From e8493693b026cf2993351153caf6d700400db08b Mon Sep 17 00:00:00 2001 From: Alberto Ramos Date: Sat, 25 Sep 2021 15:22:47 +0200 Subject: [PATCH] Bugs corrected --- src/LatticeGPU.jl | 1 + src/YM/YM.jl | 3 +++ src/YM/YMact.jl | 26 +++++++++++++++----------- src/YM/YMflow.jl | 8 ++++---- src/YM/YMhmc.jl | 2 +- src/main/test.jl | 16 +++++++++++----- 6 files changed, 35 insertions(+), 21 deletions(-) diff --git a/src/LatticeGPU.jl b/src/LatticeGPU.jl index 94f11b0..f576c8b 100644 --- a/src/LatticeGPU.jl +++ b/src/LatticeGPU.jl @@ -31,5 +31,6 @@ include("YM/YM.jl") using .YM export YMworkspace, GaugeParm, force0_wilson!, field, field_pln, randomize!, zero!, norm2 export gauge_action, hamiltonian, plaquette, HMC!, OMF4! +export wfl_euler, wfl_rk3 end # module diff --git a/src/YM/YM.jl b/src/YM/YM.jl index 8bcb7d5..c11a624 100644 --- a/src/YM/YM.jl +++ b/src/YM/YM.jl @@ -102,4 +102,7 @@ export krnl_plaq!, force0_wilson! include("YMhmc.jl") export gauge_action, hamiltonian, plaquette, HMC!, OMF4! +include("YMflow.jl") +export wfl_euler, wfl_rk3 + end diff --git a/src/YM/YMact.jl b/src/YM/YMact.jl index 6e07026..279562b 100644 --- a/src/YM/YMact.jl +++ b/src/YM/YMact.jl @@ -9,7 +9,7 @@ ### created: Mon Jul 12 18:31:19 2021 ### -function krnl_plaq!(plx, U, lp::SpaceParm{N,M,D}) where {T,N,M,D} +function krnl_plaq!(plx, U::AbstractArray{T}, lp::SpaceParm{N,M,D}) where {T,N,M,D} b, r = CUDA.threadIdx().x, CUDA.blockIdx().x @@ -17,25 +17,29 @@ function krnl_plaq!(plx, U, lp::SpaceParm{N,M,D}) where {T,N,M,D} plx[b,r] = zero(plx[b,r]) for id1 in 1:N-1 - if ru2 == r - gt2 = Ush[bu2,1] - else - gt2 = U[bu2,id1,ru2] - end + bu1, ru1 = up((b, r), id1, lp) + Ush[b,1] = U[b,id1,r] + for id2 = id1+1:N + bu2, ru2 = up((b, r), id2, lp) + Ush[b,2] = U[b,id2,r] + sync_threads() + if ru1 == r gt1 = Ush[bu1,2] else gt1 = U[bu1,id2,ru1] end - sync_threads() - - bu1, ru1 = up((b, r), id1, lp) - bu2, ru2 = up((b, r), id2, lp) + if ru2 == r + gt2 = Ush[bu2,1] + else + gt2 = U[bu2,id1,ru2] + end plx[b,r] += tr(Ush[b,1]*gt1 / (Ush[b,2]*gt2)) + end end - + return nothing end diff --git a/src/YM/YMflow.jl b/src/YM/YMflow.jl index b282d8b..ba4e517 100644 --- a/src/YM/YMflow.jl +++ b/src/YM/YMflow.jl @@ -13,7 +13,7 @@ function wfl_euler(U, ns, eps, lp::SpaceParm, ymws::YMworkspace) for i in 1:ns force_wilson(ymws, U, lp) - U .= expm(U, ymws.frc1, 2*eps) + U .= expm.(U, ymws.frc1, 2*eps) end return nothing @@ -25,18 +25,18 @@ function wfl_rk3(U, ns, eps, lp::SpaceParm, ymws::YMworkspace) c0 = eps/2 force_wilson(ymws, U, lp) ymws.mom .= ymws.frc1 - U .= expm(U, ymws.mom, c0) + U .= expm.(U, ymws.mom, c0) c0 = -34*eps/36 c1 = 16*eps/9 force_wilson(ymws, U, lp) ymws.mom .= c0.*ymws.mom .+ c1.*ymws.frc1 - U .= expm(U, ymws.mom) + U .= expm.(U, ymws.mom) c1 = 6*eps/4 force_wilson(ymws, U, lp) ymws.mom .= c1.*ymws.frc1 .- ymws.mom - U .= expm(U, ymws.mom) + U .= expm.(U, ymws.mom) end return nothing diff --git a/src/YM/YMhmc.jl b/src/YM/YMhmc.jl index 56fcc68..8b02100 100644 --- a/src/YM/YMhmc.jl +++ b/src/YM/YMhmc.jl @@ -15,7 +15,7 @@ Returns the value of the Wilson plaquette action for the configuration U. """ -function gauge_action(U, lp::SpaceParm, gp::GaugeParm{T}, ymws::YMworkspace{T}) where T <: A +function gauge_action(U, lp::SpaceParm, gp::GaugeParm{T}, ymws::YMworkspace{T}) where T <: AbstractFloat CUDA.@sync begin CUDA.@cuda threads=lp.bsz blocks=lp.rsz krnl_plaq!(ymws.cm, U, lp) diff --git a/src/main/test.jl b/src/main/test.jl index d6b1031..2290676 100644 --- a/src/main/test.jl +++ b/src/main/test.jl @@ -12,7 +12,7 @@ println(CUDA.device()) GRP = SU3 ALG = SU3alg PREC = Float64 -lp = SpaceParm{4}((64,64,64,64), (4,4,4,4)) +lp = SpaceParm{4}((32,32,32,32), (4,4,4,4)) gp = GaugeParm{PREC}(6.0, (0.0,0.0), 3) println("Space Parameters: ", lp) @@ -28,6 +28,10 @@ println("Allocating gauge field") U = field(GRP{PREC}, lp) fill!(U, one(GRP{PREC})) +println("Take to take the configuration to memory: ") +@time Ucpu = Array(U) + + println("Allocating YM workspace") ymws = YMworkspace(GRP, PREC, lp, save_mem = true) @@ -60,10 +64,12 @@ for i in 1:ntot println("# Plaquette: ", pl[end], "\n") end -io = open("foo.txt", "w") -for i in 1:ntot - println(io, pl[i]) -end +@time wfl_rk3(U, 1, 0.01, lp, ymws) + +println("Action: ", gauge_action(U, lp, gp, ymws)) +println("Time for 100 steps of RK3 flow integrator: ") +@time wfl_rk3(U, 100, 0.01, lp, ymws) +println("Action: ", gauge_action(U, lp, gp, ymws)) println("END")