Skip to content

Commit

Permalink
Some header file cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
daboehme committed Oct 30, 2024
1 parent 13bdcf5 commit 966b519
Show file tree
Hide file tree
Showing 36 changed files with 106 additions and 165 deletions.
3 changes: 1 addition & 2 deletions caliper-config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@
#cmakedefine CALIPER_HAVE_UMPIRE
#cmakedefine CALIPER_HAVE_CRAYPAT
#cmakedefine CALIPER_HAVE_LDMS
#cmakedefine CALIPER_HAVE_KOKKOS
#cmakedefine CALIPER_HAVE_ARCH "@CALIPER_HAVE_ARCH@"
#ifdef CALIPER_HAVE_PAPI
#cmakedefine CALIPER_WITH_PAPI_RDPMC
#endif

#cmakedefine CALIPER_REDUCED_CONSTEXPR_USAGE

#cmakedefine CALIPER_MPIWRAP_USE_GOTCHA

#cmakedefine CALIPER_ENABLE_HISTOGRAMS
Expand Down
1 change: 1 addition & 0 deletions examples/apps/cxx-example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ int main(int argc, char* argv[])
// The ConfigManager manages built-in or custom Caliper measurement
// configurations, and provides an API to control performance profiling.
cali::ConfigManager mgr;
mgr.set_default_parameter("aggregate_across_ranks", "false");

// Parse command-line arguments. Let users choose a Caliper performance
// profiling configuration via the "-P" command-line argument.
Expand Down
9 changes: 1 addition & 8 deletions include/caliper/AnnotationBinding.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@

#pragma once

#include "caliper/CaliperService.h"

#include "caliper/caliper-config.h"
#include "caliper/Caliper.h"
#include "caliper/CaliperService.h"

#include "caliper/common/Log.h"
#include "caliper/common/RuntimeConfig.h"

#include <iostream>
#include <memory>
Expand Down Expand Up @@ -72,15 +69,11 @@ class Node;

class AnnotationBinding
{
ConfigSet m_config;
Attribute m_marker_attr;

std::unique_ptr<RegionFilter> m_filter;

std::vector<std::string> m_trigger_attr_names;

static const ConfigSet::Entry s_configdata[];

void mark_attribute(Caliper*, Channel*, const Attribute&);
void check_attribute(Caliper*, Channel*, const Attribute&);

Expand Down
3 changes: 0 additions & 3 deletions include/caliper/Caliper.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@

#include "SnapshotRecord.h"

#include "common/Attribute.h"
#include "common/CaliperMetadataAccessInterface.h"
#include "common/Entry.h"
#include "common/Variant.h"
#include "common/callback.hpp"

#include <memory>
Expand Down
11 changes: 7 additions & 4 deletions include/caliper/ConfigManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
/// %Caliper ConfigManager class definition

#pragma once
#ifndef CALI_CONFIGMANAGER_H
#define CALI_CONFIGMANAGER_H

#include "ChannelController.h"

#include <map>
#include <memory>
#include <string>
#include <vector>

#include "ChannelController.h"

#include "common/StringConverter.h"

namespace cali
{
Expand Down Expand Up @@ -96,7 +97,7 @@ class ConfigManager

/// \brief Return the value for \a option, or \a default_value
/// if it is not set in the options list.
StringConverter get(const char* option, const char* default_value = "") const;
std::string get(const char* option, const char* default_value = "") const;

/// \brief Perform a validity check.
std::string check() const;
Expand Down Expand Up @@ -524,3 +525,5 @@ class ConfigManager
void add_global_config_specs(const ConfigManager::ConfigInfo** configs);

} // namespace cali

#endif
10 changes: 0 additions & 10 deletions include/caliper/SnapshotRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,17 @@ class SnapshotView
public:

SnapshotView() : m_data { nullptr }, m_len { 0 } {}

SnapshotView(size_t len, const Entry* data) : m_data { data }, m_len { len } {}

SnapshotView(const Entry& e) : m_data { &e }, m_len { 1 } {}

using iterator = Entry*;
using const_iterator = const Entry*;

const_iterator begin() const { return m_data; }

const_iterator end() const { return m_data + m_len; }

size_t size() const { return m_len; }

const Entry* data() const { return m_data; }

bool empty() const { return m_len == 0; }

const Entry& operator[] (std::size_t n) const { return m_data[n]; }
Expand Down Expand Up @@ -78,7 +73,6 @@ class SnapshotBuilder
public:

SnapshotBuilder() : m_data { nullptr }, m_capacity { 0 }, m_len { 0 }, m_skipped { 0 } {}

SnapshotBuilder(size_t capacity, Entry* data)
: m_data { data }, m_capacity { capacity }, m_len { 0 }, m_skipped { 0 }
{}
Expand All @@ -90,9 +84,7 @@ class SnapshotBuilder
SnapshotBuilder& operator= (const SnapshotBuilder&) = delete;

size_t capacity() const { return m_capacity; }

size_t size() const { return m_len; }

size_t skipped() const { return m_skipped; }

void append(const Entry& e)
Expand All @@ -112,7 +104,6 @@ class SnapshotBuilder
}

void append(const Attribute& attr, const Variant& val) { append(Entry(attr, val)); }

void append(SnapshotView view) { append(view.size(), view.data()); }

SnapshotView view() const { return SnapshotView { m_len, m_data }; }
Expand All @@ -133,7 +124,6 @@ class FixedSizeSnapshotRecord
FixedSizeSnapshotRecord<N> operator= (const FixedSizeSnapshotRecord<N>&) = delete;

SnapshotBuilder& builder() { return m_builder; }

SnapshotView view() const { return m_builder.view(); }

void reset() { m_builder = SnapshotBuilder(N, m_data); }
Expand Down
10 changes: 1 addition & 9 deletions include/caliper/common/Attribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
* \brief Attribute class declaration
*/

#pragma once
#ifndef CALI_ATTRIBUTE_H
#define CALI_ATTRIBUTE_H

#include "caliper/common/cali_types.h"

#include "caliper/common/Node.h"
#include "caliper/common/Variant.h"

Expand Down Expand Up @@ -45,9 +44,7 @@ class Attribute

std::string name() const;
const char* name_c_str() const;

cali_attr_type type() const;

int properties() const;

/// \brief Return the context tree node pointer that represents
Expand All @@ -57,15 +54,10 @@ class Attribute
Variant get(const Attribute& attr) const;

bool store_as_value() const { return properties() & CALI_ATTR_ASVALUE; }

bool is_autocombineable() const { return !store_as_value() && !(properties() & CALI_ATTR_NOMERGE); }

bool skip_events() const { return properties() & CALI_ATTR_SKIP_EVENTS; }

bool is_hidden() const { return properties() & CALI_ATTR_HIDDEN; }

bool is_nested() const { return properties() & CALI_ATTR_NESTED; }

bool is_global() const { return properties() & CALI_ATTR_GLOBAL; }

int level() const { return (properties() & CALI_ATTR_LEVEL_MASK) >> 16; }
Expand Down
2 changes: 0 additions & 2 deletions include/caliper/common/Node.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#ifndef CALI_NODE_H
#define CALI_NODE_H

#include "cali_types.h"

#include "lockfree-tree.hpp"
#include "Variant.h"

Expand Down
1 change: 0 additions & 1 deletion include/caliper/common/RuntimeConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class ConfigSet
class RuntimeConfig
{
struct RuntimeConfigImpl;

std::shared_ptr<RuntimeConfigImpl> mP;

public:
Expand Down
20 changes: 2 additions & 18 deletions include/caliper/common/Variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

#pragma once

#include "cali_types.h"
#include "cali_variant.h"
#include "caliper/caliper-config.h"

#include <iostream>
#include <string>
Expand Down Expand Up @@ -39,19 +37,15 @@ class Variant
Variant(const cali_variant_t& v) : m_v(v) {}

Variant(bool val) : m_v(cali_make_variant_from_bool(val)) {}

Variant(int val) : m_v(cali_make_variant_from_int(val)) {}

Variant(double val) : m_v(cali_make_variant_from_double(val)) {}
Variant(const char* val) : m_v(cali_make_variant_from_string(val)) {}
Variant(cali_attr_type val) : m_v(cali_make_variant_from_type(val)) {}

template <typename U, typename std::enable_if<std::is_unsigned<U>::value, int>::type = 0>
Variant(U val) : m_v(cali_make_variant_from_uint(val))
{}

Variant(const char* val) : m_v(cali_make_variant_from_string(val)) {}

Variant(cali_attr_type val) : m_v(cali_make_variant_from_type(val)) {}

Variant(cali_attr_type type, const void* data, std::size_t size) { m_v = cali_make_variant(type, data, size); }

bool empty() const { return (m_v.type_and_size & CALI_VARIANT_TYPE_MASK) == CALI_TYPE_INV; };
Expand All @@ -65,27 +59,17 @@ class Variant
}

cali_variant_t c_variant() const { return m_v; }

cali_attr_type type() const { return cali_variant_get_type(m_v); }

const void* data() const { return cali_variant_get_data(&m_v); }

size_t size() const { return cali_variant_get_size(m_v); }

void* get_ptr() const { return cali_variant_get_ptr(m_v); }

cali_id_t to_id(bool* okptr = nullptr) const;

int to_int(bool* okptr = nullptr) const { return cali_variant_to_int(m_v, okptr); }

int64_t to_int64(bool* okptr = nullptr) const { return cali_variant_to_int64(m_v, okptr); }

uint64_t to_uint(bool* okptr = nullptr) const { return cali_variant_to_uint(m_v, okptr); }

bool to_bool(bool* okptr = nullptr) const { return cali_variant_to_bool(m_v, okptr); }

double to_double(bool* okptr = nullptr) const { return cali_variant_to_double(m_v, okptr); }

cali_attr_type to_attr_type(bool* okptr = nullptr) const { return cali_variant_to_type(m_v, okptr); }

std::string to_string() const;
Expand Down
3 changes: 1 addition & 2 deletions include/caliper/reader/QueryProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#pragma once

#include "QuerySpec.h"
#include "RecordProcessor.h"

#include <iostream>
Expand All @@ -17,6 +16,7 @@ namespace cali

class CaliperMetadataAccessInterface;
class OutputStream;
class QuerySpec;

/// \brief Execute a given query (filter, aggregation, and output formatting)
/// on a series of snapshot records.
Expand All @@ -32,7 +32,6 @@ class QueryProcessor
~QueryProcessor();

void process_record(CaliperMetadataAccessInterface&, const EntryList&);

void flush(CaliperMetadataAccessInterface&);

void operator() (CaliperMetadataAccessInterface& db, const EntryList& rec) { process_record(db, rec); }
Expand Down
2 changes: 0 additions & 2 deletions src/caliper/Annotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
#include "caliper/Annotation.h"

#include "caliper/Caliper.h"
#include "caliper/cali.h"

#include "caliper/common/Log.h"
#include "caliper/common/Variant.h"

#include <atomic>
#include <cstring>
Expand Down
28 changes: 15 additions & 13 deletions src/caliper/AnnotationBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,24 @@

#include "caliper/common/Node.h"
#include "caliper/common/Log.h"
#include "caliper/common/RuntimeConfig.h"


using namespace cali;

//
// --- Static data
//

const cali::ConfigSet::Entry AnnotationBinding::s_configdata[] = {
namespace cali
{
extern Attribute subscription_event_attr;
}

namespace
{

const cali::ConfigSet::Entry annotation_binding_configdata[] = {
{
"include_regions",
CALI_TYPE_STRING,
Expand All @@ -40,14 +50,6 @@ const cali::ConfigSet::Entry AnnotationBinding::s_configdata[] = {
cali::ConfigSet::Terminator
};

namespace cali
{
extern Attribute subscription_event_attr;
}

namespace
{

bool has_marker(const Attribute& attr, const Attribute& marker_attr)
{
cali_id_t marker_attr_id = marker_attr.id();
Expand Down Expand Up @@ -133,11 +135,11 @@ void AnnotationBinding::base_pre_initialize(Caliper* c, Channel* chn)
const char* tag = service_tag();
std::string cfgname = std::string(tag) + "_binding";

m_config = chn->config().init(cfgname.c_str(), s_configdata);
auto cfg = chn->config().init(cfgname.c_str(), ::annotation_binding_configdata);

{
std::string i_filter = m_config.get("include_regions").to_string();
std::string e_filter = m_config.get("exclude_regions").to_string();
std::string i_filter = cfg.get("include_regions").to_string();
std::string e_filter = cfg.get("exclude_regions").to_string();

auto p = RegionFilter::from_config(i_filter, e_filter);

Expand All @@ -148,7 +150,7 @@ void AnnotationBinding::base_pre_initialize(Caliper* c, Channel* chn)
}
}

m_trigger_attr_names = m_config.get("trigger_attributes").to_stringlist(",:");
m_trigger_attr_names = cfg.get("trigger_attributes").to_stringlist(",:");

std::string marker_attr_name("cali.binding.");
marker_attr_name.append(tag);
Expand Down
5 changes: 0 additions & 5 deletions src/caliper/Blackboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@
#ifndef CALI_BLACKBOARD_H
#define CALI_BLACKBOARD_H

#include "caliper/common/Attribute.h"
#include "caliper/common/Entry.h"
#include "caliper/common/Node.h"
#include "caliper/common/Variant.h"

#include "caliper/caliper-config.h"

#include "../common/util/spinlock.hpp"

Expand Down
Loading

0 comments on commit 966b519

Please sign in to comment.