DPCT1000#

Message#

Error handling if-stmt was detected but could not be rewritten.

Detailed Help#

This warning is generated when SYCLomatic detects more complex error handling than it considers safe to remove.

The CUDA* API returns error codes that are consumed by the program logic. SYCL* uses exceptions to report errors and does not return the error code.

When the error handling logic in the original code is simple (for example, a print error message and exit), the code is removed in the resulting Data Parallel C++ (DPC++) application. The expectation is that SYCL throws an exception, which is handled with the printing of an exception message and exiting (the exception handler is generated automatically by SYCLomatic).

Suggestions to Fix#

Review the error handling if- statement and try to rewrite it to use an exception handler instead.

For example, this original CUDA code:

 1void check_err(cudaError_t err, float **f) {
 2  if (err != cudaSuccess) {
 3   log_error();
 4  }
 5}
 6
 7void foo() {
 8  float *f;
 9  cudaError_t err = cudaMalloc(&f, 4);
10  check_err(err, &f);
11}

results in the following migrated SYCL code:

 1void check_err(int err, float **f) {
 2  /*
 3  DPCT1000:1: Error handling if-stmt was detected but could not be rewritten.
 4  */
 5  if (err != 0) {
 6    /*
 7    DPCT1001:0: The statement could not be removed.
 8    */
 9    log_error();
10  }
11}
12
13void foo() {
14  float *f;
15  ...
16  int err = (f = (float *)sycl::malloc_device(4, dpct::get_default_queue()), 0);
17  check_err(err, &f);
18}

which is rewritten to:

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    log_error();
7  }
8}