DPCT1056#

Message#

The use of <variable name> in device code was not detected. If this variable is also used in device code, you need to rewrite the code.

Detailed Help#

If __constant__ variable is only used in host code, “__constant__” attribute will be removed.

Suggestions to Fix#

For example, this original CUDA* code:

1#include <stdio.h>
2#include <cuda_runtime.h>
3
4static __constant__ const float const_a = 10.f;
5
6void foo_host() {
7  printf("%f\n", const_a);
8}

is migrated using the following migration command:

1dpct --out-root out test.h --extra-arg=-xc

which results in the following migrated SYCL* code:

1/*
2DPCT1056:0: The use of const_a in device code was not detected. If this variable is
3also used in device code, you need to rewrite the code.
4*/
5static const float const_a = 10.f;
6
7void foo_host() {
8  printf("%f\n", const_a);
9}

If the variable “const_a” is only used in host code, just ignore the DPCT1056 warning. For example:

1static const float const_a = 10.f;
2
3void foo_host() {
4  printf("%f\n", const_a);
5}

If the variable “const_a” is used in both host and device code, rewrite the migrated code. For example:

1static const float const_a_host_ct1 = 10.f;
2static dpct::constant_memory<const float, 0> const_a(10.f);
3
4void foo_host() {
5  printf("%f\n", const_a_host_ct1);
6}