mirror of
https://igit.ific.uv.es/alramos/latticegpu.jl.git
synced 2025-05-15 11:43:42 +02:00
Added basic support for simulating Scalar field theories
This commit is contained in:
parent
3f71a5222f
commit
3f8ba58848
5 changed files with 114 additions and 6 deletions
60
src/Scalar/ScalarAction.jl
Normal file
60
src/Scalar/ScalarAction.jl
Normal file
|
@ -0,0 +1,60 @@
|
|||
###
|
||||
### "THE BEER-WARE LICENSE":
|
||||
### Alberto Ramos wrote this file. As long as you retain this
|
||||
### notice you can do whatever you want with this stuff. If we meet some
|
||||
### day, and you think this stuff is worth it, you can buy me a beer in
|
||||
### return. <alberto.ramos@cern.ch>
|
||||
###
|
||||
### file: ScalarAction.jl
|
||||
### created: Tue Oct 5 11:53:49 2021
|
||||
###
|
||||
|
||||
function scalar_action(U, Phi, lp::SpaceParm, sp::ScalarParm, gp::GaugeParm{T}, ymws::YMworkspace{T})
|
||||
|
||||
CUDA.@sync begin
|
||||
CUDA.@cuda threads=lp.bsz blocks=lp.rsz krnl_act!(ymws.rm, U, Phi, sp, lp)
|
||||
end
|
||||
|
||||
S = CUDA.reduce(+, ymws.rm)
|
||||
return S
|
||||
end
|
||||
|
||||
function krnl_act!(act, U::AbstractArray{TG}, Phi::AbstractArray{TS}, sp::ScalarParam{NP,T}, lp::SpaceParm{N,M,D}) where {TG,TS,NP,T,N,M,D}
|
||||
|
||||
|
||||
b, r = CUDA.threadIdx().x, CUDA.blockIdx().x
|
||||
|
||||
Ush = @cuStaticSharedMem(TG, (D,N))
|
||||
Psh = @cuStaticSharedMem(TS, (D,NP))
|
||||
|
||||
for id in 1:N
|
||||
Ush[b,id] = U[b,id,r]
|
||||
end
|
||||
for i in 1:NP
|
||||
Psh[b,i] = Phi[b,i,r]
|
||||
end
|
||||
sync_threads()
|
||||
|
||||
act[b,r] = zero(act[b,r])
|
||||
for id in 1:N
|
||||
bu, ru = up((b, r), id, lp)
|
||||
|
||||
if ru == r
|
||||
Pup = ntuple(i -> Psh[bu,i], NP)
|
||||
else
|
||||
Pup = ntuple(i -> Phi[bu,i,ru], NP)
|
||||
end
|
||||
|
||||
for i in 1:NP
|
||||
act[b,r] += -2*sp.kap[i]*dot(Psh[b,i],Ush[b,id]*Pup[i])
|
||||
end
|
||||
end
|
||||
|
||||
for i in 1:NP
|
||||
sdot = dot(Psh[b,i],Psh[b,i])
|
||||
act[b,r] += sdot + sp.eta[i]*(sdot - 1)^2
|
||||
end
|
||||
|
||||
return nothing
|
||||
end
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue