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
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#include <span>
34
35#define EVENT_COUNT_RST 0x80000000
36#define USER_CTRL_OFFSET 0x10
37
39{
41 {
42 public:
43 using IntegrationBase::IntegrationBase;
44 virtual StatusCode initialize() override final;
45 virtual StatusCode execute(const EventContext &ctx) const override final;
46 virtual StatusCode finalize() override final;
47
48
49 private:
51 "ChronoStatSvc", name()};
52
53 ToolHandle<xAODClusterMaker> m_xaodClusterMaker{
54 this,
55 "xAODClusterMaker",
56 "xAODClusterMaker",
57 "Tool for creating xAOD cluster containers"};
58
59 ToolHandle<TestVectorTool> m_testVectorTool{
60 this, "TestVectorTool", "TestVectorTool", "Tool for preparing test vectors"};
61
62 ToolHandle<FPGADataFormatTool> m_FPGADataFormatTool{
63 this, "FPGADataFormatTool", "FPGADataFormatTool", "Tool for formatting FPGA data"};
64
65 Gaudi::Property<std::string> m_xclbin{this, "xclbin", "", "xclbin path and name"};
66
67 Gaudi::Property<bool> m_runSE{this, "RunSlicing", "", "Whether to run slicing engine or not"};
68 Gaudi::Property<bool> m_runIO{this, "RunInsideOut", "", "Whether to run inside out or not"};
69 Gaudi::Property<bool> m_runIOOnSE{this, "RunInsideOutOnSlicingEngine", "", "Whether to run inside out on the output of the slicing engine"};
70 Gaudi::Property<bool> m_runFull150{this, "RunFullF150", "", "Whether to run Full 150 chain"};
71 Gaudi::Property<bool> m_outputTextFile{this, "outputTextFile", "", "Whether to output text file"};
72
73 SG::ReadHandleKey<FPGATrackSimHitCollection> m_FPGAHitKey {this, "FPGATrackSimHitKey","FPGAHits", "FPGATrackSim hits key"}; // Pixel CLS Output
74 SG::ReadHandleKey<FPGATrackSimHitCollection> m_FPGASlicedHitKey{this, "FPGATrackSimHitKey_1st", "FPGAHits_1st_reg34", "FPGATrackSim Hits 1st stage key"}; // Slicing Engine Output
75 SG::ReadHandleKey<FPGATrackSimTrackCollection> m_FPGATrackKey{this, "FPGATrackSimTrack1stKey","FPGATracks_1st_reg34","FPGATrackSim Tracks 1st stage key"}; // Inside Out Output
76
77 SG::WriteHandleKey<std::vector<uint64_t>> m_FPGATrackOutput{this, "FPGAOutputTrackKey", "FPGATrackOutput", "Track output from FPGA format"};
78
79 // Tool for output conversion
80 ToolHandle<OutputConversionTool> m_outputConversionTool{this, "OutputConversionTool", "OutputConversionTool", "tool for output conversion"};
81
82 // XRT Kernels and IPs Name Properties
83 Gaudi::Property<std::string> m_slicingEngineInputName{this, "SlicingEngineInputName", "", "Name of the slicing engine input kernel"};
84 Gaudi::Property<std::string> m_slicingEngineOutputName{this, "SlicingEngineOutputName", "", "Name of the slicing engine output kernel"};
85 Gaudi::Property<std::string> m_insideOutInputName{this, "InsideOutInputName", "", "Name of the inside out input kernel"};
86 Gaudi::Property<std::string> m_insideOutOutputName{this, "InsideOutOutputName", "", "Name of the inside out output kernel"};
87
88
89 Gaudi::Property<std::string> m_pixelEdmKernelName{this, "PixelEDMPrepKernelName", "", "Name of the FPGA kernel"};
90 Gaudi::Property<std::string> m_stripEdmKernelName{this, "StripEDMPrepKernelName", "", "Name of the FPGA kernel"};
91 Gaudi::Property<std::string> m_pixelClusterKernelName{this, "PixelClusterKernelName", "", "Name of the pixel clustering kernel"};
92 Gaudi::Property<std::string> m_stripClusterKernelName{this, "StripClusterKernelName", "", "Name of the strip clustering kernel"};
93 Gaudi::Property<std::string> m_stripL2GKernelName{this, "StripL2GKernelName", "", "Name of the strip L2G kernel"};
94
95
96 mutable std::atomic<cl_ulong> m_IO_kernelTime{0};
97 mutable std::atomic<cl_ulong> m_SE_kernelTime{0};
98 mutable std::atomic<ulonglong> m_numEvents{0};
99 // For IP access through XRT
100 xrt::device m_xrt_accelerator;
101
102 cl::Event m_slicingEngineInputEndEvent ATLAS_THREAD_SAFE;
103 cl::Event m_slicingEngineOutputEndEvent ATLAS_THREAD_SAFE;
104 cl::Event m_insideOutEndEvent ATLAS_THREAD_SAFE;
105
106 // Kernels
107 mutable cl::Kernel m_slicingEngineInput ATLAS_THREAD_SAFE;
108 mutable cl::Kernel m_slicingEngineOutput ATLAS_THREAD_SAFE;
109 mutable cl::Kernel m_insideOutInput ATLAS_THREAD_SAFE;
110 mutable cl::Kernel m_insideOutOutput ATLAS_THREAD_SAFE;
111
112 // Buffers
113 mutable cl::Buffer m_slicingEngineInputBuffer ATLAS_THREAD_SAFE;
114 mutable cl::Buffer m_slicingEngineOutputBuffer ATLAS_THREAD_SAFE;
115 mutable cl::Buffer m_insideOutInputBuffer ATLAS_THREAD_SAFE;
116 mutable cl::Buffer m_insideOutOutputBuffer ATLAS_THREAD_SAFE;
117
118 // F100 kernels
119 // Clustering
120 mutable cl::Kernel m_pixelClusteringKernel ATLAS_THREAD_SAFE;
121 mutable cl::Kernel m_stripClusteringKernel ATLAS_THREAD_SAFE;
122 // L2G
123 mutable cl::Kernel m_stripL2GKernel ATLAS_THREAD_SAFE;
124 // EDM prep
125 mutable cl::Kernel m_pixelEdmPrepKernel ATLAS_THREAD_SAFE;
126 mutable cl::Kernel m_stripEdmPrepKernel ATLAS_THREAD_SAFE;
127
128 // Buffers for input
129 mutable cl::Buffer m_pixelClusterInputBuffer ATLAS_THREAD_SAFE;
130 mutable cl::Buffer m_stripClusterInputBuffer ATLAS_THREAD_SAFE;
131 // Buffers for Clustering
132 mutable cl::Buffer m_pixelClusterOutputBuffer ATLAS_THREAD_SAFE;
133 mutable cl::Buffer m_stripClusterOutputBuffer ATLAS_THREAD_SAFE;
134 mutable cl::Buffer m_pixelClusterEDMOutputBuffer ATLAS_THREAD_SAFE;
135 mutable cl::Buffer m_stripClusterEDMOutputBuffer ATLAS_THREAD_SAFE;
136 // L2G
137 mutable cl::Buffer m_stripL2GInputBuffer ATLAS_THREAD_SAFE;
138 mutable cl::Buffer m_stripL2GEDMInputBuffer ATLAS_THREAD_SAFE;
139
140 mutable cl::Buffer m_stripL2GOutputBuffer ATLAS_THREAD_SAFE;
141 mutable cl::Buffer m_stripL2GEDMOutputBuffer ATLAS_THREAD_SAFE;
142 // EDMPrep
143 mutable cl::Buffer m_edmPixelInputBuffer ATLAS_THREAD_SAFE;
144 mutable cl::Buffer m_edmStripInputBuffer ATLAS_THREAD_SAFE;
145
146 mutable cl::Buffer m_edmPixelOutputBuffer ATLAS_THREAD_SAFE;
147 mutable cl::Buffer m_edmStripOutputBuffer ATLAS_THREAD_SAFE;
148
149 SG::ReadHandleKey<std::vector<uint64_t>> m_FPGAPixelRDO{this, "FPGAEncodedPixelKey", "FPGAEncodedPixelRDOs", "Pixel RDO converted to FPGA format"};
150 SG::ReadHandleKey<std::vector<uint64_t>> m_FPGAStripRDO{this, "FPGAEncodedStripKey", "FPGAEncodedStripRDOs", "Strip RDO converted to FPGA format"};
151
152 SG::ReadHandleKey<int> m_FPGAPixelRDOSize{this, "FPGAEncodedPixelSizeKey", "FPGAEncodedPixelSizeRDOs", "Pixel RDO converted to FPGA format"};
153 SG::ReadHandleKey<int> m_FPGAStripRDOSize{this, "FPGAEncodedStripSizeKey", "FPGAEncodedStripSizeRDOs", "Strip RDO converted to FPGA format"};
154
155 SG::WriteHandleKey<std::vector<uint32_t>> m_FPGAPixelOutput{this, "FPGAOutputPixelKey", "FPGAPixelOutput", "Pixel output from FPGA format"};
156 SG::WriteHandleKey<std::vector<uint32_t>> m_FPGAStripOutput{this, "FPGAOutputStripKey", "FPGAStripOutput", "Strip output from FPGA format"};
157 // Command queue
158 cl::CommandQueue m_queue;
159
160 std::string get_cu_name(const std::string& kernel_name, int cu);
161
162 void dumpHexData(std::span<const uint64_t> data, const std::string &dataDescriptor, const EventContext &ctx) const;
163 void dumpHexData(std::span<const uint32_t> data, const std::string &dataDescriptor, const EventContext &ctx) const;
164 };
165}
166
167#endif // EFTRACKING_FPGA_INTEGRATION_F150KERNELTESTERALG_H
168
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.