diff --git a/runtime/legion/legion_context.cc b/runtime/legion/legion_context.cc index 35d5f91613..ea425df476 100644 --- a/runtime/legion/legion_context.cc +++ b/runtime/legion/legion_context.cc @@ -4789,17 +4789,11 @@ namespace Legion { } if (!to_perform.empty()) { - for (std::vector::const_iterator it = + for (std::vector::iterator it = to_perform.begin(); it != to_perform.end(); it++) { - if (it->instance.exists()) - { - it->context->post_end_task(it->result, it->size, false/*owned*/); - // Once we've copied the data then we can destroy the instance - it->instance.destroy(); - } - else - it->context->post_end_task(it->result, it->size, true/*owned*/); + DeferredPostTaskArgs args(*it); + runtime->issue_runtime_meta_task(args, LG_THROUGHPUT_WORK_PRIORITY); } } if (launch_next_op != NULL) @@ -6625,6 +6619,24 @@ namespace Legion { pargs->proxy_this->process_post_end_tasks(); } + //-------------------------------------------------------------------------- + /*static*/ void InnerContext::handle_deferred_post_end_task( + const void *args) + //-------------------------------------------------------------------------- + { + const PostTaskArgs *pargs = &((const DeferredPostTaskArgs*)args)->args; + if (pargs->instance.exists()) + { + pargs->context->post_end_task( + pargs->result, pargs->size, false/*owned*/); + // Once we've copied the data then we can destroy the instance + pargs->instance.destroy(); + } + else + pargs->context->post_end_task( + pargs->result, pargs->size, true/*owned*/); + } + //-------------------------------------------------------------------------- void InnerContext::inline_child_task(TaskOp *child) //-------------------------------------------------------------------------- diff --git a/runtime/legion/legion_context.h b/runtime/legion/legion_context.h index bee7d1c915..b5a5e4cfe0 100644 --- a/runtime/legion/legion_context.h +++ b/runtime/legion/legion_context.h @@ -620,6 +620,17 @@ namespace Legion { PhysicalInstance instance; RtEvent wait_on; }; + struct DeferredPostTaskArgs : public LgTaskArgs { + public: + static const LgTaskID TASK_ID = LG_DEFERRED_POST_END_ID; + public: + DeferredPostTaskArgs(PostTaskArgs &a) + : LgTaskArgs( + a.context->owner_task->get_unique_op_id()), + args(a.context, a.result, a.size, a.instance, a.wait_on) { } + public: + PostTaskArgs args; + }; struct PostDecrementArgs : public LgTaskArgs { public: static const LgTaskID TASK_ID = LG_POST_DECREMENT_TASK_ID; @@ -1001,6 +1012,7 @@ namespace Legion { static void handle_prepipeline_stage(const void *args); static void handle_dependence_stage(const void *args); static void handle_post_end_task(const void *args); + static void handle_deferred_post_end_task(const void *args); public: void free_remote_contexts(void); void send_remote_context(AddressSpaceID remote_instance, diff --git a/runtime/legion/legion_types.h b/runtime/legion/legion_types.h index 961dd01bd4..8263183960 100644 --- a/runtime/legion/legion_types.h +++ b/runtime/legion/legion_types.h @@ -270,6 +270,7 @@ namespace Legion { LG_DEFERRED_COMPLETE_ID, LG_DEFERRED_COMMIT_ID, LG_DEFERRED_COLLECT_ID, + LG_DEFERRED_POST_END_ID, LG_PRE_PIPELINE_ID, LG_TRIGGER_DEPENDENCE_ID, LG_TRIGGER_COMPLETE_ID, diff --git a/runtime/legion/runtime.cc b/runtime/legion/runtime.cc index 0bbe8c6262..2c21af1c1d 100644 --- a/runtime/legion/runtime.cc +++ b/runtime/legion/runtime.cc @@ -19867,6 +19867,11 @@ namespace Legion { InnerContext::handle_post_end_task(args); break; } + case LG_DEFERRED_POST_END_ID: + { + InnerContext::handle_deferred_post_end_task(args); + break; + } case LG_DEFERRED_READY_TRIGGER_ID: { const Operation::DeferredReadyArgs *deferred_ready_args =