The use of pointers is somewhat restricted. The following rules apply:
Arguments to kernel functions declared in a program that are pointers must be declared with the __global, __constant, or __local qualifier.
A pointer declared with the __constant qualifier can only be assigned to a pointer declared with the __constant qualifier.
Pointers to functions are not allowed.
An image type ( image2d_t, image3d_t, image2d_array_t, image1d_t, image1d_buffer_t, or image1d_array_t) can only be used as the type of a function argument. An image function argument cannot be modified. Elements of an image can only be accessed using the Built-in Image Functions.
An image type cannot be used to declare a variable, a structure or union field, an array of images, a pointer to an image, or the return type of a function. An image type cannot be used with the __global, __private, __local and __constant address space qualifiers.
The sampler type (sampler_t) can only be used as the type of a function argument or a variable declared in the program scope or the outermost scope of a kernel function. The behavior of a sampler variable declared in a non-outermost scope of a kernel function is implementation-defined. A sampler argument or variable cannot be modified.
The sampler type cannot be used to declare a structure or union field, an array of samplers, a pointer to a sampler, or the return type of a function. The sampler type cannot be used with the __local and __global address space qualifiers.
Bit-fields struct members are currently not supported.
Variadic macros and functions with the exception of printf and enqueue_kernel are not supported.
The library functions defined in the C99 standard headers assert.h
,
ctype.h
, complex.h
, errno.h
,
fenv.h
, float.h
, inttypes.h
,
limits.h
, locale.h
, setjmp.h
,
signal.h
, stdarg.h
, stdio.h
,
stdlib.h
, string.h
, tgmath.h
,
time.h
, wchar.h
, and wctype.h
are not
available and cannot be included by a program.
The auto
and register
storage-class specifiers are not supported.
Recursion is not supported.
The return type of a kernel function must be void.
Arguments to kernel functions in a program cannot be declared with the built-in scalar types bool, half, size_t, ptrdiff_t, intptr_t, and uintptr_t, or a struct and/or union that contain fields declared to be one of these built-in scalar types. The size in bytes of these types except half are implementation-defined and in addition can also be different for the OpenCL device and the host processor making it difficult to allocate buffer objects to be passed as arguments to a kernel declared as pointer to these types. half is not supported as half can be used as a storage format only (unless the cl_khr_fp16 extension is supported) and is not a data type on which floating-point arithmetic can be performed.
Whether or not irreducible control flow is illegal is implementation defined.
The type qualifiers const
, restrict
and volatile
as defined by the C99
specification are supported. These qualifiers cannot be used with
image2d_t,
image3d_t,
image2d_array_t,
image2d_depth_t,
image2d_array_depth_t,
image1d_t,
image1d_buffer_t and
image1d_array_t
types. Types other than pointer types shall not use the
restrict
qualifier.
The event type (event_t) cannot be used as the type of a kernel function argument. The event type cannot be used to declare a program scope variable. The event type cannot be used to declare a structure or union field. The event type cannot be used with the __local, __constant and __global address space qualifiers.
The clk_event_t, ndrange_t and reserve_id_t types cannot be used as arguments to kernel functions that get enqueued from the host. The clk_event_t and reserve_id_t types cannot be declared in program scope.
The behavior of applying the sizeof
operator
to the queue_t, clk_event_t,
ndrange_t and reserve_id_t
types is implementation-defined.
Kernels enqueued by the host must continue to have their arguments that are a pointer to a type declared to point to a named address space.
A function in an OpenCL program cannot be called main
.
If the
cl_khr_initialize_memory
extension is enabled,
if the context is created with
CL CONTEXT MEMORY INITIALIZE KHR
, appropriate memory
locations as specified by the bit-field is
initialized with zeroes, prior to the start of execution of
any kernel. The driver chooses when, prior to
kernel execution, the initialization of local and/or
private memory is performed. The only requirement
is there should be no values set from outside
the context, which can be read during a kernel execution.