# thread_testing_matrixinverse_MKL6.txt # # Tests matrix inversion using the 'parallelMatrixInv' function. # # MRO 3.3.0 (x64) is used with the MKL BLAS library. The number of MKL threads is fixed at 6. # The number of RcppParallel threads is varied from 1 to 6 (the number of physical cores in # the machine). # The matrix inversion is repeated five times for each setting. > source('G:/Temp/dynamic model/roll_lm_test/20160823/20160823.R', echo=TRUE) > # setwd("G:/Temp/dynamic model/roll_lm_test/20160823/") > > # install.packages("Rcpp", repos = "http://cran.us.r-project.org", > # .... [TRUNCATED] > library(RcppParallel) Attaching package: ‘RcppParallel’ The following object is masked from ‘package:Rcpp’: LdFlags > sourceCpp("20160823.cpp") > n_vars <- 150 > n_obs <- 1000 > set.seed(1) > x <- array(rnorm(n_obs * n_vars * n_vars), dim = c(n_vars, n_vars, n_obs)) > try(setMKLthreads(6), silent = T) > RcppThreads <- 1 > RcppParallel::setThreadOptions(numThreads = RcppThreads) > times <- list() > for (i in 1:5){ + times[[i]] <- + system.time(parallelMatrixInv(x)) + } > tryCatch(getMKLthreads(), error = function(e) print('MKL BLAS library not in use')) [1] 6 > print(RcppThreads) [1] 1 > times [[1]] user system elapsed 6.37 0.47 1.28 [[2]] user system elapsed 6.71 0.59 1.22 [[3]] user system elapsed 6.51 0.70 1.21 [[4]] user system elapsed 6.33 0.68 1.24 [[5]] user system elapsed 6.77 0.73 1.26 > RcppThreads <- 2 > RcppParallel::setThreadOptions(numThreads = RcppThreads) > times <- list() > for (i in 1:5){ + times[[i]] <- + system.time(parallelMatrixInv(x)) + } > tryCatch(getMKLthreads(), error = function(e) print('MKL BLAS library not in use')) [1] 6 > print(RcppThreads) [1] 2 > times [[1]] user system elapsed 9.03 1.02 1.03 [[2]] user system elapsed 11.90 1.42 1.19 [[3]] user system elapsed 10.12 1.17 1.12 [[4]] user system elapsed 10.08 1.29 1.09 [[5]] user system elapsed 10.22 1.27 1.00 > RcppThreads <- 3 > RcppParallel::setThreadOptions(numThreads = RcppThreads) > times <- list() > for (i in 1:5){ + times[[i]] <- + system.time(parallelMatrixInv(x)) + } > tryCatch(getMKLthreads(), error = function(e) print('MKL BLAS library not in use')) [1] 6 > print(RcppThreads) [1] 3 > times [[1]] user system elapsed 4.54 0.89 0.81 [[2]] user system elapsed 4.06 1.26 0.89 [[3]] user system elapsed 3.98 0.71 0.84 [[4]] user system elapsed 3.69 0.83 0.84 [[5]] user system elapsed 3.67 0.97 0.86 > RcppThreads <- 4 > RcppParallel::setThreadOptions(numThreads = RcppThreads) > times <- list() > for (i in 1:5){ + times[[i]] <- + system.time(parallelMatrixInv(x)) + } > tryCatch(getMKLthreads(), error = function(e) print('MKL BLAS library not in use')) [1] 6 > print(RcppThreads) [1] 4 > times [[1]] user system elapsed 4.18 1.73 0.87 [[2]] user system elapsed 4.51 1.42 0.88 [[3]] user system elapsed 4.62 1.09 0.88 [[4]] user system elapsed 4.79 1.81 0.95 [[5]] user system elapsed 4.03 1.31 0.84 > RcppThreads <- 5 > RcppParallel::setThreadOptions(numThreads = RcppThreads) > times <- list() > for (i in 1:5){ + times[[i]] <- + system.time(parallelMatrixInv(x)) + } > tryCatch(getMKLthreads(), error = function(e) print('MKL BLAS library not in use')) [1] 6 > print(RcppThreads) [1] 5 > times [[1]] user system elapsed 4.35 1.30 0.84 [[2]] user system elapsed 4.75 2.50 0.97 [[3]] user system elapsed 4.51 1.97 0.89 [[4]] user system elapsed 4.66 2.51 0.98 [[5]] user system elapsed 4.93 3.43 1.12 > RcppThreads <- 6 > RcppParallel::setThreadOptions(numThreads = RcppThreads) > times <- list() > for (i in 1:5){ + times[[i]] <- + system.time(parallelMatrixInv(x)) + } > tryCatch(getMKLthreads(), error = function(e) print('MKL BLAS library not in use')) [1] 6 > print(RcppThreads) [1] 6 > times [[1]] user system elapsed 5.39 3.17 1.09 [[2]] user system elapsed 4.98 2.95 1.06 [[3]] user system elapsed 4.99 1.71 0.92 [[4]] user system elapsed 5.30 3.34 1.10 [[5]] user system elapsed 5.48 2.69 1.08