ttg 1.0.0
Template Task Graph (TTG): flowgraph-based programming model for high-performance distributed-memory algorithms
Loading...
Searching...
No Matches
keymap.h
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-3-Clause
2#ifndef TTG_BASE_KEYMAP_H
3#define TTG_BASE_KEYMAP_H
4
5#include <type_traits>
6#include "ttg/util/meta.h"
7#include "ttg/util/hash.h"
8
9namespace ttg {
10 namespace detail {
11
15 template <typename keyT, typename Enabler = void>
17 template <typename keyT>
19 keyT, std::enable_if_t<meta::has_ttg_hash_specialization_v<keyT> || meta::is_void_v<keyT>>> {
21 default_keymap_impl(int world_size) : world_size(world_size) {}
22
23 template <typename Key = keyT>
24 std::enable_if_t<!meta::is_void_v<Key>,int>
25 operator()(const Key &key) const {
26 if (world_size == 1) {
27 return 0;
28 } else {
29 return ttg::hash<keyT>{}(key) % world_size;
30 }
31 }
32 template <typename Key = keyT>
33 std::enable_if_t<meta::is_void_v<Key>,int>
34 operator()() const { return 0; }
35
36 private:
37 int world_size;
38 };
39
40
42 template <typename keyT>
45
46 template <typename Key = keyT>
47 std::enable_if_t<!meta::is_void_v<Key>,int>
48 operator()(const Key &key) const { return 0; }
49 template <typename Key = keyT>
50 std::enable_if_t<meta::is_void_v<Key>,int>
51 operator()() const { return 0; }
52 };
53
54 } // namespace detail
55
56} // namespace ttg
57
58#endif // TTG_BASE_KEYMAP_H
STL namespace.
top-level TTG namespace contains runtime-neutral functionality
Definition keymap.h:9
the default priority map implementation
Definition keymap.h:43
std::enable_if_t< meta::is_void_v< Key >, int > operator()() const
Definition keymap.h:51
std::enable_if_t<!meta::is_void_v< Key >, int > operator()(const Key &key) const
Definition keymap.h:48
Computes hash values for objects of type T.
Definition hash.h:82