forked from cms-sw/cmssw
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
197 changed files
with
77,066 additions
and
499 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
CalibTracker/Records/interface/SiPixelGainCalibrationForHLTGPURcd.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef CalibTracker_Records_SiPixelGainCalibrationForHLTGPURcd_h | ||
#define CalibTracker_Records_SiPixelGainCalibrationForHLTGPURcd_h | ||
|
||
#include "FWCore/Framework/interface/EventSetupRecordImplementation.h" | ||
#include "FWCore/Framework/interface/DependentRecordImplementation.h" | ||
|
||
#include "CondFormats/DataRecord/interface/SiPixelGainCalibrationForHLTRcd.h" | ||
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" | ||
|
||
#include "boost/mpl/vector.hpp" | ||
|
||
class SiPixelGainCalibrationForHLTGPURcd : public edm::eventsetup::DependentRecordImplementation<SiPixelGainCalibrationForHLTGPURcd, boost::mpl::vector<SiPixelGainCalibrationForHLTRcd, TrackerDigiGeometryRecord> > {}; | ||
|
||
#endif |
5 changes: 5 additions & 0 deletions
5
CalibTracker/Records/src/SiPixelGainCalibrationForHLTGPURcd.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "CalibTracker/Records/interface/SiPixelGainCalibrationForHLTGPURcd.h" | ||
#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" | ||
#include "FWCore/Utilities/interface/typelookup.h" | ||
|
||
EVENTSETUP_RECORD_REG(SiPixelGainCalibrationForHLTGPURcd); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
CalibTracker/SiPixelESProducers/interface/SiPixelGainCalibrationForHLTGPU.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#ifndef CalibTracker_SiPixelESProducers_SiPixelGainCalibrationForHLTGPU_H | ||
#define CalibTracker_SiPixelESProducers_SiPixelGainCalibrationForHLTGPU_H | ||
|
||
#include "HeterogeneousCore/CUDACore/interface/CUDAESProduct.h" | ||
#include "CondFormats/SiPixelObjects/interface/SiPixelGainCalibrationForHLT.h" | ||
|
||
#include <cuda/api_wrappers.h> | ||
|
||
class SiPixelGainCalibrationForHLT; | ||
class SiPixelGainForHLTonGPU; | ||
struct SiPixelGainForHLTonGPU_DecodingStructure; | ||
class TrackerGeometry; | ||
|
||
class SiPixelGainCalibrationForHLTGPU { | ||
public: | ||
explicit SiPixelGainCalibrationForHLTGPU(const SiPixelGainCalibrationForHLT& gains, const TrackerGeometry& geom); | ||
~SiPixelGainCalibrationForHLTGPU(); | ||
|
||
const SiPixelGainForHLTonGPU *getGPUProductAsync(cuda::stream_t<>& cudaStream) const; | ||
|
||
private: | ||
const SiPixelGainCalibrationForHLT *gains_ = nullptr; | ||
SiPixelGainForHLTonGPU *gainForHLTonHost_ = nullptr; | ||
struct GPUData { | ||
~GPUData(); | ||
SiPixelGainForHLTonGPU *gainForHLTonGPU = nullptr; | ||
SiPixelGainForHLTonGPU_DecodingStructure *gainDataOnGPU = nullptr; | ||
}; | ||
CUDAESProduct<GPUData> gpuData_; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
CalibTracker/SiPixelESProducers/plugins/SiPixelGainCalibrationForHLTGPUESProducer.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "CalibTracker/SiPixelESProducers/interface/SiPixelGainCalibrationForHLTGPU.h" | ||
#include "CalibTracker/Records/interface/SiPixelGainCalibrationForHLTGPURcd.h" | ||
#include "CondFormats/SiPixelObjects/interface/SiPixelGainCalibrationForHLT.h" | ||
#include "CondFormats/DataRecord/interface/SiPixelGainCalibrationForHLTRcd.h" | ||
#include "FWCore/Framework/interface/ESProducer.h" | ||
#include "FWCore/Framework/interface/EventSetup.h" | ||
#include "FWCore/Framework/interface/ESHandle.h" | ||
#include "FWCore/Framework/interface/ModuleFactory.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" | ||
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" | ||
|
||
#include <memory> | ||
|
||
class SiPixelGainCalibrationForHLTGPUESProducer: public edm::ESProducer { | ||
public: | ||
explicit SiPixelGainCalibrationForHLTGPUESProducer(const edm::ParameterSet& iConfig); | ||
std::unique_ptr<SiPixelGainCalibrationForHLTGPU> produce(const SiPixelGainCalibrationForHLTGPURcd& iRecord); | ||
|
||
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); | ||
private: | ||
}; | ||
|
||
SiPixelGainCalibrationForHLTGPUESProducer::SiPixelGainCalibrationForHLTGPUESProducer(const edm::ParameterSet& iConfig) { | ||
setWhatProduced(this); | ||
} | ||
|
||
void SiPixelGainCalibrationForHLTGPUESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { | ||
edm::ParameterSetDescription desc; | ||
descriptions.add("siPixelGainCalibrationForHLTGPU", desc); | ||
} | ||
|
||
std::unique_ptr<SiPixelGainCalibrationForHLTGPU> SiPixelGainCalibrationForHLTGPUESProducer::produce(const SiPixelGainCalibrationForHLTGPURcd& iRecord) { | ||
edm::ESHandle<SiPixelGainCalibrationForHLT> gains; | ||
iRecord.getRecord<SiPixelGainCalibrationForHLTRcd>().get(gains); | ||
|
||
edm::ESHandle<TrackerGeometry> geom; | ||
iRecord.getRecord<TrackerDigiGeometryRecord>().get(geom); | ||
|
||
return std::make_unique<SiPixelGainCalibrationForHLTGPU>(*gains, *geom); | ||
} | ||
|
||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
#include "FWCore/Utilities/interface/typelookup.h" | ||
#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" | ||
|
||
DEFINE_FWK_EVENTSETUP_MODULE(SiPixelGainCalibrationForHLTGPUESProducer); |
4 changes: 4 additions & 0 deletions
4
CalibTracker/SiPixelESProducers/src/ES_SiPixelGainCalibrationForHLTGPU.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#include "CalibTracker/SiPixelESProducers/interface/SiPixelGainCalibrationForHLTGPU.h" | ||
#include "FWCore/Utilities/interface/typelookup.h" | ||
|
||
TYPELOOKUP_DATA_REG(SiPixelGainCalibrationForHLTGPU); |
98 changes: 98 additions & 0 deletions
98
CalibTracker/SiPixelESProducers/src/SiPixelGainCalibrationForHLTGPU.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#include "CalibTracker/SiPixelESProducers/interface/SiPixelGainCalibrationForHLTGPU.h" | ||
#include "CondFormats/SiPixelObjects/interface/SiPixelGainCalibrationForHLT.h" | ||
#include "CondFormats/SiPixelObjects/interface/SiPixelGainForHLTonGPU.h" | ||
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" | ||
#include "Geometry/CommonDetUnit/interface/GeomDetType.h" | ||
#include "HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h" | ||
|
||
#include <cuda.h> | ||
|
||
SiPixelGainCalibrationForHLTGPU::SiPixelGainCalibrationForHLTGPU(const SiPixelGainCalibrationForHLT& gains, const TrackerGeometry& geom): | ||
gains_(&gains) | ||
{ | ||
// bizzarre logic (looking for fist strip-det) don't ask | ||
auto const & dus = geom.detUnits(); | ||
unsigned m_detectors = dus.size(); | ||
for(unsigned int i=1;i<7;++i) { | ||
if(geom.offsetDU(GeomDetEnumerators::tkDetEnum[i]) != dus.size() && | ||
dus[geom.offsetDU(GeomDetEnumerators::tkDetEnum[i])]->type().isTrackerStrip()) { | ||
if(geom.offsetDU(GeomDetEnumerators::tkDetEnum[i]) < m_detectors) m_detectors = geom.offsetDU(GeomDetEnumerators::tkDetEnum[i]); | ||
} | ||
} | ||
|
||
/* | ||
std::cout << "caching calibs for " << m_detectors << " pixel detectors of size " << gains.data().size() << std::endl; | ||
std::cout << "sizes " << sizeof(char) << ' ' << sizeof(uint8_t) << ' ' << sizeof(SiPixelGainForHLTonGPU::DecodingStructure) << std::endl; | ||
*/ | ||
|
||
cudaCheck(cudaMallocHost((void**) & gainForHLTonHost_, sizeof(SiPixelGainForHLTonGPU))); | ||
//gainForHLTonHost_->v_pedestals = gainDataOnGPU_; // how to do this? | ||
|
||
// do not read back from the (possibly write-combined) memory buffer | ||
auto minPed = gains.getPedLow(); | ||
auto maxPed = gains.getPedHigh(); | ||
auto minGain = gains.getGainLow(); | ||
auto maxGain = gains.getGainHigh(); | ||
auto nBinsToUseForEncoding = 253; | ||
|
||
// we will simplify later (not everything is needed....) | ||
gainForHLTonHost_->minPed_ = minPed; | ||
gainForHLTonHost_->maxPed_ = maxPed; | ||
gainForHLTonHost_->minGain_= minGain; | ||
gainForHLTonHost_->maxGain_= maxGain; | ||
|
||
gainForHLTonHost_->numberOfRowsAveragedOver_ = 80; | ||
gainForHLTonHost_->nBinsToUseForEncoding_ = nBinsToUseForEncoding; | ||
gainForHLTonHost_->deadFlag_ = 255; | ||
gainForHLTonHost_->noisyFlag_ = 254; | ||
|
||
gainForHLTonHost_->pedPrecision = static_cast<float>(maxPed - minPed) / nBinsToUseForEncoding; | ||
gainForHLTonHost_->gainPrecision = static_cast<float>(maxGain - minGain) / nBinsToUseForEncoding; | ||
|
||
/* | ||
std::cout << "precisions g " << gainForHLTonHost_->pedPrecision << ' ' << gainForHLTonHost_->gainPrecision << std::endl; | ||
*/ | ||
|
||
// fill the index map | ||
auto const & ind = gains.getIndexes(); | ||
/* | ||
std::cout << ind.size() << " " << m_detectors << std::endl; | ||
*/ | ||
|
||
for (auto i=0U; i<m_detectors; ++i) { | ||
auto p = std::lower_bound(ind.begin(),ind.end(),dus[i]->geographicalId().rawId(),SiPixelGainCalibrationForHLT::StrictWeakOrdering()); | ||
assert (p!=ind.end() && p->detid==dus[i]->geographicalId()); | ||
assert(p->iend<=gains.data().size()); | ||
assert(p->iend>=p->ibegin); | ||
assert(0==p->ibegin%2); | ||
assert(0==p->iend%2); | ||
assert(p->ibegin!=p->iend); | ||
assert(p->ncols>0); | ||
gainForHLTonHost_->rangeAndCols[i] = std::make_pair(SiPixelGainForHLTonGPU::Range(p->ibegin,p->iend), p->ncols); | ||
// if (ind[i].detid!=dus[i]->geographicalId()) std::cout << ind[i].detid<<"!="<<dus[i]->geographicalId() << std::endl; | ||
// gainForHLTonHost_->rangeAndCols[i] = std::make_pair(SiPixelGainForHLTonGPU::Range(ind[i].ibegin,ind[i].iend), ind[i].ncols); | ||
} | ||
|
||
} | ||
|
||
SiPixelGainCalibrationForHLTGPU::~SiPixelGainCalibrationForHLTGPU() { | ||
cudaCheck(cudaFreeHost(gainForHLTonHost_)); | ||
} | ||
|
||
SiPixelGainCalibrationForHLTGPU::GPUData::~GPUData() { | ||
cudaCheck(cudaFree(gainForHLTonGPU)); | ||
cudaCheck(cudaFree(gainDataOnGPU)); | ||
} | ||
|
||
const SiPixelGainForHLTonGPU *SiPixelGainCalibrationForHLTGPU::getGPUProductAsync(cuda::stream_t<>& cudaStream) const { | ||
const auto& data = gpuData_.dataForCurrentDeviceAsync(cudaStream, [this](GPUData& data, cuda::stream_t<>& stream) { | ||
cudaCheck(cudaMalloc((void**) & data.gainForHLTonGPU, sizeof(SiPixelGainForHLTonGPU))); | ||
cudaCheck(cudaMalloc((void**) & data.gainDataOnGPU, this->gains_->data().size())); // TODO: this could be changed to cuda::memory::device::unique_ptr<> | ||
// gains.data().data() is used also for non-GPU code, we cannot allocate it on aligned and write-combined memory | ||
cudaCheck(cudaMemcpyAsync(data.gainDataOnGPU, this->gains_->data().data(), this->gains_->data().size(), cudaMemcpyDefault, stream.id())); | ||
|
||
cudaCheck(cudaMemcpyAsync(data.gainForHLTonGPU, this->gainForHLTonHost_, sizeof(SiPixelGainForHLTonGPU), cudaMemcpyDefault, stream.id())); | ||
cudaCheck(cudaMemcpyAsync(&(data.gainForHLTonGPU->v_pedestals), &(data.gainDataOnGPU), sizeof(SiPixelGainForHLTonGPU_DecodingStructure*), cudaMemcpyDefault, stream.id())); | ||
}); | ||
return data.gainForHLTonGPU; | ||
} |
73 changes: 73 additions & 0 deletions
73
CondFormats/SiPixelObjects/interface/SiPixelGainForHLTonGPU.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#ifndef CondFormats_SiPixelObjects_SiPixelGainForHLTonGPU_h | ||
#define CondFormats_SiPixelObjects_SiPixelGainForHLTonGPU_h | ||
|
||
#include <cstdint> | ||
#include <cstdio> | ||
#include <tuple> | ||
|
||
#include "HeterogeneousCore/CUDAUtilities/interface/cuda_assert.h" | ||
|
||
struct SiPixelGainForHLTonGPU_DecodingStructure{ | ||
uint8_t gain; | ||
uint8_t ped; | ||
}; | ||
|
||
|
||
// copy of SiPixelGainCalibrationForHLT | ||
class SiPixelGainForHLTonGPU { | ||
|
||
public: | ||
|
||
using DecodingStructure = SiPixelGainForHLTonGPU_DecodingStructure; | ||
|
||
using Range = std::pair<uint32_t,uint32_t>; | ||
|
||
|
||
inline __host__ __device__ | ||
std::pair<float,float> getPedAndGain(uint32_t moduleInd, int col, int row, bool& isDeadColumn, bool& isNoisyColumn ) const { | ||
|
||
|
||
auto range = rangeAndCols[moduleInd].first; | ||
auto nCols = rangeAndCols[moduleInd].second; | ||
|
||
// determine what averaged data block we are in (there should be 1 or 2 of these depending on if plaquette is 1 by X or 2 by X | ||
unsigned int lengthOfColumnData = (range.second-range.first)/nCols; | ||
unsigned int lengthOfAveragedDataInEachColumn = 2; // we always only have two values per column averaged block | ||
unsigned int numberOfDataBlocksToSkip = row / numberOfRowsAveragedOver_; | ||
|
||
|
||
auto offset = range.first + col*lengthOfColumnData + lengthOfAveragedDataInEachColumn*numberOfDataBlocksToSkip; | ||
|
||
assert(offset<range.second); | ||
assert(offset<3088384); | ||
assert(0==offset%2); | ||
|
||
DecodingStructure const * __restrict__ lp = v_pedestals; | ||
auto s = lp[offset/2]; | ||
|
||
isDeadColumn = (s.ped & 0xFF) == deadFlag_; | ||
isNoisyColumn = (s.ped & 0xFF) == noisyFlag_; | ||
|
||
return std::make_pair(decodePed(s.ped & 0xFF),decodeGain(s.gain & 0xFF)); | ||
|
||
} | ||
|
||
|
||
|
||
constexpr float decodeGain(unsigned int gain) const {return gain*gainPrecision + minGain_;} | ||
constexpr float decodePed (unsigned int ped) const { return ped*pedPrecision + minPed_;} | ||
|
||
DecodingStructure * v_pedestals; | ||
std::pair<Range, int> rangeAndCols[2000]; | ||
|
||
float minPed_, maxPed_, minGain_, maxGain_; | ||
|
||
float pedPrecision, gainPrecision; | ||
|
||
unsigned int numberOfRowsAveragedOver_; // this is 80!!!! | ||
unsigned int nBinsToUseForEncoding_; | ||
unsigned int deadFlag_; | ||
unsigned int noisyFlag_; | ||
}; | ||
|
||
#endif // CondFormats_SiPixelObjects_SiPixelGainForHLTonGPU_h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
# This modifier is for replacing CPU modules with GPU counterparts | ||
|
||
gpu = cms.Modifier() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
# This modifier is for replacing the default pixel track "fitting" with Riemann fit on GPU | ||
|
||
riemannFitGPU = cms.Modifier() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
# This modifier is for replacing the default pixel track "fitting" with Riemann fit | ||
|
||
riemannFit = cms.Modifier() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.