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.2 kB

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