ATOMIC_VAR_INIT

Expands to a token sequence suitable for initializing an atomic object.

The ATOMIC_VAR_INIT macro is defined as:

#define ATOMIC_VAR_INIT(C value)

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.

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

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

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.

Specification

OpenCL Specification

Also see

Copyright © 2007-2013 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.