Moving multidimensional data

I could use some help getting some 3D data over to the GPU.

Data in the host:
vector<Vec3D > V1;
vector<vector<Vec3D > > V2;

Where Vec3D is:
template
class Vec3D {
public:
T x;
T y;
T z;
Vec3D(): x(0), y(0), z(0){};
Vec3D(T a, T b, T c): x(a),y(b),z(c ){};
template
Vec3D(U da[3]: x(T(da[0])), y(T(da[1])), z(T(da[3])){};
template
Vec3D(U Vec3D& oth): x((T)oth.x), y((T)oth.y), z((T)oth.z){};
// some oper overload funcs here
}

In the GPU I want to do some basic 3-dimensional math. Stuff like: V1-V2, if(V1<V2)then,…

Step 1)
To get the data over to the GPU I tried:
thrust::device_vector<Vec3D > dV1(V1.begin(), V1.end());
thrust::device_vector<vector<Vec3D > > dV2(v2.begin(), v2.end());
But the compiler sure doesn’t like this. The errors went on for pages.

What am I doing wrong?

Step 2)
I’m not sure how to approach the math. That is, do I want to use a transform? Use the data in a tuple form? Maybe break the V1 data down to x,y,z components and operate on them separately?

C++ is not my strong suit, and I’m new to the GPU.
Your guidance or suggestions would be appreciated.

Templates are cumbersome, unless you really thrive on verbose C++ stuff.

ArrayFire might be more naturally suited to your style, since it has 3D math that is expressed more simply. (I’m biased in suggesting it, of course, cause I work on it)

Also, you have a bunch of smiley faces in your code. If you use the code markup in the forum editor, those will go away and your code will get nice syntax highlighting.

Could someone tell me if it is possible to directly copy the Vec3D container directly into the GPU? Or will I need to break it down to its component X,Y,Z values?

If the 3D data structure is allocated in a flat manner then a single memory copy will be enough.

However if each dimension is an array by itself, thus a piece of memory by itself, then it will need a memory copy per dimension.

So the ammount of memory copies will quickly go up: 1 copy for first dimension, B copies for second dimension where B represents size of first dimension, C copies for third dimension where C represents size of second dimension.

So roughly 1 * B * C. If each dimension has it’s own size so it’s a flexible thing then this can vary somewhat, if it’s fixed size then that’s basically it.

See if the template/class has some properties to get pointer(s) back to the memory this could be used for the memory copies.