User Guide

  • 2022.0
  • 05/15/2022
  • Public Content

Invalid Kernel Argument

Occurs when a null or an invalid pointer is passed to a kernel via buffer or queue.
Problem type: Memory leak
Code Location
Allocation site
Represents a source location of a pointer with no registered allocation operations or a deleted pointer.
cl::sycl::buffer<InputT, 1> inputBuf(inputPtr, size); queue.submit([&](cl::sycl::handler &cgh) { auto inputAcc = inputBuf.template get_access<cl::sycl::access::mode::read>(cgh); cgh.parallel_for<class my_task>(cl::sycl::range<1> { size }, [=](cl::sycl::id<1> idx) { outputPtr[0] += some_function(inputAcc[idx]); } }
A kernel argument is invalid if it contains:
  • Stuff pointer - the memory was not allocated for this pointer. The pointer is not initialized.
    DPC++ Example
    int* inputPtr; // Memory not allocated
  • Released pointer - the memory was released before passing the pointer to a kernel.
    DPC++ Example
    Int* inputPtr = new int[N]; for(int i=0; i<N; i++) inputPtr[I] = …; delete[] inputPtr; cl::sycl::buffer<InputT, 1> inputBuf(inputPtr, size);
  • Null pointer
    DPC++ Example
    int* inputPtr = nullptr; cl::sycl::buffer<InputT, 1> inputBuf(inputPtr, size);
    A null pointer is considered invalid only if it is passed with
  • Uninitialized buffer - the memory was allocated, but the data was not passed to a buffer.
    DPC++ Example
    int* inputPtr = new int[N]; cl::sycl::buffer<InputT, 1> inputBuf(inputPtr, size); // The array is not filled in with values

Possible Correction Strategies

Depending on the type of invalid kernel argument, use the following correction hints:
  • For a stuff pointer, allocate memory.
  • For a released pointer, make sure to use the release command after kernel execution.
  • For a null pointer:
    • If you are going to reuse this pointer on GPU, allocate memory for the pointer.
    • If you are not going to reuse this pointer on GPU, remove the
  • For an uninitialized buffer, make sure to initialize values in the buffer.

Product and Performance Information


Performance varies by use, configuration and other factors. Learn more at