Skip to content

Commit

Permalink
Making sure flow events are unique across processes.
Browse files Browse the repository at this point in the history
  • Loading branch information
khuck committed May 12, 2023
1 parent 9f1c09a commit e09b42c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/apex/apex_ompt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1292,13 +1292,13 @@ extern "C" void apex_ompt_work (
snprintf(regionIDstr, 128, "OpenMP Work %s", tmp_str);
apex_ompt_start(regionIDstr, task_data, parallel_data, true);
}
/*
if (apex::apex_options::ompt_high_overhead_events()) {
std::stringstream ss;
ss << count_type << ": " << regionIDstr;
std::string tmp{ss.str()};
apex::sample_value(tmp, count);
}
/*
*/
} else {
DEBUG_PRINT("%" PRId64 ": %s End task: %p, region: %p\n", apex_threadid, tmp_str,
Expand Down
7 changes: 4 additions & 3 deletions src/apex/trace_event_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ void trace_event_listener::end_trace_time(void) {
void trace_event_listener::on_startup(startup_event_data &data) {
APEX_UNUSED(data);
saved_node_id = apex::instance()->get_node_id();
reversed_node_id = ((uint64_t)(simple_reverse((uint32_t)saved_node_id))) << 32;
std::stringstream ss;
ss.precision(3);
ss << fixed
Expand Down Expand Up @@ -164,7 +165,7 @@ long unsigned int trace_event_listener::get_thread_id_metadata() {
}

uint64_t get_flow_id() {
static uint64_t flow_id = 0;
static atomic<uint64_t> flow_id{0};
return ++flow_id;
}

Expand Down Expand Up @@ -201,7 +202,7 @@ inline void trace_event_listener::_common_stop(std::shared_ptr<profiler> &p) {
#endif
) {
//std::cout << "FLOWING!" << std::endl;
uint64_t flow_id = get_flow_id();
uint64_t flow_id = reversed_node_id + get_flow_id();
write_flow_event(ss, p->tt_ptr->parent->get_flow_us(), 's', "ControlFlow", flow_id,
saved_node_id, p->tt_ptr->parent->thread_id, p->tt_ptr->parent->task_id->get_name());
write_flow_event(ss, p->get_start_us(), 'f', "ControlFlow", flow_id,
Expand Down Expand Up @@ -349,7 +350,7 @@ void trace_event_listener::on_async_event(base_thread_node &node,
// write a flow event pair!
// make sure the start of the flow is before the end of the flow, ideally the middle of the parent
if (data.flow) {
uint64_t flow_id = get_flow_id();
uint64_t flow_id = reversed_node_id + get_flow_id();
if (data.reverse_flow) {
double begin_ts = (p->get_stop_us() + p->get_start_us()) * 0.5;
double end_ts = std::min(p->get_stop_us(), data.parent_ts_stop);
Expand Down
1 change: 1 addition & 0 deletions src/apex/trace_event_listener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class trace_event_listener : public event_listener {
std::stringstream * get_thread_stream(size_t index);
void write_to_trace(std::stringstream& events);
int saved_node_id;
uint64_t reversed_node_id;
std::atomic<size_t> num_events;
std::string get_file_name();
#ifdef APEX_HAVE_ZLIB
Expand Down

0 comments on commit e09b42c

Please sign in to comment.