Description

The ATOMIC_VAR_INIT macro expands to a token sequence suitable for initializing an atomic object of a type that is initialization-compatible with value. An atomic object with automatic storage duration that is not explicitly initialized using ATOMIC_VAR_INIT is initially in an indeterminate state; however, the default (zero) initialization for objects with static storage duration is guaranteed to produce a valid state.

#define ATOMIC_VAR_INIT(C value)

This macro can only be used to initialize atomic objects that are declared in program scope in the global address space.

Examples:

global atomic_int guide = ATOMIC_VAR_INIT(42);

Concurrent access to the variable being initialized, even via an atomic operation, constitutes a data-race.

See Also

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 (c) 2014-2020 Khronos Group. This work is licensed under a Creative Commons Attribution 4.0 International License.