mult_native.jl 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import Libdl
  2. using StarPU
  3. using LinearAlgebra
  4. function multiply_without_starpu(A :: Matrix{Float32}, B :: Matrix{Float32}, C :: Matrix{Float32}, nslicesx, nslicesy, stride)
  5. tmin = 0
  6. for i in (1 : 10 )
  7. t=time_ns()
  8. C = A * B;
  9. t=time_ns() - t
  10. if (tmin==0 || tmin>t)
  11. tmin=t
  12. end
  13. end
  14. return tmin
  15. end
  16. function compute_times(io,start_dim, step_dim, stop_dim, nslicesx, nslicesy, stride)
  17. for dim in (start_dim : step_dim : stop_dim)
  18. A = Array(rand(Cfloat, dim, dim))
  19. B = Array(rand(Cfloat, dim, dim))
  20. C = zeros(Float32, dim, dim)
  21. mt = multiply_without_starpu(A, B, C, nslicesx, nslicesy, stride)
  22. flops = (2*dim-1)*dim*dim/mt
  23. size=dim*dim*4*3/1024/1024
  24. println(io,"$size $flops")
  25. println("$size $flops")
  26. end
  27. end
  28. if size(ARGS, 1) < 2
  29. stride=4
  30. filename="x.dat"
  31. else
  32. stride=parse(Int, ARGS[1])
  33. filename=ARGS[2]
  34. end
  35. io=open(filename,"w")
  36. compute_times(io,16*stride,4*stride,128*stride,2,2,stride)
  37. close(io)