cancel
Showing results for 
Search instead for 
Did you mean: 

OpenCL

ymhsieh0226
Adept I

64bit atomic_cmpxchg

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

0 Likes
1 Solution

For 64bit version, name of the function starts with atom_<> instead of atomic_<>

View solution in original post

5 Replies

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

dipak
Staff

Please use 64-bit version of this function atom_cmpxchg .

Regards,

0 Likes

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);

0 Likes

For 64bit version, name of the function starts with atom_<> instead of atomic_<>

Thank you!!!

0 Likes