Passing an struct including a pointer to another struct, to kernel in CUDA

前端 未结 1 1467
无人共我
无人共我 2021-01-17 05:06

I have two structs as

struct collapsed {
    char **seq;
    int num;
};


struct data {
    collapsed *x;
    int num;
    int numblocks;
    int *blocksize         


        
相关标签:
1条回答
  • 2021-01-17 05:30

    You're dereferencing a host pointer on the device. X is a valid device pointer.

    But when you copied the X struct to the device, you copied x along with it, which contains a host pointer. When you dereference that pointer:

    collapsed x = X->x[0];
                     ^ this is dereferencing the x pointer
    

    the device code throws an error.

    More detail is given here as well as instructions on how to fix it.

    0 讨论(0)
提交回复
热议问题