mult_native.jl 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. import Libdl
  17. using StarPU
  18. using LinearAlgebra
  19. function multiply_without_starpu(A :: Matrix{Float32}, B :: Matrix{Float32}, C :: Matrix{Float32}, nslicesx, nslicesy, stride)
  20. tmin = 0
  21. for i in (1 : 10 )
  22. t=time_ns()
  23. C = A * B;
  24. t=time_ns() - t
  25. if (tmin==0 || tmin>t)
  26. tmin=t
  27. end
  28. end
  29. return tmin
  30. end
  31. function compute_times(io,start_dim, step_dim, stop_dim, nslicesx, nslicesy, stride)
  32. for dim in (start_dim : step_dim : stop_dim)
  33. A = Array(rand(Cfloat, dim, dim))
  34. B = Array(rand(Cfloat, dim, dim))
  35. C = zeros(Float32, dim, dim)
  36. mt = multiply_without_starpu(A, B, C, nslicesx, nslicesy, stride)
  37. flops = (2*dim-1)*dim*dim/mt
  38. size=dim*dim*4*3/1024/1024
  39. println(io,"$size $flops")
  40. println("$size $flops")
  41. end
  42. end
  43. if size(ARGS, 1) < 2
  44. stride=4
  45. filename="x.dat"
  46. else
  47. stride=parse(Int, ARGS[1])
  48. filename=ARGS[2]
  49. end
  50. io=open(filename,"w")
  51. compute_times(io,16*stride,4*stride,128*stride,2,2,stride)
  52. close(io)