From 939a5495efdaa01ff649f2ab5c6db1cd370b6a0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20L=C3=BCbke?= Date: Mon, 21 Dec 2020 12:32:33 +0100 Subject: [PATCH] removed RRuntime and grid as a function parameter --- src/kin.cpp | 4 +++- src/util/SimParams.h | 4 ++++ src/worker.cpp | 4 +++- src/worker.h | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/kin.cpp b/src/kin.cpp index cdddb1ad0..8cdfa47f7 100644 --- a/src/kin.cpp +++ b/src/kin.cpp @@ -220,6 +220,7 @@ int main(int argc, char *argv[]) { cout << "CPP: R Init (RInside) on process " << params.world_rank << endl; RRuntime R(argc, argv); + params.R = &R; // if local_rank == 0 then master else worker R["local_rank"] = params.world_rank; @@ -269,6 +270,7 @@ int main(int argc, char *argv[]) { R.parseEval(init_chemistry_code); Grid grid(R); + params.grid = &grid; grid.init(); /* Retrieve state_C from R context for MPI buffer generation */ // Rcpp::DataFrame state_C = R.parseEval("mysetup$state_C"); @@ -820,7 +822,7 @@ int main(int argc, char *argv[]) { std::cout.flush(); } } - worker_function(R, grid, ¶ms); + worker_function(¶ms); free(mpi_buffer_results); } diff --git a/src/util/SimParams.h b/src/util/SimParams.h index f54d864cd..948dee481 100644 --- a/src/util/SimParams.h +++ b/src/util/SimParams.h @@ -3,6 +3,7 @@ #include #include +#include "RRuntime.h" typedef struct { int world_size; @@ -21,6 +22,9 @@ typedef struct { unsigned int wp_size; std::string out_dir; + + void* R; + void* grid; } t_simparams; #endif // SIMPARAMS_H diff --git a/src/worker.cpp b/src/worker.cpp index 0bc36dfb6..60643530d 100644 --- a/src/worker.cpp +++ b/src/worker.cpp @@ -10,7 +10,9 @@ using namespace poet; using namespace Rcpp; -void worker_function(RRuntime &R, Grid &grid, t_simparams *params) { +void worker_function(t_simparams *params) { + RRuntime R = *(static_cast(params->R)); + Grid grid = *(static_cast(params->grid)); int world_rank; MPI_Comm_rank(MPI_COMM_WORLD, &world_rank); MPI_Status probe_status; diff --git a/src/worker.h b/src/worker.h index 435cfef7d..076ede6e2 100644 --- a/src/worker.h +++ b/src/worker.h @@ -6,7 +6,7 @@ using namespace std; using namespace poet; /*Functions*/ -void worker_function(RRuntime &R, Grid &grid, t_simparams *params); +void worker_function(t_simparams *params); /*Globals*/