Passing my CPP vector of struct to thrust vector

Hi,

I am new to cuda and I would like to pass from my cpp program vector of struct to thrust “type” vector"

Assistance will be appreciated.

The call from cpp to my cu file is as following:

int _declspec(dllexport) run_on_cuda(CPictureData* cpp_vec, int number_of_elements)

–Gil.

Why not use thrust::host_vector in lieu of std::vector?

inside your run_on_cuda procedure, the following should work:

thrust::device_vector d_vec(cpp_vec, cpp_vec+number_of_elements);

This assumes previously in the same file you have:

#include <thrust\device_vector.h>

A thrust::host_vector can be constructed in a similar fashion.

More information about thrust:

https://github.com/thrust/thrust/wiki/Quick-Start-Guide

thanks! this seems to work…