Skip to content

Commit

Permalink
Revert "Removing mpi from testing"
Browse files Browse the repository at this point in the history
This reverts commit 1478129.
  • Loading branch information
DylanKierans committed Mar 18, 2024
1 parent 721f21b commit 7a51678
Show file tree
Hide file tree
Showing 11 changed files with 243 additions and 2 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ jobs:
run: |
brew install otf2
# MANUAL OPENMPI INSTALL
- name: Install openmpi (linux)
if: runner.os == 'linux'
run: |
sudo apt-get install libopenmpi-dev
export MPI_ROOT=$(which mpicc | xargs dirname | xargs dirname)
- name: Install openmpi (mac)
if: runner.os == 'macOS'
run: |
brew install open-mpi
export MPI_ROOT=$(which mpicc | xargs dirname | xargs dirname)
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
Expand Down
25 changes: 25 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,28 @@ get_ppid <- function() {
.Call('_rTrace_get_ppid', PACKAGE = 'rTrace')
}

#' mpi_init
mpi_init <- function() {
.Call('_rTrace_mpi_init', PACKAGE = 'rTrace')
}

#' mpi_finalize
mpi_finalize <- function() {
.Call('_rTrace_mpi_finalize', PACKAGE = 'rTrace')
}

#' mpi_is_init
mpi_is_init <- function() {
.Call('_rTrace_mpi_is_init', PACKAGE = 'rTrace')
}

#' get_mpi_rank
get_mpi_rank <- function() {
.Call('_rTrace_get_mpi_rank', PACKAGE = 'rTrace')
}

#' get_mpi_size
get_mpi_size <- function() {
.Call('_rTrace_get_mpi_size', PACKAGE = 'rTrace')
}

14 changes: 14 additions & 0 deletions man/get_env.Rd

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

11 changes: 11 additions & 0 deletions man/get_mpi_rank.Rd

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

11 changes: 11 additions & 0 deletions man/get_mpi_size.Rd

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

11 changes: 11 additions & 0 deletions man/mpi_finalize.Rd

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

11 changes: 11 additions & 0 deletions man/mpi_init.Rd

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

11 changes: 11 additions & 0 deletions man/mpi_is_init.Rd

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

10 changes: 8 additions & 2 deletions src/Makevars
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@
OTF2_PKG_CPPFLAGS=-I${OTF2_ROOT}/include -I.
OTF2_PKG_LIBS=-L${OTF2_ROOT}/lib -L. -lotf2

PKG_CPPFLAGS=${OTF2_PKG_CPPFLAGS}
PKG_LIBS=${OTF2_PKG_LIBS}
# mpi
#MPI_PKG_CPPFLAGS=$(mpicc -showme:compile)
#MPI_PKG_LIBS=$(mpicc -showme:link)
MPI_PKG_CPPFLAGS=-I${MPI_ROOT}/include
MPI_PKG_LIBS=-L${MPI_ROOT}/lib -lmpi

PKG_CPPFLAGS=${OTF2_PKG_CPPFLAGS} ${MPI_PKG_CPPFLAGS}
PKG_LIBS=${OTF2_PKG_LIBS} ${MPI_PKG_LIBS}
55 changes: 55 additions & 0 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,56 @@ BEGIN_RCPP
return rcpp_result_gen;
END_RCPP
}
// mpi_init
RcppExport int mpi_init();
RcppExport SEXP _rTrace_mpi_init() {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = Rcpp::wrap(mpi_init());
return rcpp_result_gen;
END_RCPP
}
// mpi_finalize
RcppExport SEXP mpi_finalize();
RcppExport SEXP _rTrace_mpi_finalize() {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = Rcpp::wrap(mpi_finalize());
return rcpp_result_gen;
END_RCPP
}
// mpi_is_init
RcppExport int mpi_is_init();
RcppExport SEXP _rTrace_mpi_is_init() {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = Rcpp::wrap(mpi_is_init());
return rcpp_result_gen;
END_RCPP
}
// get_mpi_rank
RcppExport int get_mpi_rank();
RcppExport SEXP _rTrace_get_mpi_rank() {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = Rcpp::wrap(get_mpi_rank());
return rcpp_result_gen;
END_RCPP
}
// get_mpi_size
RcppExport int get_mpi_size();
RcppExport SEXP _rTrace_get_mpi_size() {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = Rcpp::wrap(get_mpi_size());
return rcpp_result_gen;
END_RCPP
}

static const R_CallMethodDef CallEntries[] = {
{"_rTrace_init_Archive", (DL_FUNC) &_rTrace_init_Archive, 2},
Expand All @@ -210,6 +260,11 @@ static const R_CallMethodDef CallEntries[] = {
{"_rTrace_get_pid", (DL_FUNC) &_rTrace_get_pid, 0},
{"_rTrace_get_tid", (DL_FUNC) &_rTrace_get_tid, 0},
{"_rTrace_get_ppid", (DL_FUNC) &_rTrace_get_ppid, 0},
{"_rTrace_mpi_init", (DL_FUNC) &_rTrace_mpi_init, 0},
{"_rTrace_mpi_finalize", (DL_FUNC) &_rTrace_mpi_finalize, 0},
{"_rTrace_mpi_is_init", (DL_FUNC) &_rTrace_mpi_is_init, 0},
{"_rTrace_get_mpi_rank", (DL_FUNC) &_rTrace_get_mpi_rank, 0},
{"_rTrace_get_mpi_size", (DL_FUNC) &_rTrace_get_mpi_size, 0},
{NULL, NULL, 0}
};

Expand Down
73 changes: 73 additions & 0 deletions src/rTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
#include <sys/types.h>
#include <unistd.h>

// if (MPI)
#include <mpi.h>


//#define DEBUG /* Uncomment to enable verbose debug info */
//#define DUMMY_TIMESTEPS /* Uncomment for 1s timestep for each subsequent event call */

Expand Down Expand Up @@ -382,3 +386,72 @@ RcppExport int get_tid() {
RcppExport int get_ppid() {
return((int)getppid());
}

//' mpi_init
// [[Rcpp::export]]
RcppExport int mpi_init() {
int flag;
int fake_argc = 0;
char **fake_argv = NULL;
//char **fake_argv = malloc(1*sizeof(*fake_argv));
MPI_Init(&fake_argc, &fake_argv);
free(fake_argv);

MPI_Initialized(&flag);
if (flag) {
Rcout << "MPI is initialized.\n";
return(0);
}
Rcout << "MPI UNABLE to initialize.\n";
return (-1);
}

//' mpi_finalize
// [[Rcpp::export]]
RcppExport SEXP mpi_finalize() {
MPI_Finalize();
return(R_NilValue);
}

//' mpi_is_init
// [[Rcpp::export]]
RcppExport int mpi_is_init() {
int init_flag;
MPI_Initialized(&init_flag);
if (init_flag) {
Rcout << "MPI is initialized.\n";
return(0);
}
Rcout << "MPI is NOT initialized\n";
return (-1);
}

//' get_mpi_rank
// [[Rcpp::export]]
RcppExport int get_mpi_rank() {
int rank, init_flag;
MPI_Initialized(&init_flag);
if (init_flag) {
Rcout << "MPI is initialized.\n";
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
return(rank);
}
Rcout << "MPI is NOT initialized\n";
return (-1);
}

//' get_mpi_size
// [[Rcpp::export]]
RcppExport int get_mpi_size() {
int size, init_flag;
MPI_Initialized(&init_flag);
if (init_flag) {
Rcout << "MPI is initialized.\n";
MPI_Comm_size(MPI_COMM_WORLD, &size);
return(size);
}
Rcout << "MPI is NOT initialized\n";
return (-1);
}


0 comments on commit 7a51678

Please sign in to comment.