DPCT1056
目次
DPCT1056
メッセージ
デバイスコードの <variable name> の使用を検出できませんでした。この変数がデバイスコードでも使用されている場合は、コードを書き換える必要があります。
詳細な説明
__constant__
変数がホストコードでのみ使用されている場合、「__constant__」属性は削除されます。
修正方法の提案#
例えば、以下のオリジナル CUDA* コードについて考えてみます。
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}
上記のソースは次のコマンドラインを使用して移行されます。
1dpct --out-root out test.h --extra-arg=-xc
結果は、次の SYCL* コードに移行されます。
1 /*
2 DPCT1056:0: The use of const_a in device code was not detected. If this variable is
3 also used in device code, you need to rewrite the code.
4 */
5 static const float const_a = 10.f;
6
7 void foo_host() {
8 printf("%f\n", const_a);
9 }
「const_a」変数がホストコードでのみ使用されている場合は、DPCT1056 を無視します。以下に例を示します。
1static const float const_a = 10.f;
2
3void foo_host() {
4 printf("%f\n", const_a);
5}
「const_a」変数がホストとデバイスコードの両方で使用されている場合、移行後のコードを書き直します。以下に例を示します。
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}