aboutsummaryrefslogtreecommitdiff
path: root/arm_compute
diff options
context:
space:
mode:
authorMichalis Spyrou <michalis.spyrou@arm.com>2021-04-20 11:26:21 +0100
committerGeorgios Pinitas <georgios.pinitas@arm.com>2021-04-21 20:48:28 +0000
commit402740da11c4fd2a9dc7aee5dadf3b1fdda0afde (patch)
tree61501d2f0af7115b87d26907d6ca9a3d00f4ef5e /arm_compute
parentbff2f9f2f92bf7a8d2f7532df0329dedfbe84693 (diff)
downloadComputeLibrary-402740da11c4fd2a9dc7aee5dadf3b1fdda0afde.tar.gz
Add support for CLVK
This patch enables CLVK through the graph API and inside the CLScheduler. By default the Native platform is selected. Selecting CLVK can be done via --target=clvk. Resolves COMPMID-4205 and COMPMID-4206 Change-Id: Ic60744980c6b8a60e776627ea677ed46be88f656 Signed-off-by: Michalis Spyrou <michalis.spyrou@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5475 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Diffstat (limited to 'arm_compute')
-rw-r--r--arm_compute/core/CL/OpenCL.h1
-rw-r--r--arm_compute/graph/TypePrinter.h3
-rw-r--r--arm_compute/graph/Types.h24
-rw-r--r--arm_compute/graph/backends/CL/CLDeviceBackend.h2
-rw-r--r--arm_compute/runtime/CL/CLHelpers.h15
-rw-r--r--arm_compute/runtime/CL/CLRuntimeContext.h4
-rw-r--r--arm_compute/runtime/CL/CLScheduler.h26
-rw-r--r--arm_compute/runtime/CL/CLTypes.h7
8 files changed, 59 insertions, 23 deletions
diff --git a/arm_compute/core/CL/OpenCL.h b/arm_compute/core/CL/OpenCL.h
index 155c3e4eef..1e6b04c042 100644
--- a/arm_compute/core/CL/OpenCL.h
+++ b/arm_compute/core/CL/OpenCL.h
@@ -123,6 +123,7 @@ public:
DECLARE_FUNCTION_PTR(clGetDeviceIDs);
DECLARE_FUNCTION_PTR(clGetMemObjectInfo);
DECLARE_FUNCTION_PTR(clRetainEvent);
+ DECLARE_FUNCTION_PTR(clGetPlatformInfo);
DECLARE_FUNCTION_PTR(clGetPlatformIDs);
DECLARE_FUNCTION_PTR(clGetKernelWorkGroupInfo);
DECLARE_FUNCTION_PTR(clGetCommandQueueInfo);
diff --git a/arm_compute/graph/TypePrinter.h b/arm_compute/graph/TypePrinter.h
index 317c5a7596..0bbb4695de 100644
--- a/arm_compute/graph/TypePrinter.h
+++ b/arm_compute/graph/TypePrinter.h
@@ -48,6 +48,9 @@ inline ::std::ostream &operator<<(::std::ostream &os, const Target &target)
case Target::CL:
os << "CL";
break;
+ case Target::CLVK:
+ os << "CLVK";
+ break;
default:
ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
}
diff --git a/arm_compute/graph/Types.h b/arm_compute/graph/Types.h
index 4f3ce76370..7306b82a1e 100644
--- a/arm_compute/graph/Types.h
+++ b/arm_compute/graph/Types.h
@@ -28,6 +28,7 @@
#include "arm_compute/core/PixelValue.h"
#include "arm_compute/core/Types.h"
#include "arm_compute/runtime/CL/CLTunerTypes.h"
+#include "arm_compute/runtime/CL/CLTypes.h"
#include <limits>
#include <string>
@@ -37,6 +38,7 @@ namespace arm_compute
namespace graph
{
using arm_compute::CLTunerMode;
+using arm_compute::CLBackendType;
using arm_compute::Status;
using arm_compute::Coordinates;
@@ -80,16 +82,17 @@ struct TensorDescriptor;
/** Graph configuration structure */
struct GraphConfig
{
- bool use_function_memory_manager{ true }; /**< Use a memory manager to manage per-function auxilary memory */
- bool use_function_weights_manager{ true }; /**< Use a weights manager to manage transformed weights */
- bool use_transition_memory_manager{ true }; /**< Use a memory manager to manager transition buffer memory */
- bool use_tuner{ false }; /**< Use a tuner in tunable backends */
- bool use_synthetic_type{ false }; /**< Convert graph to a synthetic graph for a data type */
- DataType synthetic_type{ DataType::QASYMM8 }; /**< The data type of the synthetic graph */
- CLTunerMode tuner_mode{ CLTunerMode::EXHAUSTIVE }; /**< Tuner mode to be used by the CL tuner */
- int num_threads{ -1 }; /**< Number of threads to use (thread capable backends), if 0 the backend will auto-initialize, if -1 the backend will stay as it is. */
- std::string tuner_file{ "acl_tuner.csv" }; /**< File to load/store tuning values from */
- std::string mlgo_file{ "heuristics.mlgo" }; /**< Filename to load MLGO heuristics from */
+ bool use_function_memory_manager{ true }; /**< Use a memory manager to manage per-function auxilary memory */
+ bool use_function_weights_manager{ true }; /**< Use a weights manager to manage transformed weights */
+ bool use_transition_memory_manager{ true }; /**< Use a memory manager to manager transition buffer memory */
+ bool use_tuner{ false }; /**< Use a tuner in tunable backends */
+ bool use_synthetic_type{ false }; /**< Convert graph to a synthetic graph for a data type */
+ DataType synthetic_type{ DataType::QASYMM8 }; /**< The data type of the synthetic graph */
+ CLTunerMode tuner_mode{ CLTunerMode::EXHAUSTIVE }; /**< Tuner mode to be used by the CL tuner */
+ int num_threads{ -1 }; /**< Number of threads to use (thread capable backends), if 0 the backend will auto-initialize, if -1 the backend will stay as it is. */
+ std::string tuner_file{ "acl_tuner.csv" }; /**< File to load/store tuning values from */
+ std::string mlgo_file{ "heuristics.mlgo" }; /**< Filename to load MLGO heuristics from */
+ CLBackendType backend_type{ CLBackendType::Native }; /**< CL backend type to use */
};
/**< Device target types */
@@ -98,6 +101,7 @@ enum class Target
UNSPECIFIED, /**< Unspecified Target */
NEON, /**< Arm® Neon™ capable target device */
CL, /**< OpenCL capable target device */
+ CLVK, /**< CLVK capable target device */
};
/** Supported Element-wise operations */
diff --git a/arm_compute/graph/backends/CL/CLDeviceBackend.h b/arm_compute/graph/backends/CL/CLDeviceBackend.h
index 82c0eacd11..278a8e5031 100644
--- a/arm_compute/graph/backends/CL/CLDeviceBackend.h
+++ b/arm_compute/graph/backends/CL/CLDeviceBackend.h
@@ -28,6 +28,7 @@
#include "arm_compute/runtime/CL/CLBufferAllocator.h"
#include "arm_compute/runtime/CL/CLGEMMHeuristicsHandle.h"
+#include "arm_compute/runtime/CL/CLTypes.h"
#include "arm_compute/runtime/CL/CLTuner.h"
namespace arm_compute
@@ -76,6 +77,7 @@ private:
CLGEMMHeuristicsHandle _gemm_heuristics; /**< GEMM heuristics */
std::unique_ptr<CLBufferAllocator> _allocator; /**< CL buffer affinity allocator */
std::string _tuner_file; /**< Filename to load/store the tuner's values from */
+ CLBackendType _backend_type; /**< OpenCL backend type to use */
};
} // namespace backends
} // namespace graph
diff --git a/arm_compute/runtime/CL/CLHelpers.h b/arm_compute/runtime/CL/CLHelpers.h
index 9b71561c39..fef2619071 100644
--- a/arm_compute/runtime/CL/CLHelpers.h
+++ b/arm_compute/runtime/CL/CLHelpers.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Arm Limited.
+ * Copyright (c) 2019-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -25,6 +25,7 @@
#define ARM_COMPUTE_CL_HELPERS_H
#include "arm_compute/core/CL/OpenCL.h"
+#include "arm_compute/runtime/CL/CLTypes.h"
#include "arm_compute/runtime/IScheduler.h"
namespace arm_compute
@@ -37,11 +38,13 @@ class ICLKernel;
*
* @note In debug builds, the function will automatically enable cl_arm_printf if the driver/device supports it.
*
+ * @param[in] cl_backend_type The OpenCL backend type to use.
+ *
* @return A std::tuple where the first element is the opencl context, the second element is the opencl device
* and the third one an error code. The error code will be CL_SUCCESS upon successful creation, otherwise
* a value telling why the function failed.
*/
-std::tuple<cl::Context, cl::Device, cl_int> create_opencl_context_and_device();
+std::tuple<cl::Context, cl::Device, cl_int> create_opencl_context_and_device(CLBackendType cl_backend_type);
/** Schedules a kernel using the context if not nullptr else uses the legacy scheduling flow.
*
* @param[in] ctx Context to use.
@@ -49,5 +52,13 @@ std::tuple<cl::Context, cl::Device, cl_int> create_opencl_context_and_device();
* @param[in] flush (Optional) Specifies if the command queue will be flushed after running the kernel.
*/
void schedule_kernel_on_ctx(CLRuntimeContext *ctx, ICLKernel *kernel, bool flush = true);
+
+/** This function selects the OpenCL platform based on the backend type.
+ *
+ * @param[in] cl_backend_type The OpenCL backend type to use.
+ *
+ * @return A cl::Platform object.
+ */
+cl::Platform select_preferable_platform(CLBackendType cl_backend_type);
} // namespace arm_compute
#endif /* ARM_COMPUTE_CL_HELPERS_H */
diff --git a/arm_compute/runtime/CL/CLRuntimeContext.h b/arm_compute/runtime/CL/CLRuntimeContext.h
index 083ac0ab88..4ab8f70887 100644
--- a/arm_compute/runtime/CL/CLRuntimeContext.h
+++ b/arm_compute/runtime/CL/CLRuntimeContext.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2020 Arm Limited.
+ * Copyright (c) 2019-2021 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -29,6 +29,7 @@
#include "arm_compute/core/CL/OpenCL.h"
#include "arm_compute/runtime/CL/CLScheduler.h"
#include "arm_compute/runtime/CL/CLTuner.h"
+#include "arm_compute/runtime/CL/CLTypes.h"
#include "arm_compute/runtime/IScheduler.h"
#include "arm_compute/runtime/RuntimeContext.h"
@@ -60,6 +61,7 @@ private:
CLTuner _tuner{ false };
CLSymbols _symbols{};
CLCoreRuntimeContext _core_context{};
+ CLBackendType _backend_type{ CLBackendType::Native };
};
} // namespace arm_compute
#endif /*ARM_COMPUTE_CLRUNTIME_CONTEXT_H */
diff --git a/arm_compute/runtime/CL/CLScheduler.h b/arm_compute/runtime/CL/CLScheduler.h
index 41a074089e..56852aec6e 100644
--- a/arm_compute/runtime/CL/CLScheduler.h
+++ b/arm_compute/runtime/CL/CLScheduler.h
@@ -31,6 +31,8 @@
#include "arm_compute/core/Types.h"
#include "arm_compute/core/experimental/Types.h"
#include "arm_compute/runtime/CL/CLGEMMHeuristicsHandle.h"
+#include "arm_compute/runtime/CL/CLHelpers.h"
+#include "arm_compute/runtime/CL/CLTypes.h"
#include "arm_compute/runtime/CL/ICLTuner.h"
namespace arm_compute
@@ -57,10 +59,11 @@ public:
/** Initialises the context and command queue used by the scheduler to default values
* and sets a default device and kernel path for the @ref CLKernelLibrary.
*
- * @param[in] cl_tuner (Optional) Pointer to ICLTuner (default=nullptr)
- * @param[in] gemm_h (Optional) Pointer to CLGEMMHeuristicsHandle (default = nullptr)
+ * @param[in] cl_tuner (Optional) Pointer to ICLTuner (default=nullptr)
+ * @param[in] gemm_h (Optional) Pointer to CLGEMMHeuristicsHandle (default = nullptr)
+ * @param[in] cl_backend_type (Optional) Type of backend to use (default = CLBackendType::Native)
*/
- void default_init(ICLTuner *cl_tuner = nullptr, CLGEMMHeuristicsHandle *gemm_h = nullptr);
+ void default_init(ICLTuner *cl_tuner = nullptr, CLGEMMHeuristicsHandle *gemm_h = nullptr, CLBackendType cl_backend_type = CLBackendType::Native);
/** Initialises the scheduler with context and device provided by the user
*
* @param[in] device OpenCL device to be used
@@ -86,14 +89,16 @@ public:
/** Initialises the context and command queue to be used by the scheduler.
*
- * @param[in] context A CL context.
- * @param[in] queue A CL command queue.
- * @param[in] device A CL device.
- * @param[in] cl_tuner (Optional) Pointer to OpenCL tuner (default=nullptr)
- * Note: It is caller's responsibility to release the allocated memory for CLTuner
- * @param[in] gemm_h (Optional) Pointer to CLGEMMHeuristicsHandle (default = nullptr)
+ * @param[in] context A CL context.
+ * @param[in] queue A CL command queue.
+ * @param[in] device A CL device.
+ * @param[in] cl_tuner (Optional) Pointer to OpenCL tuner (default=nullptr)
+ * Note: It is caller's responsibility to release the allocated memory for CLTuner
+ * @param[in] gemm_h (Optional) Pointer to CLGEMMHeuristicsHandle (default = nullptr)
+ * @param[in] cl_backend_type (Optional) Type of backend to use (default = CLBackendType::Native)
*/
- void init(cl::Context context, cl::CommandQueue queue, const cl::Device &device, ICLTuner *cl_tuner = nullptr, CLGEMMHeuristicsHandle *gemm_h = nullptr);
+ void init(cl::Context context, cl::CommandQueue queue, const cl::Device &device, ICLTuner *cl_tuner = nullptr, CLGEMMHeuristicsHandle *gemm_h = nullptr,
+ CLBackendType cl_backend_type = CLBackendType::Native);
/** Accessor for the associated CL context.
*
@@ -171,6 +176,7 @@ private:
bool _is_initialised;
ICLTuner *_cl_tuner;
CLGEMMHeuristicsHandle *_gemm_heuristics;
+ CLBackendType _backend_type;
};
} // namespace arm_compute
#endif /* ARM_COMPUTE_CLSCHEDULER_H */
diff --git a/arm_compute/runtime/CL/CLTypes.h b/arm_compute/runtime/CL/CLTypes.h
index ab973f973c..cf0486c8c3 100644
--- a/arm_compute/runtime/CL/CLTypes.h
+++ b/arm_compute/runtime/CL/CLTypes.h
@@ -58,5 +58,12 @@ struct CLGEMMKernelSelectionParams
bool is_rhs_constant{ false }; /**< True if the content of the rhs matrix is constant */
DataType data_type{ DataType::UNKNOWN }; /**< Data type */
};
+
+/** List the possible OpenCL backends */
+enum class CLBackendType
+{
+ Native, /**< OpenCL native backend */
+ Clvk, /**< CLVK backend */
+};
} // namespace arm_compute
#endif /* ARM_COMPUTE_RUNTIME_CLTYPES_H */