OpenCL - 将树复制到设备内存 [英] OpenCL - copy Tree to device memory

查看:23
本文介绍了OpenCL - 将树复制到设备内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用 C 代码实现了一个二叉搜索树.我的每个树节点看起来像这样:

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,那么您可以使用 Shared Virtual Memory.在主机上创建的指针也将在设备上有效.这是描述和二叉搜索树示例:opencl-2-shared-virtual-memory.

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.

这篇关于OpenCL - 将树复制到设备内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆