Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
khuck committed May 11, 2018
2 parents 8688f4b + ad80aec commit 3c6f892
Show file tree
Hide file tree
Showing 26 changed files with 441 additions and 203 deletions.
155 changes: 86 additions & 69 deletions src/apex/apex.cpp

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/apex/apex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "apex_options.hpp"
#include "apex_export.h"
#include <unordered_map>
#include <unordered_set>
#include "apex_cxx_shared_lock.hpp"

#ifdef APEX_HAVE_RCR
Expand Down
51 changes: 32 additions & 19 deletions src/apex/apex_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
#include <hpx/config.hpp>
#endif

#include <string>
#include <set>
#include <vector>
#include <stdint.h>
#include "apex_types.h"
#include "apex_options.hpp"
#include "apex_export.h"
Expand All @@ -26,6 +22,10 @@
#include "task_wrapper.hpp"
#include <functional>
#include <stdio.h>
#include <string>
#include <set>
#include <vector>
#include <stdint.h>

#endif /* DOXYGEN_SHOULD_SKIP_THIS */

Expand All @@ -41,6 +41,9 @@ class apex_tuning_request;
namespace apex
{

// declare a default "null" pointer for std::shared_ptr<task_wrapper>& references
static std::shared_ptr<task_wrapper> null_task_wrapper(nullptr);

// These are all static functions for the class. There should be only
// one APEX object in the process space.

Expand Down Expand Up @@ -134,7 +137,7 @@ APEX_EXPORT profiler * start(const std::string &timer_name);
call when the timer should be stopped.
\sa @ref apex::stop, @ref apex::yield, @ref apex::resume
*/
APEX_EXPORT profiler * start(apex_function_address function_address);
APEX_EXPORT profiler * start(const apex_function_address function_address);

/**
\brief Start a timer.
Expand All @@ -153,7 +156,7 @@ APEX_EXPORT profiler * start(apex_function_address function_address);
call when the timer should be stopped.
\sa @ref apex::stop, @ref apex::yield, @ref apex::resume @ref apex::new_task
*/
APEX_EXPORT profiler * start(task_wrapper * task_wrapper_ptr);
APEX_EXPORT profiler * start(std::shared_ptr<task_wrapper> &task_wrapper_ptr);

/**
\brief Stop a timer.
Expand All @@ -166,7 +169,7 @@ APEX_EXPORT profiler * start(task_wrapper * task_wrapper_ptr);
\return No return value.
\sa @ref apex::start, @ref apex::yield, @ref apex::resume
*/
APEX_EXPORT void stop(profiler * the_profiler);
APEX_EXPORT void stop(profiler * the_profiler, bool cleanup=true);

/**
\brief Stop a timer.
Expand All @@ -179,7 +182,7 @@ APEX_EXPORT void stop(profiler * the_profiler);
\return No return value.
\sa @ref apex::start, @ref apex::yield, @ref apex::resume, @ref apex::new_task
*/
APEX_EXPORT void stop(task_wrapper * task_wrapper_ptr);
APEX_EXPORT void stop(std::shared_ptr<task_wrapper> &task_wrapper_ptr);

/**
\brief Stop a timer, but don't increment the number of calls.
Expand Down Expand Up @@ -209,7 +212,7 @@ APEX_EXPORT void yield(profiler * the_profiler);
\return No return value.
\sa @ref apex::start, @ref apex::stop, @ref apex::resume
*/
APEX_EXPORT void yield(task_wrapper * task_wrapper_ptr);
APEX_EXPORT void yield(std::shared_ptr<task_wrapper> &task_wrapper_ptr);

/**
\brief Resume a timer.
Expand Down Expand Up @@ -247,7 +250,7 @@ APEX_EXPORT profiler * resume(const std::string &timer_name);
call when the timer should be stopped.
\sa apex::stop, apex::yield, apex::start
*/
APEX_EXPORT profiler * resume(apex_function_address function_address);
APEX_EXPORT profiler * resume(const apex_function_address function_address);

/**
\brief Resume a timer.
Expand All @@ -269,7 +272,7 @@ APEX_EXPORT profiler * resume(apex_function_address function_address);
call when the timer should be stopped.
\sa apex::stop, apex::yield, apex::start
*/
APEX_EXPORT profiler * resume(task_wrapper * task_wrapper_ptr);
APEX_EXPORT profiler * resume(std::shared_ptr<task_wrapper> &task_wrapper_ptr);

/*
* Functions for resetting timer values
Expand Down Expand Up @@ -336,7 +339,10 @@ APEX_EXPORT void sample_value(const std::string &name, double value);
\return pointer to an apex::task_wrapper object
*/

APEX_EXPORT task_wrapper * new_task(const std::string &name, uint64_t task_id = UINTMAX_MAX, apex::task_wrapper * parent_task = nullptr);
APEX_EXPORT std::shared_ptr<task_wrapper> new_task(
const std::string &name,
const uint64_t task_id = UINTMAX_MAX,
const std::shared_ptr<apex::task_wrapper> &parent_task = null_task_wrapper);

/**
\brief Create a new task (dependency).
Expand All @@ -349,7 +355,10 @@ APEX_EXPORT task_wrapper * new_task(const std::string &name, uint64_t task_id =
\return pointer to an apex::task_wrapper object
*/

APEX_EXPORT task_wrapper * new_task(apex_function_address function_address, uint64_t task_id = UINTMAX_MAX, apex::task_wrapper * parent_task = nullptr);
APEX_EXPORT std::shared_ptr<task_wrapper> new_task(
const apex_function_address function_address,
const uint64_t task_id = UINTMAX_MAX,
const std::shared_ptr<apex::task_wrapper> &parent_task = null_task_wrapper);

/**
\brief Update a task (dependency).
Expand All @@ -360,7 +369,9 @@ APEX_EXPORT task_wrapper * new_task(apex_function_address function_address, uint
\param name The new name of the timer.
*/

APEX_EXPORT task_wrapper * update_task(task_wrapper * wrapper, const std::string &name);
APEX_EXPORT std::shared_ptr<task_wrapper> update_task(
std::shared_ptr<task_wrapper> &wrapper,
const std::string &name);

/**
\brief Update a task wrapper (dependency).
Expand All @@ -371,7 +382,9 @@ APEX_EXPORT task_wrapper * update_task(task_wrapper * wrapper, const std::string
\param function_address The new function address of the timer.
*/

APEX_EXPORT task_wrapper * update_task(task_wrapper * wrapper, apex_function_address function_address);
APEX_EXPORT std::shared_ptr<task_wrapper> update_task(
std::shared_ptr<task_wrapper> &wrapper,
const apex_function_address function_address);

/**
\brief Register an event type with APEX.
Expand Down Expand Up @@ -807,7 +820,7 @@ APEX_EXPORT void recv (uint64_t tag, uint64_t size, uint64_t source_rank, uint64
*/
class scoped_timer {
private:
apex::task_wrapper * twp;
std::shared_ptr<apex::task_wrapper> twp;
public:
/**
\brief Construct and start an APEX timer.
Expand All @@ -833,7 +846,7 @@ class scoped_timer {
\param func The address of a function used to identify the timer type
\param thread_name The name of this new worker thread in the runtime
*/
scoped_timer(uint64_t func, apex::task_wrapper * parent)
scoped_timer(uint64_t func, std::shared_ptr<apex::task_wrapper> parent)
: twp(nullptr) {
twp = apex::new_task((apex_function_address)func, UINTMAX_MAX, parent);
apex::start(twp);
Expand All @@ -844,7 +857,7 @@ class scoped_timer {
\param func The name of a function used to identify the timer type
\param thread_name The name of this new worker thread in the runtime
*/
scoped_timer(std::string func, apex::task_wrapper * parent)
scoped_timer(std::string func, std::shared_ptr<apex::task_wrapper> parent)
: twp(nullptr) {
twp = apex::new_task(func, UINTMAX_MAX, parent);
apex::start(twp);
Expand All @@ -870,7 +883,7 @@ class scoped_timer {
/*
\brief Get the internal task wrapper object
*/
apex::task_wrapper * get_task_wrapper(void) {
std::shared_ptr<apex::task_wrapper> get_task_wrapper(void) {
return twp;
}
};
Expand Down
8 changes: 4 additions & 4 deletions src/apex/concurrency_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ bool concurrency_handler::common_start(task_identifier *id) {
}
}

bool concurrency_handler::on_start(task_wrapper * tt_ptr) {
return common_start(tt_ptr->task_id);
bool concurrency_handler::on_start(std::shared_ptr<task_wrapper> &tt_ptr) {
return common_start(tt_ptr->get_task_id());
}

bool concurrency_handler::on_resume(task_wrapper * tt_ptr) {
return common_start(tt_ptr->task_id);
bool concurrency_handler::on_resume(std::shared_ptr<task_wrapper> &tt_ptr) {
return common_start(tt_ptr->get_task_id());
}

void concurrency_handler::common_stop(std::shared_ptr<profiler> &p) {
Expand Down
7 changes: 3 additions & 4 deletions src/apex/concurrency_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,12 @@ class concurrency_handler : public handler, public event_listener {
void on_new_node(node_event_data &data) { APEX_UNUSED(data); };
void on_new_thread(new_thread_event_data &data);
void on_exit_thread(event_data &data);
bool on_start(task_wrapper * tt_ptr);
bool on_start(std::shared_ptr<task_wrapper> &tt_ptr);
void on_stop(std::shared_ptr<profiler> &p);
void on_yield(std::shared_ptr<profiler> &p);
bool on_resume(task_wrapper * tt_ptr);
void on_new_task(task_wrapper * tt_ptr, task_wrapper * parent_ptr) {
bool on_resume(std::shared_ptr<task_wrapper> &tt_ptr);
void on_task_complete(std::shared_ptr<task_wrapper> &tt_ptr) {
APEX_UNUSED(tt_ptr);
APEX_UNUSED(parent_ptr);
};
void on_sample_value(sample_value_event_data &data) { APEX_UNUSED(data); };
void on_periodic(periodic_event_data &data) { APEX_UNUSED(data); };
Expand Down
2 changes: 1 addition & 1 deletion src/apex/event_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ timer_event_data::timer_event_data(task_identifier * id) : task_id(id) {

/* this object never actually gets instantiated. too much overhead. */
timer_event_data::timer_event_data(std::shared_ptr<profiler> &the_profiler) : my_profiler(the_profiler) {
this->task_id = the_profiler->task_id;
this->task_id = the_profiler->tt_ptr->get_task_id();
}

timer_event_data::~timer_event_data() {
Expand Down
6 changes: 3 additions & 3 deletions src/apex/event_listener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ class event_listener
virtual void on_new_node(node_event_data &data) = 0;
virtual void on_new_thread(new_thread_event_data &data) = 0;
virtual void on_exit_thread(event_data &data) = 0;
virtual bool on_start(task_wrapper * tt_ptr) = 0;
virtual bool on_start(std::shared_ptr<task_wrapper> &tt_ptr) = 0;
virtual void on_stop(std::shared_ptr<profiler> &p) = 0;
virtual void on_yield(std::shared_ptr<profiler> &p) = 0;
virtual bool on_resume(task_wrapper * tt_ptr) = 0;
virtual void on_new_task(task_wrapper * tt_ptr, task_wrapper * parent_ptr) = 0;
virtual bool on_resume(std::shared_ptr<task_wrapper> &tt_ptr) = 0;
virtual void on_task_complete(std::shared_ptr<task_wrapper> &tt_ptr) = 0;
virtual void on_sample_value(sample_value_event_data &data) = 0;
virtual void on_periodic(periodic_event_data &data) = 0;
virtual void on_custom_event(custom_event_data &data) = 0;
Expand Down
10 changes: 5 additions & 5 deletions src/apex/otf2_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,8 +812,8 @@ namespace apex {
return;
}

bool otf2_listener::on_start(task_wrapper * tt_ptr) {
task_identifier * id = tt_ptr->task_id;
bool otf2_listener::on_start(std::shared_ptr<task_wrapper> &tt_ptr) {
task_identifier * id = tt_ptr->get_task_id();
// don't close the archive on us!
read_lock_type lock(_archive_mutex);
// not likely, but just in case...
Expand Down Expand Up @@ -849,7 +849,7 @@ namespace apex {
return false;
}

bool otf2_listener::on_resume(task_wrapper * tt_ptr) {
bool otf2_listener::on_resume(std::shared_ptr<task_wrapper> &tt_ptr) {
return on_start(tt_ptr);
}

Expand All @@ -865,7 +865,7 @@ namespace apex {
// create an attribute
OTF2_AttributeList_AddUint64( al, 0, p->guid );
if (thread_instance::get_id() == 0) {
uint64_t idx = get_region_index(p->task_id);
uint64_t idx = get_region_index(p->get_task_id());
// Because the event writer for thread 0 is also
// used for communication events and sampled values,
// we have to get a lock for it.
Expand All @@ -879,7 +879,7 @@ namespace apex {
} else {
uint64_t stamp = get_time();
OTF2_EC(OTF2_EvtWriter_Leave( local_evt_writer, al, stamp,
get_region_index(p->task_id) /* region */ ));
get_region_index(p->get_task_id()) /* region */ ));
}
// delete the attribute list
OTF2_AttributeList_Delete(al);
Expand Down
7 changes: 3 additions & 4 deletions src/apex/otf2_listener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,13 @@ namespace apex {
void on_new_node(node_event_data &data);
void on_new_thread(new_thread_event_data &data);
void on_exit_thread(event_data &data);
bool on_start(task_wrapper * tt_ptr);
bool on_start(std::shared_ptr<task_wrapper> &tt_ptr);
void on_stop(std::shared_ptr<profiler> &p);
void on_yield(std::shared_ptr<profiler> &p);
bool on_resume(task_wrapper * tt_ptr);
bool on_resume(std::shared_ptr<task_wrapper> &tt_ptr);
void on_sample_value(sample_value_event_data &data);
void on_new_task(task_wrapper * tt_ptr, task_wrapper * parent_ptr) {
void on_task_complete(std::shared_ptr<task_wrapper> &tt_ptr) {
APEX_UNUSED(tt_ptr);
APEX_UNUSED(parent_ptr);
};
void on_periodic(periodic_event_data &data)
{ APEX_UNUSED(data); };
Expand Down
12 changes: 6 additions & 6 deletions src/apex/policy_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,22 +442,22 @@ namespace apex {
call_policies(exit_thread_policies, (void *)&data, APEX_EXIT_THREAD);
}

bool policy_handler::on_start(task_wrapper * tt_ptr) {
call_policies(start_event_policies, (void *)tt_ptr->task_id, APEX_START_EVENT);
bool policy_handler::on_start(std::shared_ptr<task_wrapper> &tt_ptr) {
call_policies(start_event_policies, (void *)tt_ptr->get_task_id(), APEX_START_EVENT);
return true;
}

bool policy_handler::on_resume(task_wrapper * tt_ptr) {
call_policies(resume_event_policies, (void *)tt_ptr->task_id, APEX_RESUME_EVENT);
bool policy_handler::on_resume(std::shared_ptr<task_wrapper> &tt_ptr) {
call_policies(resume_event_policies, (void *)tt_ptr->get_task_id(), APEX_RESUME_EVENT);
return true;
}

void policy_handler::on_stop(std::shared_ptr<profiler> &p) {
call_policies(stop_event_policies, (void *)p->task_id, APEX_STOP_EVENT);
call_policies(stop_event_policies, (void *)p->tt_ptr->get_task_id(), APEX_STOP_EVENT);
}

void policy_handler::on_yield(std::shared_ptr<profiler> &p) {
call_policies(yield_event_policies, (void *)p->task_id, APEX_YIELD_EVENT);
call_policies(yield_event_policies, (void *)p->tt_ptr->get_task_id(), APEX_YIELD_EVENT);
}

void policy_handler::on_sample_value(sample_value_event_data &data) {
Expand Down
7 changes: 3 additions & 4 deletions src/apex/policy_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,12 @@ class policy_handler : public handler, public event_listener
void on_new_node(node_event_data &data);
void on_new_thread(new_thread_event_data &data);
void on_exit_thread(event_data &data);
bool on_start(task_wrapper * tt_ptr);
bool on_start(std::shared_ptr<task_wrapper> &tt_ptr);
void on_stop(std::shared_ptr<profiler> &p);
void on_yield(std::shared_ptr<profiler> &p);
bool on_resume(task_wrapper * tt_ptr);
void on_new_task(task_wrapper * tt_ptr, task_wrapper * parent_ptr) {
bool on_resume(std::shared_ptr<task_wrapper> &tt_ptr);
void on_task_complete(std::shared_ptr<task_wrapper> &tt_ptr) {
APEX_UNUSED(tt_ptr);
APEX_UNUSED(parent_ptr);
};
void on_sample_value(sample_value_event_data &data);
void on_custom_event(custom_event_data &data);
Expand Down
Loading

0 comments on commit 3c6f892

Please sign in to comment.