BioCMAMC-ST
kokkos_getpolicy.hpp
1#ifndef __COMMON_KOKKOS_GET_POLICY_HPP__
2#define __COMMON_KOKKOS_GET_POLICY_HPP__
3
4#include <Kokkos_Core.hpp>
5#include <common/common.hpp>
6#include <common/env_var.hpp>
7
8namespace Common
9{
10
11 inline constexpr bool
12 is_power_of_2(std::size_t x)
13 {
14 return x != 0 && (x & (x - 1)) == 0;
15 }
16
17 std::size_t c_league_size(std::size_t n_tot, std::size_t n_per_team) noexcept;
18
19 template <typename Tag = void>
20 Kokkos::TeamPolicy<ComputeSpace, Tag>
21 get_policy_team(std::size_t league_size = 1)
22 {
23 const auto _league_size = read_env_or("BIOMC_LEAGUE_SIZE", league_size);
24 return Kokkos::TeamPolicy<ComputeSpace, Tag>(_league_size, Kokkos::AUTO);
25 }
26
27 template <typename Tag = void>
28 Kokkos::TeamPolicy<ComputeSpace, Tag>
29 get_policy_team_from_npt(std::size_t n_tot, std::size_t n_per_team)
30 {
31 return Kokkos::TeamPolicy<ComputeSpace, Tag>(
32 c_league_size(n_tot, n_per_team), Kokkos::AUTO(), Kokkos::AUTO());
33 }
34} // namespace Common
35#endif
Definition config_loader.hpp:8
std::size_t c_league_size(std::size_t n_tot, std::size_t n_per_team) noexcept
Definition common.cpp:17
T read_env_or(std::string_view varname, T vdefault)
Wrapper arround get_env to get envariable with fallback to default.
Definition env_var.hpp:49
Kokkos::TeamPolicy< ComputeSpace, Tag > get_policy_team(std::size_t league_size=1)
Definition kokkos_getpolicy.hpp:21
Kokkos::TeamPolicy< ComputeSpace, Tag > get_policy_team_from_npt(std::size_t n_tot, std::size_t n_per_team)
Definition kokkos_getpolicy.hpp:29
constexpr bool is_power_of_2(std::size_t x)
Definition kokkos_getpolicy.hpp:12