Skip to content

Commit

Permalink
More papi updates
Browse files Browse the repository at this point in the history
  • Loading branch information
daboehme committed Oct 30, 2024
1 parent 5944222 commit 4658bfe
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ if (WITH_PAPI_RDPMC)
set(CALIPER_WITH_PAPI_RDPMC TRUE)
endif ()


set(WITH_ARCH "" CACHE STRING "Enable features specific to the provided archspec CPU architecture name")
if (NOT WITH_ARCH STREQUAL "")
string(TOLOWER ${WITH_ARCH} LOWER_WITH_ARCH)
Expand Down
2 changes: 1 addition & 1 deletion src/caliper/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,7 @@ struct ConfigManager::ConfigManagerImpl {
{
#ifdef CALIPER_HAVE_PAPI
#ifdef CALIPER_HAVE_ARCH
if (CALIPER_HAVE_ARCH == "sapphirerapids") {
if (std::string(CALIPER_HAVE_ARCH) == "sapphirerapids") {
builtin_option_specs_list.push_back(builtin_papi_spr_option_specs);
} else {
builtin_option_specs_list.push_back(builtin_papi_hsw_option_specs);
Expand Down
26 changes: 15 additions & 11 deletions src/services/papi/Papi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class PapiService
Attribute m_thread_attr;

bool m_enable_multiplex;
bool m_disable_multiplex;

unsigned m_num_eventsets;
unsigned m_num_event_mismatch;
Expand Down Expand Up @@ -366,9 +365,8 @@ class PapiService
<< m_num_threads << " thread(s)." << std::endl;
}

PapiService(Caliper* c, Channel* channel)
: m_enable_multiplex(false),
m_disable_multiplex(false),
PapiService(Caliper* c, Channel* channel, bool use_multiplex)
: m_enable_multiplex(use_multiplex),
m_num_eventsets(0),
m_num_event_mismatch(0),
m_num_failed_acquire(0),
Expand All @@ -385,7 +383,7 @@ class PapiService
);
}

static bool init_papi_library()
static bool init_papi_library(bool use_multiplex)
{
if (PAPI_is_initialized() == PAPI_THREAD_LEVEL_INITED)
return true;
Expand All @@ -398,7 +396,13 @@ class PapiService
return false;
}

PAPI_multiplex_init();
if (use_multiplex) {
Log(2).stream() << "papi: Enabling multiplexing\n";
PAPI_multiplex_init();
} else {
Log(2).stream() << "papi: Disabling multiplexing\n";
}

PAPI_thread_init(pthread_self);

if (PAPI_is_initialized() == PAPI_NOT_INITED) {
Expand Down Expand Up @@ -435,28 +439,28 @@ class PapiService
auto cfg = services::init_config_from_spec(channel->config(), s_spec);
auto eventlist = cfg.get("counters").to_stringlist(",");

bool use_multiplex = cfg.get("enable_multiplexing").to_bool();

if (eventlist.empty()) {
Log(1).stream() << channel->name() << ": papi: No counters specified, dropping papi service" << std::endl;
return;
}

if (!init_papi_library()) {
if (!init_papi_library(use_multiplex)) {
Log(0).stream() << channel->name() << ": papi: PAPI library not initialized, dropping papi service"
<< std::endl;
return;
}

++s_num_instances;
PapiService* instance = new PapiService(c, channel);

instance->m_enable_multiplex = cfg.get("enable_multiplexing").to_bool();
instance->m_disable_multiplex = cfg.get("disable_multiplexing").to_bool();
PapiService* instance = new PapiService(c, channel, use_multiplex);

if (!(instance->setup_event_info(c, eventlist) && instance->setup_thread_eventsets(c))) {
Log(0).stream() << channel->name() << ": papi: Failed to initialize event sets, dropping papi service"
<< std::endl;

finish_papi_library();
delete instance;
return;
}

Expand Down

0 comments on commit 4658bfe

Please sign in to comment.