From 76436499d7769162b0e9203cfe46aa2a8b0cb129 Mon Sep 17 00:00:00 2001 From: Mike Bauer Date: Mon, 29 Nov 2021 15:29:46 -0800 Subject: [PATCH 1/3] legion/tools: clean up some distributed collectable reference counting for legion gc --- runtime/legion/legion_analysis.cc | 3 ++- runtime/legion/region_tree.cc | 8 ++++++++ tools/legion_gc.py | 24 ++++++++++++++++++++---- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/runtime/legion/legion_analysis.cc b/runtime/legion/legion_analysis.cc index bdad5bce2a..e77f2401f5 100644 --- a/runtime/legion/legion_analysis.cc +++ b/runtime/legion/legion_analysis.cc @@ -8683,7 +8683,8 @@ namespace Legion { index_space_node->add_nested_resource_ref(did); } #ifdef LEGION_GC - log_garbage.info("GC Equivalence Set %lld %d", this->did, local_space); + log_garbage.info("GC Equivalence Set %lld %d", + LEGION_DISTRIBUTED_ID_FILTER(this->did), local_space); #endif } diff --git a/runtime/legion/region_tree.cc b/runtime/legion/region_tree.cc index 6c1f9d9520..3a5c60bb7c 100644 --- a/runtime/legion/region_tree.cc +++ b/runtime/legion/region_tree.cc @@ -6578,6 +6578,10 @@ namespace Legion { { // We always keep a reference on ourself until we get invalidated add_expression_reference(true/*expr tree*/); +#ifdef LEGION_GC + log_garbage.info("GC Index Expr %lld %d %lld", + LEGION_DISTRIBUTED_ID_FILTER(this->did), local_space, expr_id); +#endif } //-------------------------------------------------------------------------- @@ -6592,6 +6596,10 @@ namespace Legion { { #ifdef DEBUG_LEGION assert(!is_owner()); +#endif +#ifdef LEGION_GC + log_garbage.info("GC Index Expr %lld %d %lld", + LEGION_DISTRIBUTED_ID_FILTER(this->did), local_space, expr_id); #endif } diff --git a/tools/legion_gc.py b/tools/legion_gc.py index e5693ba05f..14f7ed4beb 100755 --- a/tools/legion_gc.py +++ b/tools/legion_gc.py @@ -537,22 +537,22 @@ def check_for_cycles_by_kind(self, assert_on_error, stack, kind): self.on_stack = True if kind == GC_REF_KIND and self.nested_gc_refs: for src,refs in iteritems(self.nested_gc_refs): - if refs is 0: + if refs == 0: continue src.check_for_cycles_by_kind(assert_on_error, stack, kind) if kind == VALID_REF_KIND and self.nested_valid_refs: for src,refs in iteritems(self.nested_valid_refs): - if refs is 0: + if refs == 0: continue src.check_for_cycles_by_kind(assert_on_error, stack, kind) if kind == REMOTE_REF_KIND and self.nested_remote_refs: for src,refs in iteritems(self.nested_remote_refs): - if refs is 0: + if refs == 0: continue src.check_for_cycles_by_kind(assert_on_error, stack, kind) if kind == RESOURCE_REF_KIND and self.nested_resource_refs: for src,refs in iteritems(self.nested_resource_refs): - if refs is 0: + if refs == 0: continue src.check_for_cycles_by_kind(assert_on_error, stack, kind) stack.pop() @@ -874,6 +874,8 @@ def post_parse(self): index_space.update_nested_references(self) for index_part in itervalues(self.index_partitions): index_part.update_nested_references(self) + for index_expr in itervalues(self.index_expressions): + index_expr.update_nested_references(self) for field_space in itervalues(self.field_spaces): field_space.update_nested_references(self) for region in itervalues(self.regions): @@ -1101,6 +1103,8 @@ def get_obj(self, did, node): return self.index_spaces[key] if key in self.index_partitions: return self.index_partitions[key] + if key in self.index_expressions: + return self.index_expressions[key] if key in self.field_spaces: return self.field_spaces[key] if key in self.regions: @@ -1137,6 +1141,9 @@ def check_for_cycles(self, assert_on_error): for did,index_part in iteritems(self.index_partitions): print("Checking for cycles in "+repr(index_part)) index_part.check_for_cycles(assert_on_error) + for did,index_expr in iteritems(self.index_expressions): + print("Checking for cycles in "+repr(index_expr)) + index_expr.check_for_cycles(assert_on_error) for did,field_space in iteritems(self.field_spaces): print("Checking for cycles in "+repr(field_space)) field_space.check_for_cycles(assert_on_error) @@ -1157,6 +1164,7 @@ def check_for_leaks(self, assert_on_error, verbose): leaked_eq_sets = 0 leaked_index_spaces = 0 leaked_index_partitions = 0 + leaked_index_expressions = 0 leaked_field_spaces = 0 leaked_regions = 0 leaked_partitions = 0 @@ -1188,6 +1196,9 @@ def check_for_leaks(self, assert_on_error, verbose): for index_part in itervalues(self.index_partitions): if not index_part.check_for_leaks(assert_on_error, verbose): leaked_index_partitions += 1 + for index_expr in itervalues(self.index_expressions): + if not index_expr.check_for_leaks(assert_on_error, verbose): + leaked_index_expressions += 1 for field_space in itervalues(self.field_spaces): if not field_space.check_for_leaks(assert_on_error, verbose): leaked_field_spaces += 1 @@ -1243,6 +1254,11 @@ def check_for_leaks(self, assert_on_error, verbose): if assert_on_error: assert False else: print(" Leaked Index Partitions: "+str(leaked_index_partitions)) + if leaked_index_expressions > 0: + print(" LEAKED INDEX EXPRESSIONS: "+str(leaked_index_expressions)) + if assert_on_error: assert False + else: + print(" Leaked Index Expressions: "+str(leaked_index_expressions)) if leaked_field_spaces > 0: print(" LEAKED FIELD SPACES: "+str(leaked_field_spaces)) if assert_on_error: assert False From afbdd1f404f17cb2535baf8aa4052f89e424716e Mon Sep 17 00:00:00 2001 From: Mike Bauer Date: Tue, 30 Nov 2021 01:48:14 -0800 Subject: [PATCH 2/3] legion: another small fix for type tags --- runtime/legion/mapper_manager.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/legion/mapper_manager.cc b/runtime/legion/mapper_manager.cc index 9b388b3b66..039b918d43 100644 --- a/runtime/legion/mapper_manager.cc +++ b/runtime/legion/mapper_manager.cc @@ -3157,14 +3157,14 @@ namespace Legion { { pause_mapper_call(ctx); Domain result = Domain::NO_DOMAIN; - const TypeTag type_tag = handle.get_type_tag(); - switch (NT_TemplateHelper::get_dim(type_tag)) + switch (NT_TemplateHelper::get_dim(handle.get_type_tag())) { #define DIMFUNC(DIM) \ case DIM: \ { \ DomainT realm_is; \ - runtime->get_index_space_domain(handle, &realm_is, type_tag); \ + const TypeTag tag = NT_TemplateHelper::encode_tag(); \ + runtime->get_index_space_domain(handle, &realm_is, tag); \ result = realm_is; \ break; \ } From f315c9b1931fd87a39da6995df151243e82543d7 Mon Sep 17 00:00:00 2001 From: Mike Bauer Date: Tue, 30 Nov 2021 15:38:58 -0800 Subject: [PATCH 3/3] legion: heapify index space expression classes for correct alignment during allocation --- runtime/legion/legion_allocation.h | 5 +++++ runtime/legion/region_tree.h | 25 ++++++++++++++++++++----- runtime/legion/runtime.cc | 10 ++++++++++ 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/runtime/legion/legion_allocation.h b/runtime/legion/legion_allocation.h index 301654289b..a232754d7a 100644 --- a/runtime/legion/legion_allocation.h +++ b/runtime/legion/legion_allocation.h @@ -136,6 +136,11 @@ namespace Legion { VARIANT_IMPL_ALLOC, LAYOUT_CONSTRAINTS_ALLOC, COPY_FILL_AGGREGATOR_ALLOC, + UNION_EXPR_ALLOC, + INTERSECTION_EXPR_ALLOC, + DIFFERENCE_EXPR_ALLOC, + INSTANCE_EXPR_ALLOC, + REMOTE_EXPR_ALLOC, LAST_ALLOC, // must be last }; diff --git a/runtime/legion/region_tree.h b/runtime/legion/region_tree.h index a3c6efedbe..74c971a145 100644 --- a/runtime/legion/region_tree.h +++ b/runtime/legion/region_tree.h @@ -1461,7 +1461,10 @@ namespace Legion { }; template - class IndexSpaceUnion : public IndexSpaceOperationT { + class IndexSpaceUnion : public IndexSpaceOperationT, + public LegionHeapify > { + public: + static const AllocationType alloc_type = UNION_EXPR_ALLOC; public: IndexSpaceUnion(const std::vector &to_union, RegionTreeForest *context); @@ -1498,7 +1501,10 @@ namespace Legion { }; template - class IndexSpaceIntersection : public IndexSpaceOperationT { + class IndexSpaceIntersection : public IndexSpaceOperationT, + public LegionHeapify > { + public: + static const AllocationType alloc_type = INTERSECTION_EXPR_ALLOC; public: IndexSpaceIntersection(const std::vector &to_inter, RegionTreeForest *context); @@ -1535,7 +1541,10 @@ namespace Legion { }; template - class IndexSpaceDifference : public IndexSpaceOperationT { + class IndexSpaceDifference : public IndexSpaceOperationT, + public LegionHeapify > { + public: + static const AllocationType alloc_type = DIFFERENCE_EXPR_ALLOC; public: IndexSpaceDifference(IndexSpaceExpression *lhs,IndexSpaceExpression *rhs, RegionTreeForest *context); @@ -1579,7 +1588,10 @@ namespace Legion { * rectangles that represent a physical instance */ template - class InstanceExpression : public IndexSpaceOperationT { + class InstanceExpression : public IndexSpaceOperationT, + public LegionHeapify > { + public: + static const AllocationType alloc_type = INSTANCE_EXPR_ALLOC; public: InstanceExpression(const Rect *rects, size_t num_rects, RegionTreeForest *context); @@ -1597,7 +1609,10 @@ namespace Legion { * A copy of an expression that lives on a remote node. */ template - class RemoteExpression : public IndexSpaceOperationT { + class RemoteExpression : public IndexSpaceOperationT, + public LegionHeapify > { + public: + static const AllocationType alloc_type = REMOTE_EXPR_ALLOC; public: RemoteExpression(RegionTreeForest *context, IndexSpaceExprID eid, DistributedID did, AddressSpaceID own, IndexSpaceOperation *op, diff --git a/runtime/legion/runtime.cc b/runtime/legion/runtime.cc index 13d339dbe4..b34322e005 100644 --- a/runtime/legion/runtime.cc +++ b/runtime/legion/runtime.cc @@ -22038,6 +22038,16 @@ namespace Legion { return "Layout Constraints"; case COPY_FILL_AGGREGATOR_ALLOC: return "Copy Fill Aggregator"; + case UNION_EXPR_ALLOC: + return "Union Index Space Expression"; + case INTERSECTION_EXPR_ALLOC: + return "Intersection Index Space Expression"; + case DIFFERENCE_EXPR_ALLOC: + return "Difference Index Space Expression"; + case INSTANCE_EXPR_ALLOC: + return "Instance Index Space Expression"; + case REMOTE_EXPR_ALLOC: + return "Remote Index Space Expression"; default: assert(false); // should never get here }