Skip to content

Commit

Permalink
fix nilang version
Browse files Browse the repository at this point in the history
  • Loading branch information
GiggleLiu committed May 11, 2021
1 parent 3842cf7 commit 0693b2f
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Compose = "0.9"
HDF5 = "0.15"
LightGraphs = "1.3"
LuxurySparse = "0.6"
NiLang = "0.8"
NiLang = "0.8, 0.9"
Requires = "1"
SimpleTensorNetworks = "0.2"
TropicalNumbers = "0.2.1"
Expand Down
33 changes: 21 additions & 12 deletions src/reversible/chimera.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ end

@i function isolve_largemem(out!::T, sg::Spinglass{ChimeraLattice, T}, reg::ArrayReg{B,TT}, REG_STACK) where {B,T,TT<:Tropical{T}}
@invcheckoff begin
Lx sg.lattice.Nx
Ly sg.lattice.Ny
Js sg.Js
hs sg.hs
nj_red (Ly-1)*4 + 16 * Ly
@routine begin
Lx sg.lattice.Nx
Ly sg.lattice.Ny
Js sg.Js
hs sg.hs
nj_red (Ly-1)*4 + 16 * Ly
end
k 0
@safe println("Running Chimera, Lx = $Lx, Ly = $Ly, eltype = $T.")
@safe println("Layer 1/$Lx")
Expand All @@ -33,7 +35,7 @@ end
end

for i=2:Lx
hk (i-1)*Ly*8
@routine hk (i-1)*Ly*8
@safe println("Layer $i/$Lx")
# BLACK
for j=1:Ly*4
Expand All @@ -45,28 +47,33 @@ end
end

# Contract with RED
rr _init_reg(Tropical{T}, Ly*4, Val(false))
@routine rr _init_reg(Tropical{T}, Ly*4, Val(false))
red_reg(rr, Ly, Js[k+1:k+nj_red], hs[hk+1:hk+4Ly], REG_STACK)
reg.state .*= rr.state
incstack!(REG_STACK)
swap_state!(REG_STACK, rr.state)
k += nj_red
~@routine
~@routine
end
summed one(TT)
i_sum(summed, reg.state)
NiLang.SWAP(summed.n, out!)
k length(Js)
summed one(TT)
~@routine
end
end

@i function isolve(out!::T, sg::AbstractSpinglass{ChimeraLattice, T}, reg::ArrayReg{B,TT}, A_STACK, B_STACK) where {B,T,TT<:Tropical{T}}
@invcheckoff begin
Lx sg.lattice.Nx
Ly sg.lattice.Ny
Js sg.Js
hs sg.hs
nj_red (Ly-1)*4 + 16 * Ly
@routine begin
Lx sg.lattice.Nx
Ly sg.lattice.Ny
Js sg.Js
hs sg.hs
nj_red (Ly-1)*4 + 16 * Ly
end
k 0
@safe println("Running Chimera, Lx = $Lx, Ly = $Ly, eltype = $T.")
@safe println("Layer 1/$Lx")
Expand Down Expand Up @@ -112,12 +119,14 @@ end
reg.state .*= rr.state
~@routine
k += nj_red
hk (i-1)*Ly*8
end
summed one(TT)
i_sum(summed, reg.state)
NiLang.SWAP(summed.n, out!)
k length(Js)
summed one(TT)
~@routine
end
end

Expand Down
30 changes: 18 additions & 12 deletions src/reversible/second_neighbor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ end

@i function isolve_largemem(out!::T, sg::AbstractSpinglass{MaskedSquareLattice}, reg::ArrayReg{1,TT}, REG_STACK; usecuda=false) where {T,TT<:Tropical{T}}
@invcheckoff begin
lt sg.lattice
Lx size(lt, 1)
Ly size(lt, 2)
nbit Ly + 2
Js sg.Js
hs sg.hs
@routine begin
lt sg.lattice
Lx size(lt, 1)
Ly size(lt, 2)
nbit Ly + 2
Js sg.Js
hs sg.hs
end
k 0
l 0
for i=1:Lx
Expand Down Expand Up @@ -61,6 +63,7 @@ end
l length(hs)
k length(Js)
summed one(TT)
~@routine
end
end

Expand All @@ -83,12 +86,14 @@ function cachesize_largemem(lt::MaskedSquareLattice)
end

@i function isolve(out!::T, sg::Spinglass{MaskedSquareLattice,T}, reg::ArrayReg{1,TT}, A_STACK, B_STACK; usecuda=false) where {T,TT<:Tropical{T}}
lt sg.lattice
Lx size(lt, 1)
Ly size(lt, 2)
nbit Ly + 2
Js sg.Js
hs sg.hs
@routine begin
lt sg.lattice
Lx size(lt, 1)
Ly size(lt, 2)
nbit Ly + 2
Js sg.Js
hs sg.hs
end
k 0
l 0
for i=1:Lx
Expand Down Expand Up @@ -159,6 +164,7 @@ end
l length(hs)
k length(Js)
summed one(TT)
~@routine
end

cachesize_A(lt::MaskedSquareLattice) = size(lt,2)*3-1
Expand Down
22 changes: 14 additions & 8 deletions src/reversible/square.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
@i function isolve(out!::T, sg::AbstractSpinglass{SquareLattice, T}, reg::ArrayReg{B,TT}, A_STACK, B_STACK) where {B,T,TT<:Tropical{T}}
@invcheckoff begin
Lx sg.lattice.Nx
Ly sg.lattice.Ny
Js sg.Js
hs sg.hs
@routine begin
Lx sg.lattice.Nx
Ly sg.lattice.Ny
Js sg.Js
hs sg.hs
end
@safe println("Layer 1/$Lx, stack size: $(A_STACK.top) & $(B_STACK.top)")
k 0
for j=1:Ly
Expand Down Expand Up @@ -46,6 +48,7 @@
NiLang.SWAP(summed.n, out!)
k length(Js)
summed one(TT)
~@routine
end
end

Expand All @@ -63,10 +66,12 @@ end

@i function isolve_largemem(out!, sg::Spinglass{SquareLattice, T}, reg::ArrayReg{B,TT}, REG_STACK) where {B,T,TT<:Tropical{T}}
@invcheckoff begin
Lx sg.lattice.Nx
Ly sg.lattice.Ny
Js sg.Js
hs sg.hs
@routine begin
Lx sg.lattice.Nx
Ly sg.lattice.Ny
Js sg.Js
hs sg.hs
end
@safe println("Layer 1/$Lx")
k 0
for j=1:Ly
Expand Down Expand Up @@ -95,6 +100,7 @@ end
NiLang.SWAP(summed.n, out!)
k length(Js)
summed one(TT)
~@routine
end
end

Expand Down

0 comments on commit 0693b2f

Please sign in to comment.