Manolete
Manolete

Reputation: 3517

Array of vectors using Thrust

Is it possible to create an array of device_vectors using Thrust? I know I can't create a device_vector of a device_vector, but how I would create an array of device_vectors?

Upvotes: 8

Views: 5367

Answers (1)

phoad
phoad

Reputation: 1861

The following code worked for me. If you place this code to a file with .cu extension it compiles well, but if you place it in a file with .cpp extension it gives compile time assertion failure.

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 assertion failure is like the following

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

Upvotes: 10

Related Questions