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 Nov 26, 2018
2 parents ee83889 + bc576ee commit 20f01fb
Show file tree
Hide file tree
Showing 14 changed files with 209 additions and 47 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,13 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/pkgconfig/apex.pc.in
${CMAKE_BINARY_DIR}/pkgconfig/apex.pc @ONLY)
INSTALL_FILES(/lib/pkgconfig FILES pkgconfig/apex.pc)

if (APEX_USE_WEAK_SYMBOLS)
add_definitions(-DAPEX_USE_WEAK_SYMBOLS)
else()
find_library(DYNAMICLIB dl)
set(LIBS ${LIBS} ${DYNAMICLIB})
endif (APEX_USE_WEAK_SYMBOLS)

message(INFO " Getting processor count...")
include(ProcessorCount) # how many cores at our disposal?
if(PROCESSOR_COUNT)
Expand Down
7 changes: 7 additions & 0 deletions src/apex/CMakeLists.hpx
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,13 @@ if(APEX_WITH_MSR)
hpx_libraries(${MSR_LIBRARIES})
endif()

if (APEX_USE_WEAK_SYMBOLS)
add_definitions(-DAPEX_USE_WEAK_SYMBOLS)
else()
find_library(DYNAMICLIB dl)
hpx_libraries(${DYNAMICLIB})
endif (APEX_USE_WEAK_SYMBOLS)

set(apex_sources
apex.cpp
apex_options.cpp
Expand Down
10 changes: 8 additions & 2 deletions src/apex/apex_ompt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@ class linked_timer {
std::shared_ptr<apex::task_wrapper> &parent,
bool auto_start) :
prev(p), timing(auto_start) {
tw = apex::new_task(name, task_id, parent);
if (auto_start) { this->start(); }
// No GUIDs generated by the runtime? Generate our own.
if (task_id == 0ULL) {
tw = apex::new_task(name);
} else {
tw = apex::new_task(name, task_id, parent);
}
if (auto_start) { this->start();
}
}
/* destructor */
~linked_timer() {
Expand Down
4 changes: 2 additions & 2 deletions src/apex/concurrency_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ bool concurrency_handler::_handler(void) {
apex* inst = apex::instance();
if (inst == nullptr) return false; // running after finalization!
if (apex_options::use_tau()) {
Tau_start("concurrency_handler::_handler");
tau_listener::Tau_start_wrapper("concurrency_handler::_handler");
}
map<task_identifier, unsigned int> *counts = new(map<task_identifier,
unsigned int>);
Expand Down Expand Up @@ -119,7 +119,7 @@ bool concurrency_handler::_handler(void) {
_power_samples.push_back(power);
}
if (apex_options::use_tau()) {
Tau_stop("concurrency_handler::_handler");
tau_listener::Tau_stop_wrapper("concurrency_handler::_handler");
}
#ifdef APEX_WITH_JUPYTER_SUPPORT
// update the timeout, if the user changed it.
Expand Down
42 changes: 26 additions & 16 deletions src/apex/otf2_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ namespace apex {
if (evt_writer == nullptr && create) {
// should already be locked by the "new thread" event.
uint64_t my_node_id = my_saved_node_id;
my_node_id = (my_node_id << 32) + thread_instance::get_id();
//my_node_id = (my_node_id << 32) + thread_instance::get_id();
my_node_id = (my_node_id << 32) + _event_threads.size();
evt_writer = OTF2_Archive_GetEvtWriter( archive, my_node_id );
if (thread_instance::get_id() == 0) {
comm_evt_writer = evt_writer;
Expand Down Expand Up @@ -570,11 +571,12 @@ namespace apex {
uint64_t map_size = global_region_indices.size();
OTF2_IdMap * my_map = OTF2_IdMap_CreateFromUint64Array(map_size,
mappings, false);
for (int i = 0 ; i < thread_instance::get_num_threads() ; i++) {
if (event_file_exists(i)) {
//for (int i = 0 ; i < thread_instance::get_num_threads() ; i++) {
for (size_t i = 0 ; i < _event_threads.size() ; i++) {
//if (event_file_exists(i)) {
OTF2_DefWriter_WriteMappingTable(getDefWriter(i),
OTF2_MAPPING_REGION, my_map);
}
//}
}
// free the map
OTF2_IdMap_Free(my_map);
Expand All @@ -598,11 +600,12 @@ namespace apex {
uint64_t map_size = global_metric_indices.size();
OTF2_IdMap * my_map = OTF2_IdMap_CreateFromUint64Array(map_size,
mappings, false);
for (int i = 0 ; i < thread_instance::get_num_threads() ; i++) {
if (event_file_exists(i)) {
//for (int i = 0 ; i < thread_instance::get_num_threads() ; i++) {
for (size_t i = 0 ; i < _event_threads.size() ; i++) {
//if (event_file_exists(i)) {
OTF2_DefWriter_WriteMappingTable(getDefWriter(i),
OTF2_MAPPING_METRIC, my_map);
}
//}
}
// free the map
OTF2_IdMap_Free(my_map);
Expand Down Expand Up @@ -717,7 +720,8 @@ namespace apex {
/* if we are node 0, write the global definitions */
if (my_saved_node_id == 0) {
// save my number of threads
rank_thread_map[0] = thread_instance::get_num_threads();
//rank_thread_map[0] = thread_instance::get_num_threads();
rank_thread_map[0] = _event_threads.size();
std::cout << "Writing OTF2 definition files..." << std::endl;
// make a common list of regions and metrics across all nodes...
reduce_regions();
Expand Down Expand Up @@ -800,12 +804,13 @@ namespace apex {
// write out the counter names we saw
reduce_metrics();
}
for (int i = 0 ; i < thread_instance::get_num_threads() ; i++) {
//for (int i = 0 ; i < thread_instance::get_num_threads() ; i++) {
for (size_t i = 0 ; i < _event_threads.size() ; i++) {
/* close (and possibly create) the definition files */
if (event_file_exists(i)) {
//if (event_file_exists(i)) {
OTF2_EC(OTF2_Archive_CloseDefWriter( archive,
getDefWriter(i) ));
}
//}
}
if (my_saved_node_id == 0) {
std::cout << "Closing the archive..." << std::endl;
Expand Down Expand Up @@ -983,7 +988,8 @@ namespace apex {
// create an attribute list
OTF2_AttributeList * al = OTF2_AttributeList_New();
// create an attribute
OTF2_AttributeList_AddUint64( al, 0, p->guid );
OTF2_AttributeList_AddUint64( al, 0, p->tt_ptr->guid );
OTF2_AttributeList_AddUint64( al, 1, p->tt_ptr->parent_guid );
// unfortunately, we can't use the timestamp from the
// profiler object. bummer. it has to be taken after
// the lock is acquired, so that events happen on
Expand Down Expand Up @@ -1184,7 +1190,8 @@ namespace apex {
std::string otf2_listener::write_my_regions(void) {
stringstream region_file;
// first, output our number of threads.
region_file << thread_instance::get_num_threads() << endl;
//region_file << thread_instance::get_num_threads() << endl;
region_file << _event_threads.size() << endl;
// then iterate over the regions and write them out.
for (auto const &i : global_region_indices) {
task_identifier id = i.first;
Expand Down Expand Up @@ -1323,7 +1330,8 @@ namespace apex {
std::string otf2_listener::write_my_metrics(void) {
stringstream metric_file;
// first, output our number of threads.
metric_file << thread_instance::get_num_threads() << endl;
//metric_file << thread_instance::get_num_threads() << endl;
metric_file << _event_threads.size() << endl;
// then iterate over the metrics and write them out.
for (auto const &i : global_metric_indices) {
string id = i.first;
Expand Down Expand Up @@ -1512,7 +1520,8 @@ namespace apex {
region_filename << region_filename_prefix << my_saved_node_id;
ofstream region_file(region_filename.str(), ios::out | ios::trunc );
// first, output our number of threads.
region_file << thread_instance::get_num_threads() << endl;
//region_file << thread_instance::get_num_threads() << endl;
region_file << _event_threads.size() << endl;
// then iterate over the regions and write them out.
for (auto const &i : global_region_indices) {
task_identifier id = i.first;
Expand Down Expand Up @@ -1649,7 +1658,8 @@ namespace apex {
metric_filename << metric_filename_prefix << my_saved_node_id;
ofstream metric_file(metric_filename.str(), ios::out | ios::trunc );
// first, output our number of threads.
metric_file << thread_instance::get_num_threads() << endl;
//metric_file << thread_instance::get_num_threads() << endl;
metric_file << _event_threads.size() << endl;
// then iterate over the metrics and write them out.
for (auto const &i : global_metric_indices) {
string id = i.first;
Expand Down
4 changes: 2 additions & 2 deletions src/apex/otf2_listener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "event_listener.hpp"
#include <otf2/otf2.h>
#include <map>
#include <unordered_set>
#include <set>
#include <string>
#include <tuple>
#include <memory>
Expand All @@ -29,7 +29,7 @@ namespace apex {
std::mutex _metric_mutex;
std::mutex _comm_mutex;
std::mutex _event_set_mutex;
std::unordered_set<int> _event_threads;
std::set<int> _event_threads;
/* this is a reader/writer lock. Don't close the archive
* if other threads are writing to it. but allow concurrent
* access from the writer threads. */
Expand Down
4 changes: 2 additions & 2 deletions src/apex/policy_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ namespace apex {
this->_reset();
if (_terminate) return true;
if (apex_options::use_tau()) {
Tau_start("policy_handler::_handler");
tau_listener::Tau_start_wrapper("policy_handler::_handler");
}
periodic_event_data data;
this->on_periodic(data);
if (apex_options::use_tau()) {
Tau_stop("policy_handler::_handler");
tau_listener::Tau_stop_wrapper("policy_handler::_handler");
}
return true;
}
Expand Down
8 changes: 4 additions & 4 deletions src/apex/proc_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ void* proc_data_reader::read_proc(void * _ptw) {
_initialized = true;
}
if (apex_options::use_tau()) {
Tau_start("proc_data_reader::read_proc");
tau_listener::Tau_start_wrapper("proc_data_reader::read_proc");
}
if (done) { return nullptr; }
#ifdef APEX_HAVE_LM_SENSORS
Expand All @@ -605,7 +605,7 @@ void* proc_data_reader::read_proc(void * _ptw) {
while(ptw->wait()) {
if (done) break;
if (apex_options::use_tau()) {
Tau_start("proc_data_reader::read_proc: main loop");
tau_listener::Tau_start_wrapper("proc_data_reader::read_proc: main loop");
}
if (apex_options::use_proc_stat()) {
// take a reading
Expand All @@ -630,15 +630,15 @@ void* proc_data_reader::read_proc(void * _ptw) {
#endif

if (apex_options::use_tau()) {
Tau_stop("proc_data_reader::read_proc: main loop");
tau_listener::Tau_stop_wrapper("proc_data_reader::read_proc: main loop");
}
}
#ifdef APEX_HAVE_LM_SENSORS
delete(mysensors);
#endif

if (apex_options::use_tau()) {
Tau_stop("proc_data_reader::read_proc");
tau_listener::Tau_stop_wrapper("proc_data_reader::read_proc");
}
delete(oldData);
thread_instance::delete_instance();
Expand Down
18 changes: 9 additions & 9 deletions src/apex/profiler_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ std::unordered_set<profile*> free_profiles;
* file, or both. */
void profiler_listener::finalize_profiles(dump_event_data &data) {
if (apex_options::use_tau()) {
Tau_start("profiler_listener::finalize_profiles");
tau_listener::Tau_start_wrapper("profiler_listener::finalize_profiles");
}
// our TOTAL available time is the elapsed * the number of threads, or cores
int num_worker_threads = thread_instance::get_num_threads();
Expand Down Expand Up @@ -718,7 +718,7 @@ std::unordered_set<profile*> free_profiles;
csvfile.close();
}
if (apex_options::use_tau()) {
Tau_stop("profiler_listener::finalize_profiles");
tau_listener::Tau_stop_wrapper("profiler_listener::finalize_profiles");
}
}

Expand Down Expand Up @@ -1038,7 +1038,7 @@ node_color * get_node_color(double v,double vmin,double vmax)
_initialized = true;
}
if (apex_options::use_tau()) {
Tau_start("profiler_listener::process_profiles");
tau_listener::Tau_start_wrapper("profiler_listener::process_profiles");
}

std::shared_ptr<profiler> p;
Expand Down Expand Up @@ -1076,7 +1076,7 @@ node_color * get_node_color(double v,double vmin,double vmax)
while (!_done) {
queue_signal.wait();
if (apex_options::use_tau()) {
Tau_start("profiler_listener::process_profiles: main loop");
tau_listener::Tau_start_wrapper("profiler_listener::process_profiles: main loop");
}
{
std::unique_lock<std::mutex> queue_lock(queue_mtx);
Expand All @@ -1095,7 +1095,7 @@ node_color * get_node_color(double v,double vmin,double vmax)
}
}
if (apex_options::use_tau()) {
Tau_stop("profiler_listener::process_profiles: main loop");
tau_listener::Tau_stop_wrapper("profiler_listener::process_profiles: main loop");
}
// release the flag, and wait for the queue_signal
consumer_task_running.clear(memory_order_release);
Expand All @@ -1109,7 +1109,7 @@ node_color * get_node_color(double v,double vmin,double vmax)
#endif

if (apex_options::use_tau()) {
Tau_stop("profiler_listener::process_profiles");
tau_listener::Tau_stop_wrapper("profiler_listener::process_profiles");
}
}

Expand Down Expand Up @@ -1276,11 +1276,11 @@ if (rc != 0) cout << "PAPI error! " << name << ": " << PAPI_strerror(rc) << endl
std::unique_lock<std::mutex> queue_lock(queue_mtx);
for (unsigned int i=0; i<allqueues.size(); ++i) {
if (apex_options::use_tau()) {
Tau_start("profiler_listener::concurrent_cleanup");
tau_listener::Tau_start_wrapper("profiler_listener::concurrent_cleanup");
}
concurrent_cleanup(i);
if (apex_options::use_tau()) {
Tau_stop("profiler_listener::concurrent_cleanup");
tau_listener::Tau_stop_wrapper("profiler_listener::concurrent_cleanup");
}
}
}
Expand Down Expand Up @@ -1425,7 +1425,7 @@ if (rc != 0) cout << "PAPI error! " << name << ": " << PAPI_strerror(rc) << endl
//is_resume);
// get the right task identifier, based on whether there are aliases
profiler * p = new profiler(tt_ptr, is_resume);
p->guid = thread_instance::get_guid();
p->guid = tt_ptr->guid;
thread_instance::instance().set_current_profiler(p);
#if APEX_HAVE_PAPI
if (num_papi_counters > 0 && !apex_options::papi_suspend()) {
Expand Down
6 changes: 5 additions & 1 deletion src/apex/tau_dummy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

using namespace std;

#ifdef APEX_USE_WEAK_SYMBOLS

/* Weak symbols that are redefined if we use TAU at runtime */
extern "C" {
APEX_EXPORT APEX_WEAK_PRE int Tau_init(int, char**) APEX_WEAK_POST {
Expand All @@ -24,7 +26,7 @@ APEX_EXPORT APEX_WEAK_PRE int
APEX_EXPORT APEX_WEAK_PRE int Tau_start(const char *) APEX_WEAK_POST {return 0;}
APEX_EXPORT APEX_WEAK_PRE int Tau_stop(const char *) APEX_WEAK_POST {return 0;}
APEX_EXPORT APEX_WEAK_PRE int Tau_exit(const char*) APEX_WEAK_POST {return 0;}
APEX_EXPORT APEX_WEAK_PRE int Tau_dump(void) APEX_WEAK_POST {return 0;}
APEX_EXPORT APEX_WEAK_PRE int Tau_dump_prefix(const char*) APEX_WEAK_POST {return 0;}
APEX_EXPORT APEX_WEAK_PRE int Tau_set_node(int) APEX_WEAK_POST {return 0;}
APEX_EXPORT APEX_WEAK_PRE int
Tau_profile_exit_all_threads(void) APEX_WEAK_POST {return 0;}
Expand All @@ -35,3 +37,5 @@ APEX_EXPORT APEX_WEAK_PRE int Tau_global_stop(void) APEX_WEAK_POST {return 0;}
APEX_EXPORT APEX_WEAK_PRE int
Tau_trigger_context_event_thread(char*, double, int) APEX_WEAK_POST {return 0;}
}

#endif // APEX_USE_WEAK_SYMBOLS
Loading

0 comments on commit 20f01fb

Please sign in to comment.