CMS 3D CMS Logo

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

#include <SiPixelGainCalibrationForHLTGPU.h>

Classes

struct  GPUData
 

Public Member Functions

const SiPixelGainForHLTonGPUcpuProduct () const
 
const SiPixelGainForHLTonGPUgetGPUProductAsync (cudaStream_t cudaStream) const
 
const SiPixelGainCalibrationForHLToriginalProduct ()
 
 SiPixelGainCalibrationForHLTGPU (const SiPixelGainCalibrationForHLT &gains, const TrackerGeometry &geom)
 
 ~SiPixelGainCalibrationForHLTGPU ()
 

Private Attributes

SiPixelGainForHLTonGPUgainForHLTonHost_ = nullptr
 
const SiPixelGainCalibrationForHLTgains_ = nullptr
 
cms::cuda::ESProduct< GPUDatagpuData_
 

Detailed Description

Definition at line 12 of file SiPixelGainCalibrationForHLTGPU.h.

Constructor & Destructor Documentation

◆ SiPixelGainCalibrationForHLTGPU()

SiPixelGainCalibrationForHLTGPU::SiPixelGainCalibrationForHLTGPU ( const SiPixelGainCalibrationForHLT gains,
const TrackerGeometry geom 
)
explicit

Definition at line 11 of file SiPixelGainCalibrationForHLTGPU.cc.

13  : gains_(&gains) {
14  // bizzarre logic (looking for fist strip-det) don't ask
15  auto const& dus = geom.detUnits();
16  unsigned int n_detectors = dus.size();
17  for (unsigned int i = 1; i < 7; ++i) {
18  const auto offset = geom.offsetDU(GeomDetEnumerators::tkDetEnum[i]);
19  if (offset != dus.size() && dus[offset]->type().isTrackerStrip()) {
20  if (n_detectors > offset)
21  n_detectors = offset;
22  }
23  }
24 
25  LogDebug("SiPixelGainCalibrationForHLTGPU")
26  << "caching calibs for " << n_detectors << " pixel detectors of size " << gains.data().size() << '\n'
27  << "sizes " << sizeof(char) << ' ' << sizeof(uint8_t) << ' ' << sizeof(SiPixelGainForHLTonGPU::DecodingStructure);
28 
29  cudaCheck(cudaMallocHost((void**)&gainForHLTonHost_, sizeof(SiPixelGainForHLTonGPU)));
31  (SiPixelGainForHLTonGPU_DecodingStructure*)this->gains_->data().data(); // so it can be used on CPU as well...
32 
33  // do not read back from the (possibly write-combined) memory buffer
34  auto minPed = gains.getPedLow();
35  auto maxPed = gains.getPedHigh();
36  auto minGain = gains.getGainLow();
37  auto maxGain = gains.getGainHigh();
38  auto nBinsToUseForEncoding = 253;
39 
40  // we will simplify later (not everything is needed....)
41  gainForHLTonHost_->minPed_ = minPed;
42  gainForHLTonHost_->maxPed_ = maxPed;
43  gainForHLTonHost_->minGain_ = minGain;
44  gainForHLTonHost_->maxGain_ = maxGain;
45 
47  gainForHLTonHost_->nBinsToUseForEncoding_ = nBinsToUseForEncoding;
50 
51  gainForHLTonHost_->pedPrecision_ = static_cast<float>(maxPed - minPed) / nBinsToUseForEncoding;
52  gainForHLTonHost_->gainPrecision_ = static_cast<float>(maxGain - minGain) / nBinsToUseForEncoding;
53 
54  LogDebug("SiPixelGainCalibrationForHLTGPU")
55  << "precisions g " << gainForHLTonHost_->pedPrecision_ << ' ' << gainForHLTonHost_->gainPrecision_;
56 
57  // fill the index map
58  auto const& ind = gains.getIndexes();
59  LogDebug("SiPixelGainCalibrationForHLTGPU") << ind.size() << " " << n_detectors;
60 
61  for (auto i = 0U; i < n_detectors; ++i) {
62  auto p = std::lower_bound(
63  ind.begin(), ind.end(), dus[i]->geographicalId().rawId(), SiPixelGainCalibrationForHLT::StrictWeakOrdering());
64  assert(p != ind.end() && p->detid == dus[i]->geographicalId());
65  assert(p->iend <= gains.data().size());
66  assert(p->iend >= p->ibegin);
67  assert(0 == p->ibegin % 2);
68  assert(0 == p->iend % 2);
69  assert(p->ibegin != p->iend);
70  assert(p->ncols > 0);
71  gainForHLTonHost_->rangeAndCols_[i] = std::make_pair(SiPixelGainForHLTonGPU::Range(p->ibegin, p->iend), p->ncols);
72  if (ind[i].detid != dus[i]->geographicalId())
73  LogDebug("SiPixelGainCalibrationForHLTGPU") << ind[i].detid << "!=" << dus[i]->geographicalId();
74  }
75 }

References cms::cuda::assert(), cudaCheck, SiPixelGainCalibrationForHLT::data(), SiPixelGainForHLTonGPU::deadFlag_, gainForHLTonHost_, SiPixelGainForHLTonGPU::gainPrecision_, gains_, relativeConstraints::geom, SiPixelGainCalibrationForHLT::getGainHigh(), SiPixelGainCalibrationForHLT::getGainLow(), SiPixelGainCalibrationForHLT::getIndexes(), SiPixelGainCalibrationForHLT::getPedHigh(), SiPixelGainCalibrationForHLT::getPedLow(), mps_fire::i, LogDebug, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, SiPixelGainForHLTonGPU::maxGain_, SiPixelGainForHLTonGPU::maxPed_, SiPixelGainForHLTonGPU::minGain_, SiPixelGainForHLTonGPU::minPed_, SiPixelGainForHLTonGPU::nBinsToUseForEncoding_, SiPixelGainForHLTonGPU::noisyFlag_, SiPixelGainForHLTonGPU::numberOfRowsAveragedOver_, hltrates_dqm_sourceclient-live_cfg::offset, AlCaHLTBitMon_ParallelJobs::p, SiPixelGainForHLTonGPU::pedPrecision_, SiPixelGainForHLTonGPU::rangeAndCols_, GeomDetEnumerators::tkDetEnum, mitigatedMETSequence_cff::U, and SiPixelGainForHLTonGPU::v_pedestals_.

◆ ~SiPixelGainCalibrationForHLTGPU()

SiPixelGainCalibrationForHLTGPU::~SiPixelGainCalibrationForHLTGPU ( )

Definition at line 77 of file SiPixelGainCalibrationForHLTGPU.cc.

77 { cudaCheck(cudaFreeHost(gainForHLTonHost_)); }

References cudaCheck, and gainForHLTonHost_.

Member Function Documentation

◆ cpuProduct()

const SiPixelGainForHLTonGPU* SiPixelGainCalibrationForHLTGPU::cpuProduct ( ) const
inline

Definition at line 18 of file SiPixelGainCalibrationForHLTGPU.h.

18 { return gainForHLTonHost_; }

References gainForHLTonHost_.

◆ getGPUProductAsync()

const SiPixelGainForHLTonGPU * SiPixelGainCalibrationForHLTGPU::getGPUProductAsync ( cudaStream_t  cudaStream) const

Definition at line 84 of file SiPixelGainCalibrationForHLTGPU.cc.

84  {
85  const auto& data = gpuData_.dataForCurrentDeviceAsync(cudaStream, [this](GPUData& data, cudaStream_t stream) {
86  cudaCheck(cudaMalloc((void**)&data.gainForHLTonGPU, sizeof(SiPixelGainForHLTonGPU)));
87  cudaCheck(cudaMalloc((void**)&data.gainDataOnGPU, this->gains_->data().size()));
88  // gains.data().data() is used also for non-GPU code, we cannot allocate it on aligned and write-combined memory
89  cudaCheck(cudaMemcpyAsync(
90  data.gainDataOnGPU, this->gains_->data().data(), this->gains_->data().size(), cudaMemcpyDefault, stream));
91 
92  cudaCheck(cudaMemcpyAsync(
93  data.gainForHLTonGPU, this->gainForHLTonHost_, sizeof(SiPixelGainForHLTonGPU), cudaMemcpyDefault, stream));
94  cudaCheck(cudaMemcpyAsync(&(data.gainForHLTonGPU->v_pedestals_),
95  &(data.gainDataOnGPU),
97  cudaMemcpyDefault,
98  stream));
99  });
100  return data.gainForHLTonGPU;
101 }

References cudaCheck, SiPixelGainCalibrationForHLT::data(), data, gains_, gpuData_, and cms::cuda::stream.

◆ originalProduct()

const SiPixelGainCalibrationForHLT* SiPixelGainCalibrationForHLTGPU::originalProduct ( )
inline

Definition at line 19 of file SiPixelGainCalibrationForHLTGPU.h.

19 { return gains_; }

References gains_.

Member Data Documentation

◆ gainForHLTonHost_

SiPixelGainForHLTonGPU* SiPixelGainCalibrationForHLTGPU::gainForHLTonHost_ = nullptr
private

◆ gains_

const SiPixelGainCalibrationForHLT* SiPixelGainCalibrationForHLTGPU::gains_ = nullptr
private

◆ gpuData_

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

Definition at line 29 of file SiPixelGainCalibrationForHLTGPU.h.

Referenced by getGPUProductAsync().

SiPixelGainForHLTonGPU
Definition: SiPixelGainForHLTonGPU.h:28
mps_fire.i
i
Definition: mps_fire.py:428
SiPixelGainForHLTonGPU::numberOfRowsAveragedOver_
unsigned int numberOfRowsAveragedOver_
Definition: SiPixelGainForHLTonGPU.h:68
SiPixelGainCalibrationForHLT::getPedHigh
float getPedHigh() const
Definition: SiPixelGainCalibrationForHLT.h:72
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
cms::cuda::stream
cudaStream_t stream
Definition: HistoContainer.h:57
SiPixelGainCalibrationForHLT::getPedLow
float getPedLow() const
Definition: SiPixelGainCalibrationForHLT.h:71
cms::cuda::assert
assert(be >=bs)
SiPixelGainForHLTonGPU::maxPed_
float maxPed_
Definition: SiPixelGainForHLTonGPU.h:65
SiPixelGainForHLTonGPU::rangeAndCols_
std::pair< Range, int > rangeAndCols_[gpuClustering::maxNumModules]
Definition: SiPixelGainForHLTonGPU.h:63
SiPixelGainCalibrationForHLT::getGainHigh
float getGainHigh() const
Definition: SiPixelGainCalibrationForHLT.h:70
SiPixelGainForHLTonGPU::minPed_
float minPed_
Definition: SiPixelGainForHLTonGPU.h:65
SiPixelGainForHLTonGPU_DecodingStructure
Definition: SiPixelGainForHLTonGPU.h:22
GeomDetEnumerators::tkDetEnum
constexpr SubDetector tkDetEnum[8]
Definition: GeomDetEnumerators.h:37
SiPixelGainCalibrationForHLT::getGainLow
float getGainLow() const
Definition: SiPixelGainCalibrationForHLT.h:69
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
SiPixelGainCalibrationForHLTGPU::gainForHLTonHost_
SiPixelGainForHLTonGPU * gainForHLTonHost_
Definition: SiPixelGainCalibrationForHLTGPU.h:23
SiPixelGainForHLTonGPU::maxGain_
float maxGain_
Definition: SiPixelGainForHLTonGPU.h:65
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
SiPixelGainForHLTonGPU::nBinsToUseForEncoding_
unsigned int nBinsToUseForEncoding_
Definition: SiPixelGainForHLTonGPU.h:69
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:15
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
SiPixelGainForHLTonGPU::Range
std::pair< uint32_t, uint32_t > Range
Definition: SiPixelGainForHLTonGPU.h:32
SiPixelGainForHLTonGPU::noisyFlag_
unsigned int noisyFlag_
Definition: SiPixelGainForHLTonGPU.h:71
SiPixelGainForHLTonGPU::v_pedestals_
DecodingStructure * v_pedestals_
Definition: SiPixelGainForHLTonGPU.h:62
SiPixelGainForHLTonGPU::gainPrecision_
float gainPrecision_
Definition: SiPixelGainForHLTonGPU.h:66
SiPixelGainForHLTonGPU::pedPrecision_
float pedPrecision_
Definition: SiPixelGainForHLTonGPU.h:66
SiPixelGainForHLTonGPU::DecodingStructure
SiPixelGainForHLTonGPU_DecodingStructure DecodingStructure
Definition: SiPixelGainForHLTonGPU.h:30
SiPixelGainCalibrationForHLTGPU::gains_
const SiPixelGainCalibrationForHLT * gains_
Definition: SiPixelGainCalibrationForHLTGPU.h:22
SiPixelGainForHLTonGPU::minGain_
float minGain_
Definition: SiPixelGainForHLTonGPU.h:65
cudaCheck
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:62
SiPixelGainCalibrationForHLT::StrictWeakOrdering
Definition: SiPixelGainCalibrationForHLT.h:45
SiPixelGainForHLTonGPU::deadFlag_
unsigned int deadFlag_
Definition: SiPixelGainForHLTonGPU.h:70
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
SiPixelGainCalibrationForHLT::data
std::vector< char > const & data() const
Definition: SiPixelGainCalibrationForHLT.h:74
SiPixelGainCalibrationForHLT::getIndexes
std::vector< DetRegistry > const & getIndexes() const
Definition: SiPixelGainCalibrationForHLT.h:75
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
SiPixelGainCalibrationForHLTGPU::gpuData_
cms::cuda::ESProduct< GPUData > gpuData_
Definition: SiPixelGainCalibrationForHLTGPU.h:29