Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/140.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 有没有一种方法可以创建cl::sycl::pipe的数组?_C++_Opencl_Sycl - Fatal编程技术网

C++ 有没有一种方法可以创建cl::sycl::pipe的数组?

C++ 有没有一种方法可以创建cl::sycl::pipe的数组?,c++,opencl,sycl,C++,Opencl,Sycl,我正在使用Xilinx的Trisyck github实现 我正在尝试创建一个包含100个cl::sycl::pipes的设计,每个管道的容量为6。我将通过SYCL代码中的一个单独线程访问每个管道 以下是我尝试过的: constexpr int T = 6; constexpr int n_threads = 100; cl::sycl::pipe<cl::sycl::pipe<float>> p { n_threads, cl::sycl::pipe<float&

我正在使用Xilinx的Trisyck github实现

我正在尝试创建一个包含100个
cl::sycl::pipes
的设计,每个管道的
容量为6
。我将通过SYCL代码中的一个单独线程访问每个管道

以下是我尝试过的:

constexpr int T = 6;
constexpr int n_threads = 100;

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

for (int j=0; j<n_threads; j++) {
    q.submit([&](cl::sycl::handler &cgh) {
      // Get write access to the pipe
      auto kp = p[j].get_access<cl::sycl::access::mode::write>(cgh);
      // Get read access to the data
      auto ba = A.get_access<cl::sycl::access::mode::read>(cgh);

      cgh.single_task<class producer>([=] () mutable {
          for (int i = 0; i != T; i++)
            // Try to write to the pipe up to success
            while (!kp.write(ba[i]));
        });
};
constexpr int T=6;
constexpr int n_线程=100;
cl::sycl::pipe p{n_螺纹,cl::sycl::pipe{T};

对于(int j=0;j首先,关于以下事实的免责声明:
cl::sycl::pipe
是临时sycl 2.2规范中的实验性内容,并且仅在CPU上运行(没有加速器,没有FPGA…),而且效率非常低

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

管道类似于某些硬件FIFO

你写的

cl::sycl::pipe<cl::sycl::pipe<float>> p { n_threads, cl::sycl::pipe<float> { T } };
也就是说,我没有试过

此外,在仔细考虑之后,我真的不明白为什么在SYCL 2.2中管道不能有默认构造函数,因为它们只是OpenCL等效对象的包装。我将把这个推给SYCL委员会。感谢您让SYCL变得更好。:-)

如果所有这些都有意义,请发布最终的工作代码,并使用新的单元测试代码提出请求。:-)

如果您正在查看一些使用SYCL进行元编程的示例,请查看 幻灯片45-49

感谢您的回复@Ronan。我正在研究SYCL,因此提出了许多新问题。我会试试看这是否有效。再次感谢。有一个关于管道的新建议,您可能会感兴趣,也会为详细说明做出贡献:
struct my_pipe : cl::sycl::pipe<float> {
  my_pipe() : pipe { T } {};
};

std::array<my_pipe, n_threads> p;