Week 12

make

Monday, Mar 23

Learning objectives

  • Create a basic Makefile
  • make variables, pattern rules, and phony targets
  • Using make for a reproducible workflow

Materials


Parallelization

Wednesday, Mar 25

Learning objectives

  • Benchmarking code
  • Computing terminology
  • Forking versus sockets
  • Core functions in package parallel

Materials


Lab 9

Friday, Mar 27

GitHub

Materials


Exercise of the week

  1. Use pawn to compare parallelizing via forking and sockets. Consider 1, 2, 4, 8, and 16 cores to evaluate the computation time for a simple task of your choice. What is the difference in overhead cost between forking and using sockets?

  2. Do you notice anything strange with objects result2 and result4? What is going on?
library(parallel)
library(magrittr)
detectCores()

result2 <- mclapply(1:12, FUN = function(x) rnorm(1), 
                   mc.cores = 2, mc.set.seed = FALSE) %>% unlist()

result2
## [1]  0.32006303  0.32006303 -1.01143576 -1.01143576  0.06824854  0.06824854  
## [7]  2.09764952  2.09764952  1.30633116  1.30633116  0.92467119  0.92467119
result4 <- mclapply(1:12, FUN = function(x) rnorm(1), 
                   mc.cores = 4, mc.set.seed = FALSE) %>% unlist()

result4
## [1]  0.32006303  0.32006303  0.32006303  0.32006303 -1.01143576 -1.01143576 
## [7]  -1.01143576 -1.01143576  0.06824854  0.06824854  0.06824854  0.06824854
Previous
Next