Atomic Functions

The atomic functions are shown below. Click an item in the table below for details about that function.

64-bit Atomics

The optional extension cl_khr_int64_base_atomics implements atomic operations on 64-bit signed and unsigned integers to locations in __global and __local memory.

The cl_khr_int64_extended_atomics extension enables additional atomic functions using types long and unsigned long. An application that wants to use this extension will need to include the #pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : enable in the OpenCL program source.


As of OpenCL version 1.1, cl_khr_global_int32_base_atomics, cl_khr_global_int32_extended_atomics, cl_khr_local_int32_base_atomics and cl_khr_local_int32_extended_atomics extensions are core features. The built-in atomic function names are changed to use the atomic_ prefix instead of atom_.

The list of supported atomic type names are:

  • atomic_int
  • atomic_uint
  • atomic_long
  • atomic_ulong
  • atomic_float
  • atomic_double
  • atomic_intptr_t
  • atomic_uintptr_t
  • atomic_size_t
  • atomic_ptrdiff_t

The atomic_long and atomic_ulong types are supported if the cl_khr_int64_base_atomics and cl_khr_int64_extended_atomics extensions are supported.

The atomic_double type is only supported if double precision is supported and the cl_khr_int64_base_atomics and cl_khr_int64_extended_atomics extensions are supported.

If the device address space is 64-bits, the data types atomic_intptr_t, atomic_uintptr_t, atomic_size_t and atomic_ptrdiff_t are supported if the cl_khr_int64_base_atomics and cl_khr_int64_extended_atomics extensions are supported.

Arguments to a kernel can be declared to be a pointer to the above atomic types or the atomic_flag type.

The representation of atomic integer, floating-point and pointer types have the same size as their corresponding regular types. The atomic_flag type must be implemented as a 32-bit integer.


OpenCL Specification

Also see

memory_order, memory_scope, atomic_flag type

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.