From 26712e11ab7cd9df1a39c822ac9f2c0a0e7ccd71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20W=C3=B3jtowicz?= Date: Fri, 20 May 2016 12:54:32 +0200 Subject: [PATCH] added gcbd benchmark; added power-off option --- benchmark-gcbd.R | 81 +++++++++++++++++++++++++++++++++++++++++++ master-ctrl-slaves.sh | 26 +++++++++++++- slave-cmds.sh | 4 +++ 3 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 benchmark-gcbd.R diff --git a/benchmark-gcbd.R b/benchmark-gcbd.R new file mode 100644 index 0000000..5ab0456 --- /dev/null +++ b/benchmark-gcbd.R @@ -0,0 +1,81 @@ +# source: CRAN gcbd package + +size = c(100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1250, 1500, 1750, 2000, 2500, 3000, 3500, 4000, 4500, 5000) +runs = c( 50, 50, 50, 50, 50, 50, 50, 50, 50, 30, 30, 30, 30, 20, 20, 5, 5, 5, 5, 5) +meanTrim = 0.1 + +results = data.frame(t1=numeric(), t2=numeric(), t3=numeric(), t4=numeric()) + +library(Matrix) + +# functions + +getMatrix <- function(N) { + a <- rnorm(N*N) + dim(a) <- c(N,N) + invisible(gc()) + invisible(a) +} + +matmultBenchmark <- function(N, n, trim=0.1) { + a <- getMatrix(N) + traw <- replicate(n, system.time(crossprod(a))[3]) + tmean <- mean(traw,trim=trim) +} + + +qrBenchmark <- function(N, n, trim=0.1) { + a <- getMatrix(N) + traw <- replicate(n, system.time(qr(a, LAPACK=TRUE))[3]) + tmean <- mean(traw,trim=trim) +} + +svdBenchmark <- function(N, n, trim=0.1) { + a <- getMatrix(N) + traw <- replicate(n, system.time(svd(a))[3]) + tmean <- mean(traw,trim=trim) +} + +luBenchmark <- function(N, n, trim=0.1) { + a <- getMatrix(N) + traw <- replicate(n, system.time(lu(a))[3]) + tmean <- mean(traw,trim=trim) +} + + +# Initialization + +set.seed (1) + +cat(paste0("Mean trim : ", meanTrim, "\n")) + +for (i in 1:length(size)) +{ + n = size[i] + r = runs[i] + + cat(paste0("Size : ", n, "\n")) + cat(paste0("Runs : ", r, "\n")) + + t1 = matmultBenchmark(n, r, meanTrim) + cat(paste0("Matrix Multiply : ", t1, "\n")) + + t2 = qrBenchmark(n, r, meanTrim) + cat(paste0("QR Decomposition : ", t2, "\n")) + + t3 = svdBenchmark(n, r, meanTrim) + cat(paste0("Singular Value Deomposition : ", t3, "\n")) + + t4 = luBenchmark(n, r, meanTrim) + cat(paste0("Triangular Decomposition : ", t4, "\n")) + + results = rbind(results, data.frame(t1=t1, t2=t2, t3=t3, t4=t4)) +} + +colnames(results) = c("Matrix Multiply", "QR Decomposition", + "Singular Value Deomposition", "Triangular Decomposition") + +attr(results, "size") = size +attr(results, "runs") = runs +attr(results, "meanTrim") = meanTrim +saveRDS(results, paste0("test-gcbd-", ifelse(exists("blasLibName"), blasLibName, ""), ".rds")) diff --git a/master-ctrl-slaves.sh b/master-ctrl-slaves.sh index be8a8cd..dc145c9 100644 --- a/master-ctrl-slaves.sh +++ b/master-ctrl-slaves.sh @@ -13,7 +13,7 @@ function configure_hosts { echo -n "${host} ... " echo -n "config-push " - scp ${SSH_OPTIONS} -i ssh/${SSH_KEY_PRIV} slave-cmds.sh cpuinfo benchmark-sample.R benchmark-urbanek.R benchmark-revolution.R root@${host}:/root + scp ${SSH_OPTIONS} -i ssh/${SSH_KEY_PRIV} slave-cmds.sh cpuinfo benchmark-sample.R benchmark-urbanek.R benchmark-revolution.R benchmark-gcbd.R root@${host}:/root ret=$? if [ $ret -ne 0 ] ; then echo "error $ret"; continue @@ -49,6 +49,23 @@ function configure_hosts { } +function power_off { + + echo "* Power-off hosts:" + + for host in `cat hosts-list.txt` + do + echo -n "${host} ... " + + echo "power off " + ssh ${SSH_OPTIONS} -i ssh/${SSH_KEY_PRIV} root@${host} 'poweroff' + + done + + echo "* Done" + +} + function benchmark { echo "* Benchmark: ${BENCHMARK_TEST}" @@ -99,6 +116,9 @@ else configure_hosts) configure_hosts ;; + power_off) + power_off + ;; test_sample) BENCHMARK_TEST="sample" benchmark @@ -111,6 +131,10 @@ else BENCHMARK_TEST="revolution" benchmark ;; + test_gcbd) + BENCHMARK_TEST="gcbd" + benchmark + ;; *) echo "unknown command" esac diff --git a/slave-cmds.sh b/slave-cmds.sh index e6f6116..44de027 100644 --- a/slave-cmds.sh +++ b/slave-cmds.sh @@ -55,6 +55,7 @@ function mro_install { sed -i "1i\library(checkpoint); checkpoint('${CHECKPOINT_DATE}', scanForPackages=FALSE, verbose=FALSE)" benchmark-sample.R sed -i "1i\library(checkpoint); checkpoint('${CHECKPOINT_DATE}', scanForPackages=FALSE, verbose=FALSE)" benchmark-urbanek.R sed -i "1i\library(checkpoint); checkpoint('${CHECKPOINT_DATE}', scanForPackages=FALSE, verbose=FALSE)" benchmark-revolution.R + sed -i "1i\library(checkpoint); checkpoint('${CHECKPOINT_DATE}', scanForPackages=FALSE, verbose=FALSE)" benchmark-gcbd.R # make directory for BLAS and LAPACK libraries mkdir -p ${DIR_BLAS} @@ -631,6 +632,9 @@ else test_revolution) R_BENCHMARK_SCRIPT="benchmark-revolution.R" ;; + test_gcbd) + R_BENCHMARK_SCRIPT="benchmark-gcbd.R" + ;; *) $i esac