DPCT1109#
Message#
<language feature> cannot be called in SYCL device code. You need to adjust the code.
Detailed Help#
In SYCL device code, features like memory storage allocation, recursive function, and virtual function are not supported. Rewrite the code to comply with the SYCL specification.
Suggestions to Fix#
For example, this original CUDA* code:
1__global__ void kernel_func(size_t size) {
2 int *data = new int[size];
3 *data = 1;
4}
5
6void foo() {
7 Kernel_func<<<1, 1>>>(size);
8}
results in the following migrated SYCL code:
1/*
2DPCT1109:0: Memory storage allocation cannot be called in SYCL device code. You need to adjust the code.
3*/
4void kernel_func(size_t size) {
5 int *data= new int[size];
6 *data = 1;
7}
8void foo() {
9 q.parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, 1), sycl::range<3>(1, 1, 1)), [=](sycl::nd_item<3> item_ct1) {kernel_func (data, size); };)
10}
which is rewritten to:
1void kernel_func(int *data, size_t size) {
2 *data = 1;
3}
4
5int *data= sycl::malloc_shared<int>(size, q); // Call the memory allocation function on the host code.
6q.parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, 1), sycl::range<3>(1, 1, 1)), [=](sycl::nd_item<3> item_ct1) {
7 kernel_func(data, size);
8};)