Skip to content

Commit b62d3d6

Browse files
f3schdavidrohr
authored andcommitted
ITS: GPU: create compile time stack tags
Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
1 parent c3f85c1 commit b62d3d6

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

Detectors/ITSMFT/ITS/tracking/GPU/cuda/TimeFrameGPU.cu

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
///
1212

1313
#include <cuda_runtime.h>
14-
#include <fmt/format.h>
1514

1615
#include <unistd.h>
1716
#include <vector>
@@ -633,21 +632,37 @@ void TimeFrameGPU<nLayers>::unregisterHostMemory(const int maxLayers)
633632
checkedUnregisterArray(mPinnedROFramesClusters, mROFramesClustersDevice);
634633
}
635634

635+
namespace detail
636+
{
637+
template <std::size_t I>
638+
constexpr uint64_t makeIterTag()
639+
{
640+
static_assert(I < 10);
641+
constexpr char tag[] = {'I', 'T', 'S', 'I', 'T', 'E', 'R', char('0' + I), '\0'};
642+
return qStr2Tag(tag);
643+
}
644+
template <std::size_t... I>
645+
constexpr auto makeIterTags(std::index_sequence<I...>)
646+
{
647+
return std::array<uint64_t, sizeof...(I)>{makeIterTag<I>()...};
648+
}
649+
// FIXME: we have to be careful that the MaxIter does not diverge from the 4 here!
650+
constexpr auto kIterTags = makeIterTags(std::make_index_sequence<4>{});
651+
} // namespace detail
652+
636653
template <int nLayers>
637654
void TimeFrameGPU<nLayers>::pushMemoryStack(const int iteration)
638655
{
639656
// mark the beginning of memory marked with MEMORY_STACK that can be discarded
640657
// after doing one iteration
641-
const auto name = fmt::format("ITSITER{}", iteration);
642-
(this->mExternalAllocator)->pushTagOnStack(qStr2Tag(name.c_str()));
658+
(this->mExternalAllocator)->pushTagOnStack(detail::kIterTags[iteration]);
643659
}
644660

645661
template <int nLayers>
646662
void TimeFrameGPU<nLayers>::popMemoryStack(const int iteration)
647663
{
648664
// pop all memory on the stack from this iteration
649-
const auto name = fmt::format("ITSITER{}", iteration);
650-
(this->mExternalAllocator)->popTagOffStack(qStr2Tag(name.c_str()));
665+
(this->mExternalAllocator)->popTagOffStack(detail::kIterTags[iteration]);
651666
}
652667

653668
template <int nLayers>

0 commit comments

Comments
 (0)