See www.khronos.org/opencl for the full specicaon.©2009 Khronos Group - Rev. 0309
OpenCL
TM
API 1.0 Quick Reference Card
The OpenCL Runme
Command Queues [5.1]
cl_command_queue clCreateCommandQueue (
cl_context context, cl_device_id device,
cl_command_queue_properes properes,
cl_int *errcode_ret)
properes: CL_QUEUE_PROFILING_ENABLE,
CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ ENABLE
cl_int clRetainCommandQueue (cl_command_queue
command_queue)
cl_int clReleaseCommandQueue (cl_command_queue
command_queue)
cl_int clGetCommandQueueInfo (
cl_command_queue command_queue,
cl_command_queue_info param_name,
size_t param_value_size, void *param_value,
size_t *param_value_size_ret)
param_name: CL_QUEUE_CONTEXT,
CL_QUEUE_DEVICE,
CL_QUEUE_REFERENCE_COUNT,
CL_QUEUE_PROPERTIES
cl_int clSetCommandQueueProperty (cl_command_queue
command_queue, cl_command_queue_properes
properes, cl_bool enable,
cl_command_queue_properes *old_properes)
properes:
CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ ENABLE,
CL_QUEUE_PROFILING_ENABLE
OpenCL (Open Compung Language) is a mul-
vendor open standard for general-purpose parallel
programming of heterogeneous systems that
include CPUs, GPUs and other processors. OpenCL
provides a uniform programming environment for
soware developers to write ecient, portable code
for high-performance compute servers, desktop
computer systems and handheld devices.
[n.n.n] refers to the secon in the API Specicaon
available at www.khronos.org/opencl.
Memory Objects
Memory objects include buer objects, and image objects. Refer
to the Graphic page for informaon about image objects.
A buer object stores a one-dimensional collecon of elements.
Elements of a buer object can be a scalar data type (such an
int, oat), vector data type, or a user-dened structure, and are
stored in sequenal fashion and can be accessed using a pointer
by a kernel execung on a device. The data is stored in the same
format as it is accessed by the kernel.
Create Buer Objects [5.2.1]
cl_mem clCreateBuer (cl_context context,
cl_mem_ags ags, size_t size, void *host_ptr,
cl_int *errcode_ret)
ags: CL_MEM_READ_WRITE,
CL_MEM_WRITE_ONLY,
CL_MEM_READ_ONLY,
CL_MEM_USE_HOST_PTR,
CL_MEM_ALLOC_HOST_PTR,
CL_MEM_COPY_HOST_PTR
Read, Write, Copy Buer Objects [5.2.2 - 5.2.3]
cl_int clEnqueueReadBuer (
cl_command_queue command_queue, cl_mem buer,
cl_bool blocking_read, size_t oset, size_t cb,
void *ptr, cl_uint num_events_in_wait_list,
const cl_event *event_wait_list, cl_event *event)
cl_int clEnqueueWriteBuer (
cl_command_queue command_queue, cl_mem buer,
cl_bool blocking_write, size_t oset, size_t cb,
const void *ptr, cl_uint num_events_in_wait_list,
const cl_event *event_wait_list, cl_event *event)
cl_int clEnqueueCopyBuer (
cl_command_queue command_queue,
cl_mem src_buer, cl_mem dst_buer, size_t src_oset,
size_t dst_oset, size_t cb,
cl_uint num_events_in_wait_list,
const cl_event *event_wait_list, cl_event *event)
cl_int clRetainMemObject (cl_mem memobj)
cl_int clReleaseMemObject (cl_mem memobj)
Map and Unmap Memory Objects [5.2.8]
void * clEnqueueMapBuer (
cl_command_queue command_queue, cl_mem buer,
cl_bool blocking_map, cl_map_ags map_ags,
size_t oset, size_t cb, cl_uint num_events_in_wait_list,
const cl_event *event_wait_list, cl_event *event,
cl_int *errcode_ret)
cl_int clEnqueueUnmapMemObject (
cl_command_queue command_queue, cl_mem memobj,
void *mapped_ptr, cl_uint num_events_in_wait_list,
const cl_event *event_wait_list, cl_event *event)
Query Buer Object [5.2.9]
cl_int clGetMemObjectInfo (cl_mem memobj,
cl_mem_info param_name, size_t param_value_size,
void *param_value, size_t *param_value_size_ret)
param_name: CL_MEM_TYPE,
CL_MEM_FLAGS, CL_MEM_SIZE,
CL_MEM_HOST_PTR, CL_MEM_MAP_COUNT,
CL_MEM_REFERENCE_COUNT, CL_MEM_CONTEXT
Program Objects
Create Program Objects [5.4.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_int clRetainProgram (cl_program program)
cl_int clReleaseProgram (cl_program program)
Build Program Executable [5.4.2]
cl_int clBuildProgram (cl_program program,
cl_uint num_devices, const cl_device_id *device_list,
const char *opons, void (*pfn_nofy)
(cl_program, void *user_data), void *user_data)
Build Opons [5.4.3]
Preprocessor opons:
(-D opons processed in order listed in clBuildProgram)
-D name,
-D name=denion,
-I dir
Math Intrinsics opons:
-cl-single-precision-constant,
-cl-denorms-are-zero,
Opmizaon opons:
-cl-opt-disable, -cl-strict-aliasing,
-cl-mad-enable, -cl-no-signed-zeros,
-cl-nite-math-only, -cl-fast-relaxed-math,
-cl-unsafe-math-opmizaons
Warning request/suppress opons:
-w, -Werror
Unload the OpenCL Compiler [5.4.4]
cl_int clUnloadCompiler (void)
Query Program Objects [5.4.5]
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_value: CL_PROGRAM_REFERENCE_COUNT,
CL_PROGRAM_CONTEXT,
CL_PROGRAM_NUM_DEVICES,
CL_PROGRAM_DEVICES,
CL_PROGRAM_BINARY_SIZES,
CL_PROGRAM_BINARIES
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: CL_PROGRAM_BUILD_STATUS,
CL_PROGRAM_BUILD_OPTIONS,
CL_PROGRAM_BUILD_LOG
The OpenCL Plaorm Layer
The OpenCL plaorm layer which implements plaorm-specic features that allow applicaons to query OpenCL devices, device
conguraon informaon, and to create OpenCL contexts using one or more devices.
Contexts [4.3]
cl_context clCreateContext (
cl_context_properes *properes, cl_uint num_devices,
const cl_device_id *devices, void (*pfn_nofy)
(const char *errinfo, const void *private_info, size_t cb,
void *user_data), void *user_data, cl_int *errcode_ret)
cl_context clCreateContextFromType (
cl_context_properes *properes,
cl_device_type device_type, void (*pfn_nofy)
(const char *errinfo, const void *private_info,
size_t cb, void *user_data), void *user_data,
cl_int *errcode_ret)
cl_int clRetainContext (cl_context context)
cl_int clReleaseContext (cl_context context)
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)
param_name: CL_CONTEXT_REFERENCE_COUNT,
CL_CONTEXT_DEVICES,
CL_CONTEXT_PROPERTIES
Querying Plaorm Info and Devices [4.1, 4.2]
cl_int clGetPlaormInfo (cl_plaorm_info param_name,
size_t param_value_size, void *param_value,
size_t *param_value_size_ret)
param_name: CL_PLATFORM_PROFILE,
CL_PLATFORM_VERSION
cl_int clGetDeviceIDs (cl_device_type device_type,
cl_uint num_entries, cl_device_id *devices,
cl_uint *num_devices)
device_type: CL_DEVICE_TYPE_CPU,
CL_DEVICE_TYPE_GPU,
CL_DEVICE_TYPE_ACCELERATOR,
CL_DEVICE_TYPE_DEFAULT, CL_DEVICE_TYPE_ALL
cl_int clGetDeviceInfo (cl_device_id device,
cl_device_info param_name,
size_t param_value_size, void *param_value,
size_t *param_value_size_ret)
param_name: CL_DEVICE_TYPE,
CL_DEVICE_VENDOR_ID,
CL_DEVICE_MAX_COMPUTE_UNITS,
CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS,
CL_DEVICE_MAX_WORK_ITEM_SIZES,
CL_DEVICE_MAX_WORK_GROUP_SIZE,
CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR,
CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT,
CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT,
CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG,
CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT,
CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE,
CL_DEVICE_MAX_CLOCK_FREQUENCY,
CL_DEVICE_ADDRESS_BITS,
CL_DEVICE_MAX_MEM_ALLOC_SIZE,
CL_DEVICE_IMAGE_SUPPORT,
CL_DEVICE_MAX_READ_IMAGE_ARGS,
CL_DEVICE_MAX_WRITE_IMAGE_ARGS,
CL_DEVICE_IMAGE2D_MAX_WIDTH,
CL_DEVICE_IMAGE2D_MAX_HEIGHT,
CL_DEVICE_IMAGE3D_MAX_WIDTH,
CL_DEVICE_IMAGE3D_MAX_HEIGHT,
CL_DEVICE_IMAGE3D_MAX_DEPTH,
CL_DEVICE_MAX_SAMPLERS,
CL_DEVICE_MAX_PARAMETER_SIZE,
CL_DEVICE_MEM_BASE_ADDR_ALIGN,
CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE,
CL_DEVICE_SINGLE_FP_CONFIG,
CL_DEVICE_GLOBAL_MEM_CACHE_TYPE,
CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE,
CL_DEVICE_GLOBAL_MEM_CACHE_SIZE,
CL_DEVICE_GLOBAL_MEM_SIZE,
CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE,
CL_DEVICE_MAX_CONSTANT_ARGS,
CL_DEVICE_LOCAL_MEM_TYPE,
CL_DEVICE_LOCAL_MEM_SIZE,
CL_DEVICE_ERROR_CORRECTION_SUPPORT,
CL_DEVICE_PROFILING_TIMER_RESOLUTION,
CL_DEVICE_ENDIAN_LITTLE,
CL_DEVICE_AVAILABLE,
CL_DEVICE_COMPILER_AVAILABLE,
CL_DEVICE_EXECUTION_CAPABILITIES,
CL_DEVICE_QUEUE_PROPERTIES,
CL_DEVICE_NAME,
CL_DEVICE_VENDOR,
CL_DRIVER_VERSION, CL_DEVICE_PROFILE,
CL_DEVICE_VERSION, CL_DEVICE_EXTENSIONS
https://cvs.khronos.org/svn/repos/registry/trunk
/public/cl/sdk/1.0/docs/man/xhtml/