diff --git a/pyNN/neuron/nmodl/gif.mod b/pyNN/neuron/nmodl/gif.mod index 7829fcd3..b14599b5 100644 --- a/pyNN/neuron/nmodl/gif.mod +++ b/pyNN/neuron/nmodl/gif.mod @@ -55,8 +55,13 @@ VERBATIM #include #include +#ifndef NRN_VERSION_GTEQ_8_2_0 double nrn_random_pick(void* r); void* nrn_random_arg(int argpos); +#define RANDCAST +#else +#define RANDCAST (Rand*) +#endif ENDVERBATIM ASSIGNED { @@ -199,7 +204,7 @@ VERBATIM : each instance. However, the corresponding hoc Random : distribution MUST be set to Random.negexp(1) */ - value = nrn_random_pick(_p_rng); + value = nrn_random_pick(RANDCAST _p_rng); //printf("random stream for this simulation = %lf\n",value); return value; }else{ @@ -208,7 +213,7 @@ ENDVERBATIM : independent of nhost or which host this instance is on : is desired, since each instance on this cpu draws from : the same stream - value = scop_random(1) + value = scop_random() VERBATIM } ENDVERBATIM diff --git a/pyNN/neuron/nmodl/netstim2.mod b/pyNN/neuron/nmodl/netstim2.mod index c612422e..eb60a82c 100755 --- a/pyNN/neuron/nmodl/netstim2.mod +++ b/pyNN/neuron/nmodl/netstim2.mod @@ -72,8 +72,13 @@ FUNCTION invl(mean (ms)) (ms) { } } VERBATIM +#ifndef NRN_VERSION_GTEQ_8_2_0 double nrn_random_pick(void* r); void* nrn_random_arg(int argpos); +#define RANDCAST +#else +#define RANDCAST (Rand*) +#endif ENDVERBATIM FUNCTION erand() { @@ -84,7 +89,7 @@ VERBATIM : each instance. However, the corresponding hoc Random : distribution MUST be set to Random.negexp(1) */ - _lerand = nrn_random_pick(_p_donotuse); + _lerand = nrn_random_pick(RANDCAST _p_donotuse); }else{ /* only can be used in main thread */ if (_nt != nrn_threads) { diff --git a/pyNN/neuron/nmodl/quantal_stp.mod b/pyNN/neuron/nmodl/quantal_stp.mod index 6d976501..f7ed37c9 100644 --- a/pyNN/neuron/nmodl/quantal_stp.mod +++ b/pyNN/neuron/nmodl/quantal_stp.mod @@ -82,8 +82,13 @@ NET_RECEIVE(w, available, t_last (ms)) { } VERBATIM +#ifndef NRN_VERSION_GTEQ_8_2_0 double nrn_random_pick(void* r); void* nrn_random_arg(int argpos); +#define RANDCAST +#else +#define RANDCAST (Rand*) +#endif ENDVERBATIM PROCEDURE setRNG() { @@ -110,12 +115,12 @@ VERBATIM : each instance. However, the corresponding hoc Random : distribution MUST be set to Random.negexp(1) */ - value = nrn_random_pick(_p_rng); + value = nrn_random_pick(RANDCAST _p_rng); //printf("random stream for this simulation = %lf\n",value); return value; } else { ENDVERBATIM - value = scop_random(1) + value = scop_random() VERBATIM } ENDVERBATIM diff --git a/pyNN/neuron/nmodl/stochastic_synapse.mod b/pyNN/neuron/nmodl/stochastic_synapse.mod index 87da7bad..8a8906c1 100644 --- a/pyNN/neuron/nmodl/stochastic_synapse.mod +++ b/pyNN/neuron/nmodl/stochastic_synapse.mod @@ -21,8 +21,13 @@ VERBATIM #include #include +#ifndef NRN_VERSION_GTEQ_8_2_0 double nrn_random_pick(void* r); void* nrn_random_arg(int argpos); +#define RANDCAST +#else +#define RANDCAST (Rand*) +#endif ENDVERBATIM @@ -63,12 +68,12 @@ VERBATIM : each instance. However, the corresponding hoc Random : distribution MUST be set to Random.negexp(1) */ - value = nrn_random_pick(_p_rng); + value = nrn_random_pick(RANDCAST _p_rng); //printf("random stream for this simulation = %lf\n",value); return value; } else { ENDVERBATIM - value = scop_random(1) + value = scop_random() VERBATIM } ENDVERBATIM diff --git a/pyNN/neuron/nmodl/stochastic_tsodyksmarkram.mod b/pyNN/neuron/nmodl/stochastic_tsodyksmarkram.mod index 519e578c..5e2fc104 100644 --- a/pyNN/neuron/nmodl/stochastic_tsodyksmarkram.mod +++ b/pyNN/neuron/nmodl/stochastic_tsodyksmarkram.mod @@ -85,8 +85,13 @@ NET_RECEIVE(w, p_surv, t_surv) { } VERBATIM +#ifndef NRN_VERSION_GTEQ_8_2_0 double nrn_random_pick(void* r); void* nrn_random_arg(int argpos); +#define RANDCAST +#else +#define RANDCAST (Rand*) +#endif ENDVERBATIM PROCEDURE setRNG() { @@ -113,12 +118,12 @@ VERBATIM : each instance. However, the corresponding hoc Random : distribution MUST be set to Random.negexp(1) */ - value = nrn_random_pick(_p_rng); + value = nrn_random_pick(RANDCAST _p_rng); //printf("random stream for this simulation = %lf\n",value); return value; } else { ENDVERBATIM - value = scop_random(1) + value = scop_random() VERBATIM } ENDVERBATIM diff --git a/pyNN/neuron/nmodl/tsodyksmarkram.mod b/pyNN/neuron/nmodl/tsodyksmarkram.mod index c4580fe3..569e014a 100644 --- a/pyNN/neuron/nmodl/tsodyksmarkram.mod +++ b/pyNN/neuron/nmodl/tsodyksmarkram.mod @@ -5,6 +5,7 @@ Andrew Davison, UNIC, CNRS, 2013 ENDCOMMENT NEURON { + THREADSAFE POINT_PROCESS TsodyksMarkramWA RANGE tau_rec, tau_facil, U, u0, tau_syn POINTER wsyn diff --git a/pyNN/neuron/simulator.py b/pyNN/neuron/simulator.py index f95c3339..09c5d10e 100644 --- a/pyNN/neuron/simulator.py +++ b/pyNN/neuron/simulator.py @@ -26,6 +26,7 @@ import warnings import numpy as np +import neuron from neuron import h, nrn_dll_loaded from .. import common @@ -76,30 +77,11 @@ def load_mechanisms(path): which the directory 'i686' (or 'x86_64' or 'powerpc' depending on your platform) was created. """ - import platform - - if path in nrn_dll_loaded: - logger.warning("Mechanisms already loaded from path: %s" % path) - return - # in case NEURON is assuming a different architecture to Python, - # we try multiple possibilities - if platform.system() == 'Windows': - lib_path = os.path.join(path, 'nrnmech.dll') - if os.path.exists(lib_path): - h.nrn_load_dll(lib_path) - nrn_dll_loaded.append(path) - return - else: - arch_list = [platform.machine(), 'i686', 'x86_64', 'powerpc', 'umac'] - for arch in arch_list: - lib_path = os.path.join(path, arch, '.libs', 'libnrnmech.so') - if os.path.exists(lib_path): - h.nrn_load_dll(lib_path) - nrn_dll_loaded.append(path) - return - raise IOError( - f"NEURON mechanisms not found in {path}. " - "You may need to run 'nrnivmodl' in this directory.") + result = neuron.load_mechanisms(path) + if not result: + raise IOError( + f"NEURON mechanisms not found in {path}. " + "You may need to run 'nrnivmodl' in this directory.") def is_point_process(obj):