18 #include <flecsi-config.h> 20 #if !defined(__FLECSI_PRIVATE__) 21 #error Do not include this file directly! 30 #if !defined(FLECSI_ENABLE_LEGION) 31 #error FLECSI_ENABLE_LEGION not defined! This file depends on Legion! 36 #if !defined(FLECSI_ENABLE_MPI) 37 #error FLECSI_ENABLE_MPI not defined! This file depends on MPI! 44 #include <string_view> 45 #include <unordered_map> 49 const size_t FLECSI_TOP_LEVEL_TASK_ID = 0;
50 const size_t FLECSI_MAPPER_FORCE_RANK_MATCH = 0x00001000;
51 const size_t FLECSI_MAPPER_COMPACTED_STORAGE = 0x00002000;
52 const size_t FLECSI_MAPPER_SUBRANK_LAUNCH = 0x00003000;
53 const size_t FLECSI_MAPPER_EXCLUSIVE_LR = 0x00004000;
56 template<
class R =
void>
57 using task = R(
const Legion::Task *,
58 const std::vector<Legion::PhysicalRegion> &,
70 friend leg::task<> top_level_task;
80 int initialize(
int argc,
char ** argv,
bool dependent);
92 int start(
const std::function<
int()> &);
105 return context::process_;
113 return context::processes_;
121 return context::threads_per_process_;
129 return context::threads_;
136 static size_t task_depth() {
137 return Legion::Runtime::get_runtime()
138 ->get_current_task(Legion::Runtime::get_context())
146 static size_t color() {
148 task_depth() > 0,
"this method can only be called from within a task");
149 return Legion::Runtime::get_runtime()
150 ->get_current_task(Legion::Runtime::get_context())
151 ->index_point.point_data[0];
160 task_depth() > 0,
"this method can only be called from within a task");
161 return Legion::Runtime::get_runtime()
162 ->get_current_task(Legion::Runtime::get_context())
163 ->index_domain.get_volume();
178 flog_devel(info) <<
"In set_mpi_task" << std::endl;
181 mpi_task_ = std::move(mpi_task);
189 all_processes_ = all_processes;
197 return all_processes_;
207 void handoff_to_mpi(Legion::Context & ctx, Legion::Runtime * runtime);
218 Legion::FutureMap wait_on_mpi(Legion::Context & ctx,
219 Legion::Runtime * runtime);
228 void connect_with_mpi(Legion::Context & ctx, Legion::Runtime * runtime);
235 void handoff_to_legion() {
238 flog_devel(info) <<
"In handoff_to_legion" << std::endl;
241 MPI_Barrier(MPI_COMM_WORLD);
242 handshake_.mpi_handoff_to_legion();
249 void wait_on_legion() {
252 flog_devel(info) <<
"In wait_on_legion" << std::endl;
255 handshake_.mpi_wait_on_legion();
256 MPI_Barrier(MPI_COMM_WORLD);
264 static void mpi_handoff() {
265 instance().handshake_.legion_handoff_to_mpi();
272 static void mpi_wait() {
273 instance().handshake_.legion_wait_on_mpi();
282 bool invoke_mpi_task() {
283 const bool ret(mpi_task_);
295 const std::function<int()> * top_level_action_ =
nullptr;
301 std::function<void()> mpi_task_;
302 Legion::MPILegionHandshake handshake_;
303 LegionRuntime::Arrays::Rect<1> all_processes_;
size_t threads_per_process()
Definition: execution.hh:303
void set_all_processes(const LegionRuntime::Arrays::Rect< 1 > &all_processes)
Definition: context.hh:188
#define flog_assert(test, message)
Definition: flog.hh:411
void set_mpi_task(std::function< void()> mpi_task)
Definition: context.hh:175
int start(const std::function< int()> &action)
Definition: execution.hh:69
Definition: backend.hh:41
size_t processes()
Definition: execution.hh:294
int initialize(int argc, char **argv, bool dependent=true)
Definition: execution.hh:55
size_t process()
Definition: execution.hh:285
void finalize()
Definition: execution.hh:80
const LegionRuntime::Arrays::Rect< 1 > & all_processes() const
Definition: context.hh:196
Definition: context.hh:64
size_t color()
Definition: execution.hh:326
size_t colors()
Definition: execution.hh:336
Definition: context.hh:63
size_t threads()
Definition: execution.hh:316