13 #include <CL/cl_ext_xilinx.h>
20 std::vector<cl::Platform> platforms;
23 if (
err == CL_SUCCESS)
25 ATH_MSG_INFO(
"Detected OpenCL platforms: " << platforms.size());
30 return StatusCode::FAILURE;
33 std::vector<cl::Device> allDevices;
36 bool foundAccelerator =
false;
39 for (cl::Platform
pf : platforms)
44 ATH_MSG_INFO(
"Platform profile: " <<
pf.getInfo<CL_PLATFORM_PROFILE>());
45 ATH_MSG_INFO(
"Platform vendor: " <<
pf.getInfo<CL_PLATFORM_VENDOR>());
47 pf.getDevices(CL_DEVICE_TYPE_ALL, &allDevices);
48 ATH_MSG_INFO(
"There are " << allDevices.size() <<
" devices in this platform.");
50 for(
auto device : allDevices)
56 foundAccelerator =
true;
60 if (device.getInfo<CL_DEVICE_TYPE>() == CL_DEVICE_TYPE_ACCELERATOR)
62 std::string deviceBDF =
"";
63 device.getInfo(CL_DEVICE_PCIE_BDF, &deviceBDF);
71 foundAccelerator =
true;
77 ATH_MSG_INFO(
"Using the first found accelerator card: " << device.getInfo<CL_DEVICE_NAME>());
79 foundAccelerator =
true;
88 ATH_MSG_INFO(
"Couldn't find an FPGA accelerator card in this platform");
96 ATH_MSG_ERROR(
"Couldn't find an FPGA accelerator card on any platform");
97 return StatusCode::FAILURE;
100 ATH_MSG_INFO(
"Using device number " << device_id <<
" which is a FPGA accelerator card: " <<
m_accelerator.getInfo<CL_DEVICE_NAME>());
105 return StatusCode::SUCCESS;
112 return StatusCode::SUCCESS;
118 std::ifstream bin_file(xclbin, std::ios_base::binary);
122 return StatusCode::FAILURE;
125 bin_file.seekg(0, bin_file.end);
126 unsigned bin_size = bin_file.tellg();
128 bin_file.seekg(0, bin_file.beg);
130 std::vector<char> buf(bin_size);
131 bin_file.read(buf.data(), bin_size);
135 std::vector<cl_int> binaryStatus;
136 cl::Program::Binaries
bins{{buf.data(), bin_size}};
141 if (
err == CL_SUCCESS && binaryStatus.at(0) == CL_SUCCESS)
148 return StatusCode::FAILURE;
151 return StatusCode::SUCCESS;
160 ATH_MSG_FATAL(
item.documentation()<<
" is empty. Please set it to a valid value");
161 return StatusCode::FAILURE;
168 ATH_MSG_WARNING(
"Device BDF is not set. Using the first found accelerator card. Set property 'bdfID' to specify the BDF of the device.");
171 return StatusCode::SUCCESS;