DVR-jl/benchmark.jl

44 lines
903 B
Julia

include("HOperator.jl")
GPU_mode = !("CPU" in ARGS) && CUDA.functional() && CUDA.has_cuda() && CUDA.has_cuda_gpu()
println("Running with ",Threads.nthreads()," thread(s)")
if GPU_mode
mode=gpu_cutensor
println("Available GPUs:")
print(" ")
println.(name.(devices()))
else
mode=cpu_tensor
end
T=Float32
function V_test(r2)
return -4*exp(-r2/4)
end
function apply1000times(H,v)
for i in 1:1000
v=H(v);
end
end
N=10
n_image=1
μ=0.5
for L::T in 5.0:14.0
println("Constructing H operator...")
@time H=HOperator{T}(V_test,3,3,N,L,convert(T,0),convert(T,μ),n_image,mode)
println("Applying H 1000 times...")
if GPU_mode
v=CUDA.rand(Complex{T},vectorDims(H)...)
synchronize()
CUDA.@profile CUDA.@time apply1000times(H,v)
else
v=rand(Complex{T},vectorDims(H)...)
@time apply1000times(H,v)
end
end