alpaka
Abstraction Library for Parallel Kernel Acceleration
IdxGbRef.hpp
Go to the documentation of this file.
1 /* Copyright 2022 Axel Huebl, Benjamin Worpitz, Matthias Werner, Jan Stephan, Bernhard Manfred Gruber
2  * SPDX-License-Identifier: MPL-2.0
3  */
4 
5 #pragma once
6 
9 #include "alpaka/dim/Traits.hpp"
10 #include "alpaka/idx/Traits.hpp"
11 #include "alpaka/vec/Vec.hpp"
12 
13 namespace alpaka
14 {
15  namespace gb
16  {
17  //! A IdxGbRef grid block index.
18  template<typename TDim, typename TIdx>
19  class IdxGbRef : public concepts::Implements<ConceptIdxGb, IdxGbRef<TDim, TIdx>>
20  {
21  public:
22  IdxGbRef(Vec<TDim, TIdx> const& gridBlockIdx) : m_gridBlockIdx(gridBlockIdx)
23  {
24  }
25 
27  };
28  } // namespace gb
29 
30  namespace trait
31  {
32  //! The IdxGbRef grid block index dimension get trait specialization.
33  template<typename TDim, typename TIdx>
34  struct DimType<gb::IdxGbRef<TDim, TIdx>>
35  {
36  using type = TDim;
37  };
38 
39  //! The IdxGbRef grid block index grid block index get trait specialization.
40  template<typename TDim, typename TIdx>
41  struct GetIdx<gb::IdxGbRef<TDim, TIdx>, origin::Grid, unit::Blocks>
42  {
43  //! \return The index of the current block in the grid.
44  template<typename TWorkDiv>
45  ALPAKA_FN_HOST static auto getIdx(gb::IdxGbRef<TDim, TIdx> const& idx, TWorkDiv const& /* workDiv */)
47  {
48  return idx.m_gridBlockIdx;
49  }
50  };
51 
52  //! The IdxGbRef grid block index idx type trait specialization.
53  template<typename TDim, typename TIdx>
54  struct IdxType<gb::IdxGbRef<TDim, TIdx>>
55  {
56  using type = TIdx;
57  };
58  } // namespace trait
59 } // namespace alpaka
A IdxGbRef grid block index.
Definition: IdxGbRef.hpp:20
IdxGbRef(Vec< TDim, TIdx > const &gridBlockIdx)
Definition: IdxGbRef.hpp:22
Vec< TDim, TIdx > const & m_gridBlockIdx
Definition: IdxGbRef.hpp:26
#define ALPAKA_FN_HOST
Definition: Common.hpp:40
The alpaka accelerator library.
Tag used in class inheritance hierarchies that describes that a specific concept (TConcept) is implem...
Definition: Concepts.hpp:15
The dimension getter type trait.
Definition: Traits.hpp:14
static ALPAKA_FN_HOST auto getIdx(gb::IdxGbRef< TDim, TIdx > const &idx, TWorkDiv const &) -> Vec< TDim, TIdx >
Definition: IdxGbRef.hpp:45
The index get trait.
Definition: Traits.hpp:42
The idx type trait.
Definition: Traits.hpp:25