Description

The functionality described in this section requires support for OpenCL C 2.0, or OpenCL C 3.0 or newer and the __opencl_c_generic_address_space feature.

This section describes built-in functions to safely convert from pointers to the generic address space to pointers to named address spaces, and to query the appropriate fence flags for a pointer to the generic address space. We use the generic type name gentype to indicate any of the built-in data types supported by OpenCL C or a user defined type.

Table 1. Built-in Address Space Qualifier Functions

Function

Description

global gentype * to_global(gentype *ptr)
const global gentype * to_global(const gentype *ptr)

Returns a pointer that points to a region in the global address space if to_global can cast ptr to the global address space. Otherwise it returns NULL.

local gentype * to_local(gentype *ptr)
const local gentype * to_local(const gentype *ptr)

Returns a pointer that points to a region in the local address space if to_local can cast ptr to the local address space. Otherwise it returns NULL.

private gentype * to_private(gentype *ptr)
const private gentype * to_private(const gentype *ptr)

Returns a pointer that points to a region in the private address space if to_private can cast ptr to the private address space. Otherwise it returns NULL.

cl_mem_fence_flags get_fence(gentype *ptr)
cl_mem_fence_flags get_fence(const gentype *ptr)

Returns a valid memory fence value for ptr.

See Also

No cross-references are available

Document Notes

For more information, see the OpenCL C Specification

This page is extracted from the OpenCL C Specification. Fixes and changes should be made to the Specification, not directly.

Copyright 2014-2023 The Khronos Group Inc.

SPDX-License-Identifier: CC-BY-4.0