Skip to content

Commit

Permalink
Add ConfigManager config options to metadata (#512)
Browse files Browse the repository at this point in the history
* Add config options to metadata

* Use ':' in channel option attribute names

* Add test checking saved config options
  • Loading branch information
daboehme authored Oct 16, 2023
1 parent 7094755 commit 1340071
Show file tree
Hide file tree
Showing 16 changed files with 61 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/caliper/ChannelController.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class Channel;

typedef std::map<std::string, std::string> config_map_t;

typedef std::map<std::string, std::string> info_map_t;

/// \class ChannelController
/// \ingroup ControlChannelAPI
/// \brief Base class for %Caliper channel controllers
Expand All @@ -46,6 +48,9 @@ class ChannelController
/// the underlying %Caliper channel has been created.
config_map_t& config();

/// \brief Provide access to the underlying metadata info map.
info_map_t& metadata();

/// \brief Create the channel with the controller's
/// name, flags, and config map
Channel* create();
Expand Down
4 changes: 4 additions & 0 deletions include/caliper/ConfigManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ class ConfigManager
/// configuration flags that may be required.
void update_channel_config(config_map_t& config) const;

/// \brief Update the config controller's metadata
/// according to the selected options
void update_channel_metadata(info_map_t& metadata) const;

/// \brief Returns a CalQL query based on the fields in \a input
/// and option list.
///
Expand Down
28 changes: 28 additions & 0 deletions src/caliper/ChannelController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct ChannelController::ChannelControllerImpl
std::string name;
int flags;
config_map_t config;
info_map_t metadata;

Channel* channel = nullptr;

Expand All @@ -32,6 +33,25 @@ struct ChannelController::ChannelControllerImpl
}
};

namespace
{

void add_channel_metadata(Caliper& c, Channel* channel, const info_map_t& metadata)
{
for (const auto &entry : metadata) {
std::string key = channel->name();
key.append(":");
key.append(entry.first);

auto attr =
c.create_attribute(key, CALI_TYPE_STRING, CALI_ATTR_GLOBAL | CALI_ATTR_SKIP_EVENTS);

c.set(channel, attr, Variant(entry.second.c_str()));
}
}

} // namespace [anonymous]

Channel*
ChannelController::channel()
{
Expand All @@ -50,6 +70,12 @@ ChannelController::copy_config() const
return mP->config;
}

info_map_t&
ChannelController::metadata()
{
return mP->metadata;
}

Channel*
ChannelController::create()
{
Expand All @@ -76,6 +102,8 @@ ChannelController::create()

on_create(&c, mP->channel);

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

// Reset the object's channel pointer if the channel is destroyed
// behind our back (e.g., in Caliper::release())
mP->channel->events().finish_evt.connect([this](Caliper*, Channel*){
Expand Down
12 changes: 12 additions & 0 deletions src/caliper/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ ChannelController* make_basic_channel_controller(const char* name, const config_
}

opts.update_channel_config(config());
opts.update_channel_metadata(metadata());
}
};

Expand Down Expand Up @@ -510,6 +511,11 @@ struct ConfigManager::Options::OptionsImpl
append_config(config);
}

void
update_channel_metadata(info_map_t& info) {
info.insert(args.begin(), args.end());
}

std::vector< const OptionSpec::query_arg_t* >
get_enabled_query_args(const char* level) const {
std::vector< const OptionSpec::query_arg_t* > ret;
Expand Down Expand Up @@ -803,6 +809,12 @@ ConfigManager::Options::update_channel_config(config_map_t& config) const
mP->update_channel_config(config);
}

void
ConfigManager::Options::update_channel_metadata(info_map_t& metadata) const
{
mP->update_channel_metadata(metadata);
}

std::string
ConfigManager::Options::build_query(const char* level, const std::map<std::string, std::string>& in, bool use_alias) const
{
Expand Down
1 change: 1 addition & 0 deletions src/caliper/controllers/CudaActivityProfileController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class CudaActivityProfileController : public cali::ChannelController
}

opts.update_channel_config(config());
opts.update_channel_metadata(metadata());
}
};

Expand Down
1 change: 1 addition & 0 deletions src/caliper/controllers/CudaActivityReportController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class CudaActivityReportController : public cali::ChannelController
}

opts.update_channel_config(config());
opts.update_channel_metadata(metadata());
}
};

Expand Down
1 change: 1 addition & 0 deletions src/caliper/controllers/HatchetRegionProfileController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class HatchetRegionProfileController : public cali::ChannelController
}

opts.update_channel_config(config());
opts.update_channel_metadata(metadata());
}
};

Expand Down
1 change: 1 addition & 0 deletions src/caliper/controllers/HatchetSampleProfileController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class HatchetSampleProfileController : public cali::ChannelController
}

opts.update_channel_config(config());
opts.update_channel_metadata(metadata());
}
};

Expand Down
1 change: 1 addition & 0 deletions src/caliper/controllers/LoopReportController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ class LoopReportController : public cali::internal::CustomOutputController
config()["CALI_LOOP_MONITOR_TARGET_LOOPS" ] = opts.get("target_loops").to_string();

opts.update_channel_config(config());
opts.update_channel_metadata(metadata());
}
};

Expand Down
1 change: 1 addition & 0 deletions src/caliper/controllers/OpenMPReportController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class OpenMPReportController : public cali::ChannelController
}

opts.update_channel_config(config());
opts.update_channel_metadata(metadata());
}
};

Expand Down
1 change: 1 addition & 0 deletions src/caliper/controllers/ROCmActivityProfileController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class RocmActivityProfileController : public cali::ChannelController
}

opts.update_channel_config(config());
opts.update_channel_metadata(metadata());
}
};

Expand Down
1 change: 1 addition & 0 deletions src/caliper/controllers/ROCmActivityReportController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class RocmActivityReportController : public cali::ChannelController
}

opts.update_channel_config(config());
opts.update_channel_metadata(metadata());
}
};

Expand Down
1 change: 1 addition & 0 deletions src/caliper/controllers/RuntimeReportController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class RuntimeReportController : public cali::ChannelController
}

opts.update_channel_config(config());
opts.update_channel_metadata(metadata());
}
};

Expand Down
1 change: 1 addition & 0 deletions src/caliper/controllers/SampleReportController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class SampleReportController : public cali::ChannelController
}

opts.update_channel_config(config());
opts.update_channel_metadata(metadata());
}
};

Expand Down
1 change: 1 addition & 0 deletions src/caliper/controllers/SpotController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ class SpotController : public cali::internal::CustomOutputController
}

opts.update_channel_config(config());
opts.update_channel_metadata(metadata());
}
};

Expand Down
1 change: 1 addition & 0 deletions test/ci_app_tests/test_spot.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def test_spot_regionprofile(self):
self.assertEqual(r['spot.channel'], 'regionprofile')

self.assertEqual('regionprofile', obj['globals']['spot.channels'])
self.assertEqual('true', obj['globals']['spot:region.count'])

def test_spot_timeseries(self):
target_cmd = [ './ci_test_macros', '0', 'spot(output=stdout,timeseries,timeseries.iteration_interval=15)', '75' ]
Expand Down

0 comments on commit 1340071

Please sign in to comment.