gemm_native.jl 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # StarPU --- Runtime system for heterogeneous multicore architectures.
  2. #
  3. # Copyright (C) 2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. #
  5. # StarPU is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU Lesser General Public License as published by
  7. # the Free Software Foundation; either version 2.1 of the License, or (at
  8. # your option) any later version.
  9. #
  10. # StarPU is distributed in the hope that it will be useful, but
  11. # WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. #
  14. # See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. #
  16. using LinearAlgebra.BLAS
  17. function gemm_without_starpu(A :: Matrix{Float32}, B :: Matrix{Float32}, C :: Matrix{Float32}, alpha :: Float32, beta :: Float32)
  18. tmin = 0
  19. for i in (1 : 10 )
  20. t=time_ns()
  21. gemm!('N', 'N', alpha, A, B, beta, C)
  22. t=time_ns() - t
  23. if (tmin==0 || tmin>t)
  24. tmin=t
  25. end
  26. end
  27. return tmin
  28. end
  29. function compute_times(io,start_dim, step_dim, stop_dim)
  30. for dim in (start_dim : step_dim : stop_dim)
  31. A = Array(rand(Cfloat, dim, dim))
  32. B = Array(rand(Cfloat, dim, dim))
  33. C = zeros(Float32, dim, dim)
  34. alpha = 4.0f0
  35. beta = 2.0f0
  36. mt = gemm_without_starpu(A, B, C, alpha, beta)
  37. gflop = 2 * dim * dim * dim * 1.e-9
  38. gflops = gflop / (mt * 1.e-9)
  39. size=dim*dim*dim*4*3/1024/1024
  40. println(io,"$dim $gflops")
  41. println("$dim $gflops")
  42. end
  43. end
  44. if size(ARGS, 1) < 1
  45. filename="x.dat"
  46. else
  47. filename=ARGS[1]
  48. end
  49. io=open(filename,"w")
  50. compute_times(io,64,512,4096)
  51. close(io)