Intel® Inspector User Guide for Linux* OS

ID 767796
Date 10/31/2024
Public
Document Table of Contents

Invalid Kernel Argument

Occurs when a null or an invalid pointer is passed to a kernel via buffer or queue.

ID

Code Location

Description

1

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); 

    NOTE:
    A null pointer is considered invalid only if it is passed with CL_MEM_USE_HOST_PTR; and CL_MEM_COPY_HOST_PTR; flags.
  • 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 CL_MEM_USE_HOST_PTR; and CL_MEM_COPY_HOST_PTR; flags.
  • For an uninitialized buffer, make sure to initialize values in the buffer.