not workking test timings

parent 339f9e1d
using LatticeGPU using LatticeGPU
using CUDA using CUDA
using TimerOutputs
@timeit "fA_fP test" let
function bndpropagator(U, dpar::DiracParam{T}, dws::DiracWorkspace,lp::SpaceParm{4,6,1,D}, maxiter::Int64, tol::Float64, c::Int64, s::Int64) where {T,D} function bndpropagator(U, dpar::DiracParam{T}, dws::DiracWorkspace,lp::SpaceParm{4,6,1,D}, maxiter::Int64, tol::Float64, c::Int64, s::Int64) where {T,D}
...@@ -42,6 +45,8 @@ end ...@@ -42,6 +45,8 @@ end
function fP_test(;theta = (0.5,0.7,1.0,0.0), m = 1.3, size = (8,8,8,16),prec = 1.0e-16) function fP_test(;theta = (0.5,0.7,1.0,0.0), m = 1.3, size = (8,8,8,16),prec = 1.0e-16)
@timeit "fP inversion (x12)" let
lp = SpaceParm{4}(size,(4,4,4,4),1,(0,0,0,0,0,0)); lp = SpaceParm{4}(size,(4,4,4,4),1,(0,0,0,0,0,0));
exptheta = exp.(im.*theta./lp.iL); exptheta = exp.(im.*theta./lp.iL);
...@@ -67,6 +72,10 @@ for s in 1:4 for c in 1:3 ...@@ -67,6 +72,10 @@ for s in 1:4 for c in 1:3
end end end end
end
@timeit "fP analitical solution" let
#THEORETICAL SOLUTION: hep-lat/9606016 eq (2.33) #THEORETICAL SOLUTION: hep-lat/9606016 eq (2.33)
res_th = zeros(lp.iL[4]) res_th = zeros(lp.iL[4])
...@@ -81,7 +90,7 @@ end end ...@@ -81,7 +90,7 @@ end end
res_th[i] = (2*3*sinh(omega)/(Rpp^2)) * ( (Mpp + sinh(omega))*exp(-2*omega*(i-1)) - (Mpp - sinh(omega))*exp(-2*omega*(2*lp.iL[4]- (i - 1))) ) res_th[i] = (2*3*sinh(omega)/(Rpp^2)) * ( (Mpp + sinh(omega))*exp(-2*omega*(i-1)) - (Mpp - sinh(omega))*exp(-2*omega*(2*lp.iL[4]- (i - 1))) )
end end
end
return sum(abs.(res-res_th)) return sum(abs.(res-res_th))
end end
...@@ -90,6 +99,8 @@ end ...@@ -90,6 +99,8 @@ end
function fA_test(;theta = (0.5,0.7,1.0,0.0), m = 1.3, size = (8,8,8,16),prec = 1.0e-16) function fA_test(;theta = (0.5,0.7,1.0,0.0), m = 1.3, size = (8,8,8,16),prec = 1.0e-16)
@timeit "fA inversion (x12)" let
lp = SpaceParm{4}(size,(4,4,4,4),1,(0,0,0,0,0,0)); lp = SpaceParm{4}(size,(4,4,4,4),1,(0,0,0,0,0,0));
exptheta = exp.(im.*theta./lp.iL); exptheta = exp.(im.*theta./lp.iL);
...@@ -115,8 +126,10 @@ function fA_test(;theta = (0.5,0.7,1.0,0.0), m = 1.3, size = (8,8,8,16),prec = 1 ...@@ -115,8 +126,10 @@ function fA_test(;theta = (0.5,0.7,1.0,0.0), m = 1.3, size = (8,8,8,16),prec = 1
end end end end
end
#THEORETICAL SOLUTION: hep-lat/9606016 eq (2.32) #THEORETICAL SOLUTION: hep-lat/9606016 eq (2.32)
@timeit "fA analitical solution" let
res_th = zeros(lp.iL[4]) res_th = zeros(lp.iL[4])
pp3 = ntuple(i -> theta[i]/lp.iL[i],3) pp3 = ntuple(i -> theta[i]/lp.iL[i],3)
...@@ -130,6 +143,7 @@ function fA_test(;theta = (0.5,0.7,1.0,0.0), m = 1.3, size = (8,8,8,16),prec = 1 ...@@ -130,6 +143,7 @@ function fA_test(;theta = (0.5,0.7,1.0,0.0), m = 1.3, size = (8,8,8,16),prec = 1
- Mpp*((Mpp + sinh(omega))*exp(-2*omega*(i-1)) + (Mpp - sinh(omega))*exp(-2*omega*(2*lp.iL[4]- (i - 1))))) - Mpp*((Mpp + sinh(omega))*exp(-2*omega*(i-1)) + (Mpp - sinh(omega))*exp(-2*omega*(2*lp.iL[4]- (i - 1)))))
end end
end
return sum(abs.(res-res_th)) return sum(abs.(res-res_th))
...@@ -146,3 +160,5 @@ elseif difP > 1.0e-15 ...@@ -146,3 +160,5 @@ elseif difP > 1.0e-15
else else
print("fA & fP tests passed with errors: ", difA," and ",difP,"!\n") print("fA & fP tests passed with errors: ", difA," and ",difP,"!\n")
end end
end
using LatticeGPU, CUDA using LatticeGPU, CUDA, TimerOutputs
#Test for the relation Dw(n|m)^{-1} e^(ipm) = D(p)^{-1} e^{ipn} with a given momenta (if p=0 its randomized), spin and color #Test for the relation Dw(n|m)^{-1} e^(ipm) = D(p)^{-1} e^{ipn} with a given momenta (if p=0 its randomized), spin and color
@timeit "Plw test" begin
function Dwpw_test(;p=0,s=1,c=1) function Dwpw_test(;p=0,s=1,c=1)
lp = SpaceParm{4}((16,16,16,16), (4,4,4,4), 0, (0,0,0,0,0,0)) lp = SpaceParm{4}((16,16,16,16), (4,4,4,4), 0, (0,0,0,0,0,0))
gp = GaugeParm{Float64}(SU3{Float64}, 6.0, 1.0) gp = GaugeParm{Float64}(SU3{Float64}, 6.0, 1.0)
...@@ -15,16 +17,23 @@ U = fill!(vector_field(SU3{Float64},lp),one(SU3{Float64})) ...@@ -15,16 +17,23 @@ U = fill!(vector_field(SU3{Float64},lp),one(SU3{Float64}))
rm = 2* pi* p./(lp.iL) rm = 2* pi* p./(lp.iL)
rmom=(rm[1],rm[2],rm[3],rm[4]) rmom=(rm[1],rm[2],rm[3],rm[4])
@timeit "Generate plane wave" begin
pwave = fill!(scalar_field(Spinor{4,SU3fund{Float64}},lp),zero(eltype(scalar_field(Spinor{4,SU3fund{Float64}},lp)))) pwave = fill!(scalar_field(Spinor{4,SU3fund{Float64}},lp),zero(eltype(scalar_field(Spinor{4,SU3fund{Float64}},lp))))
prop = scalar_field(Spinor{4,SU3fund{Float64}},lp) prop = scalar_field(Spinor{4,SU3fund{Float64}},lp)
prop_th = fill!(scalar_field(Spinor{4,SU3fund{Float64}},lp),zero(eltype(scalar_field(Spinor{4,SU3fund{Float64}},lp)))) prop_th = fill!(scalar_field(Spinor{4,SU3fund{Float64}},lp),zero(eltype(scalar_field(Spinor{4,SU3fund{Float64}},lp))))
#Generate plane wave #Generate plane wave
for x in 1:lp.iL[1] for y in 1:lp.iL[2] for z in 1:lp.iL[3] for t in 1:lp.iL[4] for x in 1:lp.iL[1] for y in 1:lp.iL[2] for z in 1:lp.iL[3] for t in 1:lp.iL[4]
CUDA.@allowscalar pwave[point_index(CartesianIndex{lp.ndim}((x,y,z,t)),lp)...] = exp(im * (x*rmom[1] + y*rmom[2] + z*rmom[3] + t*rmom[4]))*Spinor{4,SU3fund{Float64}}(ntuple(i -> (i==s)*SU3fund{Float64}(ntuple(j -> (j==c)*1.0,3)...),4)) CUDA.@allowscalar pwave[point_index(CartesianIndex{lp.ndim}((x,y,z,t)),lp)...] = exp(im * (x*rmom[1] + y*rmom[2] + z*rmom[3] + t*rmom[4]))*Spinor{4,SU3fund{Float64}}(ntuple(i -> (i==s)*SU3fund{Float64}(ntuple(j -> (j==c)*1.0,3)...),4))
end end end end end end end end
end
@timeit "Generate analitical solution" begin
#Th solution #Th solution
if s == 1 if s == 1
...@@ -53,8 +62,15 @@ else ...@@ -53,8 +62,15 @@ else
end end end end end end end end
end end
end
end
#compute Sum{x} D^-1(x|y)P(y) #compute Sum{x} D^-1(x|y)P(y)
@timeit "Solving propagator" begin
function krnlg5!(src) function krnlg5!(src)
b=Int64(CUDA.threadIdx().x) b=Int64(CUDA.threadIdx().x)
r=Int64(CUDA.blockIdx().x) r=Int64(CUDA.blockIdx().x)
...@@ -67,7 +83,7 @@ CUDA.@sync begin ...@@ -67,7 +83,7 @@ CUDA.@sync begin
end end
g5Dw!(prop,U,pwave,dpar,lp) g5Dw!(prop,U,pwave,dpar,lp)
CG!(prop,U,DwdagDw!,dpar,lp,dws,ymws,gp,10000,1.0e-14) CG!(prop,U,DwdagDw!,dpar,lp,dws,ymws,gp,10000,1.0e-14)
end
dif = sum(norm2.(prop - prop_th)) dif = sum(norm2.(prop - prop_th))
...@@ -75,10 +91,12 @@ if dif > 1.0e-15 ...@@ -75,10 +91,12 @@ if dif > 1.0e-15
error("Dwpl test for s=",s,", c=",c," failed with difference: ",dif,"\n") error("Dwpl test for s=",s,", c=",c," failed with difference: ",dif,"\n")
end end
end
return dif return dif
end end
let begin
dif = 0.0 dif = 0.0
for i in 1:3 for j in 1:4 for i in 1:3 for j in 1:4
dif += Dwpw_test(c=i,s=j) dif += Dwpw_test(c=i,s=j)
...@@ -86,3 +104,5 @@ end end ...@@ -86,3 +104,5 @@ end end
print("Dwpl test passed with average error ", dif/12,"!\n") print("Dwpl test passed with average error ", dif/12,"!\n")
end end
end
using CUDA,LatticeGPU using CUDA,LatticeGPU, TimerOutputs
#Check that Dw ( (DwdagDw)^{-1} g5 Dw g5 ) psi = psi for random fields #Check that Dw ( (DwdagDw)^{-1} g5 Dw g5 ) psi = psi for random fields
@timeit "Rand solver test" let
function pfrandomize!(f,lp::SpaceParm,dpar::DiracParam) function pfrandomize!(f,lp::SpaceParm,dpar::DiracParam)
if dpar.rep == SU3fund && lp.ndim == 4 if dpar.rep == SU3fund && lp.ndim == 4
...@@ -30,6 +32,8 @@ function krnl_assign_pf!(f::AbstractArray{T}, p ,lp::SpaceParm) where {T} ...@@ -30,6 +32,8 @@ function krnl_assign_pf!(f::AbstractArray{T}, p ,lp::SpaceParm) where {T}
end end
@timeit "Generate random fields" let
lp = SpaceParm{4}((16,16,16,16), (4,4,4,4), 0, (0,0,0,0,0,0)) lp = SpaceParm{4}((16,16,16,16), (4,4,4,4), 0, (0,0,0,0,0,0))
gp = GaugeParm{Float64}(SU3{Float64}, 6.0, 1.0) gp = GaugeParm{Float64}(SU3{Float64}, 6.0, 1.0)
ymws = YMworkspace(SU3, Float64, lp) ymws = YMworkspace(SU3, Float64, lp)
...@@ -44,6 +48,8 @@ U = exp.(ymws.mom) ...@@ -44,6 +48,8 @@ U = exp.(ymws.mom)
rpsi = scalar_field(Spinor{4,SU3fund{Float64}},lp) rpsi = scalar_field(Spinor{4,SU3fund{Float64}},lp)
pfrandomize!(rpsi,lp,dpar) pfrandomize!(rpsi,lp,dpar)
end
prop = scalar_field(Spinor{4,SU3fund{Float64}},lp) prop = scalar_field(Spinor{4,SU3fund{Float64}},lp)
function krnlg5!(src) function krnlg5!(src)
...@@ -75,3 +81,4 @@ else ...@@ -75,3 +81,4 @@ else
error("Drand test failed with difference: ",res,"\n") error("Drand test failed with difference: ",res,"\n")
end end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment