From 1370f68b955fdd6fa1947f1fa95ff3f697fb79df Mon Sep 17 00:00:00 2001 From: Wonchan Lee Date: Fri, 20 Apr 2018 13:21:29 -0700 Subject: [PATCH] legion, regent: Add interface for task local regions, do nothing for them yet --- language/examples/manual_capi.rg | 2 +- language/examples/manual_capi_1d.rg | 2 +- .../manual_capi_fields_after_region.rg | 2 +- language/examples/manual_capi_reduce.rg | 2 +- ...manual_capi_single_task_multile_regions.rg | 4 +-- language/src/regent/codegen.t | 4 +-- runtime/legion.h | 6 ++-- runtime/legion/legion.cc | 4 +-- runtime/legion/legion.inl | 4 +-- runtime/legion/legion_c.cc | 6 ++-- runtime/legion/legion_c.h | 3 +- runtime/legion/legion_context.cc | 35 +++++++++++-------- runtime/legion/legion_context.h | 16 +++++---- runtime/legion/legion_tasks.cc | 19 +++++----- runtime/legion/legion_tasks.h | 7 ++-- runtime/legion/runtime.cc | 5 +-- runtime/legion/runtime.h | 2 +- 17 files changed, 72 insertions(+), 51 deletions(-) diff --git a/language/examples/manual_capi.rg b/language/examples/manual_capi.rg index 94d1a9a13d..9653b849bc 100644 --- a/language/examples/manual_capi.rg +++ b/language/examples/manual_capi.rg @@ -60,7 +60,7 @@ terra top_level_task(task : c.legion_task_t, var is = c.legion_index_space_create(runtime, ctx, 5) var fs = c.legion_field_space_create(runtime, ctx) - var r = c.legion_logical_region_create(runtime, ctx, is, fs) + var r = c.legion_logical_region_create(runtime, ctx, is, fs, true) var ptr1 : c.legion_ptr_t, ptr2 : c.legion_ptr_t var f1 : c.legion_field_id_t, f2 : c.legion_field_id_t diff --git a/language/examples/manual_capi_1d.rg b/language/examples/manual_capi_1d.rg index cad76a490b..9e176f3350 100644 --- a/language/examples/manual_capi_1d.rg +++ b/language/examples/manual_capi_1d.rg @@ -93,7 +93,7 @@ terra top_level_task(task : c.legion_task_t, }) var is = c.legion_index_space_create_domain(runtime, ctx, d) var fs = c.legion_field_space_create(runtime, ctx) - var r = c.legion_logical_region_create(runtime, ctx, is, fs) + var r = c.legion_logical_region_create(runtime, ctx, is, fs, true) do var fsa = c.legion_field_allocator_create(runtime, ctx, fs) diff --git a/language/examples/manual_capi_fields_after_region.rg b/language/examples/manual_capi_fields_after_region.rg index 23eb4dcaf3..feb04ffff0 100644 --- a/language/examples/manual_capi_fields_after_region.rg +++ b/language/examples/manual_capi_fields_after_region.rg @@ -33,7 +33,7 @@ terra top_level_task(task : c.legion_task_t, var is = c.legion_index_space_create(runtime, ctx, 5) var fs = c.legion_field_space_create(runtime, ctx) - var r = c.legion_logical_region_create(runtime, ctx, is, fs) + var r = c.legion_logical_region_create(runtime, ctx, is, fs, true) var ptr1 : c.legion_ptr_t, ptr2 : c.legion_ptr_t var f1 : c.legion_field_id_t, f2 : c.legion_field_id_t diff --git a/language/examples/manual_capi_reduce.rg b/language/examples/manual_capi_reduce.rg index bcc018bb80..3711a2696a 100644 --- a/language/examples/manual_capi_reduce.rg +++ b/language/examples/manual_capi_reduce.rg @@ -58,7 +58,7 @@ terra top_level_task(task : c.legion_task_t, var is = c.legion_index_space_create(runtime, ctx, 5) var fs = c.legion_field_space_create(runtime, ctx) - var r = c.legion_logical_region_create(runtime, ctx, is, fs) + var r = c.legion_logical_region_create(runtime, ctx, is, fs, true) var ptr1 : c.legion_ptr_t, ptr2 : c.legion_ptr_t var f1 : c.legion_field_id_t, f2 : c.legion_field_id_t diff --git a/language/examples/manual_capi_single_task_multile_regions.rg b/language/examples/manual_capi_single_task_multile_regions.rg index fded1b71ce..3d7ea66ec1 100644 --- a/language/examples/manual_capi_single_task_multile_regions.rg +++ b/language/examples/manual_capi_single_task_multile_regions.rg @@ -52,7 +52,7 @@ terra top_level_task(task : c.legion_task_t, c.legion_field_allocator_destroy(allocator) end var lr1 = - c.legion_logical_region_create(runtime, ctx, is1, fs1) + c.legion_logical_region_create(runtime, ctx, is1, fs1, true) var is2 = c.legion_index_space_create(runtime, ctx, 5) var fs2 = c.legion_field_space_create(runtime, ctx) @@ -66,7 +66,7 @@ terra top_level_task(task : c.legion_task_t, c.legion_field_allocator_destroy(allocator) end var lr2 = - c.legion_logical_region_create(runtime, ctx, is2, fs2) + c.legion_logical_region_create(runtime, ctx, is2, fs2, true) var arg_nil = c.legion_task_argument_t { args = nil, arglen = 0 } diff --git a/language/src/regent/codegen.t b/language/src/regent/codegen.t index 3ab4750a05..10f7b38080 100644 --- a/language/src/regent/codegen.t +++ b/language/src/regent/codegen.t @@ -3543,7 +3543,7 @@ function codegen.expr_region(cx, node) end)] [fs_naming_actions]; c.legion_field_allocator_destroy(fsa) - var [lr] = c.legion_logical_region_create([cx.runtime], [cx.context], [is], [fs]) + var [lr] = c.legion_logical_region_create([cx.runtime], [cx.context], [is], [fs], true) var [r] = [region_type]{ impl = [lr] } end local tag = terralib.newsymbol(c.legion_mapping_tag_id_t, "tag") @@ -4125,7 +4125,7 @@ function codegen.expr_list_duplicate_partition(cx, node) var color = [indices_type:data(indices.value)][i] var orig_r = [get_partition_subregion(cx, partition, color)] var r = c.legion_logical_region_create( - [cx.runtime], [cx.context], orig_r.index_space, orig_r.field_space) + [cx.runtime], [cx.context], orig_r.index_space, orig_r.field_space, true) var new_root = c.legion_logical_partition_get_logical_subregion_by_tree( [cx.runtime], orig_r.index_space, orig_r.field_space, r.tree_id) diff --git a/runtime/legion.h b/runtime/legion.h index 0cf0d42d2f..59bfd14d17 100644 --- a/runtime/legion.h +++ b/runtime/legion.h @@ -4500,12 +4500,14 @@ namespace Legion { * @return handle for the logical region created */ LogicalRegion create_logical_region(Context ctx, IndexSpace index, - FieldSpace fields); + FieldSpace fields, + bool task_local = false); // Template version template LogicalRegionT create_logical_region(Context ctx, IndexSpaceT index, - FieldSpace fields); + FieldSpace fields, + bool task_local = false); /** * Destroy a logical region and all of its logical sub-regions. * @param ctx enclosing task context diff --git a/runtime/legion/legion.cc b/runtime/legion/legion.cc index 07f3b9fef0..d0d137c849 100644 --- a/runtime/legion/legion.cc +++ b/runtime/legion/legion.cc @@ -5330,10 +5330,10 @@ namespace Legion { //-------------------------------------------------------------------------- LogicalRegion Runtime::create_logical_region(Context ctx, - IndexSpace index, FieldSpace fields) + IndexSpace index, FieldSpace fields, bool task_local) //-------------------------------------------------------------------------- { - return runtime->create_logical_region(ctx, index, fields); + return runtime->create_logical_region(ctx, index, fields, task_local); } //-------------------------------------------------------------------------- diff --git a/runtime/legion/legion.inl b/runtime/legion/legion.inl index e4c89c0e56..bafccc74b5 100644 --- a/runtime/legion/legion.inl +++ b/runtime/legion/legion.inl @@ -7577,11 +7577,11 @@ namespace Legion { //-------------------------------------------------------------------------- template LogicalRegionT Runtime::create_logical_region(Context ctx, - IndexSpaceT index, FieldSpace fields) + IndexSpaceT index, FieldSpace fields, bool task_local) //-------------------------------------------------------------------------- { return LogicalRegionT(create_logical_region(ctx, - IndexSpace(index), fields)); + IndexSpace(index), fields, task_local)); } //-------------------------------------------------------------------------- diff --git a/runtime/legion/legion_c.cc b/runtime/legion/legion_c.cc index 6b040e8668..b97eebe618 100644 --- a/runtime/legion/legion_c.cc +++ b/runtime/legion/legion_c.cc @@ -1515,14 +1515,16 @@ legion_logical_region_t legion_logical_region_create(legion_runtime_t runtime_, legion_context_t ctx_, legion_index_space_t index_, - legion_field_space_t fields_) + legion_field_space_t fields_, + bool task_local) { Runtime *runtime = CObjectWrapper::unwrap(runtime_); Context ctx = CObjectWrapper::unwrap(ctx_)->context(); IndexSpace index = CObjectWrapper::unwrap(index_); FieldSpace fields = CObjectWrapper::unwrap(fields_); - LogicalRegion r = runtime->create_logical_region(ctx, index, fields); + LogicalRegion r = + runtime->create_logical_region(ctx, index, fields, task_local); return CObjectWrapper::wrap(r); } diff --git a/runtime/legion/legion_c.h b/runtime/legion/legion_c.h index 532490af9c..57cef81ee6 100644 --- a/runtime/legion/legion_c.h +++ b/runtime/legion/legion_c.h @@ -1368,7 +1368,8 @@ extern "C" { legion_logical_region_create(legion_runtime_t runtime, legion_context_t ctx, legion_index_space_t index, - legion_field_space_t fields); + legion_field_space_t fields, + bool task_local); /** * @param handle Caller must have ownership of parameter `handle`. diff --git a/runtime/legion/legion_context.cc b/runtime/legion/legion_context.cc index f75df19037..437a587ee6 100644 --- a/runtime/legion/legion_context.cc +++ b/runtime/legion/legion_context.cc @@ -208,7 +208,8 @@ namespace Legion { } //-------------------------------------------------------------------------- - void TaskContext::register_region_creation(LogicalRegion handle) + void TaskContext::register_region_creation(LogicalRegion handle, + bool task_local) //-------------------------------------------------------------------------- { // Create a new logical region @@ -218,7 +219,7 @@ namespace Legion { #ifdef DEBUG_LEGION assert(created_regions.find(handle) == created_regions.end()); #endif - created_regions.insert(handle); + created_regions[handle] = task_local; add_created_region(handle); } @@ -231,7 +232,8 @@ namespace Legion { // be returning values from the utility processor { AutoLock priv_lock(privilege_lock); - std::set::iterator finder = created_regions.find(handle); + std::map::iterator finder = + created_regions.find(handle); // See if we created this region, if so remove it from the list // of created regions, otherwise add it to the list of deleted // regions to flow backwards @@ -434,18 +436,18 @@ namespace Legion { //-------------------------------------------------------------------------- void TaskContext::register_region_creations( - const std::set ®s) + const std::map ®s) //-------------------------------------------------------------------------- { AutoLock priv_lock(privilege_lock); - for (std::set::const_iterator it = regs.begin(); + for (std::map::const_iterator it = regs.begin(); it != regs.end(); it++) { #ifdef DEBUG_LEGION - assert(created_regions.find(*it) == created_regions.end()); + assert(created_regions.find(it->first) == created_regions.end()); #endif - created_regions.insert(*it); - add_created_region(*it); + created_regions[it->first] = it->second; + add_created_region(it->first); } } @@ -460,7 +462,8 @@ namespace Legion { for (std::set::const_iterator it = regs.begin(); it != regs.end(); it++) { - std::set::iterator finder = created_regions.find(*it); + std::map::iterator finder = + created_regions.find(*it); if (finder != created_regions.end()) { created_regions.erase(finder); @@ -3505,7 +3508,8 @@ namespace Legion { //-------------------------------------------------------------------------- LogicalRegion InnerContext::create_logical_region(RegionTreeForest *forest, IndexSpace index_space, - FieldSpace field_space) + FieldSpace field_space, + bool task_local) //-------------------------------------------------------------------------- { AutoRuntimeCall call(this); @@ -3522,7 +3526,7 @@ namespace Legion { forest->create_logical_region(region); // Register the creation of a top-level region with the context - register_region_creation(region); + register_region_creation(region, task_local); return region; } @@ -8135,7 +8139,8 @@ namespace Legion { //-------------------------------------------------------------------------- LogicalRegion LeafContext::create_logical_region(RegionTreeForest *forest, IndexSpace index_space, - FieldSpace field_space) + FieldSpace field_space, + bool task_local) //-------------------------------------------------------------------------- { REPORT_LEGION_ERROR(ERROR_ILLEGAL_REGION_CREATION, @@ -9350,10 +9355,12 @@ namespace Legion { //-------------------------------------------------------------------------- LogicalRegion InlineContext::create_logical_region(RegionTreeForest *forest, IndexSpace index_space, - FieldSpace field_space) + FieldSpace field_space, + bool task_local) //-------------------------------------------------------------------------- { - return enclosing->create_logical_region(forest, index_space, field_space); + return enclosing->create_logical_region(forest, index_space, field_space, + task_local); } //-------------------------------------------------------------------------- diff --git a/runtime/legion/legion_context.h b/runtime/legion/legion_context.h index 585535408e..db8c6f5809 100644 --- a/runtime/legion/legion_context.h +++ b/runtime/legion/legion_context.h @@ -246,7 +246,8 @@ namespace Legion { const std::set &to_free) = 0; virtual LogicalRegion create_logical_region(RegionTreeForest *forest, IndexSpace index_space, - FieldSpace field_space) = 0; + FieldSpace field_space, + bool task_local) = 0; virtual void destroy_logical_region(LogicalRegion handle) = 0; virtual void destroy_logical_partition(LogicalPartition handle) = 0; virtual FieldAllocator create_field_allocator(Legion::Runtime *external, @@ -385,7 +386,7 @@ namespace Legion { void log_created_requirements(void); public: // Privilege tracker methods virtual void register_region_creations( - const std::set ®ions); + const std::map ®ions); virtual void register_region_deletions( const std::set ®ions); public: @@ -409,7 +410,7 @@ namespace Legion { virtual void register_index_partition_deletions( const std::set &parts); public: - void register_region_creation(LogicalRegion handle); + void register_region_creation(LogicalRegion handle, bool task_local); void register_region_deletion(LogicalRegion handle); public: void register_field_creation(FieldSpace space, FieldID fid, bool local); @@ -848,7 +849,8 @@ namespace Legion { const std::set &to_free); virtual LogicalRegion create_logical_region(RegionTreeForest *forest, IndexSpace index_space, - FieldSpace field_space); + FieldSpace field_space, + bool task_local); virtual void destroy_logical_region(LogicalRegion handle); virtual void destroy_logical_partition(LogicalPartition handle); virtual FieldAllocator create_field_allocator(Legion::Runtime *external, @@ -1448,7 +1450,8 @@ namespace Legion { const std::set &to_free); virtual LogicalRegion create_logical_region(RegionTreeForest *forest, IndexSpace index_space, - FieldSpace field_space); + FieldSpace field_space, + bool task_local); virtual void destroy_logical_region(LogicalRegion handle); virtual void destroy_logical_partition(LogicalPartition handle); virtual FieldAllocator create_field_allocator(Legion::Runtime *external, @@ -1757,7 +1760,8 @@ namespace Legion { const std::set &to_free); virtual LogicalRegion create_logical_region(RegionTreeForest *forest, IndexSpace index_space, - FieldSpace field_space); + FieldSpace field_space, + bool task_local); virtual void destroy_logical_region(LogicalRegion handle); virtual void destroy_logical_partition(LogicalPartition handle); virtual FieldAllocator create_field_allocator(Legion::Runtime *external, diff --git a/runtime/legion/legion_tasks.cc b/runtime/legion/legion_tasks.cc index e0c24ea045..d7a4ad968c 100644 --- a/runtime/legion/legion_tasks.cc +++ b/runtime/legion/legion_tasks.cc @@ -103,10 +103,11 @@ namespace Legion { rez.serialize(created_regions.size()); if (!created_regions.empty()) { - for (std::set::const_iterator it = + for (std::map::const_iterator it = created_regions.begin(); it != created_regions.end(); it++) { - rez.serialize(*it); + rez.serialize(it->first); + rez.serialize(it->second); } } rez.serialize(deleted_regions.size()); @@ -240,12 +241,14 @@ namespace Legion { derez.deserialize(num_created_regions); if (num_created_regions > 0) { - std::set created_regions; + std::map created_regions; for (unsigned idx = 0; idx < num_created_regions; idx++) { LogicalRegion reg; + bool local; derez.deserialize(reg); - created_regions.insert(reg); + derez.deserialize(local); + created_regions[reg] = local; } target->register_region_creations(created_regions); } @@ -8733,17 +8736,17 @@ namespace Legion { //-------------------------------------------------------------------------- void SliceTask::register_region_creations( - const std::set ®s) + const std::map ®s) //-------------------------------------------------------------------------- { AutoLock o_lock(op_lock); - for (std::set::const_iterator it = regs.begin(); + for (std::map::const_iterator it = regs.begin(); it != regs.end(); it++) { #ifdef DEBUG_LEGION - assert(created_regions.find(*it) == created_regions.end()); + assert(created_regions.find(it->first) == created_regions.end()); #endif - created_regions.insert(*it); + created_regions[it->first] = it->second; } } diff --git a/runtime/legion/legion_tasks.h b/runtime/legion/legion_tasks.h index 5d9a50e831..a39737943d 100644 --- a/runtime/legion/legion_tasks.h +++ b/runtime/legion/legion_tasks.h @@ -46,7 +46,7 @@ namespace Legion { ResourceTracker& operator=(const ResourceTracker &rhs); public: virtual void register_region_creations( - const std::set ®ions) = 0; + const std::map ®ions) = 0; virtual void register_region_deletions( const std::set ®ions) = 0; public: @@ -76,7 +76,8 @@ namespace Legion { static void unpack_privilege_state(Deserializer &derez, ResourceTracker *target); protected: - std::set created_regions; + std::map created_regions; std::map, bool/*local*/> created_fields; std::set created_field_spaces; @@ -1081,7 +1082,7 @@ namespace Legion { static void handle_slice_return(Runtime *rt, Deserializer &derez); public: // Privilege tracker methods virtual void register_region_creations( - const std::set ®ions); + const std::map ®ions); virtual void register_region_deletions( const std::set ®ions); public: diff --git a/runtime/legion/runtime.cc b/runtime/legion/runtime.cc index 3baa2fcd8c..df4cc7ef8f 100644 --- a/runtime/legion/runtime.cc +++ b/runtime/legion/runtime.cc @@ -11224,13 +11224,14 @@ namespace Legion { //-------------------------------------------------------------------------- LogicalRegion Runtime::create_logical_region(Context ctx, - IndexSpace index_space, FieldSpace field_space) + IndexSpace index_space, FieldSpace field_space, bool task_local) //-------------------------------------------------------------------------- { if (ctx == DUMMY_CONTEXT) REPORT_DUMMY_CONTEXT( "Illegal dummy context create logical region!"); - return ctx->create_logical_region(forest, index_space, field_space); + return ctx->create_logical_region(forest, index_space, field_space, + task_local); } //-------------------------------------------------------------------------- diff --git a/runtime/legion/runtime.h b/runtime/legion/runtime.h index eb30d5deda..5e72ca2bbf 100644 --- a/runtime/legion/runtime.h +++ b/runtime/legion/runtime.h @@ -1840,7 +1840,7 @@ namespace Legion { const std::set &to_free); public: LogicalRegion create_logical_region(Context ctx, IndexSpace index, - FieldSpace fields); + FieldSpace fields, bool task_local); void destroy_logical_region(Context ctx, LogicalRegion handle); void destroy_logical_partition(Context ctx, LogicalPartition handle); // Called from deletion ops