Skip to content

Commit

Permalink
Disabling overwriting of otf2 archivePath by default by adding timest…
Browse files Browse the repository at this point in the history
…amp-related suffix
  • Loading branch information
DylanKierans committed Jul 23, 2024
1 parent 7fcfad9 commit 6cfcbcf
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 18 deletions.
5 changes: 3 additions & 2 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
#' @param max_nprocs Maximum number of R processes (ie evtWriters required)
#' @param archivePath Path to otf2 archive
#' @param archiveName Name of otf2 archive
#' @param overwrite_archivePath If true then use archivePath as prefix for directory to avoid overwriting, the suffix is generated using mkdtemp
#' @param collect_metrics Collect HWPC metrics via pmpmeas
#' @param flag_print_pids True to print pids of parent and child procs
#' @return <0 if error, 0 if R master, else >0 if child
init_otf2_logger <- function(max_nprocs, archivePath, archiveName, collect_metrics, flag_print_pids) {
.Call(`_rTrace_init_otf2_logger`, max_nprocs, archivePath, archiveName, collect_metrics, flag_print_pids)
init_otf2_logger <- function(max_nprocs, archivePath, archiveName, overwrite_archivePath, collect_metrics, flag_print_pids) {
.Call(`_rTrace_init_otf2_logger`, max_nprocs, archivePath, archiveName, overwrite_archivePath, collect_metrics, flag_print_pids)
}

#' r_pmpmeas_init
Expand Down
2 changes: 1 addition & 1 deletion R/r_instrument_hl.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ instrumentation_init <- function(flag_user_functions=T, collect_metrics=F, verbo

## Initiate new proc - close R if not Master
ret <- init_otf2_logger(parallelly::availableCores(), "rTrace", "rTrace",
collect_metrics=pkg.env$COLLECT_METRICS,
overwrite_archivePath = FALSE, collect_metrics=pkg.env$COLLECT_METRICS,
flag_print_pids=F) # Master R proc returns 0
if (ret != 0){ quit(save="no"); } # Unintended fork R proc for otf2 logger

Expand Down
3 changes: 3 additions & 0 deletions man/init_otf2_logger.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ Rcpp::Rostream<false>& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get();
#endif

// init_otf2_logger
RcppExport int init_otf2_logger(int max_nprocs, Rcpp::String archivePath, Rcpp::String archiveName, bool collect_metrics, bool flag_print_pids);
RcppExport SEXP _rTrace_init_otf2_logger(SEXP max_nprocsSEXP, SEXP archivePathSEXP, SEXP archiveNameSEXP, SEXP collect_metricsSEXP, SEXP flag_print_pidsSEXP) {
RcppExport int init_otf2_logger(int max_nprocs, Rcpp::String archivePath, Rcpp::String archiveName, bool overwrite_archivePath, bool collect_metrics, bool flag_print_pids);
RcppExport SEXP _rTrace_init_otf2_logger(SEXP max_nprocsSEXP, SEXP archivePathSEXP, SEXP archiveNameSEXP, SEXP overwrite_archivePathSEXP, SEXP collect_metricsSEXP, SEXP flag_print_pidsSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< int >::type max_nprocs(max_nprocsSEXP);
Rcpp::traits::input_parameter< Rcpp::String >::type archivePath(archivePathSEXP);
Rcpp::traits::input_parameter< Rcpp::String >::type archiveName(archiveNameSEXP);
Rcpp::traits::input_parameter< bool >::type overwrite_archivePath(overwrite_archivePathSEXP);
Rcpp::traits::input_parameter< bool >::type collect_metrics(collect_metricsSEXP);
Rcpp::traits::input_parameter< bool >::type flag_print_pids(flag_print_pidsSEXP);
rcpp_result_gen = Rcpp::wrap(init_otf2_logger(max_nprocs, archivePath, archiveName, collect_metrics, flag_print_pids));
rcpp_result_gen = Rcpp::wrap(init_otf2_logger(max_nprocs, archivePath, archiveName, overwrite_archivePath, collect_metrics, flag_print_pids));
return rcpp_result_gen;
END_RCPP
}
Expand Down Expand Up @@ -300,7 +301,7 @@ END_RCPP
}

static const R_CallMethodDef CallEntries[] = {
{"_rTrace_init_otf2_logger", (DL_FUNC) &_rTrace_init_otf2_logger, 5},
{"_rTrace_init_otf2_logger", (DL_FUNC) &_rTrace_init_otf2_logger, 6},
{"_rTrace_r_pmpmeas_init", (DL_FUNC) &_rTrace_r_pmpmeas_init, 0},
{"_rTrace_r_pmpmeas_finish", (DL_FUNC) &_rTrace_r_pmpmeas_finish, 0},
{"_rTrace_r_pmpmeas_start", (DL_FUNC) &_rTrace_r_pmpmeas_start, 0},
Expand Down
2 changes: 1 addition & 1 deletion src/pmpmeas
17 changes: 8 additions & 9 deletions src/rTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@
// Server refers to otf2 logger proc {server}n{clients}=0
// @note WARNING - Was receiving consistent noise on port 5558
// @todo Look at timing offsets per proc
// @todo Signal handling for both procs
// @todo get epochs from Master proc
// @todo Multipart message implimentation for repeated buffer usage
// @todo Move pmpmeas to sub-directory and update buildchain
//
// @note Use pmpmeas_init to parse environment variables
// @note New object Meas for each meas_type, contains multiple metrics via _cnt
// Names and values stored in papi/perf interface (include/papiinf.hh)

#include <otf2/otf2.h>
#include <sys/time.h>
Expand All @@ -42,7 +36,6 @@ using namespace Rcpp;
using namespace PMPMEAS;



///////////////////////////////
// Global vars
///////////////////////////////
Expand Down Expand Up @@ -88,7 +81,6 @@ sighandler_t default_sigint_handler;
// Function definitions
///////////////////////////////

// TODO: Ensure this doesn't cause overflow of wtime
// get_time
// @description Returns wall-clock time in units of milliseconds (1E-6s)
// @return OTF2_Timestamp - Wallclock time
Expand Down Expand Up @@ -191,12 +183,13 @@ void sigint_handler(int sig){
//' @param max_nprocs Maximum number of R processes (ie evtWriters required)
//' @param archivePath Path to otf2 archive
//' @param archiveName Name of otf2 archive
//' @param overwrite_archivePath If true then use archivePath as prefix for directory to avoid overwriting, the suffix is generated using current time in seconds
//' @param collect_metrics Collect HWPC metrics via pmpmeas
//' @param flag_print_pids True to print pids of parent and child procs
//' @return <0 if error, 0 if R master, else >0 if child
// [[Rcpp::export]]
RcppExport int init_otf2_logger(int max_nprocs, Rcpp::String archivePath,
Rcpp::String archiveName, bool collect_metrics,
Rcpp::String archiveName, bool overwrite_archivePath, bool collect_metrics,
bool flag_print_pids)
{
// TODO: Verify this acts as intended to save child proc
Expand All @@ -212,6 +205,12 @@ RcppExport int init_otf2_logger(int max_nprocs, Rcpp::String archivePath,
}
COLLECT_METRICS = collect_metrics;

// Postpend start time to archivePath name to avoid overwrite
char new_archivePath[120];
snprintf(new_archivePath, 120, "%s_%lu", archivePath.get_cstring(), get_time());
if (!overwrite_archivePath)
archivePath = new_archivePath;

child_pid = fork();
if (child_pid == (pid_t) -1 ){ // ERROR
report_and_exit("Forking logger process", NULL);
Expand Down
2 changes: 1 addition & 1 deletion src/rTrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ char log_filename[]="log.log"; ///* Name of log file on server proc
///////////////////////////////
// R client functions (master/slaves)
RcppExport int init_otf2_logger(int max_nprocs, Rcpp::String archivePath = "rTrace",
Rcpp::String archiveName = "rTrace", bool collect_metrics=false,
Rcpp::String archiveName = "rTrace", bool overwrite_archivePath=false, bool collect_metrics=false,
bool flag_print_pids=false);
RcppExport SEXP finalize_GlobalDefWriter_client();
RcppExport int define_otf2_regionRef_client(Rcpp::String, int);
Expand Down

0 comments on commit 6cfcbcf

Please sign in to comment.