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.

dsolve.R 1.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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(rnorm(n * n), ncol = n, nrow = n)
  35. B <- matrix(rnorm(n * n), ncol = n, nrow = n)
  36. z <- system.time(for (l in 1:loops) {
  37. solve(A, B)
  38. })
  39. mflops <-
  40. (2.0 / 3.0 * n * n * n + 2.0 * n * n * n) * loops / (z[3] * 1.0e6)
  41. st <- sprintf("%.0fx%.0f :", n, n)
  42. cat(sprintf("%20s %10.2f MFlops %10.6f sec\n", st, mflops, z[3]))
  43. n <- n + nstep
  44. }