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

查看:179
本文介绍了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.

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

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