Skip to content

Instantly share code, notes, and snippets.

@rossholmberg
Created July 16, 2016 14:01
Show Gist options
  • Select an option

  • Save rossholmberg/145ca5961cc11695b0394fb0256e234d to your computer and use it in GitHub Desktop.

Select an option

Save rossholmberg/145ca5961cc11695b0394fb0256e234d to your computer and use it in GitHub Desktop.
library( holmberg )
holmberg::pkgLoad( c( "data.table", "doMC", "plyr", "dplyr", "utils", "parallel" ) )
logicalCores <- parallel::detectCores( logical = FALSE )
virtualCores <- parallel::detectCores( logical = TRUE )
if( virtualCores > logicalCores ) {
doMC::registerDoMC( cores = logicalCores )
} else if( logicalCores > 2 ) {
doMC::registerDoMC( cores = logicalCores - 1L )
} else {
doMC::registerDoMC( cores = 1L )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment