mult_native.jl 1.0 KB

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