mult_native.jl 959 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import Libdl
  2. using StarPU
  3. using LinearAlgebra
  4. #shoud be the same as in the makefile
  5. const STRIDE = 72
  6. function multiply_without_starpu(A :: Matrix{Float32}, B :: Matrix{Float32}, C :: Matrix{Float32}, nslicesx, nslicesy)
  7. tmin = 0
  8. for i in (1 : 10 )
  9. t=time_ns()
  10. C = A * B;
  11. t=time_ns() - t
  12. if (tmin==0 || tmin>t)
  13. tmin=t
  14. end
  15. end
  16. return tmin
  17. end
  18. function compute_times(io,start_dim, step_dim, stop_dim, nslicesx, nslicesy)
  19. for dim in (start_dim : step_dim : stop_dim)
  20. A = Array(rand(Cfloat, dim, dim))
  21. B = Array(rand(Cfloat, dim, dim))
  22. C = zeros(Float32, dim, dim)
  23. mt = multiply_without_starpu(A, B, C, nslicesx, nslicesy)
  24. flops = (2*dim-1)*dim*dim/mt
  25. size=dim*dim*4*3/1024/1024
  26. println(io,"$size $flops")
  27. println("$size $flops")
  28. end
  29. end
  30. io=open(ARGS[1],"w")
  31. compute_times(io,16*STRIDE,4*STRIDE,4096,2,2)
  32. close(io)