PDA

View Full Version : atom_add with float



dweo
04-30-2010, 12:01 PM
According to the OpenCl spec there should be a function:
T atom_add (Q T *p, T val)

The following line works properly
__local int z=1;
int w = 5;
atom_add(&z, w);

But switching from int to float
__local float z=1;
float w = 5;
atom_add(&z, w);

results in the following error
<program source>:45:2:{45:2-45:10}: error: no matching overload found for arguments of type 'float __attribute__((address_space(3)))*, float'
atom_add(&z, w);
^~~~~~~~~~~~~~~
/System/Library/Frameworks/OpenCL.framework/Resources/cl_kernel.h:2531:23: note: instantiated from:
#define atom_add(X,Y) __CLFN_A2(X, Y, add)
^
/System/Library/Frameworks/OpenCL.framework/Resources/cl_kernel.h:2525:26: note: instantiated from:
#define __CLFN_A2(x,y,R) __builtin_overload(2, x, y, \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Any ideas? I'm running a new MacbookPro i5 with OS X 10.6.

Rui
04-30-2010, 06:48 PM
According to the specification there is a function
int atom_add (__local int *p, int val)

affie
04-30-2010, 09:02 PM
atomic operations are only supported on integer data (not floating-point data). This is why you are getting the compile error.

dweo
05-01-2010, 05:51 PM
I see that now. I assumed T was any native type (float/int/long/char..). Thanks for clearing this up!