Skip to content

Commit

Permalink
legion: Groundwork for capturing execution contexts for leaf tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
magnatelee committed May 22, 2018
1 parent 0c7be75 commit 891e7b0
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 1 deletion.
65 changes: 65 additions & 0 deletions runtime/legion/legion_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,51 @@ namespace Legion {
return false;
}

//--------------------------------------------------------------------------
void TaskContext::repurpose_context(SingleTask *new_owner_task)
//--------------------------------------------------------------------------
{
#ifdef DEBUG_LEGION
assert(new_owner_task->is_leaf());
assert(owner_task->task_id == new_owner_task->task_id);
assert(regions == new_owner_task->regions);
#endif
created_requirements.clear();
returnable_privileges.clear();
executing_processor = Processor::NO_PROC;
total_tunable_count = 0;
overhead_tracker = NULL;
task_executed = false;
has_inline_accessor = false;
mutable_priority = false;
children_complete_invoked = false;
children_commit_invoked = false;
task_local_variables.clear();
safe_cast_spaces.clear();

owner_task = new_owner_task;
const std::deque<InstanceSet>& physical_instances =
new_owner_task->get_physical_instances();
const std::vector<bool> &no_access_regions =
new_owner_task->get_no_access_regions();
#ifdef DEBUG_LEGION
std::vector<bool> virtual_mapped;
new_owner_task->clone_virtual_mapped(virtual_mapped);
#endif
for (unsigned idx = 0; idx < physical_regions.size(); idx++)
{
#ifdef DEBUG_LEGION
assert(!virtual_mapped[idx]);
#endif
bool mapped = !no_access_regions[idx];
PhysicalRegionImpl *impl = physical_regions[idx].impl;
impl->reset_physical_region(ApEvent::NO_AP_EVENT, mapped);
if (mapped)
impl->reset_references(physical_instances[idx],
Runtime::create_ap_user_event());
}
}

//--------------------------------------------------------------------------
void TaskContext::add_physical_region(const RegionRequirement &req,
bool mapped, MapperID mid, MappingTagID tag,
Expand Down Expand Up @@ -5780,6 +5825,13 @@ namespace Legion {
current_priority = priority;
}

//--------------------------------------------------------------------------
void InnerContext::repurpose_context(SingleTask *new_owner_task)
//--------------------------------------------------------------------------
{
assert(false);
}

//--------------------------------------------------------------------------
void InnerContext::configure_context(MapperManager *mapper, TaskPriority p)
//--------------------------------------------------------------------------
Expand Down Expand Up @@ -8961,6 +9013,13 @@ namespace Legion {
assert(false);
}

//--------------------------------------------------------------------------
void LeafContext::repurpose_context(SingleTask *new_owner_task)
//--------------------------------------------------------------------------
{
TaskContext::repurpose_context(new_owner_task);
}

/////////////////////////////////////////////////////////////
// Inline Context
/////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -10029,6 +10088,12 @@ namespace Legion {
enclosing->set_current_priority(priority);
}

//--------------------------------------------------------------------------
void InlineContext::repurpose_context(SingleTask *new_owner_task)
//--------------------------------------------------------------------------
{
assert(false);
}
};
};

Expand Down
10 changes: 9 additions & 1 deletion runtime/legion/legion_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ namespace Legion {
public:
virtual TaskPriority get_current_priority(void) const = 0;
virtual void set_current_priority(TaskPriority priority) = 0;
public:
virtual void repurpose_context(SingleTask *new_owner_task);
public:
PhysicalRegion get_physical_region(unsigned idx);
void get_physical_references(unsigned idx, InstanceSet &refs);
Expand Down Expand Up @@ -515,7 +517,7 @@ namespace Legion {
void (*destructor)(void*));
public:
Runtime *const runtime;
TaskOp *const owner_task;
TaskOp *owner_task;
const std::vector<RegionRequirement> &regions;
protected:
// For profiling information
Expand Down Expand Up @@ -1006,6 +1008,8 @@ namespace Legion {
public:
virtual TaskPriority get_current_priority(void) const;
virtual void set_current_priority(TaskPriority priority);
public:
virtual void repurpose_context(SingleTask *new_owner_task);
public:
static void handle_version_owner_request(Deserializer &derez,
Runtime *runtime, AddressSpaceID source);
Expand Down Expand Up @@ -1598,6 +1602,8 @@ namespace Legion {
public:
virtual TaskPriority get_current_priority(void) const;
virtual void set_current_priority(TaskPriority priority);
public:
virtual void repurpose_context(SingleTask *new_owner_task);
};

/**
Expand Down Expand Up @@ -1909,6 +1915,8 @@ namespace Legion {
public:
virtual TaskPriority get_current_priority(void) const;
virtual void set_current_priority(TaskPriority priority);
public:
virtual void repurpose_context(SingleTask *new_owner_task);
protected:
TaskContext *const enclosing;
TaskOp *const inline_task;
Expand Down
7 changes: 7 additions & 0 deletions runtime/legion/legion_tasks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3806,6 +3806,7 @@ namespace Legion {
// If we're a leaf task and we have virtual mappings
// then it's possible for the application to do inline
// mappings which require a physical context
if (execution_context == NULL)
{
if (!variant->is_leaf() || has_virtual_instances())
{
Expand Down Expand Up @@ -3889,6 +3890,10 @@ namespace Legion {
execution_context->initialize_region_tree_contexts(clone_requirements,
unmap_events, wait_on_events, map_applied_conditions);
}
#ifdef DEBUG_LEGION
else
assert(variant->is_leaf() && !has_virtual_instances());
#endif
// Merge together all the events for the start condition
ApEvent start_condition = Runtime::merge_events(wait_on_events);
// Take all the locks in order in the proper way
Expand Down Expand Up @@ -4628,6 +4633,7 @@ namespace Legion {
void IndividualTask::deactivate(void)
//--------------------------------------------------------------------------
{
if (is_captured) return;
DETAILED_PROFILER(runtime, DEACTIVATE_INDIVIDUAL_CALL);
deactivate_single();
if (!remote_instances.empty())
Expand Down Expand Up @@ -5783,6 +5789,7 @@ namespace Legion {
void PointTask::deactivate(void)
//--------------------------------------------------------------------------
{
if (is_captured) return;
DETAILED_PROFILER(runtime, POINT_DEACTIVATE_CALL);
if (runtime->profiler != NULL)
runtime->profiler->register_slice_owner(
Expand Down
7 changes: 7 additions & 0 deletions runtime/legion/legion_tasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,11 @@ namespace Legion {
size_t res_size, bool owned) = 0;
virtual void handle_post_mapped(RtEvent pre = RtEvent::NO_RT_EVENT) = 0;
virtual void handle_misspeculation(void) = 0;
public:
TaskContext* get_execution_context(void) { return execution_context; }
public:
void set_captured(void) { is_captured = true; }
void clear_captured(void) { is_captured = false; }
protected:
// Boolean for each region saying if it is virtual mapped
std::vector<bool> virtual_mapped;
Expand All @@ -554,6 +559,8 @@ namespace Legion {
mutable bool leaf_cached, is_leaf_result;
mutable bool inner_cached, is_inner_result;
mutable bool has_virtual_instances_cached, has_virtual_instances_result;
protected:
bool is_captured;
protected:
// Profiling information
std::vector<ProfilingMeasurementID> task_profiling_requests;
Expand Down
11 changes: 11 additions & 0 deletions runtime/legion/runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1879,6 +1879,17 @@ namespace Legion {
}
}

//--------------------------------------------------------------------------
void PhysicalRegionImpl::reset_physical_region(ApEvent ready, bool m)
//--------------------------------------------------------------------------
{
ready_event = ready;
mapped = m;
valid = false;
trigger_on_unmap = false;
made_accessor = false;
}

/////////////////////////////////////////////////////////////
// Grant Impl
/////////////////////////////////////////////////////////////
Expand Down
2 changes: 2 additions & 0 deletions runtime/legion/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,8 @@ namespace Legion {
ReductionOpID redop);
void fail_bounds_check(DomainPoint p, FieldID fid, PrivilegeMode mode);
void fail_bounds_check(Domain d, FieldID fid, PrivilegeMode mode);
public:
void reset_physical_region(ApEvent ready_event, bool mapped);
public:
Runtime *const runtime;
TaskContext *const context;
Expand Down

0 comments on commit 891e7b0

Please sign in to comment.