且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

有没有办法创建cl :: sycl :: pipe数组?

更新时间:2021-08-04 23:10:32

首先,免责声明以下事实:cl::sycl::pipe是临时SYCL 2.2规范中的实验性内容,并且仅在CPU上运行(没有加速器,没有FPGA. ..),而且效率很低.

First, a disclaimer about the fact that cl::sycl::pipe are experimental things from the provisional SYCL 2.2 specification and that runs only on CPU (no accelerator, no FPGA...), and only in a very inefficient way.

但是,当然,对实际设计如何工作以及SYCL如何工作进行实验很有用.

But of course it is useful to experiment about how a real design would work and how SYCL can work.

管道类似于某些硬件FIFO.

A pipe is similar to some hardware FIFO.

你写了

cl::sycl::pipe<cl::sycl::pipe<float>> p { n_threads, cl::sycl::pipe<float> { T } };

这意味着cl::sycl::pipe可以传输一些... cl::sycl::pipe可以传输一些float!虽然像《星际迷航》中那样传送一些硬件会很好,但是在当前版本的SYCL中,尚不可能通过管道发送实际的硬件. :-)

which means a cl::sycl::pipe to transfer some... cl::sycl::pipe to transfer some float! While it would be nice to beam some hardware like in Star Trek, it is not possible yet in the current version of SYCL to send real hardware through pipes. :-)

也许像您这样的代码可以工作,但是具有真正的管道数组. 但是问题是管道需要在施工时指定一些尺寸...

Probably a code like yours could work, but with a real array of pipes. But the issue is that pipes need some size specified at construction time...

我可以想到的一些想法是std::vector<cl::sycl::pipe<float>> p和执行n_threads p.emplace_back(T)的循环.

A few ideas I could think of would be std::vector<cl::sycl::pipe<float>> p and a loop doing n_threads p.emplace_back(T).

或者您可以使用一些元编程(Boost.Hana可能会帮助...)从n_threads T的初始值设定项列表构造std::array<cl::sycl::pipe<float>>.

Or you could use some metaprogramming (Boost.Hana might help...) to construct a std::array<cl::sycl::pipe<float>> from an initializer list of n_threads T.

或者您可以使用具有默认构造的中间对象来执行您感兴趣的管道.

Or you could use an intermediate object with a default construction doing the pipe you are interested in.

struct my_pipe : cl::sycl::pipe<float> {
  my_pipe() : pipe { T } {};
};

std::array<my_pipe, n_threads> p;

也就是说,我还没有尝试...

That said, I have not tried...

此外,经过仔细考虑,我并没有真正理解为什么在SYCL 2.2中管道不能具有默认构造函数,因为它们只是OpenCL等效对象的包装.我将其推送给SYCL委员会.感谢您使SYCL更好. :-)

Furthermore, after thinking at it, I do not really see why in SYCL 2.2 the pipes could not have default constructors since they are just a wrappers around the OpenCL equivalent objects. I will push this to the SYCL committee. Thank you for making SYCL better. :-)

如果所有这些都有意义,请发布最终的工作代码,并在 https://上进行拉取请求github.com/triSYCL/triSYCL 和新的单元测试代码. :-)

If all this makes sense, please post the final working code and make a pull-request on https://github.com/triSYCL/triSYCL with a new unit test code. :-)

如果您正在查看一些使用SYCL进行元编程的示例,请查看 https://www.khronos. org/assets/uploads/developers/library/2017-supercomputing/Xilinx-triSYCL-complete_Nov17.pdf 幻灯片45--49 https://www.***.com/watch?v=4r6FXxknJEA

If you are looking at some examples of metaprogramming with SYCL, look at https://www.khronos.org/assets/uploads/developers/library/2017-supercomputing/Xilinx-triSYCL-complete_Nov17.pdf slides 45--49 https://www.***.com/watch?v=4r6FXxknJEA