ATLAS Offline Software
Loading...
Searching...
No Matches
F100StreamIntegrationAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4
8#include <xrt/xrt_bo.h>
9#include <xrt/xrt_device.h>
10#include <xrt/xrt_kernel.h>
11#include <xrt/xrt_uuid.h>
12
14{
16 {
17 ATH_MSG_INFO("Running on the FPGA accelerator");
18
20
21 ATH_CHECK(m_chronoSvc.retrieve());
22
23 {
24 Athena::Chrono chrono("Platform and device initlize", m_chronoSvc.get());
26 }
27
28 {
29 Athena::Chrono chrono("CL::loadProgram", m_chronoSvc.get());
31 }
32 ATH_MSG_INFO("loading "<<m_xclbin);
33
34
35 ATH_CHECK(m_FPGAStripRDO.initialize());
36 ATH_CHECK(m_FPGAPixelRDO.initialize());
37
38 ATH_CHECK(m_FPGAStripOutput.initialize());
39 ATH_CHECK(m_FPGAPixelOutput.initialize());
40
41 ATH_CHECK(m_FPGAPixelRDOSize.initialize());
42 ATH_CHECK(m_FPGAStripRDOSize.initialize());
43
44 std::vector<std::string> listofCUs;
45
46 getListofCUs(listofCUs);
47
48 cl_int err = 0;
49
50 unsigned int nthreads = m_FPGAThreads.value();
51
52 if(m_FPGAThreads.value() < 1){
53 nthreads = SG::getNSlots();
54 }
55
56 // create the buffers
57 for(unsigned int i = 0; i < nthreads; i++)
58 {
59 m_acc_queues.emplace_back(m_context, m_accelerator, CL_QUEUE_PROFILING_ENABLE | CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err);
60
61 // Input
62 m_pixelClusterInputBufferList.push_back(cl::Buffer(m_context, CL_MEM_READ_ONLY, EFTrackingTransient::PIXEL_CONTAINER_INPUT_BUF_SIZE * sizeof(uint64_t), NULL, &err));
63 m_stripClusterInputBufferList.push_back(cl::Buffer(m_context, CL_MEM_READ_ONLY, EFTrackingTransient::STRIP_CONTAINER_INPUT_BUF_SIZE * sizeof(uint64_t), NULL, &err));
64
65 // Clustering
66 m_pixelClusterOutputBufferList.push_back(cl::Buffer(m_context, CL_MEM_READ_WRITE,EFTrackingTransient::PIXEL_BLOCK_BUF_SIZE * sizeof(uint64_t), NULL, &err));
67 m_stripClusterOutputBufferList.push_back(cl::Buffer(m_context, CL_MEM_READ_WRITE, EFTrackingTransient::STRIP_BLOCK_BUF_SIZE * sizeof(uint64_t), NULL, &err));
68 m_pixelClusterEDMOutputBufferList.push_back(cl::Buffer(m_context, CL_MEM_READ_WRITE,EFTrackingTransient::PIXEL_BLOCK_BUF_SIZE * sizeof(uint64_t), NULL, &err));
69 m_stripClusterEDMOutputBufferList.push_back(cl::Buffer(m_context, CL_MEM_READ_WRITE, EFTrackingTransient::STRIP_BLOCK_BUF_SIZE * sizeof(uint64_t), NULL, &err));
70
71 // L2G
72 m_pixelL2GOutputBufferList.push_back(cl::Buffer(m_context, CL_MEM_READ_WRITE, EFTrackingTransient::PIXEL_BLOCK_BUF_SIZE * sizeof(uint64_t), NULL, &err));
73 m_pixelL2GEDMOutputBufferList.push_back(cl::Buffer(m_context, CL_MEM_READ_WRITE, EFTrackingTransient::PIXEL_BLOCK_BUF_SIZE * sizeof(uint64_t), NULL, &err));
74 m_stripL2GOutputBufferList.push_back(cl::Buffer(m_context, CL_MEM_READ_WRITE, EFTrackingTransient::STRIP_BLOCK_BUF_SIZE * sizeof(uint64_t), NULL, &err));
75 m_stripL2GEDMOutputBufferList.push_back(cl::Buffer(m_context, CL_MEM_READ_WRITE, EFTrackingTransient::STRIP_BLOCK_BUF_SIZE * sizeof(uint64_t), NULL, &err));
76
77 // EDMPrep
78 m_edmPixelOutputBufferList.push_back(cl::Buffer(m_context, CL_MEM_READ_WRITE, EFTrackingTransient::PIXEL_CONTAINER_BUF_SIZE * sizeof(uint32_t), NULL, &err));
79 m_edmStripOutputBufferList.push_back(cl::Buffer(m_context, CL_MEM_READ_WRITE, EFTrackingTransient::STRIP_CONTAINER_BUF_SIZE * sizeof(uint32_t), NULL, &err));
80 }
81
82 // Create kernels for each one of CUs that is inside device
83 for (const auto& cuName: listofCUs)
84 {
85 // Pixel clustering
86 if(cuName.find(m_pixelEndClusterKernelName.value()) != std::string::npos) m_pixelEndClusteringClusterKernels.emplace_back(cl::Kernel(m_program, cuName.c_str()));
87 else if(cuName.find(m_pixelEndClusterEdmKernelName.value()) != std::string::npos) m_pixelEndClusteringEDMKernels.emplace_back(cl::Kernel(m_program, cuName.c_str()));
88 else if(cuName.find(m_pixelStartClusterKernelName.value()) != std::string::npos) m_pixelStartClusteringKernels.emplace_back(cl::Kernel(m_program, cuName.c_str()));
89
90 // Strip clustering
91 else if(cuName.find(m_stripEndClusterKernelName.value()) != std::string::npos) m_stripEndClusteringKernels.emplace_back(cl::Kernel(m_program, cuName.c_str()));
92 else if(cuName.find(m_stripStartClusterKernelName.value()) != std::string::npos) m_stripStartClusteringKernels.emplace_back(cl::Kernel(m_program, cuName.c_str()));
93
94 // Pixel L2G
95 else if(cuName.find(m_pixelL2GKernelName.value()) != std::string::npos) m_pixelL2GKernels.emplace_back(cl::Kernel(m_program, cuName.c_str()));
96
97 // Strip L2G
98 else if(cuName.find(m_stripL2GKernelName.value()) != std::string::npos) m_stripL2GKernels.emplace_back(cl::Kernel(m_program, cuName.c_str()));
99
100 // EDM prep
101 else if(cuName.find(m_pixelEdmKernelName.value()) != std::string::npos) m_pixelEdmPrepKernels.emplace_back(cl::Kernel(m_program, cuName.c_str()));
102
103 else if(cuName.find(m_stripEdmKernelName.value()) != std::string::npos) m_stripEdmPrepKernels.emplace_back(cl::Kernel(m_program, cuName.c_str()));
104 else
105 {
106 ATH_MSG_WARNING("Do not recognize kernel name: "<<cuName);
107 }
108 }
109
110 ATH_MSG_INFO(m_pixelStartClusterKernelName.value()<<" size: "<<m_pixelStartClusteringKernels.size());
111 ATH_MSG_INFO(m_pixelEndClusterKernelName.value()<<" size: "<<m_pixelEndClusteringClusterKernels.size());
112 ATH_MSG_INFO(m_pixelEndClusterEdmKernelName.value()<<" size: "<<m_pixelEndClusteringEDMKernels.size());
113 ATH_MSG_INFO(m_stripStartClusterKernelName.value()<<" size: "<<m_stripStartClusteringKernels.size());
114 ATH_MSG_INFO(m_stripEndClusterKernelName.value()<<" size: "<<m_stripEndClusteringKernels.size());
115 ATH_MSG_INFO(m_stripL2GKernelName.value()<<" size: "<<m_stripL2GKernels.size());
116 ATH_MSG_INFO(m_pixelEdmKernelName.value()<<" size: "<<m_pixelEdmPrepKernels.size());
117 ATH_MSG_INFO(m_stripEdmKernelName.value()<<" size: "<<m_stripEdmPrepKernels.size());
118
119
120 return StatusCode::SUCCESS;
121 }
122
123 StatusCode F100StreamIntegrationAlg::execute(const EventContext &ctx) const
124 {
125 ATH_MSG_DEBUG("Executing F100StreamIntegrationAlg");
126 m_numEvents++;
127
129 const std::vector<uint64_t>* pixelInput{nullptr}, *stripInput{nullptr};
130 ATH_CHECK(SG::get(pixelInput, m_FPGAPixelRDO, ctx));
131 ATH_CHECK(SG::get(stripInput, m_FPGAStripRDO, ctx));
132
133 const int* pixelInputSize{nullptr}, *stripInputSize{nullptr};
134 ATH_CHECK(SG::get(pixelInputSize, m_FPGAPixelRDOSize, ctx));
135 ATH_CHECK(SG::get(stripInputSize, m_FPGAStripRDOSize, ctx));
136
137
138 // logic
139 unsigned int nthreads = m_FPGAThreads.value();
140
141 if(m_FPGAThreads.value() < 1){
142 nthreads = SG::getNSlots();
143 }
144
145 size_t bufferIndex = ctx.slot() % nthreads;
146
147 // Get index for each of the kernels
148 size_t pixelStartClusterIndex = ctx.slot() % m_pixelStartClusteringKernels.size();
149 size_t pixelEndClusterIndex = ctx.slot() % m_pixelEndClusteringClusterKernels.size();
150 size_t pixelEndClusterEDMIndex = ctx.slot() % m_pixelEndClusteringEDMKernels.size();
151 size_t stripStartClusterIndex = ctx.slot() % m_stripStartClusteringKernels.size();
152 size_t stripEndClusterIndex = ctx.slot() % m_stripEndClusteringKernels.size();
153 size_t pixelL2GIndex = m_pixelL2GKernels.size() ? ctx.slot() % m_pixelL2GKernels.size() : 0;
154 size_t stripL2GIndex = ctx.slot() % m_stripL2GKernels.size();
155 size_t pixelEDMIndex = m_pixelEdmPrepKernels.size() ? ctx.slot() % m_pixelEdmPrepKernels.size() : 0;
156 size_t stripEDMIndex = m_stripEdmPrepKernels.size() ? ctx.slot() % m_stripEdmPrepKernels.size() : 0;
157
158 const cl::CommandQueue &acc_queue = m_acc_queues[bufferIndex];
159
160 ATH_MSG_INFO("Thread number "<<ctx.slot()<<" running on buffer "<<bufferIndex<<" pixelStartClusterIndex: "<< pixelStartClusterIndex<<" stripStartClusterIndex: "<< stripStartClusterIndex<<" stripEndClusterIndex: "<< stripEndClusterIndex<<" stripL2GIndex: "<< stripL2GIndex<<" pixelEDMIndex: "<< pixelEDMIndex<<" stripEDMIndex: "<< stripEDMIndex);
161
162 cl::Kernel &pixelStartClusteringKernel = m_pixelStartClusteringKernels[pixelStartClusterIndex];
163 cl::Kernel &pixelEndClusteringClusterKernel = m_pixelEndClusteringClusterKernels[pixelEndClusterIndex];
164 cl::Kernel &pixelEndClusteringEDMKernel = m_pixelEndClusteringEDMKernels[pixelEndClusterEDMIndex];
165 cl::Kernel &stripStartClusteringKernel = m_stripStartClusteringKernels[stripStartClusterIndex];
166 cl::Kernel &stripEndClusteringKernel = m_stripEndClusteringKernels[stripEndClusterIndex];
167 cl::Kernel &stripL2GKernel = m_stripL2GKernels[stripL2GIndex];
168 cl::Kernel &pixelL2GKernel = m_pixelL2GKernels[pixelL2GIndex];
169
170 cl::Kernel &pixelEdmPrepKernel = m_pixelEdmPrepKernels[pixelEDMIndex];
171 cl::Kernel &stripEdmPrepKernel = m_stripEdmPrepKernels[stripEDMIndex];
172
173
174 // Set kernel arguments
175 pixelStartClusteringKernel.setArg(0, m_pixelClusterInputBufferList[bufferIndex]);
176 pixelStartClusteringKernel.setArg(2, static_cast<unsigned long long>(*pixelInputSize));
177
178 pixelEndClusteringClusterKernel.setArg(1, m_pixelClusterOutputBufferList[bufferIndex]);
179 pixelEndClusteringEDMKernel.setArg(1, m_pixelClusterEDMOutputBufferList[bufferIndex]);
180
181 stripStartClusteringKernel.setArg(0, m_stripClusterInputBufferList[bufferIndex]);
182 stripStartClusteringKernel.setArg(2, static_cast<unsigned long long>(*stripInputSize));
183
184 stripEndClusteringKernel.setArg(1, m_stripClusterOutputBufferList[bufferIndex]);
185
186 pixelL2GKernel.setArg(0, m_pixelClusterOutputBufferList[bufferIndex]);
187 pixelL2GKernel.setArg(1, m_pixelClusterEDMOutputBufferList[bufferIndex]);
188 pixelL2GKernel.setArg(2, m_pixelL2GOutputBufferList[bufferIndex]);
189 pixelL2GKernel.setArg(3, m_pixelL2GEDMOutputBufferList[bufferIndex]);
190
191
192 stripL2GKernel.setArg(0, m_stripClusterOutputBufferList[bufferIndex]);
193 stripL2GKernel.setArg(1, m_stripClusterEDMOutputBufferList[bufferIndex]);
194 stripL2GKernel.setArg(2, m_stripL2GOutputBufferList[bufferIndex]);
195 stripL2GKernel.setArg(3, m_stripL2GEDMOutputBufferList[bufferIndex]);
196
197 pixelEdmPrepKernel.setArg(0, m_pixelL2GEDMOutputBufferList[bufferIndex]);
198 pixelEdmPrepKernel.setArg(1, m_edmPixelOutputBufferList[bufferIndex]);
199 stripEdmPrepKernel.setArg(0, m_stripL2GEDMOutputBufferList[bufferIndex]);
200 stripEdmPrepKernel.setArg(1, m_edmStripOutputBufferList[bufferIndex]);
201
202
203
204 // Start the transfers
205 cl::Event evt_write_pixel_input;
206 cl::Event evt_write_strip_input;
207
208 acc_queue.enqueueWriteBuffer(m_pixelClusterInputBufferList[bufferIndex], CL_FALSE, 0, sizeof(uint64_t) * (*pixelInput).size(), (*pixelInput).data(), NULL, &evt_write_pixel_input);
209 acc_queue.enqueueWriteBuffer(m_stripClusterInputBufferList[bufferIndex], CL_FALSE, 0, sizeof(uint64_t) * (*stripInput).size(), (*stripInput).data(), NULL, &evt_write_strip_input);
210 std::vector<cl::Event> evt_vec_pixel_input{evt_write_pixel_input};
211 std::vector<cl::Event> evt_vec_strip_input{evt_write_strip_input};
212
213
214 cl::Event evt_pixel_start_clustering;
215 cl::Event evt_pixel_end_clustering_cluster;
216 cl::Event evt_pixel_end_clustering_edm;
217 cl::Event evt_strip_start_clustering;
218 cl::Event evt_strip_end_clustering;
219 cl::Event evt_strip_l2g;
220 cl::Event evt_pixel_l2g;
221 cl::Event evt_edm_prep;
222 cl::Event evt_pixel_edm_prep;
223 cl::Event evt_strip_edm_prep;
224 {
225 Athena::Chrono chrono("Kernel execution", m_chronoSvc.get());
226 acc_queue.enqueueTask(pixelStartClusteringKernel, &evt_vec_pixel_input, &evt_pixel_start_clustering);
227 acc_queue.enqueueTask(pixelEndClusteringClusterKernel, NULL , &evt_pixel_end_clustering_cluster);
228 acc_queue.enqueueTask(pixelEndClusteringEDMKernel, NULL , &evt_pixel_end_clustering_edm);
229 acc_queue.enqueueTask(stripStartClusteringKernel, &evt_vec_strip_input, &evt_strip_start_clustering);
230 acc_queue.enqueueTask(stripEndClusteringKernel, NULL, &evt_strip_end_clustering);
231
232 std::vector<cl::Event> evt_vec_pixel_clustering{
233 evt_pixel_end_clustering_cluster,
234 evt_pixel_end_clustering_edm,
235 };
236
237 acc_queue.enqueueTask(pixelL2GKernel, &evt_vec_pixel_clustering, &evt_pixel_l2g);
238
239 std::vector<cl::Event> evt_vec_strip_clustering{evt_strip_end_clustering};
240 acc_queue.enqueueTask(stripL2GKernel, &evt_vec_strip_clustering, &evt_strip_l2g);
241
242 std::vector<cl::Event> evt_vec_pixel_l2g{evt_pixel_l2g};
243 acc_queue.enqueueTask(pixelEdmPrepKernel, &evt_vec_pixel_l2g, &evt_pixel_edm_prep);
244
245 std::vector<cl::Event> evt_vec_strip_l2g{evt_strip_l2g};
246 acc_queue.enqueueTask(stripEdmPrepKernel, &evt_vec_strip_l2g, &evt_strip_edm_prep);
247
248 }
249
250 cl::Event evt_pixel_cluster_output;
251 cl::Event evt_strip_cluster_output;
252
253 std::vector<cl::Event> evt_vec_pixel_edm_prep;
254 std::vector<cl::Event> evt_vec_strip_edm_prep;
255
256 evt_vec_pixel_edm_prep.push_back(evt_pixel_edm_prep);
257 evt_vec_strip_edm_prep.push_back(evt_strip_edm_prep);
258
259
260 // output handles
261
263 ATH_CHECK(FPGAPixelOutput.record(std::make_unique<std::vector<uint32_t> >(EFTrackingTransient::PIXEL_CONTAINER_BUF_SIZE, 0)));
264
266 ATH_CHECK(FPGAStripOutput.record(std::make_unique<std::vector<uint32_t> >(EFTrackingTransient::STRIP_CONTAINER_BUF_SIZE, 0)));
267
268 acc_queue.enqueueReadBuffer(m_edmPixelOutputBufferList[bufferIndex], CL_FALSE, 0, sizeof(uint32_t) * (*FPGAPixelOutput).size(), (*FPGAPixelOutput).data(), &evt_vec_pixel_edm_prep, &evt_pixel_cluster_output);
269 acc_queue.enqueueReadBuffer(m_edmStripOutputBufferList[bufferIndex], CL_FALSE, 0, sizeof(uint32_t) * (*FPGAStripOutput).size(), (*FPGAStripOutput).data(), &evt_vec_strip_edm_prep, &evt_strip_cluster_output);
270
271 std::vector<cl::Event> wait_for_reads = { evt_pixel_cluster_output, evt_strip_cluster_output };
272 cl::Event::waitForEvents(wait_for_reads);
273
274
275 if(*pixelInputSize == 6) (*FPGAPixelOutput)[0] = 0; // if no pixel input, set the first element to 0
276 if(*stripInputSize == 6) (*FPGAStripOutput)[0] = 0; // if no strip input, set the first element to 0
277
278
279 // calculate the time for the kernel execution
280 // get the time of writing pixel input buffer
281 cl_ulong pixel_input_time = evt_write_pixel_input.getProfilingInfo<CL_PROFILING_COMMAND_END>() - evt_write_pixel_input.getProfilingInfo<CL_PROFILING_COMMAND_START>();
282 m_pixelInputTime += pixel_input_time;
283 ATH_MSG_DEBUG("Pixel input buffer write time: " << pixel_input_time / 1e6 << " ms");
284
285 // get the time of writing strip input buffer
286 cl_ulong strip_input_time = evt_write_strip_input.getProfilingInfo<CL_PROFILING_COMMAND_END>() - evt_write_strip_input.getProfilingInfo<CL_PROFILING_COMMAND_START>();
287 m_stripInputTime += strip_input_time;
288 ATH_MSG_DEBUG("Strip input buffer write time: " << strip_input_time / 1e6 << " ms");
289
290 // get the time of pixel clustering_cluster
291 cl_ulong pixel_clustering_cluster_time = evt_pixel_end_clustering_cluster.getProfilingInfo<CL_PROFILING_COMMAND_END>() - evt_pixel_start_clustering.getProfilingInfo<CL_PROFILING_COMMAND_START>();
292 m_pixelClusteringTime += pixel_clustering_cluster_time;
293 ATH_MSG_DEBUG("Pixel clustering_cluster time: " << pixel_clustering_cluster_time / 1e6 << " ms");
294
295 cl_ulong pixel_clustering_edm_time = evt_pixel_end_clustering_edm.getProfilingInfo<CL_PROFILING_COMMAND_END>() - evt_pixel_start_clustering.getProfilingInfo<CL_PROFILING_COMMAND_START>();
296 m_pixelClusteringTime += pixel_clustering_edm_time;
297 ATH_MSG_DEBUG("Pixel clustering_edm time: " << pixel_clustering_edm_time / 1e6 << " ms");
298
299 // get the time of strip clustering
300 cl_ulong strip_clustering_time = evt_strip_end_clustering.getProfilingInfo<CL_PROFILING_COMMAND_END>() - evt_strip_start_clustering.getProfilingInfo<CL_PROFILING_COMMAND_START>();
301 m_stripClusteringTime += strip_clustering_time;
302 ATH_MSG_DEBUG("Strip clustering time: " << strip_clustering_time / 1e6 << " ms");
303
304 // get the time of pixel L2G
305 cl_ulong pixel_l2g_time = evt_pixel_l2g.getProfilingInfo<CL_PROFILING_COMMAND_END>() - evt_pixel_l2g.getProfilingInfo<CL_PROFILING_COMMAND_START>();
306 m_pixelL2GTime += pixel_l2g_time;
307 ATH_MSG_DEBUG("Pixel L2G time: " << pixel_l2g_time / 1e6 << " ms");
308
309 // get the time of strip L2G
310 cl_ulong strip_l2g_time = evt_strip_l2g.getProfilingInfo<CL_PROFILING_COMMAND_END>() - evt_strip_l2g.getProfilingInfo<CL_PROFILING_COMMAND_START>();
311 m_stripL2GTime += strip_l2g_time;
312 ATH_MSG_DEBUG("Strip L2G time: " << strip_l2g_time / 1e6 << " ms");
313
314 // get the time of EDMPrep
315 cl_ulong pixel_edm_prep_time = evt_pixel_edm_prep.getProfilingInfo<CL_PROFILING_COMMAND_END>() - evt_pixel_edm_prep.getProfilingInfo<CL_PROFILING_COMMAND_START>();
316 cl_ulong strip_edm_prep_time = evt_strip_edm_prep.getProfilingInfo<CL_PROFILING_COMMAND_END>() - evt_strip_edm_prep.getProfilingInfo<CL_PROFILING_COMMAND_START>();
317
318 m_pixelEdmPrepTime += pixel_edm_prep_time;
319 ATH_MSG_DEBUG("PixelEDMPrep time: " << pixel_edm_prep_time / 1e6 << " ms");
320
321 m_stripEdmPrepTime += strip_edm_prep_time;
322 ATH_MSG_DEBUG("StripEDMPrep time: " << strip_edm_prep_time / 1e6 << " ms");
323
324
325 // get the time of the whole kernel execution
326 cl_ulong kernel_start = evt_pixel_start_clustering.getProfilingInfo<CL_PROFILING_COMMAND_QUEUED>();
327 cl_ulong kernel_end = std::max(evt_pixel_edm_prep.getProfilingInfo<CL_PROFILING_COMMAND_END>(), evt_strip_edm_prep.getProfilingInfo<CL_PROFILING_COMMAND_END>());
328 m_kernelTime += (kernel_end - kernel_start);
329 ATH_MSG_DEBUG("Kernel execution time: " << (kernel_end - kernel_start) / 1e6 << " ms");
330
331 // get the time of reading pixel output buffer
332 cl_ulong pixel_output_time = evt_pixel_cluster_output.getProfilingInfo<CL_PROFILING_COMMAND_END>() - evt_pixel_cluster_output.getProfilingInfo<CL_PROFILING_COMMAND_START>();
333 m_pixelOutputTime += pixel_output_time;
334 ATH_MSG_DEBUG("Pixel output buffer read time: " << pixel_output_time / 1e6 << " ms");
335
336 // get the time of reading strip output buffer
337 cl_ulong strip_output_time = evt_strip_cluster_output.getProfilingInfo<CL_PROFILING_COMMAND_END>() - evt_strip_cluster_output.getProfilingInfo<CL_PROFILING_COMMAND_START>();
338 m_stripOutputTime += strip_output_time;
339 ATH_MSG_DEBUG("Strip output buffer read time: " << strip_output_time / 1e6 << " ms");
340
341 return StatusCode::SUCCESS;
342 }
343
345 {
346
347 ATH_MSG_INFO("Finalizing F100StreamIntegrationAlg");
348 ATH_MSG_INFO("Number of events: " << m_numEvents);
349
350 if(m_numEvents > 0){
351 ATH_MSG_INFO("Pixel input ave time: " << m_pixelInputTime / m_numEvents / 1e6 << " ms");
352 ATH_MSG_INFO("Strip input ave time: " << m_stripInputTime / m_numEvents / 1e6 << " ms");
353 ATH_MSG_INFO("Pixel clustering ave time: " << m_pixelClusteringTime / m_numEvents / 1e6 << " ms");
354 ATH_MSG_INFO("Strip clustering ave time: " << m_stripClusteringTime / m_numEvents / 1e6 << " ms");
355 ATH_MSG_INFO("Pixel L2G ave time: " << m_pixelL2GTime / m_numEvents / 1e6 << " ms");
356 ATH_MSG_INFO("Strip L2G ave time: " << m_stripL2GTime / m_numEvents / 1e6 << " ms");
357 ATH_MSG_INFO("PixelEDMPrep ave time: " << m_pixelEdmPrepTime / m_numEvents / 1e6 << " ms");
358 ATH_MSG_INFO("StripEDMPrep ave time: " << m_stripEdmPrepTime / m_numEvents / 1e6 << " ms");
359 ATH_MSG_INFO("Kernel execution ave time: " << m_kernelTime / m_numEvents / 1e6 << " ms");
360 ATH_MSG_INFO("Pixel output ave time: " << m_pixelOutputTime / m_numEvents / 1e6 << " ms");
361 ATH_MSG_INFO("Strip output ave time: " << m_stripOutputTime / m_numEvents / 1e6 << " ms");
362 }
363
364 return StatusCode::SUCCESS;
365 }
366
367 void F100StreamIntegrationAlg::getListofCUs(std::vector<std::string>& cuNames)
368 {
369 xrt::xclbin xrt_xclbin(m_xclbin.value());
370
371 ATH_MSG_INFO("xsa name: "<<xrt_xclbin.get_xsa_name());
372 ATH_MSG_INFO("fpga name: "<<xrt_xclbin.get_fpga_device_name());
373 ATH_MSG_INFO("uuid: "<<xrt_xclbin.get_uuid().to_string());
374
375 for (const xrt::xclbin::kernel &kernel : xrt_xclbin.get_kernels()) {
376 const std::string& kernelName = kernel.get_name();
377
378 ATH_MSG_INFO("kernelName: "<<kernelName);
379
380
381 for (const xrt::xclbin::ip &computeUnit : kernel.get_cus()) {
382 const std::string& computeUnitName = computeUnit.get_name();
383 const std::string computeUnitIsolatedName = computeUnitName.substr(kernelName.size() + 1);
384
385 const std::string computeUnitUsableName = kernelName + ":{" + computeUnitIsolatedName + "}";
386
387 ATH_MSG_INFO("CU name: "<<computeUnitUsableName);
388 cuNames.push_back(computeUnitUsableName);
389 }
390 }
391 }
392
393} // namespace EFTrackingFPGAIntegration
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Maintain a set of objects, one per slot.
Exception-safe IChronoSvc caller.
Exception-safe IChronoSvc caller.
Definition Chrono.h:50
Gaudi::Property< std::string > m_stripStartClusterKernelName
Name of the strip clustering kernel start.
std::atomic< cl_ulong > m_pixelL2GTime
Time for pixel L2G.
SG::WriteHandleKey< std::vector< uint32_t > > m_FPGAPixelOutput
Gaudi::Property< std::string > m_stripL2GKernelName
Name of the strip L2G kernelS.
Gaudi::Property< std::string > m_pixelEdmKernelName
Name of the FPGA kernel.
std::atomic< cl_ulong > m_stripEdmPrepTime
Time for strip EDM preparation.
std::atomic< ulonglong > m_numEvents
Number of events processed.
std::atomic< cl_ulong > m_stripInputTime
Time for strip input buffer write.
std::atomic< cl_ulong > m_pixelEdmPrepTime
Time for pixel EDM preparation.
SG::WriteHandleKey< std::vector< uint32_t > > m_FPGAStripOutput
Gaudi::Property< std::string > m_pixelEndClusterKernelName
Name of the pixel clustering kernel start.
Gaudi::Property< std::string > m_pixelEndClusterEdmKernelName
Name of the pixel clustering kernel start.
virtual StatusCode execute(const EventContext &ctx) const override final
Should be overriden by derived classes to perform meaningful work.
Gaudi::Property< std::string > m_stripEndClusterKernelName
Name of the strip clustering kernel start.
std::atomic< cl_ulong > m_pixelInputTime
Time for pixel input buffer write.
std::atomic< cl_ulong > m_pixelOutputTime
Time for pixel output buffer read.
SG::ReadHandleKey< std::vector< uint64_t > > m_FPGAPixelRDO
SG::ReadHandleKey< std::vector< uint64_t > > m_FPGAStripRDO
void getListofCUs(std::vector< std::string > &cuNames)
virtual StatusCode initialize() override final
Detect the OpenCL devices and prepare OpenCL context.
Gaudi::Property< std::string > m_pixelL2GKernelName
Name of the pixel L2G kernel.
Gaudi::Property< std::string > m_stripEdmKernelName
Name of the FPGA kernel.
ServiceHandle< IChronoSvc > m_chronoSvc
Service for timing the algorithm.
std::atomic< cl_ulong > m_kernelTime
Time for kernel execution.
Gaudi::Property< std::string > m_xclbin
Path and name of the xclbin file.
std::atomic< cl_ulong > m_stripL2GTime
Time for strip L2G.
std::atomic< cl_ulong > m_pixelClusteringTime
Time for pixel clustering.
std::atomic< cl_ulong > m_stripClusteringTime
Time for strip clustering.
std::atomic< cl_ulong > m_stripOutputTime
Time for strip output buffer read.
Gaudi::Property< std::string > m_pixelStartClusterKernelName
Name of the pixel clustering kernel start.
StatusCode loadProgram(const std::string &xclbin)
Find the xclbin file and load it into the OpenCL program object.
cl::Program m_program
Program object containing the kernel.
virtual StatusCode initialize() override
Detect the OpenCL devices and prepare OpenCL context.
cl::Context m_context
Context object for the application.
StatusCode precheck(const std::vector< Gaudi::Property< std::string > > &inputs) const
Check if the the desired Gaudi properties are set.
cl::Device m_accelerator
Device object for the accelerator card.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
The class for enconding RDO to FPGA format.
constexpr unsigned long PIXEL_CONTAINER_INPUT_BUF_SIZE
constexpr uint32_t STRIP_CONTAINER_BUF_SIZE
constexpr unsigned long STRIP_CONTAINER_INPUT_BUF_SIZE
constexpr uint32_t STRIP_BLOCK_BUF_SIZE
constexpr uint32_t PIXEL_BLOCK_BUF_SIZE
constexpr uint32_t PIXEL_CONTAINER_BUF_SIZE
size_t getNSlots()
Return the number of event slots.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.