ATLAS Offline Software
Loading...
Searching...
No Matches
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
17
18// XRT includes
19#include "xrt/xrt_device.h"
20#include "xrt/xrt_kernel.h"
21#include <experimental/xrt_ip.h>
22
23// XRT -> CL includes
24#include "CL/cl2xrt.hpp"
25
26// Athena include
27#include "GaudiKernel/ServiceHandle.h"
28#include "GaudiKernel/IChronoSvc.h"
29
30#include <filesystem>
31#include <fstream>
32#include <span>
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 Gaudi::Property<bool> m_runFull150{this, "RunFullF150", "", "Whether to run Full 150 chain"};
70 Gaudi::Property<bool> m_outputTextFile{this, "outputTextFile", "", "Whether to output text file"};
71
72 SG::ReadHandleKey<FPGATrackSimHitCollection> m_FPGAHitKey {this, "FPGATrackSimHitKey","FPGAHits", "FPGATrackSim hits key"}; // Pixel CLS Output
73 SG::ReadHandleKey<FPGATrackSimHitCollection> m_FPGASlicedHitKey{this, "FPGATrackSimHitKey_1st", "FPGAHits_1st_reg34", "FPGATrackSim Hits 1st stage key"}; // Slicing Engine Output
74 SG::ReadHandleKey<FPGATrackSimTrackCollection> m_FPGATrackKey{this, "FPGATrackSimTrack1stKey","FPGATracks_1st_reg34","FPGATrackSim Tracks 1st stage key"}; // Inside Out Output
75
76 SG::WriteHandleKey<std::vector<uint64_t>> m_FPGATrackOutput{this, "FPGAOutputTrackKey", "FPGATrackOutput", "Track output from FPGA format"};
77
78 // Tool for output conversion
79 ToolHandle<OutputConversionTool> m_outputConversionTool{this, "OutputConversionTool", "OutputConversionTool", "tool for output conversion"};
80
81 // XRT Kernels and IPs Name Properties
82 Gaudi::Property<std::string> m_slicingEngineInputName{this, "SlicingEngineInputName", "", "Name of the slicing engine input kernel"};
83 Gaudi::Property<std::string> m_slicingEngineOutputName{this, "SlicingEngineOutputName", "", "Name of the slicing engine output kernel"};
84 Gaudi::Property<std::string> m_insideOutInputName{this, "InsideOutInputName", "", "Name of the inside out input kernel"};
85 Gaudi::Property<std::string> m_insideOutOutputName{this, "InsideOutOutputName", "", "Name of the inside out output kernel"};
86
87
88 Gaudi::Property<std::string> m_pixelEdmKernelName{this, "PixelEDMPrepKernelName", "", "Name of the FPGA kernel"};
89 Gaudi::Property<std::string> m_stripEdmKernelName{this, "StripEDMPrepKernelName", "", "Name of the FPGA kernel"};
90 Gaudi::Property<std::string> m_pixelClusterKernelName{this, "PixelClusterKernelName", "", "Name of the pixel clustering kernel"};
91 Gaudi::Property<std::string> m_stripClusterKernelName{this, "StripClusterKernelName", "", "Name of the strip clustering kernel"};
92 Gaudi::Property<std::string> m_stripL2GKernelName{this, "StripL2GKernelName", "", "Name of the strip L2G kernel"};
93
94
95 mutable std::atomic<cl_ulong> m_IO_kernelTime{0};
96 mutable std::atomic<cl_ulong> m_SE_kernelTime{0};
97 mutable std::atomic<ulonglong> m_numEvents{0};
98 // For IP access through XRT
99 xrt::device m_xrt_accelerator;
100
101 cl::Event m_slicingEngineInputEndEvent ATLAS_THREAD_SAFE;
102 cl::Event m_slicingEngineOutputEndEvent ATLAS_THREAD_SAFE;
103 cl::Event m_insideOutEndEvent ATLAS_THREAD_SAFE;
104
105 // Kernels
106 mutable cl::Kernel m_slicingEngineInput ATLAS_THREAD_SAFE;
107 mutable cl::Kernel m_slicingEngineOutput ATLAS_THREAD_SAFE;
108 mutable cl::Kernel m_insideOutInput ATLAS_THREAD_SAFE;
109 mutable cl::Kernel m_insideOutOutput ATLAS_THREAD_SAFE;
110
111 // Buffers
112 mutable cl::Buffer m_slicingEngineInputBuffer ATLAS_THREAD_SAFE;
113 mutable cl::Buffer m_slicingEngineOutputBuffer ATLAS_THREAD_SAFE;
114 mutable cl::Buffer m_insideOutInputBuffer ATLAS_THREAD_SAFE;
115 mutable cl::Buffer m_insideOutOutputBuffer ATLAS_THREAD_SAFE;
116
117 // F100 kernels
118 // Clustering
119 mutable cl::Kernel m_pixelClusteringKernel ATLAS_THREAD_SAFE;
120 mutable cl::Kernel m_stripClusteringKernel ATLAS_THREAD_SAFE;
121 // L2G
122 mutable cl::Kernel m_stripL2GKernel ATLAS_THREAD_SAFE;
123 // EDM prep
124 mutable cl::Kernel m_pixelEdmPrepKernel ATLAS_THREAD_SAFE;
125 mutable cl::Kernel m_stripEdmPrepKernel ATLAS_THREAD_SAFE;
126
127 // Buffers for input
128 mutable cl::Buffer m_pixelClusterInputBuffer ATLAS_THREAD_SAFE;
129 mutable cl::Buffer m_stripClusterInputBuffer ATLAS_THREAD_SAFE;
130 // Buffers for Clustering
131 mutable cl::Buffer m_pixelClusterOutputBuffer ATLAS_THREAD_SAFE;
132 mutable cl::Buffer m_stripClusterOutputBuffer ATLAS_THREAD_SAFE;
133 mutable cl::Buffer m_pixelClusterEDMOutputBuffer ATLAS_THREAD_SAFE;
134 mutable cl::Buffer m_stripClusterEDMOutputBuffer ATLAS_THREAD_SAFE;
135 // L2G
136 mutable cl::Buffer m_stripL2GInputBuffer ATLAS_THREAD_SAFE;
137 mutable cl::Buffer m_stripL2GEDMInputBuffer ATLAS_THREAD_SAFE;
138
139 mutable cl::Buffer m_stripL2GOutputBuffer ATLAS_THREAD_SAFE;
140 mutable cl::Buffer m_stripL2GEDMOutputBuffer ATLAS_THREAD_SAFE;
141 // EDMPrep
142 mutable cl::Buffer m_edmPixelInputBuffer ATLAS_THREAD_SAFE;
143 mutable cl::Buffer m_edmStripInputBuffer ATLAS_THREAD_SAFE;
144
145 mutable cl::Buffer m_edmPixelOutputBuffer ATLAS_THREAD_SAFE;
146 mutable cl::Buffer m_edmStripOutputBuffer ATLAS_THREAD_SAFE;
147
148 SG::ReadHandleKey<std::vector<uint64_t>> m_FPGAPixelRDO{this, "FPGAEncodedPixelKey", "FPGAEncodedPixelRDOs", "Pixel RDO converted to FPGA format"};
149 SG::ReadHandleKey<std::vector<uint64_t>> m_FPGAStripRDO{this, "FPGAEncodedStripKey", "FPGAEncodedStripRDOs", "Strip RDO converted to FPGA format"};
150
151 SG::ReadHandleKey<int> m_FPGAPixelRDOSize{this, "FPGAEncodedPixelSizeKey", "FPGAEncodedPixelSizeRDOs", "Pixel RDO converted to FPGA format"};
152 SG::ReadHandleKey<int> m_FPGAStripRDOSize{this, "FPGAEncodedStripSizeKey", "FPGAEncodedStripSizeRDOs", "Strip RDO converted to FPGA format"};
153
154 SG::WriteHandleKey<std::vector<uint32_t>> m_FPGAPixelOutput{this, "FPGAOutputPixelKey", "FPGAPixelOutput", "Pixel output from FPGA format"};
155 SG::WriteHandleKey<std::vector<uint32_t>> m_FPGAStripOutput{this, "FPGAOutputStripKey", "FPGAStripOutput", "Strip output from FPGA format"};
156 // Command queue
157 cl::CommandQueue m_queue;
158
159 std::string get_cu_name(const std::string& kernel_name, int cu);
160
161 void dumpHexData(std::span<const uint64_t> data, const std::string &dataDescriptor, const EventContext &ctx) const;
162 void dumpHexData(std::span<const uint32_t> data, const std::string &dataDescriptor, const EventContext &ctx) const;
163 };
164}
165
166#endif // EFTRACKING_FPGA_INTEGRATION_F150KERNELTESTERALG_H
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
Gaudi::Property< bool > m_outputTextFile
Whether to run SE or not.
Gaudi::Property< std::string > m_slicingEngineInputName
Gaudi::Property< std::string > m_pixelEdmKernelName
Name of the FPGA kernel.
Gaudi::Property< bool > m_runIO
Whether to run inside out or not.
virtual StatusCode execute(const EventContext &ctx) const override final
Should be overriden by derived classes to perform meaningful work.
SG::WriteHandleKey< std::vector< uint32_t > > m_FPGAPixelOutput
ToolHandle< FPGADataFormatTool > m_FPGADataFormatTool
Tool for formatting FPGA data.
Gaudi::Property< std::string > m_slicingEngineOutputName
SG::ReadHandleKey< FPGATrackSimHitCollection > m_FPGASlicedHitKey
SG::ReadHandleKey< std::vector< uint64_t > > m_FPGAStripRDO
SG::WriteHandleKey< std::vector< uint64_t > > m_FPGATrackOutput
Gaudi::Property< std::string > m_insideOutOutputName
std::atomic< cl_ulong > m_IO_kernelTime
Time for kernel execution.
Gaudi::Property< std::string > m_stripL2GKernelName
Name of the strip L2G kernelS.
Gaudi::Property< bool > m_runFull150
Whether to run the Full F150 include F100 on hy.
Gaudi::Property< std::string > m_xclbin
Path and name of the xclbin file.
ToolHandle< xAODClusterMaker > m_xaodClusterMaker
Tool for creating xAOD containers.
virtual StatusCode initialize() override final
Detect the OpenCL devices and prepare OpenCL context.
std::atomic< cl_ulong > m_SE_kernelTime
Sum for the average time of the kernel execution.
Gaudi::Property< std::string > m_pixelClusterKernelName
Name of the pixel clustering kernel.
Gaudi::Property< std::string > m_insideOutInputName
std::atomic< ulonglong > m_numEvents
Number of events for the average time of the kernel execution.
ToolHandle< TestVectorTool > m_testVectorTool
Tool for preparing test vectors.
SG::ReadHandleKey< FPGATrackSimTrackCollection > m_FPGATrackKey
SG::ReadHandleKey< FPGATrackSimHitCollection > m_FPGAHitKey
ToolHandle< OutputConversionTool > m_outputConversionTool
Gaudi::Property< bool > m_runIOOnSE
Whether to run inside out on the output of slicing engine.
std::string get_cu_name(const std::string &kernel_name, int cu)
Gaudi::Property< bool > m_runSE
Whether to run SE or not.
ServiceHandle< IChronoSvc > m_chronoSvc
Service for timing the algorithm.
void dumpHexData(std::span< const uint64_t > data, const std::string &dataDescriptor, const EventContext &ctx) const
SG::WriteHandleKey< std::vector< uint32_t > > m_FPGAStripOutput
Gaudi::Property< std::string > m_stripClusterKernelName
Name of the strip clustering kernel.
SG::ReadHandleKey< std::vector< uint64_t > > m_FPGAPixelRDO
Gaudi::Property< std::string > m_stripEdmKernelName
Name of the FPGA kernel.
cl::Event m_slicingEngineInputEndEvent ATLAS_THREAD_SAFE
The base class for the EFTracking FPGA integration development.
Property holding a SG store/key/clid from which a ReadHandle is made.
Property holding a SG store/key/clid from which a WriteHandle is made.
The class for enconding RDO to FPGA format.