CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Attributes
SiPixelROCsStatusAndMappingWrapper Class Reference

#include <SiPixelROCsStatusAndMappingWrapper.h>

Classes

struct  GPUData
 
struct  ModulesToUnpack
 

Public Member Functions

const SiPixelROCsStatusAndMappinggetGPUProductAsync (cudaStream_t cudaStream) const
 
const unsigned char * getModToUnpAllAsync (cudaStream_t cudaStream) const
 
cms::cuda::device::unique_ptr< unsigned char[]> getModToUnpRegionalAsync (std::set< unsigned int > const &modules, cudaStream_t cudaStream) const
 
bool hasQuality () const
 
 SiPixelROCsStatusAndMappingWrapper (SiPixelFedCablingMap const &cablingMap, TrackerGeometry const &trackerGeom, SiPixelQuality const *badPixelInfo)
 
 ~SiPixelROCsStatusAndMappingWrapper ()
 

Private Attributes

const SiPixelFedCablingMapcablingMap_
 
SiPixelROCsStatusAndMappingcablingMapHost = nullptr
 
cms::cuda::ESProduct< GPUDatagpuData_
 
bool hasQuality_
 
cms::cuda::ESProduct< ModulesToUnpackmodToUnp_
 
std::vector< unsigned char, cms::cuda::HostAllocator< unsigned char > > modToUnpDefault
 
unsigned int size
 

Detailed Description

Definition at line 17 of file SiPixelROCsStatusAndMappingWrapper.h.

Constructor & Destructor Documentation

◆ SiPixelROCsStatusAndMappingWrapper()

SiPixelROCsStatusAndMappingWrapper::SiPixelROCsStatusAndMappingWrapper ( SiPixelFedCablingMap const &  cablingMap,
TrackerGeometry const &  trackerGeom,
SiPixelQuality const *  badPixelInfo 
)

Definition at line 23 of file SiPixelROCsStatusAndMappingWrapper.cc.

26  : cablingMap_(&cablingMap), modToUnpDefault(pixelgpudetails::MAX_SIZE), hasQuality_(badPixelInfo != nullptr) {
27  cudaCheck(cudaMallocHost(&cablingMapHost, sizeof(SiPixelROCsStatusAndMapping)));
28 
29  std::vector<unsigned int> const& fedIds = cablingMap.fedIds();
30  std::unique_ptr<SiPixelFedCablingTree> const& cabling = cablingMap.cablingTree();
31 
32  unsigned int startFed = *(fedIds.begin());
33  unsigned int endFed = *(fedIds.end() - 1);
34 
36  int index = 1;
37 
38  for (unsigned int fed = startFed; fed <= endFed; fed++) {
39  for (unsigned int link = 1; link <= pixelgpudetails::MAX_LINK; link++) {
40  for (unsigned int roc = 1; roc <= pixelgpudetails::MAX_ROC; roc++) {
41  path = {fed, link, roc};
42  const sipixelobjects::PixelROC* pixelRoc = cabling->findItem(path);
43  cablingMapHost->fed[index] = fed;
46  if (pixelRoc != nullptr) {
47  cablingMapHost->rawId[index] = pixelRoc->rawId();
48  cablingMapHost->rocInDet[index] = pixelRoc->idInDetUnit();
49  modToUnpDefault[index] = false;
50  if (badPixelInfo != nullptr)
51  cablingMapHost->badRocs[index] = badPixelInfo->IsRocBad(pixelRoc->rawId(), pixelRoc->idInDetUnit());
52  else
53  cablingMapHost->badRocs[index] = false;
54  } else { // store some dummy number
57  cablingMapHost->badRocs[index] = true;
58  modToUnpDefault[index] = true;
59  }
60  index++;
61  }
62  }
63  } // end of FED loop
64 
65  // Given FedId, Link and idinLnk; use the following formula
66  // to get the rawId and idinDU
67  // index = (FedID-1200) * MAX_LINK* MAX_ROC + (Link-1)* MAX_ROC + idinLnk;
68  // where, MAX_LINK = 48, MAX_ROC = 8 for Phase1 as mentioned Danek's email
69  // FedID varies between 1200 to 1338 (In total 108 FED's)
70  // Link varies between 1 to 48
71  // idinLnk varies between 1 to 8
72 
73  for (int i = 1; i < index; i++) {
76  } else {
77  /*
78  std::cout << cablingMapHost->rawId[i] << std::endl;
79  */
80  auto gdet = trackerGeom.idToDetUnit(cablingMapHost->rawId[i]);
81  if (!gdet) {
82  LogDebug("SiPixelROCsStatusAndMapping") << " Not found: " << cablingMapHost->rawId[i] << std::endl;
83  continue;
84  }
85  cablingMapHost->moduleId[i] = gdet->index();
86  }
87  LogDebug("SiPixelROCsStatusAndMapping")
88  << "----------------------------------------------------------------------------" << std::endl;
89  LogDebug("SiPixelROCsStatusAndMapping")
90  << i << std::setw(20) << cablingMapHost->fed[i] << std::setw(20) << cablingMapHost->link[i] << std::setw(20)
91  << cablingMapHost->roc[i] << std::endl;
92  LogDebug("SiPixelROCsStatusAndMapping")
93  << i << std::setw(20) << cablingMapHost->rawId[i] << std::setw(20) << cablingMapHost->rocInDet[i]
94  << std::setw(20) << cablingMapHost->moduleId[i] << std::endl;
95  LogDebug("SiPixelROCsStatusAndMapping")
96  << i << std::setw(20) << (bool)cablingMapHost->badRocs[i] << std::setw(20) << std::endl;
97  LogDebug("SiPixelROCsStatusAndMapping")
98  << "----------------------------------------------------------------------------" << std::endl;
99  }
100 
101  cablingMapHost->size = index - 1;
102 }

References SiPixelROCsStatusAndMapping::badRocs, electrons_cff::bool, cablingMapHost, SiPixelFedCablingMap::cablingTree(), cudaCheck, SiPixelROCsStatusAndMapping::fed, L1TStage2BMTF_cff::fedIds, SiPixelFedCablingMap::fedIds(), mps_fire::i, sipixelobjects::PixelROC::idInDetUnit(), TrackerGeometry::idToDetUnit(), gpuClustering::invalidModuleId, SiPixelQuality::IsRocBad(), SiPixelROCsStatusAndMapping::link, MainPageGenerator::link, LogDebug, pixelgpudetails::MAX_LINK, pixelgpudetails::MAX_ROC, modToUnpDefault, SiPixelROCsStatusAndMapping::moduleId, castor_dqm_sourceclient_file_cfg::path, SiPixelROCsStatusAndMapping::rawId, sipixelobjects::PixelROC::rawId(), SiPixelROCsStatusAndMapping::roc, PixelMapPlotter::roc, SiPixelROCsStatusAndMapping::rocInDet, and SiPixelROCsStatusAndMapping::size.

◆ ~SiPixelROCsStatusAndMappingWrapper()

SiPixelROCsStatusAndMappingWrapper::~SiPixelROCsStatusAndMappingWrapper ( )

Definition at line 104 of file SiPixelROCsStatusAndMappingWrapper.cc.

104 { cudaCheck(cudaFreeHost(cablingMapHost)); }

References cablingMapHost, and cudaCheck.

Member Function Documentation

◆ getGPUProductAsync()

const SiPixelROCsStatusAndMapping * SiPixelROCsStatusAndMappingWrapper::getGPUProductAsync ( cudaStream_t  cudaStream) const

Definition at line 106 of file SiPixelROCsStatusAndMappingWrapper.cc.

107  {
108  const auto& data = gpuData_.dataForCurrentDeviceAsync(cudaStream, [this](GPUData& data, cudaStream_t stream) {
109  // allocate
110  cudaCheck(cudaMalloc(&data.cablingMapDevice, sizeof(SiPixelROCsStatusAndMapping)));
111 
112  // transfer
113  cudaCheck(cudaMemcpyAsync(
114  data.cablingMapDevice, this->cablingMapHost, sizeof(SiPixelROCsStatusAndMapping), cudaMemcpyDefault, stream));
115  });
116  return data.cablingMapDevice;
117 }

References cudaCheck, data, gpuData_, and cms::cuda::stream.

◆ getModToUnpAllAsync()

const unsigned char * SiPixelROCsStatusAndMappingWrapper::getModToUnpAllAsync ( cudaStream_t  cudaStream) const

Definition at line 119 of file SiPixelROCsStatusAndMappingWrapper.cc.

119  {
120  const auto& data =
121  modToUnp_.dataForCurrentDeviceAsync(cudaStream, [this](ModulesToUnpack& data, cudaStream_t stream) {
122  cudaCheck(cudaMalloc((void**)&data.modToUnpDefault, pixelgpudetails::MAX_SIZE_BYTE_BOOL));
123  cudaCheck(cudaMemcpyAsync(data.modToUnpDefault,
124  this->modToUnpDefault.data(),
125  this->modToUnpDefault.size() * sizeof(unsigned char),
126  cudaMemcpyDefault,
127  stream));
128  });
129  return data.modToUnpDefault;
130 }

References cudaCheck, data, pixelgpudetails::MAX_SIZE_BYTE_BOOL, modToUnp_, modToUnpDefault, and cms::cuda::stream.

◆ getModToUnpRegionalAsync()

cms::cuda::device::unique_ptr< unsigned char[]> SiPixelROCsStatusAndMappingWrapper::getModToUnpRegionalAsync ( std::set< unsigned int > const &  modules,
cudaStream_t  cudaStream 
) const

Definition at line 132 of file SiPixelROCsStatusAndMappingWrapper.cc.

133  {
134  auto modToUnpDevice = cms::cuda::make_device_unique<unsigned char[]>(pixelgpudetails::MAX_SIZE, cudaStream);
135  auto modToUnpHost = cms::cuda::make_host_unique<unsigned char[]>(pixelgpudetails::MAX_SIZE, cudaStream);
136 
137  std::vector<unsigned int> const& fedIds = cablingMap_->fedIds();
138  std::unique_ptr<SiPixelFedCablingTree> const& cabling = cablingMap_->cablingTree();
139 
140  unsigned int startFed = *(fedIds.begin());
141  unsigned int endFed = *(fedIds.end() - 1);
142 
144  int index = 1;
145 
146  for (unsigned int fed = startFed; fed <= endFed; fed++) {
147  for (unsigned int link = 1; link <= pixelgpudetails::MAX_LINK; link++) {
148  for (unsigned int roc = 1; roc <= pixelgpudetails::MAX_ROC; roc++) {
149  path = {fed, link, roc};
150  const sipixelobjects::PixelROC* pixelRoc = cabling->findItem(path);
151  if (pixelRoc != nullptr) {
152  modToUnpHost[index] = (not modules.empty()) and (modules.find(pixelRoc->rawId()) == modules.end());
153  } else { // store some dummy number
154  modToUnpHost[index] = true;
155  }
156  index++;
157  }
158  }
159  }
160 
161  cudaCheck(cudaMemcpyAsync(modToUnpDevice.get(),
162  modToUnpHost.get(),
163  pixelgpudetails::MAX_SIZE * sizeof(unsigned char),
164  cudaMemcpyHostToDevice,
165  cudaStream));
166  return modToUnpDevice;
167 }

References cablingMap_, SiPixelFedCablingMap::cablingTree(), cudaCheck, L1TStage2BMTF_cff::fedIds, SiPixelFedCablingMap::fedIds(), MainPageGenerator::link, pixelgpudetails::MAX_LINK, pixelgpudetails::MAX_ROC, pixelgpudetails::MAX_SIZE, castor_dqm_sourceclient_file_cfg::path, sipixelobjects::PixelROC::rawId(), and PixelMapPlotter::roc.

◆ hasQuality()

bool SiPixelROCsStatusAndMappingWrapper::hasQuality ( ) const
inline

Definition at line 24 of file SiPixelROCsStatusAndMappingWrapper.h.

24 { return hasQuality_; }

References hasQuality_.

Member Data Documentation

◆ cablingMap_

const SiPixelFedCablingMap* SiPixelROCsStatusAndMappingWrapper::cablingMap_
private

Definition at line 35 of file SiPixelROCsStatusAndMappingWrapper.h.

Referenced by getModToUnpRegionalAsync().

◆ cablingMapHost

SiPixelROCsStatusAndMapping* SiPixelROCsStatusAndMappingWrapper::cablingMapHost = nullptr
private

◆ gpuData_

cms::cuda::ESProduct<GPUData> SiPixelROCsStatusAndMappingWrapper::gpuData_
private

Definition at line 46 of file SiPixelROCsStatusAndMappingWrapper.h.

Referenced by getGPUProductAsync().

◆ hasQuality_

bool SiPixelROCsStatusAndMappingWrapper::hasQuality_
private

Definition at line 38 of file SiPixelROCsStatusAndMappingWrapper.h.

Referenced by hasQuality().

◆ modToUnp_

cms::cuda::ESProduct<ModulesToUnpack> SiPixelROCsStatusAndMappingWrapper::modToUnp_
private

Definition at line 52 of file SiPixelROCsStatusAndMappingWrapper.h.

Referenced by getModToUnpAllAsync().

◆ modToUnpDefault

std::vector<unsigned char, cms::cuda::HostAllocator<unsigned char> > SiPixelROCsStatusAndMappingWrapper::modToUnpDefault
private

◆ size

unsigned int SiPixelROCsStatusAndMappingWrapper::size
private
electrons_cff.bool
bool
Definition: electrons_cff.py:366
mps_fire.i
i
Definition: mps_fire.py:428
SiPixelROCsStatusAndMappingWrapper::cablingMap_
const SiPixelFedCablingMap * cablingMap_
Definition: SiPixelROCsStatusAndMappingWrapper.h:35
MainPageGenerator.link
link
Definition: MainPageGenerator.py:271
modules
Definition: MuonCleanerBySegments.cc:35
SiPixelROCsStatusAndMapping::rawId
unsigned int rawId[pixelgpudetails::MAX_SIZE]
Definition: SiPixelROCsStatusAndMapping.h:18
cms::cuda::stream
cudaStream_t stream
Definition: HistoContainer.h:57
SiPixelROCsStatusAndMapping::roc
unsigned int roc[pixelgpudetails::MAX_SIZE]
Definition: SiPixelROCsStatusAndMapping.h:17
SiPixelROCsStatusAndMappingWrapper::hasQuality_
bool hasQuality_
Definition: SiPixelROCsStatusAndMappingWrapper.h:38
SiPixelROCsStatusAndMapping::link
unsigned int link[pixelgpudetails::MAX_SIZE]
Definition: SiPixelROCsStatusAndMapping.h:16
pixelgpudetails::MAX_LINK
constexpr unsigned int MAX_LINK
Definition: SiPixelROCsStatusAndMapping.h:8
SiPixelROCsStatusAndMapping::rocInDet
unsigned int rocInDet[pixelgpudetails::MAX_SIZE]
Definition: SiPixelROCsStatusAndMapping.h:19
SiPixelROCsStatusAndMapping::size
unsigned int size
Definition: SiPixelROCsStatusAndMapping.h:22
pixelgpudetails::MAX_SIZE
constexpr unsigned int MAX_SIZE
Definition: SiPixelROCsStatusAndMapping.h:10
sipixelobjects::CablingPathToDetUnit
Definition: CablingPathToDetUnit.h:5
SiPixelROCsStatusAndMappingWrapper::cablingMapHost
SiPixelROCsStatusAndMapping * cablingMapHost
Definition: SiPixelROCsStatusAndMappingWrapper.h:40
SiPixelROCsStatusAndMapping::moduleId
unsigned int moduleId[pixelgpudetails::MAX_SIZE]
Definition: SiPixelROCsStatusAndMapping.h:20
sipixelobjects::PixelROC::rawId
uint32_t rawId() const
return the DetUnit to which this ROC belongs to.
Definition: PixelROC.h:34
SiPixelFedCablingMap::cablingTree
std::unique_ptr< SiPixelFedCablingTree > cablingTree() const
Definition: SiPixelFedCablingMap.cc:103
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
gpuClustering::invalidModuleId
constexpr uint16_t invalidModuleId
Definition: gpuClusteringConstants.h:32
sipixelobjects::PixelROC
Definition: PixelROC.h:23
cudaCheck
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:62
SiPixelROCsStatusAndMapping::fed
unsigned int fed[pixelgpudetails::MAX_SIZE]
Definition: SiPixelROCsStatusAndMapping.h:15
SiPixelROCsStatusAndMapping::badRocs
unsigned char badRocs[pixelgpudetails::MAX_SIZE]
Definition: SiPixelROCsStatusAndMapping.h:21
pixelgpudetails::MAX_SIZE_BYTE_BOOL
constexpr unsigned int MAX_SIZE_BYTE_BOOL
Definition: SiPixelROCsStatusAndMapping.h:11
SiPixelROCsStatusAndMappingWrapper::modToUnpDefault
std::vector< unsigned char, cms::cuda::HostAllocator< unsigned char > > modToUnpDefault
Definition: SiPixelROCsStatusAndMappingWrapper.h:36
SiPixelROCsStatusAndMappingWrapper::modToUnp_
cms::cuda::ESProduct< ModulesToUnpack > modToUnp_
Definition: SiPixelROCsStatusAndMappingWrapper.h:52
PixelMapPlotter.roc
roc
Definition: PixelMapPlotter.py:498
L1TStage2BMTF_cff.fedIds
fedIds
Definition: L1TStage2BMTF_cff.py:10
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
SiPixelROCsStatusAndMappingWrapper::gpuData_
cms::cuda::ESProduct< GPUData > gpuData_
Definition: SiPixelROCsStatusAndMappingWrapper.h:46
pixelgpudetails::MAX_ROC
constexpr unsigned int MAX_ROC
Definition: SiPixelROCsStatusAndMapping.h:9
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
SiPixelROCsStatusAndMapping
Definition: SiPixelROCsStatusAndMapping.h:14
sipixelobjects::PixelROC::idInDetUnit
unsigned int idInDetUnit() const
id of this ROC in DetUnit etermined by token path
Definition: PixelROC.h:37
SiPixelFedCablingMap::fedIds
std::vector< unsigned int > fedIds() const
Definition: SiPixelFedCablingMap.cc:114