DPCT1041#

Message#

SYCL uses exceptions to report errors, it does not use error codes. 0 is used instead of an error code in <statement name> statement. You may need to rewrite this code.

Detailed Help#

SYCL* uses exceptions to report errors, it does not use error codes. The original code tries to get an error code, but SYCL does not require this functionality. Therefore, 0 is used instead of an error code in the following statements:

  • if

  • while

  • do

  • for

  • switch

  • return

  • function-like macro

Suggestions to Fix#

You may need to rewrite this code.

For example, this original CUDA* code:

 1 void foo() {
 2   ...
 3   int N;
 4   cublasHandle_t handle;
 5   float alpha, beta;
 6   float *a, *b, *c;
 7   if (int status = cublasSgemm(handle, CUBLAS_OP_N, CUBLAS_OP_N, N, N, N, &alpha,
 8                              a, N, b, N, &beta, c, N)) {
 9     printf("cublasSgemm failed\n");
10   }
11   ...
12 }

results in the following migrated SYCL code:

 1 void foo() try {
 2   ...
 3   int N;
 4   dpct::queue_ptr handle;
 5   float alpha, beta;
 6   float *a, *b, *c;
 7   {
 8     auto a_buf_ct1 = dpct::get_buffer<float>(a);
 9     auto b_buf_ct2 = dpct::get_buffer<float>(b);
10     auto c_buf_ct3 = dpct::get_buffer<float>(c);
11     oneapi::mkl::blas::column_major::gemm(
12         *handle, oneapi::mkl::transpose::nontrans,
13         oneapi::mkl::transpose::nontrans, N, N, N, alpha, a_buf_ct1, N,
14         b_buf_ct2, N, beta, c_buf_ct3, N);
15   }
16   /*
17   DPCT1041:0: SYCL uses exceptions to report errors, it does not use error
18   codes. 0 is used instead of an error code in an if statement. You may need to
19   rewrite this code.
20   */
21   if (int status = 0) {
22     printf("cublasSgemm failed\n");
23   }
24   ...
25 }
26 catch (sycl::exception const &exc) {
27   std::cerr << exc.what() << "Exception caught at file:" << __FILE__
28             << ", line:" << __LINE__ << std::endl;
29   std::exit(1);
30 }

which is rewritten to:

 1 void foo() try {
 2   ...
 3   int N;
 4   dpct::queue_ptr handle;
 5   float alpha, beta;
 6   float *a, *b, *c;
 7   {
 8     auto a_buf_ct1 = dpct::get_buffer<float>(a);
 9     auto b_buf_ct2 = dpct::get_buffer<float>(b);
10     auto c_buf_ct3 = dpct::get_buffer<float>(c);
11     oneapi::mkl::blas::column_major::gemm(
12         *handle, oneapi::mkl::transpose::nontrans,
13         oneapi::mkl::transpose::nontrans, N, N, N, alpha, a_buf_ct1, N,
14         b_buf_ct2, N, beta, c_buf_ct3, N);
15   }
16   ...
17 }
18 catch (sycl::exception const &exc) {
19   std::cerr << exc.what() << "Exception caught at file:" << __FILE__
20             << ", line:" << __LINE__ << std::endl;
21   std::exit(1);
22 }