Skip to content

Commit

Permalink
commenting the parallel test script
Browse files Browse the repository at this point in the history
  • Loading branch information
blog-neas committed Oct 8, 2024
1 parent da89e60 commit 14052fa
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 87 deletions.
4 changes: 0 additions & 4 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ RHO_BOOT_Cpp <- function(x, B) {
.Call('_INAr_RHO_BOOT_Cpp', PACKAGE = 'INAr', x, B)
}

RHO_BOOT_Cpp_Parallel <- function(x, B, num_threads = 2L) {
.Call('_INAr_RHO_BOOT_Cpp_Parallel', PACKAGE = 'INAr', x, B, num_threads)
}

#' Sun-McCabe score statistic to test for dependence in an integer autoregressive process
#' @param x NumericVector
#' @param method unsigned int
Expand Down
69 changes: 0 additions & 69 deletions src/INARboot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,75 +80,6 @@ NumericVector RHO_BOOT_Cpp(NumericVector x, int B){
}



//
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
//

// testing the possibility to use a parallel version of the bootstrap
// WARNING: compilation error on Mac OS X
//
// // [[Rcpp::plugins(openmp)]]
// #include <omp.h>
//
// // [[Rcpp::export]]
// NumericVector RHO_BOOT_Cpp_Parallel(NumericVector x, int B, int num_threads = 2) {
// int n = x.length();
// NumericVector s_temp(B);
//
// // Set the number of threads (optional, default is usually the number of cores)
// if(num_threads > 1 & num_threads <= omp_get_max_threads()){
// omp_set_num_threads(num_threads);
// }else{
// num_threads = 1;
// }
//
// #pragma omp parallel num_threads(num_threads)
// {
// // Each thread needs its own RNG
// RNGScope scope;
//
// #pragma omp for
// for(int i = 0; i < B; i++) {
// // simplified version for testing, to update using the correct do while loop
// NumericVector xb = RcppArmadillo::sample(x, n, true);
// s_temp[i] = RHO_Cpp(xb)[0];
// }
// }
//
// return s_temp;
// }


// #include <omp.h>
//
// // Placeholder for the RHO_Cpp function, which you need to provide
// NumericVector RHO_Cpp(NumericVector x);
//
// // [[Rcpp::export]]
// NumericVector RHO_BOOT_Cpp_Parallel(NumericVector x, int B, int threads = 0) {
// int n = x.length();
// NumericVector s_temp(B);
//
// // Set the number of threads (optional, default is usually the number of cores)
// if(threads > 0 & threads <= omp_get_max_threads()){
// omp_set_num_threads(threads);
// }else{
// omp_set_num_threads(1);
// }
//
// #pragma omp parallel for
// for(int i = 0; i < B; i++) {
// NumericVector xb = RcppArmadillo::sample(x, n, true);
// s_temp[i] = RHO_Cpp(xb)[0];
// }
//
// return s_temp;
// }


//
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
Expand Down
61 changes: 61 additions & 0 deletions src/INARbootpar.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

// testing the possibility to use a parallel version of the bootstrap
// WARNING: compilation error on Mac OS X
//
// // [[Rcpp::plugins(openmp)]]
// #include <omp.h>
//
// // [[Rcpp::export]]
// NumericVector RHO_BOOT_Cpp_Parallel(NumericVector x, int B, int num_threads = 2) {
// int n = x.length();
// NumericVector s_temp(B);
//
// // Set the number of threads (optional, default is usually the number of cores)
// if(num_threads > 1 & num_threads <= omp_get_max_threads()){
// omp_set_num_threads(num_threads);
// }else{
// num_threads = 1;
// }
//
// #pragma omp parallel num_threads(num_threads)
// {
// // Each thread needs its own RNG
// RNGScope scope;
//
// #pragma omp for
// for(int i = 0; i < B; i++) {
// // simplified version for testing, to update using the correct do while loop
// NumericVector xb = RcppArmadillo::sample(x, n, true);
// s_temp[i] = RHO_Cpp(xb)[0];
// }
// }
//
// return s_temp;
// }


// #include <omp.h>
//
// // Placeholder for the RHO_Cpp function, which you need to provide
// NumericVector RHO_Cpp(NumericVector x);
//
// // [[Rcpp::export]]
// NumericVector RHO_BOOT_Cpp_Parallel(NumericVector x, int B, int threads = 0) {
// int n = x.length();
// NumericVector s_temp(B);
//
// // Set the number of threads (optional, default is usually the number of cores)
// if(threads > 0 & threads <= omp_get_max_threads()){
// omp_set_num_threads(threads);
// }else{
// omp_set_num_threads(1);
// }
//
// #pragma omp parallel for
// for(int i = 0; i < B; i++) {
// NumericVector xb = RcppArmadillo::sample(x, n, true);
// s_temp[i] = RHO_Cpp(xb)[0];
// }
//
// return s_temp;
// }
14 changes: 0 additions & 14 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,6 @@ BEGIN_RCPP
return rcpp_result_gen;
END_RCPP
}
// RHO_BOOT_Cpp_Parallel
NumericVector RHO_BOOT_Cpp_Parallel(NumericVector x, int B, int num_threads);
RcppExport SEXP _INAr_RHO_BOOT_Cpp_Parallel(SEXP xSEXP, SEXP BSEXP, SEXP num_threadsSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< NumericVector >::type x(xSEXP);
Rcpp::traits::input_parameter< int >::type B(BSEXP);
Rcpp::traits::input_parameter< int >::type num_threads(num_threadsSEXP);
rcpp_result_gen = Rcpp::wrap(RHO_BOOT_Cpp_Parallel(x, B, num_threads));
return rcpp_result_gen;
END_RCPP
}
// SMC_Cpp
NumericVector SMC_Cpp(NumericVector x, unsigned int method);
RcppExport SEXP _INAr_SMC_Cpp(SEXP xSEXP, SEXP methodSEXP) {
Expand Down Expand Up @@ -212,7 +199,6 @@ END_RCPP
static const R_CallMethodDef CallEntries[] = {
{"_INAr_RHO_Cpp", (DL_FUNC) &_INAr_RHO_Cpp, 1},
{"_INAr_RHO_BOOT_Cpp", (DL_FUNC) &_INAr_RHO_BOOT_Cpp, 2},
{"_INAr_RHO_BOOT_Cpp_Parallel", (DL_FUNC) &_INAr_RHO_BOOT_Cpp_Parallel, 3},
{"_INAr_SMC_Cpp", (DL_FUNC) &_INAr_SMC_Cpp, 2},
{"_INAr_SMC_semiparBOOT_Cpp", (DL_FUNC) &_INAr_SMC_semiparBOOT_Cpp, 3},
{"_INAr_SMC_parBOOT_Cpp", (DL_FUNC) &_INAr_SMC_parBOOT_Cpp, 3},
Expand Down

0 comments on commit 14052fa

Please sign in to comment.