removed RRuntime and grid as a function parameter

This commit is contained in:
Max Lübke 2020-12-21 12:32:33 +01:00
parent a6e3aa4fe3
commit ea15c1e23d
No known key found for this signature in database
GPG Key ID: D3201E51647D1199
4 changed files with 11 additions and 3 deletions

View File

@ -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, &params);
worker_function(&params);
free(mpi_buffer_results);
}

View File

@ -3,6 +3,7 @@
#include <string>
#include <vector>
#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

View File

@ -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<RRuntime *>(params->R));
Grid grid = *(static_cast<Grid *>(params->grid));
int world_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
MPI_Status probe_status;

View File

@ -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*/