Skip to content

Commit

Permalink
Initialize trace buffer and aggregation DB for new thread scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
daboehme committed Jun 6, 2017
1 parent 88187c4 commit 8bd37b5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/services/aggregate/Aggregate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,13 @@ class AggregateDB {
s_key_attribute_ids[it-s_key_attribute_names.begin()] = attr.id();
}
}


static void create_scope_cb(Caliper* c, cali_context_scope_t scope) {
// create new aggregation DB on thread
if (scope == CALI_SCOPE_THREAD)
acquire(c, true);
}

static void finish_cb(Caliper* c) {
Log(2).stream() << "Aggregate: max key len " << s_global_max_keylen << ", "
<< s_global_num_kernel_entries << " entries, "
Expand Down Expand Up @@ -827,6 +833,7 @@ class AggregateDB {

c->events().create_attr_evt.connect(create_attribute_cb);
c->events().post_init_evt.connect(post_init_cb);
c->events().create_scope_evt.connect(create_scope_cb);
c->events().process_snapshot.connect(process_snapshot_cb);
c->events().flush_evt.connect(flush_cb);
c->events().finish_evt.connect(finish_cb);
Expand Down
9 changes: 8 additions & 1 deletion src/services/trace/Trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,13 @@ namespace
else
Log(0).stream() << "trace: error: unknown buffer policy \"" << polname << "\"" << endl;
}


void create_scope_cb(Caliper* c, cali_context_scope_t scope) {
// init trace buffer on new threads
if (scope == CALI_SCOPE_THREAD)
acquire_tbuf(true);
}

void finish_cb(Caliper* c) {
if (dropped_snapshots > 0)
Log(1).stream() << "Trace: dropped " << dropped_snapshots << " snapshots." << endl;
Expand All @@ -312,6 +318,7 @@ namespace
return;
}

c->events().create_scope_evt.connect(&create_scope_cb);
c->events().process_snapshot.connect(&process_snapshot_cb);
c->events().flush_evt.connect(&flush_cb);
c->events().finish_evt.connect(&finish_cb);
Expand Down

0 comments on commit 8bd37b5

Please sign in to comment.