disable NaN checks before BLAS calls dgemm.R
authorAndrew <16061801+brada4@users.noreply.github.com>
Wed, 16 Jan 2019 09:54:22 +0000 (11:54 +0200)
committerAndrew <16061801+brada4@users.noreply.github.com>
Wed, 16 Jan 2019 09:54:22 +0000 (11:54 +0200)
benchmark/scripts/R/dgemm.R

index 75297df..d7c3e81 100755 (executable)
@@ -2,6 +2,8 @@
 
 argv <- commandArgs(trailingOnly = TRUE)
 
+if (!is.null(options("matprod")[[1]])) options(matprod = "blas")
+
 nfrom <- 128
 nto <- 2048
 nstep <- 128
@@ -19,7 +21,6 @@ if (length(argv) > 0) {
       loops <- as.numeric(argv[z])
     }
   }
-
 }
 
 p <- Sys.getenv("OPENBLAS_LOOPS")
@@ -27,26 +28,13 @@ if (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"))
 
 n <- nfrom
 while (n <= nto) {
-  A <- matrix(runif(n * n),
-              ncol = n,
-              nrow = n,
-              byrow = TRUE)
-  B <- matrix(runif(n * n),
-              ncol = n,
-              nrow = n,
-              byrow = TRUE)
+  A <- matrix(runif(n * n), nrow = n)
+  B <- matrix(runif(n * n), nrow = n)
   C <- 1
 
   z <- system.time(for (l in 1:loops) {
@@ -54,11 +42,10 @@ while (n <= nto) {
     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)
   cat(sprintf("%20s %10.2f MFlops %10.6f sec\n", st, mflops, z[3]))
 
   n <- n + nstep
-
 }