Merge pull request #1962 from brada4/r

Modrenize R benchmarks slightly
This commit is contained in:
Martin Kroeker 2019-01-28 15:42:57 +01:00 committed by GitHub
commit a529c71a74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 45 deletions

View File

@ -2,6 +2,8 @@
argv <- commandArgs(trailingOnly = TRUE) argv <- commandArgs(trailingOnly = TRUE)
if (!is.null(options("matprod")[[1]])) options(matprod = "blas")
nfrom <- 128 nfrom <- 128
nto <- 2048 nto <- 2048
nstep <- 128 nstep <- 128
@ -19,7 +21,6 @@ if (length(argv) > 0) {
loops <- as.numeric(argv[z]) loops <- as.numeric(argv[z])
} }
} }
} }
p <- Sys.getenv("OPENBLAS_LOOPS") p <- Sys.getenv("OPENBLAS_LOOPS")
@ -27,29 +28,21 @@ if (p != "") {
loops <- as.numeric(p) loops <- as.numeric(p)
} }
cat(sprintf("From %.0f To %.0f Step=%.0f Loops=%.0f\n", nfrom, nto, nstep, loops))
cat(sprintf(
"From %.0f To %.0f Step=%.0f Loops=%.0f\n",
nfrom,
nto,
nstep,
loops
))
cat(sprintf(" SIZE Flops Time\n")) cat(sprintf(" SIZE Flops Time\n"))
n <- nfrom n <- nfrom
while (n <= nto) { while (n <= nto) {
A <- matrix(rnorm(n * n), ncol = n, nrow = n) A <- matrix(rnorm(n * n), nrow = n)
ev <- 0 ev <- 0
z <- system.time(for (l in 1:loops) { z <- system.time(for (l in 1:loops) {
ev <- eigen(A) ev <- eigen(A)
}) })
mflops <- (26.66 * n * n * n) * loops / (z[3] * 1.0e6) mflops <- (26.66 * n * n * n) * loops / (z[3] * 1e+06)
st <- sprintf("%.0fx%.0f :", n, n) st <- sprintf("%.0fx%.0f :", n, n)
cat(sprintf("%20s %10.2f MFlops %10.6f sec\n", st, mflops, z[3])) cat(sprintf("%20s %10.2f MFlops %10.6f sec\n", st, mflops, z[3]))
n <- n + nstep n <- n + nstep
} }

View File

@ -2,6 +2,8 @@
argv <- commandArgs(trailingOnly = TRUE) argv <- commandArgs(trailingOnly = TRUE)
if (!is.null(options("matprod")[[1]])) options(matprod = "blas")
nfrom <- 128 nfrom <- 128
nto <- 2048 nto <- 2048
nstep <- 128 nstep <- 128
@ -19,7 +21,6 @@ if (length(argv) > 0) {
loops <- as.numeric(argv[z]) loops <- as.numeric(argv[z])
} }
} }
} }
p <- Sys.getenv("OPENBLAS_LOOPS") p <- Sys.getenv("OPENBLAS_LOOPS")
@ -27,26 +28,13 @@ if (p != "") {
loops <- as.numeric(p) loops <- as.numeric(p)
} }
cat(sprintf("From %.0f To %.0f Step=%.0f Loops=%.0f\n", nfrom, nto, nstep, loops))
cat(sprintf(
"From %.0f To %.0f Step=%.0f Loops=%.0f\n",
nfrom,
nto,
nstep,
loops
))
cat(sprintf(" SIZE Flops Time\n")) cat(sprintf(" SIZE Flops Time\n"))
n <- nfrom n <- nfrom
while (n <= nto) { while (n <= nto) {
A <- matrix(runif(n * n), A <- matrix(runif(n * n), nrow = n)
ncol = n, B <- matrix(runif(n * n), nrow = n)
nrow = n,
byrow = TRUE)
B <- matrix(runif(n * n),
ncol = n,
nrow = n,
byrow = TRUE)
C <- 1 C <- 1
z <- system.time(for (l in 1:loops) { z <- system.time(for (l in 1:loops) {
@ -54,11 +42,10 @@ while (n <= nto) {
l <- l + 1 l <- l + 1
}) })
mflops <- (2.0 * n * n * n) * loops / (z[3] * 1.0e6) mflops <- (2.0 * n * n * n) * loops / (z[3] * 1e+06)
st <- sprintf("%.0fx%.0f :", n, n) st <- sprintf("%.0fx%.0f :", n, n)
cat(sprintf("%20s %10.2f MFlops %10.6f sec\n", st, mflops, z[3])) cat(sprintf("%20s %10.2f MFlops %10.6f sec\n", st, mflops, z[3]))
n <- n + nstep n <- n + nstep
} }

View File

@ -2,6 +2,8 @@
argv <- commandArgs(trailingOnly = TRUE) argv <- commandArgs(trailingOnly = TRUE)
if (!is.null(options("matprod")[[1]])) options(matprod = "blas")
nfrom <- 128 nfrom <- 128
nto <- 2048 nto <- 2048
nstep <- 128 nstep <- 128
@ -19,7 +21,6 @@ if (length(argv) > 0) {
loops <- as.numeric(argv[z]) loops <- as.numeric(argv[z])
} }
} }
} }
p <- Sys.getenv("OPENBLAS_LOOPS") p <- Sys.getenv("OPENBLAS_LOOPS")
@ -27,31 +28,22 @@ if (p != "") {
loops <- as.numeric(p) loops <- as.numeric(p)
} }
cat(sprintf("From %.0f To %.0f Step=%.0f Loops=%.0f\n", nfrom, nto, nstep, loops))
cat(sprintf(
"From %.0f To %.0f Step=%.0f Loops=%.0f\n",
nfrom,
nto,
nstep,
loops
))
cat(sprintf(" SIZE Flops Time\n")) cat(sprintf(" SIZE Flops Time\n"))
n <- nfrom n <- nfrom
while (n <= nto) { while (n <= nto) {
A <- matrix(rnorm(n * n), ncol = n, nrow = n) A <- matrix(rnorm(n * n), nrow = n)
B <- matrix(rnorm(n * n), ncol = n, nrow = n) B <- matrix(rnorm(n * n), nrow = n)
z <- system.time(for (l in 1:loops) { z <- system.time(for (l in 1:loops) {
solve(A, B) solve(A, B)
}) })
mflops <- mflops <- (8.0 / 3 * n * n * n) * loops / (z[3] * 1e+06)
(2.0 / 3.0 * n * n * n + 2.0 * n * n * n) * loops / (z[3] * 1.0e6)
st <- sprintf("%.0fx%.0f :", n, n) st <- sprintf("%.0fx%.0f :", n, n)
cat(sprintf("%20s %10.2f MFlops %10.6f sec\n", st, mflops, z[3])) cat(sprintf("%20s %10.2f MFlops %10.6f sec\n", st, mflops, z[3]))
n <- n + nstep n <- n + nstep
} }