Skip to content

Commit

Permalink
Adding delayed start and max measurement
Browse files Browse the repository at this point in the history
Adding APEX_START_DELAY_SECONDS option and APEX_MAX_DURATION_SECONDS
to specify a delayed start of measurement, and a max length to measure.
The max length does not include delayed time.  So a delay of 1
seconds and a max length of 2 seconds would record seconds 1-3 of an
execution.
  • Loading branch information
khuck committed Aug 4, 2021
1 parent 4be2e25 commit 5f5de28
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/apex/apex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ uint64_t init(const char * thread_name, uint64_t comm_rank,
instance->listeners[i]->on_startup(data);
}
}
handle_delayed_start();
// start accepting requests, now that all listeners are started
_initialized = true;
#if APEX_HAVE_PROC
Expand Down
2 changes: 2 additions & 0 deletions src/apex/apex_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ inline unsigned int sc_nprocessors_onln()
macro (APEX_JUPYTER_SUPPORT, use_jupyter_support, int, false) \
macro (APEX_KOKKOS_VERBOSE, use_kokkos_verbose, bool, false) \
macro (APEX_KOKKOS_TUNING, use_kokkos_tuning, bool, true) \
macro (APEX_START_DELAY_SECONDS, start_delay_seconds, int, 0) \
macro (APEX_MAX_DURATION_SECONDS, max_duration_seconds, int, 0) \

#define FOREACH_APEX_FLOAT_OPTION(macro) \
macro (APEX_SCATTERPLOT_FRACTION, scatterplot_fraction, double, 0.01) \
Expand Down
34 changes: 34 additions & 0 deletions src/apex/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include <string>
#include <vector>
#include <mutex>
#include <thread>
#include <chrono>

namespace apex {

Expand Down Expand Up @@ -530,6 +532,38 @@ uint64_t test_for_MPI_comm_size(uint64_t commsize) {
return commsize;
}

/* Thread that sleeps for a bit then enables data collection */
void threaded_start_delay() {
std::this_thread::sleep_for(
std::chrono::seconds(
apex_options::start_delay_seconds()));
// enable data collection
apex_options::suspend(false);
}

/* Thread that sleeps for a bit then disables data collection */
void threaded_stop_recording() {
std::this_thread::sleep_for(
std::chrono::seconds(
apex_options::start_delay_seconds() +
apex_options::max_duration_seconds()));
// disable data collection
apex_options::suspend(true);
}

void handle_delayed_start() {
if (apex_options::start_delay_seconds() > 0) {
// disable data collection
apex_options::suspend(true);
static std::thread delayed_start(threaded_start_delay);
delayed_start.detach();
}
if (apex_options::max_duration_seconds() > 0) {
static std::thread stop_recording(threaded_stop_recording);
stop_recording.detach();
}
}

std::string activity_to_string(apex_async_activity_t activity) {
static std::string kernel{"Compute"};
static std::string memory{"Memory"};
Expand Down
1 change: 1 addition & 0 deletions src/apex/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ inline char filesystem_separator()

uint64_t test_for_MPI_comm_rank(uint64_t commrank);
uint64_t test_for_MPI_comm_size(uint64_t commsize);
void handle_delayed_start(void);

std::string activity_to_string(apex_async_activity_t activity);

Expand Down

0 comments on commit 5f5de28

Please sign in to comment.