Skip to content

Commit 7954009

Browse files
authored
Merge pull request #51 from slamballais/assert_cores
0.9.0 check for parallelism layers
2 parents fbb3589 + e7b1096 commit 7954009

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ License: GPL-3
1111
Encoding: UTF-8
1212
LazyData: true
1313
Imports:
14-
bigstatsr (>= 0.6.2),
14+
bigstatsr (>= 1.5.1),
1515
doParallel (>= 1.0.14),
1616
foreach (>= 1.4.4),
1717
Matrix (>= 1.2.12),
1818
methods,
1919
parallel,
2020
RcppEigen (>= 0.3.3.4.0),
21+
RhpcBLASctl (>= 0.21.247.1),
2122
stats (>= 3.4.3)
2223
Suggests:
2324
magick (>= 2.0),

R/qdecr_check.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## COPIED FROM bigparallelr:::default_nproc_blas
2+
default_nproc_blas <- function() {
3+
4+
cl <- parallel::makePSOCKcluster(1)
5+
on.exit(parallel::stopCluster(cl), add = TRUE)
6+
7+
parallel::clusterEvalQ(cl, RhpcBLASctl::blas_get_num_procs())[[1]]
8+
}
9+
110
qdecr_check_backing <- function(backing, clobber){
211
for (n in backing){
312
n <- paste0(n, ".bk")
@@ -63,6 +72,7 @@ check_cores <- function(n_cores) {
6372
rec_cores <- parallel::detectCores() - 1
6473
if (rec_cores == 0) rec_cores <- 1
6574
if (n_cores > rec_cores) stop("You specified `n_cores` to be too high (", n_cores, "). Recommended is ", rec_cores)
75+
if (n_cores > 1 && default_nproc_blas() > 1) stop("`n_cores` > 1, but there already seems to be a parallel BLAS library present. Either set `n_cores` to 1, or set the BLAS library to 1.")
6676
NULL
6777
}
6878

0 commit comments

Comments
 (0)