ATLAS Offline Software
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
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
More...
 
virtual ~TrigInDetAccelerationSvc () override
 
virtual StatusCode initialize () override
 Initialize
More...
 
virtual StatusCode finalize () override
 Finalize
More...
 
virtual void handle (const Incident &) override
 OnBeginRun data gathering and export. More...
 
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

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
 
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 29 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_detStore("DetectorStore", name),
35  m_evtStore("StoreGateSvc",name),
36  m_factoryConfigured(false) {
37 
38  declareProperty( "NumberOfDCs", m_nDCs = 8 );
39  declareProperty( "ModuleName", m_moduleName = "libTrigInDetCUDA.so");
40  declareProperty( "useITkGeometry", m_useITkGeometry = false);
41  declareProperty( "MiddleSpacePointLayers", m_middleSpacePointLayers = std::vector<int>(), "Global IDs of layers that can contain middle spacepoints of track seeds" );
42 }

◆ ~TrigInDetAccelerationSvc()

virtual TrigInDetAccelerationSvc::~TrigInDetAccelerationSvc ( )
inlineoverridevirtual

Definition at line 35 of file TrigInDetAccelerationSvc.h.

35 {};

Member Function Documentation

◆ createWork()

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

Definition at line 176 of file TrigInDetAccelerationSvc.cxx.

176  {
177 
178  if(!m_factoryConfigured) return 0;
179 
180  // To remove this, WorkFactory::createWork() should be made const
181  // (and thread-safe).
182  std::scoped_lock lock (m_workMutex);
184  return wf->createWork(jobCode, pB);
185 
186 }

◆ exportGeometryInformation()

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

Definition at line 403 of file TrigInDetAccelerationSvc.cxx.

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

◆ exportITkGeometryInformation()

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

Definition at line 194 of file TrigInDetAccelerationSvc.cxx.

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

◆ extractGeometryInformation()

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

Definition at line 530 of file TrigInDetAccelerationSvc.cxx.

530  {
531 
532  const PixelID* pixelId = nullptr;
533  const SCT_ID* sctId = nullptr;
534 
535  if (m_detStore->retrieve(pixelId, "PixelID").isFailure()) {
536  ATH_MSG_WARNING("Could not get Pixel ID helper");
537  return false;
538  }
539 
540  if (m_detStore->retrieve(sctId, "SCT_ID").isFailure()) {
541  ATH_MSG_WARNING("Could not get Pixel ID helper");
542  return false;
543  }
544 
545  short subdetid = 1;
546 
547  for(int hash = 0; hash<(int)pixelId->wafer_hash_max(); hash++) {
548 
549  Identifier offlineId = pixelId->wafer_id(hash);
550 
551  if(offlineId==0) continue;
552 
553  short barrel_ec = pixelId->barrel_ec(offlineId);
554  if(abs(barrel_ec)>2) continue;//no DBM needed
555  short layer_disk = pixelId->layer_disk(offlineId);
556  short phi_index = pixelId->phi_module(offlineId);
557  short eta_index = pixelId->eta_module(offlineId);
558  auto t = std::make_tuple(subdetid, barrel_ec, layer_disk);
559  std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> >::iterator it = hashMap.find(t);
560  if(it==hashMap.end())
561  hashMap.insert(std::pair<std::tuple<short,short,short>,std::vector<PhiEtaHash> >(t,std::vector<PhiEtaHash>(1, PhiEtaHash(phi_index, eta_index, hash) )));
562  else (*it).second.push_back(PhiEtaHash(phi_index, eta_index, hash));
563  }
564  subdetid = 2;
565  for(int hash = 0; hash<(int)sctId->wafer_hash_max(); hash++) {
566 
567  Identifier offlineId = sctId->wafer_id(hash);
568 
569  if(offlineId==0) continue;
570 
571  short barrel_ec = sctId->barrel_ec(offlineId);
572  short layer_disk = sctId->layer_disk(offlineId);
573  short phi_index = sctId->phi_module(offlineId);
574  short eta_index = sctId->eta_module(offlineId);
575 
576  auto t = std::make_tuple(subdetid, barrel_ec, layer_disk);
577  std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> >::iterator it = hashMap.find(t);
578  if(it==hashMap.end())
579  hashMap.insert(std::pair<std::tuple<short,short,short>,std::vector<PhiEtaHash> >(t,std::vector<PhiEtaHash>(1, PhiEtaHash(phi_index, eta_index, hash))));
580  else (*it).second.push_back(PhiEtaHash(phi_index, eta_index, hash));
581  }
582 
583  m_layerInfo[1].resize(pixelId->wafer_hash_max(), -1);
584  m_layerInfo[2].resize(sctId->wafer_hash_max(), -1);
585 
586  int layerId=0;
587 
588  for(std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> >::iterator it = hashMap.begin();it!=hashMap.end();++it, layerId++) {
589 
590  short subdetId = std::get<0>((*it).first);
591  short barrel_ec = std::get<1>((*it).first);
592 
593  m_layerInfo[0].push_back(barrel_ec);
594 
595  if(subdetId == 1) {//pixel
596  for(std::vector<PhiEtaHash>::iterator hIt = (*it).second.begin();hIt != (*it).second.end();++hIt) {
597  m_layerInfo[subdetId][(*hIt).m_hash] = layerId;
598  }
599  }
600  if(subdetId == 2) {//SCT
601  for(std::vector<PhiEtaHash>::iterator hIt = (*it).second.begin();hIt != (*it).second.end();++hIt) {
602  m_layerInfo[subdetId][(*hIt).m_hash] = layerId;
603  }
604  }
605  }
606 
607 
608  for(std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> >::iterator it = hashMap.begin();it!=hashMap.end();++it) {
609 
610  //sorting along phi first, then along eta
611 
612  std::sort((*it).second.begin(), (*it).second.end(), PhiEtaHash::compare());
613 
614  }
615  return true;
616 }

◆ extractITkGeometryInformation()

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

Definition at line 322 of file TrigInDetAccelerationSvc.cxx.

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

◆ finalize()

StatusCode TrigInDetAccelerationSvc::finalize ( )
overridevirtual

Finalize

Definition at line 128 of file TrigInDetAccelerationSvc.cxx.

128  {
129 
130  delete m_pWF;
131 
132  dlclose(m_libHandle);
133 
134  return StatusCode::SUCCESS;
135 }

◆ getLayerInformation()

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

Definition at line 189 of file TrigInDetAccelerationSvc.cxx.

189  {
190  if (i<0 || i>2) i = 0;
191  return m_layerInfo[i];
192 }

◆ getMiddleLayersSize()

virtual size_t TrigInDetAccelerationSvc::getMiddleLayersSize ( ) const
inlineoverridevirtual

Definition at line 47 of file TrigInDetAccelerationSvc.h.

47 {return m_middleSpacePointLayers.size();};

◆ handle()

void TrigInDetAccelerationSvc::handle ( const Incident &  )
overridevirtual

OnBeginRun data gathering and export.

Definition at line 142 of file TrigInDetAccelerationSvc.cxx.

142  {
143 
144  ATH_MSG_INFO("OnBeginRun ");
145 
146  if (m_useITkGeometry) {
147  // barrel ec, subdetector id, itk volume id, itk layer disk id
148  std::map<std::tuple<short,short, int, int>,std::vector<PhiEtaHash> > hashMap;
149  if(!extractITkGeometryInformation(hashMap)) {
150  ATH_MSG_INFO("ITk Geometry extraction failed");
151  return;
152  }
153 
154  if(!exportITkGeometryInformation(hashMap)) {
155  ATH_MSG_INFO("ITk Geometry export failed");
156  }
157 
158  } else {
159  // subdetector id, barrel ec, layer disk
160  std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> > hashMap;
161 
162  if(!extractGeometryInformation(hashMap)) {
163  ATH_MSG_INFO("Geometry extraction failed");
164  return;
165  }
166 
167  if(!exportGeometryInformation(hashMap)) {
168  ATH_MSG_INFO("Geometry export failed");
169  }
170 
171  }
172 
173  return;
174 }

◆ initialize()

StatusCode TrigInDetAccelerationSvc::initialize ( )
overridevirtual

Initialize

Definition at line 49 of file TrigInDetAccelerationSvc.cxx.

49  {
50 
51  ATH_MSG_INFO("TrigInDetAccelerationSvc: initialize");
52 
53  ATH_CHECK (m_evtStore.retrieve() );
54  ATH_CHECK (m_detStore.retrieve() );
55 
56  //load the OffloadFactory library
57 
58  m_libHandle = dlopen(m_moduleName.c_str(), RTLD_LAZY);
59 
60  if(!m_libHandle) {
61  ATH_MSG_INFO("TrigInDetAccelerationSvc: cannot load the factory library, error:"<<dlerror());
62  return StatusCode::SUCCESS;
63  }
64 
65  dlerror();
66 
67  //declare library interface methods
68  TrigAccel::Module* (*getModule)();
69 
70  getModule = (TrigAccel::Module* (*)()) dlsym(m_libHandle, "getModule");
71 
72  m_module = getModule();
73 
74  int factory_id_to_load = 0;
75 
76  if(m_useITkGeometry){
77  factory_id_to_load = TrigAccel::TrigITkModuleID_CUDA;
78  }else{
79  factory_id_to_load = TrigAccel::TrigInDetModuleID_CUDA;
80  }
81 
82  m_pWF = m_module->getFactoryById(factory_id_to_load);
83 
84  if(m_pWF == nullptr){
85  ATH_MSG_INFO("OffloadFactory with id "<<std::hex<<factory_id_to_load<<" not available from the module");
86  m_factoryConfigured = false;
87  return StatusCode::SUCCESS;
88  }
89 
90  bool cfgResult = m_pWF->configure();
91 
92  if(!cfgResult) {
93  ATH_MSG_INFO("OffloadFactory config failed");
94  m_factoryConfigured = false;
95  return StatusCode::SUCCESS;
96  }
97 
98  m_factoryConfigured = true;
99 
100  for(int i=0;i<3;i++) m_layerInfo[i].clear();
101 
102  ATH_MSG_INFO("TrigInDetAccelerationSvc: created OffloadFactory, factory id = "<<std::hex<<m_pWF->getFactoryId()<<std::dec);
103 
104  /*
105  * Ask to be informed at the beginning of a new run so that we
106  * can collect geometry, conditions, etc. and copy them to on-GPU data structures
107  * For athenaHLT this should be UpdateAfterFork
108  */
109 
110  SmartIF<IIncidentSvc> incsvc{service("IncidentSvc")};
111  const int priority = 100;
112  if( incsvc ) {
113  const bool is_multiprocess = (Gaudi::Concurrency::ConcurrencyFlags::numProcs() > 0);
114  if (is_multiprocess) {
115  incsvc->addListener( this, AthenaInterprocess::UpdateAfterFork::type(), priority);
116  }
117  else {
118  incsvc->addListener( this, "BeginRun", priority);
119  }
120  }
121 
122  return StatusCode::SUCCESS;
123 }

◆ isReady()

virtual bool TrigInDetAccelerationSvc::isReady ( ) const
inlineoverridevirtual

Definition at line 41 of file TrigInDetAccelerationSvc.h.

41  {
42  return m_factoryConfigured;
43  }

Member Data Documentation

◆ m_detStore

ServiceHandle<StoreGateSvc> TrigInDetAccelerationSvc::m_detStore
private

Definition at line 78 of file TrigInDetAccelerationSvc.h.

◆ m_evtStore

ServiceHandle<StoreGateSvc> TrigInDetAccelerationSvc::m_evtStore
private

Definition at line 79 of file TrigInDetAccelerationSvc.h.

◆ m_factoryConfigured

bool TrigInDetAccelerationSvc::m_factoryConfigured
private

Definition at line 81 of file TrigInDetAccelerationSvc.h.

◆ m_layerInfo

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

Definition at line 91 of file TrigInDetAccelerationSvc.h.

◆ m_libHandle

void* TrigInDetAccelerationSvc::m_libHandle
private

Definition at line 75 of file TrigInDetAccelerationSvc.h.

◆ m_middleSpacePointLayers

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

Definition at line 74 of file TrigInDetAccelerationSvc.h.

◆ m_module

TrigAccel::Module* TrigInDetAccelerationSvc::m_module
private

Definition at line 77 of file TrigInDetAccelerationSvc.h.

◆ m_moduleName

std::string TrigInDetAccelerationSvc::m_moduleName
private

Definition at line 72 of file TrigInDetAccelerationSvc.h.

◆ m_nDCs

int TrigInDetAccelerationSvc::m_nDCs
private

Definition at line 71 of file TrigInDetAccelerationSvc.h.

◆ m_pWF

TrigAccel::WorkFactory* TrigInDetAccelerationSvc::m_pWF
private

Definition at line 76 of file TrigInDetAccelerationSvc.h.

◆ m_useITkGeometry

bool TrigInDetAccelerationSvc::m_useITkGeometry
private

Definition at line 73 of file TrigInDetAccelerationSvc.h.

◆ m_workMutex

std::mutex TrigInDetAccelerationSvc::m_workMutex
mutableprivate

Definition at line 93 of file TrigInDetAccelerationSvc.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
TrigInDetAccelerationSvc::m_factoryConfigured
bool m_factoryConfigured
Definition: TrigInDetAccelerationSvc.h:81
TrigAccel::DataExportBuffer
Definition: DataExportBuffer.h:14
TrigAccel::SiliconLayer::m_nElements
int m_nElements
Definition: TrigInDetAccelEDM.h:26
TrigAccel::DataExportBuffer::fit
bool fit(size_t s)
Definition: DataExportBuffer.h:26
TrigAccel::DATA_EXPORT_BUFFER
struct TrigAccel::DataExportBuffer DATA_EXPORT_BUFFER
InDetDD::SCT_DetectorManager
Definition: SCT_DetectorManager.h:49
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
TrigAccel::ITk::SiliconLayer::m_nPhiSlices
int m_nPhiSlices
Definition: TrigITkAccelEDM.h:31
TrigAccel::DataExportBuffer::reallocate
void reallocate(size_t s)
Definition: DataExportBuffer.h:30
TrigAccel::ITk::SiliconLayer::m_refCoord
float m_refCoord
Definition: TrigITkAccelEDM.h:27
PixelID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: PixelID.h:619
PhiEtaHash
Definition: TrigL2LayerNumberTool.h:23
TrigInDetAccelerationSvc::extractITkGeometryInformation
bool extractITkGeometryInformation(std::map< std::tuple< short, short, int, int >, std::vector< PhiEtaHash > > &)
Definition: TrigInDetAccelerationSvc.cxx:322
TrigAccel::SIL_LAYERS_EXPORT
@ SIL_LAYERS_EXPORT
Definition: TrigInDetAccelCodes.h:24
TrigAccel::WorkFactory::createWork
virtual Work * createWork(int, std::shared_ptr< OffloadBuffer > data)=0
TrigAccel::WorkFactory::getFactoryId
virtual int getFactoryId()=0
DMTest::C
C_v1 C
Definition: C.h:26
TrigAccel::DetectorModel::m_nLayers
int m_nLayers
Definition: TrigInDetAccelEDM.h:35
skel.it
it
Definition: skel.GENtoEVGEN.py:396
TrigAccel::TrigITkModuleID_CUDA
constexpr unsigned int TrigITkModuleID_CUDA
Definition: TrigInDetAccelCodes.h:13
TrigAccel::ITk::DetectorModel::m_layers
SILICON_LAYER m_layers[MAX_SILICON_LAYERS]
Definition: TrigITkAccelEDM.h:39
TrigInDetAccelerationSvc::exportITkGeometryInformation
bool exportITkGeometryInformation(const std::map< std::tuple< short, short, int, int >, std::vector< PhiEtaHash > > &hashMap) const
Definition: TrigInDetAccelerationSvc.cxx:194
python.selector.AtlRunQuerySelectorLhcOlc.priority
priority
Definition: AtlRunQuerySelectorLhcOlc.py:611
SCT_ID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: SCT_ID.h:728
TrigAccel::SiliconLayer::m_subdet
int m_subdet
Definition: TrigInDetAccelEDM.h:23
SCT_ID::phi_module
int phi_module(const Identifier &id) const
Definition: SCT_ID.h:740
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
TrigAccel::SiliconLayer::m_type
int m_type
Definition: TrigInDetAccelEDM.h:24
TrigInDetAccelerationSvc::m_pWF
TrigAccel::WorkFactory * m_pWF
Definition: TrigInDetAccelerationSvc.h:76
getModule
bool getModule(std::istream &s, RegSelModule &m)
Definition: RegSelModule.cxx:110
InDetDD::SCT_DetectorManager::getDetectorElement
virtual SiDetectorElement * getDetectorElement(const Identifier &id) const override
access to individual elements via Identifier
Definition: SCT_DetectorManager.cxx:64
PixelID::wafer_id
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
Definition: PixelID.h:364
TrigInDetAccelerationSvc::m_module
TrigAccel::Module * m_module
Definition: TrigInDetAccelerationSvc.h:77
TrigInDetAccelerationSvc::createWork
virtual TrigAccel::Work * createWork(unsigned int, std::shared_ptr< TrigAccel::OffloadBuffer >) const override
Definition: TrigInDetAccelerationSvc.cxx:176
TrigAccel::DetectorModel::m_maxRZ
float m_maxRZ[MAX_NUMBER_PIX_MODULES+MAX_NUMBER_SCT_MODULES]
Definition: TrigInDetAccelEDM.h:40
TrigAccel::Module
Definition: Trigger/TrigAccel/TrigAccelEvent/TrigAccelEvent/Module.h:16
TrigInDetAccelerationSvc::m_detStore
ServiceHandle< StoreGateSvc > m_detStore
Definition: TrigInDetAccelerationSvc.h:78
TrigAccel::TrigInDetModuleID_CUDA
constexpr unsigned int TrigInDetModuleID_CUDA
Definition: TrigInDetAccelCodes.h:12
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
TrigAccel::ITk::SiliconLayer::m_type
int m_type
Definition: TrigITkAccelEDM.h:26
TrigAccel::SiliconLayer::m_minBound
float m_minBound
Definition: TrigInDetAccelEDM.h:27
TrigInDetAccelerationSvc::m_nDCs
int m_nDCs
Definition: TrigInDetAccelerationSvc.h:71
TrigAccel::DetectorModel::m_layers
SILICON_LAYER m_layers[MAX_SILICON_LAYERS]
Definition: TrigInDetAccelEDM.h:37
lumiFormat.i
int i
Definition: lumiFormat.py:85
TrigAccel::ITk::DetectorModel::m_maxRZ
float m_maxRZ[MAX_NUMBER_PIX_MODULES+MAX_NUMBER_SCT_MODULES]
Definition: TrigITkAccelEDM.h:43
TrigAccel::WorkFactory::configure
virtual bool configure()=0
TrigAccel::ITk::SiliconLayer::m_maxBound
float m_maxBound
Definition: TrigITkAccelEDM.h:29
TrigAccel::DetectorModel::m_nModules
int m_nModules
Definition: TrigInDetAccelEDM.h:36
TrigInDetAccelerationSvc::m_evtStore
ServiceHandle< StoreGateSvc > m_evtStore
Definition: TrigInDetAccelerationSvc.h:79
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TrigAccel::ITk::DetectorModel::m_hashArray
int m_hashArray[MAX_NUMBER_PIX_MODULES+MAX_NUMBER_SCT_MODULES]
Definition: TrigITkAccelEDM.h:41
TrigAccel::DetectorModel::m_minRZ
float m_minRZ[MAX_NUMBER_PIX_MODULES+MAX_NUMBER_SCT_MODULES]
Definition: TrigInDetAccelEDM.h:39
createCablingJSON.eta_index
int eta_index
Definition: createCablingJSON.py:9
TrigInDetAccelerationSvc::m_workMutex
std::mutex m_workMutex
Definition: TrigInDetAccelerationSvc.h:93
TrigAccel::ITk::DetectorModel::m_minRZ
float m_minRZ[MAX_NUMBER_PIX_MODULES+MAX_NUMBER_SCT_MODULES]
Definition: TrigITkAccelEDM.h:42
TrigAccel::ITk::DetectorModel
Definition: TrigITkAccelEDM.h:35
TrigAccel::ITk::DetectorModel::m_middleSpacePointLayers
int m_middleSpacePointLayers[MAX_SILICON_LAYERS]
Definition: TrigITkAccelEDM.h:40
TrigAccel::DetectorModel::m_hashArray
int m_hashArray[MAX_NUMBER_PIX_MODULES+MAX_NUMBER_SCT_MODULES]
Definition: TrigInDetAccelEDM.h:38
TrigAccel::SiliconLayer::m_maxBound
float m_maxBound
Definition: TrigInDetAccelEDM.h:27
PixelID::layer_disk
int layer_disk(const Identifier &id) const
Definition: PixelID.h:626
PixelID::eta_module
int eta_module(const Identifier &id) const
Definition: PixelID.h:651
InDetDD::PixelDetectorManager
Definition: PixelDetectorManager.h:47
TrigAccel::SiliconLayer::m_nPhiSlices
int m_nPhiSlices
Definition: TrigInDetAccelEDM.h:29
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
SCT_ID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: SCT_ID.cxx:636
TrigAccel::ITk::DetectorModel::m_nModules
int m_nModules
Definition: TrigITkAccelEDM.h:38
TrigInDetAccelerationSvc::m_middleSpacePointLayers
std::vector< int > m_middleSpacePointLayers
Definition: TrigInDetAccelerationSvc.h:74
TrigAccel::Work
Definition: Work.h:14
SCT_ID::layer_disk
int layer_disk(const Identifier &id) const
Definition: SCT_ID.h:734
TrigAccel::DETECTOR_MODEL
struct TrigAccel::DetectorModel DETECTOR_MODEL
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
PixelID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: PixelID.cxx:907
PhiEtaHash::compare
Definition: TrigL2LayerNumberTool.h:25
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
TrigInDetAccelerationSvc::m_moduleName
std::string m_moduleName
Definition: TrigInDetAccelerationSvc.h:72
AthenaInterprocess::UpdateAfterFork::type
static const std::string & type()
Incident type.
Definition: Incidents.h:49
TrigAccel::ITk::DETECTOR_MODEL
struct TrigAccel::ITk::DetectorModel DETECTOR_MODEL
TrigAccel::DataExportBuffer::m_buffer
char * m_buffer
Definition: DataExportBuffer.h:57
TrigInDetAccelerationSvc::m_libHandle
void * m_libHandle
Definition: TrigInDetAccelerationSvc.h:75
TrigAccel::ITk::SiliconLayer::m_subdet
int m_subdet
Definition: TrigITkAccelEDM.h:25
VKalVrtAthena::varHolder_detail::clear
void clear(T &var)
Definition: NtupleVars.h:48
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
SCT_ID
Definition: SCT_ID.h:68
TrigAccel::Module::getFactoryById
virtual WorkFactory * getFactoryById(int id)=0
TrigAccel::ITk::SiliconLayer::m_nElements
int m_nElements
Definition: TrigITkAccelEDM.h:28
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
DeMoScan.first
bool first
Definition: DeMoScan.py:536
TrigInDetAccelerationSvc::m_useITkGeometry
bool m_useITkGeometry
Definition: TrigInDetAccelerationSvc.h:73
SCT_ID::eta_module
int eta_module(const Identifier &id) const
Definition: SCT_ID.h:746
python.copyTCTOutput.totalSize
totalSize
Definition: copyTCTOutput.py:93
TrigAccel::ITk::DetectorModel::m_nLayers
int m_nLayers
Definition: TrigITkAccelEDM.h:37
TrigAccel::WorkFactory
Definition: WorkFactory.h:16
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
SCT_ID::wafer_id
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:464
PixelID::phi_module
int phi_module(const Identifier &id) const
Definition: PixelID.h:644
TrigAccel::ITk::SiliconLayer::m_minBound
float m_minBound
Definition: TrigITkAccelEDM.h:29
PixelID
Definition: PixelID.h:67
TrigAccel::SiliconLayer::m_refCoord
float m_refCoord
Definition: TrigInDetAccelEDM.h:25
TrigAccel::DetectorModel
Definition: TrigInDetAccelEDM.h:33
python.trfValidateRootFile.rc
rc
Definition: trfValidateRootFile.py:349
TrigInDetAccelerationSvc::m_layerInfo
std::vector< short > m_layerInfo[3]
Definition: TrigInDetAccelerationSvc.h:91
TrigInDetAccelerationSvc::extractGeometryInformation
bool extractGeometryInformation(std::map< std::tuple< short, short, short >, std::vector< PhiEtaHash > > &)
Definition: TrigInDetAccelerationSvc.cxx:530
InDetDD::PixelDetectorManager::getDetectorElement
virtual SiDetectorElement * getDetectorElement(const Identifier &id) const override
access to individual elements : via Identifier
Definition: PixelDetectorManager.cxx:80
TrigInDetAccelerationSvc::exportGeometryInformation
bool exportGeometryInformation(const std::map< std::tuple< short, short, short >, std::vector< PhiEtaHash > > &) const
Definition: TrigInDetAccelerationSvc.cxx:403
Identifier
Definition: IdentifierFieldParser.cxx:14