Thrust multidimensional vectors passing vector of vectors to a cuda kernel

Hi all,

I am currently working on an unstructured cfd solver. My main programm (.cpp file) does all the partitioning for my and tells me which cells are in which partition and which neighbours they have. These information are basically all stored in a vector of vectors

std::vector<std::vector<int>>

which are dynamically populated during runtime.

Then I am using 2 .cu files, one which includes all the Blocksize declarations etc, the second one includes only the Kernel.

The Kernel can be declared as

__global__ void JacobiRelaxationGPU_unstructured(float *u_d, float h,float *problem_1D, float *problem_1D_source, std::vector<std::vector<int>> complete_domains, std::vector<std::vector<int>> complete_domains_renumbered, int parts_metis, int ArraySizeX, int ArraySizeY, int BLOCK_SIZE_X, int BLOCK_SIZE_Y)

but it wasn’t possible to use the vectors inside the kernel. After some research I tried Thrust (which I am not sure if I am doing it right)

thrust::host_vector<thrust::host_vector<int>> complete_domains_thrust_host(complete_domains.begin(), complete_domains.end());

thrust::device_vector<thrust::device_vector<int>> complete_domains_thrust_device();

The 2 thrust vectors are included in the section where the blocksizes etc is set up.

My question is, what is the actual way of doing it ?

  1. create host_vector

  2. get my actual 2 dim vector data in the host_vector

  3. get host_vector data into device_vector

And does it work in the kernel that I can access my vector like

vector.at().at()?

any suggestions are welcome

regards Markus

Hi all,

I am currently working on an unstructured cfd solver. My main programm (.cpp file) does all the partitioning for my and tells me which cells are in which partition and which neighbours they have. These information are basically all stored in a vector of vectors

std::vector<std::vector<int>>

which are dynamically populated during runtime.

Then I am using 2 .cu files, one which includes all the Blocksize declarations etc, the second one includes only the Kernel.

The Kernel can be declared as

__global__ void JacobiRelaxationGPU_unstructured(float *u_d, float h,float *problem_1D, float *problem_1D_source, std::vector<std::vector<int>> complete_domains, std::vector<std::vector<int>> complete_domains_renumbered, int parts_metis, int ArraySizeX, int ArraySizeY, int BLOCK_SIZE_X, int BLOCK_SIZE_Y)

but it wasn’t possible to use the vectors inside the kernel. After some research I tried Thrust (which I am not sure if I am doing it right)

thrust::host_vector<thrust::host_vector<int>> complete_domains_thrust_host(complete_domains.begin(), complete_domains.end());

thrust::device_vector<thrust::device_vector<int>> complete_domains_thrust_device();

The 2 thrust vectors are included in the section where the blocksizes etc is set up.

My question is, what is the actual way of doing it ?

  1. create host_vector

  2. get my actual 2 dim vector data in the host_vector

  3. get host_vector data into device_vector

And does it work in the kernel that I can access my vector like

vector.at().at()?

any suggestions are welcome

regards Markus