Skip to content

Instantly share code, notes, and snippets.

@andrie
Last active October 26, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrie/1efde1d1e903350273f1 to your computer and use it in GitHub Desktop.
Save andrie/1efde1d1e903350273f1 to your computer and use it in GitHub Desktop.
This code originated in the RRO mailing list at https://groups.google.com/forum/#!topic/rropen/MG98lXsFepo
library(parallel)
set.seed(1)
m <- 10000
n <- 2000
A <- matrix(runif (m*n),m,n)
setMKLthreads(1)
system.time(S <- svd (A,nu=0,nv=0))
# user system elapsed
# 7.282 0.133 7.431
setMKLthreads(4)
system.time(S <- svd (A,nu=0,nv=0))
# user system elapsed
# 16.584 0.347 5.377
setMKLthreads(1)
system.time(mclapply(X=list(A, A, A, A),
FUN=svd,
nu=0,
nv=0,
mc.cores=4))
# user system elapsed
# 852.845 35.167 19.691
setMKLthreads(4)
system.time(mclapply(X=list(A, A, A, A),
FUN=svd,
nu=0,
nv=0,
mc.cores=1))
# user system elapsed
# 66.333 1.245 21.573
setMKLthreads(4)
system.time(mclapply(X=list(A, A, A, A),
FUN=svd,
nu=0,
nv=0,
mc.cores=4))
# threads sleep; use 0% cpu and do not finish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment