Restrictions

  • 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, __local, or __global qualifier can only be assigned to a pointer declared with the __constant, __local, or __global qualifier respectively.

    • Pointers to functions are not allowed.

    • Arguments to __kernel functions in a program cannot be declared as a pointer to a pointer(s). Variables inside a function or arguments to non __kernel functions in a program can be declared as a pointer to a pointer(s).

  • Variables that are declared to be of type image2d_t or image3d_t refer to image memory objects. These can only be specified as arguments to a function. Elements of an image cannot be directly accessed. Specific built-in image read and write functions are provided to read from and write to any location in the image. Pointers to image2d_t or image3d_t are not allowed. image2d_t or image3d_t data types cannot be declared in a struct. image2d_t and image3d_t cannot be used to declare local variables or as the return type of a function. An image2d_t or image3d_t argument to a function cannot be modified.

    Samplers cannot be declared as arrays, pointers, or be used as the type for local variables inside a function or as the return value of a function defined in a program. Samplers cannot be passed as arguments to functions called by a __kernel function. A sampler argument to a __kernel function cannot be modified.

  • Bit-fields are currently not supported.

  • Variable length arrays and structures with flexible (or unsized) arrays are not supported.

  • Variadic macros and functions are not supported.

  • 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 extern, static, auto, and register storage-class specifiers are not supported.

  • Predefined identifiers are not supported.

  • Recursion is not supported.

  • The function using the __kernel qualifier can only have return type void in the source code.

  • 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. 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 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.

  • Built-in types that are less than 32-bits in size i.e. char, uchar, char2, uchar2, short, ushort, and half have the following restriction:

    Writes to a pointer (or arrays) of type char, uchar, char2, uchar2, short, ushort, and half or to elements of a struct that are of type char, uchar, char2, uchar2, short, and ushort are not supported.

    The kernel example below shows what memory operations are not supported on built-in types less than 32-bits in size.


              kernel void
              do_proc (__global char *pA, short b,
                             __global short *pB)
              {
                    char            x[100];
                    __private char  *px = x;
                    int             id = (int)get_global_id(0);
                    short           f;
                    f = pB[id] + b; // is allowed
                    px[1] = pA[1];  // error. px cannot be written.
                    pB[id] = b;   // error. pB cannot be written
              }

  • Arguments to __kernel functions in a program cannot be declared to be of type event_t.

  • Elements of a struct or union must belong to the same address space. Declaring a struct or union whose elements are in different address spaces is illegal.

Specification

OpenCL Specification

Also see

Image Functions, Function Qualifiers

Copyright © Copyright © 2007-2009 The Khronos Group Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials.