SEH error when executing cuLaunchKernel

The gist of it is as follows:

When executing cuLaunchKernel with params that are mixed host/device pointers, I am getting SEH exception with code 0xc0000006 when the parameters vector is initialized with device buffer pointer. It doesn’t matter if the buffer is device-only or managed/using pinned memory.

        // initialize parameters
        std::vector<void *> parameters{};

        for ( const auto &arg : writeArgs ) {
            // this code extracts buffer pointers from our list of arguments
            // when buffers are scalar values, these point to host memory
            // when buffers are gpu buffers, these point to device memory
            parameters.push_back( arg->getGPUBufferPtr() );

        cuLaunchKernel( cuFunc,
                                      execGridSize[2], // Grid Sizes
                                      execBlockDim[2], // Block Dimensions
                                      0,               // Shared Memory
                                      _cuStream,       // Stream
                            ,  // Kernel Parameters,
                                      NULL             // Extra Parameters

Please provide a short, complete example.
Remember that with respect to the parameters (2nd to last argument), buffer pointers are effectively pointer-to-pointers.

You cannot have device pointers in the parameters array. Those pointers must point to host memory, from which the corresponding kernel parameter should be copied.

i.e. if int* d_data is a device allocation , you need to add &d_data to the parameter array.

Quoting the documentation

If the kernel has N parameters the args should point to array of N pointers. 
Each pointer, from args[0] to args[N - 1], point to the region of memory from which the actual parameter will be copied. 
1 Like

Thank you very much, this is indeed the answer.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.