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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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(rnorm(n * n), nrow = n)
  30. B <- matrix(rnorm(n * n), nrow = n)
  31. z <- system.time(for (l in 1:loops) {
  32. solve(A, B)
  33. })
  34. mflops <- (8.0 / 3 * n * n * n) * loops / (z[3] * 1e+06)
  35. st <- sprintf("%.0fx%.0f :", n, n)
  36. cat(sprintf("%20s %10.2f MFlops %10.6f sec\n", st, mflops, z[3]))
  37. n <- n + nstep
  38. }