Skip to content

Commit

Permalink
Rewire active channel logic (#606)
Browse files Browse the repository at this point in the history
  • Loading branch information
daboehme authored Oct 10, 2024
1 parent f196256 commit 021716b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
19 changes: 14 additions & 5 deletions src/caliper/Caliper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,10 @@ void make_default_channel()

if (services.empty())
Log(1).stream() << "No manual config specified, disabling default channel\n";
else
c.create_channel("default", cfg);
else {
auto channel = c.create_channel("default", cfg);
c.activate_channel(channel);
}

internal::init_builtin_configmanager(&c);
}
Expand Down Expand Up @@ -180,7 +182,7 @@ struct Channel::ChannelImpl
ChannelImpl(cali_id_t _id, const char* _name, const RuntimeConfig& cfg)
: id(_id),
name(_name),
is_active(true),
is_active(false),
config(cfg)
{
ConfigSet cali_cfg =
Expand Down Expand Up @@ -335,13 +337,16 @@ struct Caliper::GlobalData
vector< Channel > all_channels;
vector< Channel > active_channels;

size_t max_active_channels;

vector< ThreadData* > thread_data;
std::mutex thread_data_lock;

// --- constructor

GlobalData(ThreadData* sT)
: attribute_default_scope { CALI_ATTR_SCOPE_THREAD }
: attribute_default_scope { CALI_ATTR_SCOPE_THREAD },
max_active_channels { 0 }
{
// put the attribute [name,type,prop] attributes in the map

Expand All @@ -362,6 +367,8 @@ struct Caliper::GlobalData
s_init_lock = 2;

if (Log::verbosity() >= 2) {
Log(2).stream() << "Releasing Caliper global data.\n"
<< " Max active channels: " << max_active_channels << std::endl;
process_blackboard.print_statistics( Log(2).stream() << "Process blackboard: " )
<< std::endl;
}
Expand Down Expand Up @@ -1343,7 +1350,6 @@ Caliper::create_channel(const char* name, const RuntimeConfig& cfg)

Channel channel(next_id++, name, cfg);
sG->all_channels.emplace_back(channel);
sG->active_channels.emplace_back(channel);

// Create and set key & version attributes
begin(&channel, create_attribute("cali.channel", CALI_TYPE_STRING,
Expand Down Expand Up @@ -1406,6 +1412,9 @@ Caliper::activate_channel(Channel& channel)
auto it = std::find(sG->active_channels.begin(), sG->active_channels.end(), channel);
if (it == sG->active_channels.end())
sG->active_channels.emplace_back(channel);

sG->max_active_channels =
std::max(sG->max_active_channels, sG->active_channels.size());
}

void
Expand Down
3 changes: 0 additions & 3 deletions src/caliper/ChannelController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ ChannelController::create()
return Channel();
}

if (mP->flags & CALI_CHANNEL_LEAVE_INACTIVE)
c.deactivate_channel(mP->channel);

on_create(&c, mP->channel);
add_channel_metadata(c, mP->channel, mP->metadata);

Expand Down
8 changes: 4 additions & 4 deletions src/caliper/cali.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,8 +708,8 @@ cali_create_channel(const char* name, int flags, cali_configset_t cfgset)

if (!channel)
return CALI_INV_ID;
if (flags & CALI_CHANNEL_LEAVE_INACTIVE)
c.deactivate_channel(channel);
if (!(flags & CALI_CHANNEL_LEAVE_INACTIVE))
c.activate_channel(channel);

return channel.id();
}
Expand Down Expand Up @@ -847,8 +847,8 @@ create_channel(const char* name, int flags, const config_map_t& cfgmap)

if (!channel)
return CALI_INV_ID;
if (flags & CALI_CHANNEL_LEAVE_INACTIVE)
c.deactivate_channel(channel);
if (!(flags & CALI_CHANNEL_LEAVE_INACTIVE))
c.activate_channel(channel);

return channel.id();
}
Expand Down

0 comments on commit 021716b

Please sign in to comment.