From ea8c8392ef8a84a146bf1e46fe36d55bdc89799d Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Fri, 21 Jun 2024 08:53:11 +1000 Subject: R: allow configuration of the number of threads --- R/R/pca.R | 3 ++- R/src/wrapper.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/R/R/pca.R b/R/R/pca.R index 7d0d742..ab24732 100644 --- a/R/R/pca.R +++ b/R/R/pca.R @@ -1,4 +1,4 @@ -pca <- function(x, k=1, q=0.5, iters=10000){ +pca <- function(x, k=1, q=0.5, iters=10000, nprocs=0){ n <- nrow(x) d <- ncol(x) B <- matrix(0, n, k) @@ -6,6 +6,7 @@ pca <- function(x, k=1, q=0.5, iters=10000){ l <- 0 res <- .C("pca_wrapper", + nprocs=as.integer(nprocs), n=as.integer(n), d=as.integer(d), iters=as.integer(iters), diff --git a/R/src/wrapper.c b/R/src/wrapper.c index 52c1192..5e258b8 100644 --- a/R/src/wrapper.c +++ b/R/src/wrapper.c @@ -1,9 +1,10 @@ #include "pca.h" void -pca_wrapper(int *n, int *d, int *iters, double *q, int *k, double *X, double *B, double *U, double *l) { +pca_wrapper(int *nprocs, int *n, int *d, int *iters, double *q, int *k, double *X, double *B, double *U, double *l) { struct futhark_context_config *cfg = futhark_context_config_new(); + futhark_context_config_set_num_threads(cfg, *nprocs); struct futhark_context *ctx = futhark_context_new(cfg); struct futhark_f64_2d *Xf = futhark_new_f64_2d(ctx, X, *n, *d); -- cgit v1.2.3