Interface Documentation
Version: invalid
storage.hh
Go to the documentation of this file.
1 /*
2  @@@@@@@@ @@ @@@@@@ @@@@@@@@ @@
3  /@@///// /@@ @@////@@ @@////// /@@
4  /@@ /@@ @@@@@ @@ // /@@ /@@
5  /@@@@@@@ /@@ @@///@@/@@ /@@@@@@@@@/@@
6  /@@//// /@@/@@@@@@@/@@ ////////@@/@@
7  /@@ /@@/@@//// //@@ @@ /@@/@@
8  /@@ @@@//@@@@@@ //@@@@@@ @@@@@@@@ /@@
9  // /// ////// ////// //////// //
10 
11  Copyright (c) 2016, Los Alamos 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 "../entity_storage.hh"
23 #include "../index_space.hh"
24 #include "flecsi/run/backend.hh"
25 #include "flecsi/run/context.hh"
27 #include "flecsi/util/id.hh"
28 
29 #include <array>
30 
31 namespace flecsi {
32 namespace topo {
33 
34 template<class TREE_TYPE>
35 struct ntree_storage {
36 
37  using id_t = util::id_t;
38  static constexpr size_t num_partitions = 5;
39 
40  using entity_t = typename TREE_TYPE::entity_t;
41  using node_t = typename TREE_TYPE::node_t;
42  using tree_entity_t = typename TREE_TYPE::tree_entity_t;
43 
44  // entity index spaces
45  using entity_index_space_t =
51 
52  entity_index_space_t entity_index_space;
53  entity_index_subspaces_t entity_index_subspaces;
54  std::array<entity_partition_index_spaces_t, num_partitions>
55  entity_partition_index_spaces;
56 
57  // Tree entity index space
64 
65  tree_entity_index_space_t tree_entity_index_space;
66  tree_entity_index_subspaces_t tree_entity_index_subspaces;
67  std::array<tree_entity_partition_index_spaces_t, num_partitions>
68  tree_entity_partition_index_spaces;
69 
70  // Nodes index space
71  using node_index_space_t =
77 
78  node_index_space_t node_index_space;
79  node_index_subspaces_t node_index_subspaces;
80  std::array<node_partition_index_spaces_t, num_partitions>
81  node_partition_index_spaces;
82 
83  ntree_storage() {
84  // auto & context_ = run::context::instance();
85  }
86 
87  void finalize_storage() {
88  // auto & context = run::context::instance();
89  }
90 
94  void init_entities(entity_t * buf_entity,
95  id_t * buf_id_entity,
96  tree_entity_t * buf_tree_entity,
97  id_t * buf_id_tree_entity,
98  size_t num_entities) {
99  entity_index_space.storage()->set_buffer(buf_entity, num_entities);
100  entity_index_space.id_storage().set_buffer(buf_id_entity, num_entities);
101  tree_entity_index_space.storage()->set_buffer(
102  buf_tree_entity, num_entities);
103  tree_entity_index_space.id_storage().set_buffer(
104  buf_id_tree_entity, num_entities);
105  }
106 
110  void init_nodes(node_t * buf, size_t num_nodes) {
111  node_index_space.storage()->set_buffer(buf, num_nodes);
112  }
113 
117  template<class... ARG_TYPES>
118  entity_t * make_entity(ARG_TYPES &&... args) {
119  size_t entity = entity_index_space.size();
120  auto placement_ptr =
121  static_cast<entity_t *>(entity_index_space.storage()->buffer()) + entity;
122  auto ent = new(placement_ptr) entity_t(std::forward<ARG_TYPES>(args)...);
123  id_t global_id = id_t::make<0, 0>(entity);
124  ent->template set_global_id(global_id);
125  auto & id_storage = entity_index_space.id_storage();
126  id_storage[entity] = global_id;
127  entity_index_space.pushed();
128  return ent;
129  } // make
130 
131 }; // class mpi_topology_storage_policy
132 
133 } // namespace topo
134 } // namespace flecsi
void init_entities(entity_t *buf_entity, id_t *buf_id_entity, tree_entity_t *buf_tree_entity, id_t *buf_id_tree_entity, size_t num_entities)
Initialize the entitiy index space.
Definition: storage.hh:94
void init_nodes(node_t *buf, size_t num_nodes)
Definition: storage.hh:110
entity_t * make_entity(ARG_TYPES &&... args)
Definition: storage.hh:118
Definition: id.hh:36
storage_t * storage()
Return the storage object.
Definition: index_space.hh:627
Definition: storage.hh:35
const id_storage_t & id_storage() const
Return the index storage object.
Definition: index_space.hh:1087
void pushed()
Called if an index was added to storage internally.
Definition: index_space.hh:1490
size_t size() const
Get the size of the index space.
Definition: index_space.hh:973
Definition: control.hh:31