AnsweredAssumed Answered

int64 atom_cmpxchg on AMD 6168 CPU

Question asked by wohlbier on Apr 19, 2013
Latest reply on Aug 4, 2014 by pinform

The OpenCL code below fails to compile for an AMD 6168 CPU. AMD_APP version 2.8. Note the compiler does not complain about cl_khr_int64_base_atomics, so I have to assume they are supported for the 6168. The compiler error is listed before the code, and note that the signature I'm trying to use for atomic_cmpxchg is listed in the OpenCL spec.

http://www.khronos.org/registry/cl/sdk/1.0/docs/man/xhtml/cl_khr_int64_base_atomics.html

 

Thanks for any help!

jgw

 

 

2: clBuildProgram failed:

2: "/tmp/OCLOciay5.cl", line 46: error: no instance of overloaded function

2:           "atomic_cmpxchg" matches the argument list

2:             argument types are: (volatile __global ulong *, ulong, ulong)

2:     } while (atomic_cmpxchg((volatile __global unsigned long *)source,

2:              ^

2:

2: 1 error detected in the compilation of "/tmp/OCLOciay5.cl".

2:

2: Frontend phase failed compilation.

2:

2: -D__OCL_AMD__ -I/home/wohlbier/Chicoma/chicoma/config/../src/util -Werror -cl-strict-aliasing -cl-fast-relaxed-math -cl-std=CL1.1

 

 

 

 

// enable int64 atomics

#pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable

 

typedef double real_t;

 

inline void atomic_real_add(volatile __global real_t * source,

                  const real_t operand) {

  union {

    unsigned long intVal;

    real_t realVal;

  } newVal;

  union {

    unsigned long intVal;

    real_t realVal;

  } prevVal;

 

  do {

    prevVal.realVal = *source;

    newVal.realVal = prevVal.realVal + operand;

  } while (atomic_cmpxchg((volatile __global unsigned long *)source,

                prevVal.intVal, newVal.intVal) != prevVal.intVal);

}

Outcomes