DPCT1002

メッセージ

特別なケースのエラーを処理する if-stmt が検出されました。コードを修正する必要があります。

詳細な説明

DPCT1000」を参照してください。

修正方法の提案

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


1void foo() { 
2 float *f; 
3 cudaError_t err = cudaMalloc(&f, 4); 
4 if (err == cudaErrorMemoryAllocation) { 
5 std::cerr << "cudaErrorMemoryAllocation" << std::endl; 
6 } 
7}

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


1void foo() 
2 float *f; 
3 int err = (f = (float *)sycl::malloc_device(4, dpct::get_default_queue()), 0); 
4 /* 
5 DPCT1002:1: Special case error handling if-stmt was detected.You may need to 
6 rewrite this code.
7 */ 
8 if (err == 2) { 
9 std::cerr << "cudaErrorMemoryAllocation" << std::endl; 
10 } 
11}

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


1void foo() 
2 float *f; 
3 try { 
4 f = (float *)sycl::malloc_device(4, dpct::get_default_queue()); 
5 } catch (sycl::exception const &e) { 
6 std::cerr << e.what() << std::endl; 
7 } 
8}