DVR-jl/benchmark.jl

44 lines
880 B
Julia

using CUDA
GPU_mode = !("CPU" in ARGS) && CUDA.functional() && CUDA.has_cuda() && CUDA.has_cuda_gpu()
println("Running with ",Threads.nthreads()," thread(s)")
if GPU_mode
include("GPU.jl")
println("Available GPUs:")
print(" ")
println.(name.(devices()))
else
include("CPU.jl")
end
T=Float32
function V_test(r2::T)::T
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,μ),n_image)
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