Skip to content

Commit

Permalink
Use floating-point literals in benchmark equations
Browse files Browse the repository at this point in the history
Else the benchmarks fail for brian2genn, see brian-team/brian2genn#133
  • Loading branch information
denisalevi committed Sep 8, 2021
1 parent bd58b94 commit 415d837
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 42 deletions.
40 changes: 20 additions & 20 deletions brian2cuda/tests/features/speed.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ def run(self):
dh/dt = alpha_h*(1-h)-beta_h*h : 1
dge/dt = -ge*(1./taue) : siemens
dgi/dt = -gi*(1./taui) : siemens
alpha_m = 0.32*(mV**-1)*(13*mV-v+VT)/
(exp((13*mV-v+VT)/(4*mV))-1.)/ms : Hz
beta_m = 0.28*(mV**-1)*(v-VT-40*mV)/
(exp((v-VT-40*mV)/(5*mV))-1)/ms : Hz
alpha_h = 0.128*exp((17*mV-v+VT)/(18*mV))/ms : Hz
beta_h = 4./(1+exp((40*mV-v+VT)/(5*mV)))/ms : Hz
alpha_n = 0.032*(mV**-1)*(15*mV-v+VT)/
(exp((15*mV-v+VT)/(5*mV))-1.)/ms : Hz
beta_n = .5*exp((10*mV-v+VT)/(40*mV))/ms : Hz
alpha_m = 0.32*(mV**-1)*(13.*mV-v+VT)/
(exp((13.*mV-v+VT)/(4.*mV))-1.)/ms : Hz
beta_m = 0.28*(mV**-1.)*(v-VT-40.*mV)/
(exp((v-VT-40.*mV)/(5.*mV))-1.)/ms : Hz
alpha_h = 0.128*exp((17.*mV-v+VT)/(18.*mV))/ms : Hz
beta_h = 4./(1.+exp((40.*mV-v+VT)/(5.*mV)))/ms : Hz
alpha_n = 0.032*(mV**-1.)*(15.*mV-v+VT)/
(exp((15.*mV-v+VT)/(5.*mV))-1.)/ms : Hz
beta_n = .5*exp((10.*mV-v+VT)/(40.*mV))/ms : Hz
''')

P = NeuronGroup(self.n, model=eqs, threshold='v>-20*mV', refractory=3*ms,
Expand Down Expand Up @@ -635,22 +635,22 @@ def run(self):
scale = .675

traub_miles = '''
dV/dt = -(1/C)*(g_Na*m**3*h*(V - E_Na) +
g_K*n**4*(V - E_K) +
dV/dt = -(1./C)*(g_Na*m**3.*h*(V - E_Na) +
g_K*n**4.*(V - E_K) +
g_leak*(V - E_leak) +
I_syn) : volt
dm/dt = alpha_m*(1 - m) - beta_m*m : 1
dn/dt = alpha_n*(1 - n) - beta_n*n : 1
dh/dt = alpha_h*(1 - h) - beta_h*h : 1
alpha_m = 0.32*(mV**-1)*(13*mV-V+VT)/
(exp((13*mV-V+VT)/(4*mV))-1.)/ms : Hz
beta_m = 0.28*(mV**-1)*(V-VT-40*mV)/
(exp((V-VT-40*mV)/(5*mV))-1)/ms : Hz
alpha_h = 0.128*exp((17*mV-V+VT)/(18*mV))/ms : Hz
beta_h = 4./(1+exp((40*mV-V+VT)/(5*mV)))/ms : Hz
alpha_n = 0.032*(mV**-1)*(15*mV-V+VT)/
(exp((15*mV-V+VT)/(5*mV))-1.)/ms : Hz
beta_n = .5*exp((10*mV-V+VT)/(40*mV))/ms : Hz
alpha_m = 0.32*(mV**-1)*(13.*mV-V+VT)/
(exp((13.*mV-V+VT)/(4.*mV))-1.)/ms : Hz
beta_m = 0.28*(mV**-1)*(V-VT-40.*mV)/
(exp((V-VT-40.*mV)/(5.*mV))-1.)/ms : Hz
alpha_h = 0.128*exp((17.*mV-V+VT)/(18.*mV))/ms : Hz
beta_h = 4./(1.+exp((40.*mV-V+VT)/(5.*mV)))/ms : Hz
alpha_n = 0.032*(mV**-1.)*(15.*mV-V+VT)/
(exp((15.*mV-V+VT)/(5.*mV))-1.)/ms : Hz
beta_n = .5*exp((10*mV-V+VT)/(40.*mV))/ms : Hz
'''

# Principal neurons (Antennal Lobe)
Expand Down
18 changes: 9 additions & 9 deletions examples/cobahh.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@
dh/dt = alpha_h*(1-h)-beta_h*h : 1
dge/dt = -ge*(1./taue) : siemens
dgi/dt = -gi*(1./taui) : siemens
alpha_m = 0.32*(mV**-1)*(13*mV-v+VT)/
(exp((13*mV-v+VT)/(4*mV))-1.)/ms : Hz
beta_m = 0.28*(mV**-1)*(v-VT-40*mV)/
(exp((v-VT-40*mV)/(5*mV))-1)/ms : Hz
alpha_h = 0.128*exp((17*mV-v+VT)/(18*mV))/ms : Hz
beta_h = 4./(1+exp((40*mV-v+VT)/(5*mV)))/ms : Hz
alpha_n = 0.032*(mV**-1)*(15*mV-v+VT)/
(exp((15*mV-v+VT)/(5*mV))-1.)/ms : Hz
beta_n = .5*exp((10*mV-v+VT)/(40*mV))/ms : Hz
alpha_m = 0.32*(mV**-1)*(13.*mV-v+VT)/
(exp((13.*mV-v+VT)/(4.*mV))-1.)/ms : Hz
beta_m = 0.28*(mV**-1.)*(v-VT-40.*mV)/
(exp((v-VT-40.*mV)/(5.*mV))-1.)/ms : Hz
alpha_h = 0.128*exp((17.*mV-v+VT)/(18.*mV))/ms : Hz
beta_h = 4./(1.+exp((40.*mV-v+VT)/(5.*mV)))/ms : Hz
alpha_n = 0.032*(mV**-1.)*(15.*mV-v+VT)/
(exp((15.*mV-v+VT)/(5.*mV))-1.)/ms : Hz
beta_n = .5*exp((10.*mV-v+VT)/(40.*mV))/ms : Hz
''')

P = NeuronGroup(params['N'], model=eqs, threshold='v>-20*mV', refractory=3*ms,
Expand Down
31 changes: 18 additions & 13 deletions examples/mushroombody.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@
from brian2 import *
if params['devicename'] == 'cuda_standalone':
import brian2cuda
elif params['devicename'] == 'genn':
import brian2genn
if params['profiling']:
prefs['devices.genn.kernel_timing'] = True
params['profiling'] = False

# set brian2 prefs from params dict
name = set_prefs(params, prefs)
Expand Down Expand Up @@ -118,22 +123,22 @@
scale = .675

traub_miles = '''
dV/dt = -(1/C)*(g_Na*m**3*h*(V - E_Na) +
g_K*n**4*(V - E_K) +
dV/dt = -(1./C)*(g_Na*m**3.*h*(V - E_Na) +
g_K*n**4.*(V - E_K) +
g_leak*(V - E_leak) +
I_syn) : volt
dm/dt = alpha_m*(1 - m) - beta_m*m : 1
dn/dt = alpha_n*(1 - n) - beta_n*n : 1
dh/dt = alpha_h*(1 - h) - beta_h*h : 1
alpha_m = 0.32*(mV**-1)*(13*mV-V+VT)/
(exp((13*mV-V+VT)/(4*mV))-1.)/ms : Hz
beta_m = 0.28*(mV**-1)*(V-VT-40*mV)/
(exp((V-VT-40*mV)/(5*mV))-1)/ms : Hz
alpha_h = 0.128*exp((17*mV-V+VT)/(18*mV))/ms : Hz
beta_h = 4./(1+exp((40*mV-V+VT)/(5*mV)))/ms : Hz
alpha_n = 0.032*(mV**-1)*(15*mV-V+VT)/
(exp((15*mV-V+VT)/(5*mV))-1.)/ms : Hz
beta_n = .5*exp((10*mV-V+VT)/(40*mV))/ms : Hz
alpha_m = 0.32*(mV**-1)*(13.*mV-V+VT)/
(exp((13.*mV-V+VT)/(4.*mV))-1.)/ms : Hz
beta_m = 0.28*(mV**-1)*(V-VT-40.*mV)/
(exp((V-VT-40.*mV)/(5.*mV))-1.)/ms : Hz
alpha_h = 0.128*exp((17.*mV-V+VT)/(18.*mV))/ms : Hz
beta_h = 4./(1.+exp((40.*mV-V+VT)/(5.*mV)))/ms : Hz
alpha_n = 0.032*(mV**-1.)*(15.*mV-V+VT)/
(exp((15.*mV-V+VT)/(5.*mV))-1.)/ms : Hz
beta_n = .5*exp((10*mV-V+VT)/(40.*mV))/ms : Hz
'''

# Principal neurons (Antennal Lobe)
Expand Down Expand Up @@ -192,11 +197,11 @@
''',
on_pre='''g_iKC_eKC += g_raw
Apre += dApre
g_raw = clip(g_raw + Apost, 0, g_max)
g_raw = clip(g_raw + Apost, 0*siemens, g_max)
''',
on_post='''
Apost += dApost
g_raw = clip(g_raw + Apre, 0, g_max)''',
g_raw = clip(g_raw + Apre, 0*siemens, g_max)''',
)
eKC_eKC = Synapses(eKC, eKC, on_pre='g_eKC_eKC += scale*w_eKC_eKC')
PN_iKC.connect(p=0.15)
Expand Down

0 comments on commit 415d837

Please sign in to comment.