diff --git a/libgomp/config/nvptx/atomic.c b/libgomp/config/nvptx/atomic.c new file mode 100644 index 00000000000..2e13b09b497 --- /dev/null +++ b/libgomp/config/nvptx/atomic.c @@ -0,0 +1,18 @@ +#include "libgomp.h" + +#include "../../atomic.c" + +/* Implement __sync_val_compare_and_swap_16, to support offloading from hosts + that support this builtin. Fallback on libatomic. This can be removed + once omp-expand starts using __atomic_compare_exchange_n instead. */ + +unsigned __int128 +__sync_val_compare_and_swap_16 (volatile void *vptr, unsigned __int128 oldval, + unsigned __int128 newval) +{ + volatile __int128 *ptr = vptr; + __int128 expected = oldval; + __atomic_compare_exchange_n (ptr, &expected, newval, false, + MEMMODEL_SEQ_CST, MEMMODEL_SEQ_CST); + return expected; +} diff --git a/libgomp/testsuite/libgomp.c-c++-common/reduction-16.c b/libgomp/testsuite/libgomp.c-c++-common/reduction-16.c index d0e82b04790..e60fe3664ed 100644 --- a/libgomp/testsuite/libgomp.c-c++-common/reduction-16.c +++ b/libgomp/testsuite/libgomp.c-c++-common/reduction-16.c @@ -1,4 +1,5 @@ /* { dg-do run } */ +/* { dg-additional-options "-foffload=-latomic" { target offload_target_nvptx } } */ #include