oneapi-src / SYCLomatic

Other
222 stars 91 forks source link

[SYCLomatic] Fix `set_data_ptr` parameter qualifier #2145

Open the-slow-one opened 1 month ago

the-slow-one commented 1 month ago

Parameter data in method pitched_data.set_data_ptr should have a const qualified parameter.

The reasoning behind this is CUDA_MEMCPY2D.srcHost is of const qualifed (const void *). See here.

This PR resolves compile error in the following code.

$ cat src.cu
#include <cstring>
#include <cuda.h>

CUDA_MEMCPY2D get(const void *pSrc) {
  CUDA_MEMCPY2D cpy;
  cpy.srcHost = pSrc;  return cpy;
}

Migrated code by DPCT is as following. icpx fails to compile this code.

$ cat dpct_output/src.dp.cpp
#include <sycl/sycl.hpp>
#include <dpct/dpct.hpp>
#include <cstring>dpct::memcpy_parameter get(const void *pSrc) {
  dpct::memcpy_parameter cpy;
  cpy.from.pitched.set_data_ptr(pSrc);  
  return cpy;
}