Skip to content

Commit

Permalink
legion: Implement the rest of logic for task local regions
Browse files Browse the repository at this point in the history
  • Loading branch information
magnatelee committed Apr 20, 2018
1 parent 1370f68 commit df10108
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 5 deletions.
12 changes: 12 additions & 0 deletions runtime/legion/legion_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3527,6 +3527,13 @@ namespace Legion {
forest->create_logical_region(region);
// Register the creation of a top-level region with the context
register_region_creation(region, task_local);
if (task_local)
{
#ifdef DEBUG_LEGION
assert(local_regions.find(region) == local_regions.end());
#endif
local_regions.insert(region);
}
return region;
}

Expand Down Expand Up @@ -6255,6 +6262,11 @@ namespace Legion {
get_task_name(), get_unique_id())
// Unmap any of our mapped regions before issuing any close operations
unmap_all_regions();
// If we own any task local regions, we issue deletion operations on them.
if (!local_regions.empty())
for (std::set<LogicalRegion>::iterator it = local_regions.begin();
it != local_regions.end(); it++)
destroy_logical_region(*it);
const std::deque<InstanceSet> &physical_instances =
single_task->get_physical_instances();
// Note that this loop doesn't handle create regions
Expand Down
3 changes: 3 additions & 0 deletions runtime/legion/legion_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,9 @@ namespace Legion {
// Track information for locally allocated fields
mutable LocalLock local_field_lock;
std::map<FieldSpace,std::vector<LocalFieldInfo> > local_fields;
protected:
// Track information for locally created regions
std::set<LogicalRegion> local_regions;
};

/**
Expand Down
36 changes: 31 additions & 5 deletions runtime/legion/legion_tasks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,40 @@ namespace Legion {
// Shouldn't need the lock here since we only do this
// while there is no one else executing
RezCheck z(rez);
rez.serialize<size_t>(created_regions.size());
if (!created_regions.empty())
if (returning)
{
// Only non-local task regions get returned
size_t non_local = 0;
for (std::map<LogicalRegion,bool>::const_iterator it =
created_regions.begin(); it != created_regions.end(); it++)
created_regions.begin(); it != created_regions.end(); it++)
{
rez.serialize(it->first);
rez.serialize<bool>(it->second);
if (it->second)
continue;
non_local++;
}
rez.serialize(non_local);
if (non_local > 0)
{
for (std::map<LogicalRegion,bool>::const_iterator it =
created_regions.begin(); it != created_regions.end(); it++)
if (!it->second)
{
rez.serialize(it->first);
rez.serialize<bool>(it->second);
}
}
}
else
{
rez.serialize<size_t>(created_regions.size());
if (!created_regions.empty())
{
for (std::map<LogicalRegion,bool>::const_iterator it =
created_regions.begin(); it != created_regions.end(); it++)
{
rez.serialize(it->first);
rez.serialize<bool>(it->second);
}
}
}
rez.serialize<size_t>(deleted_regions.size());
Expand Down

0 comments on commit df10108

Please sign in to comment.