5 Replies Latest reply on Aug 5, 2018 5:21 PM by ymhsieh0226

    64bit atomic_cmpxchg

    ymhsieh0226

      Hi!

      I'm currently using supposedly the latest amdgpu-pro driver to write OpenCL codes on W8100 (Hawaii).  Our code uses 64-bit atomic_cmpxchg, and

      #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable 

      was added to the beginning of the cl code.  But the compilation suggests atomic_cmpxchg only accept 32-bit integers, but not 64-bit ones.  Is this normal?

       

       

      Yo-Ming Hsieh

        • Re: 64bit atomic_cmpxchg
          elstaci

          This post is best to be posted at OpenCL that deals with OpenCl coding and issues. dipak, AMD Moderator, might be able to assist you in getting access to this forum if you have problems posting there.

          1 of 1 people found this helpful
          • Re: 64bit atomic_cmpxchg
            dipak

            Please use 64-bit version of this function atom_cmpxchg .

             

            Regards,

              • Re: 64bit atomic_cmpxchg
                ymhsieh0226

                That is exactly what we intended to do - 64-bit atomic_cmpxchg (as in the title).  The pointer (the first argument) we fed to the atomic_cmpxchg is __global ulong *, but the *.cl built with errors.  The error messages seem to try to convert ulong to 32-bit integers as the following:

                /tmp/OCL32735T3.cl:99:26: error: no matching function for call to 'atomic_cmpxchg'

                        prevVal.intVal = atomic_cmpxchg((volatile __global CL_ATOMICINT *)source, assume.intVal, newVal.intVal);

                                         ^~~~~~~~~~~~~~

                /home/foreman/sources/stream/opencl/compiler/clc2/ocl-headers/build/lnx64a/B_rel/opencl12_builtins.h:4370:35: note: candidate function not viable: no known conversion from 'volatile __global ulong *' (aka 'volatile __global unsigned long *') to 'volatile __global int *' for 1st argument

                int __attribute__((overloadable)) atomic_cmpxchg(volatile __global int *p, int cmp, int val);

                                                  ^

                /home/foreman/sources/stream/opencl/compiler/clc2/ocl-headers/build/lnx64a/B_rel/opencl12_builtins.h:4371:44: note: candidate function not viable: no known conversion from 'volatile __global ulong *' (aka 'volatile __global unsigned long *') to 'volatile __global unsigned int *' for 1st argument

                unsigned int __attribute__((overloadable)) atomic_cmpxchg(volatile __global unsigned int *p, unsigned int cmp, unsigned int val);

                                                           ^

                /home/foreman/sources/stream/opencl/compiler/clc2/ocl-headers/build/lnx64a/B_rel/opencl12_builtins.h:4372:35: note: candidate function not viable: no known conversion from 'volatile __global ulong *' (aka 'volatile __global unsigned long *') to 'volatile __local int *' for 1st argument

                int __attribute__((overloadable)) atomic_cmpxchg(volatile __local int *p, int cmp, int val);

                                                  ^

                /home/foreman/sources/stream/opencl/compiler/clc2/ocl-headers/build/lnx64a/B_rel/opencl12_builtins.h:4373:44: note: candidate function not viable: no known conversion from 'volatile __global ulong *' (aka 'volatile __global unsigned long *') to 'volatile __local unsigned int *' for 1st argument

                unsigned int __attribute__((overloadable)) atomic_cmpxchg(volatile __local unsigned int *p, unsigned int cmp, unsigned int val);