0

I'm new at CUDA and have the following question? My kernel is supposed to calculate a type:

vector <double *> *my_vector = new vector <double *>();

Before I tried to change the original c++ code to cuda it would calculate an array[6] in a loop and then push it back to my_vector.

for{
          //calculations


        double *array = new double[6];
        array[0] = data;
        array[1] = data;
        array[2] = data;
        array[3] = data;
        array[4] = data;
        array[5] = data;

        my_vector->push_back(array);
}

I know that using thrust could help but I prefer if I didn't use it. I thought of using a 2D array at my kernel and copying the data back to my host code and then copying that to my_vector with the std::vector. What I've tried so far has failed.

If anyone has some experience on this and has any idea it would be much help.

4

1 回答 1

1

查看为主机和设备代码使用提供有用模板的 Thrust模板库。thrust::device_vector可以像类比一样使用std::vector,尽管不在设备代码内部。

于 2012-05-18T22:13:17.243 回答