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

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