https://mooseframework.inl.gov
KokkosThread.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #ifdef MOOSE_KOKKOS_SCOPE
13 #include "KokkosHeader.h"
14 #endif
15 
16 #include "MooseTypes.h"
17 
19 
20 namespace Moose
21 {
22 namespace Kokkos
23 {
24 
29 class Thread
30 {
31 #ifdef MOOSE_KOKKOS_SCOPE
32 public:
37  void resize(std::vector<ThreadID> dims);
42  ThreadID size() const { return _size; }
49  KOKKOS_FUNCTION ThreadID operator()(ThreadID tid, unsigned int dim) const
50  {
51  KOKKOS_ASSERT(dim < _dim);
52 
53  return (tid / _strides[dim]) % _dims[dim];
54  }
55 #endif
56 
57 protected:
65  unsigned int _dim = 0;
74 };
75 
76 } // namespace Kokkos
77 } // namespace Moose
KOKKOS_FUNCTION ThreadID operator()(ThreadID tid, unsigned int dim) const
Get the multi-dimensional thread index of a dimension given a one-dimensional thread index...
Definition: KokkosThread.h:49
dof_id_type ThreadID
Definition: KokkosThread.h:18
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:159
void resize(std::vector< ThreadID > dims)
Set the thread pool size and dimension.
unsigned int _dim
Thread pool dimension.
Definition: KokkosThread.h:65
ThreadID _size
Total thread pool size.
Definition: KokkosThread.h:61
ThreadID _dims[10]
Thread pool size of each dimension.
Definition: KokkosThread.h:69
ThreadID _strides[10]
Thread pool stride of each dimension.
Definition: KokkosThread.h:73
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
ThreadID size() const
Get the total thread pool size.
Definition: KokkosThread.h:42
The Kokkos thread object that aids in converting the one-dimensional thread index into multi-dimensio...
Definition: KokkosThread.h:29
uint8_t dof_id_type