Array of vectors using Thrust

Is it possible to create a device_vectors array using Thrust? I know that I cannot create device_vector device device_vector, but how would I create an array device_vectors?

+4
source share
1 answer

The following code worked for me. If you put this code in a file with the extension .cu, it compiles well, but if you put it in a file with the extension .cpp, it will give a compile-time error message.

thrust::device_vector<float> vectors[3]; //thrust::device_vector<float> *vectors = new thrust::device_vector<float>[3]; vectors[0] = thrust::device_vector<float>(10); vectors[1] = thrust::device_vector<float>(10); vectors[2] = thrust::device_vector<float>(10); printf("Works\n"); 

The approval error is as follows

 1>../for_each.inl(96) : error C2027: use of undefined type 'thrust::detail::STATIC_ASSERTION_FAILURE<x>' 
+6
source

Source: https://habr.com/ru/post/1434004/


All Articles