Skip to content

Commit

Permalink
Integrated PR #29: use all.tests=TRUE for detecting number of cores o…
Browse files Browse the repository at this point in the history
…n OpenBSD
  • Loading branch information
Renaud committed Mar 23, 2015
1 parent cb8e721 commit 063cdcb
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion R/nmf.R
Expand Up @@ -1468,7 +1468,7 @@ function(x, rank, method
," [version ", getDoParVersion(),"]")
# show number of processes
if( getDoParWorkers() == 1 ) message("Mode: sequential [foreach:",getDoParName(),"]")
else message("Mode: parallel ", str_c("(", getDoParWorkers(), '/', parallel::detectCores()," core(s))"))
else message("Mode: parallel ", str_c("(", getDoParWorkers(), '/', getAllCores()," core(s))"))
}

# check shared memory capability
Expand Down
2 changes: 1 addition & 1 deletion R/options.R
Expand Up @@ -78,7 +78,7 @@ NULL
, gc=50
# define default parallel backend
, parallel.backend= option_symlink('pbackend') # for backward compatibility
, pbackend= if( parallel::detectCores() > 1 ) 'par' else 'seq'
, pbackend= if( getAllCores() > 1 ) 'par' else 'seq'
# toogle verbosity
, verbose=FALSE
# toogle debug mode
Expand Down
2 changes: 1 addition & 1 deletion R/parallel.R
Expand Up @@ -16,7 +16,7 @@ NULL
# specified by the user
getMaxCores <- function(limit=TRUE){
#ceiling(parallel::detectCores()/2)
nt <- n <- parallel::detectCores()
nt <- n <- getAllCores()
# limit to number of cores specified in options if asked for
if( limit ){
if( !is.null(nc <- getOption('cores')) ) n <- nc # global option
Expand Down
6 changes: 6 additions & 0 deletions R/utils.R
Expand Up @@ -43,6 +43,12 @@ rmAttributes <- function(x){
x
}

# returns total number of available cores
getAllCores <- function(){
isOpenBSD <- grepl('openbsd', R.version$os, ignore.case = TRUE)
parallel::detectCores(all.tests = isOpenBSD)
}

#' \code{str_args} formats the arguments of a function using \code{\link{args}},
#' but returns the output as a string.
#'
Expand Down
2 changes: 1 addition & 1 deletion inst/tests/runit.parallel.r
Expand Up @@ -266,7 +266,7 @@ test.nmf <- function(){

.check('SEQ', .pbackend='SEQ')
# Multicore
if( parallel::detectCores() > 1 )
if( NMF:::getAllCores() > 1 )
.check('P2', .options='P2')

# SNOW-type from char spec
Expand Down

0 comments on commit 063cdcb

Please sign in to comment.