OpenCL 2.0 Reference Card Page 3
©2013 Khronos Group - Rev. 1113 www.khronos.org/opencl
Shared Virtual Memory (connued)
cl_int clEnqueueSVMMemcpy (
cl_command_queue command_queue,
cl_bool blocking_copy, void *dst_ptr,
const void *src_ptr, size_t size,
cl_uint num_events_in_wait_list,
const cl_event *event_wait_list, cl_event *event)
cl_int clEnqueueSVMMemFill (
cl_command_queue command_queue,
void *svm_ptr, const void *paern,
size_t paern_size, size_t size,
cl_uint num_events_in_wait_list,
const cl_event *event_wait_list, cl_event *event)
cl_int clEnqueueSVMMap (
cl_command_queue command_queue,
cl_bool blocking_map, cl_map_ags map_ags,
void *svm_ptr, size_t size,
cl_uint num_events_in_wait_list,
const cl_event *event_wait_list, cl_event *event)
cl_int clEnqueueSVMUnmap (
cl_command_queue command_queue,
void *svm_ptr, cl_uint num_events_in_wait_list,
const cl_event *event_wait_list, cl_event *event)
OpenCL API
Program Objects
An OpenCL program consists of a set of kernels that
are idened as funcons declared with the __kernel
qualier in the program source.
Create Program Objects [5.8.1]
cl_program clCreateProgramWithSource (
cl_context context, cl_uint count,
const char **strings, const size_t *lengths,
cl_int *errcode_ret)
cl_program clCreateProgramWithBinary (
cl_context context, cl_uint num_devices,
const cl_device_id *device_list, const size_t *lengths,
const unsigned char **binaries,
cl_int *binary_status, cl_int *errcode_ret)
cl_program clCreateProgramWithBuiltInKernels (
cl_context context, cl_uint num_devices,
const cl_device_id *device_list,
const char *kernel_names, cl_int *errcode_ret)
cl_int clRetainProgram (cl_program program)
cl_int clReleaseProgram (cl_program program)
Building Program Executables [5.8.2]
cl_int clBuildProgram (cl_program program,
cl_uint num_devices, const cl_device_id *device_list,
const char *opons, void (CL_CALLBACK*pfn_nofy)
(cl_program program, void *user_data),
void *user_data)
Separate Compilaon and Linking [5.8.3]
cl_int clCompileProgram (cl_program program,
cl_uint num_devices, const cl_device_id *device_list,
const char *opons, cl_uint num_input_headers,
const cl_program *input_headers,
const char **header_include_names,
void (CL_CALLBACK*pfn_nofy)
(cl_program program, void *user_data),
void *user_data)
cl_program clLinkProgram (cl_context context,
cl_uint num_devices, const cl_device_id *device_list,
const char *opons, cl_uint num_input_programs,
const cl_program *input_programs,
void (CL_CALLBACK*pfn_nofy)
(cl_program program, void *user_data),
void *user_data, cl_int *errcode_ret)
Unload the OpenCL Compiler [5.8.6]
cl_int clUnloadPlaormCompiler (
cl_plaorm_id plaorm)
Query Program Objects [5.8.7]
cl_int clGetProgramInfo (cl_program program,
cl_program_info param_name,
size_t param_value_size, void *param_value,
size_t *param_value_size_ret)
param_name: [Table 5.16]
CL_PROGRAM_REFERENCE_COUNT,
CL_PROGRAM_{CONTEXT, NUM_DEVICES, DEVICES},
CL_PROGRAM_{SOURCE, BINARY_SIZES, BINARIES},
CL_PROGRAM_{NUM_KERNELS, KERNEL_NAMES}
cl_int clGetProgramBuildInfo (
cl_program program, cl_device_id device,
cl_program_build_info param_name,
size_t param_value_size, void *param_value,
size_t *param_value_size_ret)
param_name: [Table 5.17]
CL_PROGRAM_BINARY_TYPE,
CL_PROGRAM_BUILD_{STATUS, OPTIONS, LOG},
CL_PRO
GRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE
Compiler Opons [5.8.4]
SPIR opons require the cl_khr_spir extension.
Preprocessor:
(-D processed in order for clBuildProgram or
clCompileProgram)
-D name -D name=denion -I dir
Math intrinsics:
-cl-single-precision-constant
-cl-denorms-are-zero
-cl-fp32-correctly-rounded-divide-sqrt
Opmizaon opons:
-cl-opt-disable -cl-mad-enable
-cl-no-signed-zeros -cl-nite-math-only
-cl-unsafe-math-opmizaons -cl-fast-relaxed-math
-cl-uniform-work-group-size
Warning request/suppress:
-w -Werror
Control OpenCL C language version:
-cl-std=CL1.1 // OpenCL 1.1 specicaon
-cl-std=CL1.2 // OpenCL 1.2 specicaon
-cl-std=CL2.0 // OpenCL 2.0 specicaon
Query kernel argument informaon:
-cl-kernel-arg-info
Debugging opons:
-g // generate addional errors for built-in
// funcons that allow you to enqueue
// commands on a device
SPIR binary opons:
-x spir // indicate that binary is in SPIR format
-spir-std=x //x is SPIR spec version, e.g.: 1.2
Linker Opons [5.8.5]
Library linking opons:
-create-library
-enable-link-opons
Program linking opons:
-cl-denorms-are-zero -cl-no-signed-zeroes
-cl-nite-math-only -cl-fast-relaxed-math
-cl-unsafe-math-opmizaons
Flush and Finish [5.15]
cl_int clFlush (cl_command_queue command_queue)
cl_int clFinish (cl_command_queue command_queue)
Event Objects
Event objects can be used to refer to a kernel execuon
command, and read, write, map and copy commands
on memory objects or user events.
Event Objects [5.11]
cl_event clCreateUserEvent (cl_context context,
cl_int *errcode_ret)
cl_int clSetUserEventStatus (cl_event event,
cl_int execuon_status)
cl_int clWaitForEvents (cl_uint num_events,
const cl_event *event_list)
cl_int clGetEventInfo (cl_event event,
cl_event_info param_name, size_t param_value_size,
void *param_value, size_t *param_value_size_ret)
param_name: CL_EVENT_COMMAND_{QUEUE, TYPE},
CL_EVENT_{CONTEXT, REFERENCE_COUNT},
CL_EVENT_COMMAND_EXECUTION_STATUS
[Table 5.22]
cl_int clRetainEvent (cl_event event)
(Connued on next page >)
Kernel Objects
A kernel is a funcon declared in a program, idened
by the __kernel qualier. A kernel object encapsulates
the specic __kernel funcon and the argument values
to be used when execung it. Items in blue apply when
the appropriate extension is supported.
Create Kernel Objects [5.9.1]
cl_kernel clCreateKernel (cl_program program,
const char *kernel_name, cl_int *errcode_ret)
cl_int clCreateKernelsInProgram (cl_program program,
cl_uint num_kernels, cl_kernel *kernels,
cl_uint *num_kernels_ret)
cl_int clRetainKernel (cl_kernel kernel)
cl_int clReleaseKernel (cl_kernel kernel)
Kernel Arguments and Queries [5.9.2, 5.9.3]
cl_int clSetKernelArg (cl_kernel kernel,
cl_uint arg_index, size_t arg_size,
const void *arg_value)
cl_int clSetKernelArgSVMPointer (cl_kernel kernel,
cl_uint arg_index, const void *arg_value)
cl_int clSetKernelExecInfo (cl_kernel kernel,
cl_kernel_exec_info param_name,
size_t param_value_size, const void *param_value)
param_name: CL_KERNEL_EXEC_INFO_SVM_PTRS,
CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM
cl_int clGetKernelInfo (cl_kernel kernel,
cl_kernel_info param_name,
size_t param_value_size, void *param_value,
size_t *param_value_size_ret)
param_name: [Table 5.19]
CL_KERNEL_FUNCTION_NAME,
CL_KERNEL_NUM_ARGS,
CL_KERNEL_REFERENCE_COUNT,
CL_KERNEL_{ATTRIBUTES, CONTEXT, PROGRAM}
cl_int clGetKernelWorkGroupInfo (cl_kernel kernel,
cl_device_id device,
cl_kernel_work_group_info param_name,
size_t param_value_size, void *param_value,
size_t *param_value_size_ret)
param_name: CL_KERNEL_GLOBAL_WORK_SIZE,
CL_KERNEL_[COMPILE_]WORK_GROUP_SIZE,
CL_KERNEL_{LOCAL, PRIVATE}_MEM_SIZE,
CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_-
MULTIPLE [Table 5.20]
cl_int clGetKernelArgInfo (cl
_
kernel kernel,
cl_uint arg_indx, cl_kernel_arg_info param_name,
size_t param_value_size, void *param_value,
size_t *param_value_size_ret)
param_name:
CL_KERNEL_ARG_{ACCESS, ADDRESS}_QUALIFIER,
CL_KERNEL_ARG_NAME,
CL_KERNEL_ARG_TYPE_{NAME, QUALIFIER} [Table 5.21]
cl_int clGetKernelSubGroupInfoKHR
(cl_kernel kernel, cl_device_id device,
cl_kernel_sub_group_info param_name,
size_t input_value_size, const void *input_value,
size_t param_value_size, void *param_value,
size_t *param_value_size_ret)
param_name:
CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE,
CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE
Execute Kernels [5.10]
cl_int clEnqueueNDRangeKernel (
cl_command_queue command_queue,
cl_kernel kernel, cl_uint work_dim,
const size_t *global_work_oset,
const size_t *global_work_size,
const size_t *local_work_size,
cl_uint num_events_in_wait_list,
const cl_event *event_wait_list, cl_event *event)
cl_int clEnqueueNaveKernel (
cl_command_queue command_queue,
void (CL_CALLBACK *user_func)(void *), void *args,
size_t cb_args, cl_uint num_mem_objects,
const cl_mem *mem_list, const void **args_mem_loc,
cl_uint num_events_in_wait_list,
const cl_event *event_wait_list, cl_event *event)