CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
< ModulesToUnpack
modToUnp_
 
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 ( SiPixelFedCablingMap const &  cablingMap,
TrackerGeometry const &  trackerGeom,
SiPixelQuality const *  badPixelInfo 
)

Definition at line 23 of file SiPixelROCsStatusAndMappingWrapper.cc.

References SiPixelROCsStatusAndMapping::badRocs, cablingMapHost, SiPixelFedCablingMap::cablingTree(), cudaCheck, SiPixelROCsStatusAndMapping::fed, 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, fed_dqm_sourceclient-live_cfg::path, SiPixelROCsStatusAndMapping::rawId, sipixelobjects::PixelROC::rawId(), SiPixelROCsStatusAndMapping::roc, PixelMapPlotter::roc, SiPixelROCsStatusAndMapping::rocInDet, and SiPixelROCsStatusAndMapping::size.

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 }
unsigned char badRocs[pixelgpudetails::MAX_SIZE]
unsigned int rawId[pixelgpudetails::MAX_SIZE]
unsigned int moduleId[pixelgpudetails::MAX_SIZE]
unsigned int roc[pixelgpudetails::MAX_SIZE]
unsigned int rocInDet[pixelgpudetails::MAX_SIZE]
unsigned int idInDetUnit() const
id of this ROC in DetUnit etermined by token path
Definition: PixelROC.h:37
uint32_t rawId() const
return the DetUnit to which this ROC belongs to.
Definition: PixelROC.h:34
constexpr unsigned int MAX_ROC
constexpr uint16_t invalidModuleId
unsigned int link[pixelgpudetails::MAX_SIZE]
std::vector< unsigned char, cms::cuda::HostAllocator< unsigned char > > modToUnpDefault
constexpr unsigned int MAX_SIZE
unsigned int fed[pixelgpudetails::MAX_SIZE]
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69
constexpr unsigned int MAX_LINK
#define LogDebug(id)
SiPixelROCsStatusAndMappingWrapper::~SiPixelROCsStatusAndMappingWrapper ( )

Definition at line 104 of file SiPixelROCsStatusAndMappingWrapper.cc.

References cablingMapHost, and cudaCheck.

104 { cudaCheck(cudaFreeHost(cablingMapHost)); }
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69

Member Function Documentation

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

Definition at line 106 of file SiPixelROCsStatusAndMappingWrapper.cc.

References SiPixelROCsStatusAndMappingWrapper::GPUData::cablingMapDevice, cudaCheck, data, gpuData_, and cms::cuda::stream.

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 }
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69
const unsigned char * SiPixelROCsStatusAndMappingWrapper::getModToUnpAllAsync ( cudaStream_t  cudaStream) const

Definition at line 119 of file SiPixelROCsStatusAndMappingWrapper.cc.

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

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 }
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
cms::cuda::ESProduct< ModulesToUnpack > modToUnp_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
std::vector< unsigned char, cms::cuda::HostAllocator< unsigned char > > modToUnpDefault
constexpr unsigned int MAX_SIZE_BYTE_BOOL
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69
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.

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

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 }
uint32_t rawId() const
return the DetUnit to which this ROC belongs to.
Definition: PixelROC.h:34
constexpr unsigned int MAX_ROC
std::unique_ptr< SiPixelFedCablingTree > cablingTree() const
constexpr unsigned int MAX_SIZE
std::vector< unsigned int > fedIds() const
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69
constexpr unsigned int MAX_LINK
bool SiPixelROCsStatusAndMappingWrapper::hasQuality ( ) const
inline

Member Data Documentation

const SiPixelFedCablingMap* SiPixelROCsStatusAndMappingWrapper::cablingMap_
private

Definition at line 35 of file SiPixelROCsStatusAndMappingWrapper.h.

Referenced by getModToUnpRegionalAsync().

SiPixelROCsStatusAndMapping* SiPixelROCsStatusAndMappingWrapper::cablingMapHost = nullptr
private
cms::cuda::ESProduct<GPUData> SiPixelROCsStatusAndMappingWrapper::gpuData_
private

Definition at line 46 of file SiPixelROCsStatusAndMappingWrapper.h.

Referenced by getGPUProductAsync().

bool SiPixelROCsStatusAndMappingWrapper::hasQuality_
private

Definition at line 38 of file SiPixelROCsStatusAndMappingWrapper.h.

Referenced by hasQuality().

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

Definition at line 52 of file SiPixelROCsStatusAndMappingWrapper.h.

Referenced by getModToUnpAllAsync().

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