Noam Kremen
Noam Kremen

Reputation: 418

What is the optimal memory data structure for a 3D triangulated mesh in CUDA?

I'm trying to calculate a certain statistic around each point of a triangulated mesh. The function that does the calculation itself accepts as input a point (6 floats: x,y,z coordinates; nx,ny,nz normal ) and an array of 10 of its mesh neighbours. Currently, I'm passing this data to the GPU in a very simple way: a 1D array for the point coordinates [x,y,z,x1,y1,z1,x2,y2,z2,..] (the coordinate of each point is followed by the coordinates of its 10 neighbours) and another 1D array for the normals, arranged in the same manner.

Access to the data to be processed by a specific thread is done by simple pointer arithmetic on these two arrays.

Obviously, this is inefficient memory- and computation-wise. In a 'vanilla' non-CUDA implementation I would have used a sparse adjacency matrix populated with point structs. Is it possible to do something similar with CUDA?

Upvotes: 1

Views: 283

Answers (1)

darxsys
darxsys

Reputation: 1570

You could pass an array of structures where one structure stores x,y,z and nx,ny,nz coordinates for a point. And then array would store the corresponding stuff for a point and its neighbours. If I'm right, CUDA likes AOS's (arrays of structures) a lot.

Upvotes: 1

Related Questions