SOCL_CreateContext

SOCL_context_t *

SOCL_CreateContextAndLoadProgram(cl_device_type dtype,

                                 unsigned int socl_create_flags,

                                 char * source_file_name)


Description

  1. SOCL_CreateContextAndLoadProgram initializes the OpenCL runtime system, selects a target device, and creates an SOCL context object to keep track of allocated resources. After the context is created, the file source_file_name is compiled with the OpenCL just-in-time compiler. 

Parameters

  1. dtype one of CL_DEVICE_TYPE_CPU, CL_DEVICE_TYPE_GPU, CL_DEVICE_TYPE_ACCELERATOR, CL_DEVICE_TYPE_DEFAULT, or CL_DEVICE_TYPE_ALL. Typically, this is CL_DEVICE_TYPE_GPU.

  2. See the OpenCL reference for clGetDeviceIDs.

  3. socl_create_flags bitwise OR of

  4. SOCL_ABORT_ON_ERROR SOCL will call exit(-1) for any unrecoverable error in calling the OpenCL runtime.

  5. SOCL_WAIT_FOR_COMPLETION SOCL operations that enqueue operations to the device will not return until the operation is complete.

  6. SOCL_COLLECT_TIMING The SOCL runtime will measure time-to-complete each major operation and write the results to SOCL.log when SOCL_Close is called.

  7. source_file_name is the name of an OpenCL program file containing kernel definitions.

Errors

  1. SOCL_CreateContext will return NULL on any error unless SOCL_ABORT_ON_ERROR is set. In the latter case, the program will terminate.

Notes

  1. SOCL_CreateContext or SOCL_CreateContextAndLoadProgram must be called before any other SOCL routines.