From 0a33c84c10d98b4929f8c508e5213f72c0ac76bc Mon Sep 17 00:00:00 2001 From: "Fernando P. Panadero" Date: Thu, 22 Feb 2024 12:24:42 +0100 Subject: [PATCH] Log file and gauge measurements --- input/sfcf.in | 4 +- output/randfield.fA | 8 ---- output/randfield.fP | 8 ---- output/randfield.gA | 8 ---- output/randfield.gP | 8 ---- sfcf.jl | 21 +++++--- src/corr.jl | 114 ++++++++++++++++++++++---------------------- src/io.jl | 59 +++++++++++++++-------- src/meas.jl | 100 ++++++++++++++++++++++++++++++++++++++ src/props.jl | 77 ------------------------------ 10 files changed, 212 insertions(+), 195 deletions(-) delete mode 100644 output/randfield.fA delete mode 100644 output/randfield.fP delete mode 100644 output/randfield.gA delete mode 100644 output/randfield.gP create mode 100644 src/meas.jl delete mode 100644 src/props.jl diff --git a/input/sfcf.in b/input/sfcf.in index 7499ed3..c17b8fa 100644 --- a/input/sfcf.in +++ b/input/sfcf.in @@ -1,6 +1,6 @@ [Run] -user = "Lattice user" -name = "Template run" +user = "Lattice_user" +name = "Template_run" [Space] size = [8,8,8,8] diff --git a/output/randfield.fA b/output/randfield.fA deleted file mode 100644 index dbb44f1..0000000 --- a/output/randfield.fA +++ /dev/null @@ -1,8 +0,0 @@ -1 0.0 + 0.0im -2 -31.04305231567254 + 2.1252056646610396e-18im -3 -1.4671112666898436 - 9.031488800098977e-20im -4 -0.06537188111892875 + 2.716461131624143e-21im -5 -0.002933795526834015 - 2.365736551901659e-22im -6 -0.00013043629270008468 + 1.8495241508802853e-23im -7 -5.875876629837171e-6 + 4.476186102841274e-25im -8 -2.726581392340069e-7 + 6.563322731438818e-27im diff --git a/output/randfield.fP b/output/randfield.fP deleted file mode 100644 index 891060c..0000000 --- a/output/randfield.fP +++ /dev/null @@ -1,8 +0,0 @@ -1 0.0 + 0.0im -2 73.67395934956765 + 0.0im -3 3.3887421125734036 + 0.0im -4 0.15144928799903828 + 0.0im -5 0.006828696539887742 + 0.0im -6 0.0003023150684989386 + 0.0im -7 1.361849306449979e-5 + 0.0im -8 6.375793198531621e-7 + 0.0im diff --git a/output/randfield.gA b/output/randfield.gA deleted file mode 100644 index 770405d..0000000 --- a/output/randfield.gA +++ /dev/null @@ -1,8 +0,0 @@ -1 0.0 + 0.0im -2 -2.7310053780937123e-7 - 4.550149701314796e-27im -3 -5.8143401218682364e-6 + 1.6206358436860467e-25im -4 -0.00013056821426116682 - 5.932435955653745e-24im -5 -0.0029261383446798125 + 7.222320723353623e-23im -6 -0.06619259853464403 - 3.22931311140702e-21im -7 -1.4692707713700914 + 2.5710096927128185e-19im -8 -30.89429497223169 - 3.0001906991747318e-18im diff --git a/output/randfield.gP b/output/randfield.gP deleted file mode 100644 index 92d1afb..0000000 --- a/output/randfield.gP +++ /dev/null @@ -1,8 +0,0 @@ -1 0.0 + 0.0im -2 6.435062273546668e-7 + 0.0im -3 1.3621688998858976e-5 + 0.0im -4 0.00030680086560982034 + 0.0im -5 0.006857460528564787 + 0.0im -6 0.1539180922119846 + 0.0im -7 3.3981870666381786 + 0.0im -8 73.17751168291873 + 0.0im diff --git a/sfcf.jl b/sfcf.jl index 39b6c27..fa68426 100644 --- a/sfcf.jl +++ b/sfcf.jl @@ -5,15 +5,21 @@ using ArgParse using CUDA include("./src/io.jl") -include("./src/props.jl") +include("./src/meas.jl") include("./src/corr.jl") -@timeit "Input reading" begin -read_input() -load_structs() -U = load_gauge_field() +@timeit "Imput reading and space allocation" begin + read_input() + load_structs() + U = vector_field(SU3{Float64}, lp) end +log_file = open("./output/"*params["Run"]["name"]*".log","w+") +write_log() + +@timeit "Gauge field reading" U .= load_gauge_field() + +@timeit "Gauge measurements" gauge_meas() @timeit "Propagator computation" compute_propagators() @@ -21,4 +27,7 @@ end print("\n\n") -print_timer() +print_timer(log_file) + +flush(log_file) +close(log_file) diff --git a/src/corr.jl b/src/corr.jl index 9427a6f..1f16559 100644 --- a/src/corr.jl +++ b/src/corr.jl @@ -20,7 +20,6 @@ function fP_fun() return cf end - function fA_fun() cf = Vector{Complex{Float64}}(undef,lp.iL[4]) for t in 1:lp.iL[4] @@ -34,7 +33,6 @@ function fA_fun() return cf end - function gP_fun() cf = Vector{Complex{Float64}}(undef,lp.iL[4]) for t in 1:lp.iL[4] @@ -47,7 +45,6 @@ function gP_fun() return cf end - function gA_fun() cf = Vector{Complex{Float64}}(undef,lp.iL[4]) for t in 1:lp.iL[4] @@ -78,7 +75,6 @@ function kV_fun() return cf end - function lV_fun() cf = Vector{Complex{Float64}}(undef,lp.iL[4]) for t in 1:lp.iL[4] @@ -96,7 +92,6 @@ function lV_fun() return cf end - function kT_fun() cf = Vector{Complex{Float64}}(undef,lp.iL[4]) for t in 1:lp.iL[4] @@ -114,7 +109,6 @@ function kT_fun() return cf end - function lT_fun() cf = Vector{Complex{Float64}}(undef,lp.iL[4]) for t in 1:lp.iL[4] @@ -145,76 +139,82 @@ k1_fun() = (dot(C11,dmul(Gamma{6},imm(C12))) + dot(C11,dmul(Gamma{7},-C12)) + do function compute_correlators() - println("Computing correlators") + println(log_file,"\nComputing correlators") - println("Computing f1...") - file = open("./output/"*basename(parsed_args["c"])*".f1","w+") + println(log_file,"\nComputing f1...") global f1 = f1_fun() - println(file,f1) - flush(file) - close(file) + println(log_file,"f1 = \n") + println(log_file,f1) + flush(log_file) - println("Computing k1...") - file = open("./output/"*basename(parsed_args["c"])*".k1","w+") + println(log_file,"\nComputing k1...") global k1 = k1_fun() - println(file,k1) - flush(file) - close(file) + println(log_file,"k1 = \n") + println(log_file,k1) + flush(log_file) - println("Computing fP...") - file = open("./output/"*basename(parsed_args["c"])*".fP","w+") + println(log_file,"\nComputing fP...") global fP = fP_fun() - println(file,fP) - flush(file) - close(file) + println(log_file,"fP = \n") + for i in 1:lp.iL[4] + println(log_file,fP[i]) + end + flush(log_file) - println("Computing fA...") - file = open("./output/"*basename(parsed_args["c"])*".fA","w+") + println(log_file,"\nComputing fA...") global fA = fA_fun() - println(file,fA) - flush(file) - close(file) + println(log_file,"fA = \n") + for i in 1:lp.iL[4] + println(log_file,fA[i]) + end + flush(log_file) - println("Computing gP...") - file = open("./output/"*basename(parsed_args["c"])*".gP","w+") + println(log_file,"\nComputing gP...") global gP = gP_fun() - println(file,gP) - flush(file) - close(file) + println(log_file,"gP = \n") + for i in 1:lp.iL[4] + println(log_file,gP[i]) + end + flush(log_file) - println("Computing gA...") - file = open("./output/"*basename(parsed_args["c"])*".gA","w+") + println(log_file,"\nComputing gA...") global gA = gA_fun() - println(file,gA) - flush(file) - close(file) + println(log_file,"gA = \n") + for i in 1:lp.iL[4] + println(log_file,gA[i]) + end + flush(log_file) - println("Computing kV...") - file = open("./output/"*basename(parsed_args["c"])*".kV","w+") + println(log_file,"\nComputing kV...") global kV = kV_fun() - println(file,kV) - flush(file) - close(file) + println(log_file,"kV = \n") + for i in 1:lp.iL[4] + println(log_file,kV[i]) + end + flush(log_file) - println("Computing lV...") - file = open("./output/"*basename(parsed_args["c"])*".lV","w+") + println(log_file,"\nComputing lV...") global lV = lV_fun() - println(file,lV) - flush(file) - close(file) + println(log_file,"lV = \n") + for i in 1:lp.iL[4] + println(log_file,lV[i]) + end + flush(log_file) - println("Computing kT...") - file = open("./output/"*basename(parsed_args["c"])*".kT","w+") + println(log_file,"\nComputing kT...") global kT = kT_fun() - println(file,kT) - flush(file) - close(file) + println(log_file,"kT = \n") + for i in 1:lp.iL[4] + println(log_file,kT[i]) + end + flush(log_file) - println("Computing lT...") - file = open("./output/"*basename(parsed_args["c"])*".lT","w+") + println(log_file,"\nComputing lT...") global lT = lT_fun() - println(file,lT) - flush(file) - close(file) + println(log_file,"lT = \n") + for i in 1:lp.iL[4] + println(log_file,lT[i]) + end + flush(log_file) end diff --git a/src/io.jl b/src/io.jl index 79da828..3a0b58e 100644 --- a/src/io.jl +++ b/src/io.jl @@ -12,8 +12,7 @@ Stores as global variables 'parsed_args' (info from the command line) and 'param """ function read_input() global parsed_args = parse_commandline() - println("--------------------------------------------------") - println("Reading input file from:", parsed_args["i"], "...") + println(log_file,"Reading input file from:", parsed_args["i"], "...") global params = TOML.parsefile(parsed_args["i"]) return nothing end @@ -47,22 +46,22 @@ end function load_gauge_field() Returns the gauge field and computes the Csw term - """ function load_gauge_field() - println("Reading gauge field from: ", parsed_args["c"], "...") if !parsed_args["cern"] + println(log_file,"\nReading gauge field with LGPU native convention from: ", parsed_args["c"], "...\n") U,_ = read_cnfg(parsed_args["c"]) else + println(log_file,"\nReading gauge field with CERN convention from: ", parsed_args["c"], "...\n") U = read_cnfg_cern(parsed_args["c"],lp) end - Csw!(dws, U, gp, lp) + Csw!(dws, U, gp, lp) return U end function read_cnfg_cern(path::String,lp::SpaceParm) - U = vector_field(SU3{Float64}, lp); + Ucpu = Array{SU3{Float64}, 3}(undef, lp.bsz, lp.ndim, lp.rsz) file = open(path) for t in 1:lp.iL[4] for i in 1:lp.iL[1] @@ -118,8 +117,8 @@ function read_cnfg_cern(path::String,lp::SpaceParm) re33 = read(file,Float64) co33 = read(file,Float64) - CUDA.@allowscalar (U[f,d,r] = SU3{Float64}(re11 + im*co11, re12 + im*co12, re13 + im*co13, - re21 + im*co21, re22 + im*co22, re23 + im*co23)) + (Ucpu[f,d,r] = SU3{Float64}(re11 + im*co11, re12 + im*co12, re13 + im*co13, + re21 + im*co21, re22 + im*co22, re23 + im*co23)) end end end @@ -128,7 +127,7 @@ function read_cnfg_cern(path::String,lp::SpaceParm) length(read(file)) == (prod(lp.iL[1:3])*4*8*9*2) ? nothing : error("File not fully read") close(file) - return U + return CuArray(Ucpu) end """ @@ -144,17 +143,35 @@ function load_structs() global dws = DiracWorkspace(SU3fund,Float64,lp); global ymws = YMworkspace(SU3,Float64,lp); - println("Parameters:") - println("Lattice size: ", lp.iL) - println("Phi0 = ", params["Space"]["phi0"]) - println("PhiT = ", params["Space"]["phiT"]) - println("cG = ", gp.cG[1]) - println("kappa = ", params["Fermion"]["kappa"]) - println("theta = ", params["Fermion"]["theta"]) - println("csw = ", dpar.csw) - println("ct = ", dpar.ct) - println("tolerance = ", params["Solver"]["tolerance"]) - println("maxiter = ", params["Solver"]["maxiter"]) - + return nothing +end + +function write_log() + + println(log_file,"Running sfcf.jl by ", params["Run"]["user"],". Name of the run: ",params["Run"]["name"]) + println(log_file,"") + + print(log_file,"Calling: ") + print(log_file,PROGRAM_FILE*" "); for x in ARGS; print(log_file,x*" "); end + println(log_file,"") + + println(log_file,"Version info:") + println(log_file,versioninfo()) + println(log_file,"") + + println(log_file,"Parameters:") + println(log_file,"Lattice size: ", lp.iL) + println(log_file,"Phi0 = ", params["Space"]["phi0"]) + println(log_file,"PhiT = ", params["Space"]["phiT"]) + println(log_file,"cG = ", gp.cG[1]) + println(log_file,"kappa = ", params["Fermion"]["kappa"]) + println(log_file,"theta = ", params["Fermion"]["theta"]) + println(log_file,"csw = ", dpar.csw) + println(log_file,"ct = ", dpar.ct) + println(log_file,"tolerance = ", params["Solver"]["tolerance"]) + println(log_file,"maxiter = ", params["Solver"]["maxiter"]) + println(log_file,"") + + flush(log_file) return nothing end diff --git a/src/meas.jl b/src/meas.jl new file mode 100644 index 0000000..fdbe8f7 --- /dev/null +++ b/src/meas.jl @@ -0,0 +1,100 @@ +using LatticeGPU +using TOML +using TimerOutputs +using ArgParse +using CUDA + +""" + function compute_propagators() + +Computes the propagators for the first two components of spin. +The propagators are stored in Acs (t=0 to bulk), Bcs(bulk to t=T) and Ccs(t=0 to t=T) +""" + +function compute_propagators() + + psi = scalar_field(Spinor{4,SU3fund{Float64}},lp) + + println(log_file,"Computing propagators from t=0 to the bulk") + flush(log_file) + niter = bndpropagator!(psi, U, dpar, dws, lp, params["Solver"]["maxiter"], params["Solver"]["tolerance"], 1, 1) + println(log_file,"CG converged for c=1 and s=1 after ",niter," iterations with absolute residue ", CUDA.mapreduce(x -> norm(x), +, dws.sr)) + global A11 = Array(psi) + global C11 = bndtobnd(psi, U, dpar, dws, lp) + flush(log_file) + + niter = bndpropagator!(psi, U, dpar, dws, lp, params["Solver"]["maxiter"], params["Solver"]["tolerance"], 2, 1) + println(log_file,"CG converged for c=2 and s=1 after ",niter," iterations with absolute residue ", CUDA.mapreduce(x -> norm(x), +, dws.sr)) + global A21 = Array(psi) + global C21 = bndtobnd(psi, U, dpar, dws, lp) + flush(log_file) + + niter = bndpropagator!(psi, U, dpar, dws, lp, params["Solver"]["maxiter"], params["Solver"]["tolerance"], 3, 1) + println(log_file,"CG converged for c=3 and s=1 after ",niter," iterations with absolute residue ", CUDA.mapreduce(x -> norm(x), +, dws.sr)) + global A31 = Array(psi) + global C31 = bndtobnd(psi, U, dpar, dws, lp) + flush(log_file) + + niter = bndpropagator!(psi, U, dpar, dws, lp, params["Solver"]["maxiter"], params["Solver"]["tolerance"], 1, 2) + println(log_file,"CG converged for c=1 and s=2 after ",niter," iterations with absolute residue ", CUDA.mapreduce(x -> norm(x), +, dws.sr)) + global A12 = Array(psi) + global C12 = bndtobnd(psi, U, dpar, dws, lp) + flush(log_file) + + niter = bndpropagator!(psi, U, dpar, dws, lp, params["Solver"]["maxiter"], params["Solver"]["tolerance"], 2, 2) + println(log_file,"CG converged for c=2 and s=2 after ",niter," iterations with absolute residue ", CUDA.mapreduce(x -> norm(x), +, dws.sr)) + global A22 = Array(psi) + global C22 = bndtobnd(psi, U, dpar, dws, lp) + flush(log_file) + + niter = bndpropagator!(psi, U, dpar, dws, lp, params["Solver"]["maxiter"], params["Solver"]["tolerance"], 3, 2) + println(log_file,"CG converged for c=3 and s=2 after ",niter," iterations with absolute residue ", CUDA.mapreduce(x -> norm(x), +, dws.sr)) + global A32 = Array(psi) + global C32 = bndtobnd(psi, U, dpar, dws, lp) + flush(log_file) + + println(log_file,"Computing propagators from t=T to the bulk") + niter = Tbndpropagator!(psi, U, dpar, dws, lp, params["Solver"]["maxiter"], params["Solver"]["tolerance"], 1, 1) + println(log_file,"CG converged for c=1 and s=1 after ",niter," iterations with absolute residue ", CUDA.mapreduce(x -> norm(x), +, dws.sr)) + global B11 = Array(psi) + flush(log_file) + + niter = Tbndpropagator!(psi, U, dpar, dws, lp, params["Solver"]["maxiter"], params["Solver"]["tolerance"], 2, 1) + println(log_file,"CG converged for c=2 and s=1 after ",niter," iterations with absolute residue ", CUDA.mapreduce(x -> norm(x), +, dws.sr)) + global B21 = Array(psi) + flush(log_file) + + niter = Tbndpropagator!(psi, U, dpar, dws, lp, params["Solver"]["maxiter"], params["Solver"]["tolerance"], 3, 1) + println(log_file,"CG converged for c=3 and s=1 after ",niter," iterations with absolute residue ", CUDA.mapreduce(x -> norm(x), +, dws.sr)) + global B31 = Array(psi) + flush(log_file) + + niter = Tbndpropagator!(psi, U, dpar, dws, lp, params["Solver"]["maxiter"], params["Solver"]["tolerance"], 1, 2) + println(log_file,"CG converged for c=1 and s=2 after ",niter," iterations with absolute residue ", CUDA.mapreduce(x -> norm(x), +, dws.sr)) + global B12 = Array(psi) + flush(log_file) + + niter = Tbndpropagator!(psi, U, dpar, dws, lp, params["Solver"]["maxiter"], params["Solver"]["tolerance"], 2, 2) + println(log_file,"CG converged for c=2 and s=2 after ",niter," iterations with absolute residue ", CUDA.mapreduce(x -> norm(x), +, dws.sr)) + global B22 = Array(psi) + flush(log_file) + + niter = Tbndpropagator!(psi, U, dpar, dws, lp, params["Solver"]["maxiter"], params["Solver"]["tolerance"], 3, 2) + println(log_file,"CG converged for c=3 and s=2 after ",niter," iterations with absolute residue ", CUDA.mapreduce(x -> norm(x), +, dws.sr)) + global B32 = Array(psi) + println(log_file,"\n") + flush(log_file) + + return nothing +end + +function gauge_meas() + + println(log_file,"\nGauge meassurements:") + println(log_file,"Plaquette: ", plaquette(U, lp, gp, ymws)) + println(log_file,"Topological charge: ", Qtop(U, gp, lp, ymws)) + println(log_file,"SF coupling (dS/deta): ",sfcoupling(U, lp, gp, ymws)[1]) + flush(log_file) + + return nothing +end diff --git a/src/props.jl b/src/props.jl deleted file mode 100644 index a998c71..0000000 --- a/src/props.jl +++ /dev/null @@ -1,77 +0,0 @@ -using LatticeGPU -using TOML -using TimerOutputs -using ArgParse -using CUDA - -""" - function compute_propagators() - -Computes the propagators for the first two components of spin. -The propagators are stored in Acs (t=0 to bulk), Bcs(bulk to t=T) and Ccs(t=0 to t=T) -""" - -function compute_propagators() - - println("--------------------------------------------------") - psi = scalar_field(Spinor{4,SU3fund{Float64}},lp) - - println("Computing propagators from t=0 to the bulk") - niter = bndpropagator!(psi, U, dpar, dws, lp, params["Solver"]["maxiter"], params["Solver"]["tolerance"], 1, 1) - println("CG converged for c=1 and s=1 after ",niter," iterations with absolute residue ", CUDA.mapreduce(x -> norm(x), +, dws.sr)) - global A11 = Array(psi) - global C11 = bndtobnd(psi, U, dpar, dws, lp) - - niter = bndpropagator!(psi, U, dpar, dws, lp, params["Solver"]["maxiter"], params["Solver"]["tolerance"], 2, 1) - println("CG converged for c=2 and s=1 after ",niter," iterations with absolute residue ", CUDA.mapreduce(x -> norm(x), +, dws.sr)) - global A21 = Array(psi) - global C21 = bndtobnd(psi, U, dpar, dws, lp) - - niter = bndpropagator!(psi, U, dpar, dws, lp, params["Solver"]["maxiter"], params["Solver"]["tolerance"], 3, 1) - println("CG converged for c=3 and s=1 after ",niter," iterations with absolute residue ", CUDA.mapreduce(x -> norm(x), +, dws.sr)) - global A31 = Array(psi) - global C31 = bndtobnd(psi, U, dpar, dws, lp) - - niter = bndpropagator!(psi, U, dpar, dws, lp, params["Solver"]["maxiter"], params["Solver"]["tolerance"], 1, 2) - println("CG converged for c=1 and s=2 after ",niter," iterations with absolute residue ", CUDA.mapreduce(x -> norm(x), +, dws.sr)) - global A12 = Array(psi) - global C12 = bndtobnd(psi, U, dpar, dws, lp) - - niter = bndpropagator!(psi, U, dpar, dws, lp, params["Solver"]["maxiter"], params["Solver"]["tolerance"], 2, 2) - println("CG converged for c=2 and s=2 after ",niter," iterations with absolute residue ", CUDA.mapreduce(x -> norm(x), +, dws.sr)) - global A22 = Array(psi) - global C22 = bndtobnd(psi, U, dpar, dws, lp) - - niter = bndpropagator!(psi, U, dpar, dws, lp, params["Solver"]["maxiter"], params["Solver"]["tolerance"], 3, 2) - println("CG converged for c=3 and s=2 after ",niter," iterations with absolute residue ", CUDA.mapreduce(x -> norm(x), +, dws.sr)) - global A32 = Array(psi) - global C32 = bndtobnd(psi, U, dpar, dws, lp) - - println("Computing propagators from t=T to the bulk") - niter = Tbndpropagator!(psi, U, dpar, dws, lp, params["Solver"]["maxiter"], params["Solver"]["tolerance"], 1, 1) - println("CG converged for c=1 and s=1 after ",niter," iterations with absolute residue ", CUDA.mapreduce(x -> norm(x), +, dws.sr)) - global B11 = Array(psi) - - niter = Tbndpropagator!(psi, U, dpar, dws, lp, params["Solver"]["maxiter"], params["Solver"]["tolerance"], 2, 1) - println("CG converged for c=2 and s=1 after ",niter," iterations with absolute residue ", CUDA.mapreduce(x -> norm(x), +, dws.sr)) - global B21 = Array(psi) - - niter = Tbndpropagator!(psi, U, dpar, dws, lp, params["Solver"]["maxiter"], params["Solver"]["tolerance"], 3, 1) - println("CG converged for c=3 and s=1 after ",niter," iterations with absolute residue ", CUDA.mapreduce(x -> norm(x), +, dws.sr)) - global B31 = Array(psi) - - niter = Tbndpropagator!(psi, U, dpar, dws, lp, params["Solver"]["maxiter"], params["Solver"]["tolerance"], 1, 2) - println("CG converged for c=1 and s=2 after ",niter," iterations with absolute residue ", CUDA.mapreduce(x -> norm(x), +, dws.sr)) - global B12 = Array(psi) - - niter = Tbndpropagator!(psi, U, dpar, dws, lp, params["Solver"]["maxiter"], params["Solver"]["tolerance"], 2, 2) - println("CG converged for c=2 and s=2 after ",niter," iterations with absolute residue ", CUDA.mapreduce(x -> norm(x), +, dws.sr)) - global B22 = Array(psi) - - niter = Tbndpropagator!(psi, U, dpar, dws, lp, params["Solver"]["maxiter"], params["Solver"]["tolerance"], 3, 2) - println("CG converged for c=3 and s=2 after ",niter," iterations with absolute residue ", CUDA.mapreduce(x -> norm(x), +, dws.sr)) - global B32 = Array(psi) - - println("--------------------------------------------------") - return nothing -end