Forum Discussion

okramer's avatar
okramer
Icon for Occasional Contributor rankOccasional Contributor
7 years ago

OpenCL C++ API for Pipes doesn't provide read/write methods?

I'm looking for guidance here, as I'm confused on whether to use OpenCL C or C++ API. I'm learning to use host pipes. The examples use the C++ API for establishing queues and contexts, etc., but then the example pipes code is all in C. There is a C++ API for pipes (in cl2.hpp), namely, cl::Pipes. However, I don't see any method for reading or writing to a cl::Pipe object. How is this accomplished? Here is the relevant host code:

// Create host-to-FPGA pipe and bind to kernel, then launch:
   std::vector<cl::Device> DeviceList;
   cl::Context context;
   getContextAndDevices(mode, context, DeviceList);  // Fetch items using OpenCL C++ API
   cl::Pipe p_out (context, sizeof(float), vectorSize, &err);
   host_reader_kernel.setArg(0, &p_out);
   err=queue1.enqueueTask(host_reader_kernel);
 
   // Write data to the FPGA via pipe. THIS DOES NOT COMPILE because "write_pipe" not declared:
   float data=42.0;
   cl::write_pipe(p_out, data);

In the kernel code, there is `write_pipe()` so I took a guess that host-side would be the same API. It is supposed to be C++ though so would have expected write_pipe() to be a method on cl::Pipe. Are C++ Pipes not supported? Do I have to do everything (contexts, queues, etc) in OpenCL's C API?

5 Replies