- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Tags:
- OpenCL™
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
The cl2.hpp is a wrapper API as shown in https://www.intel.com/content/dam/www/programmable/us/en/pdfs/literature/hb/opencl-sdk/aocl_getting_started.pdf table 1. However it is not fully supported C++ and tied to OpenCL specification based on the version.
To read and write between the kernel and host, you may need to refer https://www.intel.com/content/dam/www/programmable/us/en/pdfs/literature/hb/opencl-sdk/aocl_programming_guide.pdf in chapter 5.5.6.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To summarize the answer: I found that the C++ wrappers (cl::Context, cl:Kernel, etc.) all have the parens operator () to access the underlying C struct (cl_context, cl_kernel, etc.). So it is a trivial matter to mix the C and C++ APIs.
For host-to-dev comms, there are clWritePipeIntelFPGA and clReadPipeIntelFPGA functions on the host side defined in CL/cl_ext_intelfpga.h that must be included in the host code. It seems Intel should have implemented Pipe::write() and Pipe::read() in the wrapper code to call the C Intel functions above.
I also had to declare the following before including any CL headers:
#define CL_HPP_TARGET_OPENCL_VERSION=200
#define CL_TARGET_OPENCL_VERSION=200
I have a good compile now, though getting "ERROR: Enqueue Task (-52)" while running emulation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Do you run compilation successfully?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes. Now working on a hang associated with host write - kernel read pipe operation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
The latest problem seem like same as here: https://forums.intel.com/s/question/0D50P00004XbSe1/host-pipes-not-working-as-documented-in-programming-guide.
I will reply on the forum stated above.
Thanks

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page