DPCT1003#
Message#
Migrated API does not return error code. (*, 0)
is inserted. You may need to
rewrite this code.
Detailed Help#
Typically, this happens because the CUDA* API 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 (*, 0)
operator, so that the resulting
application can be compiled. This operator returns 0 and is inserted if the return
code is expected by the program logic and the new API does not return it. You
should review all such places in the code.
Suggestions to Fix#
If in a DPC++ application you:
Do not need the code that consumes the error code, remove the code and the
(*, 0)
operator.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.
For example, this original CUDA code:
1void foo() {
2 cudaError_t err;
3 float *f;
4 err = cudaMalloc(&f, 4);
5 err = cudaFree(f);
6}
results in the following migrated SYCL code:
1void foo() {
2 dpct::device_ext &dev_ct1 = dpct::get_current_device();
3 sycl::queue &q_ct1 = dev_ct1.default_queue();
4 int err;
5 float *f;
6 /*
7 DPCT1003:0: Migrated API does not return error code. (*, 0) is inserted. You
8 may need to rewrite this code.
9 */
10 err = (f = (float *)sycl::malloc_device(4, q_ct1), 0);
11 /*
12 DPCT1003:1: Migrated API does not return error code. (*, 0) is inserted. You
13 may need to rewrite this code.
14 */
15 err = (sycl::free(f, q_ct1), 0);
16}
which is rewritten to:
1void foo() {
2 dpct::device_ext &dev_ct1 = dpct::get_current_device();
3 sycl::queue &q_ct1 = dev_ct1.default_queue();
4
5 float *f;
6 f = (float *)sycl::malloc_device(4, q_ct1);
7 sycl::free(f, q_ct1);
8}