From 0693b2f06e29da99987064b8beba2456dcbb3133 Mon Sep 17 00:00:00 2001 From: GiggleLiu Date: Mon, 10 May 2021 21:15:00 -0400 Subject: [PATCH] fix nilang version --- Project.toml | 2 +- src/reversible/chimera.jl | 33 ++++++++++++++++++++----------- src/reversible/second_neighbor.jl | 30 +++++++++++++++++----------- src/reversible/square.jl | 22 +++++++++++++-------- 4 files changed, 54 insertions(+), 33 deletions(-) diff --git a/Project.toml b/Project.toml index 3f78c81..7ad271c 100644 --- a/Project.toml +++ b/Project.toml @@ -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" diff --git a/src/reversible/chimera.jl b/src/reversible/chimera.jl index 817d4b2..64d9814 100644 --- a/src/reversible/chimera.jl +++ b/src/reversible/chimera.jl @@ -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") @@ -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 @@ -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") @@ -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 diff --git a/src/reversible/second_neighbor.jl b/src/reversible/second_neighbor.jl index 580aa36..14af52c 100644 --- a/src/reversible/second_neighbor.jl +++ b/src/reversible/second_neighbor.jl @@ -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 @@ -61,6 +63,7 @@ end l → length(hs) k → length(Js) summed → one(TT) + ~@routine end end @@ -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 @@ -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 diff --git a/src/reversible/square.jl b/src/reversible/square.jl index 61a4c04..0988945 100644 --- a/src/reversible/square.jl +++ b/src/reversible/square.jl @@ -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 @@ -46,6 +48,7 @@ NiLang.SWAP(summed.n, out!) k → length(Js) summed → one(TT) + ~@routine end end @@ -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 @@ -95,6 +100,7 @@ end NiLang.SWAP(summed.n, out!) k → length(Js) summed → one(TT) + ~@routine end end