Skip to content

Commit

Permalink
Cycle args for optimizing, gpu syncing improvements, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoreilly committed Nov 21, 2024
1 parent 30f657d commit 69345bd
Show file tree
Hide file tree
Showing 18 changed files with 711 additions and 759 deletions.
6 changes: 3 additions & 3 deletions axon/act-layer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions axon/act-layer.goal
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func (ly *LayerParams) GInteg(ctx *Context, pi, ni, di uint32) {
// drvAct is for Pulvinar layers, activation of driving neuron
func (ly *LayerParams) SpecialPreGs(ctx *Context, pi, ni, di uint32, drvGe float32, nonDrivePct float32) float32 {
saveVal := float32(0) // sometimes we need to use a value computed here, for the post Gs step
pi0 := pi - 1 // 0-n pool index
pi0 := pi - ly.PoolSt - 1 // 0-n pool index
pnn := uint32(PoolNNeurons(pi))
pni := NeuronIxs[NrnNeurIndex, ni] - uint32(PoolsInt[PoolNeurSt, pi, di])
nrnCtxtGe := Neurons[CtxtGe, ni, di]
Expand Down Expand Up @@ -462,7 +462,7 @@ func (ly *LayerParams) GFromRawSyn(ctx *Context, ni, di uint32) {
extraSyn = md * nrnGModSyn * ly.Acts.Dend.ModGain
default:
if ly.Acts.Dend.HasMod.IsTrue() {
md := ly.Acts.Dend.ModBase + ly.Acts.Dend.ModGain*nrnGModSyn
md := ly.Acts.Dend.ModBase + ly.Acts.Dend.ModGain * nrnGModSyn
if md > 1 {
md = 1
}
Expand Down Expand Up @@ -566,7 +566,7 @@ func (ly *LayerParams) SendSpike(ctx *Context, ni, di uint32) {
func (ly *LayerParams) PostSpikeSpecial(ctx *Context, lpi, pi, ni, di uint32) {
Neurons[Burst, ni, di] = Neurons[CaSpkP, ni, di]
li := ly.Index
pi0 := pi - 1 // 0-n pool index
pi0 := pi - ly.PoolSt - 1 // 0-n pool index
pnn := uint32(PoolNNeurons(pi))
pni := NeuronIxs[NrnNeurIndex, ni] - uint32(PoolsInt[PoolNeurSt, pi, di])
hasRew := GlobalScalars[GvHasRew, di] > 0
Expand Down
39 changes: 27 additions & 12 deletions axon/act-net.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 27 additions & 12 deletions axon/act-net.goal
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,36 @@

package axon

// Cycle runs one cycle of activation updating using threading methods.
func (nt *Network) Cycle() {
// todo: chunks of 10 cycles
// todo: don't even need layer-level ultimately.

// Cycle runs n cycles of activation updating.
// If getNeurons is true, then neuron state is synced back
// from the GPU (for cycle-level display etc). Otherwise only
// layer-level state is synced.
func (nt *Network) Cycle(ncyc int, getNeurons bool) {
nix := nt.NetIxs()
ctx := nt.Context()
nd := int(nix.NNeurons * ctx.NData)
ld := int(nix.NLayers * ctx.NData)
pd := int(nix.NPools * ctx.NData)
RunGatherSpikes(nd)
RunLayerGi(ld)
RunBetweenGi(ld)
RunPoolGi(pd)
RunCycleNeuron(nd)
RunSendSpike(nd)
RunCyclePost(ld)
RunCycleInc(1)

RunDoneLayers()
ToGPUCtxGlobal()
for range ncyc {
RunGatherSpikes(nd)
RunLayerGi(ld)
RunBetweenGi(ld)
RunPoolGi(pd)
RunCycleNeuron(nd)
RunSendSpike(nd)
RunCyclePost(ld)
RunCycleInc(1)
}

if getNeurons {
RunDoneLayersNeurons()
} else {
RunDoneLayers()
}

// todo: fix this:
// var ldt, vta *Layer
Expand Down Expand Up @@ -64,6 +76,7 @@ func (nt *Network) ApplyExts() {
if !UseGPU {
return
}
ToGPU(ExtsVar)
nix := nt.NetIxs()
ctx := nt.Context()
nd := int(nix.NNeurons * ctx.NData)
Expand All @@ -79,6 +92,7 @@ func (nt *Network) MinusPhase() {
RunMinusPhasePool(pd)
RunMinusPhaseNeuron(nd)
nt.MinusPhasePost()
ToGPULayersNeurons()
// todo:
// nt.GPU.SyncStateToGPU()
}
Expand Down Expand Up @@ -112,6 +126,7 @@ func (nt *Network) PlusPhase() {
RunPlusPhasePool(pd)
RunPlusPhaseNeuron(nd)
nt.PlusPhasePost()
ToGPULayersNeurons()
// todo:
// nt.GPU.SyncStateToGPU()
}
Expand Down
Loading

0 comments on commit 69345bd

Please sign in to comment.