diff --git a/RecoTracker/LSTCore/interface/Constants.h b/RecoTracker/LSTCore/interface/Constants.h index 725cf5f46b224..c0c342b6ad8a0 100644 --- a/RecoTracker/LSTCore/interface/Constants.h +++ b/RecoTracker/LSTCore/interface/Constants.h @@ -14,23 +14,21 @@ namespace lst { using Buf = alpaka::Buf; // Allocation wrapper function to make integration of the caching allocator easier and reduce code boilerplate. - template - ALPAKA_FN_HOST ALPAKA_FN_INLINE Buf, T> allocBufWrapper(TAcc const& devAccIn, - TSize nElements, - TQueue queue) { + template + ALPAKA_FN_HOST ALPAKA_FN_INLINE Buf allocBufWrapper(TDev const& dev, TSize nElements, TQueue queue) { #ifdef CACHE_ALLOC return cms::alpakatools::allocCachedBuf( - devAccIn, queue, alpaka_common::Vec1D(static_cast(nElements))); + dev, queue, alpaka_common::Vec1D(static_cast(nElements))); #else - return alpaka::allocBuf(devAccIn, + return alpaka::allocBuf(dev, alpaka_common::Vec1D(static_cast(nElements))); #endif } // Second allocation wrapper function when queue is not given. Reduces code boilerplate. - template - ALPAKA_FN_HOST ALPAKA_FN_INLINE Buf, T> allocBufWrapper(TAcc const& devAccIn, TSize nElements) { - return alpaka::allocBuf(devAccIn, + template + ALPAKA_FN_HOST ALPAKA_FN_INLINE Buf allocBufWrapper(TDev const& dev, TSize nElements) { + return alpaka::allocBuf(dev, alpaka_common::Vec1D(static_cast(nElements))); } diff --git a/RecoTracker/LSTCore/interface/alpaka/Constants.h b/RecoTracker/LSTCore/interface/alpaka/Constants.h index e2ebd979a59a3..029d5ebcb80b7 100644 --- a/RecoTracker/LSTCore/interface/alpaka/Constants.h +++ b/RecoTracker/LSTCore/interface/alpaka/Constants.h @@ -36,25 +36,24 @@ namespace lst { #endif // Adjust grid and block sizes based on backend configuration - template - ALPAKA_FN_HOST ALPAKA_FN_INLINE WorkDiv3D createWorkDiv(const Vec& blocksPerGrid, - const Vec& threadsPerBlock, - const Vec& elementsPerThreadArg) { + template > + ALPAKA_FN_HOST ALPAKA_FN_INLINE WorkDiv createWorkDiv(const Vec& blocksPerGrid, + const Vec& threadsPerBlock, + const Vec& elementsPerThreadArg) { Vec adjustedBlocks = blocksPerGrid; Vec adjustedThreads = threadsPerBlock; - // Serial execution, so all launch parameters set to 1. -#if defined(ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED) - adjustedBlocks = Vec::all(static_cast(1)); - adjustedThreads = Vec::all(static_cast(1)); -#endif + // special overrides for CPU/host cases + if constexpr (std::is_same_v) { + adjustedBlocks = Vec::all(static_cast(1)); - // Threads enabled, set number of blocks to 1. -#if defined(ALPAKA_ACC_CPU_B_SEQ_T_THREADS_ENABLED) - adjustedBlocks = Vec::all(static_cast(1)); -#endif + if constexpr (alpaka::accMatchesTags) { + // Serial execution, set threads to 1 as well + adjustedThreads = Vec::all(static_cast(1)); // probably redundant + } + } - return WorkDiv3D(adjustedBlocks, adjustedThreads, elementsPerThreadArg); + return WorkDiv(adjustedBlocks, adjustedThreads, elementsPerThreadArg); } // The constants below are usually used in functions like alpaka::math::min(), diff --git a/RecoTracker/LSTCore/src/ModuleMethods.h b/RecoTracker/LSTCore/src/ModuleMethods.h index 196212defdfa6..bf51e262f69e5 100644 --- a/RecoTracker/LSTCore/src/ModuleMethods.h +++ b/RecoTracker/LSTCore/src/ModuleMethods.h @@ -12,6 +12,7 @@ #include "RecoTracker/LSTCore/interface/PixelMap.h" #include "HeterogeneousCore/AlpakaInterface/interface/host.h" +#include "HeterogeneousCore/AlpakaInterface/interface/memory.h" namespace lst { struct ModuleMetaData { @@ -80,7 +81,7 @@ namespace lst { nPixels = connectedPix_size; // Now we re-initialize connectedPixels_buf since nPixels is now known - modulesBuf.connectedPixels_buf = allocBufWrapper(cms::alpakatools::host(), nPixels); + modulesBuf.connectedPixels_buf = cms::alpakatools::make_host_buffer(nPixels); modulesBuf.data_.setData(modulesBuf); unsigned int* connectedPixels = modulesBuf.connectedPixels_buf.data();