ATLAS Offline Software
Spacepoints.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
11 #include "Spacepoints.h"
12 #include <fstream>
13 
15 {
19 
20  return StatusCode::SUCCESS;
21 }
22 
23 StatusCode Spacepoints::execute(const EventContext &ctx) const
24 {
25  ATH_MSG_DEBUG("In execute(), event slot: "<<ctx.slot());
26 
27  int MAX_DATA_SIZE = 46219;
28 
29  // Prepare input test vector
30  EFTrackingFPGAIntegration::TVHolder spacePointsTV("Spacepoints");
31  ATH_CHECK(m_testVectorTool->prepareTV(m_inputTV, spacePointsTV.inputTV));
32  ATH_CHECK(m_testVectorTool->prepareTV(m_refTV, spacePointsTV.refTV));
33 
34  // print the first 10 elements of the input vector
35  for (int i = 0; i < 10; i++)
36  {
37  ATH_MSG_DEBUG("inputTV[" << std::dec << i << "] = " << std::hex << spacePointsTV.inputTV[i]<<std::dec);
38  }
39 
40  // Work with the accelerator
41  cl_int err = 0;
42 
43  // Allocate buffers on acc. card
44  cl::Buffer acc_inbuff(m_context, CL_MEM_READ_ONLY, spacePointsTV.inputTV.size() * sizeof(uint64_t), NULL, &err);
45  cl::Buffer acc_outbuff(m_context, CL_MEM_READ_WRITE, spacePointsTV.inputTV.size() * sizeof(uint64_t), NULL, &err);
46 
47  // Prepare kernel
48  // Connect kernel to buffer before command queue
49  cl::Kernel acc_kernel(m_program, m_kernelName.value().data(), &err);
50  acc_kernel.setArg(0, acc_inbuff);
51  acc_kernel.setArg(1, acc_outbuff);
52  acc_kernel.setArg<int>(2, spacePointsTV.inputTV.size());
53 
54  // Make queue of commands
55  cl::CommandQueue acc_queue(m_context, m_accelerator);
56 
57  acc_queue.enqueueWriteBuffer(acc_inbuff, CL_TRUE, 0, spacePointsTV.inputTV.size() * sizeof(uint64_t), spacePointsTV.inputTV.data(), NULL, NULL);
58 
59  // // Enqueue task
60  acc_queue.enqueueTask(acc_kernel);
61 
62  acc_queue.finish();
63 
64  std::vector<uint64_t> output(spacePointsTV.inputTV.size(), 0);
65 
66  acc_queue.enqueueReadBuffer(acc_outbuff, CL_TRUE, 0, spacePointsTV.inputTV.size() * sizeof(uint64_t), output.data(), NULL, NULL);
67 
68  // Compare the output with the reference
69  ATH_CHECK(m_testVectorTool->compare(spacePointsTV.refTV, output));
70 
71  return StatusCode::SUCCESS;
72 }
EFTrackingFPGAIntegration::TVHolder::refTV
std::vector< uint64_t > refTV
Definition: TestVectorTool.h:32
IntegrationBase::m_accelerator
cl::Device m_accelerator
Device object for the accelerator card.
Definition: IntegrationBase.h:66
IntegrationBase::initialize
virtual StatusCode initialize() override
Detect the OpenCL devices and prepare OpenCL context.
Definition: IntegrationBase.cxx:14
IntegrationBase::m_context
cl::Context m_context
Context object for the application.
Definition: IntegrationBase.h:67
Spacepoints.h
Class for the spacepoints kernel.
dqt_zlumi_pandas.err
err
Definition: dqt_zlumi_pandas.py:182
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
EFTrackingFPGAIntegration::TVHolder
Definition: TestVectorTool.h:27
Spacepoints::m_kernelName
Gaudi::Property< std::string > m_kernelName
Kernel name.
Definition: Spacepoints.h:31
IntegrationBase::loadProgram
StatusCode loadProgram(const std::string &xclbin)
Find the xclbin file and load it into the OpenCL program object.
Definition: IntegrationBase.cxx:82
IntegrationBase::precheck
StatusCode precheck(std::vector< Gaudi::Property< std::string >> inputs) const
Check if the the desired Gaudi properties are set.
Definition: IntegrationBase.cxx:121
merge.output
output
Definition: merge.py:17
Spacepoints::execute
StatusCode execute(const EventContext &ctx) const override
Should be overriden by derived classes to perform meaningful work.
Definition: Spacepoints.cxx:23
Spacepoints::m_refTV
Gaudi::Property< std::string > m_refTV
Reference TestVector.
Definition: Spacepoints.h:33
Spacepoints::m_xclbin
Gaudi::Property< std::string > m_xclbin
Path and name of the xclbin file.
Definition: Spacepoints.h:30
Spacepoints::initialize
StatusCode initialize() override
Detect the OpenCL devices and prepare OpenCL context.
Definition: Spacepoints.cxx:14
IntegrationBase::m_program
cl::Program m_program
Program object containing the kernel.
Definition: IntegrationBase.h:68
Spacepoints::m_inputTV
Gaudi::Property< std::string > m_inputTV
Input TestVector.
Definition: Spacepoints.h:32
Spacepoints::m_testVectorTool
ToolHandle< TestVectorTool > m_testVectorTool
Tool handle for TestVectorTool.
Definition: Spacepoints.h:35
EFTrackingFPGAIntegration::TVHolder::inputTV
std::vector< uint64_t > inputTV
Definition: TestVectorTool.h:31