Alex Rivera | Logout

Array of vectors using Thrust

Asked 2012-09-13T13:04:49.760
8

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?

Edit
Report

1 Answer

10

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>'
answered 2012-09-18T16:05:59.973

Your Answer