Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CUDA Vector for easier pushback #7

Closed
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
af2b739
Implementation of the pixel raw to digi algorithm in CUDA
sushildubey171 Nov 15, 2017
a977e5e
Cleanup the CUDA code, and recover the CPU code
fwyzard Nov 16, 2017
c5b6b01
Better integration in CMSSW, validation, cleanup and fixes
Nov 26, 2017
ed49833
Make class for reading GPU friendly cabling map
sushildubey171 Dec 1, 2017
cb386db
Direct access to cabling map for GPU RawToDigi
sushildubey171 Dec 1, 2017
8a9dd11
Unpack errors, bad ROCs, improve validation, fixes and cleanup
Dec 7, 2017
410b81e
Clean up and debug
fwyzard Jan 22, 2018
fa32bfc
Set CUDA optimization flags
felicepantaleo Jan 24, 2018
45ded38
Some optimizations around the CUDA kernel
felicepantaleo Jan 24, 2018
7e90b13
Backport, Modify FileInPath to not lookup file in edmWriteConfigs
wddgit Jan 25, 2018
1de5e70
Merge pull request #21967 from wddgit/backportModificationToFileInPath
cmsbuild Jan 26, 2018
28c19cf
thread safe histo
civanch Jan 28, 2018
3ea71bf
restoring egamma sequence for allForPrompt dqm sequence
fabozzi Jan 29, 2018
793e836
adding egamma also for harvesting
fabozzi Jan 30, 2018
19968d3
Merge pull request #22012 from fabozzi/from-CMSSW_10_0_X_rerecodqm
cmsbuild Jan 31, 2018
e0189dc
Merge pull request #22011 from ggovi/condcore-utilities-tools-fix4-100X
cmsbuild Jan 31, 2018
9a3f731
Merge pull request #21996 from Dr15Jones/fixPVFitter
cmsbuild Feb 1, 2018
7ad3807
Merge pull request #22004 from civanch/thread_safe_histo_pileup
cmsbuild Feb 1, 2018
e925ce4
Merge pull request #21944 from rappoccio/patjet_groomedmass_10x
cmsbuild Feb 1, 2018
fe05df7
Merge pull request #21953 from arizzi/fixeMerge100X
cmsbuild Feb 1, 2018
30eb550
Merge pull request #22038 from cms-nanoAOD/master100Xbase
cmsbuild Feb 1, 2018
054b279
Compare cone volumes up to 11th digit of fp
mrodozov Jan 19, 2018
f870206
Backport in 10_0_X of fix for Cons test (PR 21898)
fabiocos Feb 2, 2018
e28052a
Merge pull request #22084 from fabiocos/fc-fixGeoTest100X
cmsbuild Feb 2, 2018
b41495c
Various improvements to pixel-related modules
VinInn Jan 29, 2018
9915a9f
Various fixes to GPU implementation o the pixel unpacker
fwyzard Feb 2, 2018
86b1945
Further fixes to the unpacking, and some clean up
Feb 1, 2018
c7a7292
Merge branch CMSSW_10_0_X_Patatrack with CMSSW_10_0_1
fwyzard Feb 4, 2018
149d115
adding gpu vector
felicepantaleo Feb 9, 2018
84a8076
adding test for GPUSimpleVector
felicepantaleo Feb 9, 2018
10fe141
making [] and at const
felicepantaleo Feb 9, 2018
f03818b
renaming header file to .h
felicepantaleo Feb 15, 2018
bb2963a
replace maxSize with m_capacity
felicepantaleo Feb 15, 2018
7246ee6
added requested features
felicepantaleo Feb 15, 2018
6e97c1b
compile test file
felicepantaleo Feb 15, 2018
34fdec4
test file
felicepantaleo Feb 15, 2018
883468d
operator[] and back() return refs
felicepantaleo Feb 15, 2018
8c3bc58
removing unused variable
felicepantaleo Feb 15, 2018
ab6ebf0
new file structure
felicepantaleo Feb 15, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ float SiPixelGainCalibrationOffline::getGain(const int& col, const int& row, con
int maxRow = lengthOfColumnData - (lengthOfColumnData % numberOfRowsToAverageOver_) - 1;
if (col >= nCols || row > maxRow){
throw cms::Exception("CorruptedData")
<< "[SiPixelGainCalibrationOffline::getPed] Pixel out of range: col " << col;
<< "[SiPixelGainCalibrationOffline::getPed] Pixel out of range: col " << col << " row " << row;
}
return decodeGain(s.datum & 0xFF);
}
Expand Down
3 changes: 2 additions & 1 deletion Configuration/DataProcessing/python/Merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from FWCore.ParameterSet.Config import Process, EndPath
from FWCore.ParameterSet.Modules import OutputModule, Source, Service
from Configuration.EventContent.EventContent_cff import NANOAODEventContent
import FWCore.ParameterSet.Types as CfgTypes


Expand Down Expand Up @@ -64,7 +65,7 @@ def mergeProcess(*inputFiles, **options):
if newDQMIO:
outMod = OutputModule("DQMRootOutputModule")
elif mergeNANO:
outMod = OutputModule("NanoAODOutputModule")
outMod = OutputModule("NanoAODOutputModule",NANOAODEventContent.clone())
else:
outMod = OutputModule("PoolOutputModule")

Expand Down
4 changes: 2 additions & 2 deletions DQMOffline/Configuration/python/autoDQM.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
'express': ['@commonSiStripZeroBias+@muon+@hcal+@jetmet+@ecal',
'PostDQMOffline',
'@commonSiStripZeroBias+@muon+@hcal+@jetmet+@ecal'],
'allForPrompt': ['@common+@muon+@hcal+@jetmet+@ecal',
'allForPrompt': ['@common+@muon+@hcal+@jetmet+@ecal+@egamma',
'PostDQMOffline',
'@common+@muon+@hcal+@jetmet+@ecal'],
'@common+@muon+@hcal+@jetmet+@ecal+@egamma'],
'miniAODDQM': ['DQMOfflineMiniAOD',
'PostDQMOfflineMiniAOD',
'DQMHarvestMiniAOD'],
Expand Down
26 changes: 22 additions & 4 deletions DataFormats/PatCandidates/interface/Jet.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
#include "DataFormats/Common/interface/OwnVector.h"
#include "DataFormats/Common/interface/AtomicPtrCache.h"

#include <numeric>


// Define typedefs for convenience
namespace pat {
Expand Down Expand Up @@ -498,21 +500,37 @@ namespace pat {


/// String access to subjet list
pat::JetPtrCollection const & subjets( std::string label ) const ;
pat::JetPtrCollection const & subjets( std::string const & label ) const ;

/// Add new set of subjets
void addSubjets( pat::JetPtrCollection const & pieces, std::string label = "" );
void addSubjets( pat::JetPtrCollection const & pieces, std::string const & label = "" );

/// Check to see if the subjet collection exists
bool hasSubjets( std::string label ) const { return find( subjetLabels_.begin(), subjetLabels_.end(), label) != subjetLabels_.end(); }
bool hasSubjets( std::string const & label ) const { return find( subjetLabels_.begin(), subjetLabels_.end(), label) != subjetLabels_.end(); }

/// Number of subjet collections
unsigned int nSubjetCollections( ) const { return subjetCollections_.size(); }

/// Subjet collection names
std::vector<std::string> const & subjetCollectionNames() const { return subjetLabels_; }


/// Access to mass of subjets
double groomedMass(unsigned int index = 0) const{
auto const& sub = subjets(index);
return nSubjetCollections() > index && !sub.empty() ?
std::accumulate( sub.begin(), sub.end(),
reco::Candidate::LorentzVector(),
[] (reco::Candidate::LorentzVector const & a, reco::CandidatePtr const & b){return a + b->p4();}).mass() :
-1.0;
}
double groomedMass(std::string const & label) const{
auto const& sub = subjets(label);
return hasSubjets(label) && !sub.empty() ?
std::accumulate( sub.begin(), sub.end(),
reco::Candidate::LorentzVector(),
[] (reco::Candidate::LorentzVector const & a, reco::CandidatePtr const & b){return a + b->p4();}).mass() :
-1.0;
}

protected:

Expand Down
4 changes: 2 additions & 2 deletions DataFormats/PatCandidates/src/Jet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ pat::JetPtrCollection const & Jet::subjets( unsigned int index) const {


/// String access to subjet list
pat::JetPtrCollection const & Jet::subjets( std::string label ) const {
pat::JetPtrCollection const & Jet::subjets( std::string const & label ) const {
auto found = find( subjetLabels_.begin(), subjetLabels_.end(), label );
if ( found != subjetLabels_.end() ){
auto index = std::distance( subjetLabels_.begin(), found );
Expand All @@ -611,7 +611,7 @@ pat::JetPtrCollection const & Jet::subjets( std::string label ) const {
}

/// Add new set of subjets
void Jet::addSubjets( pat::JetPtrCollection const & pieces, std::string label ) {
void Jet::addSubjets( pat::JetPtrCollection const & pieces, std::string const & label ) {
subjetCollections_.push_back( pieces );
subjetLabels_.push_back( label );
}
2 changes: 1 addition & 1 deletion DataFormats/SiPixelDigi/interface/PixelDigi.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PixelDigi {
typedef unsigned int PackedDigiType;
typedef unsigned int ChannelType;

PixelDigi( int packed_value) : theData(packed_value) {}
explicit PixelDigi(PackedDigiType packed_value) : theData(packed_value) {}

PixelDigi( int row, int col, int adc) {
init( row, col, adc);
Expand Down
72 changes: 72 additions & 0 deletions EventFilter/SiPixelRawToDigi/interface/GPUSimpleVector.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// author: Felice Pantaleo, CERN, 2018
#ifndef GPU_SIMPLEVECTOR_HPP_
#define GPU_SIMPLEVECTOR_HPP_
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use the CMS-standard extension .h? I guess eventually this file will be moved to some "CUDA utilities" package?


namespace GPU {
template <class T> struct SimpleVector {
// Constructors
__host__ __device__ SimpleVector(unsigned int maxSize, T *m_data = nullptr)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why nullptr is allowed (and even default)? From the code it looks to me that any proper use of the class requires passing the pointer to user-allocated memory to the constructor.

Consider adding a comment that the ownership of m_data stays within the caller.

: m_size(0), m_data(m_data), maxSize(static_cast<int>(maxSize)) {}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why take unsigned int parameter and cast it directly to int?


__host__ __device__ SimpleVector() : SimpleVector(0) {}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add emplace_back() ?

__inline__ __host__ __device__ int push_back(const T &element) {

auto previousSize = m_size;
m_size++;
if (previousSize < maxSize) {
m_data[previousSize] = element;
return previousSize;
} else {
--m_size;
return -1;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More general question on the caller-side error handling (not necessary to cover fully here). I guess it is up to the caller to check the return value, and act accordingly if it gets -1 (possibly propagating to the host to throw an exception).

}
}

#if defined(__NVCC__) || defined(__CUDACC__)
__device__ int push_back_ts(const T &element) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, what does the _ts stand for?

auto previousSize = atomicAdd(&m_size, 1);
if (previousSize < maxSize) {
m_data[previousSize] = element;
return previousSize;
} else {
atomicSub(&m_size, 1);
return -1;
}
}
#endif

__inline__ __host__ __device__ T pop_back() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if we're not dealing with exceptions here, could we use the same interface as std::vector for consistency (i.e. back() for the value and pop_back() to reduce the size)?

if (m_size > 0) {
auto previousSize = m_size--;
return m_data[previousSize - 1];
} else
return T();
}

__inline__ __host__ __device__ T operator[](int i) { return m_data[i]; }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should return a T&, to allow something like simplevector[i] = 42;


__inline__ __host__ __device__ T at(int i) {
if (i < m_size)
return m_data[i];
else
return T();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really want to silently return a default-constructed object ?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the added benefit of at()? Isn't default-constructed T a valid value? If yes, there is no way to check that an error actually happened.

}

__inline__ __host__ __device__ void reset() { m_size = 0; }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this, in principle at least, call the destructors of all contained objects? Or is T assumed to be simple-enough that this doesn't matter (in which case please add a comment)?


__inline__ __host__ __device__ int size() const { return m_size; }

__inline__ __host__ __device__ int capacity() const { return maxSize; }


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a data() method ?


private:
int m_size;
int maxSize;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use m_capacity or m_max_size ?


T *m_data;
};
} // namespace GPU

#endif
7 changes: 6 additions & 1 deletion EventFilter/SiPixelRawToDigi/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<use name="EventFilter/SiPixelRawToDigi"/>
<library file="*.cc" name="EventFilterSiPixelRawToDigiPlugins">
<library file="SiPixelDigiToRaw.cc SiPixelRawToDigi.cc SealModule.cc" name="EventFilterSiPixelRawToDigiPlugins">
<flags EDM_PLUGIN="1"/>
</library>
<library file="SiPixelRawToDigiGPU.cc SiPixelFedCablingMapGPU.cc RawToDigiGPU.cu" name="EventFilterSiPixelRawToDigiGPUPlugins">
<use name="cuda"/>
<flags EDM_PLUGIN="1"/>
<flags CUDA_FLAGS="-O2 --expt-relaxed-constexpr"/>
</library>
39 changes: 39 additions & 0 deletions EventFilter/SiPixelRawToDigi/plugins/DetParamBits.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Sushil Dubey, Shashi Dugad, TIFR
#ifndef DETPARAMBITS_H
#define DETPARAMBITS_H
typedef unsigned int uint;
//reference
//http://cmsdoxygen.web.cern.ch/cmsdoxygen/CMSSW_9_2_0/doc/html/d3/db2/PixelROC_8cc_source.html#l00197
const uint layerStartBit_ = 20;
const uint ladderStartBit_ = 12;
const uint moduleStartBit_ = 2;

const uint panelStartBit_ = 10;
const uint diskStartBit_ = 18;
const uint bladeStartBit_ = 12;

const uint layerMask_ = 0xF;
const uint ladderMask_ = 0xFF;
const uint moduleMask_ = 0x3FF;
const uint panelMask_ = 0x3;
const uint diskMask_ = 0xF;
const uint bladeMask_ = 0x3F;

// __host__ __device__ bool isBarrel(uint rawId) {
// return (1==((rawId>>25)&0x7));
// }

__host__ __device__ int getLayer(uint rawId) {
int layer = (rawId >> layerStartBit_) & layerMask_;
return layer;
}

__host__ __device__ int getDisk(uint rawId) {
// int side =1;
// unsigned int panel = ((rawId>>panelStartBit_) & panelMask_);
// if(panel==1) side = -1;
unsigned int disk = int((rawId>>diskStartBit_) & diskMask_);
// return disk*side;
return disk;
}
#endif
11 changes: 11 additions & 0 deletions EventFilter/SiPixelRawToDigi/plugins/EventInfoGPU.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*Sushil Dubey, Shashi Dugad, TIFR
*/

#ifndef EVENTINFO_GPU
#define EVENTINFO_GPU

const int NEVENT = 1 ; //optimal number of events to run simultaneously,
// using 4 cuda stream, hence it should be multiple of 4
const int NMODULE = 1856; // for phase 1, we have 1856 modules

#endif
Loading