Home > Articles

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Restrictions

OpenCL C implements the following restrictions. Some of these restrictions have already been described in this chapter but are also included here to provide a single place where the language restrictions are described.

  • Kernel functions have the following restrictions:
    • Arguments to kernel functions that are pointers must use the global, constant, or local qualifier.
    • An argument to a kernel function cannot be declared as a pointer to a pointer(s).
    • Arguments to kernel functions cannot be declared with the following built-in types: bool, half, size_t, ptrdiff_t, intptr_t, uintptr_t, or event_t.
    • The return type for a kernel function must be void.
    • Arguments to kernel functions that are declared to be a struct cannot pass OpenCL objects (such as buffers, images) as elements of the struct.
    • Bit field struct members are not supported.
    • Variable-length arrays and structures with flexible (or unsized) arrays are not supported.
    • Variadic macros and functions are not supported.
    • The extern, static, auto, and register storage class specifiers are not supported.
    • Predefined identifiers such as __func__ are not supported.
    • Recursion is 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 image types image2d_t and image3d_t can be specified only as the types of a function argument. They cannot be declared as local variables inside a function or as the return types of a function. An image function argument cannot be modified. An image type cannot be used with the private, local, and constant address space qualifiers. An image type cannot be used with the read_write access qualifier, which is reserved for future use. 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.
    • The sampler type sampler_t can be specified only 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 a 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.
    • The event type event_t can be used as the type of a function argument except for kernel functions or a variable declared inside a function. The event type can be used to declare an array of events. The event type can be used to declare a pointer to an event, for example, event_t *event_ptr. An event argument or variable cannot be modified. The event type cannot be used to declare a structure or union field, or for variables declared in the program scope. The event type cannot be used with the local, constant, and global address space qualifiers.
    • The behavior of irreducible control flow in a kernel is implementation-defined. Irreducible control flow is typically encountered in code that uses gotos. An example of irreducible control flow is a goto jumping inside a nested loop or a Duff's device.
  • + Share This
  • 🔖 Save To Your Account