-
Notifications
You must be signed in to change notification settings - Fork 5
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
Changes from 47 commits
af2b739
a977e5e
c5b6b01
ed49833
cb386db
8a9dd11
410b81e
fa32bfc
45ded38
7e90b13
1de5e70
28c19cf
3ea71bf
793e836
19968d3
e0189dc
9a3f731
7ad3807
e925ce4
fe05df7
30eb550
054b279
f870206
e28052a
b41495c
9915a9f
86b1945
c7a7292
149d115
84a8076
10fe141
f03818b
bb2963a
7246ee6
6e97c1b
34fdec4
883468d
8c3bc58
ab6ebf0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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_ | ||
|
||
namespace GPU { | ||
template <class T> struct SimpleVector { | ||
// Constructors | ||
__host__ __device__ SimpleVector(unsigned int maxSize, T *m_data = nullptr) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why Consider adding a comment that the ownership of |
||
: m_size(0), m_data(m_data), maxSize(static_cast<int>(maxSize)) {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why take |
||
|
||
__host__ __device__ SimpleVector() : SimpleVector(0) {} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add |
||
__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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
} | ||
} | ||
|
||
#if defined(__NVCC__) || defined(__CUDACC__) | ||
__device__ int push_back_ts(const T &element) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of curiosity, what does the |
||
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() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
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]; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should return a |
||
|
||
__inline__ __host__ __device__ T at(int i) { | ||
if (i < m_size) | ||
return m_data[i]; | ||
else | ||
return T(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we really want to silently return a default-constructed object ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the added benefit of |
||
} | ||
|
||
__inline__ __host__ __device__ void reset() { m_size = 0; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
__inline__ __host__ __device__ int size() const { return m_size; } | ||
|
||
__inline__ __host__ __device__ int capacity() const { return maxSize; } | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add a |
||
|
||
private: | ||
int m_size; | ||
int maxSize; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you use |
||
|
||
T *m_data; | ||
}; | ||
} // namespace GPU | ||
|
||
#endif |
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> |
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 |
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 |
There was a problem hiding this comment.
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?