Skip to content

Commit 51fdb72

Browse files
authored
Merge 9960f88 into sapling-pr-archive-ktf
2 parents 69968ee + 9960f88 commit 51fdb72

File tree

26 files changed

+488
-293
lines changed

26 files changed

+488
-293
lines changed

.github/workflows/code-transformations.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
1515
with:
1616
ref: ${{ github.event.pull_request.head.sha }}
1717
persist-credentials: false

.github/workflows/datamodel-doc.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ jobs:
1010
steps:
1111

1212
- name: Checkout O2
13-
uses: actions/checkout@v3
13+
uses: actions/checkout@v4
1414
with:
1515
path: O2
1616
persist-credentials: false
1717

1818
- name: Checkout O2Physics
19-
uses: actions/checkout@v3
19+
uses: actions/checkout@v4
2020
with:
2121
repository: AliceO2Group/O2Physics
2222
path: O2Physics
2323
persist-credentials: false
2424

2525
- name: Checkout documentation
26-
uses: actions/checkout@v3
26+
uses: actions/checkout@v4
2727
with:
2828
repository: AliceO2Group/analysis-framework
2929
path: analysis-framework
@@ -40,7 +40,7 @@ jobs:
4040
git checkout -B auto-datamodel-doc
4141
4242
- name: Set up Python
43-
uses: actions/setup-python@v2
43+
uses: actions/setup-python@v5
4444
with:
4545
python-version: 3.x
4646

.github/workflows/doxygen.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
run: |
1414
sudo apt-get update -y
1515
sudo apt-get install -y doxygen doxygen-doc doxygen-latex doxygen-gui graphviz cmake
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1717
with:
1818
ref: "dev"
1919
persist-credentials: false

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
branch=$(echo ${{ github.event.inputs.tag }}-patches | tr . - | sed -e's/-[0-9]*-patches$/-patches/')
1919
EOF
2020
id: decide_release_branch
21-
- uses: actions/checkout@v3
21+
- uses: actions/checkout@v4
2222
with:
2323
ref: "dev"
2424
- name: Tag branch (or create one before tagging if does not exists)

.github/workflows/stale.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
stale:
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/stale@v1
10+
- uses: actions/stale@v9
1111
with:
1212
repo-token: ${{ secrets.GITHUB_TOKEN }}
1313
stale-pr-message: 'This PR did not have any update in the last 30 days. Is it still needed? Unless further action in will be closed in 5 days.'

DataFormats/simulation/src/DigitizationContext.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ DigitizationContext DigitizationContext::extractSingleTimeframe(int timeframeid,
705705
}
706706
std::copy(mEventRecords.begin() + startindex, mEventRecords.begin() + endindex, std::back_inserter(r.mEventRecords));
707707
std::copy(mEventParts.begin() + startindex, mEventParts.begin() + endindex, std::back_inserter(r.mEventParts));
708-
if (mInteractionVertices.size() > endindex) {
708+
if (mInteractionVertices.size() >= endindex) {
709709
std::copy(mInteractionVertices.begin() + startindex, mInteractionVertices.begin() + endindex, std::back_inserter(r.mInteractionVertices));
710710
}
711711

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
namespace o2::its::gpu
2424
{
2525

26-
class Stream;
27-
2826
class DefaultGPUAllocator : public ExternalAllocator
2927
{
3028
void* allocate(size_t size) override;
@@ -81,10 +79,11 @@ class TimeFrameGPU : public TimeFrame<nLayers>
8179
void downloadCellsLUTDevice();
8280
void unregisterRest();
8381
template <Task task>
84-
Stream& getStream(const size_t stream)
82+
auto& getStream(const size_t stream)
8583
{
86-
return *mGpuStreams[stream];
84+
return mGpuStreams[stream];
8785
}
86+
auto& getStreams() { return mGpuStreams; }
8887
void wipe(const int);
8988

9089
/// interface
@@ -146,7 +145,7 @@ class TimeFrameGPU : public TimeFrame<nLayers>
146145
int getNumberOfNeighbours() const final;
147146

148147
private:
149-
void allocMemAsync(void**, size_t, Stream*, bool); // Abstract owned and unowned memory allocations
148+
void allocMemAsync(void**, size_t, Stream&, bool); // Abstract owned and unowned memory allocations
150149
bool mHostRegistered = false;
151150
TimeFrameGPUParameters mGpuParams;
152151

@@ -200,7 +199,7 @@ class TimeFrameGPU : public TimeFrame<nLayers>
200199
const TrackingFrameInfo** mTrackingFrameInfoDeviceArray;
201200

202201
// State
203-
std::vector<Stream*> mGpuStreams;
202+
Streams mGpuStreams;
204203
size_t mAvailMemGB;
205204
bool mFirstInit = true;
206205

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ void countTrackletsInROFsHandler(const IndexTableUtils* utils,
8484
std::vector<float>& radii,
8585
bounded_vector<float>& mulScatAng,
8686
const int nBlocks,
87-
const int nThreads);
87+
const int nThreads,
88+
gpu::Streams& streams);
8889

8990
template <int nLayers = 7>
9091
void computeTrackletsInROFsHandler(const IndexTableUtils* utils,
@@ -117,7 +118,8 @@ void computeTrackletsInROFsHandler(const IndexTableUtils* utils,
117118
std::vector<float>& radii,
118119
bounded_vector<float>& mulScatAng,
119120
const int nBlocks,
120-
const int nThreads);
121+
const int nThreads,
122+
gpu::Streams& streams);
121123

122124
void countCellsHandler(const Cluster** sortedClusters,
123125
const Cluster** unsortedClusters,

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

Lines changed: 71 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616
#ifndef ITSTRACKINGGPU_UTILS_H_
1717
#define ITSTRACKINGGPU_UTILS_H_
1818

19+
#include <vector>
20+
1921
#include "GPUCommonDef.h"
22+
#include "GPUCommonHelpers.h"
2023

21-
namespace o2
22-
{
23-
namespace its
24+
namespace o2::its
2425
{
26+
2527
template <typename T1, typename T2>
2628
struct gpuPair {
2729
T1 first;
@@ -31,11 +33,6 @@ struct gpuPair {
3133
namespace gpu
3234
{
3335

34-
template <typename T>
35-
void discardResult(const T&)
36-
{
37-
}
38-
3936
// Poor man implementation of a span-like struct. It is very limited.
4037
template <typename T>
4138
struct gpuSpan {
@@ -85,19 +82,74 @@ enum class Task {
8582
Vertexer = 1
8683
};
8784

88-
template <class T>
89-
GPUhd() T* getPtrFromRuler(int index, T* src, const int* ruler, const int stride = 1)
85+
// Abstract stream class
86+
class Stream
9087
{
91-
return src + ruler[index] * stride;
92-
}
88+
public:
89+
#if defined(__HIPCC__)
90+
using Handle = hipStream_t;
91+
static constexpr Handle Default = 0;
92+
#elif defined(__CUDACC__)
93+
using Handle = cudaStream_t;
94+
static constexpr Handle Default = 0;
95+
#else
96+
using Handle = void*;
97+
static constexpr Handle Default = nullptr;
98+
#endif
99+
100+
Stream(unsigned int flags = 0)
101+
{
102+
#if defined(__HIPCC__)
103+
GPUChkErrS(hipStreamCreateWithFlags(&mHandle, flags));
104+
#elif defined(__CUDACC__)
105+
GPUChkErrS(cudaStreamCreateWithFlags(&mHandle, flags));
106+
#endif
107+
}
93108

94-
template <class T>
95-
GPUhd() const T* getPtrFromRuler(int index, const T* src, const int* ruler, const int stride = 1)
109+
Stream(Handle h) : mHandle(h) {}
110+
~Stream()
111+
{
112+
if (mHandle != Default) {
113+
#if defined(__HIPCC__)
114+
GPUChkErrS(hipStreamDestroy(mHandle));
115+
#elif defined(__CUDACC__)
116+
GPUChkErrS(cudaStreamDestroy(mHandle));
117+
#endif
118+
}
119+
}
120+
121+
operator bool() const { return mHandle != Default; }
122+
const Handle& get() { return mHandle; }
123+
void sync() const
124+
{
125+
#if defined(__HIPCC__)
126+
GPUChkErrS(hipStreamSynchronize(mHandle));
127+
#elif defined(__CUDACC__)
128+
GPUChkErrS(cudaStreamSynchronize(mHandle));
129+
#endif
130+
}
131+
132+
private:
133+
Handle mHandle{Default};
134+
};
135+
static_assert(sizeof(Stream) == sizeof(void*), "Stream type must match pointer type!");
136+
137+
// Abstract vector for streams.
138+
// Handles specifically wrap around.
139+
class Streams
96140
{
97-
return src + ruler[index] * stride;
98-
}
141+
public:
142+
size_t size() const noexcept { return mStreams.size(); }
143+
void resize(size_t n) { mStreams.resize(n); }
144+
void clear() { mStreams.clear(); }
145+
auto& operator[](size_t i) { return mStreams[i % mStreams.size()]; }
146+
void push_back(const Stream& stream) { mStreams.push_back(stream); }
147+
148+
private:
149+
std::vector<Stream> mStreams;
150+
};
151+
99152
} // namespace gpu
100-
} // namespace its
101-
} // namespace o2
153+
} // namespace o2::its
102154

103-
#endif
155+
#endif

0 commit comments

Comments
 (0)