From 6974e6d4f59693f36be5ebcadb7135da1b0a9265 Mon Sep 17 00:00:00 2001 From: Othman El Hammouchi Date: Tue, 7 May 2024 22:26:38 +0200 Subject: [PATCH 1/4] Add empty case for PAIRS in odpSim switch statement The compiler issues a warning on Windows which angers R CMD check --- src/odp.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/odp.cpp b/src/odp.cpp index 57daae9..4663e00 100644 --- a/src/odp.cpp +++ b/src/odp.cpp @@ -174,6 +174,8 @@ Rcpp::List odpSim(arma::mat triangle, options::SimType sim_type, int n_boot, reserves.colptr(k), pgb); break; } + case options::PAIRS: + break; } } } @@ -239,6 +241,8 @@ Rcpp::List odpSim(arma::mat triangle, options::SimType sim_type, int n_boot, reserves.colptr(i_diag), pgb); break; } + case options::PAIRS: + break; } } } @@ -295,6 +299,8 @@ Rcpp::List odpSim(arma::mat triangle, options::SimType sim_type, int n_boot, reserves.colptr(i), pgb); break; } + case options::PAIRS: + break; } } } From 9860ea3213981a6b41f67374af6ee32b25bddbac Mon Sep 17 00:00:00 2001 From: Othman El Hammouchi Date: Tue, 7 May 2024 22:27:54 +0200 Subject: [PATCH 2/4] Add preprocessor magic to try to deal with the state of R & OpenMP on Mac --- inst/include/config.h | 13 +++++++++++-- inst/include/random.h | 4 ++-- src/pgb.cpp | 2 +- src/random.cpp | 4 ++-- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/inst/include/config.h b/inst/include/config.h index 803d035..8d3c0bb 100644 --- a/inst/include/config.h +++ b/inst/include/config.h @@ -1,7 +1,16 @@ #pragma once -#include -#include +#ifdef _OPENMP + #include +#else + #define omp_get_num_threads() 1 + #define omp_get_thread_num() 0 + #define omp_get_max_threads() 1 + #define omp_get_thread_limit() 1 + #define omp_get_num_procs() 1 +#endif + +#include #include #include #include diff --git a/inst/include/random.h b/inst/include/random.h index dbe83d3..2c57c99 100644 --- a/inst/include/random.h +++ b/inst/include/random.h @@ -1,9 +1,9 @@ #pragma once #include -#include - #include +#include "config.h" + /** * @brief Singleton class managing a parallel RNG engine for * the entire package. diff --git a/src/pgb.cpp b/src/pgb.cpp index 5a21981..e984e1c 100644 --- a/src/pgb.cpp +++ b/src/pgb.cpp @@ -1,5 +1,5 @@ #include -#include +#include "config.h" #include #include diff --git a/src/random.cpp b/src/random.cpp index eef1fba..42a25a4 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -1,14 +1,14 @@ #include "random.h" #include -#include - #include #include #include #include #include +#include "config.h" + extern "C" { double rnorm(double mean, double sd); double rgamma(double shape, double scale); From 80fe14c1a7f99220ed538ee3eafea5907961a35e Mon Sep 17 00:00:00 2001 From: Othman El Hammouchi Date: Tue, 7 May 2024 22:36:30 +0200 Subject: [PATCH 3/4] Disable graphical tests on MacOS as well The results are not reproducible for some reason, same as for Windows --- tests/testthat/test-boot_res.R | 1 + tests/testthat/test-calendar.R | 1 + tests/testthat/test-origin.R | 1 + tests/testthat/test-single.R | 1 + 4 files changed, 4 insertions(+) diff --git a/tests/testthat/test-boot_res.R b/tests/testthat/test-boot_res.R index 978b54e..5c41ded 100644 --- a/tests/testthat/test-boot_res.R +++ b/tests/testthat/test-boot_res.R @@ -3,6 +3,7 @@ test_that("bootstrap plot works with correct output", { announce_snapshot_file(name = "boot_multiple.png") skip_on_ci() skip_on_os("windows") + skip_on_os("mac") res <- withr::with_seed( 42, diff --git a/tests/testthat/test-calendar.R b/tests/testthat/test-calendar.R index f6e62a6..88e43c6 100644 --- a/tests/testthat/test-calendar.R +++ b/tests/testthat/test-calendar.R @@ -2,6 +2,7 @@ test_that("calendar sim plot works with correct output", { announce_snapshot_file(name = "sim_calendar.png") skip_on_ci() skip_on_os("windows") + skip_on_os("mac") withr::local_seed(42) restore <- getTrnglSeed() diff --git a/tests/testthat/test-origin.R b/tests/testthat/test-origin.R index 44c31b4..808b4b9 100644 --- a/tests/testthat/test-origin.R +++ b/tests/testthat/test-origin.R @@ -2,6 +2,7 @@ test_that("origin sim plot works with correct output", { announce_snapshot_file(name = "sim_origin.png") skip_on_ci() skip_on_os("windows") + skip_on_os("mac") withr::local_seed(42) restore <- getTrnglSeed() diff --git a/tests/testthat/test-single.R b/tests/testthat/test-single.R index 61f6da3..8e4b771 100644 --- a/tests/testthat/test-single.R +++ b/tests/testthat/test-single.R @@ -2,6 +2,7 @@ test_that("single sim plot works with correct output", { announce_snapshot_file(name = "sim_single.png") skip_on_ci() skip_on_os("windows") + skip_on_os("mac") withr::local_seed(42) restore <- getTrnglSeed() From 28a96ed7b62113ab555ee72b94ae20999076c743 Mon Sep 17 00:00:00 2001 From: Othman El Hammouchi Date: Tue, 7 May 2024 22:54:23 +0200 Subject: [PATCH 4/4] Remove redundant call to omp_get_thread_num in mod_mack It's blocking CI for MacOS --- src/mod_mack.f90 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/mod_mack.f90 b/src/mod_mack.f90 index b1eb034..3348280 100644 --- a/src/mod_mack.f90 +++ b/src/mod_mack.f90 @@ -246,7 +246,7 @@ function mack_pairs_boot(trngl, n_boot, n_sim, pgb) result(reserve) type(c_ptr), intent(in), value :: pgb real(c_double) :: reserve(n_boot * n_sim) - integer :: i, j, k, i_diag, i_boot, i_sim, i_thread, n_rows, n_obs + integer :: i, j, k, i_diag, i_boot, i_sim, n_rows, n_obs real(c_double) :: mean, sd real(c_double) :: triangle_sim(trngl%n_dev, trngl%n_dev) integer :: status @@ -256,7 +256,6 @@ function mack_pairs_boot(trngl, n_boot, n_sim, pgb) result(reserve) logical :: show_progress show_progress = c_associated(pgb) - i_thread = omp_get_thread_num() i_boot = 1 main_loop: do while (i_boot <= n_boot)