Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-26 08:22:04

0001 /**
0002  * traccc library, part of the ACTS project (R&D line)
0003  *
0004  * (c) 2024-2025 CERN for the benefit of the ACTS project
0005  *
0006  * Mozilla Public License Version 2.0
0007  */
0008 
0009 #pragma once
0010 
0011 // Local include(s).
0012 #include "utils.hpp"
0013 
0014 // Project include(s).
0015 #include "traccc/definitions/qualifiers.hpp"
0016 #include "traccc/device/concepts/thread_id.hpp"
0017 
0018 // Alpaka include(s).
0019 #include <alpaka/alpaka.hpp>
0020 
0021 namespace traccc::alpaka::details {
0022 
0023 /// An Alpaka thread identifier type
0024 template <typename TAcc>
0025 struct thread_id1 {
0026   ALPAKA_FN_INLINE ALPAKA_FN_ACC explicit thread_id1(const TAcc& acc)
0027       : m_acc(acc) {}
0028 
0029   unsigned int inline ALPAKA_FN_ACC getLocalThreadId() const {
0030     return static_cast<unsigned int>(
0031         ::alpaka::getIdx<::alpaka::Block, ::alpaka::Threads>(m_acc)[0u]);
0032   }
0033 
0034   unsigned int inline ALPAKA_FN_ACC getLocalThreadIdX() const {
0035     return getLocalThreadId();
0036   }
0037 
0038   unsigned int inline ALPAKA_FN_ACC getGlobalThreadId() const {
0039     return getLocalThreadId() + getBlockIdX() * getBlockDimX();
0040   }
0041 
0042   unsigned int inline ALPAKA_FN_ACC getGlobalThreadIdX() const {
0043     return getLocalThreadId() + getBlockIdX() * getBlockDimX();
0044   }
0045 
0046   unsigned int inline ALPAKA_FN_ACC getBlockIdX() const {
0047     return static_cast<unsigned int>(
0048         ::alpaka::getIdx<::alpaka::Grid, ::alpaka::Blocks>(m_acc)[0u]);
0049   }
0050 
0051   unsigned int inline ALPAKA_FN_ACC getBlockDimX() const {
0052     return static_cast<unsigned int>(
0053         ::alpaka::getWorkDiv<::alpaka::Block, ::alpaka::Threads>(m_acc)[0u]);
0054   }
0055 
0056   unsigned int inline ALPAKA_FN_ACC getGridDimX() const {
0057     return static_cast<unsigned int>(
0058         ::alpaka::getWorkDiv<::alpaka::Grid, ::alpaka::Blocks>(m_acc)[0u]);
0059   }
0060 
0061  private:
0062   const TAcc& m_acc;
0063 };
0064 
0065 /// Verify that @c traccc::alpaka::details::thread_id1 fulfills the
0066 /// @c traccc::device::concepts::thread_id1 concept.
0067 static_assert(traccc::device::concepts::thread_id1<thread_id1<Acc>>);
0068 
0069 }  // namespace traccc::alpaka::details