From 415d83792d51f17e8aec31991e2dca95d904555d Mon Sep 17 00:00:00 2001 From: Denis Alevi Date: Wed, 8 Sep 2021 19:27:47 +0200 Subject: [PATCH] Use floating-point literals in benchmark equations Else the benchmarks fail for brian2genn, see brian-team/brian2genn#133 --- brian2cuda/tests/features/speed.py | 40 +++++++++++++++--------------- examples/cobahh.py | 18 +++++++------- examples/mushroombody.py | 31 +++++++++++++---------- 3 files changed, 47 insertions(+), 42 deletions(-) diff --git a/brian2cuda/tests/features/speed.py b/brian2cuda/tests/features/speed.py index 0b80705b..87805a33 100644 --- a/brian2cuda/tests/features/speed.py +++ b/brian2cuda/tests/features/speed.py @@ -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, @@ -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) diff --git a/examples/cobahh.py b/examples/cobahh.py index abbb32cd..91f27630 100644 --- a/examples/cobahh.py +++ b/examples/cobahh.py @@ -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, diff --git a/examples/mushroombody.py b/examples/mushroombody.py index 252ffece..7a985b3a 100644 --- a/examples/mushroombody.py +++ b/examples/mushroombody.py @@ -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) @@ -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) @@ -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)