Skip to content

Commit

Permalink
Merge branch 'develop' of git.nic.uoregon.edu:/gitroot/xpress-apex in…
Browse files Browse the repository at this point in the history
…to develop
  • Loading branch information
khuck committed Aug 12, 2019
2 parents a78150c + 1650ad3 commit 682773a
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 34 deletions.
1 change: 1 addition & 0 deletions cmake/tests/ompt_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
project(ompt_test)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_CXX_FLAGS}")
add_executable(ompt_test ompt_test.cpp)
96 changes: 93 additions & 3 deletions src/apex/proc_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,20 @@ namespace apex {

static bool rapl_initialized = false;
static bool nvml_initialized = false;
static bool lms_initialized = false;
static int rapl_EventSet;
static int nvml_EventSet;
static int lms_EventSet;
static std::vector<std::string> nvml_event_names;
static std::vector<std::string> lms_event_names;

void initialize_papi_events(void) {
// get the PAPI components
int num_components = PAPI_num_components();
const PAPI_component_info_t *comp_info;
bool rapl_found = false;
bool nvml_found = false;
bool lms_found = false;
// are there any components?
for (int i = 0 ; i < num_components ; i++) {
comp_info = PAPI_get_component_info(i);
Expand All @@ -75,6 +79,9 @@ void initialize_papi_events(void) {
printf("PAPI RAPL component found...\n");
if (comp_info->num_native_events == 0) {
fprintf(stderr, "No RAPL events found.\n");
if (comp_info->disabled != 0) {
fprintf(stderr, "%s.\n", comp_info->disabled_reason);
}
} else {
rapl_found = true;
}
Expand All @@ -84,6 +91,9 @@ void initialize_papi_events(void) {
printf("PAPI NVML component found...\n");
if (comp_info->num_native_events == 0) {
fprintf(stderr, "No NVML events found.\n");
if (comp_info->disabled != 0) {
fprintf(stderr, "%s.\n", comp_info->disabled_reason);
}
} else {
nvml_found = true;
int code = PAPI_NATIVE_MASK;
Expand All @@ -94,6 +104,7 @@ void initialize_papi_events(void) {
if ( retval != PAPI_OK ) fprintf( stderr, "%s %d %s %d\n", __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
char event_name[PAPI_MAX_STR_LEN];
retval = PAPI_event_code_to_name( code, event_name );
#if 0
char *ss;
// We need events that END in :power, etc.
/*
Expand Down Expand Up @@ -125,11 +136,43 @@ void initialize_papi_events(void) {
printf("Found event '%s'\n", event_name); // Report what we found.
}
*/
#else
// add all NVML events!
nvml_event_names.push_back(std::string(event_name)); // Valid! Remember the name.
//printf("Found event '%s'\n", event_name); // Report what we found.
#endif
}
}
}
if (strstr(comp_info->name, "lmsensors")) {
printf("PAPI lmsensors component found...\n");
if (comp_info->num_native_events == 0) {
fprintf(stderr, "No lmsensors events found.\n");
if (comp_info->disabled != 0) {
fprintf(stderr, "%s.\n", comp_info->disabled_reason);
}
} else {
lms_found = true;
int code = PAPI_NATIVE_MASK;
int event_modifier = PAPI_ENUM_FIRST;
for ( int ii=0; ii< comp_info->num_native_events; ii++ ) {
int retval = PAPI_enum_cmp_event( &code, event_modifier, i );
event_modifier = PAPI_ENUM_EVENTS;
if ( retval != PAPI_OK ) fprintf( stderr, "%s %d %s %d\n", __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
char event_name[PAPI_MAX_STR_LEN];
retval = PAPI_event_code_to_name( code, event_name );
// add all LMSensors events! Except the "Core" specific ones. Can be too many.
char *ss;
ss = strstr(event_name, ".Core "); // get position of this string.
if (ss == NULL) {
lms_event_names.push_back(std::string(event_name)); // Valid! Remember the name.
//printf("Found event '%s'\n", event_name); // Report what we found.
}
}
}
}
}
if (!rapl_found && !nvml_found) {
if (!rapl_found && !nvml_found && !lms_found) {
return;
}
if (rapl_found) {
Expand Down Expand Up @@ -188,14 +231,41 @@ void initialize_papi_events(void) {
}
nvml_initialized = true;
}
if (lms_found) {
lms_EventSet = PAPI_NULL;
int retval = PAPI_create_eventset(&lms_EventSet);
if (retval != PAPI_OK) {
fprintf(stderr, "Error creating PAPI eventset.\n");
return;
}
for (size_t i = 0 ; i < lms_event_names.size() ; i++) {
int event;
retval = PAPI_event_name_to_code( const_cast<char*>(lms_event_names[i].c_str()), &event );
if (retval != PAPI_OK) {
fprintf(stderr, "Error coding lm_sensors event: '%s'.\n", lms_event_names[i].c_str());
continue;
}
retval = PAPI_add_events(lms_EventSet, &event, 1);
if (retval != PAPI_OK) {
fprintf(stderr, "Error adding lm_sensors event.\n");
continue;
}
}
retval = PAPI_start(lms_EventSet);
if (retval != PAPI_OK) {
fprintf(stderr, "Error starting PAPI eventset.\n");
return;
}
lms_initialized = true;
}
}

void read_papi_power(ProcData * data) {
long long values[256] = {0LL};
if (rapl_initialized) {
int retval = PAPI_read(rapl_EventSet, values);
if (retval != PAPI_OK) {
fprintf(stderr, "Error reading PAPI eventset.\n");
fprintf(stderr, "Error reading PAPI RAPL eventset.\n");
return;
}
data->package_energy_package0 = values[0];
Expand All @@ -210,13 +280,23 @@ void read_papi_power(ProcData * data) {
if (nvml_initialized) {
int retval = PAPI_read(nvml_EventSet, values);
if (retval != PAPI_OK) {
fprintf(stderr, "Error reading PAPI eventset.\n");
fprintf(stderr, "Error reading PAPI NVML eventset.\n");
return;
}
for (size_t i = 0 ; i < nvml_event_names.size() ; i++) {
data->nvml_metrics.push_back(values[i++]);
}
}
if (lms_initialized) {
int retval = PAPI_read(lms_EventSet, values);
if (retval != PAPI_OK) {
fprintf(stderr, "Error reading PAPI lmsensors eventset.\n");
return;
}
for (size_t i = 0 ; i < lms_event_names.size() ; i++) {
data->lms_metrics.push_back(values[i++]);
}
}
return;
}

Expand Down Expand Up @@ -369,6 +449,11 @@ ProcData* ProcData::diff(ProcData const& rhs) {
d->nvml_metrics.push_back(nvml_metrics[i]);
}
}
if (lms_initialized) {
for (size_t i = 0 ; i < lms_event_names.size() ; i++) {
d->lms_metrics.push_back(lms_metrics[i]);
}
}
#endif
return d;
}
Expand Down Expand Up @@ -525,6 +610,11 @@ void ProcData::sample_values(void) {
sample_value(nvml_event_names[i].c_str(), (double)nvml_metrics[i]);
}
}
if (lms_initialized) {
for (size_t i = 0 ; i < lms_event_names.size() ; i++) {
sample_value(lms_event_names[i].c_str(), (double)lms_metrics[i]);
}
}
#endif
}

Expand Down
1 change: 1 addition & 0 deletions src/apex/proc_read.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class ProcData {
long long uncore_energy_package0;
long long uncore_energy_package1;
std::vector<long long> nvml_metrics;
std::vector<long long> lms_metrics;
#endif
//softirq 10953997190 0 1380880059 1495447920 1585783785 ...
// 15525789 0 12 661586214 0 1519806115
Expand Down
74 changes: 43 additions & 31 deletions src/apex/profiler_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ std::unordered_set<profile*> free_profiles;
return; // don't write out apex main timer
}
string shorter(action_name);
size_t maxlength = 30;
size_t maxlength = 41;
if (timer) maxlength = 52;
// to keep formatting pretty, trim any long timer names
if (shorter.size() > maxlength) {
Expand All @@ -490,7 +490,7 @@ std::unordered_set<profile*> free_profiles;
if (timer) {
screen_output << string_format("%52s", shorter.c_str()) << " : ";
} else {
screen_output << string_format("%30s", shorter.c_str()) << " : ";
screen_output << string_format("%41s", shorter.c_str()) << " : ";
}
#if defined(APEX_THROTTLE)
if (!apex_options::use_tau()) {
Expand Down Expand Up @@ -527,11 +527,21 @@ std::unordered_set<profile*> free_profiles;
csv_output << std::llround(p->get_accumulated()*
profiler::get_cpu_mhz()*1000000);
//screen_output << " --n/a-- " ;
screen_output << string_format(FORMAT_SCIENTIFIC,
(p->get_mean()*profiler::get_cpu_mhz())) << " " ;
if (p->get_mean()*profiler::get_cpu_mhz() > 10000) {
screen_output << string_format(FORMAT_SCIENTIFIC,
(p->get_mean()*profiler::get_cpu_mhz())) << " " ;
} else {
screen_output << string_format(FORMAT_PERCENT,
(p->get_mean()*profiler::get_cpu_mhz())) << " " ;
}
//screen_output << " --n/a-- " ;
screen_output << string_format(FORMAT_SCIENTIFIC,
(p->get_accumulated()*profiler::get_cpu_mhz())) << " " ;
if (p->get_accumulated()*profiler::get_cpu_mhz() > 10000) {
screen_output << string_format(FORMAT_SCIENTIFIC,
(p->get_accumulated()*profiler::get_cpu_mhz())) << " " ;
} else {
screen_output << string_format(FORMAT_PERCENT,
(p->get_accumulated()*profiler::get_cpu_mhz())) << " " ;
}
//screen_output << " --n/a-- " ;
if (task_id.get_name().compare(APEX_MAIN) == 0) {
screen_output << string_format(FORMAT_PERCENT, 100.0);
Expand All @@ -555,30 +565,26 @@ std::unordered_set<profile*> free_profiles;
screen_output << endl;
csv_output << endl;
} else {
if (action_name.find('%') == string::npos) {
screen_output << string_format(FORMAT_SCIENTIFIC,
p->get_minimum()) << " " ;
screen_output << string_format(FORMAT_SCIENTIFIC,
p->get_mean()) << " " ;
screen_output << string_format(FORMAT_SCIENTIFIC,
p->get_maximum()) << " " ;
screen_output << string_format(FORMAT_SCIENTIFIC,
p->get_accumulated()) << " " ;
screen_output << string_format(FORMAT_SCIENTIFIC,
p->get_stddev()) << " " ;
if (action_name.find('%') == string::npos && p->get_minimum() > 10000) {
screen_output << string_format(FORMAT_SCIENTIFIC, p->get_minimum()) << " " ;
} else {
screen_output << string_format(FORMAT_PERCENT, p->get_minimum()) << " " ;
}
if (action_name.find('%') == string::npos && p->get_mean() > 10000) {
screen_output << string_format(FORMAT_SCIENTIFIC, p->get_mean()) << " " ;
} else {
screen_output << string_format(FORMAT_PERCENT,
p->get_minimum()) << " " ;
screen_output << string_format(FORMAT_PERCENT,
p->get_mean()) << " " ;
screen_output << string_format(FORMAT_PERCENT,
p->get_maximum()) << " " ;
screen_output << string_format(FORMAT_PERCENT,
p->get_accumulated()) << " " ;
screen_output << string_format(FORMAT_PERCENT,
p->get_stddev()) << " " ;
screen_output << string_format(FORMAT_PERCENT, p->get_mean()) << " " ;
}
if (action_name.find('%') == string::npos && p->get_maximum() > 10000) {
screen_output << string_format(FORMAT_SCIENTIFIC, p->get_maximum()) << " " ;
} else {
screen_output << string_format(FORMAT_PERCENT, p->get_maximum()) << " " ;
}
if (action_name.find('%') == string::npos && p->get_stddev() > 10000) {
screen_output << string_format(FORMAT_SCIENTIFIC, p->get_stddev()) << " " ;
} else {
screen_output << string_format(FORMAT_PERCENT, p->get_stddev()) << " " ;
}
//screen_output << " --n/a-- " << endl;
screen_output << endl;
}
}
Expand Down Expand Up @@ -636,8 +642,10 @@ std::unordered_set<profile*> free_profiles;
}
}
if (id_vector.size() > 0) {
screen_output << "Counter : #samples "
<< "minimum | mean | maximum | total | stddev " << endl;
screen_output << "Counter : "
<< "#samples | minimum | mean | maximum | stddev " << endl;
//screen_output << "Counter : #samples | "
//<< "minimum | mean | maximum | total | stddev " << endl;
screen_output << "------------------------------------------"
<< "------------------------------------------------------" << endl;
std::sort(id_vector.begin(), id_vector.end());
Expand Down Expand Up @@ -699,7 +707,11 @@ std::unordered_set<profile*> free_profiles;
screen_output << string_format("%52s", APEX_IDLE_TIME) << " : ";
// pad with spaces for #calls, mean
screen_output << " ";
screen_output << string_format(FORMAT_SCIENTIFIC, idle_rate) << " " ;
if (idle_rate > 10000) {
screen_output << string_format(FORMAT_SCIENTIFIC, idle_rate) << " " ;
} else {
screen_output << string_format(FORMAT_PERCENT, idle_rate) << " " ;
}
screen_output << string_format(FORMAT_PERCENT,
((idle_rate/total_main)*100)) << endl;
}
Expand Down

0 comments on commit 682773a

Please sign in to comment.