DPCT1080#

Message#

Variadic functions cannot be called in a SYCL kernel or by functions called by the kernel. You may need to adjust the code.

Detailed Help#

SYCL* device functions can’t call variadic functions.

Suggestions to Fix#

Rewrite code manually by using non-variadic functions.

For example, this original CUDA* code:

 1__device__ int add(int arg_num, ...) {
 2  va_list args;
 3  va_start(args, arg_num);
 4  int sum = 0;
 5  for (int i = 0; i < arg_num; i++) {
 6    sum += va_arg(args, int);;
 7  }
 8  va_end(args);
 9  return sum;
10};
11
12__global__ void kernel(int *p) {
13  int x = add(2, 123, 456);
14  int y = add(3, 123, 456, 789);
15}

results in the following migrated SYCL code:

 1/*
 2DPCT1080:0: Variadic functions cannot be called in a SYCL kernel or by functions
 3called by the kernel. You may need to adjust the code.
 4*/
 5int add(int arg_num, ...) {
 6  va_list args;
 7  va_start(args, arg_num);
 8  int sum = 0;
 9  for (int i = 0; i < arg_num; i++) {
10    sum += va_arg(args, int);;
11  }
12  va_end(args);
13  return sum;
14};
15
16void kernel(int *p) {
17  int x = add(2, 123, 456);
18  int y = add(3, 123, 456, 789);
19}

which is rewritten to:

 1int add(int a0, int a1) {
 2  return a0 + a1;
 3};
 4
 5int add(int a0, int a1, int a2) {
 6  return a0 + a1 + a2;
 7};
 8
 9void kernel(int *p) {
10  int x = add(123, 456);
11  int y = add(123, 456, 789);
12}