ATLAS Offline Software
Loading...
Searching...
No Matches
F600IntegrationAlg.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_F600INTEGRATIONALG_H
7 #define EFTRACKING_FPGA_INTEGRATION_F600INTEGRATIONALG_H
8
9 // EFTracking include
17
18 // Athena include
19 #include "GaudiKernel/ServiceHandle.h"
20 #include "GaudiKernel/IChronoSvc.h"
21
22// XRT includes
23#include "xrt/xrt_bo.h"
24#include "xrt/xrt_device.h"
25#include "xrt/xrt_kernel.h"
26#include <experimental/xrt_xclbin.h>
27#include <experimental/xrt_ip.h>
28#include <experimental/xrt_queue.h>
29
30// XRT -> CL includes
31#include "CL/cl2xrt.hpp"
32
33#include <filesystem>
34#include <fstream>
35
36#define IP_START 0x1 // USER_CTRL[0]
37#define IP_DONE 0x2 // USER_CTRL[1]
38#define IP_IDLE 0x4 // USER_CTRL[2]
39#define EVENT_COUNT_RST 0x80000000 // USER_CTRL[31]
40// Addresses
41#define USER_CTRL_OFFSET 0x10
42#define EVENT_RX_COUNT_OFFSET 0x14
43#define EVENT_TX_COUNT_OFFSET 0x1C
44
46 {
48 {
49 public:
50 using IntegrationBase::IntegrationBase;
51 virtual StatusCode initialize() override final;
52 virtual StatusCode execute(const EventContext &ctx) const override final;
53 virtual StatusCode finalize() override final;
54
55
56 private:
58 "ChronoStatSvc", name()};
59
60 ToolHandle<xAODClusterMaker> m_xaodClusterMaker{
61 this,
62 "xAODClusterMaker",
63 "xAODClusterMaker",
64 "Tool for creating xAOD cluster containers"};
65
66 ToolHandle<TestVectorTool> m_testVectorTool{
67 this, "TestVectorTool", "TestVectorTool", "Tool for preparing test vectors"};
68
69 ToolHandle<FPGADataFormatTool> m_FPGADataFormatTool{
70 this, "FPGADataFormatTool", "FPGADataFormatTool", "Tool for formatting FPGA data"};
71
72 Gaudi::Property<std::string> m_xclbin{
73 this, "xclbin", "", "xclbin path and name"};
74
75 SG::ReadHandleKey<FPGATrackSimTrackCollection> m_FPGATrackKey{this, "FPGATrackSimTrack1stKey","FPGATracks_1st_reg34","FPGATrackSim Tracks 1st stage key"};
76
77 // Tool for output conversion
78 ToolHandle<OutputConversionTool> m_outputConversionTool{this, "OutputConversionTool", "OutputConversionTool", "tool for output conversion"};
79
80 // XRT Kernels and IPs Name Properties
81 // Data Prep
82 Gaudi::Property<std::string> m_pixelClusteringKernelName{
83 this, "PixelClusteringKernelName", "", "Name of the pixel clustering kernel (pxl cls)"};
84 Gaudi::Property<std::string> m_processHitsKernelName{
85 this, "ProcessHitsKernelName", "", "Name of the strip clustering kernel (strp cls)"};
86 Gaudi::Property<std::string> m_pixelL2gKernelName{
87 this, "PixelL2gKernelName", "", "Name of the pixel L2G transformation kernel"};
88 Gaudi::Property<std::string> m_stripL2gKernelName{
89 this, "StripL2gKernelName", "", "Name of the strip L2G transformation kernel"};
90 Gaudi::Property<std::string> m_pixelEdmPrepKernelName{
91 this, "PixelEdmPrepKernelName", "", "Name of the pixel EDM prep kernel"};
92 Gaudi::Property<std::string> m_stripEdmPrepKernelName{
93 this, "StripEdmPrepKernelName", "", "Name of the strip EDM prep kernel"};
94
95 // Slicing Engine
96 Gaudi::Property<std::string> m_pixelFirstStageSlicingIPName{
97 this, "PixelFirstStageSlicingIPName", "", "Name of the slicing engine IP"};
98 Gaudi::Property<std::string> m_pixelFirstStageInputKernelName{
99 this, "PixelFirstStageInputKernelName", "", "Name of the input stage kernel"};
100 Gaudi::Property<std::string> m_pixelFirstStageOutputKernelName{
101 this, "PixelFirstStageOutputKernelName", "", "Name of the output stage kernel"};
102
103 // Inside Out
104 Gaudi::Property<std::string> m_memReadKernelName{
105 this, "MemReadKernelName", "", "Name of the memory read kernel"};
106 Gaudi::Property<std::string> m_memWriteKernelName{
107 this, "MemWriteKernelName", "", "Name of the memory write kernel"};
108
109 // Space Points
110 Gaudi::Property<std::string> m_spacepointKernelName{
111 this, "SpacepointKernelName", "", "Name of the spacepoint kernel"};
112
113 // NN Pathfinder
114 Gaudi::Property<std::string> m_loaderKernelName{
115 this, "LoaderKernelName", "", "Name of the loader kernel"};
116 Gaudi::Property<std::string> m_unloaderKernelName{
117 this, "UnloaderKernelName", "", "Name of the unloader kernel"};
118
119 // NN Classifier
120 Gaudi::Property<std::string> m_nnOverlapDecoratorKernelName{
121 this, "NnOverlapDecoratorKernelName", "", "Name of the NN overlap decorator kernel"};
122
123 // Duplicate Remover
124 Gaudi::Property<std::string> m_runnerKernelName{
125 this, "RunnerKernelName", "", "Name of the duplicate remover runner kernel"};
126
127 // NOTE: Temporary and for injecting TV data
128 Gaudi::Property<std::string> m_pixelClusterInputPath{
129 this, "PixelClusterInputPath", "", "Filepath for the pixel clustering input data"};
130 Gaudi::Property<std::string> m_pixelStageOneSlicingInputPath{
131 this, "PixelStageOneSlicingInputPath", "", "Filepath for the slicing engine (pixel first stage) input data"};
132 Gaudi::Property<std::string> m_insideOutInputPath{
133 this, "InsideOutInputPath", "", "Filepath for the inside out input data"};
134
135 // NOTE WHA TI NEED: max size for IO for all the kernels. working SE other stages
136
137 mutable std::atomic<cl_ulong> m_kernelTime{0};
138 mutable std::atomic<cl_ulong> m_sum_kernelTime{0};
139 mutable std::atomic<ulonglong> m_num_Events{0};
140
141 // For IP access through XRT
142 xrt::device m_xrt_accelerator;
143
144 mutable std::mutex m_fpgaHandleMtx ATLAS_THREAD_SAFE;
145
146 mutable std::vector<cl::Event> m_pixelFirstStageSlicingInputEndEvents ATLAS_THREAD_SAFE;
147 mutable std::vector<cl::Event> m_pixelFirstStageSlicingOutputEndEvents ATLAS_THREAD_SAFE;
148 mutable std::vector<cl::Event> m_insideOutInputEndEvents ATLAS_THREAD_SAFE;
149 mutable std::vector<cl::Event> m_insideOutOutputEndEvents ATLAS_THREAD_SAFE;
150
151
152 // Pixel CLS
153 mutable std::vector<cl::Kernel> m_pixelClusterL2GKernels ATLAS_THREAD_SAFE;
154 // Slicing Engine
155 mutable std::vector<cl::Kernel> m_pixelFirstStageSlicingInputKernels ATLAS_THREAD_SAFE;
156 mutable std::vector<xrt::ip> m_pixelFirstStageSlicingIPs ATLAS_THREAD_SAFE;
157 mutable std::vector<cl::Kernel> m_pixelFirstStageSlicingOutputKernels ATLAS_THREAD_SAFE;
158 // Inside Out
159 mutable std::vector<cl::Kernel> m_insideOutInputKernels ATLAS_THREAD_SAFE;
160 mutable std::vector<cl::Kernel> m_insideOutOutputKernels ATLAS_THREAD_SAFE;
161
162
163
164 // Buffers for Clustering & L2G
165 mutable std::vector<cl::Buffer> m_pixelClusterL2GInputBufferList ATLAS_THREAD_SAFE;
166 mutable std::vector<cl::Buffer> m_pixelClusterL2GOutputBufferList ATLAS_THREAD_SAFE;
167 mutable std::vector<cl::Buffer> m_pixelClusterL2GEDMOutputBufferList ATLAS_THREAD_SAFE;
168 // Buffers for slicing engine
169 mutable std::vector<cl::Buffer> m_pixelFirstStageSlicingInputBufferList ATLAS_THREAD_SAFE;
170 mutable std::vector<cl::Buffer> m_pixelFirstStageSlicingOutputBufferList ATLAS_THREAD_SAFE;
171 // Buffers for inside out
172 mutable std::vector<cl::Buffer> m_insideOutInputBufferList ATLAS_THREAD_SAFE;
173 mutable std::vector<cl::Buffer> m_insideOutOutputBufferList ATLAS_THREAD_SAFE;
174
175 // Command queue
176 cl::CommandQueue m_queue;
177
178 std::string get_cu_name(const std::string& kernel_name, int cu);
179
180 // NOTE: These are temporary and are used to inject TVs in where kernels would otherwise go.
181 // Once all kernels are working these will be removed.
182 int readTVLength(std::string filepath) const;
183 void readTV(const std::string &filepath, int n_words, uint64_t *data) const;
184
185 void outputHexData(size_t dataLen, uint64_t *data, const std::string &dataDescriptor) const;
186 };
187 }
188
189 #endif // EFTRACKING_FPGA_INTEGRATION_F600INTEGRATIONALG_H
190
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
Gaudi::Property< std::string > m_pixelFirstStageInputKernelName
std::atomic< cl_ulong > m_sum_kernelTime
Sum for the average time of the kernel execution.
void outputHexData(size_t dataLen, uint64_t *data, const std::string &dataDescriptor) const
Gaudi::Property< std::string > m_pixelStageOneSlicingInputPath
Gaudi::Property< std::string > m_pixelClusteringKernelName
virtual StatusCode initialize() override final
Detect the OpenCL devices and prepare OpenCL context.
std::atomic< cl_ulong > m_kernelTime
Time for kernel execution.
Gaudi::Property< std::string > m_insideOutInputPath
std::string get_cu_name(const std::string &kernel_name, int cu)
ToolHandle< xAODClusterMaker > m_xaodClusterMaker
Tool for creating xAOD containers.
Gaudi::Property< std::string > m_pixelFirstStageOutputKernelName
Gaudi::Property< std::string > m_memReadKernelName
virtual StatusCode finalize() override final
std::atomic< ulonglong > m_num_Events
Number of events for the average time of the kernel execution.
virtual StatusCode execute(const EventContext &ctx) const override final
Should be overriden by derived classes to perform meaningful work.
Gaudi::Property< std::string > m_stripL2gKernelName
Gaudi::Property< std::string > m_processHitsKernelName
ToolHandle< TestVectorTool > m_testVectorTool
Tool for preparing test vectors.
Gaudi::Property< std::string > m_xclbin
Path and name of the xclbin file.
Gaudi::Property< std::string > m_memWriteKernelName
ToolHandle< FPGADataFormatTool > m_FPGADataFormatTool
Tool for formatting FPGA data.
Gaudi::Property< std::string > m_pixelClusterInputPath
Gaudi::Property< std::string > m_pixelEdmPrepKernelName
Gaudi::Property< std::string > m_loaderKernelName
Gaudi::Property< std::string > m_pixelFirstStageSlicingIPName
Gaudi::Property< std::string > m_runnerKernelName
Gaudi::Property< std::string > m_pixelL2gKernelName
Gaudi::Property< std::string > m_nnOverlapDecoratorKernelName
Gaudi::Property< std::string > m_stripEdmPrepKernelName
Gaudi::Property< std::string > m_unloaderKernelName
Gaudi::Property< std::string > m_spacepointKernelName
ToolHandle< OutputConversionTool > m_outputConversionTool
SG::ReadHandleKey< FPGATrackSimTrackCollection > m_FPGATrackKey
void readTV(const std::string &filepath, int n_words, uint64_t *data) const
ServiceHandle< IChronoSvc > m_chronoSvc
Service for timing the algorithm.
The base class for the EFTracking FPGA integration development.
Property holding a SG store/key/clid from which a ReadHandle is made.
The class for enconding RDO to FPGA format.