OpenCL的 - 树复制到设备内存
我在C code ++实现的二叉搜索树。我的每一个树节点如下:
I'm implemented a Binary-Search-Tree in C code. Each of my tree nodes looks like this:
typedef struct treeNode {
int key;
struct treeNode *right;
struct treeNode *left;
} treeNode_t;
由主机发树的建设。由该装置制成的树的查询。
The construction of the Tree made by the Host. The query of the tree made by the device.
现在,让我们假设我已经建好我树在主机内存。
我想我的树的根复制到我的设备的内存中。
Now, let's assumed that I'm already finished building my Tree in host memory. I'm want to copy the root of my tree to the memory of my device.
复制树它自我的根源是不够的。因为右\\左子不位于设备内存。这是个问题。
Copying the root of the tree it self isn't enough. Because the right \ left child isn't located in the device memory. This is a problem.
所以,我的问题是什么是我的整个树复制到设备内存最简单的方法?
So, my question is what is the easiest way to copy my whole tree to the device memory?
如果您的设备支持的OpenCL 2.0,那么你可以使用共享虚拟存储
。在主机上创建的指针将是设备上有效了。这里是描述和二分搜索树的例子:的OpenCL-2共享的虚拟内存。
If your device supports OpenCL 2.0 then you can use Shared Virtual Memory
. The pointers created on the host will be valid on the device too. Here is the description and the binary search tree example: opencl-2-shared-virtual-memory.