Interface Documentation
Version: invalid
field.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 
19 #include "flecsi/run/backend.hh"
20 #include "flecsi/run/types.hh"
21 #include <flecsi/data/layout.hh>
22 #include <flecsi/data/privilege.hh>
23 
24 namespace flecsi {
25 namespace data {
26 
31 template<layout L, typename T, std::size_t Priv>
32 struct accessor;
33 
34 template<class, layout, class, std::size_t>
36 
37 template<class T, class Topo, std::size_t Space>
38 struct field_register<T, dense, Topo, Space> : field_info_t {
39  field_register() : field_info_t{unique_fid_t::instance().next(), sizeof(T)} {
40  run::context::instance().add_field_info<Topo, Space>(*this);
41  }
42  // Copying/moving is inadvisable because the context knows the address.
43  field_register(const field_register &) = delete;
44  field_register & operator=(const field_register &) = delete;
45 };
46 
47 template<class T, class Topo, std::size_t Space>
48 struct field_register<T, singular, Topo, Space>
49  : field_register<T, dense, Topo, Space> {};
50 
56 template<class Topo>
58  // The use of the slot allows creating field references statically, before
59  // the topology object has been created.
61 
62  field_reference_t(const field_info_t & info, const topology_t & topology)
63  : fid_(info.fid), topology_(&topology) {}
64 
65  field_id_t fid() const {
66  return fid_;
67  }
68  const topology_t & topology() const {
69  return *topology_;
70  } // topology_identifier
71 
72 private:
73  field_id_t fid_;
74  const topology_t * topology_;
75 
76 }; // struct field_reference
77 
82 template<class T, layout L, class Topo, topo::index_space_t<Topo> Space>
84  using Base = typename field_reference::field_reference_t; // TIP: dependent
85  using value_type = T;
86 
87  using Base::Base;
88  explicit field_reference(const Base & b) : Base(b) {}
89 
90  template<layout L2, class T2 = T> // TODO: allow only safe casts
91  auto cast() const {
93  }
94 };
95 
96 } // namespace data
97 
102 template<class T, data::layout L = data::dense>
103 struct field {
104  template<std::size_t Priv>
108  template<partition_privilege_t... PP>
109  using accessor = accessor1<privilege_pack<PP...>>;
110 
114  template<class Topo,
115  topo::index_space_t<Topo> Space = topo::default_space<Topo>>
116  struct definition : data::field_register<T, L, Topo, Space> {
117  using Field = field;
118 
122  const data::topology_slot<Topo> & t) const {
123  return {*this, t};
124  }
125  };
126 };
127 
128 namespace data {
129 template<class F, std::size_t Priv>
130 using field_accessor =
131  typename std::remove_reference_t<F>::Field::template accessor1<Priv>;
132 template<const auto & F, std::size_t Priv>
133 struct accessor_member : field_accessor<decltype(F), Priv> {
134  accessor_member() : accessor_member::accessor(F.fid) {}
135 };
136 
137 } // namespace data
138 } // namespace flecsi
Definition: field.hh:35
Definition: field.hh:116
Definition: field_info.hh:36
Definition: field.hh:83
constexpr size_t privilege_pack
Definition: privilege.hh:62
Access to the single element of an array.
Definition: layout.hh:39
partition_privilege_t
Definition: privilege.hh:44
Definition: topology_slot.hh:27
Definition: topology_slot.hh:30
Definition: field.hh:103
Definition: field.hh:57
Definition: field.hh:133
Definition: field.hh:32
data::field_reference< T, L, Topo, Space > operator()(const data::topology_slot< Topo > &t) const
Definition: field.hh:121
Definition: control.hh:31