Skip to content

Commit f2b0957

Browse files
committed
ITS: GPU: put trackleting properly on different streams
Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
1 parent db916c2 commit f2b0957

File tree

5 files changed

+80
-47
lines changed

5 files changed

+80
-47
lines changed

Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/TimeFrameGPU.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class TimeFrameGPU : public TimeFrame<nLayers>
7979
return mGpuStreams[stream];
8080
}
8181
auto& getStreams() { return mGpuStreams; }
82+
void syncStreams();
8283
virtual void wipe() final;
8384

8485
/// interface
@@ -108,7 +109,7 @@ class TimeFrameGPU : public TimeFrame<nLayers>
108109
std::vector<unsigned int> getClusterSizes();
109110
const unsigned char** getDeviceArrayUsedClusters() const { return mUsedClustersDeviceArray; }
110111
const int** getDeviceROframeClusters() const { return mROFrameClustersDeviceArray; }
111-
Tracklet** getDeviceArrayTracklets() { return mTrackletsDeviceArray; }
112+
Tracklet** getDeviceArrayTracklets() { return mTrackletsDevice.data(); }
112113
int** getDeviceArrayTrackletsLUT() const { return mTrackletsLUTDeviceArray; }
113114
int** getDeviceArrayCellsLUT() const { return mCellsLUTDeviceArray; }
114115
int** getDeviceArrayNeighboursCellLUT() const { return mNeighboursCellLUTDeviceArray; }
@@ -140,7 +141,8 @@ class TimeFrameGPU : public TimeFrame<nLayers>
140141
int getNumberOfNeighbours() const final;
141142

142143
private:
143-
void allocMemAsync(void**, size_t, Stream&, bool); // Abstract owned and unowned memory allocations
144+
void allocMemAsync(void**, size_t, Stream&, bool); // Abstract owned and unowned memory allocations on specific stream
145+
void allocMem(void**, size_t, bool); // Abstract owned and unowned memory allocations on default stream
144146
bool mHostRegistered = false;
145147
TimeFrameGPUParameters mGpuParams;
146148

@@ -167,7 +169,6 @@ class TimeFrameGPU : public TimeFrame<nLayers>
167169
const unsigned char** mUsedClustersDeviceArray;
168170
const int** mROFrameClustersDeviceArray;
169171
std::array<Tracklet*, nLayers - 1> mTrackletsDevice;
170-
Tracklet** mTrackletsDeviceArray;
171172
std::array<int*, nLayers - 1> mTrackletsLUTDevice;
172173
std::array<int*, nLayers - 2> mCellsLUTDevice;
173174
std::array<int*, nLayers - 3> mNeighboursLUTDevice;
@@ -195,8 +196,6 @@ class TimeFrameGPU : public TimeFrame<nLayers>
195196

196197
// State
197198
Streams mGpuStreams;
198-
size_t mAvailMemGB;
199-
bool mFirstInit = true;
200199

201200
// Temporary buffer for storing output tracks from GPU tracking
202201
bounded_vector<TrackITSExt> mTrackITSExt;

Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/Utils.h

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,21 @@ class Stream
9494
public:
9595
#if defined(__HIPCC__)
9696
using Handle = hipStream_t;
97-
static constexpr Handle Default = 0;
97+
static constexpr Handle DefaultStream = 0;
98+
// static constexpr unsigned int DefaultFlag = hipStreamNonBlocking; TODO replace once ready
99+
static constexpr unsigned int DefaultFlag = 0;
98100
#elif defined(__CUDACC__)
99101
using Handle = cudaStream_t;
100-
static constexpr Handle Default = 0;
102+
static constexpr Handle DefaultStream = 0;
103+
// static constexpr unsigned int DefaultFlag = cudaStreamNonBlocking; TODO replace once ready
104+
static constexpr unsigned int DefaultFlag = 0;
101105
#else
102106
using Handle = void*;
103-
static constexpr Handle Default = nullptr;
107+
static constexpr Handle DefaultStream = nullptr;
108+
static constexpr unsigned int DefaultFlag = 0;
104109
#endif
105110

106-
Stream(unsigned int flags = 0)
111+
Stream(unsigned int flags = DefaultFlag)
107112
{
108113
#if defined(__HIPCC__)
109114
GPUChkErrS(hipStreamCreateWithFlags(&mHandle, flags));
@@ -115,7 +120,7 @@ class Stream
115120
Stream(Handle h) : mHandle(h) {}
116121
~Stream()
117122
{
118-
if (mHandle != Default) {
123+
if (mHandle != DefaultStream) {
119124
#if defined(__HIPCC__)
120125
GPUChkErrS(hipStreamDestroy(mHandle));
121126
#elif defined(__CUDACC__)
@@ -124,7 +129,7 @@ class Stream
124129
}
125130
}
126131

127-
operator bool() const { return mHandle != Default; }
132+
operator bool() const { return mHandle != DefaultStream; }
128133
const Handle& get() { return mHandle; }
129134
void sync() const
130135
{
@@ -136,7 +141,7 @@ class Stream
136141
}
137142

138143
private:
139-
Handle mHandle{Default};
144+
Handle mHandle{DefaultStream};
140145
};
141146
static_assert(sizeof(Stream) == sizeof(void*), "Stream type must match pointer type!");
142147

@@ -150,6 +155,12 @@ class Streams
150155
void clear() { mStreams.clear(); }
151156
auto& operator[](size_t i) { return mStreams[i % mStreams.size()]; }
152157
void push_back(const Stream& stream) { mStreams.push_back(stream); }
158+
void sync()
159+
{
160+
for (auto& s : mStreams) {
161+
s.sync();
162+
}
163+
}
153164

154165
private:
155166
std::vector<Stream> mStreams;

0 commit comments

Comments
 (0)