DPCT1011

メッセージ

ツールは、組込みベクトル型のオーバーロードされた演算子を検出しましたが、これは SYCL* 2020 の標準演算子と競合する可能性があります (詳細は、「4.14.2.1 ベクトル・インターフェイス」を参照)。競合を回避するため、名前空間が挿入されました。代わりに、SYCL* 2020 の標準演算子を使用してください。

説明

double2 などのベクトル型にオーバーロードされた演算子があります。SYCL* でも同じシグネチャーを持つオーバーロードされた演算子が定義されているため、これは競合します。SYCL* で定義されたオペレーターと区別するため、インテル® DPC++ 互換性ツールは、オーバーロードされたオペレーターの名前空間を追加します。コードを書き換える必要があります。

修正方法の提案

コードを修正する必要があります。

例えば、以下のオリジナル CUDA* コードについて考えてみます。


1__host__ __device__ double2 &operator+=(double2 &a, const double2 &b) { 
2 a.x += b.x; 
3 a.y += b.y; 
4 return a; 
5} 
6 
7void foo(double2 &a, double2 &b) { 
8 a += b; 
9}

このコードは、以下の SYCL* コードに移行されます。


1 /* 
2 DPCT1011:0: The tool detected overloaded operators for built-in vector types, 
3which may conflict with the SYCL 2020 standard operators (see 4.14.2.1 Vec 
4interface).競合を回避するため、名前空間が挿入されました。Use SYCL 2020 
5standard operators instead.
6*/ 
7namespace dpct_operator_overloading { 
8 
9sycl::double2 &operator+=(sycl::double2 &a, const sycl::double2 &b) { 
10 a.x() += b.x(); 
11 a.y() += b.y(); 
12 return a; 
13} 
14} // namespace dpct_operator_overloading 
15 
16void foo(sycl::double2 &a, sycl::double2 &b) { 
17 dpct_operator_overloading::operator+=(a, b); 
18}

このコードは次のように書き換えられます。


1void foo(sycl::double2 &a, sycl::double2 &b) { 
2 // In this case, the user-defined overloading of `+=` has been supported by sycl::double2, so we can use the operator `+=` directly. 
3 a += b; 
4}