简体   繁体   English

如何在Boost :: Compute和自定义内核中使用共享虚拟内存?

[英]How to use Shared Virtual Memory in Boost::Compute and custom kernel?

I have written a simple kernel that performs recursion over trees like: 我编写了一个简单的内核,对诸如以下的树执行递归:

struct item {
    int data;
    item *rnext, *lnext;
} *items[NUM_ITEMS];

So i'd like to pass such array of tree items which point to themselves to the opencl kernel, and SVM seems the best way to do so (I have no problem counting on opencl 2.0). 因此,我想将指向自己的树项目数组传递给opencl内核,而SVM似乎是这样做的最好方法(我对opencl 2.0毫无疑问)。

My question is how to do it with boost::compute such that the kernel will receive triples of integers or something like that. 我的问题是如何使用boost :: compute做到这一点,以便内核将接收三进制整数或类似的东西。

Thanks! 谢谢!

Boost.Compute does support shared virtual memory using the boost::compute::svm_* functions. Boost.Compute确实使用boost :: compute :: svm_ *函数支持共享虚拟内存。

For your application, you should be able to just allocate a region of SVM memory with svm_alloc() , fill it with your input data, and then pass it to your kernel using the regular kernel::set_arg() function (which has an overload for SVM memory objects). 对于您的应用程序,您应该能够使用svm_alloc()分配SVM内存区域,用输入数据填充该区域,然后使用常规kernel :: set_arg()函数将其传递给内核(该函数具有重载)用于SVM内存对象)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 OpenCL:可以使用模板化对象作为Boost :: compute的内核参数吗? - OpenCL: Is possible to use templated objects as kernel arguments with Boost::compute? 如何使用boost :: compute :: atan2? - How to use boost::compute::atan2? OpenCl共享虚拟内存测试奇怪结果 - OpenCl shared virtual memory test strange results 如何将大数组复制到内存并在 OpenCL 内核中使用? - How to copy a big array to memory and use it in OpenCL kernel? 如何计算 GPU memory 总线? - How to compute GPU memory bus? 通过引用boost :: compute闭包或函数来传递自定义结构的向量 - Pass a vector of custom structs by reference to a boost::compute closure or function 如何调用boost_compute'BOOST_COMPUTE_FUNCTION'定义函数? - How to call boost_compute 'BOOST_COMPUTE_FUNCTION' defined function? OpenCL How efficient is the use of user-defined function in kernel code in terms of memory and performance - OpenCL How efficient is the use of user-defined function in kernel code in terms of memory and performance Opengl和opencl在单个共享上下文中只能使用1个内核 - Opengl and opencl can use only 1 kernel in a single shared context 使用Compute Prof(Cuda / OpenCL)在每个块上静态分配的共享内存的大小 - Size of statically allocated shared memory per block with Compute Prof (Cuda/OpenCL)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM