ATLAS Offline Software
F150KernelTesterAlg.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 #ifndef EFTRACKING_FPGA_INTEGRATION_F150KERNELTESTERALG_H
7 #define EFTRACKING_FPGA_INTEGRATION_F150KERNELTESTERALG_H
8 
9 // EFTracking include
18 
19 // XRT includes
20 #include "xrt/xrt_device.h"
21 #include "xrt/xrt_kernel.h"
22 #include <experimental/xrt_ip.h>
23 
24 // XRT -> CL includes
25 #include "CL/cl2xrt.hpp"
26 
27 // Athena include
28 #include "GaudiKernel/ServiceHandle.h"
29 #include "GaudiKernel/IChronoSvc.h"
30 
31 #include <filesystem>
32 #include <fstream>
33 
34 #define EVENT_COUNT_RST 0x80000000
35 #define USER_CTRL_OFFSET 0x10
36 
38 {
40  {
41  public:
42  using IntegrationBase::IntegrationBase;
43  virtual StatusCode initialize() override final;
44  virtual StatusCode execute(const EventContext &ctx) const override final;
45  virtual StatusCode finalize() override final;
46 
47 
48  private:
50  "ChronoStatSvc", name()};
51 
52  ToolHandle<xAODClusterMaker> m_xaodClusterMaker{
53  this,
54  "xAODClusterMaker",
55  "xAODClusterMaker",
56  "Tool for creating xAOD cluster containers"};
57 
58  ToolHandle<TestVectorTool> m_testVectorTool{
59  this, "TestVectorTool", "TestVectorTool", "Tool for preparing test vectors"};
60 
61  ToolHandle<FPGADataFormatTool> m_FPGADataFormatTool{
62  this, "FPGADataFormatTool", "FPGADataFormatTool", "Tool for formatting FPGA data"};
63 
64  Gaudi::Property<std::string> m_xclbin{this, "xclbin", "", "xclbin path and name"};
65 
66  Gaudi::Property<bool> m_runSE{this, "RunSlicing", "", "Whether to run slicing engine or not"};
67  Gaudi::Property<bool> m_runIO{this, "RunInsideOut", "", "Whether to run inside out or not"};
68  Gaudi::Property<bool> m_runIOOnSE{this, "RunInsideOutOnSlicingEngine", "", "Whether to run inside out on the output of the slicing engine"};
69 
70  SG::ReadHandleKey<FPGATrackSimHitCollection> m_FPGAHitKey {this, "FPGATrackSimHitKey","FPGAHits", "FPGATrackSim hits key"}; // Pixel CLS Output
71  SG::ReadHandleKey<FPGATrackSimHitCollection> m_FPGASlicedHitKey{this, "FPGATrackSimHitKey_1st", "FPGAHits_1st_reg34", "FPGATrackSim Hits 1st stage key"}; // Slicing Engine Output
72  SG::ReadHandleKey<FPGATrackSimTrackCollection> m_FPGATrackKey{this, "FPGATrackSimTrack1stKey","FPGATracks_1st_reg34","FPGATrackSim Tracks 1st stage key"}; // Inside Out Output
73 
74  // Tool for output conversion
75  ToolHandle<OutputConversionTool> m_outputConversionTool{this, "OutputConversionTool", "OutputConversionTool", "tool for output conversion"};
76 
77  // XRT Kernels and IPs Name Properties
78  Gaudi::Property<std::string> m_slicingEngineInputName{this, "SlicingEngineInputName", "", "Name of the slicing engine input kernel"};
79  Gaudi::Property<std::string> m_slicingEngineName{this, "SlicingEngineName", "", "Name of the slicing engine kernel"};
80  Gaudi::Property<std::string> m_slicingEngineOutputName{this, "SlicingEngineOutputName", "", "Name of the slicing engine output kernel"};
81  Gaudi::Property<std::string> m_insideOutInputName{this, "InsideOutInputName", "", "Name of the inside out input kernel"};
82  Gaudi::Property<std::string> m_insideOutOutputName{this, "InsideOutOutputName", "", "Name of the inside out output kernel"};
83 
84  mutable std::atomic<cl_ulong> m_kernelTime{0};
85  mutable std::atomic<cl_ulong> m_sum_kernelTime{0};
86  mutable std::atomic<ulonglong> m_num_Events{0};
87  // For IP access through XRT
88  xrt::device m_xrt_accelerator;
89 
93 
94 
95  // Kernels
97  mutable cl::Kernel m_slicingEngineInput;
98  mutable cl::Kernel m_slicingEngineOutput;
99  mutable cl::Kernel m_insideOutInput;
100  mutable cl::Kernel m_insideOutOutput;
101 
102 
103  // Buffers
104  mutable cl::Buffer m_slicingEngineInputBuffer;
105  mutable cl::Buffer m_slicingEngineOutputBuffer;
106  mutable cl::Buffer m_insideOutInputBuffer;
107  mutable cl::Buffer m_insideOutOutputBuffer;
108 
109  // Command queue
110  cl::CommandQueue m_queue;
111 
112  std::string get_cu_name(const std::string& kernel_name, int cu);
113 
114  void dumpHexData(size_t dataLen, uint64_t *data, const std::string &dataDescriptor) const;
115  };
116 }
117 
118 #endif // EFTRACKING_FPGA_INTEGRATION_F150KERNELTESTERALG_H
119 
EFTrackingFPGAIntegration::F150KernelTesterAlg::get_cu_name
std::string get_cu_name(const std::string &kernel_name, int cu)
Definition: F150KernelTesterAlg.cxx:12
IntegrationBase
The base class for the EFTracking FPGA integration development.
Definition: IntegrationBase.h:38
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_slicingEngineInputName
Gaudi::Property< std::string > m_slicingEngineInputName
Definition: F150KernelTesterAlg.h:78
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_FPGADataFormatTool
ToolHandle< FPGADataFormatTool > m_FPGADataFormatTool
Tool for formatting FPGA data.
Definition: F150KernelTesterAlg.h:61
FPGATrackSimHitCollection.h
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_insideOutOutput
cl::Kernel m_insideOutOutput
Definition: F150KernelTesterAlg.h:100
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_slicingEngineName
Gaudi::Property< std::string > m_slicingEngineName
Definition: F150KernelTesterAlg.h:79
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_chronoSvc
ServiceHandle< IChronoSvc > m_chronoSvc
Service for timing the algorithm.
Definition: F150KernelTesterAlg.h:49
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_slicingEngineOutputName
Gaudi::Property< std::string > m_slicingEngineOutputName
Definition: F150KernelTesterAlg.h:80
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_outputConversionTool
ToolHandle< OutputConversionTool > m_outputConversionTool
Definition: F150KernelTesterAlg.h:75
JiveXML::Event
struct Event_t Event
Definition: ONCRPCServer.h:65
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_insideOutInputName
Gaudi::Property< std::string > m_insideOutInputName
Definition: F150KernelTesterAlg.h:81
EFTrackingFPGAIntegration::F150KernelTesterAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Should be overriden by derived classes to perform meaningful work.
Definition: F150KernelTesterAlg.cxx:81
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_num_Events
std::atomic< ulonglong > m_num_Events
Number of events for the average time of the kernel execution.
Definition: F150KernelTesterAlg.h:86
EFTrackingFPGAIntegration::F150KernelTesterAlg
Definition: F150KernelTesterAlg.h:40
IntegrationBase.h
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_slicingEngineOutputEndEvent
cl::Event m_slicingEngineOutputEndEvent
Definition: F150KernelTesterAlg.h:91
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_queue
cl::CommandQueue m_queue
Definition: F150KernelTesterAlg.h:110
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_runIOOnSE
Gaudi::Property< bool > m_runIOOnSE
Whether to run inside out on the output of slicing engine.
Definition: F150KernelTesterAlg.h:68
SG::ReadHandleKey< FPGATrackSimHitCollection >
EFTrackingFPGAIntegration::F150KernelTesterAlg::dumpHexData
void dumpHexData(size_t dataLen, uint64_t *data, const std::string &dataDescriptor) const
Definition: F150KernelTesterAlg.cxx:18
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_sum_kernelTime
std::atomic< cl_ulong > m_sum_kernelTime
Sum for the average time of the kernel execution.
Definition: F150KernelTesterAlg.h:85
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_insideOutInput
cl::Kernel m_insideOutInput
Definition: F150KernelTesterAlg.h:99
DataPreparationPipeline.h
FPGATrackSimTrackCollection.h
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_slicingEngineInput
cl::Kernel m_slicingEngineInput
Definition: F150KernelTesterAlg.h:97
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_xaodClusterMaker
ToolHandle< xAODClusterMaker > m_xaodClusterMaker
Tool for creating xAOD containers.
Definition: F150KernelTesterAlg.h:52
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_slicingEngineOutputBuffer
cl::Buffer m_slicingEngineOutputBuffer
Definition: F150KernelTesterAlg.h:105
EFTrackingFPGAIntegration::F150KernelTesterAlg::initialize
virtual StatusCode initialize() override final
Detect the OpenCL devices and prepare OpenCL context.
Definition: F150KernelTesterAlg.cxx:26
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_insideOutEndEvent
cl::Event m_insideOutEndEvent
Definition: F150KernelTesterAlg.h:92
find_tgc_unfilled_channelids.ip
ip
Definition: find_tgc_unfilled_channelids.py:3
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
OutputConversionTool.h
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_xrt_accelerator
xrt::device m_xrt_accelerator
Definition: F150KernelTesterAlg.h:88
EFTrackingFPGAIntegration
The class for enconding RDO to FPGA format.
Definition: BenchmarkAlg.h:28
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_slicingEngineInputEndEvent
cl::Event m_slicingEngineInputEndEvent
Definition: F150KernelTesterAlg.h:90
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_runIO
Gaudi::Property< bool > m_runIO
Whether to run inside out or not.
Definition: F150KernelTesterAlg.h:67
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_testVectorTool
ToolHandle< TestVectorTool > m_testVectorTool
Tool for preparing test vectors.
Definition: F150KernelTesterAlg.h:58
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_slicingEngineOutput
cl::Kernel m_slicingEngineOutput
Definition: F150KernelTesterAlg.h:98
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_xclbin
Gaudi::Property< std::string > m_xclbin
Path and name of the xclbin file.
Definition: F150KernelTesterAlg.h:64
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_slicingEngineIP
xrt::ip m_slicingEngineIP
Definition: F150KernelTesterAlg.h:96
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_runSE
Gaudi::Property< bool > m_runSE
Whether to run SE or not.
Definition: F150KernelTesterAlg.h:66
xAODClusterMaker.h
EFTrackingFPGAIntegration::F150KernelTesterAlg::finalize
virtual StatusCode finalize() override final
Definition: F150KernelTesterAlg.cxx:164
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_insideOutOutputName
Gaudi::Property< std::string > m_insideOutOutputName
Definition: F150KernelTesterAlg.h:82
FPGADataFormatTool.h
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_insideOutInputBuffer
cl::Buffer m_insideOutInputBuffer
Definition: F150KernelTesterAlg.h:106
TestVectorTool.h
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_slicingEngineInputBuffer
cl::Buffer m_slicingEngineInputBuffer
Definition: F150KernelTesterAlg.h:104
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_insideOutOutputBuffer
cl::Buffer m_insideOutOutputBuffer
Definition: F150KernelTesterAlg.h:107
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_FPGASlicedHitKey
SG::ReadHandleKey< FPGATrackSimHitCollection > m_FPGASlicedHitKey
Definition: F150KernelTesterAlg.h:71
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_kernelTime
std::atomic< cl_ulong > m_kernelTime
Time for kernel execution.
Definition: F150KernelTesterAlg.h:84
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_FPGATrackKey
SG::ReadHandleKey< FPGATrackSimTrackCollection > m_FPGATrackKey
Definition: F150KernelTesterAlg.h:72
EFTrackingFPGAIntegration::F150KernelTesterAlg::m_FPGAHitKey
SG::ReadHandleKey< FPGATrackSimHitCollection > m_FPGAHitKey
Definition: F150KernelTesterAlg.h:70
ServiceHandle< IChronoSvc >