34 #if defined(ARM_COMPUTE_ASSERTS_ENABLED) 35 void printf_callback(
const char *buffer,
unsigned int len,
size_t complete,
void *user_data)
38 printf(
"%.*s", len, buffer);
53 void initialise_context_properties(
const cl::Platform &platform,
const cl::Device &device, std::array<cl_context_properties, 7> &prop)
56 #if defined(ARM_COMPUTE_ASSERTS_ENABLED) 61 std::array<cl_context_properties, 7> properties_printf =
63 CL_CONTEXT_PLATFORM,
reinterpret_cast<cl_context_properties
>(platform()),
65 CL_PRINTF_CALLBACK_ARM, reinterpret_cast<cl_context_properties>(printf_callback),
68 CL_PRINTF_BUFFERSIZE_ARM, 0x1000,
71 prop = properties_printf;
74 #endif // defined(ARM_COMPUTE_ASSERTS_ENABLED) 76 std::array<cl_context_properties, 3> properties =
78 CL_CONTEXT_PLATFORM,
reinterpret_cast<cl_context_properties
>(platform()),
81 std::copy(properties.begin(), properties.end(), prop.begin());
88 std::tuple<cl::Context, cl::Device, cl_int>
92 std::vector<cl::Platform> platforms;
93 cl::Platform::get(&platforms);
95 cl::Platform p = platforms[0];
97 std::vector<cl::Device> platform_devices;
98 p.getDevices(CL_DEVICE_TYPE_DEFAULT, &platform_devices);
100 device = platform_devices[0];
101 cl_int err = CL_SUCCESS;
102 std::array<cl_context_properties, 7> properties = { 0, 0, 0, 0, 0, 0, 0 };
103 initialise_context_properties(p, device, properties);
104 cl::Context cl_context = cl::Context(device, properties.data(),
nullptr,
nullptr, &err);
106 return std::make_tuple(cl_context, device, err);
static CLScheduler & get()
Access the scheduler singleton.
void schedule_kernel_on_ctx(CLRuntimeContext *ctx, ICLKernel *kernel, bool flush=true)
Schedules a kernel using the context if not nullptr else uses the legacy scheduling flow...
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
std::tuple< cl::Context, cl::Device, cl_int > create_opencl_context_and_device()
This function creates an OpenCL context and a device.
SimpleTensor< T > copy(const SimpleTensor< T > &src, const TensorShape &output_shape)
Common interface for all the OpenCL kernels.
Copyright (c) 2017-2021 Arm Limited.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
void enqueue(ICLKernel &kernel, bool flush=true)
Schedule the execution of the passed kernel if possible.
bool device_supports_extension(const cl::Device &device, const char *extension_name)
Helper function to check whether a given extension is supported.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
CLScheduler * gpu_scheduler()
bool opencl_is_available()
Check if OpenCL is available.