DPCT1034#

Message#

Migrated API does not return an error code. 0 is returned in the lambda. You may need to rewrite this code.

Detailed Help#

Typically, this happens because the API call in the original application returns an error code and then it is consumed by the program logic.

SYCL* uses exceptions to report errors and does not return the error code.

SYCLomatic inserts a return 0; statement at the end of the lambda expression, if the return code is expected by the program logic and the new API does not return it. Review all such places in the code.

Similar to DPCT1003.

Suggestions to Fix#

If in a DPC++ application you:

  • Do not need the code that consumes the error code, remove the code and the return 0; statement.

  • Need the code that consumes the error code, try to replace it with an exception handling code and use your logic in an exception handler.

Similar to DPCT1003.

For example, this original CUDA* code:

1 void foo() {
2   CUdevice device;
3   CUresult status = cuDeviceComputeCapability(&result0, &result1, device);
4 }

results in the following migrated SYCL code:

 1 void foo() {
 2   /*
 3   DPCT1034:0: Migrated API does not return an error code. 0 is returned in the
 4   lambda. You may need to rewrite this code.
 5   */
 6   int status = [&]() {
 7     result0 = dpct::dev_mgr::instance().get_device(device).get_major_version();
 8     result1 = dpct::dev_mgr::instance().get_device(device).get_minor_version();
 9     return 0;
10   }();
11 }

which is rewritten to:

1 void foo() {
2   try {
3     result0 = dpct::dev_mgr::instance().get_device(device).get_major_version();
4     result1 = dpct::dev_mgr::instance().get_device(device).get_minor_version();
5   } catch (...) {
6     ...
7   }
8 }