Skip to content
Snippets Groups Projects
Commit 61d3a8a2 authored by Marco De Lucia's avatar Marco De Lucia Committed by Max Lübke
Browse files

Added qs2 as new default format

parent b29be5fd
No related branches found
No related tags found
1 merge request!43Mdl/fgcsbench
...@@ -109,69 +109,6 @@ msgm <- function(...) { ...@@ -109,69 +109,6 @@ msgm <- function(...) {
} }
## Function called by master R process to store on disk all relevant
## parameters for the simulation
StoreSetup <- function(setup, filesim, out_dir) {
to_store <- vector(mode = "list", length = 4)
## names(to_store) <- c("Sim", "Flow", "Transport", "Chemistry", "DHT")
names(to_store) <- c("Sim", "Transport", "DHT", "Cmdline")
## read the setup R file, which is sourced in kin.cpp
tmpbuff <- file(filesim, "r")
setupfile <- readLines(tmpbuff)
close.connection(tmpbuff)
to_store$Sim <- setupfile
## to_store$Flow <- list(
## snapshots = setup$snapshots,
## gridfile = setup$gridfile,
## phase = setup$phase,
## density = setup$density,
## dt_differ = setup$dt_differ,
## prolong = setup$prolong,
## maxiter = setup$maxiter,
## saved_iter = setup$iter_output,
## out_save = setup$out_save )
to_store$Transport <- setup$diffusion
## to_store$Chemistry <- list(
## nprocs = n_procs,
## wp_size = work_package_size,
## base = setup$base,
## first = setup$first,
## init = setup$initsim,
## db = db,
## kin = setup$kin,
## ann = setup$ann)
if (dht_enabled) {
to_store$DHT <- list(
enabled = dht_enabled,
log = dht_log
## signif = dht_final_signif,
## proptype = dht_final_proptype
)
} else {
to_store$DHT <- FALSE
}
if (dht_enabled) {
to_store$DHT <- list(
enabled = dht_enabled,
log = dht_log
# signif = dht_final_signif,
# proptype = dht_final_proptype
)
} else {
to_store$DHT <- FALSE
}
saveRDS(to_store, file = paste0(fileout, "/setup.rds"))
msgm("initialization stored in ", paste0(fileout, "/setup.rds"))
}
GetWorkPackageSizesVector <- function(n_packages, package_size, len) { GetWorkPackageSizesVector <- function(n_packages, package_size, len) {
ids <- rep(1:n_packages, times = package_size, each = 1)[1:len] ids <- rep(1:n_packages, times = package_size, each = 1)[1:len]
return(as.integer(table(ids))) return(as.integer(table(ids)))
...@@ -179,7 +116,7 @@ GetWorkPackageSizesVector <- function(n_packages, package_size, len) { ...@@ -179,7 +116,7 @@ GetWorkPackageSizesVector <- function(n_packages, package_size, len) {
## Handler to read R objs from binary files using either builtin ## Handler to read R objs from binary files using either builtin
## readRDS() or qs::qread() based on file extension ## readRDS(), qs::qread() or qs2::qs_read() based on file extension
ReadRObj <- function(path) { ReadRObj <- function(path) {
## code borrowed from tools::file_ext() ## code borrowed from tools::file_ext()
pos <- regexpr("\\.([[:alnum:]]+)$", path) pos <- regexpr("\\.([[:alnum:]]+)$", path)
...@@ -187,7 +124,8 @@ ReadRObj <- function(path) { ...@@ -187,7 +124,8 @@ ReadRObj <- function(path) {
switch(extension, switch(extension,
rds = readRDS(path), rds = readRDS(path),
qs = qs::qread(path) qs = qs::qread(path),
qs2 = qs2::qs_read(path)
) )
} }
...@@ -201,6 +139,73 @@ SaveRObj <- function(x, path) { ...@@ -201,6 +139,73 @@ SaveRObj <- function(x, path) {
switch(extension, switch(extension,
rds = saveRDS(object = x, file = path), rds = saveRDS(object = x, file = path),
qs = qs::qsave(x = x, file = path) qs = qs::qsave(x = x, file = path),
qs2 = qs2::qs_save(object = x, file = path)
) )
} }
######## Old relic code
## ## Function called by master R process to store on disk all relevant
## ## parameters for the simulation
## StoreSetup <- function(setup, filesim, out_dir) {
## to_store <- vector(mode = "list", length = 4)
## ## names(to_store) <- c("Sim", "Flow", "Transport", "Chemistry", "DHT")
## names(to_store) <- c("Sim", "Transport", "DHT", "Cmdline")
## ## read the setup R file, which is sourced in kin.cpp
## tmpbuff <- file(filesim, "r")
## setupfile <- readLines(tmpbuff)
## close.connection(tmpbuff)
## to_store$Sim <- setupfile
## ## to_store$Flow <- list(
## ## snapshots = setup$snapshots,
## ## gridfile = setup$gridfile,
## ## phase = setup$phase,
## ## density = setup$density,
## ## dt_differ = setup$dt_differ,
## ## prolong = setup$prolong,
## ## maxiter = setup$maxiter,
## ## saved_iter = setup$iter_output,
## ## out_save = setup$out_save )
## to_store$Transport <- setup$diffusion
## ## to_store$Chemistry <- list(
## ## nprocs = n_procs,
## ## wp_size = work_package_size,
## ## base = setup$base,
## ## first = setup$first,
## ## init = setup$initsim,
## ## db = db,
## ## kin = setup$kin,
## ## ann = setup$ann)
## if (dht_enabled) {
## to_store$DHT <- list(
## enabled = dht_enabled,
## log = dht_log
## ## signif = dht_final_signif,
## ## proptype = dht_final_proptype
## )
## } else {
## to_store$DHT <- FALSE
## }
## if (dht_enabled) {
## to_store$DHT <- list(
## enabled = dht_enabled,
## log = dht_log
## # signif = dht_final_signif,
## # proptype = dht_final_proptype
## )
## } else {
## to_store$DHT <- FALSE
## }
## saveRDS(to_store, file = paste0(fileout, "/setup.rds"))
## msgm("initialization stored in ", paste0(fileout, "/setup.rds"))
## }
...@@ -7,7 +7,7 @@ function(ADD_BENCH_TARGET TARGET POET_BENCH_LIST RT_FILES OUT_PATH) ...@@ -7,7 +7,7 @@ function(ADD_BENCH_TARGET TARGET POET_BENCH_LIST RT_FILES OUT_PATH)
foreach(BENCH_FILE ${${POET_BENCH_LIST}}) foreach(BENCH_FILE ${${POET_BENCH_LIST}})
get_filename_component(BENCH_NAME ${BENCH_FILE} NAME_WE) get_filename_component(BENCH_NAME ${BENCH_FILE} NAME_WE)
set(OUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/${BENCH_NAME}) set(OUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/${BENCH_NAME})
set(OUT_FILE_EXT ${OUT_FILE}.qs) set(OUT_FILE_EXT ${OUT_FILE}.qs2)
add_custom_command( add_custom_command(
OUTPUT ${OUT_FILE_EXT} OUTPUT ${OUT_FILE_EXT}
......
...@@ -35,7 +35,11 @@ int main(int argc, char **argv) { ...@@ -35,7 +35,11 @@ int main(int argc, char **argv) {
->default_val(false); ->default_val(false);
bool asRDS; bool asRDS;
app.add_flag("-r, --rds", asRDS, "Save output as .rds file instead of .qs") app.add_flag("-r, --rds", asRDS, "Save output as .rds")
->default_val(false);
bool asQS;
app.add_flag("-q, --qs", asQS, "Save output as .qs")
->default_val(false); ->default_val(false);
CLI11_PARSE(app, argc, argv); CLI11_PARSE(app, argc, argv);
...@@ -69,7 +73,13 @@ int main(int argc, char **argv) { ...@@ -69,7 +73,13 @@ int main(int argc, char **argv) {
} }
// append the correct file extension // append the correct file extension
output_file += asRDS ? ".rds" : ".qs"; if (asRDS) {
output_file += ".rds";
} else if (asQS) {
output_file += ".qs";
} else {
output_file += ".qs2";
}
// set working directory to the directory of the input script // set working directory to the directory of the input script
if (setwd) { if (setwd) {
......
...@@ -57,7 +57,7 @@ static std::unique_ptr<Rcpp::List> global_rt_setup; ...@@ -57,7 +57,7 @@ static std::unique_ptr<Rcpp::List> global_rt_setup;
// before the R runtime is initialized // before the R runtime is initialized
static poet::DEFunc master_init_R; static poet::DEFunc master_init_R;
static poet::DEFunc master_iteration_end_R; static poet::DEFunc master_iteration_end_R;
static poet::DEFunc store_setup_R; // MDL: unused -> static poet::DEFunc store_setup_R;
static poet::DEFunc ReadRObj_R; static poet::DEFunc ReadRObj_R;
static poet::DEFunc SaveRObj_R; static poet::DEFunc SaveRObj_R;
static poet::DEFunc source_R; static poet::DEFunc source_R;
...@@ -66,7 +66,7 @@ static void init_global_functions(RInside &R) { ...@@ -66,7 +66,7 @@ static void init_global_functions(RInside &R) {
R.parseEval(kin_r_library); R.parseEval(kin_r_library);
master_init_R = DEFunc("master_init"); master_init_R = DEFunc("master_init");
master_iteration_end_R = DEFunc("master_iteration_end"); master_iteration_end_R = DEFunc("master_iteration_end");
store_setup_R = DEFunc("StoreSetup"); // MDL: unused -> store_setup_R = DEFunc("StoreSetup");
source_R = DEFunc("source"); source_R = DEFunc("source");
ReadRObj_R = DEFunc("ReadRObj"); ReadRObj_R = DEFunc("ReadRObj");
SaveRObj_R = DEFunc("SaveRObj"); SaveRObj_R = DEFunc("SaveRObj");
...@@ -146,7 +146,10 @@ int parseInitValues(int argc, char **argv, RuntimeParameters &params) { ...@@ -146,7 +146,10 @@ int parseInitValues(int argc, char **argv, RuntimeParameters &params) {
"Enable AI surrogate for chemistry module"); "Enable AI surrogate for chemistry module");
app.add_flag("--rds", params.as_rds, app.add_flag("--rds", params.as_rds,
"Save output as .rds file instead of .qs"); "Save output as .rds file instead of default .qs2");
app.add_flag("--qs", params.as_qs,
"Save output as .qs file instead of default .qs2");
std::string init_file; std::string init_file;
std::string runtime_file; std::string runtime_file;
...@@ -174,7 +177,9 @@ int parseInitValues(int argc, char **argv, RuntimeParameters &params) { ...@@ -174,7 +177,9 @@ int parseInitValues(int argc, char **argv, RuntimeParameters &params) {
} }
// set the output extension // set the output extension
params.out_ext = params.as_rds ? "rds" : "qs"; params.out_ext = "qs2";
if (params.as_rds) params.out_ext = "rds";
if (params.as_qs) params.out_ext = "qs";
if (MY_RANK == 0) { if (MY_RANK == 0) {
// MSG("Complete results storage is " + BOOL_PRINT(simparams.store_result)); // MSG("Complete results storage is " + BOOL_PRINT(simparams.store_result));
......
...@@ -45,8 +45,10 @@ struct RuntimeParameters { ...@@ -45,8 +45,10 @@ struct RuntimeParameters {
Rcpp::List init_params; Rcpp::List init_params;
// MDL added to accomodate for qs::qsave/qread
bool as_rds = false; bool as_rds = false;
std::string out_ext; // MDL added to accomodate for qs::qsave/qread bool as_qs = false;
std::string out_ext;
bool print_progress = false; bool print_progress = false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment