ATLAS Offline Software
Loading...
Searching...
No Matches
TrigInDetAccelerationSvc Class Reference

Service for creating GPU-accelerated Work items for HLT ID algorithms. More...

#include <TrigInDetAccelerationSvc.h>

Inheritance diagram for TrigInDetAccelerationSvc:
Collaboration diagram for TrigInDetAccelerationSvc:

Classes

struct  PhiEtaHash

Public Member Functions

 TrigInDetAccelerationSvc (const std::string &, ISvcLocator *)
 Constructor.
virtual ~TrigInDetAccelerationSvc () override
virtual StatusCode initialize () override
 Initialize.
virtual StatusCode finalize () override
 Finalize.
virtual void handle (const Incident &) override
 OnBeginRun data gathering and export.
virtual bool isReady () const override
virtual TrigAccel::WorkcreateWork (unsigned int, std::shared_ptr< TrigAccel::OffloadBuffer >) const override
virtual const std::vector< short > & getLayerInformation (int) const override
virtual size_t getMiddleLayersSize () const override

Private Member Functions

StatusCode initializeWorkFactory ()
bool exportGeometryInformation (const std::map< std::tuple< short, short, short >, std::vector< PhiEtaHash > > &) const
bool extractGeometryInformation (std::map< std::tuple< short, short, short >, std::vector< PhiEtaHash > > &)
bool extractITkGeometryInformation (std::map< std::tuple< short, short, int, int >, std::vector< PhiEtaHash > > &)
bool exportITkGeometryInformation (const std::map< std::tuple< short, short, int, int >, std::vector< PhiEtaHash > > &hashMap) const

Private Attributes

int m_nDCs
std::string m_moduleName
bool m_useITkGeometry
std::vector< int > m_middleSpacePointLayers
void * m_libHandle
TrigAccel::WorkFactorym_pWF
TrigAccel::Modulem_module
ServiceHandle< StoreGateSvcm_detStore
ServiceHandle< StoreGateSvcm_evtStore
ServiceHandle< AthCUDA::IGPUSystemInfoSvcm_cudaCheckSvc
bool m_factoryConfigured
std::vector< short > m_layerInfo [3]
std::mutex m_workMutex

Detailed Description

Service for creating GPU-accelerated Work items for HLT ID algorithms.

Definition at line 31 of file TrigInDetAccelerationSvc.h.

Constructor & Destructor Documentation

◆ TrigInDetAccelerationSvc()

TrigInDetAccelerationSvc::TrigInDetAccelerationSvc ( const std::string & name,
ISvcLocator * pSvcLocator )

Constructor.

Definition at line 27 of file TrigInDetAccelerationSvc.cxx.

27 :
28 base_class( name, pSvcLocator ),
29 m_nDCs(12),
30 m_moduleName("libTrigInDetCUDA.so"),
31 m_useITkGeometry(false),
32 m_libHandle(0),
33 m_pWF(0),
34 m_module(0),
35 m_detStore("DetectorStore", name),
36 m_evtStore("StoreGateSvc",name),
37 m_cudaCheckSvc("GPUSystemInfoSvc", "AthCUDA::GPUSystemInfoSvc"),
38 m_factoryConfigured(false) {
39
40 declareProperty( "NumberOfDCs", m_nDCs = 8 );
41 declareProperty( "ModuleName", m_moduleName = "libTrigInDetCUDA.so");
42 declareProperty( "useITkGeometry", m_useITkGeometry = false);
43 declareProperty( "MiddleSpacePointLayers", m_middleSpacePointLayers = std::vector<int>(), "Global IDs of layers that can contain middle spacepoints of track seeds" );
44}
ServiceHandle< StoreGateSvc > m_evtStore
ServiceHandle< StoreGateSvc > m_detStore
std::vector< int > m_middleSpacePointLayers
TrigAccel::WorkFactory * m_pWF
ServiceHandle< AthCUDA::IGPUSystemInfoSvc > m_cudaCheckSvc

◆ ~TrigInDetAccelerationSvc()

virtual TrigInDetAccelerationSvc::~TrigInDetAccelerationSvc ( )
inlineoverridevirtual

Definition at line 37 of file TrigInDetAccelerationSvc.h.

37{};

Member Function Documentation

◆ createWork()

TrigAccel::Work * TrigInDetAccelerationSvc::createWork ( unsigned int jobCode,
std::shared_ptr< TrigAccel::OffloadBuffer > pB ) const
overridevirtual

Definition at line 186 of file TrigInDetAccelerationSvc.cxx.

186 {
187
188 if(!m_factoryConfigured) return 0;
189
190 // To remove this, WorkFactory::createWork() should be made const
191 // (and thread-safe).
192 std::scoped_lock lock (m_workMutex);
193 TrigAccel::WorkFactory* wf ATLAS_THREAD_SAFE = m_pWF;
194 return wf->createWork(jobCode, pB);
195
196}
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
#define ATLAS_THREAD_SAFE

◆ exportGeometryInformation()

bool TrigInDetAccelerationSvc::exportGeometryInformation ( const std::map< std::tuple< short, short, short >, std::vector< PhiEtaHash > > & hashMap) const
private

Definition at line 412 of file TrigInDetAccelerationSvc.cxx.

412 {
413
414 const InDetDD::SCT_DetectorManager * sct_mgr = nullptr;
415 const InDetDD::PixelDetectorManager * pix_mgr = nullptr;
416
417 if (m_detStore->retrieve(sct_mgr, "SCT").isFailure()) {
418 ATH_MSG_WARNING("failed to get SCT Manager");
419 return false;
420
421 }
422 if (m_detStore->retrieve(pix_mgr,"Pixel").isFailure()) {
423 ATH_MSG_WARNING("failed to get SCT Manager");
424 return false;
425 }
426
427 //export layer structure
428
429 size_t dataTypeSize = sizeof(TrigAccel::DETECTOR_MODEL);
430 const size_t bufferOffset = 256;
431 size_t totalSize = bufferOffset + dataTypeSize;
432
434
435 if(!pBG->fit(totalSize)) pBG->reallocate(totalSize);
436
437 TrigAccel::DETECTOR_MODEL* pArray = reinterpret_cast<TrigAccel::DETECTOR_MODEL*>(pBG->m_buffer + bufferOffset);
438
439 // cppcheck-suppress memsetClassFloat; deliberate
440 memset(pArray,0,dataTypeSize);
441
442 int nLayers = (int)hashMap.size();
443 pArray->m_nLayers = nLayers;
444 pArray->m_nModules=0;
445
446 int layerIdx=0;
447
448 for(std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> >::const_iterator it = hashMap.begin();it!=hashMap.end();++it, layerIdx++) {
449 short subdetid = std::get<0>((*it).first);
450 short barrel_ec = std::get<1>((*it).first);
451
452 pArray->m_layers[layerIdx].m_nElements = 0;
453 pArray->m_layers[layerIdx].m_subdet = subdetid;
454 pArray->m_layers[layerIdx].m_type = barrel_ec;
455
456 std::vector<std::vector<PhiEtaHash>::const_iterator> vStops;
457 vStops.push_back((*it).second.begin());
458 std::vector<PhiEtaHash>::const_iterator firstIt = (*it).second.begin();
459 std::vector<PhiEtaHash>::const_iterator nextIt = (*it).second.begin();
460 ++nextIt;
461
462 int nPhiSlices=0;
463
464 for(; nextIt!=(*it).second.end();++nextIt, ++firstIt) {
465 if((*nextIt).m_phiIndex!=(*firstIt).m_phiIndex) {
466 vStops.push_back(nextIt);
467 nPhiSlices++;
468 }
469 }
470
471 nPhiSlices++;
472
473 vStops.push_back((*it).second.end());
474
475 float rc=0.0;
476 float minBound = 100000.0;
477 float maxBound =-100000.0;
478
479 pArray->m_layers[layerIdx].m_nPhiSlices = nPhiSlices;
480
481 //3. iterating over phi sectors
482
483 for(unsigned int iStops = 1; iStops<vStops.size();iStops++) {
484
485 bool first = true;
486
487 for(std::vector<PhiEtaHash>::const_iterator hIt = vStops[iStops-1];hIt!=vStops[iStops];++hIt) {
488
489 pArray->m_hashArray[pArray->m_nModules] = (*hIt).m_hash;
490
491 const InDetDD::SiDetectorElement *p = (subdetid==1) ? pix_mgr->getDetectorElement((*hIt).m_hash) : sct_mgr->getDetectorElement((*hIt).m_hash);
492
493 if(first) {
494 first = false;
495 }
496
497 pArray->m_layers[layerIdx].m_nElements++;
498
499 const Amg::Vector3D& C = p->center();
500 if(barrel_ec == 0) {
501 rc += sqrt(C(0)*C(0)+C(1)*C(1));
502 if(p->zMin() < minBound) minBound = p->zMin();
503 if(p->zMax() > maxBound) maxBound = p->zMax();
504 pArray->m_minRZ[pArray->m_nModules] = p->zMin();
505 pArray->m_maxRZ[pArray->m_nModules] = p->zMax();
506 }
507 else {
508 rc += C(2);
509 if(p->rMin() < minBound) minBound = p->rMin();
510 if(p->rMax() > maxBound) maxBound = p->rMax();
511 pArray->m_minRZ[pArray->m_nModules] = p->rMin();
512 pArray->m_maxRZ[pArray->m_nModules] = p->rMax();
513 }
514
515 pArray->m_nModules++;
516 }
517
518 }
519 pArray->m_layers[layerIdx].m_refCoord = rc/pArray->m_layers[layerIdx].m_nElements;
520 pArray->m_layers[layerIdx].m_minBound = minBound;
521 pArray->m_layers[layerIdx].m_maxBound = maxBound;
522 }
523
524 std::shared_ptr<TrigAccel::OffloadBuffer> pDMBuff = std::make_shared<TrigAccel::OffloadBuffer>(pBG);
525
526 delete pBG;
527
529
531
532 return pW == 0;//request is actioned immediately, no actual WorkItem is created
533
534}
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
static Double_t rc
static unsigned int totalSize(const MultiDimArray< T, N > &ht)
virtual const SiDetectorElement * getDetectorElement(const Identifier &id) const override
access to individual elements : via Identifier
virtual const SiDetectorElement * getDetectorElement(const Identifier &id) const override
access to individual elements via Identifier
virtual TrigAccel::Work * createWork(unsigned int, std::shared_ptr< TrigAccel::OffloadBuffer >) const override
struct color C
Eigen::Matrix< double, 3, 1 > Vector3D
bool first
Definition DeMoScan.py:534
struct TrigAccel::DataExportBuffer DATA_EXPORT_BUFFER
struct TrigAccel::DetectorModel DETECTOR_MODEL
SILICON_LAYER m_layers[MAX_SILICON_LAYERS]
float m_minRZ[MAX_NUMBER_PIX_MODULES+MAX_NUMBER_SCT_MODULES]
float m_maxRZ[MAX_NUMBER_PIX_MODULES+MAX_NUMBER_SCT_MODULES]
int m_hashArray[MAX_NUMBER_PIX_MODULES+MAX_NUMBER_SCT_MODULES]

◆ exportITkGeometryInformation()

bool TrigInDetAccelerationSvc::exportITkGeometryInformation ( const std::map< std::tuple< short, short, int, int >, std::vector< PhiEtaHash > > & hashMap) const
private

Definition at line 204 of file TrigInDetAccelerationSvc.cxx.

204 {
205
206 const InDetDD::PixelDetectorManager * pix_mgr = nullptr;
207
208 if (m_detStore->retrieve(pix_mgr,"ITkPixel").isFailure()) {
209 ATH_MSG_WARNING("failed to get ITkPixel Manager");
210 return false;
211 }
212
213 //export layer structure
214
215 size_t dataTypeSize = sizeof(TrigAccel::ITk::DETECTOR_MODEL);
216 const size_t bufferOffset = 256;
217 size_t totalSize = bufferOffset + dataTypeSize;
218
220
221 if(!pBG->fit(totalSize)) pBG->reallocate(totalSize);
222
223 TrigAccel::ITk::DETECTOR_MODEL* pArray = reinterpret_cast<TrigAccel::ITk::DETECTOR_MODEL*>(pBG->m_buffer + bufferOffset);
224
225 // cppcheck-suppress memsetClassFloat; deliberate
226 memset(pArray,0,dataTypeSize);
227
228 int nLayers = (int)hashMap.size();
229 pArray->m_nLayers = nLayers;
230 pArray->m_nModules=0;
231
232 int layerIdx=0;
233 int middleLayerIdx=0;
234
235 for(std::map<std::tuple<short,short, int, int>,std::vector<PhiEtaHash> >::const_iterator it = hashMap.begin();it!=hashMap.end();++it, layerIdx++) {
236
237 short barrel_ec = std::get<0>((*it).first);
238 int vol_id = std::get<2>((*it).first);
239 int lay_id = std::get<3>((*it).first);
240 if(barrel_ec == -100) barrel_ec = 0;
241 int globalLayerId = vol_id*1000 + lay_id;
242
243 pArray->m_layers[layerIdx].m_nElements = 0;
244 pArray->m_layers[layerIdx].m_subdet = globalLayerId;
245 pArray->m_layers[layerIdx].m_type = barrel_ec;
246
247 // Fill in a table of layer ids that can contain the middle SPs
248 if (std::find(m_middleSpacePointLayers.begin(), m_middleSpacePointLayers.end(), globalLayerId) != m_middleSpacePointLayers.end()){
249 pArray->m_middleSpacePointLayers[middleLayerIdx] = layerIdx;
250 ++middleLayerIdx;
251 }
252
253 std::vector<std::vector<PhiEtaHash>::const_iterator> vStops;
254 vStops.push_back((*it).second.begin());
255 std::vector<PhiEtaHash>::const_iterator firstIt = (*it).second.begin();
256 std::vector<PhiEtaHash>::const_iterator nextIt = (*it).second.begin();
257 ++nextIt;
258
259 int nPhiSlices=0;
260
261 for(; nextIt!=(*it).second.end();++nextIt, ++firstIt) {
262 if((*nextIt).m_phiIndex!=(*firstIt).m_phiIndex) {
263 vStops.push_back(nextIt);
264 nPhiSlices++;
265 }
266 }
267
268 nPhiSlices++;
269
270 vStops.push_back((*it).second.end());
271
272 float rc=0.0;
273 float minBound = 100000.0;
274 float maxBound =-100000.0;
275
276 pArray->m_layers[layerIdx].m_nPhiSlices = nPhiSlices;
277
278 //3. iterating over phi sectors
279
280 for(unsigned int iStops = 1; iStops<vStops.size();iStops++) {
281 bool first = true;
282
283 for(std::vector<PhiEtaHash>::const_iterator hIt = vStops[iStops-1];hIt!=vStops[iStops];++hIt) {
284
285 pArray->m_hashArray[pArray->m_nModules] = (*hIt).m_hash;
286 const InDetDD::SiDetectorElement *p = pix_mgr->getDetectorElement((*hIt).m_hash);
287
288 if (first) {
289 first = false;
290 }
291
292 pArray->m_layers[layerIdx].m_nElements++;
293
294 const Amg::Vector3D& C = p->center();
295 if (barrel_ec == 0) {
296 rc += sqrt(C(0)*C(0)+C(1)*C(1));
297 if(p->zMin() < minBound) minBound = p->zMin();
298 if(p->zMax() > maxBound) maxBound = p->zMax();
299 pArray->m_minRZ[pArray->m_nModules] = p->zMin();
300 pArray->m_maxRZ[pArray->m_nModules] = p->zMax();
301 } else {
302 rc += C(2);
303 if(p->rMin() < minBound) minBound = p->rMin();
304 if(p->rMax() > maxBound) maxBound = p->rMax();
305 pArray->m_minRZ[pArray->m_nModules] = p->rMin();
306 pArray->m_maxRZ[pArray->m_nModules] = p->rMax();
307 }
308
309 pArray->m_nModules++;
310 }
311
312 }
313 pArray->m_layers[layerIdx].m_refCoord = rc/pArray->m_layers[layerIdx].m_nElements;
314 pArray->m_layers[layerIdx].m_minBound = minBound;
315 pArray->m_layers[layerIdx].m_maxBound = maxBound;
316 }
317
318 std::shared_ptr<TrigAccel::OffloadBuffer> pDMBuff = std::make_shared<TrigAccel::OffloadBuffer>(pBG);
319
320 delete pBG;
321
323
325
326 return pW == 0;//request is actioned immediately, no actual WorkItem is created
327
328}
struct TrigAccel::ITk::DetectorModel DETECTOR_MODEL
int m_hashArray[MAX_NUMBER_PIX_MODULES+MAX_NUMBER_SCT_MODULES]
int m_middleSpacePointLayers[MAX_SILICON_LAYERS]
float m_minRZ[MAX_NUMBER_PIX_MODULES+MAX_NUMBER_SCT_MODULES]
SILICON_LAYER m_layers[MAX_SILICON_LAYERS]
float m_maxRZ[MAX_NUMBER_PIX_MODULES+MAX_NUMBER_SCT_MODULES]

◆ extractGeometryInformation()

bool TrigInDetAccelerationSvc::extractGeometryInformation ( std::map< std::tuple< short, short, short >, std::vector< PhiEtaHash > > & hashMap)
private

Definition at line 537 of file TrigInDetAccelerationSvc.cxx.

537 {
538
539 const PixelID* pixelId = nullptr;
540 const SCT_ID* sctId = nullptr;
541
542 if (m_detStore->retrieve(pixelId, "PixelID").isFailure()) {
543 ATH_MSG_WARNING("Could not get Pixel ID helper");
544 return false;
545 }
546
547 if (m_detStore->retrieve(sctId, "SCT_ID").isFailure()) {
548 ATH_MSG_WARNING("Could not get Pixel ID helper");
549 return false;
550 }
551
552 short subdetid = 1;
553
554 for(int hash = 0; hash<(int)pixelId->wafer_hash_max(); hash++) {
555
556 Identifier offlineId = pixelId->wafer_id(hash);
557
558 if(offlineId==0) continue;
559
560 short barrel_ec = pixelId->barrel_ec(offlineId);
561 if(abs(barrel_ec)>2) continue;//no DBM needed
562 short layer_disk = pixelId->layer_disk(offlineId);
563 short phi_index = pixelId->phi_module(offlineId);
564 short eta_index = pixelId->eta_module(offlineId);
565 auto t = std::make_tuple(subdetid, barrel_ec, layer_disk);
566 std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> >::iterator it = hashMap.find(t);
567 if(it==hashMap.end())
568 hashMap.insert(std::pair<std::tuple<short,short,short>,std::vector<PhiEtaHash> >(t,std::vector<PhiEtaHash>(1, PhiEtaHash(phi_index, eta_index, hash) )));
569 else (*it).second.push_back(PhiEtaHash(phi_index, eta_index, hash));
570 }
571 subdetid = 2;
572 for(int hash = 0; hash<(int)sctId->wafer_hash_max(); hash++) {
573
574 Identifier offlineId = sctId->wafer_id(hash);
575
576 if(offlineId==0) continue;
577
578 short barrel_ec = sctId->barrel_ec(offlineId);
579 short layer_disk = sctId->layer_disk(offlineId);
580 short phi_index = sctId->phi_module(offlineId);
581 short eta_index = sctId->eta_module(offlineId);
582
583 auto t = std::make_tuple(subdetid, barrel_ec, layer_disk);
584 std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> >::iterator it = hashMap.find(t);
585 if(it==hashMap.end())
586 hashMap.insert(std::pair<std::tuple<short,short,short>,std::vector<PhiEtaHash> >(t,std::vector<PhiEtaHash>(1, PhiEtaHash(phi_index, eta_index, hash))));
587 else (*it).second.push_back(PhiEtaHash(phi_index, eta_index, hash));
588 }
589
590 m_layerInfo[1].resize(pixelId->wafer_hash_max(), -1);
591 m_layerInfo[2].resize(sctId->wafer_hash_max(), -1);
592
593 int layerId=0;
594
595 for(std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> >::iterator it = hashMap.begin();it!=hashMap.end();++it, layerId++) {
596
597 short subdetId = std::get<0>((*it).first);
598 short barrel_ec = std::get<1>((*it).first);
599
600 m_layerInfo[0].push_back(barrel_ec);
601
602 if(subdetId == 1) {//pixel
603 for(std::vector<PhiEtaHash>::iterator hIt = (*it).second.begin();hIt != (*it).second.end();++hIt) {
604 m_layerInfo[subdetId][(*hIt).m_hash] = layerId;
605 }
606 }
607 if(subdetId == 2) {//SCT
608 for(std::vector<PhiEtaHash>::iterator hIt = (*it).second.begin();hIt != (*it).second.end();++hIt) {
609 m_layerInfo[subdetId][(*hIt).m_hash] = layerId;
610 }
611 }
612 }
613
614
615 for(std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> >::iterator it = hashMap.begin();it!=hashMap.end();++it) {
616
617 //sorting along phi first, then along eta
618
619 std::sort((*it).second.begin(), (*it).second.end(), PhiEtaHash::compare());
620
621 }
622 return true;
623}
int layer_disk(const Identifier &id) const
Definition PixelID.h:602
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
Definition PixelID.h:355
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0).
Definition PixelID.h:595
size_type wafer_hash_max() const
Definition PixelID.cxx:703
int eta_module(const Identifier &id) const
Definition PixelID.h:627
int phi_module(const Identifier &id) const
Definition PixelID.h:620
size_type wafer_hash_max() const
Definition SCT_ID.cxx:621
int layer_disk(const Identifier &id) const
Definition SCT_ID.h:687
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module, int side) const
For a single side of module.
Definition SCT_ID.h:459
int phi_module(const Identifier &id) const
Definition SCT_ID.h:693
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0).
Definition SCT_ID.h:681
int eta_module(const Identifier &id) const
Definition SCT_ID.h:699
std::vector< short > m_layerInfo[3]
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.

◆ extractITkGeometryInformation()

bool TrigInDetAccelerationSvc::extractITkGeometryInformation ( std::map< std::tuple< short, short, int, int >, std::vector< PhiEtaHash > > & hashMap)
private

Definition at line 331 of file TrigInDetAccelerationSvc.cxx.

331 {
332
333 const PixelID* pixelId = nullptr;
334
335 if (m_detStore->retrieve(pixelId, "PixelID").isFailure()) {
336 ATH_MSG_WARNING("Could not get Pixel ID helper");
337 return false;
338 }
339
340 // Read Pixel layer details
341 short subdetid = 1;
342 for(int hash = 0; hash<(int)pixelId->wafer_hash_max(); hash++) {
343
344 Identifier offlineId = pixelId->wafer_id(hash);
345
346 if(offlineId==0) continue;
347
348 short barrel_ec = pixelId->barrel_ec(offlineId);
349 if(abs(barrel_ec)>2) continue;//no DBM needed
350
351 short phi_index = pixelId->phi_module(offlineId);
352 short eta_index = pixelId->eta_module(offlineId);
353 short layer_disk = pixelId->layer_disk(offlineId);
354
355 // Calculate new volume and layer id for ITk
356 int vol_id = -1;
357 if (barrel_ec== 0) vol_id = 8;
358 if (barrel_ec==-2) vol_id = 7;
359 if (barrel_ec== 2) vol_id = 9;
360
361 int new_vol=0, new_lay=0;
362
363 if (vol_id == 7 || vol_id == 9) {
364 new_vol = 10*vol_id + layer_disk;
365 new_lay = eta_index;
366 } else if (vol_id == 8) {
367 new_lay = 0;
368 new_vol = 10*vol_id + layer_disk;
369 }
370
371 auto t = std::make_tuple(barrel_ec==0 ? -100 : barrel_ec, subdetid, new_vol, new_lay);
372 std::map<std::tuple<short,short,int,int>,std::vector<PhiEtaHash> >::iterator it = hashMap.find(t);
373 if(it==hashMap.end())
374 hashMap.insert(std::pair<std::tuple<short,short,int,int>,std::vector<PhiEtaHash> >(t,std::vector<PhiEtaHash>(1, PhiEtaHash(phi_index, eta_index, hash) )));
375 else (*it).second.push_back(PhiEtaHash(phi_index, eta_index, hash));
376 }
377
378 m_layerInfo[0].clear();
379 m_layerInfo[1].clear();
380
381 m_layerInfo[0].resize(hashMap.size()); // Mapping from layerId to barrel_ec
382 m_layerInfo[1].resize(pixelId->wafer_hash_max(), -1); // Mapping from layerId to the module hash
383
384 // Map layer geometry details to module hash id
385 int layerId=0;
386 for(std::map<std::tuple<short,short,int,int>,std::vector<PhiEtaHash> >::iterator it = hashMap.begin();it!=hashMap.end();++it, layerId++) {
387
388 short barrel_ec = std::get<0>((*it).first);
389 short subdetId = std::get<1>((*it).first);
390 if(barrel_ec == -100) barrel_ec = 0;
391
392 m_layerInfo[0][layerId] = barrel_ec;
393
394 if(subdetId == 1) {//pixel
395 for(std::vector<PhiEtaHash>::iterator hIt = (*it).second.begin();hIt != (*it).second.end();++hIt) {
396 m_layerInfo[subdetId][(*hIt).m_hash] = layerId;
397 }
398 }
399 }
400
401 for(std::map<std::tuple<short,short,int,int>,std::vector<PhiEtaHash> >::iterator it = hashMap.begin();it!=hashMap.end();++it) {
402
403 //sorting along phi first, then along eta
404 std::sort((*it).second.begin(), (*it).second.end(), PhiEtaHash::compare());
405
406 }
407
408 return true;
409}

◆ finalize()

StatusCode TrigInDetAccelerationSvc::finalize ( )
overridevirtual

Finalize.

Definition at line 133 of file TrigInDetAccelerationSvc.cxx.

133 {
134
135 delete m_pWF;
136
137 dlclose(m_libHandle);
138
139 return StatusCode::SUCCESS;
140}

◆ getLayerInformation()

const std::vector< short > & TrigInDetAccelerationSvc::getLayerInformation ( int i) const
overridevirtual

Definition at line 199 of file TrigInDetAccelerationSvc.cxx.

199 {
200 if (i<0 || i>2) i = 0;
201 return m_layerInfo[i];
202}

◆ getMiddleLayersSize()

virtual size_t TrigInDetAccelerationSvc::getMiddleLayersSize ( ) const
inlineoverridevirtual

Definition at line 49 of file TrigInDetAccelerationSvc.h.

49{return m_middleSpacePointLayers.size();};

◆ handle()

void TrigInDetAccelerationSvc::handle ( const Incident & )
overridevirtual

OnBeginRun data gathering and export.

Definition at line 147 of file TrigInDetAccelerationSvc.cxx.

147 {
148
149 ATH_MSG_INFO("OnBeginRun ");
150
151 if (initializeWorkFactory() != StatusCode::SUCCESS){
152 ATH_MSG_ERROR("Offloading Work Factory failed");
153 return;
154 }
155
156 if (m_useITkGeometry) {
157 // barrel ec, subdetector id, itk volume id, itk layer disk id
158 std::map<std::tuple<short,short, int, int>,std::vector<PhiEtaHash> > hashMap;
159 if(!extractITkGeometryInformation(hashMap)) {
160 ATH_MSG_INFO("ITk Geometry extraction failed");
161 return;
162 }
163
164 if(!exportITkGeometryInformation(hashMap)) {
165 ATH_MSG_INFO("ITk Geometry export failed");
166 }
167
168 } else {
169 // subdetector id, barrel ec, layer disk
170 std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> > hashMap;
171
172 if(!extractGeometryInformation(hashMap)) {
173 ATH_MSG_INFO("Geometry extraction failed");
174 return;
175 }
176
177 if(!exportGeometryInformation(hashMap)) {
178 ATH_MSG_INFO("Geometry export failed");
179 }
180
181 }
182
183 return;
184}
#define ATH_MSG_ERROR(x)
bool exportITkGeometryInformation(const std::map< std::tuple< short, short, int, int >, std::vector< PhiEtaHash > > &hashMap) const
bool exportGeometryInformation(const std::map< std::tuple< short, short, short >, std::vector< PhiEtaHash > > &) const
bool extractITkGeometryInformation(std::map< std::tuple< short, short, int, int >, std::vector< PhiEtaHash > > &)
bool extractGeometryInformation(std::map< std::tuple< short, short, short >, std::vector< PhiEtaHash > > &)

◆ initialize()

StatusCode TrigInDetAccelerationSvc::initialize ( )
overridevirtual

Initialize.

Definition at line 51 of file TrigInDetAccelerationSvc.cxx.

51 {
52
53 ATH_MSG_INFO("TrigInDetAccelerationSvc: initialize");
54
55 ATH_CHECK (m_evtStore.retrieve() );
56 ATH_CHECK (m_detStore.retrieve() );
57 ATH_CHECK (m_cudaCheckSvc.retrieve() );
58
59 for(int i=0;i<3;i++) m_layerInfo[i].clear();
60
61 /*
62 * Ask to be informed at the beginning of a new run so that we
63 * can collect geometry, conditions, etc. and copy them to on-GPU data structures
64 * For athenaHLT this should be UpdateAfterFork
65 */
66
67 SmartIF<IIncidentSvc> incsvc{service("IncidentSvc")};
68 const int priority = 100;
69 if( incsvc ) {
70 const bool is_multiprocess = (Gaudi::Concurrency::ConcurrencyFlags::numProcs() > 0);
71 if (is_multiprocess) {
72 incsvc->addListener( this, AthenaInterprocess::UpdateAfterFork::type(), priority);
73 }
74 else {
75 incsvc->addListener( this, "BeginRun", priority);
76 }
77 }
78
79 return StatusCode::SUCCESS;
80}
#define ATH_CHECK
Evaluate an expression and check for errors.
void clear()
Empty the pool.
static const std::string & type()
Incident type.
Definition Incidents.h:49

◆ initializeWorkFactory()

StatusCode TrigInDetAccelerationSvc::initializeWorkFactory ( )
private

Definition at line 83 of file TrigInDetAccelerationSvc.cxx.

83 {
84 // Check if CUDA device is available before creating a factory
85 if (m_cudaCheckSvc->getAvailableDevices().size() == 0) {
86 ATH_MSG_INFO("TrigInDetAccelerationSvc: no CUDA device available");
87 return StatusCode::FAILURE;
88 }
89
90
91 //load the OffloadFactory library
92 m_libHandle = dlopen(m_moduleName.c_str(), RTLD_LAZY);
93
94 if(!m_libHandle) {
95 ATH_MSG_INFO("TrigInDetAccelerationSvc: cannot load the factory library, error:"<<dlerror());
96 return StatusCode::SUCCESS;
97 }
98
99 dlerror();
100
101 //declare library interface methods
102 TrigAccel::Module* (*getModule)();
103
104 getModule = (TrigAccel::Module* (*)()) dlsym(m_libHandle, "getModule");
105
107
108 int factory_id_to_load = 0;
109
111 factory_id_to_load = TrigAccel::TrigITkModuleID_CUDA;
112 }else{
113 factory_id_to_load = TrigAccel::TrigInDetModuleID_CUDA;
114 }
115
116 m_pWF = m_module->getFactoryById(factory_id_to_load);
117
118 if(m_pWF == nullptr){
119 ATH_MSG_INFO("OffloadFactory with id "<<std::hex<<factory_id_to_load<<" not available from the module");
120 m_factoryConfigured = false;
121 return StatusCode::SUCCESS;
122 }
123
124
125 m_factoryConfigured = true;
126 ATH_MSG_INFO("TrigInDetAccelerationSvc: created OffloadFactory, factory id = "<<std::hex<<m_pWF->getFactoryId()<<std::dec);
127 return StatusCode::SUCCESS;
128}
bool getModule(std::istream &s, RegSelModule &m)
constexpr unsigned int TrigITkModuleID_CUDA
constexpr unsigned int TrigInDetModuleID_CUDA

◆ isReady()

virtual bool TrigInDetAccelerationSvc::isReady ( ) const
inlineoverridevirtual

Definition at line 43 of file TrigInDetAccelerationSvc.h.

43 {
45 }

Member Data Documentation

◆ m_cudaCheckSvc

ServiceHandle<AthCUDA::IGPUSystemInfoSvc> TrigInDetAccelerationSvc::m_cudaCheckSvc
private

Definition at line 83 of file TrigInDetAccelerationSvc.h.

◆ m_detStore

ServiceHandle<StoreGateSvc> TrigInDetAccelerationSvc::m_detStore
private

Definition at line 81 of file TrigInDetAccelerationSvc.h.

◆ m_evtStore

ServiceHandle<StoreGateSvc> TrigInDetAccelerationSvc::m_evtStore
private

Definition at line 82 of file TrigInDetAccelerationSvc.h.

◆ m_factoryConfigured

bool TrigInDetAccelerationSvc::m_factoryConfigured
private

Definition at line 85 of file TrigInDetAccelerationSvc.h.

◆ m_layerInfo

std::vector<short> TrigInDetAccelerationSvc::m_layerInfo[3]
private

Definition at line 95 of file TrigInDetAccelerationSvc.h.

◆ m_libHandle

void* TrigInDetAccelerationSvc::m_libHandle
private

Definition at line 78 of file TrigInDetAccelerationSvc.h.

◆ m_middleSpacePointLayers

std::vector<int> TrigInDetAccelerationSvc::m_middleSpacePointLayers
private

Definition at line 77 of file TrigInDetAccelerationSvc.h.

◆ m_module

TrigAccel::Module* TrigInDetAccelerationSvc::m_module
private

Definition at line 80 of file TrigInDetAccelerationSvc.h.

◆ m_moduleName

std::string TrigInDetAccelerationSvc::m_moduleName
private

Definition at line 75 of file TrigInDetAccelerationSvc.h.

◆ m_nDCs

int TrigInDetAccelerationSvc::m_nDCs
private

Definition at line 74 of file TrigInDetAccelerationSvc.h.

◆ m_pWF

TrigAccel::WorkFactory* TrigInDetAccelerationSvc::m_pWF
private

Definition at line 79 of file TrigInDetAccelerationSvc.h.

◆ m_useITkGeometry

bool TrigInDetAccelerationSvc::m_useITkGeometry
private

Definition at line 76 of file TrigInDetAccelerationSvc.h.

◆ m_workMutex

std::mutex TrigInDetAccelerationSvc::m_workMutex
mutableprivate

Definition at line 97 of file TrigInDetAccelerationSvc.h.


The documentation for this class was generated from the following files: