Interface Documentation
Version: invalid
bind_accessors.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 #include <flecsi-config.h>
19 
20 #if !defined(__FLECSI_PRIVATE__)
21 #error Do not include this file directly!
22 #endif
23 
24 #include "flecsi/data/accessor.hh"
25 #include "flecsi/data/privilege.hh"
28 #include "flecsi/run/backend.hh"
29 #include "flecsi/util/demangle.hh"
31 
32 #if !defined(FLECSI_ENABLE_LEGION)
33 #error FLECSI_ENABLE_LEGION not defined! This file depends on Legion!
34 #endif
35 
36 #include <legion.h>
37 
38 namespace flecsi {
39 
40 inline log::devel_tag bind_accessors_tag("bind_accessors");
41 
42 namespace exec::leg {
43 
51 struct bind_accessors_t : public util::tuple_walker<bind_accessors_t> {
52 
60  bind_accessors_t(Legion::Runtime * legion_runtime,
61  Legion::Context & legion_context,
62  std::vector<Legion::PhysicalRegion> const & regions,
63  std::vector<Legion::Future> const & futures)
64  : legion_runtime_(legion_runtime), legion_context_(legion_context),
65  regions_(regions), futures_(futures) {}
66 
67  template<typename DATA_TYPE, size_t PRIVILEGES>
69  auto & reg = regions_[region++];
70 
71  // Legion::FieldAccessor<privilege_mode(get_privilege<0, PRIVILEGES>()),
72  const Legion::UnsafeFieldAccessor<DATA_TYPE,
73  1,
74  Legion::coord_t,
75  Realm::AffineAccessor<DATA_TYPE, 1, Legion::coord_t>>
76  ac(reg, accessor.identifier(), sizeof(DATA_TYPE));
77  const auto dom = legion_runtime_->get_index_space_domain(
78  legion_context_, reg.get_logical_region().get_index_space());
79  const auto r = dom.get_rect<1>();
80 
81  bind(accessor,
82  r.hi[0] - r.lo[0] + 1,
83  ac.ptr(Legion::Domain::DomainPointIterator(dom).p));
84  }
85 
86  template<typename DATA_TYPE, size_t PRIVILEGES>
88  visit(accessor.get_base());
89  }
90 
91  template<class Topo, std::size_t Priv>
92  void visit(data::topology_accessor<Topo, Priv> & a) {
93  a.bind([&](auto & x) { visit(x); }); // Clang 8.0.1 deems 'this' unused
94  }
95 
96  /*--------------------------------------------------------------------------*
97  Futures
98  *--------------------------------------------------------------------------*/
99  template<typename DATA_TYPE>
100  void visit(future<DATA_TYPE> & f) {
101  f = {futures_[future_id++]};
102  }
103 
104  /*--------------------------------------------------------------------------*
105  Non-FleCSI Data Types
106  *--------------------------------------------------------------------------*/
107 
108  template<typename DATA_TYPE>
109  static typename std::enable_if_t<
110  !std::is_base_of_v<data::reference_base, DATA_TYPE>>
111  visit(DATA_TYPE &) {
112  {
113  log::devel_guard guard(bind_accessors_tag);
114  flog_devel(info) << "Skipping argument with type "
115  << util::type<DATA_TYPE>() << std::endl;
116  }
117  } // visit
118 
119 private:
120  Legion::Runtime * legion_runtime_;
121  Legion::Context & legion_context_;
122  size_t region = 0;
123  const std::vector<Legion::PhysicalRegion> & regions_;
124  size_t future_id = 0;
125  const std::vector<Legion::Future> & futures_;
126 
127 }; // struct bind_accessors_t
128 
129 } // namespace exec::leg
130 } // namespace flecsi
Definition: topology_accessor.hh:39
Definition: flog.hh:82
Definition: launch.hh:95
Definition: bind_accessors.hh:51
Definition: field.hh:32
bind_accessors_t(Legion::Runtime *legion_runtime, Legion::Context &legion_context, std::vector< Legion::PhysicalRegion > const &regions, std::vector< Legion::Future > const &futures)
Definition: bind_accessors.hh:60
Definition: tuple_walker.hh:34
Definition: control.hh:31