Interface Documentation
Version: invalid
coloring.hh
Go to the documentation of this file.
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 <flecsi/execution.hh>
23 
24 #include <optional>
25 
26 namespace flecsi {
27 namespace data {
28 
29 template<class Topo>
30 struct coloring_slot {
31  using color_type = typename Topo::coloring;
32 
38  template<typename... ARGS>
39  color_type & allocate(ARGS &&... args) {
40  constexpr auto f = [](coloring_slot & s, ARGS &&... aa) {
41  s.coloring.emplace(Topo::color(std::forward<ARGS>(aa)...));
42  };
43  execute<*f, index, mpi>(*this, std::forward<ARGS>(args)...);
44  return get();
45  } // allocate
46 
47  void deallocate() {
48  coloring.reset();
49  } // deallocate
50 
51  color_type & get() {
52  return *coloring;
53  }
54 
55  const color_type & get() const {
56  return *coloring;
57  }
58 
59 private:
60  std::optional<color_type> coloring;
61 };
62 
63 } // namespace data
64 } // namespace flecsi
Definition: coloring.hh:30
color_type & allocate(ARGS &&... args)
Definition: coloring.hh:39
size_t color()
Definition: execution.hh:326
Definition: control.hh:31