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