aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SConscript2
-rw-r--r--arm_compute/core/CL/OpenCL.h3
-rw-r--r--arm_compute/runtime/CL/CLScheduler.h23
-rw-r--r--src/core/CL/OpenCL.cpp58
4 files changed, 71 insertions, 15 deletions
diff --git a/SConscript b/SConscript
index 2544d1f64c..c7779ca8f7 100644
--- a/SConscript
+++ b/SConscript
@@ -235,7 +235,7 @@ if env['neon'] and env['opencl']:
Export('arm_compute_graph_a')
arm_compute_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']])
- arm_compute_graph_so = build_library('arm_compute_graph', shared_graph_objects, static=False, libs = [ "arm_compute", "arm_compute_core", "OpenCL" ])
+ arm_compute_graph_so = build_library('arm_compute_graph', shared_graph_objects, static=False, libs = [ "arm_compute", "arm_compute_core"])
Depends(arm_compute_graph_so, arm_compute_so)
Depends(arm_compute_graph_so, opencl)
Export('arm_compute_graph_so')
diff --git a/arm_compute/core/CL/OpenCL.h b/arm_compute/core/CL/OpenCL.h
index 8a2d30bb83..e389b867a9 100644
--- a/arm_compute/core/CL/OpenCL.h
+++ b/arm_compute/core/CL/OpenCL.h
@@ -57,6 +57,9 @@ public:
#define DECLARE_FUNCTION_PTR(func_name) \
std::function<decltype(func_name)> func_name##_ptr = nullptr
+ DECLARE_FUNCTION_PTR(clCreateContextFromType);
+ DECLARE_FUNCTION_PTR(clCreateCommandQueue);
+ DECLARE_FUNCTION_PTR(clGetContextInfo);
DECLARE_FUNCTION_PTR(clBuildProgram);
DECLARE_FUNCTION_PTR(clEnqueueNDRangeKernel);
DECLARE_FUNCTION_PTR(clSetKernelArg);
diff --git a/arm_compute/runtime/CL/CLScheduler.h b/arm_compute/runtime/CL/CLScheduler.h
index f700bbb679..91bfe5b213 100644
--- a/arm_compute/runtime/CL/CLScheduler.h
+++ b/arm_compute/runtime/CL/CLScheduler.h
@@ -39,18 +39,6 @@ void printf_callback(const char *buffer, unsigned int len, size_t complete, void
{
printf("%.*s", len, buffer);
}
-
-// Create a cl_context with a printf_callback and user specified buffer size.
-cl_context_properties properties[] =
-{
- // Enable a printf callback function for this context.
- CL_PRINTF_CALLBACK_ARM, reinterpret_cast<cl_context_properties>(printf_callback),
- // Request a minimum printf buffer size of 4MB for devices in the
- // context that support this extension.
- CL_PRINTF_BUFFERSIZE_ARM, static_cast<cl_context_properties>(0x100000),
- CL_CONTEXT_PLATFORM, reinterpret_cast<cl_context_properties>(cl::Platform::get()()),
- 0
-};
}
#endif /* defined(ARM_COMPUTE_DEBUG_ENABLED) */
@@ -83,6 +71,17 @@ public:
void default_init(ICLTuner *cl_tuner = nullptr)
{
#if defined(ARM_COMPUTE_DEBUG_ENABLED)
+ // Create a cl_context with a printf_callback and user specified buffer size.
+ cl_context_properties properties[] =
+ {
+ // Enable a printf callback function for this context.
+ CL_PRINTF_CALLBACK_ARM, reinterpret_cast<cl_context_properties>(printf_callback),
+ // Request a minimum printf buffer size of 4MB for devices in the
+ // context that support this extension.
+ CL_PRINTF_BUFFERSIZE_ARM, static_cast<cl_context_properties>(0x100000),
+ CL_CONTEXT_PLATFORM, reinterpret_cast<cl_context_properties>(cl::Platform::get()()),
+ 0
+ };
cl::Context::setDefault(cl::Context(CL_DEVICE_TYPE_DEFAULT, properties));
#endif // defined(ARM_COMPUTE_DEBUG_ENABLED)
diff --git a/src/core/CL/OpenCL.cpp b/src/core/CL/OpenCL.cpp
index 157b6d6820..726279c6ea 100644
--- a/src/core/CL/OpenCL.cpp
+++ b/src/core/CL/OpenCL.cpp
@@ -74,8 +74,9 @@ bool CLSymbols::load(const std::string &library)
#define LOAD_FUNCTION_PTR(func_name, handle) \
func_name##_ptr = reinterpret_cast<decltype(func_name) *>(dlsym(handle, #func_name));
- LOAD_FUNCTION_PTR(clBuildProgram, handle);
- LOAD_FUNCTION_PTR(clEnqueueNDRangeKernel, handle);
+ LOAD_FUNCTION_PTR(clCreateContextFromType, handle);
+ LOAD_FUNCTION_PTR(clCreateCommandQueue, handle);
+ LOAD_FUNCTION_PTR(clGetContextInfo, handle);
LOAD_FUNCTION_PTR(clBuildProgram, handle);
LOAD_FUNCTION_PTR(clEnqueueNDRangeKernel, handle);
LOAD_FUNCTION_PTR(clSetKernelArg, handle);
@@ -125,6 +126,59 @@ bool opencl_is_available()
}
} // namespace arm_compute
+cl_int clGetContextInfo(cl_context context,
+ cl_context_info param_name,
+ size_t param_value_size,
+ void *param_value,
+ size_t *param_value_size_ret)
+{
+ arm_compute::CLSymbols::get().load_default();
+ auto func = arm_compute::CLSymbols::get().clGetContextInfo_ptr;
+ if(func != nullptr)
+ {
+ return func(context, param_name, param_value_size, param_value, param_value_size_ret);
+ }
+ else
+ {
+ return CL_OUT_OF_RESOURCES;
+ }
+}
+
+cl_command_queue clCreateCommandQueue(cl_context context,
+ cl_device_id device,
+ cl_command_queue_properties properties,
+ cl_int *errcode_ret)
+{
+ arm_compute::CLSymbols::get().load_default();
+ auto func = arm_compute::CLSymbols::get().clCreateCommandQueue_ptr;
+ if(func != nullptr)
+ {
+ return func(context, device, properties, errcode_ret);
+ }
+ else
+ {
+ return nullptr;
+ }
+}
+
+cl_context clCreateContextFromType(const cl_context_properties *properties,
+ cl_device_type device_type,
+ void (*pfn_notify)(const char *, const void *, size_t, void *),
+ void *user_data,
+ cl_int *errcode_ret)
+{
+ arm_compute::CLSymbols::get().load_default();
+ auto func = arm_compute::CLSymbols::get().clCreateContextFromType_ptr;
+ if(func != nullptr)
+ {
+ return func(properties, device_type, pfn_notify, user_data, errcode_ret);
+ }
+ else
+ {
+ return nullptr;
+ }
+}
+
cl_int clBuildProgram(
cl_program program,
cl_uint num_devices,