Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
habrok:examples:r [2025/06/11 12:14] – lint pedrohabrok:examples:r [2025/06/11 12:15] (current) – [Multiple CPUs] lint pedro
Line 86: Line 86:
  
 cpu <- Sys.getenv("SLURM_CPUS_ON_NODE", 1) # Number of cores requested (use 1 core if running outside a job). cpu <- Sys.getenv("SLURM_CPUS_ON_NODE", 1) # Number of cores requested (use 1 core if running outside a job).
-hosts <- rep("localhost",cpu)+hosts <- rep("localhost", cpu)
 cl <- makeCluster(hosts, type = "SOCK") cl <- makeCluster(hosts, type = "SOCK")
 # Create random matrices. # Create random matrices.
 n <- 5000 n <- 5000
-A <- matrix(rnorm(n^2),n) +A <- matrix(rnorm(n^2), n) 
-B <- matrix(rnorm(n^2),n)+B <- matrix(rnorm(n^2), n)
  
 # Single core time of matrix multiplication of matrices # Single core time of matrix multiplication of matrices