DPCT1078#

Message#

Consider replacing memory_order::acq_rel with memory_order::seq_cst for correctness if strong memory order restrictions are needed.

Detailed Help#

memory_order::acq_rel is a light-weight fence that is sufficient for memory synchronization in most programs. If a program needs total sequentially consistent memory order to ensure correctness, replace memory_order::acq_rel with memory_order::seq_cst.

Suggestions to Fix#

Replace memory_order::acq_rel with memory_order::seq_cst if stricter memory order is needed.

For example, this original CUDA* code:

1__device__ void foo_dev() {
2  ...
3  __threadfence();
4  ...
5}

results in the following migrated SYCL code:

 1void foo_dev() {
 2  ...
 3  /*
 4  DPCT1078:0: Consider replacing memory_order::acq_rel with
 5  memory_order::seq_cst for correctness if strong memory order restrictions are
 6  needed.
 7  */
 8  sycl::atomic_fence(sycl::memory_order::acq_rel, sycl::memory_scope::device);
 9  ...
10}

which is rewritten to:

1void foo_dev() {
2  ...
3  // Assuming strong memory order restrictions are need here
4  sycl::atomic_fence(sycl::memory_order::seq_cst, sycl::memory_scope::device);
5  ...
6}