4 Replies Latest reply on Jan 27, 2011 1:58 PM by LeeHowes

    64-bit atomics

    eugenek

      Do I understand correctly that the current version of Stream does not support 64-bit atomics? I tried to define #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable, it complained about an unknown pragma. Is there an ETA?

        • 64-bit atomics
          eugenek

          Figured out how to query extensions of the device.

          name: Barts
          vendor: Advanced Micro Devices, Inc.
          version: OpenCL 1.1 ATI-Stream-v2.3 (451)
          extensions: cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_3d_image_writes cl_khr_byte_addressable_store cl_khr_gl_sharing cl_amd_device_attribute_query cl_amd_printf cl_amd_media_ops cl_amd_popcnt

          No 64 bit atomics

            • 64-bit atomics
              LeeHowes

              No. Atomics on the AMD architectures are executed differently from competing architectures. There are hardware atomic units on the memory interfaces. These allow very fast asynchronous atomics meaning that atomic operations are very low overhead on these architectures, unfortunately it also means that more complex atomics are not possible as they would be if they were based on locking cache lines and full return trips through the main ALUs. There are no floating point atomics for the same reason.

                • 64-bit atomics
                  nou

                  it should be possible implement add/sub atomic with two 32 bit numbers.

                  int old;
                  old = atom_add(a[0], x);
                  if(old+x == 0)atom_inc(a[1]);

                  but i am not sure if it is correct.

                    • 64-bit atomics
                      LeeHowes

                      It's not. Overall it's not an atomic operation because something could change in both 32-bit words before you do the second operation.

                      You'd have to do it by using a compare and set on a lock word. 

                      CAS lock, if success change 64-bit value and then unlock. if not retry.