6 #include "GaudiKernel/ConcurrencyFlags.h"
19 std::vector<std::shared_ptr<xrt::device>> devices =
21 if (devices.empty()) {
23 return StatusCode::FAILURE;
27 std::size_t slotIdx = 0;
35 const std::size_t device_idx = slotIdx % devices.size();
36 ATH_MSG_DEBUG(
"Using device " << device_idx <<
" for slot " << slotIdx);
37 slot.m_device = devices[device_idx];
41 slot.m_kernel = std::make_unique<xrt::kernel>(
42 *slot.m_device, slot.m_device->get_xclbin_uuid(),
s_krnl_name);
44 std::exception_ptr
p = std::current_exception();
46 "Could not create XRT kernel '"
48 <<
"', check that correct XCLBIN is programmed by AthXRT service");
49 return StatusCode::FAILURE;
61 slot.m_bo_in1 = std::make_unique<xrt::bo>(
62 *slot.m_device, size_in_bytes, xrt::bo::flags::normal, bank_grp_in1);
63 slot.m_bo_in2 = std::make_unique<xrt::bo>(
64 *slot.m_device, size_in_bytes, xrt::bo::flags::normal, bank_grp_in2);
65 slot.m_bo_out = std::make_unique<xrt::bo>(
66 *slot.m_device, size_in_bytes, xrt::bo::flags::normal, bank_grp_out);
69 slot.m_run = std::make_unique<xrt::run>(*slot.m_kernel);
79 return StatusCode::SUCCESS;
99 slot.
m_bo_in1->sync(XCL_BO_SYNC_BO_TO_DEVICE);
100 slot.
m_bo_in2->sync(XCL_BO_SYNC_BO_TO_DEVICE);
107 slot.
m_bo_out->sync(XCL_BO_SYNC_BO_FROM_DEVICE);
112 uint32_t cpu_result = buffer_in1[
i] * buffer_in2[
i];
113 if (buffer_out[
i] != cpu_result) {
115 <<
i <<
": CPU result = " << cpu_result
116 <<
" Device result = " << buffer_out[
i]);
125 return StatusCode::FAILURE;
129 return StatusCode::SUCCESS;