How to copy a tetrahedron tree structure to CUDA device memory?(如何将四面体树结构复制到 CUDA 设备内存?)
问题描述
如果我想将下面的结构 TetrahedronStruct
移动到 CUDA 设备内存,我应该如何进行?
If I want to move the below structure TetrahedronStruct
to CUDA device memory, how should I proceed?
struct TetrahedronStruct {
int index;
int region;
TriangleFaces Faces[4];
Vertex Vertices[4];
struct TetrahedronStruct *adjTetrahedrons[4];
};
typedef struct {
long double Nx, Ny, Nz;
long double d;
Vertex V[3];
} TriangleFaces;
typedef struct {
long double x, y, z;
} Vertex;
详情:
提供了网格细节(节点数、四面体、坐标和区域).树的创建是在 for 循环中完成的.基本上,每个人脸都根据其坐标和相邻关系在树中定位和排列.
The mesh details (number of nodes, tetrahedrons, coordinates, and regions) are provided. The creation of the tree is done in a for-loop. Basically, each face is being located and arranged in the tree accordingly with its coordinates and adjacency.
在 CUDA 设备中,我需要使用此结构叠加在媒体上以模拟粒子将如何穿过该媒体.百万粒子中的每一个都在从四面体移动到四面体(每个四面体都具有其所在介质的属性).
In the CUDA device, I need to use this structure to overlay on a media to simulate how particles will travel across that media. Each of the million particles are moving from tetrahedron to tetrahedron (each tetrahedron has the properties of the media where it resides).
推荐答案
将结构线性化,然后将它们复制到设备会更容易.
It will be easier to linearize the structures and then copy them to device.
在新的 CUDA 6 深拷贝中,只要您的计算能力是 3.x 或更高,并且使用 统一内存.
In the new CUDA 6 deep copies will be much easier as long as your compute capability is 3.x or higher with the Unified Memory.
这篇关于如何将四面体树结构复制到 CUDA 设备内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何将四面体树结构复制到 CUDA 设备内存?


- 如何对自定义类的向量使用std::find()? 2022-11-07
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- 从python回调到c++的选项 2022-11-16
- STL 中有 dereference_iterator 吗? 2022-01-01
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- Stroustrup 的 Simple_window.h 2022-01-01
- 静态初始化顺序失败 2022-01-01
- 近似搜索的工作原理 2021-01-01
- C++ 协变模板 2021-01-01