Interface Documentation
Version: invalid
core.hh
1 /*
2  @@@@@@@@ @@ @@@@@@ @@@@@@@@ @@
3  /@@///// /@@ @@////@@ @@////// /@@
4  /@@ /@@ @@@@@ @@ // /@@ /@@
5  /@@@@@@@ /@@ @@///@@/@@ /@@@@@@@@@/@@
6  /@@//// /@@/@@@@@@@/@@ ////////@@/@@
7  /@@ /@@/@@//// //@@ @@ /@@/@@
8  /@@ @@@//@@@@@@ //@@@@@@ @@@@@@@@ /@@
9  // /// ////// ////// //////// //
10 
11  Copyright (c) 2016, Triad National Security, LLC
12  All rights reserved.
13  */
14 #pragma once
15 
18 #if !defined(__FLECSI_PRIVATE__)
19 #error Do not include this file directly!
20 #endif
21 
22 #include <cstddef> // size_t
23 
24 #include "flecsi/data/privilege.hh"
28 
29 namespace flecsi {
30 namespace data {
31 template<class>
32 struct coloring_slot; // avoid dependency on flecsi::execute
33 }
34 
35 namespace topo {
36 enum single_space { elements };
37 
38 namespace detail {
39 template<template<class> class>
40 struct base;
41 
42 inline std::size_t next_id;
43 // Use functions because these are needed during non-local initialization:
44 template<class>
45 std::size_t
46 id() {
47  static auto ret = next_id++;
48  return ret;
49 }
50 
51 template<class, class = void>
52 struct index_space {
53  using type = single_space;
54  static constexpr single_space default_space = elements;
55 };
56 template<class T> // TIP: SFINAE uses index_space member if defined
57 struct index_space<T, util::voided<typename T::index_space>> {
58  using type = typename T::index_space;
59 };
60 
61 // With this as a variable template, GCC 8.1 incorrectly produces a hard error
62 // rather than discounting the partial specialization when appropriate.
63 template<class T, class = void>
64 struct default_space { // NB: not SFINAE-friendly
65  static constexpr single_space value = detail::index_space<T>::default_space;
66 };
67 template<class T>
68 struct default_space<T, decltype(void(T::default_space))> {
69  static constexpr auto value = T::default_space;
70 };
71 } // namespace detail
72 
73 template<template<class> class T>
74 using base_t = typename detail::base<T>::type;
75 
76 template<class T>
77 std::size_t
78 id() {
79  return detail::id<std::remove_cv_t<T>>();
80 }
81 
82 template<class, class = void>
83 inline constexpr std::size_t index_spaces = 1;
84 // TIP: expression SFINAE uses index_spaces member if defined
85 template<class T>
86 inline constexpr std::size_t
87  index_spaces<T, decltype(void(T::core::index_spaces))> =
88  T::core::index_spaces;
89 
90 template<class T>
91 using index_space_t = typename detail::index_space<typename T::core>::type;
92 template<class T>
93 inline constexpr auto default_space =
95 template<class T, index_space_t<T> S, class = const std::size_t>
96 inline constexpr std::size_t privilege_count = 1;
97 template<class T, index_space_t<T> S>
98 inline constexpr std::size_t
99  privilege_count<T, S, decltype(T::core::template privilege_count<S>)> =
100  T::core::template privilege_count<S>;
101 
102 template<class T>
103 using identity = T; // can be a trivial specialization interface
104 
109 template<template<class> class C, class D, template<class> class I = identity>
111  using core = C<D>;
112  using base = base_t<C>;
113  // This is just core::coloring, but core is incomplete here.
114  using coloring = typename base::coloring;
115  template<class B>
116  using interface = I<B>;
117 
118  // NB: nested classes would prevent template argument deduction.
121 
124  template<partition_privilege_t... Priv>
126 
127  specialization() = delete;
128 };
129 
130 } // namespace topo
131 } // namespace flecsi
Definition: coloring.hh:30
Definition: topology_accessor.hh:39
Definition: core.hh:52
constexpr size_t privilege_pack
Definition: privilege.hh:62
Definition: core.hh:110
Definition: core.hh:40
partition_privilege_t
Definition: privilege.hh:44
Definition: topology_slot.hh:30
constexpr size_t privilege_count(std::size_t PACK)
Definition: privilege.hh:76
Definition: control.hh:31