From 346c66bd04ca510bf52d4f6d071474babf10ed81 Mon Sep 17 00:00:00 2001 From: Kevin Huck Date: Thu, 5 Dec 2019 13:08:01 -0800 Subject: [PATCH] Yielding and restarting profiler when task is renamed. --- src/apex/apex.cpp | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/apex/apex.cpp b/src/apex/apex.cpp index a082fb31..9a6461cc 100644 --- a/src/apex/apex.cpp +++ b/src/apex/apex.cpp @@ -1114,13 +1114,19 @@ std::shared_ptr update_task( if (apex_options::suspend() == true) { return nullptr; } APEX_ASSERT(wrapper != nullptr); task_identifier * id = task_identifier::get_task_id(timer_name); + // only have to do something if the ID has changed if (id != wrapper->get_task_id()) { - wrapper->alias = id; - /*printf("%llu New alias: %s to %s\n", wrapper->guid, - wrapper->task_id->get_name().c_str(), timer_name.c_str());*/ - } - if (wrapper->prof != nullptr) { - wrapper->prof->set_task_id(wrapper->get_task_id()); + // If a profiler was already started, yield it and start a new one with the new ID + if (wrapper->prof != nullptr) { + yield(wrapper); + //wrapper->prof->set_task_id(wrapper->get_task_id()); + wrapper->alias = id; + start(wrapper); + } else { + wrapper->alias = id; + } + printf("%llu New alias: %s to %s\n", wrapper->guid, + wrapper->task_id->get_name().c_str(), timer_name.c_str()); } return wrapper; } @@ -1140,12 +1146,18 @@ std::shared_ptr update_task( task_identifier * id = task_identifier::get_task_id(function_address); wrapper = _new_task(id, UINTMAX_MAX, null_task_wrapper, instance); } else { - /*printf("%llu New alias: %s", wrapper->guid, wrapper->task_id->get_name().c_str()); - wrapper->task_id = task_identifier::get_task_id(function_address); - printf(" to %s\n", wrapper->task_id->get_name().c_str());*/ - } - if (wrapper->prof != nullptr) { - wrapper->prof->set_task_id(wrapper->get_task_id()); + task_identifier * id = task_identifier::get_task_id(function_address); + // only have to do something if the ID has changed + if (id != wrapper->get_task_id()) { + if (wrapper->prof != nullptr) { + yield(wrapper); + wrapper->alias = id; + //wrapper->prof->set_task_id(wrapper->get_task_id()); + start(wrapper); + } else { + wrapper->alias = id; + } + } } return wrapper; }