1#include <clc/clc.h> 2 3_CLC_OVERLOAD _CLC_DEF float atomic_xchg(volatile global float *p, float val) { 4 return as_float(atomic_xchg((volatile global uint *)p, as_uint(val))); 5} 6 7_CLC_OVERLOAD _CLC_DEF float atomic_xchg(volatile local float *p, float val) { 8 return as_float(atomic_xchg((volatile local uint *)p, as_uint(val))); 9} 10 11#define IMPL(TYPE, AS) \ 12_CLC_OVERLOAD _CLC_DEF TYPE atomic_xchg(volatile AS TYPE *p, TYPE val) { \ 13 return __sync_swap_4(p, val); \ 14} 15 16IMPL(int, global) 17IMPL(unsigned int, global) 18IMPL(int, local) 19IMPL(unsigned int, local) 20#undef IMPL 21