You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

dgemm.R 1.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/usr/bin/Rscript
  2. argv <- commandArgs(trailingOnly = TRUE)
  3. if (!is.null(options("matprod")[[1]])) options(matprod = "blas")
  4. nfrom <- 128
  5. nto <- 2048
  6. nstep <- 128
  7. loops <- 1
  8. if (length(argv) > 0) {
  9. for (z in 1:length(argv)) {
  10. if (z == 1) {
  11. nfrom <- as.numeric(argv[z])
  12. } else if (z == 2) {
  13. nto <- as.numeric(argv[z])
  14. } else if (z == 3) {
  15. nstep <- as.numeric(argv[z])
  16. } else if (z == 4) {
  17. loops <- as.numeric(argv[z])
  18. }
  19. }
  20. }
  21. p <- Sys.getenv("OPENBLAS_LOOPS")
  22. if (p != "") {
  23. loops <- as.numeric(p)
  24. }
  25. cat(sprintf("From %.0f To %.0f Step=%.0f Loops=%.0f\n", nfrom, nto, nstep, loops))
  26. cat(sprintf(" SIZE Flops Time\n"))
  27. n <- nfrom
  28. while (n <= nto) {
  29. A <- matrix(runif(n * n), nrow = n)
  30. B <- matrix(runif(n * n), nrow = n)
  31. C <- 1
  32. z <- system.time(for (l in 1:loops) {
  33. C <- A %*% B
  34. l <- l + 1
  35. })
  36. mflops <- (2.0 * n * n * n) * loops / (z[3] * 1e+06)
  37. st <- sprintf("%.0fx%.0f :", n, n)
  38. cat(sprintf("%20s %10.2f MFlops %10.6f sec\n", st, mflops, z[3]))
  39. n <- n + nstep
  40. }