DPCT1039#

Message#

The generated code assumes that <parameter name> points to the global memory address space. If it points to a local memory address space, replace <function name> with <function name>.

Detailed Help#

SYCLomatic deduces whether the first parameter of an atomic function points to a global memory address space or a local memory space, using the last assignment’s RHS value of the first parameter of the atomic function. If the last assignment is in an if/while/do/for statement or the first argument of the atomic function depends on a function or template argument, the deduction result may be incorrect. You need to verify the generated code to determine if the first parameter of the atomic function actually points to the local memory address space. If it does, then replace the atomic function name with an atomic function name that includes the template parameters, as pointed to in the warning message.

Suggestions to Fix#

If the first parameter of an atomic function points to a local memory address space, replace the atomic function name with an atomic function name that includes the template parameters.

For example, this original CUDA* code:

1 __device__ void d(int* s) {
2   atomicAdd(s, 1);
3 }
4
5 __global__ void k() {
6   __shared__ int shared;
7   d(&shared);
8 }

results in the following migrated SYCL* code:

 1 void d(int* s) {
 2   /*
 3   DPCT1039:0: The generated code assumes that "s" points to the global memory
 4   address space. If it points to a local memory address space, replace
 5   "atomic_fetch_add" with
 6   "atomic_fetch_add<sycl::access::address_space::local_space>".
 7   */
 8   dpct::atomic_fetch_add(s, 1);
 9 }
10
11 void k(int &shared) {
12   d(&shared);
13 }

which is rewritten to:

1 template<sycl::access::address_space as>
2 void d(int* s) {
3   dpct::atomic_fetch_add<as>(s, 1);
4 }
5
6 void k(int &shared) {
7   d<sycl::access::address_space::local_space>(&shared);
8 }