69 #define COMPACTION_ALIGNMENT_PRE 16 70 #define COMPACTION_ALIGNMENT_POST 0 79 : networkName_(name), preferredSimMode_(preferredSimMode), loggerMode_(loggerMode),
80 randSeed_(
SNN::setRandSeed(randSeed))
88 if (!simulatorDeleted)
97 short int SNN::connect(
int grpId1,
int grpId2,
const std::string& _type,
float initWt,
float maxWt,
float prob,
98 uint8_t minDelay, uint8_t maxDelay,
RadiusRF radius,
99 float _mulSynFast,
float _mulSynSlow,
bool synWtType) {
102 assert(grpId1 < numGroups);
103 assert(grpId2 < numGroups);
104 assert(minDelay <= maxDelay);
124 connConfig.
grpSrc = grpId1;
126 connConfig.
initWt = initWt;
127 connConfig.
maxWt = maxWt;
141 connConfig.
conn = NULL;
144 if ( _type.find(
"random") != std::string::npos) {
148 else if ( _type.find(
"full-no-direct") != std::string::npos) {
151 else if ( _type.find(
"full") != std::string::npos) {
154 else if ( _type.find(
"one-to-one") != std::string::npos) {
156 }
else if ( _type.find(
"gaussian") != std::string::npos) {
159 KERNEL_ERROR(
"Invalid connection type (should be 'random', 'full', 'one-to-one', 'full-no-direct', or 'gaussian')");
164 assert(connConfig.
connId == -1);
165 connConfig.
connId = numConnections;
170 connectConfigMap[numConnections] = connConfig;
175 return (numConnections - 1);
183 assert(grpId1 < numGroups);
184 assert(grpId2 < numGroups);
190 connConfig.
grpSrc = grpId1;
193 connConfig.
maxWt = 0.0f;
200 connConfig.
conn = conn;
208 assert(connConfig.
connId == -1);
209 connConfig.
connId = numConnections;
212 connectConfigMap[numConnections] = connConfig;
217 return (numConnections - 1);
222 assert(grpIdLower >= 0 && grpIdLower < numGroups);
223 assert(grpIdUpper >= 0 && grpIdUpper < numGroups);
224 assert(grpIdLower != grpIdUpper);
229 assert(groupConfigMap[grpIdLower].preferredNetId == groupConfigMap[grpIdUpper].preferredNetId);
234 sim_with_compartments =
true;
238 compConnConfig.
grpSrc = grpIdLower;
239 compConnConfig.
grpDest = grpIdUpper;
240 compConnConfig.
connId = -1;
243 assert(compConnConfig.
connId == -1);
244 compConnConfig.
connId = numCompartmentConnections;
247 compConnectConfigMap[numCompartmentConnections] = compConnConfig;
249 numCompartmentConnections++;
251 return (numCompartmentConnections - 1);
258 assert(neurType >= 0);
263 KERNEL_ERROR(
"Invalid type using createGroup... Cannot create poisson generators here.");
276 grpConfig.
type = neurType;
277 grpConfig.
numN = grid.
N;
280 grpConfig.
grid = grid;
281 grpConfig.
isLIF =
false;
290 if (preferredPartition ==
ANY) {
292 }
else if (preferredBackend ==
CPU_CORES) {
299 grpConfigMD.
gGrpId = numGroups;
302 groupConfigMap[numGroups] = grpConfig;
303 groupConfigMDMap[numGroups] = grpConfigMD;
308 return grpConfigMD.
gGrpId;
315 assert(neurType >= 0);
320 KERNEL_ERROR(
"Invalid type using createGroup... Cannot create poisson generators here.");
330 grpConfig.
type = neurType;
331 grpConfig.
numN = grid.
N;
333 grpConfig.
isLIF =
true;
335 grpConfig.
grid = grid;
343 if (preferredPartition ==
ANY) {
345 }
else if (preferredBackend ==
CPU_CORES) {
352 grpConfigMD.
gGrpId = numGroups;
355 groupConfigMap[numGroups] = grpConfig;
356 groupConfigMDMap[numGroups] = grpConfigMD;
361 return grpConfigMD.
gGrpId;
368 assert(neurType >= 0);
381 grpConfig.
numN = grid.
N;
383 grpConfig.
grid = grid;
384 grpConfig.
isLIF =
false;
392 if (preferredPartition ==
ANY) {
395 else if (preferredBackend ==
CPU_CORES) {
403 grpConfigMD.
gGrpId = numGroups;
406 groupConfigMap[numGroups] = grpConfig;
407 groupConfigMDMap[numGroups] = grpConfigMD;
413 return grpConfigMD.
gGrpId;
418 for (
int grpId = 0; grpId<numGroups; grpId++) {
423 groupConfigMap[gGrpId].withCompartments =
true;
424 groupConfigMap[gGrpId].compCouplingUp = couplingUp;
425 groupConfigMap[gGrpId].compCouplingDown = couplingDown;
426 glbNetworkConfig.
numComp += groupConfigMap[gGrpId].numN;
430 #define LN_I_CALC_TYPES__REQUIRED_FOR_BACKWARD_COMPAT 431 #define LN_I_CALC_TYPES__REQUIRED_FOR_NETWORK_LEVEL 433 void SNN::setConductances(
bool isSet,
int tdAMPA,
int trNMDA,
int tdNMDA,
int tdGABAa,
int trGABAb,
int tdGABAb) {
435 assert(tdAMPA>0); assert(tdNMDA>0); assert(tdGABAa>0); assert(tdGABAb>0);
436 assert(trNMDA>=0); assert(trGABAb>=0);
437 assert(trNMDA!=tdNMDA); assert(trGABAb!=tdGABAb);
441 sim_with_conductances |= isSet;
442 dAMPA = 1.0-1.0/tdAMPA;
443 dNMDA = 1.0-1.0/tdNMDA;
444 dGABAa = 1.0-1.0/tdGABAa;
445 dGABAb = 1.0-1.0/tdGABAb;
449 sim_with_NMDA_rise =
true;
450 rNMDA = 1.0-1.0/trNMDA;
454 double tmax = (-tdNMDA*trNMDA*log(1.0*trNMDA/tdNMDA))/(tdNMDA-trNMDA);
455 sNMDA = 1.0/(exp(-tmax/tdNMDA)-exp(-tmax/trNMDA));
457 assert(!std::isinf(tmax) && !std::isnan(tmax) && tmax >= 0);
458 assert(!std::isinf(sNMDA) && !std::isnan(sNMDA) && sNMDA>0);
463 sim_with_GABAb_rise =
true;
464 rGABAb = 1.0-1.0/trGABAb;
468 double tmax = (-tdGABAb*trGABAb*log(1.0*trGABAb/tdGABAb))/(tdGABAb-trGABAb);
469 sGABAb = 1.0/(exp(-tmax/tdGABAb)-exp(-tmax/trGABAb));
470 assert(!std::isinf(tmax) && !std::isnan(tmax)); assert(!std::isinf(sGABAb) && !std::isnan(sGABAb) && sGABAb>0);
473 if (sim_with_conductances) {
475 KERNEL_INFO(
" - AMPA decay time = %5d ms", tdAMPA);
476 KERNEL_INFO(
" - NMDA rise time %s = %5d ms", sim_with_NMDA_rise?
" ":
"(disabled)", trNMDA);
477 KERNEL_INFO(
" - GABAa decay time = %5d ms", tdGABAa);
478 KERNEL_INFO(
" - GABAb rise time %s = %5d ms", sim_with_GABAb_rise?
" ":
"(disabled)",trGABAb);
479 KERNEL_INFO(
" - GABAb decay time = %5d ms", tdGABAb);
481 KERNEL_INFO(
"Running CUBA mode (all synaptic conductances disabled)");
484 #ifdef LN_I_CALC_TYPES 492 void SNN::setConductances(
int gGrpId,
bool isSet,
int tdAMPA,
int trNMDA,
int tdNMDA,
int tdGABAa,
int trGABAb,
int tdGABAb) {
495 assert(tdAMPA > 0); assert(tdNMDA > 0); assert(tdGABAa > 0); assert(tdGABAb > 0);
496 assert(trNMDA >= 0); assert(trGABAb >= 0);
497 assert(trNMDA != tdNMDA); assert(trGABAb != tdGABAb);
501 sim_with_conductances |= isSet;
509 auto &groupConfig = groupConfigMap[gGrpId];
510 groupConfig.icalcType = isSet ?
COBA :
CUBA;
512 auto &config = groupConfig.conductanceConfig;
513 config.dAMPA = 1.0f-1.0f/tdAMPA;;
514 config.dNMDA = 1.0f-1.0f/tdNMDA;
515 config.dGABAa = 1.0f-1.0f/tdGABAa;
516 config.dGABAb = 1.0f-1.0f/tdGABAb;
520 sim_with_NMDA_rise =
true;
521 groupConfig.with_NMDA_rise =
true;
522 config.rNMDA = 1.0f-1.0f/trNMDA;
526 float tmax = (-tdNMDA * trNMDA * log(1.0f * trNMDA / tdNMDA)) / (tdNMDA - trNMDA);
527 config.sNMDA = 1.0f / (exp(-tmax / tdNMDA) - exp(-tmax / trNMDA));
528 assert(!std::isinf(tmax) && !std::isnan(tmax) && tmax >= 0.0f);
529 assert(!std::isinf(config.sNMDA) && !std::isnan(config.sNMDA) && config.sNMDA > 0.0f);
536 sim_with_GABAb_rise =
true;
537 groupConfig.with_GABAb_rise =
true;
538 config.rGABAb = 1.0f-1.0f/trGABAb;
542 float tmax = (-tdGABAb * trGABAb * log(1.0f * trGABAb / tdGABAb)) / (tdGABAb - trGABAb);
543 config.sGABAb = 1.0f / (exp(-tmax / tdGABAb) - exp(-tmax / trGABAb));
544 assert(!std::isinf(tmax) && !std::isnan(tmax)); assert(!std::isinf(config.sGABAb) && !std::isnan(config.sGABAb) && config.sGABAb > 0.0f);
549 KERNEL_INFO(
"Running group (G:%d) COBA mode:", gGrpId);
550 KERNEL_INFO(
" - AMPA decay time = %5d ms", tdAMPA);
551 KERNEL_INFO(
" - NMDA rise time %s = %5d ms", (trNMDA > 0) ?
" " :
"(disabled)", trNMDA);
552 KERNEL_INFO(
" - GABAa decay time = %5d ms", tdGABAa);
553 KERNEL_INFO(
" - GABAb rise time %s = %5d ms", (trGABAb > 0) ?
" " :
"(disabled)", trGABAb);
554 KERNEL_INFO(
" - GABAb decay time = %5d ms", tdGABAb);
557 KERNEL_INFO(
"Running group %d in CUBA mode (synaptic conductances disabled)", gGrpId);
565 auto &groupConfig = groupConfigMap[gGrpId];
567 groupConfig.icalcType = icalc;
569 auto &w = groupConfig.nm4wConfig.w;
579 KERNEL_INFO(
" - Weights (DA, 5HT, ACh, NE) = %.1f %.1f %.1f %.1f ", wDA, w5HT, wACh, wNE);
580 KERNEL_INFO(
" - Normalization/Boost, Base = %.1f %.1f", wNorm, wBase);
592 for(
int grpId = 0; grpId < numGroups; grpId++) {
597 sim_with_homeostasis |= isSet;
598 groupConfigMap[gGrpId].homeoConfig.WithHomeostasis = isSet;
599 groupConfigMap[gGrpId].homeoConfig.homeostasisScale = homeoScale;
600 groupConfigMap[gGrpId].homeoConfig.avgTimeScale = avgTimeScale;
601 groupConfigMap[gGrpId].homeoConfig.avgTimeScaleInv = 1.0f / avgTimeScale;
602 groupConfigMap[gGrpId].homeoConfig.avgTimeScaleDecay = (avgTimeScale * 1000.0f - 1.0f) / (avgTimeScale * 1000.0f);
604 KERNEL_INFO(
"Homeostasis parameters %s for %d (%s):\thomeoScale: %f, avgTimeScale: %f",
605 isSet?
"enabled":
"disabled", gGrpId, groupConfigMap[gGrpId].grpName.c_str(), homeoScale, avgTimeScale);
612 for(
int grpId = 0; grpId < numGroups; grpId++) {
617 groupConfigMap[gGrpId].homeoConfig.baseFiring = baseFiring;
618 groupConfigMap[gGrpId].homeoConfig.baseFiringSD = baseFiringSD;
620 KERNEL_INFO(
"Homeostatic base firing rate set for %d (%s):\tbaseFiring: %3.3f, baseFiringStd: %3.3f",
621 gGrpId, groupConfigMap[gGrpId].grpName.c_str(), baseFiring, baseFiringSD);
627 assert(numStepsPerMs >= 1 && numStepsPerMs <= 100);
630 glbNetworkConfig.
timeStep = 1.0f / numStepsPerMs;
635 float izh_c,
float izh_c_sd,
float izh_d,
float izh_d_sd)
637 assert(gGrpId >= -1);
638 assert(izh_a_sd >= 0); assert(izh_b_sd >= 0); assert(izh_c_sd >= 0); assert(izh_d_sd >= 0);
641 for(
int grpId = 0; grpId < numGroups; grpId++) {
642 setNeuronParameters(grpId, izh_a, izh_a_sd, izh_b, izh_b_sd, izh_c, izh_c_sd, izh_d, izh_d_sd);
645 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_a = izh_a;
646 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_a_sd = izh_a_sd;
647 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_b = izh_b;
648 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_b_sd = izh_b_sd;
649 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_c = izh_c;
650 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_c_sd = izh_c_sd;
651 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_d = izh_d;
652 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_d_sd = izh_d_sd;
653 groupConfigMap[gGrpId].withParamModel_9 = 0;
654 groupConfigMap[gGrpId].isLIF = 0;
660 float izh_vr,
float izh_vr_sd,
float izh_vt,
float izh_vt_sd,
661 float izh_a,
float izh_a_sd,
float izh_b,
float izh_b_sd,
662 float izh_vpeak,
float izh_vpeak_sd,
float izh_c,
float izh_c_sd,
663 float izh_d,
float izh_d_sd)
665 assert(gGrpId >= -1);
666 assert(izh_C_sd >= 0); assert(izh_k_sd >= 0); assert(izh_vr_sd >= 0);
667 assert(izh_vt_sd >= 0); assert(izh_a_sd >= 0); assert(izh_b_sd >= 0); assert(izh_vpeak_sd >= 0);
668 assert(izh_c_sd >= 0); assert(izh_d_sd >= 0);
671 for (
int grpId = 0; grpId<numGroups; grpId++) {
672 setNeuronParameters(grpId, izh_C, izh_C_sd, izh_k, izh_k_sd, izh_vr, izh_vr_sd, izh_vt, izh_vt_sd,
673 izh_a, izh_a_sd, izh_b, izh_b_sd, izh_vpeak, izh_vpeak_sd, izh_c, izh_c_sd,
678 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_a = izh_a;
679 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_a_sd = izh_a_sd;
680 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_b = izh_b;
681 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_b_sd = izh_b_sd;
682 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_c = izh_c;
683 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_c_sd = izh_c_sd;
684 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_d = izh_d;
685 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_d_sd = izh_d_sd;
686 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_C = izh_C;
687 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_C_sd = izh_C_sd;
688 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_k = izh_k;
689 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_k_sd = izh_k_sd;
690 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_vr = izh_vr;
691 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_vr_sd = izh_vr_sd;
692 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_vt = izh_vt;
693 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_vt_sd = izh_vt_sd;
694 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_vpeak = izh_vpeak;
695 groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_vpeak_sd = izh_vpeak_sd;
696 groupConfigMap[gGrpId].withParamModel_9 = 1;
697 groupConfigMap[gGrpId].isLIF = 0;
706 assert(gGrpId >= -1);
707 assert(tau_m >= 0); assert(tau_ref >= 0); assert(vReset < vTh);
708 assert(minRmem >= 0.0f); assert(minRmem <= maxRmem);
711 for(
int grpId = 0; grpId < numGroups; grpId++) {
715 groupConfigMap[gGrpId].neuralDynamicsConfig.lif_tau_m = tau_m;
716 groupConfigMap[gGrpId].neuralDynamicsConfig.lif_tau_ref = tau_ref;
717 groupConfigMap[gGrpId].neuralDynamicsConfig.lif_vTh = vTh;
718 groupConfigMap[gGrpId].neuralDynamicsConfig.lif_vReset = vReset;
719 groupConfigMap[gGrpId].neuralDynamicsConfig.lif_minRmem = minRmem;
720 groupConfigMap[gGrpId].neuralDynamicsConfig.lif_maxRmem = maxRmem;
721 groupConfigMap[gGrpId].withParamModel_9 = 0;
722 groupConfigMap[gGrpId].isLIF = 1;
728 float baseDP,
float tauDP,
729 float base5HT,
float tau5HT,
730 float baseACh,
float tauACh,
731 float baseNE,
float tauNE)
734 baseDP, tauDP, 0.04f,
true,
735 base5HT, tau5HT, 0.04f,
true,
736 baseACh, tauACh, 0.04f,
true,
737 baseNE, tauNE, 0.04f,
true);
741 float baseDP,
float tauDP,
float releaseDP,
bool activeDP,
742 float base5HT,
float tau5HT,
float release5HT,
bool active5HT,
743 float baseACh,
float tauACh,
float releaseACh,
bool activeACh,
744 float baseNE,
float tauNE,
float releaseNE,
bool activeNE)
746 assert(gGrpId >= -1);
747 assert(baseDP >= 0.0f); assert(base5HT >= 0.0f); assert(baseACh >= 0.0f); assert(baseNE >= 0.0f);
748 assert(tauDP > 0); assert(tau5HT > 0); assert(tauACh > 0); assert(tauNE > 0);
751 for (
int grpId = 0; grpId < numGroups; grpId++) {
753 baseDP, tauDP, releaseDP, activeDP,
754 base5HT, tau5HT, release5HT, active5HT,
755 baseACh, tauACh, releaseACh, activeACh,
756 baseNE, tauNE, releaseNE, activeNE);
759 groupConfigMap[gGrpId].neuromodulatorConfig.baseDP = baseDP;
760 groupConfigMap[gGrpId].neuromodulatorConfig.decayDP = 1.0f - (1.0f / tauDP);
761 groupConfigMap[gGrpId].neuromodulatorConfig.releaseDP = releaseDP;
762 groupConfigMap[gGrpId].neuromodulatorConfig.activeDP = activeDP;
764 groupConfigMap[gGrpId].neuromodulatorConfig.base5HT = base5HT;
765 groupConfigMap[gGrpId].neuromodulatorConfig.decay5HT = 1.0f - (1.0f / tau5HT);
766 groupConfigMap[gGrpId].neuromodulatorConfig.release5HT = release5HT;
767 groupConfigMap[gGrpId].neuromodulatorConfig.active5HT = active5HT;
769 groupConfigMap[gGrpId].neuromodulatorConfig.baseACh = baseACh;
770 groupConfigMap[gGrpId].neuromodulatorConfig.decayACh = 1.0f - (1.0f / tauACh);
771 groupConfigMap[gGrpId].neuromodulatorConfig.releaseACh = releaseACh;
772 groupConfigMap[gGrpId].neuromodulatorConfig.activeACh = activeACh;
774 groupConfigMap[gGrpId].neuromodulatorConfig.baseNE = baseNE;
775 groupConfigMap[gGrpId].neuromodulatorConfig.decayNE = 1.0f - (1.0f / tauNE);
776 groupConfigMap[gGrpId].neuromodulatorConfig.releaseNE = releaseNE;
777 groupConfigMap[gGrpId].neuromodulatorConfig.activeNE = activeNE;
782 void SNN::setESTDP(
int preGrpId,
int postGrpId,
bool isSet,
STDPType type,
STDPCurve curve,
float alphaPlus,
float tauPlus,
float alphaMinus,
float tauMinus,
float gamma) {
783 assert(preGrpId >= -1);
784 assert(postGrpId >= -1);
789 assert(tauPlus > 0.0f); assert(tauMinus > 0.0f); assert(gamma >= 0.0f);
801 connectConfigMap[connId].stdpConfig.ALPHA_PLUS_EXC = alphaPlus;
802 connectConfigMap[connId].stdpConfig.ALPHA_MINUS_EXC = alphaMinus;
803 connectConfigMap[connId].stdpConfig.TAU_PLUS_INV_EXC = 1.0f / tauPlus;
804 connectConfigMap[connId].stdpConfig.TAU_MINUS_INV_EXC = 1.0f / tauMinus;
805 connectConfigMap[connId].stdpConfig.GAMMA = gamma;
806 connectConfigMap[connId].stdpConfig.KAPPA = (1 + exp(-gamma / tauPlus)) / (1 - exp(-gamma / tauPlus));
807 connectConfigMap[connId].stdpConfig.OMEGA = alphaPlus * (1 - connectConfigMap[connId].stdpConfig.KAPPA);
809 connectConfigMap[connId].stdpConfig.WithESTDPtype = type;
810 connectConfigMap[connId].stdpConfig.WithESTDPcurve = curve;
811 connectConfigMap[connId].stdpConfig.WithESTDP = isSet;
812 connectConfigMap[connId].stdpConfig.WithSTDP |= connectConfigMap[connId].stdpConfig.WithESTDP;
813 sim_with_stdp |= connectConfigMap[connId].stdpConfig.WithSTDP;
815 groupConfigMap[postGrpId].WithSTDP |= connectConfigMap[connId].stdpConfig.WithSTDP;
816 groupConfigMap[postGrpId].WithDA_MOD |= (type ==
DA_MOD);
817 #ifdef LN_I_CALC_TYPES 818 groupConfigMap[postGrpId].WithPKA_PLC_MOD |= (type ==
PKA_PLC_MOD);
821 KERNEL_INFO(
"E-STDP %s for %s(%d) to %s(%d)", isSet?
"enabled":
"disabled", groupConfigMap[preGrpId].grpName.c_str(), preGrpId,
822 groupConfigMap[postGrpId].grpName.c_str(), postGrpId);
825 #ifdef LN_I_CALC_TYPES 827 void SNN::setESTDP(
int preGrpId,
int postGrpId,
bool isSet,
STDPType type,
STDPCurve curve,
float alphaPlus,
float tauPlus,
float alphaMinus,
float tauMinus,
int nm_pka,
float w_pka,
int nm_plc,
float w_plc)
829 assert(preGrpId >= -1);
830 assert(postGrpId >= -1);
835 assert(tauPlus > 0.0f); assert(tauMinus > 0.0f);
836 assert(w_pka >= 0.0f); assert(w_plc >= 0.0f);
837 assert(nm_pka >= 0); assert(nm_plc >= 0);
849 connectConfigMap[connId].stdpConfig.ALPHA_PLUS_EXC = alphaPlus;
850 connectConfigMap[connId].stdpConfig.ALPHA_MINUS_EXC = alphaMinus;
851 connectConfigMap[connId].stdpConfig.TAU_PLUS_INV_EXC = 1.0f / tauPlus;
852 connectConfigMap[connId].stdpConfig.TAU_MINUS_INV_EXC = 1.0f / tauMinus;
853 connectConfigMap[connId].stdpConfig.GAMMA = 0.0f;
854 connectConfigMap[connId].stdpConfig.KAPPA = 0.0f;
855 connectConfigMap[connId].stdpConfig.OMEGA = 0.0f;
856 connectConfigMap[connId].stdpConfig.NM_PKA = nm_pka;
857 connectConfigMap[connId].stdpConfig.NM_PLC = nm_plc;
858 connectConfigMap[connId].stdpConfig.W_PKA = w_pka;
859 connectConfigMap[connId].stdpConfig.W_PLC = w_plc;
861 connectConfigMap[connId].stdpConfig.WithESTDPtype = type;
862 connectConfigMap[connId].stdpConfig.WithESTDPcurve = curve;
863 connectConfigMap[connId].stdpConfig.WithESTDP = isSet;
864 connectConfigMap[connId].stdpConfig.WithSTDP |= connectConfigMap[connId].stdpConfig.WithESTDP;
865 sim_with_stdp |= connectConfigMap[connId].stdpConfig.WithSTDP;
867 groupConfigMap[postGrpId].WithSTDP |= connectConfigMap[connId].stdpConfig.WithSTDP;
868 groupConfigMap[postGrpId].WithDA_MOD |= (type ==
DA_MOD);
869 groupConfigMap[postGrpId].WithPKA_PLC_MOD |= (type ==
PKA_PLC_MOD);
871 KERNEL_INFO(
"PKA/PLC E-STDP %s for %s(%d) to %s(%d)", isSet ?
"enabled" :
"disabled", groupConfigMap[preGrpId].grpName.c_str(), preGrpId,
872 groupConfigMap[postGrpId].grpName.c_str(), postGrpId);
879 assert(preGrpId >= -1);
880 assert(postGrpId >= -1);
884 connectConfigMap[connId].icalcType = icalcType;
891 assert(preGrpId >= -1);
892 assert(postGrpId >= -1);
897 assert(tau1 > 0); assert(tau2 > 0);
910 connectConfigMap[connId].stdpConfig.ALPHA_PLUS_INB = ab1;
911 connectConfigMap[connId].stdpConfig.ALPHA_MINUS_INB = ab2;
912 connectConfigMap[connId].stdpConfig.TAU_PLUS_INV_INB = 1.0f / tau1;
913 connectConfigMap[connId].stdpConfig.TAU_MINUS_INV_INB = 1.0f / tau2;
914 connectConfigMap[connId].stdpConfig.BETA_LTP = 0.0f;
915 connectConfigMap[connId].stdpConfig.BETA_LTD = 0.0f;
916 connectConfigMap[connId].stdpConfig.LAMBDA = 1.0f;
917 connectConfigMap[connId].stdpConfig.DELTA = 1.0f;
919 connectConfigMap[connId].stdpConfig.ALPHA_PLUS_INB = 0.0f;
920 connectConfigMap[connId].stdpConfig.ALPHA_MINUS_INB = 0.0f;
921 connectConfigMap[connId].stdpConfig.TAU_PLUS_INV_INB = 1.0f;
922 connectConfigMap[connId].stdpConfig.TAU_MINUS_INV_INB = 1.0f;
923 connectConfigMap[connId].stdpConfig.BETA_LTP = ab1;
924 connectConfigMap[connId].stdpConfig.BETA_LTD = ab2;
925 connectConfigMap[connId].stdpConfig.LAMBDA = tau1;
926 connectConfigMap[connId].stdpConfig.DELTA = tau2;
930 connectConfigMap[connId].stdpConfig.WithISTDPtype = type;
931 connectConfigMap[connId].stdpConfig.WithISTDPcurve = curve;
932 connectConfigMap[connId].stdpConfig.WithISTDP = isSet;
933 connectConfigMap[connId].stdpConfig.WithSTDP |= connectConfigMap[connId].stdpConfig.WithISTDP;
934 sim_with_stdp |= connectConfigMap[connId].stdpConfig.WithSTDP;
936 groupConfigMap[postGrpId].WithSTDP |= connectConfigMap[connId].stdpConfig.WithSTDP;
937 groupConfigMap[postGrpId].WithDA_MOD |= (type ==
DA_MOD);
938 #ifdef LN_I_CALC_TYPES 939 groupConfigMap[postGrpId].WithPKA_PLC_MOD |= (type ==
PKA_PLC_MOD);
941 KERNEL_INFO(
"I-STDP %s for %s(%d) to %s(%d)", isSet?
"enabled":
"disabled", groupConfigMap[preGrpId].grpName.c_str(), preGrpId,
942 groupConfigMap[postGrpId].grpName.c_str(), postGrpId);
946 void SNN::setSTP(
int gGrpId,
bool isSet,
float STP_U,
float STP_tau_u,
float STP_tau_x) {
947 assert(gGrpId >= -1);
949 assert(STP_U > 0 && STP_U <= 1); assert(STP_tau_u > 0); assert(STP_tau_x > 0);
953 for(
int grpId = 0; grpId < numGroups; grpId++) {
954 setSTP(grpId, isSet, STP_U, STP_tau_u, STP_tau_x);
958 sim_with_stp |= isSet;
959 groupConfigMap[gGrpId].stpConfig.WithSTP = isSet;
960 groupConfigMap[gGrpId].stpConfig.STP_A = (STP_U > 0.0f) ? 1.0 / STP_U : 1.0f;
961 groupConfigMap[gGrpId].stpConfig.STP_U = STP_U;
962 groupConfigMap[gGrpId].stpConfig.STP_tau_u_inv = 1.0f / STP_tau_u;
963 groupConfigMap[gGrpId].stpConfig.STP_tau_x_inv = 1.0f / STP_tau_x;
965 KERNEL_INFO(
"STP %s for %d (%s):\tA: %1.4f, U: %1.4f, tau_u: %4.0f, tau_x: %4.0f", isSet?
"enabled":
"disabled",
966 gGrpId, groupConfigMap[gGrpId].grpName.c_str(), groupConfigMap[gGrpId].stpConfig.STP_A, STP_U, STP_tau_u, STP_tau_x);
971 #ifdef LN_I_CALC_TYPES 972 void SNN::setNM4STP(
int gGrpId,
float wSTP_U[],
float wSTP_tau_u[],
float wSTP_tau_x[]) {
973 assert(gGrpId >= -1);
974 if (!groupConfigMap[gGrpId].stpConfig.WithSTP) {
978 auto& config = groupConfigMap[gGrpId].nm4StpConfig;
980 config.WithNM4STP =
true;
982 for (
int i = 0; i <
NM_NE + 3; i++) {
983 config.w_STP_U[i] = wSTP_U[i];
984 config.w_STP_tau_u[i] = wSTP_tau_u[i];
985 config.w_STP_tau_x[i] = wSTP_tau_x[i];
993 assert(wtChangeDecay > 0.0f && wtChangeDecay < 1.0f);
995 switch (wtANDwtChangeUpdateInterval) {
997 wtANDwtChangeUpdateInterval_ = 10;
1000 wtANDwtChangeUpdateInterval_ = 100;
1004 wtANDwtChangeUpdateInterval_ = 1000;
1008 if (enableWtChangeDecay) {
1010 switch (wtANDwtChangeUpdateInterval) {
1012 stdpScaleFactor_ = 0.005f;
1015 stdpScaleFactor_ = 0.05f;
1019 stdpScaleFactor_ = 0.5f;
1023 wtChangeDecay_ = wtChangeDecay;
1025 stdpScaleFactor_ = 1.0f;
1026 wtChangeDecay_ = 0.0f;
1029 KERNEL_INFO(
"Update weight and weight change every %d ms", wtANDwtChangeUpdateInterval_);
1030 KERNEL_INFO(
"Weight Change Decay is %s", enableWtChangeDecay?
"enabled" :
"disable");
1031 KERNEL_INFO(
"STDP scale factor = %1.3f, wtChangeDecay = %1.3f", stdpScaleFactor_, wtChangeDecay_);
1050 generateRuntimeSNN();
1060 #ifdef LN_SETUP_NETWORK_MT 1066 void SNN::setupNetworkMT() {
1067 auto t0 = std::chrono::steady_clock::now();
1068 auto t1 = std::chrono::steady_clock::now();
1069 std::chrono::duration<double> d = t1 - t0;
1072 t0 = std::chrono::steady_clock::now();
1074 t1 = std::chrono::steady_clock::now();
1076 printf(
"compileSNN: %.1fs\n", d);
1078 t0 = std::chrono::steady_clock::now();
1080 t1 = std::chrono::steady_clock::now();
1082 printf(
"partitionSNNMT: %.1fs\n", d);
1084 t0 = std::chrono::steady_clock::now();
1085 generateRuntimeSNN();
1086 t1 = std::chrono::steady_clock::now();
1088 printf(
"generateRuntimeSNN: %.1fs\n", d);
1104 assert(_nmsec >= 0 && _nmsec < 1000);
1106 int runDurationMs = _nsec*1000 + _nmsec;
1107 KERNEL_DEBUG(
"runNetwork: runDur=%dms, printRunSummary=%s", runDurationMs, printRunSummary?
"y":
"n");
1113 printRunSummary = (loggerMode_==
SILENT) ?
false : printRunSummary;
1116 if (simTime==0 && printRunSummary) {
1118 KERNEL_INFO(
"******************** Running the simulation on %d GPU(s) and %d CPU(s) ***************************", numGPUs, numCores);
1126 simTimeRunStart = simTime;
1127 simTimeRunStop = simTime + runDurationMs;
1128 assert(simTimeRunStop >= simTimeRunStart);
1134 if (simTime == 0 && numConnectionMonitor) {
1139 #if defined(WIN32) && defined(__NO_CUDA__) // LN2021 fix gcc 1140 setGrpTimeSlice(
ALL, std::max<int>(1, std::min<int>(runDurationMs,
MAX_TIME_SLICE)));
1145 CUDA_RESET_TIMER(timer);
1146 CUDA_START_TIMER(timer);
1153 for(
int i = 0; i < runDurationMs; i++) {
1158 if (!sim_with_fixedwts && wtANDwtChangeUpdateInterval_ == ++wtANDwtChangeUpdateIntervalCnt_) {
1159 wtANDwtChangeUpdateIntervalCnt_ = 0;
1160 if (!sim_in_testing) {
1169 if (numSpikeMonitor) {
1172 if (numGroupMonitor) {
1175 if (numConnectionMonitor) {
1178 if (numNeuronMonitor) {
1185 fetchNeuronSpikeCount(
ALL);
1191 if (printRunSummary) {
1194 if (numSpikeMonitor) {
1195 printStatusSpikeMonitor(
ALL);
1197 if (numConnectionMonitor) {
1198 printStatusConnectionMonitor(
ALL);
1200 if (numGroupMonitor) {
1201 printStatusGroupMonitor(
ALL);
1205 simTimeLastRunSummary = simTime;
1214 CUDA_STOP_TIMER(timer);
1215 lastExecutionTime = CUDA_GET_TIMER_VALUE(timer);
1216 cumExecutionTime += lastExecutionTime;
1229 assert(connId>=0 && connId<numConnections);
1231 int netId = groupConfigMDMap[connectConfigMap[connId].grpDest].netId;
1232 int lGrpId = groupConfigMDMap[connectConfigMap[connId].grpDest].lGrpId;
1234 fetchPreConnectionInfo(netId);
1235 fetchConnIdsLookupArray(netId);
1236 fetchSynapseState(netId);
1238 for (
int lNId = groupConfigs[netId][lGrpId].lStartN; lNId <= groupConfigs[netId][lGrpId].
lEndN; lNId++) {
1239 unsigned int cumIdx = managerRuntimeData.
cumulativePre[lNId];
1242 unsigned int pos_ij = cumIdx;
1243 for (
int j = 0; j < managerRuntimeData.
Npre[lNId]; pos_ij++, j++) {
1246 float weight = managerRuntimeData.
wt[pos_ij] + bias;
1250 bool needToPrintDebug = (weight > connectConfigMap[connId].maxWt || weight < 0.0f);
1252 if (updateWeightRange) {
1256 #if defined(WIN32) && defined(__NO_CUDA__) // LN2021 fix gcc 1257 connectConfigMap[connId].maxWt = std::max<float>(connectConfigMap[connId].maxWt, weight);
1259 connectConfigMap[connId].maxWt = std::max(connectConfigMap[connId].maxWt, weight);
1261 if (needToPrintDebug) {
1262 KERNEL_DEBUG(
"biasWeights(%d,%f,%s): updated weight ranges to [%f,%f]", connId, bias,
1263 (updateWeightRange?
"true":
"false"), 0.0f, connectConfigMap[connId].maxWt);
1268 #if defined(WIN32) && defined(__NO_CUDA__) // LN2021 fix gcc 1269 weight = std::min<float>(weight, connectConfigMap[connId].maxWt);
1271 weight = std::min(weight, connectConfigMap[connId].maxWt);
1274 #if defined(WIN32) && defined(__NO_CUDA__) // LN2021 fix gcc 1275 weight = std::max<float>(weight, 0.0f);
1277 weight = std::max(weight, 0.0f);
1279 if (needToPrintDebug) {
1280 KERNEL_DEBUG(
"biasWeights(%d,%f,%s): constrained weight %f to [%f,%f]", connId, bias,
1281 (updateWeightRange?
"true":
"false"), weight, 0.0f, connectConfigMap[connId].maxWt);
1286 managerRuntimeData.
wt[pos_ij] = weight;
1287 managerRuntimeData.
maxSynWt[pos_ij] = connectConfigMap[connId].maxWt;
1294 CUDA_CHECK_ERRORS( cudaMemcpy(&(runtimeData[netId].wt[cumIdx]), &(managerRuntimeData.
wt[cumIdx]),
sizeof(
float)*managerRuntimeData.
Npre[lNId],
1295 cudaMemcpyHostToDevice) );
1297 if (runtimeData[netId].maxSynWt != NULL) {
1300 CUDA_CHECK_ERRORS( cudaMemcpy(&(runtimeData[netId].maxSynWt[cumIdx]), &(managerRuntimeData.
maxSynWt[cumIdx]),
1301 sizeof(
float) * managerRuntimeData.
Npre[lNId], cudaMemcpyHostToDevice) );
1307 memcpy(&runtimeData[netId].wt[cumIdx], &managerRuntimeData.
wt[cumIdx],
sizeof(
float) * managerRuntimeData.
Npre[lNId]);
1309 if (runtimeData[netId].maxSynWt != NULL) {
1312 memcpy(&runtimeData[netId].maxSynWt[cumIdx], &managerRuntimeData.
maxSynWt[cumIdx],
sizeof(
float) * managerRuntimeData.
Npre[lNId]);
1331 assert(connId>=0 && connId<numConnections);
1332 assert(scale>=0.0f);
1334 int netId = groupConfigMDMap[connectConfigMap[connId].grpDest].netId;
1335 int lGrpId = groupConfigMDMap[connectConfigMap[connId].grpDest].lGrpId;
1337 fetchPreConnectionInfo(netId);
1338 fetchConnIdsLookupArray(netId);
1339 fetchSynapseState(netId);
1342 for (
int lNId = groupConfigs[netId][lGrpId].lStartN; lNId <= groupConfigs[netId][lGrpId].
lEndN; lNId++) {
1343 unsigned int cumIdx = managerRuntimeData.
cumulativePre[lNId];
1346 unsigned int pos_ij = cumIdx;
1347 for (
int j = 0; j < managerRuntimeData.
Npre[lNId]; pos_ij++, j++) {
1350 float weight = managerRuntimeData.
wt[pos_ij] * scale;
1354 bool needToPrintDebug = (weight > connectConfigMap[connId].maxWt || weight < 0.0f);
1356 if (updateWeightRange) {
1360 #if defined(WIN32) && defined(__NO_CUDA__) // LN2021 fix gcc 1361 connectConfigMap[connId].maxWt = std::max<float>(connectConfigMap[connId].maxWt, weight);
1363 connectConfigMap[connId].maxWt = std::max(connectConfigMap[connId].maxWt, weight);
1365 if (needToPrintDebug) {
1366 KERNEL_DEBUG(
"scaleWeights(%d,%f,%s): updated weight ranges to [%f,%f]", connId, scale,
1367 (updateWeightRange?
"true":
"false"), 0.0f, connectConfigMap[connId].maxWt);
1372 #if defined(WIN32) && defined(__NO_CUDA__) // LN2021 fix gcc 1373 weight = std::min<float>(weight, connectConfigMap[connId].maxWt);
1375 weight = std::min(weight, connectConfigMap[connId].maxWt);
1378 #if defined(WIN32) && defined(__NO_CUDA__) // LN2021 fix gcc 1379 weight = std::max<float>(weight, 0.0f);
1381 weight = std::max(weight, 0.0f);
1383 if (needToPrintDebug) {
1384 KERNEL_DEBUG(
"scaleWeights(%d,%f,%s): constrained weight %f to [%f,%f]", connId, scale,
1385 (updateWeightRange?
"true":
"false"), weight, 0.0f, connectConfigMap[connId].maxWt);
1390 managerRuntimeData.
wt[pos_ij] = weight;
1391 managerRuntimeData.
maxSynWt[pos_ij] = connectConfigMap[connId].maxWt;
1398 CUDA_CHECK_ERRORS(cudaMemcpy(&runtimeData[netId].wt[cumIdx], &managerRuntimeData.
wt[cumIdx],
sizeof(
float)*managerRuntimeData.
Npre[lNId],
1399 cudaMemcpyHostToDevice));
1401 if (runtimeData[netId].maxSynWt != NULL) {
1404 CUDA_CHECK_ERRORS(cudaMemcpy(&runtimeData[netId].maxSynWt[cumIdx], &managerRuntimeData.
maxSynWt[cumIdx],
1405 sizeof(
float) * managerRuntimeData.
Npre[lNId], cudaMemcpyHostToDevice));
1411 memcpy(&runtimeData[netId].wt[cumIdx], &managerRuntimeData.
wt[cumIdx],
sizeof(
float) * managerRuntimeData.
Npre[lNId]);
1413 if (runtimeData[netId].maxSynWt != NULL) {
1416 memcpy(&runtimeData[netId].maxSynWt[cumIdx], &managerRuntimeData.
maxSynWt[cumIdx],
sizeof(
float) * managerRuntimeData.
Npre[lNId]);
1425 int netId = groupConfigMDMap[gGrpId].netId;
1426 int lGrpId = groupConfigMDMap[gGrpId].lGrpId;
1429 if (groupConfigMDMap[gGrpId].groupMonitorId >= 0) {
1430 KERNEL_ERROR(
"setGroupMonitor has already been called on Group %d (%s).", gGrpId, groupConfigMap[gGrpId].grpName.c_str());
1437 groupMonCoreList[numGroupMonitor] = grpMonCoreObj;
1448 groupMonList[numGroupMonitor] = grpMonObj;
1451 groupConfigMDMap[gGrpId].groupMonitorId = numGroupMonitor;
1454 KERNEL_INFO(
"GroupMonitor set for group %d (%s)", gGrpId, groupConfigMap[gGrpId].grpName.c_str());
1471 if (connectConfigMap[connId].connectionMonitorId >= 0) {
1472 KERNEL_ERROR(
"setConnectionMonitor has already been called on Connection %d (MonitorId=%d)", connId, connectConfigMap[connId].connectionMonitorId);
1478 connectConfigMap[connId].connectionMonitorId = numConnectionMonitor;
1483 grpIdPre, grpIdPost);
1484 connMonCoreList[numConnectionMonitor] = connMonCoreObj;
1495 connMonList[numConnectionMonitor] = connMonObj;
1498 connMonCoreObj->
init();
1500 numConnectionMonitor++;
1501 KERNEL_INFO(
"ConnectionMonitor %d set for Connection %d: %d(%s) => %d(%s)", connectConfigMap[connId].connectionMonitorId, connId, grpIdPre,
getGroupName(grpIdPre).c_str(),
1512 assert(spikeGenFunc);
1513 assert(groupConfigMap[gGrpId].isSpikeGenerator);
1514 groupConfigMap[gGrpId].spikeGenFunc = spikeGenFunc;
1520 if (groupConfigMDMap[gGrpId].spikeMonitorId >= 0) {
1528 KERNEL_INFO(
"SpikeMonitor updated for group %d (%s)", gGrpId, groupConfigMap[gGrpId].grpName.c_str());
1534 spikeMonCoreList[numSpikeMonitor] = spkMonCoreObj;
1545 spikeMonList[numSpikeMonitor] = spkMonObj;
1548 groupConfigMDMap[gGrpId].spikeMonitorId = numSpikeMonitor;
1551 KERNEL_INFO(
"SpikeMonitor set for group %d (%s)", gGrpId, groupConfigMap[gGrpId].grpName.c_str());
1559 int lGrpId = groupConfigMDMap[gGrpId].lGrpId;
1560 int netId = groupConfigMDMap[gGrpId].netId;
1563 KERNEL_WARN(
"Due to limited memory space, only the first 128 neurons can be monitored by NeuronMonitor");
1567 if (groupConfigMDMap[gGrpId].neuronMonitorId >= 0) {
1575 KERNEL_INFO(
"NeuronMonitor updated for group %d (%s)", gGrpId, groupConfigMap[gGrpId].grpName.c_str());
1581 neuronMonCoreList[numNeuronMonitor] = nrnMonCoreObj;
1592 neuronMonList[numNeuronMonitor] = nrnMonObj;
1595 groupConfigMDMap[gGrpId].neuronMonitorId = numNeuronMonitor;
1598 KERNEL_INFO(
"NeuronMonitor set for group %d (%s)", gGrpId, groupConfigMap[gGrpId].grpName.c_str());
1608 int netId = groupConfigMDMap[gGrpId].netId;
1609 int lGrpId = groupConfigMDMap[gGrpId].lGrpId;
1611 assert(gGrpId >= 0 && lGrpId < networkConfigs[netId].numGroups);
1613 assert(groupConfigMap[gGrpId].isSpikeGenerator);
1614 assert(ratePtr->
getNumNeurons() == groupConfigMap[gGrpId].numN);
1615 assert(refPeriod >= 1);
1617 groupConfigMDMap[gGrpId].ratePtr = ratePtr;
1618 groupConfigMDMap[gGrpId].refractPeriod = refPeriod;
1619 spikeRateUpdated =
true;
1623 void SNN::setWeight(
short int connId,
int neurIdPre,
int neurIdPost,
float weight,
bool updateWeightRange) {
1625 assert(weight>=0.0f);
1627 assert(neurIdPre >= 0 && neurIdPre <
getGroupNumNeurons(connectConfigMap[connId].grpSrc));
1628 assert(neurIdPost >= 0 && neurIdPost <
getGroupNumNeurons(connectConfigMap[connId].grpDest));
1630 float maxWt = fabs(connectConfigMap[connId].maxWt);
1634 bool needToPrintDebug = (weight>maxWt || weight<minWt);
1636 int netId = groupConfigMDMap[connectConfigMap[connId].grpDest].netId;
1637 int postlGrpId = groupConfigMDMap[connectConfigMap[connId].grpDest].lGrpId;
1638 int prelGrpId = groupConfigMDMap[connectConfigMap[connId].grpSrc].lGrpId;
1640 fetchPreConnectionInfo(netId);
1641 fetchConnIdsLookupArray(netId);
1642 fetchSynapseState(netId);
1644 if (updateWeightRange) {
1648 maxWt = fmax(maxWt, weight);
1649 if (needToPrintDebug) {
1650 KERNEL_DEBUG(
"setWeight(%d,%d,%d,%f,%s): updated weight ranges to [%f,%f]", connId, neurIdPre, neurIdPost,
1651 weight, (updateWeightRange?
"true":
"false"), minWt, maxWt);
1656 weight = fmin(weight, maxWt);
1657 weight = fmax(weight, minWt);
1658 if (needToPrintDebug) {
1659 KERNEL_DEBUG(
"setWeight(%d,%d,%d,%f,%s): constrained weight %f to [%f,%f]", connId, neurIdPre, neurIdPost,
1660 weight, (updateWeightRange?
"true":
"false"), weight, minWt, maxWt);
1665 int neurIdPreReal = groupConfigs[netId][prelGrpId].
lStartN + neurIdPre;
1666 int neurIdPostReal = groupConfigs[netId][postlGrpId].
lStartN + neurIdPost;
1669 bool synapseFound =
false;
1670 int pos_ij = managerRuntimeData.
cumulativePre[neurIdPostReal];
1671 for (
int j = 0; j < managerRuntimeData.
Npre[neurIdPostReal]; pos_ij++, j++) {
1677 managerRuntimeData.
wt[pos_ij] =
isExcitatoryGroup(connectConfigMap[connId].grpSrc) ? weight : -1.0 * weight;
1683 CUDA_CHECK_ERRORS(cudaMemcpy(&runtimeData[netId].wt[pos_ij], &managerRuntimeData.
wt[pos_ij],
sizeof(
float), cudaMemcpyHostToDevice));
1684 if (runtimeData[netId].maxSynWt != NULL) {
1687 CUDA_CHECK_ERRORS(cudaMemcpy(&runtimeData[netId].maxSynWt[pos_ij], &managerRuntimeData.
maxSynWt[pos_ij],
sizeof(
float), cudaMemcpyHostToDevice));
1694 memcpy(&runtimeData[netId].wt[pos_ij], &managerRuntimeData.
wt[pos_ij],
sizeof(
float));
1695 if (runtimeData[netId].maxSynWt != NULL) {
1698 memcpy(&runtimeData[netId].maxSynWt[pos_ij], &managerRuntimeData.
maxSynWt[pos_ij],
sizeof(
float));
1703 synapseFound =
true;
1708 if (!synapseFound) {
1709 KERNEL_WARN(
"setWeight(%d,%d,%d,%f,%s): Synapse does not exist, not updated.", connId, neurIdPre, neurIdPost,
1710 weight, (updateWeightRange?
"true":
"false"));
1715 assert(grpId >= 0); assert(grpId < numGroups);
1719 int netId = groupConfigMDMap[grpId].netId;
1720 int lGrpId = groupConfigMDMap[grpId].lGrpId;
1730 for (
int lNId = groupConfigs[netId][lGrpId].lStartN, j = 0; lNId <= groupConfigs[netId][lGrpId].
lEndN; lNId++, j++) {
1731 managerRuntimeData.
extCurrent[lNId] = current[j];
1737 copyExternalCurrent(netId, lGrpId, &runtimeData[netId], cudaMemcpyHostToDevice,
false);
1740 copyExternalCurrent(netId, lGrpId, &runtimeData[netId],
false);
1755 if (!fwrite(&tmpInt,
sizeof(
int),1,fid))
KERNEL_ERROR(
"saveSimulation fwrite error");
1759 if (!fwrite(&tmpFloat,
sizeof(
int),1,fid))
KERNEL_ERROR(
"saveSimulation fwrite error");
1762 tmpFloat = ((float)simTimeSec) + ((float)simTimeMs)/1000.0f;
1763 if (!fwrite(&tmpFloat,
sizeof(
float),1,fid))
KERNEL_ERROR(
"saveSimulation fwrite error");
1767 tmpFloat = executionTime/1000.0f;
1768 if (!fwrite(&tmpFloat,
sizeof(
float),1,fid))
KERNEL_ERROR(
"saveSimulation fwrite error");
1773 if (!fwrite(&glbNetworkConfig.
numN,
sizeof(
int),1,fid))
KERNEL_ERROR(
"saveSimulation fwrite error");
1779 if (!fwrite(&numGroups,
sizeof(
int),1,fid))
KERNEL_ERROR(
"saveSimulation fwrite error");
1783 for (
int gGrpId=0;gGrpId<numGroups;gGrpId++) {
1784 if (!fwrite(&groupConfigMDMap[gGrpId].gStartN,
sizeof(
int),1,fid))
KERNEL_ERROR(
"saveSimulation fwrite error");
1785 if (!fwrite(&groupConfigMDMap[gGrpId].gEndN,
sizeof(
int),1,fid))
KERNEL_ERROR(
"saveSimulation fwrite error");
1787 if (!fwrite(&groupConfigMap[gGrpId].grid.numX,
sizeof(
int),1,fid))
KERNEL_ERROR(
"saveSimulation fwrite error");
1788 if (!fwrite(&groupConfigMap[gGrpId].grid.numY,
sizeof(
int),1,fid))
KERNEL_ERROR(
"saveSimulation fwrite error");
1789 if (!fwrite(&groupConfigMap[gGrpId].grid.numZ,
sizeof(
int),1,fid))
KERNEL_ERROR(
"saveSimulation fwrite error");
1791 strncpy(name,groupConfigMap[gGrpId].grpName.c_str(),100);
1792 if (!fwrite(name,1,100,fid))
KERNEL_ERROR(
"saveSimulation fwrite error");
1795 if (!saveSynapseInfo)
return;
1800 if (!groupPartitionLists[netId].empty()) {
1804 if (!fwrite(&net_count,
sizeof(
int), 1, fid))
KERNEL_ERROR(
"saveSimulation fwrite error");
1808 if (!groupPartitionLists[netId].empty()) {
1810 fetchPreConnectionInfo(netId);
1811 fetchPostConnectionInfo(netId);
1812 fetchConnIdsLookupArray(netId);
1813 fetchSynapseState(netId);
1816 int numSynToSave = 0;
1817 for (std::list<GroupConfigMD>::iterator grpIt = groupPartitionLists[netId].begin(); grpIt != groupPartitionLists[netId].end(); grpIt++) {
1818 if (grpIt->netId == netId) {
1819 numSynToSave += grpIt->numPostSynapses;
1822 if (!fwrite(&numSynToSave,
sizeof(
int), 1, fid))
KERNEL_ERROR(
"saveSimulation fwrite error");
1824 int numSynSaved = 0;
1825 for (
int lNId = 0; lNId < networkConfigs[netId].
numNAssigned; lNId++) {
1829 for (
int t = 0; t < glbNetworkConfig.
maxDelay; t++) {
1837 int pre_pos = managerRuntimeData.
cumulativePre[lNIdPost] + preSynId;
1841 float weight = managerRuntimeData.
wt[pre_pos];
1842 float maxWeight = managerRuntimeData.
maxSynWt[pre_pos];
1848 int gGrpIdPre = groupConfigs[netId][lGrpIdPre].
gGrpId;
1849 int gGrpIdPost = groupConfigs[netId][lGrpIdPost].
gGrpId;
1850 int grpNIdPre = lNId - groupConfigs[netId][lGrpIdPre].
lStartN;
1851 int grpNIdPost = lNIdPost - groupConfigs[netId][lGrpIdPost].
lStartN;
1856 if (groupConfigMDMap[gGrpIdPre].netId == netId) {
1858 if (!fwrite(&gGrpIdPre,
sizeof(
int), 1, fid))
KERNEL_ERROR(
"saveSimulation fwrite error");
1859 if (!fwrite(&gGrpIdPost,
sizeof(
int), 1, fid))
KERNEL_ERROR(
"saveSimulation fwrite error");
1860 if (!fwrite(&grpNIdPre,
sizeof(
int), 1, fid))
KERNEL_ERROR(
"saveSimulation fwrite error");
1861 if (!fwrite(&grpNIdPost,
sizeof(
int), 1, fid))
KERNEL_ERROR(
"saveSimulation fwrite error");
1862 if (!fwrite(&connId,
sizeof(
int), 1, fid))
KERNEL_ERROR(
"saveSimulation fwrite error");
1863 if (!fwrite(&weight,
sizeof(
float), 1, fid))
KERNEL_ERROR(
"saveSimulation fwrite error");
1864 if (!fwrite(&maxWeight,
sizeof(
float), 1, fid))
KERNEL_ERROR(
"saveSimulation fwrite error");
1865 if (!fwrite(&delay,
sizeof(
int), 1, fid))
KERNEL_ERROR(
"saveSimulation fwrite error");
1870 assert(numSynSaved == numSynToSave);
2010 if (fpInf_!=NULL && fpInf_!=stdout && fpInf_!=stderr)
2016 if (fpErr_ != NULL && fpErr_!=stdout && fpErr_!=stderr)
2022 if (fpDeb_!=NULL && fpDeb_!=stdout && fpDeb_!=stderr)
2028 if (fpLog_!=NULL && fpLog_!=stdout && fpLog_!=stderr)
2041 short int connId = -1;
2043 for (std::map<int, ConnectConfig>::iterator it = connectConfigMap.begin(); it != connectConfigMap.end(); it++) {
2044 if (it->second.grpSrc == grpIdPre && it->second.grpDest == grpIdPost) {
2045 connId = it->second.connId;
2056 if (connectConfigMap.find(connId) == connectConfigMap.end()) {
2057 KERNEL_ERROR(
"Total Connections = %d", numConnections);
2058 KERNEL_ERROR(
"ConnectId (%d) cannot be recognized", connId);
2061 return connectConfigMap[connId];
2068 fetchConductanceAMPA(gGrpId);
2070 std::vector<float> gAMPAvec;
2071 for (
int gNId = groupConfigMDMap[gGrpId].gStartN; gNId <= groupConfigMDMap[gGrpId].gEndN; gNId++) {
2072 gAMPAvec.push_back(managerRuntimeData.
gAMPA[gNId]);
2078 #ifdef LN_I_CALC_TYPES 2079 assert(groupConfigMap[gGrpId].icalcType ==
COBA);
2085 fetchConductanceNMDA(gGrpId);
2087 std::vector<float> gNMDAvec;
2088 #ifdef LN_I_CALC_TYPES 2089 if(groupConfigMap[gGrpId].with_NMDA_rise) {
2094 for (
int gNId = groupConfigMDMap[gGrpId].gStartN; gNId <= groupConfigMDMap[gGrpId].gEndN; gNId++) {
2095 gNMDAvec.push_back(managerRuntimeData.
gNMDA_d[gNId] - managerRuntimeData.
gNMDA_r[gNId]);
2098 for (
int gNId = groupConfigMDMap[gGrpId].gStartN; gNId <= groupConfigMDMap[gGrpId].gEndN; gNId++) {
2099 gNMDAvec.push_back(managerRuntimeData.
gNMDA[gNId]);
2109 fetchConductanceGABAa(gGrpId);
2111 std::vector<float> gGABAaVec;
2112 for (
int gNId = groupConfigMDMap[gGrpId].gStartN; gNId <= groupConfigMDMap[gGrpId].gEndN; gNId++) {
2113 gGABAaVec.push_back(managerRuntimeData.
gGABAa[gNId]);
2119 #ifdef LN_I_CALC_TYPES 2120 assert(groupConfigMap[gGrpId].icalcType ==
COBA);
2126 fetchConductanceGABAb(gGrpId);
2128 std::vector<float> gGABAbVec;
2129 #ifdef LN_I_CALC_TYPES 2130 if (groupConfigMap[gGrpId].with_GABAb_rise) {
2135 for (
int gNId = groupConfigMDMap[gGrpId].gStartN; gNId <= groupConfigMDMap[gGrpId].gEndN; gNId++) {
2136 gGABAbVec.push_back(managerRuntimeData.
gGABAb_d[gNId] - managerRuntimeData.
gGABAb_r[gNId]);
2139 for (
int gNId = groupConfigMDMap[gGrpId].gStartN; gNId <= groupConfigMDMap[gGrpId].gEndN; gNId++) {
2140 gGABAbVec.push_back(managerRuntimeData.
gGABAb[gNId]);
2148 assert(connId>=0 && connId<numConnections);
2150 return RangeDelay(connectConfigMap[connId].minDelay, connectConfigMap[connId].maxDelay);
2154 uint8_t*
SNN::getDelays(
int gGrpIdPre,
int gGrpIdPost,
int& numPreN,
int& numPostN) {
2155 int netIdPost = groupConfigMDMap[gGrpIdPost].netId;
2156 int lGrpIdPost = groupConfigMDMap[gGrpIdPost].lGrpId;
2160 for (
int lGrpId = 0; lGrpId < networkConfigs[netIdPost].
numGroupsAssigned; lGrpId++)
2161 if (groupConfigs[netIdPost][lGrpId].gGrpId == gGrpIdPre) {
2165 assert(lGrpIdPre != -1);
2167 numPreN = groupConfigMap[gGrpIdPre].numN;
2168 numPostN = groupConfigMap[gGrpIdPost].numN;
2170 delays =
new uint8_t[numPreN * numPostN];
2171 memset(delays, 0, numPreN * numPostN);
2173 fetchPostConnectionInfo(netIdPost);
2175 for (
int lNIdPre = groupConfigs[netIdPost][lGrpIdPre].lStartN; lNIdPre <= groupConfigs[netIdPost][lGrpIdPre].
lEndN; lNIdPre++) {
2176 unsigned int offset = managerRuntimeData.
cumulativePost[lNIdPre];
2178 for (
int t = 0; t < glbNetworkConfig.
maxDelay; t++) {
2187 assert(lNIdPost < glbNetworkConfig.
numN);
2189 if (lNIdPost >= groupConfigs[netIdPost][lGrpIdPost].lStartN && lNIdPost <= groupConfigs[netIdPost][lGrpIdPost].lEndN) {
2190 delays[(lNIdPre - groupConfigs[netIdPost][lGrpIdPre].
lStartN) + numPreN * (lNIdPost - groupConfigs[netIdPost][lGrpIdPost].lStartN)] = t + 1;
2199 assert(gGrpId >= 0 && gGrpId < numGroups);
2201 return groupConfigMap[gGrpId].grid;
2207 for (
int gGrpId = 0; gGrpId < numGroups; gGrpId++) {
2208 if (groupConfigMap[gGrpId].grpName.compare(grpName) == 0) {
2218 assert(gGrpId >= -1 && gGrpId < numGroups);
2223 return groupConfigMap[gGrpId].grpName;
2229 cInfo.
WithSTDP = connectConfigMap[connId].stdpConfig.WithSTDP;
2230 cInfo.
WithESTDP = connectConfigMap[connId].stdpConfig.WithESTDP;
2231 cInfo.
WithISTDP = connectConfigMap[connId].stdpConfig.WithISTDP;
2232 cInfo.
WithESTDPtype = connectConfigMap[connId].stdpConfig.WithESTDPtype;
2233 cInfo.
WithISTDPtype = connectConfigMap[connId].stdpConfig.WithISTDPtype;
2234 cInfo.
WithESTDPcurve = connectConfigMap[connId].stdpConfig.WithESTDPcurve;
2235 cInfo.
WithISTDPcurve = connectConfigMap[connId].stdpConfig.WithISTDPcurve;
2236 cInfo.
ALPHA_MINUS_EXC = connectConfigMap[connId].stdpConfig.ALPHA_MINUS_EXC;
2237 cInfo.
ALPHA_PLUS_EXC = connectConfigMap[connId].stdpConfig.ALPHA_PLUS_EXC;
2238 cInfo.
TAU_MINUS_INV_EXC = connectConfigMap[connId].stdpConfig.TAU_MINUS_INV_EXC;
2239 cInfo.
TAU_PLUS_INV_EXC = connectConfigMap[connId].stdpConfig.TAU_PLUS_INV_EXC;
2240 cInfo.
ALPHA_MINUS_INB = connectConfigMap[connId].stdpConfig.ALPHA_MINUS_INB;
2241 cInfo.
ALPHA_PLUS_INB = connectConfigMap[connId].stdpConfig.ALPHA_PLUS_INB;
2242 cInfo.
TAU_MINUS_INV_INB = connectConfigMap[connId].stdpConfig.TAU_MINUS_INV_INB;
2243 cInfo.
TAU_PLUS_INV_INB = connectConfigMap[connId].stdpConfig.TAU_PLUS_INV_INB;
2244 cInfo.
GAMMA = connectConfigMap[connId].stdpConfig.GAMMA;
2245 cInfo.
BETA_LTP = connectConfigMap[connId].stdpConfig.BETA_LTP;
2246 cInfo.
BETA_LTD = connectConfigMap[connId].stdpConfig.BETA_LTD;
2247 cInfo.
LAMBDA = connectConfigMap[connId].stdpConfig.LAMBDA;
2248 cInfo.
DELTA = connectConfigMap[connId].stdpConfig.DELTA;
2256 gInfo.
baseDP = groupConfigMap[gGrpId].neuromodulatorConfig.baseDP;
2257 gInfo.
base5HT = groupConfigMap[gGrpId].neuromodulatorConfig.base5HT;
2258 gInfo.
baseACh = groupConfigMap[gGrpId].neuromodulatorConfig.baseACh;
2259 gInfo.
baseNE = groupConfigMap[gGrpId].neuromodulatorConfig.baseNE;
2261 gInfo.
decayDP = groupConfigMap[gGrpId].neuromodulatorConfig.decayDP;
2262 gInfo.
decay5HT = groupConfigMap[gGrpId].neuromodulatorConfig.decay5HT;
2263 gInfo.
decayACh = groupConfigMap[gGrpId].neuromodulatorConfig.decayACh;
2264 gInfo.
decayNE = groupConfigMap[gGrpId].neuromodulatorConfig.decayNE;
2266 gInfo.
releaseDP = groupConfigMap[gGrpId].neuromodulatorConfig.releaseDP;
2267 gInfo.
release5HT = groupConfigMap[gGrpId].neuromodulatorConfig.release5HT;
2268 gInfo.
releaseACh = groupConfigMap[gGrpId].neuromodulatorConfig.releaseACh;
2269 gInfo.
releaseNE = groupConfigMap[gGrpId].neuromodulatorConfig.releaseNE;
2271 gInfo.
activeDP = groupConfigMap[gGrpId].neuromodulatorConfig.activeDP;
2272 gInfo.
active5HT = groupConfigMap[gGrpId].neuromodulatorConfig.active5HT;
2273 gInfo.
activeACh = groupConfigMap[gGrpId].neuromodulatorConfig.activeACh;
2274 gInfo.
activeNE = groupConfigMap[gGrpId].neuromodulatorConfig.activeNE;
2281 assert(gNId >= 0 && gNId < glbNetworkConfig.
numN);
2284 for (std::map<int, GroupConfigMD>::iterator grpIt = groupConfigMDMap.begin(); grpIt != groupConfigMDMap.end(); grpIt++) {
2285 if (gNId >= grpIt->second.gStartN && gNId <= grpIt->second.gEndN)
2286 gGrpId = grpIt->second.gGrpId;
2290 int neurId = gNId - groupConfigMDMap[gGrpId].gStartN;
2296 Grid3D grid = groupConfigMap[gGrpId].grid;
2297 assert(gGrpId >= 0 && gGrpId < numGroups);
2300 int intX = relNeurId % grid.
numX;
2301 int intY = (relNeurId / grid.
numX) % grid.
numY;
2302 int intZ = relNeurId / (grid.
numX * grid.
numY);
2308 return Point3D(coordX, coordY, coordZ);
2317 Grid3D grid = groupConfigMap[gGrpId].grid;
2318 assert(gGrpId >= 0 && gGrpId < numGroups);
2340 int relNeurId = intX + intY * grid.
numX + intZ * (grid.
numX * grid.
numY);
2359 if (connectConfigMap.find(connId) == connectConfigMap.end()) {
2360 KERNEL_ERROR(
"Connection ID was not found. Quitting.");
2364 return connectConfigMap[connId].numberOfConnections;
2371 if (groupConfigMDMap[gGrpId].spikeMonitorId >= 0) {
2372 return spikeMonList[(groupConfigMDMap[gGrpId].spikeMonitorId)];
2381 if (groupConfigMDMap[gGrpId].spikeMonitorId >= 0) {
2382 return spikeMonCoreList[(groupConfigMDMap[gGrpId].spikeMonitorId)];
2392 if (groupConfigMDMap[gGrpId].neuronMonitorId >= 0) {
2393 return neuronMonList[(groupConfigMDMap[gGrpId].neuronMonitorId)];
2403 if (groupConfigMDMap[gGrpId].neuronMonitorId >= 0) {
2404 return neuronMonCoreList[(groupConfigMDMap[gGrpId].neuronMonitorId)];
2412 assert(connId>=0 && connId<numConnections);
2414 return RangeWeight(0.0f, connectConfigMap[connId].initWt, connectConfigMap[connId].maxWt);
2423 void SNN::SNNinit() {
2428 switch (loggerMode_) {
2432 #if defined(WIN32) || defined(WIN64) || defined(__APPLE__) 2433 fpDeb_ = fopen(
"nul",
"w");
2435 fpDeb_ = fopen(
"/dev/null",
"w");
2444 #if defined(WIN32) || defined(WIN64) || defined(__APPLE__) 2445 fpInf_ = fopen(
"nul",
"w");
2447 fpInf_ = fopen(
"/dev/null",
"w");
2450 #if defined(WIN32) || defined(WIN64) || defined(__APPLE__) 2451 fpDeb_ = fopen(
"nul",
"w");
2453 fpDeb_ = fopen(
"/dev/null",
"w");
2458 #if defined(WIN32) || defined(WIN64) || defined(__APPLE__) 2459 fpInf_ = fopen(
"nul",
"w");
2460 fpErr_ = fopen(
"nul",
"w");
2461 fpDeb_ = fopen(
"nul",
"w");
2463 fpInf_ = fopen(
"/dev/null",
"w");
2464 fpErr_ = fopen(
"/dev/null",
"w");
2465 fpDeb_ = fopen(
"/dev/null",
"w");
2476 #if defined(WIN32) || defined(WIN64) 2477 CreateDirectory(
"results", NULL);
2478 fpLog_ = fopen(
"results/carlsim.log",
"w");
2482 if (stat(
"results", &sb) == -1 || !S_ISDIR(sb.st_mode)) {
2484 createDir = mkdir(
"results", 0777);
2487 if (createDir == -1) {
2489 fprintf(stderr,
"Could not create directory \"results/\", which is required to " 2490 "store simulation results. Aborting simulation...\n");
2494 fpLog_ = fopen(
"results/carlsim.log",
"w");
2496 if (createDir == 0) {
2498 KERNEL_INFO(
"Created results directory \"results/\".");
2502 if (fpLog_ == NULL) {
2503 fprintf(stderr,
"Could not create the directory \"results/\" or the log file \"results/carlsim.log\"" 2504 ", which is required to store simulation results. Aborting simulation...\n");
2508 KERNEL_INFO(
"*********************************************************************************");
2509 KERNEL_INFO(
"******************** Welcome to CARLsim %d.%d ***************************",
2511 KERNEL_INFO(
"*********************************************************************************\n");
2513 KERNEL_INFO(
"***************************** Configuring Network ********************************");
2514 KERNEL_INFO(
"Starting CARLsim simulation \"%s\" in %s mode",networkName_.c_str(),
2519 struct tm * timeinfo;
2521 timeinfo = localtime(&rawtime);
2522 KERNEL_DEBUG(
"Current local time and date: %s", asctime(timeinfo));
2527 simTimeRunStart = 0; simTimeRunStop = 0;
2528 simTimeLastRunSummary = 0;
2529 simTimeMs = 0; simTimeSec = 0; simTime = 0;
2533 numCompartmentConnections = 0;
2534 numSpikeGenGrps = 0;
2535 simulatorDeleted =
false;
2537 cumExecutionTime = 0.0f;
2538 executionTime = 0.0f;
2539 prevExecutionTime = 0.0f;
2541 spikeRateUpdated =
false;
2542 numSpikeMonitor = 0;
2543 numNeuronMonitor = 0;
2544 numGroupMonitor = 0;
2545 numConnectionMonitor = 0;
2547 sim_with_compartments =
false;
2548 sim_with_fixedwts =
true;
2549 #define LN_I_CALC_TYPES__REQUIRED_FOR_NETWORK_LEVEL 2550 sim_with_conductances =
false;
2551 sim_with_stdp =
false;
2552 sim_with_modulated_stdp =
false;
2553 sim_with_homeostasis =
false;
2554 sim_with_stp =
false;
2555 sim_in_testing =
false;
2559 #define LN_I_CALC_TYPES__REQUIRED_FOR_NETWORK_LEVEL 2561 sim_with_NMDA_rise =
false;
2562 sim_with_GABAb_rise =
false;
2563 #define LN_I_CALC_TYPES__REQUIRED_FOR_NETWORK_LEVEL 2564 #ifndef LN_I_CALC_TYPES 2565 dAMPA = 1.0-1.0/5.0;
2566 rNMDA = 1.0-1.0/10.0;
2567 dNMDA = 1.0-1.0/150.0;
2569 dGABAa = 1.0-1.0/6.0;
2570 rGABAb = 1.0-1.0/100.0;
2571 dGABAb = 1.0-1.0/150.0;
2581 resetMonitors(
false);
2583 resetGroupConfigs(
false);
2585 resetConnectionConfigs(
false);
2594 memset(runtimeData, 0,
sizeof(
RuntimeData) * MAX_NET_PER_SNN);
2596 runtimeData[netId].allocated =
false;
2599 memset(&managerRuntimeData, 0,
sizeof(
RuntimeData));
2603 wtANDwtChangeUpdateInterval_ = 1000;
2604 wtANDwtChangeUpdateIntervalCnt_ = 0;
2605 stdpScaleFactor_ = 1.0f;
2606 wtChangeDecay_ = 0.0f;
2610 CUDA_CREATE_TIMER(timer);
2611 CUDA_RESET_TIMER(timer);
2615 void SNN::advSimStep() {
2616 doSTPUpdateAndDecayCond();
2620 spikeGeneratorUpdate();
2628 updateTimingTable();
2636 globalStateUpdate();
2640 clearExtFiringTable();
2643 void SNN::doSTPUpdateAndDecayCond() {
2644 #ifndef __NO_PTHREADS__ // POSIX 2645 pthread_t threads[numCores + 1];
2648 int threadCount = 0;
2652 if (!groupPartitionLists[netId].empty()) {
2653 assert(runtimeData[netId].allocated);
2655 doSTPUpdateAndDecayCond_GPU(netId);
2657 #ifdef __NO_PTHREADS__ 2658 doSTPUpdateAndDecayCond_CPU(netId);
2659 #else // Linux or MAC 2660 pthread_attr_t attr;
2661 pthread_attr_init(&attr);
2664 pthread_attr_setaffinity_np(&attr,
sizeof(cpu_set_t), &cpus);
2666 argsThreadRoutine[threadCount].
snn_pointer =
this;
2667 argsThreadRoutine[threadCount].
netId = netId;
2668 argsThreadRoutine[threadCount].
lGrpId = 0;
2669 argsThreadRoutine[threadCount].
startIdx = 0;
2670 argsThreadRoutine[threadCount].
endIdx = 0;
2671 argsThreadRoutine[threadCount].
GtoLOffset = 0;
2673 pthread_create(&threads[threadCount], &attr, &SNN::helperDoSTPUpdateAndDecayCond_CPU, (
void*)&argsThreadRoutine[threadCount]);
2674 pthread_attr_destroy(&attr);
2681 #ifndef __NO_PTHREADS__ // POSIX 2683 for (
int i=0; i<threadCount; i++){
2684 pthread_join(threads[i], NULL);
2689 void SNN::spikeGeneratorUpdate() {
2691 if (spikeRateUpdated) {
2692 #ifndef __NO_PTHREADS__ // POSIX 2693 pthread_t threads[numCores + 1];
2696 int threadCount = 0;
2700 if (!groupPartitionLists[netId].empty()) {
2702 assignPoissonFiringRate_GPU(netId);
2704 #ifdef __NO_PTHREADS__ 2705 assignPoissonFiringRate_CPU(netId);
2706 #else // Linux or MAC 2707 pthread_attr_t attr;
2708 pthread_attr_init(&attr);
2711 pthread_attr_setaffinity_np(&attr,
sizeof(cpu_set_t), &cpus);
2713 argsThreadRoutine[threadCount].
snn_pointer =
this;
2714 argsThreadRoutine[threadCount].
netId = netId;
2715 argsThreadRoutine[threadCount].
lGrpId = 0;
2716 argsThreadRoutine[threadCount].
startIdx = 0;
2717 argsThreadRoutine[threadCount].
endIdx = 0;
2718 argsThreadRoutine[threadCount].
GtoLOffset = 0;
2720 pthread_create(&threads[threadCount], &attr, &SNN::helperAssignPoissonFiringRate_CPU, (
void*)&argsThreadRoutine[threadCount]);
2721 pthread_attr_destroy(&attr);
2728 #ifndef __NO_PTHREADS__ // POSIX 2730 for (
int i=0; i<threadCount; i++){
2731 pthread_join(threads[i], NULL);
2735 spikeRateUpdated =
false;
2739 generateUserDefinedSpikes();
2741 #ifndef __NO_PTHREADS__ // POSIX 2742 pthread_t threads[numCores + 1];
2745 int threadCount = 0;
2749 if (!groupPartitionLists[netId].empty()) {
2751 spikeGeneratorUpdate_GPU(netId);
2753 #ifdef __NO_PTHREADS__ 2754 spikeGeneratorUpdate_CPU(netId);
2755 #else // Linux or MAC 2756 pthread_attr_t attr;
2757 pthread_attr_init(&attr);
2760 pthread_attr_setaffinity_np(&attr,
sizeof(cpu_set_t), &cpus);
2762 argsThreadRoutine[threadCount].
snn_pointer =
this;
2763 argsThreadRoutine[threadCount].
netId = netId;
2764 argsThreadRoutine[threadCount].
lGrpId = 0;
2765 argsThreadRoutine[threadCount].
startIdx = 0;
2766 argsThreadRoutine[threadCount].
endIdx = 0;
2767 argsThreadRoutine[threadCount].
GtoLOffset = 0;
2769 pthread_create(&threads[threadCount], &attr, &SNN::helperSpikeGeneratorUpdate_CPU, (
void*)&argsThreadRoutine[threadCount]);
2770 pthread_attr_destroy(&attr);
2777 #ifndef __NO_PTHREADS__ // POSIX 2779 for (
int i=0; i<threadCount; i++){
2780 pthread_join(threads[i], NULL);
2788 void SNN::findFiring() {
2789 #ifndef __NO_PTHREADS__ // POSIX 2790 pthread_t threads[numCores + 1];
2793 int threadCount = 0;
2797 if (!groupPartitionLists[netId].empty()) {
2799 findFiring_GPU(netId);
2801 #ifdef __NO_PTHREADS__ 2802 findFiring_CPU(netId);
2803 #else // Linux or MAC 2804 pthread_attr_t attr;
2805 pthread_attr_init(&attr);
2808 pthread_attr_setaffinity_np(&attr,
sizeof(cpu_set_t), &cpus);
2810 argsThreadRoutine[threadCount].
snn_pointer =
this;
2811 argsThreadRoutine[threadCount].
netId = netId;
2812 argsThreadRoutine[threadCount].
lGrpId = 0;
2813 argsThreadRoutine[threadCount].
startIdx = 0;
2814 argsThreadRoutine[threadCount].
endIdx = 0;
2815 argsThreadRoutine[threadCount].
GtoLOffset = 0;
2817 pthread_create(&threads[threadCount], &attr, &SNN::helperFindFiring_CPU, (
void*)&argsThreadRoutine[threadCount]);
2818 pthread_attr_destroy(&attr);
2825 #ifndef __NO_PTHREADS__ // POSIX 2827 for (
int i=0; i<threadCount; i++){
2828 pthread_join(threads[i], NULL);
2833 void SNN::doCurrentUpdate() {
2834 #ifndef __NO_PTHREADS__ // POSIX 2835 pthread_t threads[numCores + 1];
2838 int threadCount = 0;
2844 if (!groupPartitionLists[netId].empty()) {
2846 doCurrentUpdateD2_GPU(netId);
2848 #ifdef __NO_PTHREADS__ 2849 doCurrentUpdateD2_CPU(netId);
2850 #else // Linux or MAC 2851 pthread_attr_t attr;
2852 pthread_attr_init(&attr);
2855 pthread_attr_setaffinity_np(&attr,
sizeof(cpu_set_t), &cpus);
2857 argsThreadRoutine[threadCount].
snn_pointer =
this;
2858 argsThreadRoutine[threadCount].
netId = netId;
2859 argsThreadRoutine[threadCount].
lGrpId = 0;
2860 argsThreadRoutine[threadCount].
startIdx = 0;
2861 argsThreadRoutine[threadCount].
endIdx = 0;
2862 argsThreadRoutine[threadCount].
GtoLOffset = 0;
2864 pthread_create(&threads[threadCount], &attr, &SNN::helperDoCurrentUpdateD2_CPU, (
void*)&argsThreadRoutine[threadCount]);
2865 pthread_attr_destroy(&attr);
2872 #ifndef __NO_PTHREADS__ // POSIX 2874 for (
int i=0; i<threadCount; i++){
2875 pthread_join(threads[i], NULL);
2885 if (!groupPartitionLists[netId].empty()) {
2887 doCurrentUpdateD1_GPU(netId);
2889 #ifdef __NO_PTHREADS__ 2890 doCurrentUpdateD1_CPU(netId);
2891 #else // Linux or MAC 2892 pthread_attr_t attr;
2893 pthread_attr_init(&attr);
2896 pthread_attr_setaffinity_np(&attr,
sizeof(cpu_set_t), &cpus);
2898 argsThreadRoutine[threadCount].
snn_pointer =
this;
2899 argsThreadRoutine[threadCount].
netId = netId;
2900 argsThreadRoutine[threadCount].
lGrpId = 0;
2901 argsThreadRoutine[threadCount].
startIdx = 0;
2902 argsThreadRoutine[threadCount].
endIdx = 0;
2903 argsThreadRoutine[threadCount].
GtoLOffset = 0;
2905 pthread_create(&threads[threadCount], &attr, &SNN::helperDoCurrentUpdateD1_CPU, (
void*)&argsThreadRoutine[threadCount]);
2906 pthread_attr_destroy(&attr);
2913 #ifndef __NO_PTHREADS__ // POSIX 2915 for (
int i=0; i<threadCount; i++){
2916 pthread_join(threads[i], NULL);
2921 void SNN::updateTimingTable() {
2922 #ifndef __NO_PTHREADS__ // POSIX 2923 pthread_t threads[numCores + 1];
2926 int threadCount = 0;
2930 if (!groupPartitionLists[netId].empty()) {
2932 updateTimingTable_GPU(netId);
2934 #ifdef __NO_PTHREADS__ 2935 updateTimingTable_CPU(netId);
2936 #else // Linux or MAC 2937 pthread_attr_t attr;
2938 pthread_attr_init(&attr);
2941 pthread_attr_setaffinity_np(&attr,
sizeof(cpu_set_t), &cpus);
2943 argsThreadRoutine[threadCount].
snn_pointer =
this;
2944 argsThreadRoutine[threadCount].
netId = netId;
2945 argsThreadRoutine[threadCount].
lGrpId = 0;
2946 argsThreadRoutine[threadCount].
startIdx = 0;
2947 argsThreadRoutine[threadCount].
endIdx = 0;
2948 argsThreadRoutine[threadCount].
GtoLOffset = 0;
2950 pthread_create(&threads[threadCount], &attr, &SNN::helperUpdateTimingTable_CPU, (
void*)&argsThreadRoutine[threadCount]);
2951 pthread_attr_destroy(&attr);
2957 #ifndef __NO_PTHREADS__ // POSIX 2959 for (
int i=0; i<threadCount; i++){
2960 pthread_join(threads[i], NULL);
2965 void SNN::globalStateUpdate() {
2966 #ifndef __NO_PTHREADS__ // POSIX 2967 pthread_t threads[numCores + 1];
2970 int threadCount = 0;
2974 if (!groupPartitionLists[netId].empty()) {
2976 globalStateUpdate_C_GPU(netId);
2978 #ifdef __NO_PTHREADS__ 2979 globalStateUpdate_CPU(netId);
2980 #else // Linux or MAC 2981 pthread_attr_t attr;
2982 pthread_attr_init(&attr);
2985 pthread_attr_setaffinity_np(&attr,
sizeof(cpu_set_t), &cpus);
2987 argsThreadRoutine[threadCount].
snn_pointer =
this;
2988 argsThreadRoutine[threadCount].
netId = netId;
2989 argsThreadRoutine[threadCount].
lGrpId = 0;
2990 argsThreadRoutine[threadCount].
startIdx = 0;
2991 argsThreadRoutine[threadCount].
endIdx = 0;
2992 argsThreadRoutine[threadCount].
GtoLOffset = 0;
2994 pthread_create(&threads[threadCount], &attr, &SNN::helperGlobalStateUpdate_CPU, (
void*)&argsThreadRoutine[threadCount]);
2995 pthread_attr_destroy(&attr);
3002 #ifndef __NO_PTHREADS__ // POSIX 3004 for (
int i=0; i<threadCount; i++){
3005 pthread_join(threads[i], NULL);
3010 if (!groupPartitionLists[netId].empty()) {
3012 globalStateUpdate_N_GPU(netId);
3017 if (!groupPartitionLists[netId].empty()) {
3019 globalStateUpdate_G_GPU(netId);
3024 void SNN::clearExtFiringTable() {
3025 #ifndef __NO_PTHREADS__ // POSIX 3026 pthread_t threads[numCores + 1];
3029 int threadCount = 0;
3033 if (!groupPartitionLists[netId].empty()) {
3035 clearExtFiringTable_GPU(netId);
3037 #ifdef __NO_PTHREADS__ 3038 clearExtFiringTable_CPU(netId);
3039 #else // Linux or MAC 3040 pthread_attr_t attr;
3041 pthread_attr_init(&attr);
3044 pthread_attr_setaffinity_np(&attr,
sizeof(cpu_set_t), &cpus);
3046 argsThreadRoutine[threadCount].
snn_pointer =
this;
3047 argsThreadRoutine[threadCount].
netId = netId;
3048 argsThreadRoutine[threadCount].
lGrpId = 0;
3049 argsThreadRoutine[threadCount].
startIdx = 0;
3050 argsThreadRoutine[threadCount].
endIdx = 0;
3051 argsThreadRoutine[threadCount].
GtoLOffset = 0;
3053 pthread_create(&threads[threadCount], &attr, &SNN::helperClearExtFiringTable_CPU, (
void*)&argsThreadRoutine[threadCount]);
3054 pthread_attr_destroy(&attr);
3061 #ifndef __NO_PTHREADS__ // POSIX 3063 for (
int i=0; i<threadCount; i++){
3064 pthread_join(threads[i], NULL);
3069 void SNN::updateWeights() {
3070 #ifndef __NO_PTHREADS__ // POSIX 3071 pthread_t threads[numCores + 1];
3074 int threadCount = 0;
3078 if (!groupPartitionLists[netId].empty()) {
3080 updateWeights_GPU(netId);
3082 #ifdef __NO_PTHREADS__ 3083 updateWeights_CPU(netId);
3084 #else // Linux or MAC 3085 pthread_attr_t attr;
3086 pthread_attr_init(&attr);
3089 pthread_attr_setaffinity_np(&attr,
sizeof(cpu_set_t), &cpus);
3091 argsThreadRoutine[threadCount].
snn_pointer =
this;
3092 argsThreadRoutine[threadCount].
netId = netId;
3093 argsThreadRoutine[threadCount].
lGrpId = 0;
3094 argsThreadRoutine[threadCount].
startIdx = 0;
3095 argsThreadRoutine[threadCount].
endIdx = 0;
3096 argsThreadRoutine[threadCount].
GtoLOffset = 0;
3098 pthread_create(&threads[threadCount], &attr, &SNN::helperUpdateWeights_CPU, (
void*)&argsThreadRoutine[threadCount]);
3099 pthread_attr_destroy(&attr);
3105 #ifndef __NO_PTHREADS__ // POSIX 3107 for (
int i=0; i<threadCount; i++){
3108 pthread_join(threads[i], NULL);
3114 void SNN::updateNetworkConfig(
int netId) {
3118 copyNetworkConfig(netId, cudaMemcpyHostToDevice);
3120 copyNetworkConfig(netId);
3123 void SNN::shiftSpikeTables() {
3124 #ifndef __NO_PTHREADS__ // POSIX 3125 pthread_t threads[numCores + 1];
3128 int threadCount = 0;
3132 if (!groupPartitionLists[netId].empty()) {
3134 shiftSpikeTables_F_GPU(netId);
3136 #ifdef __NO_PTHREADS__ 3137 shiftSpikeTables_CPU(netId);
3138 #else // Linux or MAC 3139 pthread_attr_t attr;
3140 pthread_attr_init(&attr);
3143 pthread_attr_setaffinity_np(&attr,
sizeof(cpu_set_t), &cpus);
3145 argsThreadRoutine[threadCount].
snn_pointer =
this;
3146 argsThreadRoutine[threadCount].
netId = netId;
3147 argsThreadRoutine[threadCount].
lGrpId = 0;
3148 argsThreadRoutine[threadCount].
startIdx = 0;
3149 argsThreadRoutine[threadCount].
endIdx = 0;
3150 argsThreadRoutine[threadCount].
GtoLOffset = 0;
3152 pthread_create(&threads[threadCount], &attr, &SNN::helperShiftSpikeTables_CPU, (
void*)&argsThreadRoutine[threadCount]);
3153 pthread_attr_destroy(&attr);
3160 #ifndef __NO_PTHREADS__ // POSIX 3162 for (
int i=0; i<threadCount; i++){
3163 pthread_join(threads[i], NULL);
3168 if (!groupPartitionLists[netId].empty()) {
3170 shiftSpikeTables_T_GPU(netId);
3175 void SNN::allocateSNN(
int netId) {
3179 allocateSNN_GPU(netId);
3181 allocateSNN_CPU(netId);
3184 void SNN::allocateManagerRuntimeData() {
3197 managerRuntimeData.
voltage =
new float[managerRTDSize.maxNumNReg];
3198 managerRuntimeData.
nextVoltage =
new float[managerRTDSize.maxNumNReg];
3199 managerRuntimeData.
recovery =
new float[managerRTDSize.maxNumNReg];
3200 managerRuntimeData.
Izh_a =
new float[managerRTDSize.maxNumNReg];
3201 managerRuntimeData.
Izh_b =
new float[managerRTDSize.maxNumNReg];
3202 managerRuntimeData.
Izh_c =
new float[managerRTDSize.maxNumNReg];
3203 managerRuntimeData.
Izh_d =
new float[managerRTDSize.maxNumNReg];
3204 managerRuntimeData.
Izh_C =
new float[managerRTDSize.maxNumNReg];
3205 managerRuntimeData.
Izh_k =
new float[managerRTDSize.maxNumNReg];
3206 managerRuntimeData.
Izh_vr =
new float[managerRTDSize.maxNumNReg];
3207 managerRuntimeData.
Izh_vt =
new float[managerRTDSize.maxNumNReg];
3208 managerRuntimeData.
Izh_vpeak =
new float[managerRTDSize.maxNumNReg];
3209 managerRuntimeData.
lif_tau_m =
new int[managerRTDSize.maxNumNReg];
3210 managerRuntimeData.
lif_tau_ref =
new int[managerRTDSize.maxNumNReg];
3211 managerRuntimeData.
lif_tau_ref_c =
new int[managerRTDSize.maxNumNReg];
3212 managerRuntimeData.
lif_vTh =
new float[managerRTDSize.maxNumNReg];
3213 managerRuntimeData.
lif_vReset =
new float[managerRTDSize.maxNumNReg];
3214 managerRuntimeData.
lif_gain =
new float[managerRTDSize.maxNumNReg];
3215 managerRuntimeData.
lif_bias =
new float[managerRTDSize.maxNumNReg];
3216 managerRuntimeData.
current =
new float[managerRTDSize.maxNumNReg];
3217 managerRuntimeData.
extCurrent =
new float[managerRTDSize.maxNumNReg];
3218 managerRuntimeData.
totalCurrent =
new float[managerRTDSize.maxNumNReg];
3219 managerRuntimeData.
curSpike =
new bool[managerRTDSize.maxNumNReg];
3220 memset(managerRuntimeData.
voltage, 0,
sizeof(
float) * managerRTDSize.maxNumNReg);
3221 memset(managerRuntimeData.
nextVoltage, 0,
sizeof(
float) * managerRTDSize.maxNumNReg);
3222 memset(managerRuntimeData.
recovery, 0,
sizeof(
float) * managerRTDSize.maxNumNReg);
3223 memset(managerRuntimeData.
Izh_a, 0,
sizeof(
float) * managerRTDSize.maxNumNReg);
3224 memset(managerRuntimeData.
Izh_b, 0,
sizeof(
float) * managerRTDSize.maxNumNReg);
3225 memset(managerRuntimeData.
Izh_c, 0,
sizeof(
float) * managerRTDSize.maxNumNReg);
3226 memset(managerRuntimeData.
Izh_d, 0,
sizeof(
float) * managerRTDSize.maxNumNReg);
3227 memset(managerRuntimeData.
Izh_C, 0,
sizeof(
float) * managerRTDSize.maxNumNReg);
3228 memset(managerRuntimeData.
Izh_k, 0,
sizeof(
float) * managerRTDSize.maxNumNReg);
3229 memset(managerRuntimeData.
Izh_vr, 0,
sizeof(
float) * managerRTDSize.maxNumNReg);
3230 memset(managerRuntimeData.
Izh_vt, 0,
sizeof(
float) * managerRTDSize.maxNumNReg);
3231 memset(managerRuntimeData.
Izh_vpeak, 0,
sizeof(
float) * managerRTDSize.maxNumNReg);
3232 memset(managerRuntimeData.
lif_tau_m, 0,
sizeof(
int) * managerRTDSize.maxNumNReg);
3233 memset(managerRuntimeData.
lif_tau_ref, 0,
sizeof(
int) * managerRTDSize.maxNumNReg);
3234 memset(managerRuntimeData.
lif_tau_ref_c, 0,
sizeof(
int) * managerRTDSize.maxNumNReg);
3235 memset(managerRuntimeData.
lif_vTh, 0,
sizeof(
float) * managerRTDSize.maxNumNReg);
3236 memset(managerRuntimeData.
lif_vReset, 0,
sizeof(
float) * managerRTDSize.maxNumNReg);
3237 memset(managerRuntimeData.
lif_gain, 0,
sizeof(
float) * managerRTDSize.maxNumNReg);
3238 memset(managerRuntimeData.
lif_bias, 0,
sizeof(
float) * managerRTDSize.maxNumNReg);
3239 memset(managerRuntimeData.
current, 0,
sizeof(
float) * managerRTDSize.maxNumNReg);
3240 memset(managerRuntimeData.
extCurrent, 0,
sizeof(
float) * managerRTDSize.maxNumNReg);
3241 memset(managerRuntimeData.
totalCurrent, 0,
sizeof(
float) * managerRTDSize.maxNumNReg);
3242 memset(managerRuntimeData.
curSpike, 0,
sizeof(
bool) * managerRTDSize.maxNumNReg);
3248 memset(managerRuntimeData.
nUBuffer, 0,
sizeof(
float) * MAX_NEURON_MON_GRP_SZIE * 1000 * managerRTDSize.maxNumGroups);
3249 memset(managerRuntimeData.
nIBuffer, 0,
sizeof(
float) * MAX_NEURON_MON_GRP_SZIE * 1000 * managerRTDSize.maxNumGroups);
3251 managerRuntimeData.
gAMPA =
new float[managerRTDSize.glbNumNReg];
3252 managerRuntimeData.
gNMDA_r =
new float[managerRTDSize.glbNumNReg];
3253 managerRuntimeData.
gNMDA_d =
new float[managerRTDSize.glbNumNReg];
3254 managerRuntimeData.
gNMDA =
new float[managerRTDSize.glbNumNReg];
3255 memset(managerRuntimeData.
gAMPA, 0,
sizeof(
float) * managerRTDSize.glbNumNReg);
3256 memset(managerRuntimeData.
gNMDA_r, 0,
sizeof(
float) * managerRTDSize.glbNumNReg);
3257 memset(managerRuntimeData.
gNMDA_d, 0,
sizeof(
float) * managerRTDSize.glbNumNReg);
3258 memset(managerRuntimeData.
gNMDA, 0,
sizeof(
float) * managerRTDSize.glbNumNReg);
3260 managerRuntimeData.
gGABAa =
new float[managerRTDSize.glbNumNReg];
3261 managerRuntimeData.
gGABAb_r =
new float[managerRTDSize.glbNumNReg];
3262 managerRuntimeData.
gGABAb_d =
new float[managerRTDSize.glbNumNReg];
3263 managerRuntimeData.
gGABAb =
new float[managerRTDSize.glbNumNReg];
3264 memset(managerRuntimeData.
gGABAa, 0,
sizeof(
float) * managerRTDSize.glbNumNReg);
3265 memset(managerRuntimeData.
gGABAb_r, 0,
sizeof(
float) * managerRTDSize.glbNumNReg);
3266 memset(managerRuntimeData.
gGABAb_d, 0,
sizeof(
float) * managerRTDSize.glbNumNReg);
3267 memset(managerRuntimeData.
gGABAb, 0,
sizeof(
float) * managerRTDSize.glbNumNReg);
3270 managerRuntimeData.
grpDA =
new float[managerRTDSize.maxNumGroups];
3271 managerRuntimeData.
grp5HT =
new float[managerRTDSize.maxNumGroups];
3272 managerRuntimeData.
grpACh =
new float[managerRTDSize.maxNumGroups];
3273 managerRuntimeData.
grpNE =
new float[managerRTDSize.maxNumGroups];
3274 memset(managerRuntimeData.
grpDA, 0,
sizeof(
float) * managerRTDSize.maxNumGroups);
3275 memset(managerRuntimeData.
grp5HT, 0,
sizeof(
float) * managerRTDSize.maxNumGroups);
3276 memset(managerRuntimeData.
grpACh, 0,
sizeof(
float) * managerRTDSize.maxNumGroups);
3277 memset(managerRuntimeData.
grpNE, 0,
sizeof(
float) * managerRTDSize.maxNumGroups);
3280 managerRuntimeData.
grpDABuffer =
new float[managerRTDSize.maxNumGroups * 1000];
3281 managerRuntimeData.
grp5HTBuffer =
new float[managerRTDSize.maxNumGroups * 1000];
3282 managerRuntimeData.
grpAChBuffer =
new float[managerRTDSize.maxNumGroups * 1000];
3283 managerRuntimeData.
grpNEBuffer =
new float[managerRTDSize.maxNumGroups * 1000];
3284 memset(managerRuntimeData.
grpDABuffer, 0, managerRTDSize.maxNumGroups *
sizeof(
float) * 1000);
3285 memset(managerRuntimeData.
grp5HTBuffer, 0, managerRTDSize.maxNumGroups *
sizeof(
float) * 1000);
3286 memset(managerRuntimeData.
grpAChBuffer, 0, managerRTDSize.maxNumGroups *
sizeof(
float) * 1000);
3287 memset(managerRuntimeData.
grpNEBuffer, 0, managerRTDSize.maxNumGroups *
sizeof(
float) * 1000);
3289 managerRuntimeData.
lastSpikeTime =
new int[managerRTDSize.maxNumNAssigned];
3290 memset(managerRuntimeData.
lastSpikeTime, 0,
sizeof(
int) * managerRTDSize.maxNumNAssigned);
3292 managerRuntimeData.
nSpikeCnt =
new int[managerRTDSize.glbNumN];
3293 memset(managerRuntimeData.
nSpikeCnt, 0,
sizeof(
int) * managerRTDSize.glbNumN);
3296 managerRuntimeData.
avgFiring =
new float[managerRTDSize.maxNumN];
3297 managerRuntimeData.
baseFiring =
new float[managerRTDSize.maxNumN];
3298 memset(managerRuntimeData.
avgFiring, 0,
sizeof(
float) * managerRTDSize.maxNumN);
3299 memset(managerRuntimeData.
baseFiring, 0,
sizeof(
float) * managerRTDSize.maxNumN);
3304 managerRuntimeData.
stpu =
new float[managerRTDSize.maxNumN * (glbNetworkConfig.
maxDelay + 1)];
3305 managerRuntimeData.
stpx =
new float[managerRTDSize.maxNumN * (glbNetworkConfig.
maxDelay + 1)];
3306 memset(managerRuntimeData.
stpu, 0,
sizeof(
float) * managerRTDSize.maxNumN * (glbNetworkConfig.
maxDelay + 1));
3307 memset(managerRuntimeData.
stpx, 0,
sizeof(
float) * managerRTDSize.maxNumN * (glbNetworkConfig.
maxDelay + 1));
3309 managerRuntimeData.
Npre =
new unsigned short[managerRTDSize.maxNumNAssigned];
3310 managerRuntimeData.
Npre_plastic =
new unsigned short[managerRTDSize.maxNumNAssigned];
3311 managerRuntimeData.
Npost =
new unsigned short[managerRTDSize.maxNumNAssigned];
3312 managerRuntimeData.
cumulativePost =
new unsigned int[managerRTDSize.maxNumNAssigned];
3313 managerRuntimeData.
cumulativePre =
new unsigned int[managerRTDSize.maxNumNAssigned];
3314 memset(managerRuntimeData.
Npre, 0,
sizeof(
short) * managerRTDSize.maxNumNAssigned);
3315 memset(managerRuntimeData.
Npre_plastic, 0,
sizeof(
short) * managerRTDSize.maxNumNAssigned);
3316 memset(managerRuntimeData.
Npost, 0,
sizeof(
short) * managerRTDSize.maxNumNAssigned);
3317 memset(managerRuntimeData.
cumulativePost, 0,
sizeof(
int) * managerRTDSize.maxNumNAssigned);
3318 memset(managerRuntimeData.
cumulativePre, 0,
sizeof(
int) * managerRTDSize.maxNumNAssigned);
3328 managerRuntimeData.
wt =
new float[managerRTDSize.maxNumPreSynNet];
3329 managerRuntimeData.
wtChange =
new float[managerRTDSize.maxNumPreSynNet];
3330 managerRuntimeData.
maxSynWt =
new float[managerRTDSize.maxNumPreSynNet];
3331 managerRuntimeData.
synSpikeTime =
new int[managerRTDSize.maxNumPreSynNet];
3332 memset(managerRuntimeData.
wt, 0,
sizeof(
float) * managerRTDSize.maxNumPreSynNet);
3333 memset(managerRuntimeData.
wtChange, 0,
sizeof(
float) * managerRTDSize.maxNumPreSynNet);
3334 memset(managerRuntimeData.
maxSynWt, 0,
sizeof(
float) * managerRTDSize.maxNumPreSynNet);
3335 memset(managerRuntimeData.
synSpikeTime, 0,
sizeof(
int) * managerRTDSize.maxNumPreSynNet);
3337 mulSynFast =
new float[managerRTDSize.maxNumConnections];
3338 mulSynSlow =
new float[managerRTDSize.maxNumConnections];
3339 memset(mulSynFast, 0,
sizeof(
float) * managerRTDSize.maxNumConnections);
3340 memset(mulSynSlow, 0,
sizeof(
float) * managerRTDSize.maxNumConnections);
3342 managerRuntimeData.
connIdsPreIdx =
new short int[managerRTDSize.maxNumPreSynNet];
3343 memset(managerRuntimeData.
connIdsPreIdx, 0,
sizeof(
short int) * managerRTDSize.maxNumPreSynNet);
3345 managerRuntimeData.
grpIds =
new short int[managerRTDSize.maxNumNAssigned];
3346 memset(managerRuntimeData.
grpIds, 0,
sizeof(
short int) * managerRTDSize.maxNumNAssigned);
3348 managerRuntimeData.
spikeGenBits =
new unsigned int[managerRTDSize.maxNumNSpikeGen / 32 + 1];
3350 managerRuntimeData.
randNum =
new float[managerRTDSize.maxNumNPois];
3351 managerRuntimeData.
poissonFireRate =
new float[managerRTDSize.maxNumNPois];
3359 int SNN::assignGroup(
int gGrpId,
int availableNeuronId) {
3360 int newAvailableNeuronId;
3361 assert(groupConfigMDMap[gGrpId].gStartN == -1);
3362 groupConfigMDMap[gGrpId].gStartN = availableNeuronId;
3363 groupConfigMDMap[gGrpId].gEndN = availableNeuronId + groupConfigMap[gGrpId].numN - 1;
3366 gGrpId, groupConfigMap[gGrpId].grpName.c_str(), groupConfigMDMap[gGrpId].gStartN, groupConfigMDMap[gGrpId].gEndN);
3368 newAvailableNeuronId = availableNeuronId + groupConfigMap[gGrpId].numN;
3371 return newAvailableNeuronId;
3374 int SNN::assignGroup(std::list<GroupConfigMD>::iterator grpIt,
int localGroupId,
int availableNeuronId) {
3375 int newAvailableNeuronId;
3376 assert(grpIt->lGrpId == -1);
3377 grpIt->lGrpId = localGroupId;
3378 grpIt->lStartN = availableNeuronId;
3379 grpIt->lEndN = availableNeuronId + groupConfigMap[grpIt->gGrpId].numN - 1;
3381 grpIt->LtoGOffset = grpIt->gStartN - grpIt->lStartN;
3382 grpIt->GtoLOffset = grpIt->lStartN - grpIt->gStartN;
3384 KERNEL_DEBUG(
"Allocation for group (%s) [id:%d, local id:%d], St=%d, End=%d", groupConfigMap[grpIt->gGrpId].grpName.c_str(),
3385 grpIt->gGrpId, grpIt->lGrpId, grpIt->lStartN, grpIt->lEndN);
3387 newAvailableNeuronId = availableNeuronId + groupConfigMap[grpIt->gGrpId].numN;
3389 return newAvailableNeuronId;
3392 void SNN::generateGroupRuntime(
int netId,
int lGrpId) {
3393 resetNeuromodulator(netId, lGrpId);
3395 for(
int lNId = groupConfigs[netId][lGrpId].lStartN; lNId <= groupConfigs[netId][lGrpId].
lEndN; lNId++)
3396 resetNeuron(netId, lGrpId, lNId);
3399 void SNN::generateRuntimeGroupConfigs() {
3401 for (std::list<GroupConfigMD>::iterator grpIt = groupPartitionLists[netId].begin(); grpIt != groupPartitionLists[netId].end(); grpIt++) {
3403 int gGrpId = grpIt->gGrpId;
3404 int lGrpId = grpIt->lGrpId;
3408 groupConfigs[netId][lGrpId].
netId = grpIt->netId;
3409 groupConfigs[netId][lGrpId].
gGrpId = grpIt->gGrpId;
3410 groupConfigs[netId][lGrpId].
gStartN = grpIt->gStartN;
3411 groupConfigs[netId][lGrpId].
gEndN = grpIt->gEndN;
3412 groupConfigs[netId][lGrpId].
lGrpId = grpIt->lGrpId;
3413 groupConfigs[netId][lGrpId].
lStartN = grpIt->lStartN;
3414 groupConfigs[netId][lGrpId].
lEndN = grpIt->lEndN;
3415 groupConfigs[netId][lGrpId].
LtoGOffset = grpIt->LtoGOffset;
3416 groupConfigs[netId][lGrpId].
GtoLOffset = grpIt->GtoLOffset;
3417 groupConfigs[netId][lGrpId].
Type = groupConfigMap[gGrpId].type;
3418 groupConfigs[netId][lGrpId].
numN = groupConfigMap[gGrpId].numN;
3420 groupConfigs[netId][lGrpId].
numPreSynapses = grpIt->numPreSynapses;
3421 groupConfigs[netId][lGrpId].
isSpikeGenerator = groupConfigMap[gGrpId].isSpikeGenerator;
3422 groupConfigs[netId][lGrpId].
isSpikeGenFunc = groupConfigMap[gGrpId].spikeGenFunc != NULL ? true :
false;
3423 groupConfigs[netId][lGrpId].
WithSTP = groupConfigMap[gGrpId].stpConfig.WithSTP;
3424 groupConfigs[netId][lGrpId].
WithSTDP = groupConfigMap[gGrpId].WithSTDP;
3425 groupConfigs[netId][lGrpId].
WithDA_MOD = groupConfigMap[gGrpId].WithDA_MOD;
3433 groupConfigs[netId][lGrpId].
WithHomeostasis = groupConfigMap[gGrpId].homeoConfig.WithHomeostasis;
3434 #ifdef LN_I_CALC_TYPES 3435 groupConfigs[netId][lGrpId].
with_NMDA_rise = groupConfigMap[gGrpId].with_NMDA_rise;
3436 groupConfigs[netId][lGrpId].
with_GABAb_rise = groupConfigMap[gGrpId].with_GABAb_rise;
3438 groupConfigs[netId][lGrpId].
FixedInputWts = grpIt->fixedInputWts;
3440 groupConfigs[netId][lGrpId].
Noffset = grpIt->Noffset;
3441 groupConfigs[netId][lGrpId].
MaxDelay = grpIt->maxOutgoingDelay;
3442 groupConfigs[netId][lGrpId].
STP_A = groupConfigMap[gGrpId].stpConfig.STP_A;
3443 groupConfigs[netId][lGrpId].
STP_U = groupConfigMap[gGrpId].stpConfig.STP_U;
3444 groupConfigs[netId][lGrpId].
STP_tau_u_inv = groupConfigMap[gGrpId].stpConfig.STP_tau_u_inv;
3445 groupConfigs[netId][lGrpId].
STP_tau_x_inv = groupConfigMap[gGrpId].stpConfig.STP_tau_x_inv;
3463 groupConfigs[netId][lGrpId].
withCompartments = groupConfigMap[gGrpId].withCompartments;
3464 groupConfigs[netId][lGrpId].
compCouplingUp = groupConfigMap[gGrpId].compCouplingUp;
3465 groupConfigs[netId][lGrpId].
compCouplingDown = groupConfigMap[gGrpId].compCouplingDown;
3466 memset(&groupConfigs[netId][lGrpId].compNeighbors, 0,
sizeof(groupConfigs[netId][lGrpId].compNeighbors[0]) *
MAX_NUM_COMP_CONN);
3467 memset(&groupConfigs[netId][lGrpId].compCoupling, 0,
sizeof(groupConfigs[netId][lGrpId].compCoupling[0]) * MAX_NUM_COMP_CONN);
3470 groupConfigs[netId][lGrpId].
avgTimeScale = groupConfigMap[gGrpId].homeoConfig.avgTimeScale;
3471 groupConfigs[netId][lGrpId].
avgTimeScale_decay = groupConfigMap[gGrpId].homeoConfig.avgTimeScaleDecay;
3472 groupConfigs[netId][lGrpId].
avgTimeScaleInv = groupConfigMap[gGrpId].homeoConfig.avgTimeScaleInv;
3473 groupConfigs[netId][lGrpId].
homeostasisScale = groupConfigMap[gGrpId].homeoConfig.homeostasisScale;
3476 groupConfigs[netId][lGrpId].
baseDP = groupConfigMap[gGrpId].neuromodulatorConfig.baseDP;
3477 groupConfigs[netId][lGrpId].
base5HT = groupConfigMap[gGrpId].neuromodulatorConfig.base5HT;
3478 groupConfigs[netId][lGrpId].
baseACh = groupConfigMap[gGrpId].neuromodulatorConfig.baseACh;
3479 groupConfigs[netId][lGrpId].
baseNE = groupConfigMap[gGrpId].neuromodulatorConfig.baseNE;
3480 groupConfigs[netId][lGrpId].
decayDP = groupConfigMap[gGrpId].neuromodulatorConfig.decayDP;
3481 groupConfigs[netId][lGrpId].
decay5HT = groupConfigMap[gGrpId].neuromodulatorConfig.decay5HT;
3482 groupConfigs[netId][lGrpId].
decayACh = groupConfigMap[gGrpId].neuromodulatorConfig.decayACh;
3483 groupConfigs[netId][lGrpId].
decayNE = groupConfigMap[gGrpId].neuromodulatorConfig.decayNE;
3484 groupConfigs[netId][lGrpId].
releaseDP = groupConfigMap[gGrpId].neuromodulatorConfig.releaseDP;
3485 groupConfigs[netId][lGrpId].
release5HT = groupConfigMap[gGrpId].neuromodulatorConfig.release5HT;
3486 groupConfigs[netId][lGrpId].
releaseACh = groupConfigMap[gGrpId].neuromodulatorConfig.releaseACh;
3487 groupConfigs[netId][lGrpId].
releaseNE = groupConfigMap[gGrpId].neuromodulatorConfig.releaseNE;
3488 groupConfigs[netId][lGrpId].
activeDP = groupConfigMap[gGrpId].neuromodulatorConfig.activeDP;
3489 groupConfigs[netId][lGrpId].
active5HT = groupConfigMap[gGrpId].neuromodulatorConfig.active5HT;
3490 groupConfigs[netId][lGrpId].
activeACh = groupConfigMap[gGrpId].neuromodulatorConfig.activeACh;
3491 groupConfigs[netId][lGrpId].
activeNE = groupConfigMap[gGrpId].neuromodulatorConfig.activeNE;
3493 #ifdef LN_I_CALC_TYPES 3497 KERNEL_ERROR(
"IcalcType is unknwon in group [%d] ", gGrpId);
3501 groupConfigs[netId][lGrpId].
icalcType = groupConfigMap[gGrpId].icalcType;
3504 groupConfigs[netId][lGrpId].
dAMPA = groupConfigMap[gGrpId].conductanceConfig.dAMPA;
3505 groupConfigs[netId][lGrpId].
rNMDA = groupConfigMap[gGrpId].conductanceConfig.rNMDA;
3506 groupConfigs[netId][lGrpId].
dNMDA = groupConfigMap[gGrpId].conductanceConfig.dNMDA;
3507 groupConfigs[netId][lGrpId].
sNMDA = groupConfigMap[gGrpId].conductanceConfig.sNMDA;
3508 groupConfigs[netId][lGrpId].
dGABAa = groupConfigMap[gGrpId].conductanceConfig.dGABAa;
3509 groupConfigs[netId][lGrpId].
rGABAb = groupConfigMap[gGrpId].conductanceConfig.rGABAb;
3510 groupConfigs[netId][lGrpId].
dGABAb = groupConfigMap[gGrpId].conductanceConfig.dGABAb;
3511 groupConfigs[netId][lGrpId].
sGABAb = groupConfigMap[gGrpId].conductanceConfig.sGABAb;
3513 for (
int i = 0; i <
NM_NE + 3; i++)
3514 groupConfigs[netId][lGrpId].nm4w[i] = groupConfigMap[gGrpId].nm4wConfig.w[i];
3516 groupConfigs[netId][lGrpId].
WithNM4STP = groupConfigMap[gGrpId].nm4StpConfig.WithNM4STP;
3517 for (
int i = 0; i < NM_NE + 3; i++) {
3518 groupConfigs[netId][lGrpId].
wstpu[i] = groupConfigMap[gGrpId].nm4StpConfig.w_STP_U[i];
3519 groupConfigs[netId][lGrpId].
wstptauu[i] = groupConfigMap[gGrpId].nm4StpConfig.w_STP_tau_u[i];
3520 groupConfigs[netId][lGrpId].
wstptaux[i] = groupConfigMap[gGrpId].nm4StpConfig.w_STP_tau_x[i];
3530 #ifdef LN_AXON_PLAST 3531 groupConfigs[netId][lGrpId].
WithAxonPlast = groupConfigMap[gGrpId].WithAxonPlast;
3532 groupConfigs[netId][lGrpId].
AxonPlast_TAU = groupConfigMap[gGrpId].AxonPlast_TAU;
3536 if (netId == grpIt->netId) {
3537 groupConfigMDMap[gGrpId].netId = grpIt->netId;
3538 groupConfigMDMap[gGrpId].gGrpId = grpIt->gGrpId;
3539 groupConfigMDMap[gGrpId].gStartN = grpIt->gStartN;
3540 groupConfigMDMap[gGrpId].gEndN = grpIt->gEndN;
3541 groupConfigMDMap[gGrpId].lGrpId = grpIt->lGrpId;
3542 groupConfigMDMap[gGrpId].lStartN = grpIt->lStartN;
3543 groupConfigMDMap[gGrpId].lEndN = grpIt->lEndN;
3544 groupConfigMDMap[gGrpId].numPostSynapses = grpIt->numPostSynapses;
3545 groupConfigMDMap[gGrpId].numPreSynapses = grpIt->numPreSynapses;
3546 groupConfigMDMap[gGrpId].LtoGOffset = grpIt->LtoGOffset;
3547 groupConfigMDMap[gGrpId].GtoLOffset = grpIt->GtoLOffset;
3548 groupConfigMDMap[gGrpId].fixedInputWts = grpIt->fixedInputWts;
3549 groupConfigMDMap[gGrpId].hasExternalConnect = grpIt->hasExternalConnect;
3550 groupConfigMDMap[gGrpId].Noffset = grpIt->Noffset;
3551 groupConfigMDMap[gGrpId].maxOutgoingDelay = grpIt->maxOutgoingDelay;
3553 groupConfigs[netId][lGrpId].
withParamModel_9 = groupConfigMap[gGrpId].withParamModel_9;
3554 groupConfigs[netId][lGrpId].
isLIF = groupConfigMap[gGrpId].isLIF;
3571 void SNN::generateRuntimeConnectConfigs() {
3574 for (std::list<ConnectConfig>::iterator connIt = localConnectLists[netId].begin(); connIt != localConnectLists[netId].end(); connIt++) {
3575 int lConnId = connIt->connId;
3576 connectConfigMap[lConnId] = *connIt;
3578 connectConfigs[netId][lConnId].
grpSrc = connIt->grpSrc;
3579 connectConfigs[netId][lConnId].
grpDest = connIt->grpDest;
3581 connectConfigs[netId][lConnId].
WithSTDP = connectConfigMap[lConnId].stdpConfig.WithSTDP;
3582 connectConfigs[netId][lConnId].
WithESTDP = connectConfigMap[lConnId].stdpConfig.WithESTDP;
3583 connectConfigs[netId][lConnId].
WithISTDP = connectConfigMap[lConnId].stdpConfig.WithISTDP;
3584 connectConfigs[netId][lConnId].
WithESTDPtype = connectConfigMap[lConnId].stdpConfig.WithESTDPtype;
3585 connectConfigs[netId][lConnId].
WithISTDPtype = connectConfigMap[lConnId].stdpConfig.WithISTDPtype;
3586 connectConfigs[netId][lConnId].
WithESTDPcurve = connectConfigMap[lConnId].stdpConfig.WithESTDPcurve;
3587 connectConfigs[netId][lConnId].
WithISTDPcurve = connectConfigMap[lConnId].stdpConfig.WithISTDPcurve;
3589 connectConfigs[netId][lConnId].
TAU_PLUS_INV_EXC = connectConfigMap[lConnId].stdpConfig.TAU_PLUS_INV_EXC;
3590 connectConfigs[netId][lConnId].
TAU_MINUS_INV_EXC = connectConfigMap[lConnId].stdpConfig.TAU_MINUS_INV_EXC;
3591 connectConfigs[netId][lConnId].
ALPHA_PLUS_EXC = connectConfigMap[lConnId].stdpConfig.ALPHA_PLUS_EXC;
3592 connectConfigs[netId][lConnId].
ALPHA_MINUS_EXC = connectConfigMap[lConnId].stdpConfig.ALPHA_MINUS_EXC;
3593 connectConfigs[netId][lConnId].
GAMMA = connectConfigMap[lConnId].stdpConfig.GAMMA;
3594 connectConfigs[netId][lConnId].
KAPPA = connectConfigMap[lConnId].stdpConfig.KAPPA;
3595 connectConfigs[netId][lConnId].
OMEGA = connectConfigMap[lConnId].stdpConfig.OMEGA;
3596 connectConfigs[netId][lConnId].
TAU_PLUS_INV_INB = connectConfigMap[lConnId].stdpConfig.TAU_PLUS_INV_INB;
3597 connectConfigs[netId][lConnId].
TAU_MINUS_INV_INB = connectConfigMap[lConnId].stdpConfig.TAU_MINUS_INV_INB;
3598 connectConfigs[netId][lConnId].
ALPHA_PLUS_INB = connectConfigMap[lConnId].stdpConfig.ALPHA_PLUS_INB;
3599 connectConfigs[netId][lConnId].
ALPHA_MINUS_INB = connectConfigMap[lConnId].stdpConfig.ALPHA_MINUS_INB;
3600 connectConfigs[netId][lConnId].
BETA_LTP = connectConfigMap[lConnId].stdpConfig.BETA_LTP;
3601 connectConfigs[netId][lConnId].
BETA_LTD = connectConfigMap[lConnId].stdpConfig.BETA_LTD;
3602 connectConfigs[netId][lConnId].
LAMBDA = connectConfigMap[lConnId].stdpConfig.LAMBDA;
3603 connectConfigs[netId][lConnId].
DELTA = connectConfigMap[lConnId].stdpConfig.DELTA;
3604 #ifdef LN_I_CALC_TYPES 3605 connectConfigs[netId][lConnId].
NM_PKA = connectConfigMap[lConnId].stdpConfig.NM_PKA;
3606 connectConfigs[netId][lConnId].
NM_PLC = connectConfigMap[lConnId].stdpConfig.NM_PLC;
3607 connectConfigs[netId][lConnId].
W_PKA = connectConfigMap[lConnId].stdpConfig.W_PKA;
3608 connectConfigs[netId][lConnId].
W_PLC = connectConfigMap[lConnId].stdpConfig.W_PLC;
3609 connectConfigs[netId][lConnId].
icalcType = connectConfigMap[lConnId].icalcType;
3613 for (std::list<ConnectConfig>::iterator connIt = externalConnectLists[netId].begin(); connIt != externalConnectLists[netId].end(); connIt++) {
3614 int lConnId = connIt->connId;
3615 connectConfigMap[lConnId] = *connIt;
3617 connectConfigs[netId][lConnId].
grpSrc = connIt->grpSrc;
3618 connectConfigs[netId][lConnId].
grpDest = connIt->grpDest;
3620 connectConfigs[netId][lConnId].
WithSTDP = connectConfigMap[lConnId].stdpConfig.WithSTDP;
3621 connectConfigs[netId][lConnId].
WithESTDP = connectConfigMap[lConnId].stdpConfig.WithESTDP;
3622 connectConfigs[netId][lConnId].
WithISTDP = connectConfigMap[lConnId].stdpConfig.WithISTDP;
3623 connectConfigs[netId][lConnId].
WithESTDPtype = connectConfigMap[lConnId].stdpConfig.WithESTDPtype;
3624 connectConfigs[netId][lConnId].
WithISTDPtype = connectConfigMap[lConnId].stdpConfig.WithISTDPtype;
3625 connectConfigs[netId][lConnId].
WithESTDPcurve = connectConfigMap[lConnId].stdpConfig.WithESTDPcurve;
3626 connectConfigs[netId][lConnId].
WithISTDPcurve = connectConfigMap[lConnId].stdpConfig.WithISTDPcurve;
3628 connectConfigs[netId][lConnId].
TAU_PLUS_INV_EXC = connectConfigMap[lConnId].stdpConfig.TAU_PLUS_INV_EXC;
3629 connectConfigs[netId][lConnId].
TAU_MINUS_INV_EXC = connectConfigMap[lConnId].stdpConfig.TAU_MINUS_INV_EXC;
3630 connectConfigs[netId][lConnId].
ALPHA_PLUS_EXC = connectConfigMap[lConnId].stdpConfig.ALPHA_PLUS_EXC;
3631 connectConfigs[netId][lConnId].
ALPHA_MINUS_EXC = connectConfigMap[lConnId].stdpConfig.ALPHA_MINUS_EXC;
3632 connectConfigs[netId][lConnId].
GAMMA = connectConfigMap[lConnId].stdpConfig.GAMMA;
3633 connectConfigs[netId][lConnId].
KAPPA = connectConfigMap[lConnId].stdpConfig.KAPPA;
3634 connectConfigs[netId][lConnId].
OMEGA = connectConfigMap[lConnId].stdpConfig.OMEGA;
3635 connectConfigs[netId][lConnId].
TAU_PLUS_INV_INB = connectConfigMap[lConnId].stdpConfig.TAU_PLUS_INV_INB;
3636 connectConfigs[netId][lConnId].
TAU_MINUS_INV_INB = connectConfigMap[lConnId].stdpConfig.TAU_MINUS_INV_INB;
3637 connectConfigs[netId][lConnId].
ALPHA_PLUS_INB = connectConfigMap[lConnId].stdpConfig.ALPHA_PLUS_INB;
3638 connectConfigs[netId][lConnId].
ALPHA_MINUS_INB = connectConfigMap[lConnId].stdpConfig.ALPHA_MINUS_INB;
3639 connectConfigs[netId][lConnId].
BETA_LTP = connectConfigMap[lConnId].stdpConfig.BETA_LTP;
3640 connectConfigs[netId][lConnId].
BETA_LTD = connectConfigMap[lConnId].stdpConfig.BETA_LTD;
3641 connectConfigs[netId][lConnId].
LAMBDA = connectConfigMap[lConnId].stdpConfig.LAMBDA;
3642 connectConfigs[netId][lConnId].
DELTA = connectConfigMap[lConnId].stdpConfig.DELTA;
3643 #ifdef LN_I_CALC_TYPES 3644 connectConfigs[netId][lConnId].
NM_PKA = connectConfigMap[lConnId].stdpConfig.NM_PKA;
3645 connectConfigs[netId][lConnId].
NM_PLC = connectConfigMap[lConnId].stdpConfig.NM_PLC;
3646 connectConfigs[netId][lConnId].
W_PKA = connectConfigMap[lConnId].stdpConfig.W_PKA;
3647 connectConfigs[netId][lConnId].
W_PLC = connectConfigMap[lConnId].stdpConfig.W_PLC;
3648 connectConfigs[netId][lConnId].
icalcType = connectConfigMap[lConnId].icalcType;
3654 void SNN::generateRuntimeNetworkConfigs() {
3656 if (!groupPartitionLists[netId].empty()) {
3663 #define LN_I_CALC_TYPES__REQUIRED_FOR_NETWORK_LEVEL 3672 for (std::list<GroupConfigMD>::iterator grpIt = groupPartitionLists[netId].begin(); grpIt != groupPartitionLists[netId].end(); grpIt++) {
3673 if (grpIt->netId == netId && grpIt->neuronMonitorId >= 0)
3682 #define LN_I_CALC_TYPES__REQUIRED_FOR_NETWORK_LEVEL 3685 #ifndef LN_I_CALC_TYPES 3686 networkConfigs[netId].dAMPA = dAMPA;
3687 networkConfigs[netId].rNMDA = rNMDA;
3688 networkConfigs[netId].dNMDA = dNMDA;
3689 networkConfigs[netId].sNMDA = sNMDA;
3690 networkConfigs[netId].dGABAa = dGABAa;
3691 networkConfigs[netId].rGABAb = rGABAb;
3692 networkConfigs[netId].dGABAb = dGABAb;
3693 networkConfigs[netId].sGABAb = sGABAb;
3700 findNumN(netId, networkConfigs[netId].numN, networkConfigs[netId].numNExternal, networkConfigs[netId].numNAssigned,
3701 networkConfigs[netId].numNReg, networkConfigs[netId].numNExcReg, networkConfigs[netId].numNInhReg,
3702 networkConfigs[netId].numNPois, networkConfigs[netId].numNExcPois, networkConfigs[netId].numNInhPois);
3706 for (std::list<GroupConfigMD>::iterator grpIt = groupPartitionLists[netId].begin(); grpIt != groupPartitionLists[netId].end(); grpIt++) {
3707 if (grpIt->netId == netId)
3718 findMaxNumSynapsesNeurons(netId, networkConfigs[netId].maxNumPostSynN, networkConfigs[netId].maxNumPreSynN);
3721 findMaxSpikesD1D2(netId, networkConfigs[netId].maxSpikesD1, networkConfigs[netId].maxSpikesD2);
3724 findNumSynapsesNetwork(netId, networkConfigs[netId].numPostSynNet, networkConfigs[netId].numPreSynNet);
3728 findNumNSpikeGenAndOffset(netId);
3733 memset(&managerRTDSize, 0,
sizeof(ManagerRuntimeDataSize));
3735 if (!groupPartitionLists[netId].empty()) {
3737 if (networkConfigs[netId].numNReg > managerRTDSize.maxNumNReg) managerRTDSize.maxNumNReg = networkConfigs[netId].
numNReg;
3738 if (networkConfigs[netId].numN > managerRTDSize.maxNumN) managerRTDSize.maxNumN = networkConfigs[netId].
numN;
3739 if (networkConfigs[netId].numNAssigned > managerRTDSize.maxNumNAssigned) managerRTDSize.maxNumNAssigned = networkConfigs[netId].
numNAssigned;
3742 if (networkConfigs[netId].numNSpikeGen > managerRTDSize.maxNumNSpikeGen) managerRTDSize.maxNumNSpikeGen = networkConfigs[netId].
numNSpikeGen;
3746 if (networkConfigs[netId].numNPois > managerRTDSize.maxNumNPois) managerRTDSize.maxNumNPois = networkConfigs[netId].
numNPois;
3749 if (networkConfigs[netId].numGroups > managerRTDSize.maxNumGroups) managerRTDSize.maxNumGroups = networkConfigs[netId].
numGroups;
3750 if (networkConfigs[netId].numConnections > managerRTDSize.maxNumConnections) managerRTDSize.maxNumConnections = networkConfigs[netId].
numConnections;
3753 for (std::list<GroupConfigMD>::iterator grpIt = groupPartitionLists[netId].begin(); grpIt != groupPartitionLists[netId].end(); grpIt++) {
3754 if (groupConfigMap[grpIt->gGrpId].numN > managerRTDSize.maxNumNPerGroup) managerRTDSize.maxNumNPerGroup = groupConfigMap[grpIt->gGrpId].numN;
3758 if (networkConfigs[netId].maxSpikesD1 > managerRTDSize.maxMaxSpikeD1) managerRTDSize.maxMaxSpikeD1 = networkConfigs[netId].
maxSpikesD1;
3759 if (networkConfigs[netId].maxSpikesD2 > managerRTDSize.maxMaxSpikeD2) managerRTDSize.maxMaxSpikeD2 = networkConfigs[netId].
maxSpikesD2;
3762 if (networkConfigs[netId].numPreSynNet > managerRTDSize.maxNumPreSynNet) managerRTDSize.maxNumPreSynNet = networkConfigs[netId].
numPreSynNet;
3763 if (networkConfigs[netId].numPostSynNet > managerRTDSize.maxNumPostSynNet) managerRTDSize.maxNumPostSynNet = networkConfigs[netId].
numPostSynNet;
3766 managerRTDSize.glbNumN += networkConfigs[netId].
numN;
3767 managerRTDSize.glbNumNReg += networkConfigs[netId].
numNReg;
3784 void SNN::generateConnectionRuntime(
int netId) {
3785 std::map<int, int> GLoffset;
3786 std::map<int, int> GLgrpId;
3789 for (std::list<GroupConfigMD>::iterator grpIt = groupPartitionLists[netId].begin(); grpIt != groupPartitionLists[netId].end(); grpIt++) {
3790 GLoffset[grpIt->gGrpId] = grpIt->GtoLOffset;
3791 GLgrpId[grpIt->gGrpId] = grpIt->lGrpId;
3796 for (std::map<int, ConnectConfig>::iterator connIt = connectConfigMap.begin(); connIt != connectConfigMap.end(); connIt++) {
3798 mulSynFast[connIt->second.connId] = connIt->second.mulSynFast;
3799 mulSynSlow[connIt->second.connId] = connIt->second.mulSynSlow;
3805 int parsedConnections = 0;
3806 memset(managerRuntimeData.
Npost, 0,
sizeof(
short) * networkConfigs[netId].
numNAssigned);
3807 memset(managerRuntimeData.
Npre, 0,
sizeof(
short) * networkConfigs[netId].
numNAssigned);
3809 #ifdef LN_FIX_CONNLIST_ 3810 for (std::vector<ConnectionInfo>::iterator connIt = connectionLists[netId].begin(); connIt != connectionLists[netId].end(); connIt++) {
3812 for (std::list<ConnectionInfo>::iterator connIt = connectionLists[netId].begin(); connIt != connectionLists[netId].end(); connIt++) {
3814 connIt->srcGLoffset = GLoffset[connIt->grpSrc];
3816 KERNEL_ERROR(
"Error: the number of synapses exceeds maximum limit (%d) for neuron %d (group %d)",
SYNAPSE_ID_MASK, connIt->nSrc, connIt->grpSrc);
3819 if (managerRuntimeData.
Npre[connIt->nDest + GLoffset[connIt->grpDest]] ==
SYNAPSE_ID_MASK) {
3820 KERNEL_ERROR(
"Error: the number of synapses exceeds maximum limit (%d) for neuron %d (group %d)",
SYNAPSE_ID_MASK, connIt->nDest, connIt->grpDest);
3823 managerRuntimeData.
Npost[connIt->nSrc + GLoffset[connIt->grpSrc]]++;
3824 managerRuntimeData.
Npre[connIt->nDest + GLoffset[connIt->grpDest]]++;
3827 sim_with_fixedwts =
false;
3828 managerRuntimeData.
Npre_plastic[connIt->nDest + GLoffset[connIt->grpDest]]++;
3831 if (groupConfigMap[connIt->grpDest].homeoConfig.WithHomeostasis && groupConfigMDMap[connIt->grpDest].homeoId == -1)
3832 groupConfigMDMap[connIt->grpDest].homeoId = connIt->nDest + GLoffset[connIt->grpDest];
3851 parsedConnections++;
3853 assert(parsedConnections == networkConfigs[netId].numPostSynNet && parsedConnections == networkConfigs[netId].numPreSynNet);
3858 for (
int lNId = 1; lNId < networkConfigs[netId].
numNAssigned; lNId++) {
3864 memset(managerRuntimeData.
Npre, 0,
sizeof(
short) * networkConfigs[netId].
numNAssigned);
3865 parsedConnections = 0;
3866 #ifdef LN_FIX_CONNLIST_ 3867 for (std::vector<ConnectionInfo>::iterator connIt = connectionLists[netId].begin(); connIt != connectionLists[netId].end(); connIt++) {
3869 for (std::list<ConnectionInfo>::iterator connIt = connectionLists[netId].begin(); connIt != connectionLists[netId].end(); connIt++) {
3872 int pre_pos = managerRuntimeData.
cumulativePre[connIt->nDest + GLoffset[connIt->grpDest]] + managerRuntimeData.
Npre[connIt->nDest + GLoffset[connIt->grpDest]];
3873 assert(pre_pos < networkConfigs[netId].numPreSynNet);
3875 managerRuntimeData.
preSynapticIds[pre_pos] = SET_CONN_ID((connIt->nSrc + GLoffset[connIt->grpSrc]), 0, (GLgrpId[connIt->grpSrc]));
3876 connIt->preSynId = managerRuntimeData.
Npre[connIt->nDest + GLoffset[connIt->grpDest]];
3878 managerRuntimeData.
Npre[connIt->nDest+ GLoffset[connIt->grpDest]]++;
3879 parsedConnections++;
3887 #ifdef LN_FIX_CONNLIST_ 3888 for (std::vector<ConnectionInfo>::iterator connIt = connectionLists[netId].begin(); connIt != connectionLists[netId].end(); connIt++) {
3890 for (std::list<ConnectionInfo>::iterator connIt = connectionLists[netId].begin(); connIt != connectionLists[netId].end(); connIt++) {
3893 int pre_pos = managerRuntimeData.
cumulativePre[connIt->nDest + GLoffset[connIt->grpDest]] + managerRuntimeData.
Npre[connIt->nDest + GLoffset[connIt->grpDest]];
3894 assert(pre_pos < networkConfigs[netId].numPreSynNet);
3896 managerRuntimeData.
preSynapticIds[pre_pos] = SET_CONN_ID((connIt->nSrc + GLoffset[connIt->grpSrc]), 0, (GLgrpId[connIt->grpSrc]));
3897 connIt->preSynId = managerRuntimeData.
Npre[connIt->nDest + GLoffset[connIt->grpDest]];
3899 managerRuntimeData.
Npre[connIt->nDest + GLoffset[connIt->grpDest]]++;
3900 parsedConnections++;
3907 assert(parsedConnections == networkConfigs[netId].numPreSynNet);
3911 #ifdef LN_FIX_CONNLIST_ 3917 for (
int lNId = 0; lNId < networkConfigs[netId].
numNAssigned; lNId++) {
3918 if (managerRuntimeData.
Npost[lNId] > 0) {
3919 std::list<ConnectionInfo> postConnectionList;
3921 targetConn.
nSrc = lNId ;
3923 #ifdef LN_FIX_CONNLIST_ 3924 std::list<ConnectionInfo>::iterator firstPostConn;
3927 std::list<ConnectionInfo>::iterator firstPostConn = std::find(connectionLists[netId].begin(), connectionLists[netId].end(), targetConn);
3929 std::list<ConnectionInfo>::iterator lastPostConn = firstPostConn;
3930 std::advance(lastPostConn, managerRuntimeData.
Npost[lNId]);
3931 managerRuntimeData.
Npost[lNId] = 0;
3933 #ifdef LN_FIX_CONNLIST_ 3937 postConnectionList.splice(postConnectionList.begin(), connectionLists[netId], firstPostConn, lastPostConn);
3942 #ifdef DEBUG__generateConnectionRuntime__pre_pos 3943 printf(
"pre_pos = cumulativePre[connIt->nDest] + connIt->preSynId\n");
3945 #ifdef DEBUG__generateConnectionRuntime__preSynapticIds 3946 printf(
"preSynapticIds[pre_pos] = SET_CONN_ID((nSrc + GLoffset[grpSrc]), Npost[nSrc + GLoffset[grpSrc]], (GLgrpId[grpSrc]))\n");
3949 int post_pos, pre_pos, lastDelay = 0;
3950 parsedConnections = 0;
3952 for (std::list<ConnectionInfo>::iterator connIt = postConnectionList.begin(); connIt != postConnectionList.end(); connIt++) {
3953 assert(connIt->nSrc + GLoffset[connIt->grpSrc] == lNId);
3954 post_pos = managerRuntimeData.
cumulativePost[connIt->nSrc + GLoffset[connIt->grpSrc]] + managerRuntimeData.
Npost[connIt->nSrc + GLoffset[connIt->grpSrc]];
3955 pre_pos = managerRuntimeData.
cumulativePre[connIt->nDest + GLoffset[connIt->grpDest]] + connIt->preSynId;
3956 #ifdef DEBUG__generateConnectionRuntime__pre_pos 3957 printf(
"pre_pos = %3d[ %3d] + %3d\n", managerRuntimeData.
cumulativePre[connIt->nDest + GLoffset[connIt->grpDest]], connIt->nDest, connIt->preSynId);
3959 assert(post_pos < networkConfigs[netId].numPostSynNet);
3963 managerRuntimeData.
postSynapticIds[post_pos] = SET_CONN_ID((connIt->nDest + GLoffset[connIt->grpDest]), connIt->preSynId, (GLgrpId[connIt->grpDest]));
3965 assert(connIt->delay > 0);
3966 if (connIt->delay > lastDelay) {
3969 }
else if (connIt->delay == lastDelay) {
3972 KERNEL_ERROR(
"Post-synaptic delays not sorted correctly... pre_id=%d, delay[%d]=%d, delay[%d]=%d",
3973 lNId, managerRuntimeData.
Npost[connIt->nSrc + GLoffset[connIt->grpSrc]], connIt->delay, managerRuntimeData.
Npost[connIt->nSrc + GLoffset[connIt->grpSrc]] - 1, lastDelay);
3975 lastDelay = connIt->delay;
3981 managerRuntimeData.
preSynapticIds[pre_pos] = SET_CONN_ID((connIt->nSrc + GLoffset[connIt->grpSrc]), managerRuntimeData.
Npost[connIt->nSrc + GLoffset[connIt->grpSrc]], (GLgrpId[connIt->grpSrc]));
3982 #ifdef DEBUG__generateConnectionRuntime__preSynapticIds 3983 printf(
"preSynapticIds[ %3d] = SET_CONN_ID(( %3d + %3d[ %3d]), %3d[ %3d + %3d[ %3d]], ( %3d[ %3d]));\n",
3985 connIt->nSrc, GLoffset[connIt->grpSrc], connIt->grpSrc,
3986 managerRuntimeData.
Npost[connIt->nSrc + GLoffset[connIt->grpSrc]], connIt->nSrc, GLoffset[connIt->grpSrc], connIt->grpSrc,
3987 GLgrpId[connIt->grpSrc], connIt->grpSrc );
3990 managerRuntimeData.
wt[pre_pos] = connIt->initWt;
3991 managerRuntimeData.
maxSynWt[pre_pos] = connIt->maxWt;
3994 managerRuntimeData.
Npost[connIt->nSrc + GLoffset[connIt->grpSrc]]++;
3995 parsedConnections++;
4001 assert(parsedConnections == managerRuntimeData.
Npost[lNId]);
4016 assert(connectionLists[netId].empty());
4062 void SNN::generateCompConnectionRuntime(
int netId)
4064 std::map<int, int> GLgrpId;
4066 for (std::list<GroupConfigMD>::iterator grpIt = groupPartitionLists[netId].begin(); grpIt != groupPartitionLists[netId].end(); grpIt++) {
4067 GLgrpId[grpIt->gGrpId] = grpIt->lGrpId;
4073 for (std::list<compConnectConfig>::iterator connIt = localCompConnectLists[netId].begin(); connIt != localCompConnectLists[netId].end(); connIt++) {
4075 int grpLower = connIt->grpSrc;
4076 int grpUpper = connIt->grpDest;
4080 KERNEL_ERROR(
"Group %s(%d) exceeds max number of allowed compartmental connections (%d).",
4084 groupConfigs[netId][GLgrpId[grpLower]].
compNeighbors[i] = grpUpper;
4090 KERNEL_ERROR(
"Group %s(%d) exceeds max number of allowed compartmental connections (%d).",
4094 groupConfigs[netId][GLgrpId[grpUpper]].
compNeighbors[j] = grpLower;
4103 void SNN::generatePoissonGroupRuntime(
int netId,
int lGrpId) {
4104 resetNeuromodulator(netId, lGrpId);
4106 for(
int lNId = groupConfigs[netId][lGrpId].lStartN; lNId <= groupConfigs[netId][lGrpId].
lEndN; lNId++)
4107 resetPoissonNeuron(netId, lGrpId, lNId);
4111 void SNN::collectGlobalNetworkConfigC() {
4113 for (std::map<int, ConnectConfig>::iterator connIt = connectConfigMap.begin(); connIt != connectConfigMap.end(); connIt++) {
4114 if (connIt->second.maxDelay > glbNetworkConfig.
maxDelay)
4115 glbNetworkConfig.
maxDelay = connIt->second.maxDelay;
4117 assert(connectConfigMap.size() > 0 || glbNetworkConfig.
maxDelay != -1);
4120 for(
int gGrpId = 0; gGrpId < numGroups; gGrpId++) {
4122 glbNetworkConfig.
numNExcPois += groupConfigMap[gGrpId].numN;
4124 glbNetworkConfig.
numNInhPois += groupConfigMap[gGrpId].numN;
4126 glbNetworkConfig.
numNExcReg += groupConfigMap[gGrpId].numN;
4128 glbNetworkConfig.
numNInhReg += groupConfigMap[gGrpId].numN;
4131 if (groupConfigMDMap[gGrpId].maxOutgoingDelay == 1)
4132 glbNetworkConfig.
numN1msDelay += groupConfigMap[gGrpId].numN;
4133 else if (groupConfigMDMap[gGrpId].maxOutgoingDelay >= 2)
4134 glbNetworkConfig.
numN2msDelay += groupConfigMap[gGrpId].numN;
4143 void SNN::collectGlobalNetworkConfigP() {
4146 if (!localConnectLists[netId].empty() || !externalConnectLists[netId].empty()) {
4147 for (std::list<ConnectConfig>::iterator connIt = localConnectLists[netId].begin(); connIt != localConnectLists[netId].end(); connIt++)
4148 glbNetworkConfig.
numSynNet += connIt->numberOfConnections;
4150 for (std::list<ConnectConfig>::iterator connIt = externalConnectLists[netId].begin(); connIt != externalConnectLists[netId].end(); connIt++)
4151 glbNetworkConfig.
numSynNet += connIt->numberOfConnections;
4158 void SNN::compileSNN() {
4159 KERNEL_DEBUG(
"Beginning compilation of the network....");
4165 compileGroupConfig();
4167 compileConnectConfig();
4171 collectGlobalNetworkConfigC();
4181 KERNEL_INFO(
"************************** Global Network Configuration *******************************");
4182 KERNEL_INFO(
"The number of neurons in the network (numN) = %d", glbNetworkConfig.
numN);
4183 KERNEL_INFO(
"The number of regular neurons in the network (numNReg:numNExcReg:numNInhReg) = %d:%d:%d", glbNetworkConfig.
numNReg, glbNetworkConfig.
numNExcReg, glbNetworkConfig.
numNInhReg);
4185 KERNEL_INFO(
"The maximum axonal delay in the network (maxDelay) = %d", glbNetworkConfig.
maxDelay);
4191 void SNN::compileConnectConfig() {
4195 for (std::map<int, ConnectConfig>::iterator connIt = connectConfigMap.begin(); connIt != connectConfigMap.end(); connIt++) {
4197 if (connIt->second.stdpConfig.WithSTDP) {
4207 void SNN::compileGroupConfig() {
4212 for (std::map<int, ConnectConfig>::iterator connIt = connectConfigMap.begin(); connIt != connectConfigMap.end(); connIt++) {
4216 grpSrc = connIt->second.grpSrc;
4217 if (connIt->second.maxDelay > groupConfigMDMap[grpSrc].maxOutgoingDelay)
4218 groupConfigMDMap[grpSrc].maxOutgoingDelay = connIt->second.maxDelay;
4223 groupConfigMDMap[connIt->second.grpDest].fixedInputWts =
false;
4231 int assignedGroup = 0;
4232 int availableNeuronId = 0;
4233 for(
int order = 0; order < 4; order++) {
4234 for(
int gGrpId = 0; gGrpId < numGroups; gGrpId++) {
4236 availableNeuronId = assignGroup(gGrpId, availableNeuronId);
4238 }
else if (
IS_INHIBITORY_TYPE(groupConfigMap[gGrpId].type) && (groupConfigMap[gGrpId].type & POISSON_NEURON) && order == 2) {
4239 availableNeuronId = assignGroup(gGrpId, availableNeuronId);
4241 }
else if (
IS_EXCITATORY_TYPE(groupConfigMap[gGrpId].type) && !(groupConfigMap[gGrpId].type & POISSON_NEURON) && order == 0) {
4242 availableNeuronId = assignGroup(gGrpId, availableNeuronId);
4244 }
else if (
IS_INHIBITORY_TYPE(groupConfigMap[gGrpId].type) && !(groupConfigMap[gGrpId].type & POISSON_NEURON) && order == 1) {
4245 availableNeuronId = assignGroup(gGrpId, availableNeuronId);
4251 assert(assignedGroup == numGroups);
4253 #ifdef LN_I_CALC_TYPES 4255 auto networkDefault = sim_with_conductances ?
COBA :
CUBA;
4256 for (
int gGrpId = 0; gGrpId < numGroups; gGrpId++) {
4258 groupConfigMap[gGrpId].icalcType = networkDefault;
4259 groupConfigMap[gGrpId].with_NMDA_rise = sim_with_NMDA_rise;
4260 groupConfigMap[gGrpId].with_GABAb_rise = sim_with_GABAb_rise;
4261 #define LN_I_CALC_TYPES__REQUIRED_FOR_BACKWARD_COMP 4262 auto& config = groupConfigMap[gGrpId].conductanceConfig;
4263 config.dAMPA = dAMPA;
4264 config.dGABAa = dGABAa;
4265 config.dGABAb = dGABAb;
4266 config.dNMDA = dNMDA;
4267 config.rGABAb = rGABAb;
4268 config.rNMDA = rNMDA;
4269 config.sGABAb = sGABAb;
4270 config.sNMDA = sNMDA;
4277 void SNN::connectNetwork() {
4280 for (std::list<ConnectConfig>::iterator connIt = localConnectLists[netId].begin(); connIt != localConnectLists[netId].end(); connIt++) {
4281 switch(connIt->type) {
4283 connectRandom(netId, connIt,
false);
4286 connectFull(netId, connIt,
false);
4289 connectFull(netId, connIt,
false);
4292 connectOneToOne(netId, connIt,
false);
4295 connectGaussian(netId, connIt,
false);
4298 connectUserDefined(netId, connIt,
false);
4301 KERNEL_ERROR(
"Invalid connection type( should be 'random', 'full', 'full-no-direct', or 'one-to-one')");
4309 for (std::list<ConnectConfig>::iterator connIt = externalConnectLists[netId].begin(); connIt != externalConnectLists[netId].end(); connIt++) {
4310 switch(connIt->type) {
4312 connectRandom(netId, connIt,
true);
4315 connectFull(netId, connIt,
true);
4318 connectFull(netId, connIt,
true);
4321 connectOneToOne(netId, connIt,
true);
4324 connectGaussian(netId, connIt,
true);
4327 connectUserDefined(netId, connIt,
true);
4330 KERNEL_ERROR(
"Invalid connection type( should be 'random', 'full', 'full-no-direct', or 'one-to-one')");
4426 #ifdef LN_SETUP_NETWORK_MT 4429 void SNN::connectNetworkMT() {
4433 for (std::list<ConnectConfig>::iterator connIt = localConnectLists[netId].begin(); connIt != localConnectLists[netId].end(); connIt++) {
4434 switch (connIt->type) {
4436 connectRandomMT(netId, connIt,
false);
4439 connectFull(netId, connIt,
false);
4442 connectFull(netId, connIt,
false);
4445 connectOneToOne(netId, connIt,
false);
4448 connectGaussian(netId, connIt,
false);
4451 connectUserDefined(netId, connIt,
false);
4454 KERNEL_ERROR(
"Invalid connection type( should be 'random', 'full', 'full-no-direct', or 'one-to-one')");
4462 for (std::list<ConnectConfig>::iterator connIt = externalConnectLists[netId].begin(); connIt != externalConnectLists[netId].end(); connIt++) {
4463 switch (connIt->type) {
4465 connectRandomMT(netId, connIt,
true);
4468 connectFull(netId, connIt,
true);
4471 connectFull(netId, connIt,
true);
4474 connectOneToOne(netId, connIt,
true);
4477 connectGaussian(netId, connIt,
true);
4480 connectUserDefined(netId, connIt,
true);
4483 KERNEL_ERROR(
"Invalid connection type( should be 'random', 'full', 'full-no-direct', or 'one-to-one')");
4493 inline void SNN::connectNeurons(
int netId,
int _grpSrc,
int _grpDest,
int _nSrc,
int _nDest,
short int _connId,
int externalNetId) {
4496 connInfo.
grpSrc = _grpSrc;
4498 connInfo.
nSrc = _nSrc;
4499 connInfo.
nDest = _nDest;
4501 connInfo.
connId = _connId;
4504 connInfo.
maxWt = 0.0f;
4508 connInfo.
delay = connectConfigMap[_connId].minDelay + rand() % (connectConfigMap[_connId].maxDelay - connectConfigMap[_connId].minDelay + 1);
4509 assert((connInfo.
delay >= connectConfigMap[_connId].minDelay) && (connInfo.
delay <= connectConfigMap[_connId].maxDelay));
4512 float initWt = connectConfigMap[_connId].initWt;
4513 float maxWt = connectConfigMap[_connId].maxWt;
4519 connectionLists[netId].push_back(connInfo);
4522 if (externalNetId >= 0)
4523 connectionLists[externalNetId].push_back(connInfo);
4526 #ifdef LN_SETUP_NETWORK_MT 4527 inline void SNN::connectNeuronsMT(std::mutex &mtx,
int netId,
int _grpSrc,
int _grpDest,
int _nSrc,
int _nDest,
short int _connId,
int externalNetId) {
4531 connInfo.
grpSrc = _grpSrc;
4533 connInfo.
nSrc = _nSrc;
4534 connInfo.
nDest = _nDest;
4536 connInfo.
connId = _connId;
4539 connInfo.
maxWt = 0.0f;
4543 connInfo.
delay = connectConfigMap[_connId].minDelay + rand() % (connectConfigMap[_connId].maxDelay - connectConfigMap[_connId].minDelay + 1);
4544 assert((connInfo.
delay >= connectConfigMap[_connId].minDelay) && (connInfo.
delay <= connectConfigMap[_connId].maxDelay));
4547 float initWt = connectConfigMap[_connId].initWt;
4548 float maxWt = connectConfigMap[_connId].maxWt;
4567 connectionLists[netId].push_back(connInfo);
4570 if (externalNetId >= 0)
4571 connectionLists[externalNetId].push_back(connInfo);
4577 inline void SNN::connectNeurons(
int netId,
int _grpSrc,
int _grpDest,
int _nSrc,
int _nDest,
short int _connId,
float initWt,
float maxWt, uint8_t delay,
int externalNetId) {
4580 connInfo.
grpSrc = _grpSrc;
4582 connInfo.
nSrc = _nSrc;
4583 connInfo.
nDest = _nDest;
4585 connInfo.
connId = _connId;
4590 connInfo.
delay = delay;
4592 connectionLists[netId].push_back(connInfo);
4595 if (externalNetId >= 0)
4596 connectionLists[externalNetId].push_back(connInfo);
4600 void SNN::connectFull(
int netId, std::list<ConnectConfig>::iterator connIt,
bool isExternal) {
4601 int grpSrc = connIt->grpSrc;
4602 int grpDest = connIt->grpDest;
4604 int externalNetId = -1;
4607 externalNetId = groupConfigMDMap[grpDest].netId;
4608 assert(netId != externalNetId);
4611 int gPreStart = groupConfigMDMap[grpSrc].gStartN;
4612 for(
int gPreN = groupConfigMDMap[grpSrc].gStartN; gPreN <= groupConfigMDMap[grpSrc].gEndN; gPreN++) {
4614 int gPostStart = groupConfigMDMap[grpDest].gStartN;
4615 for(
int gPostN = groupConfigMDMap[grpDest].gStartN; gPostN <= groupConfigMDMap[grpDest].gEndN; gPostN++) {
4617 if(noDirect && gPreN == gPostN)
4625 connectNeurons(netId, grpSrc, grpDest, gPreN, gPostN, connIt->connId, externalNetId);
4626 connIt->numberOfConnections++;
4630 std::list<GroupConfigMD>::iterator grpIt;
4634 targetGrp.
gGrpId = grpSrc;
4635 grpIt = std::find(groupPartitionLists[netId].begin(), groupPartitionLists[netId].end(), targetGrp);
4636 assert(grpIt != groupPartitionLists[netId].end());
4637 grpIt->numPostSynapses += connIt->numberOfConnections;
4639 targetGrp.
gGrpId = grpDest;
4640 grpIt = std::find(groupPartitionLists[netId].begin(), groupPartitionLists[netId].end(), targetGrp);
4641 assert(grpIt != groupPartitionLists[netId].end());
4642 grpIt->numPreSynapses += connIt->numberOfConnections;
4646 targetGrp.
gGrpId = grpSrc;
4647 grpIt = std::find(groupPartitionLists[externalNetId].begin(), groupPartitionLists[externalNetId].end(), targetGrp);
4648 assert(grpIt != groupPartitionLists[externalNetId].end());
4649 grpIt->numPostSynapses += connIt->numberOfConnections;
4651 targetGrp.
gGrpId = grpDest;
4652 grpIt = std::find(groupPartitionLists[externalNetId].begin(), groupPartitionLists[externalNetId].end(), targetGrp);
4653 assert(grpIt != groupPartitionLists[externalNetId].end());
4654 grpIt->numPreSynapses += connIt->numberOfConnections;
4658 void SNN::connectGaussian(
int netId, std::list<ConnectConfig>::iterator connIt,
bool isExternal) {
4660 int grpSrc = connIt->grpSrc;
4661 int grpDest = connIt->grpDest;
4665 int externalNetId = -1;
4668 externalNetId = groupConfigMDMap[grpDest].netId;
4669 assert(netId != externalNetId);
4672 for(
int i = groupConfigMDMap[grpSrc].gStartN; i <= groupConfigMDMap[grpSrc].gEndN; i++) {
4675 for(
int j = groupConfigMDMap[grpDest].gStartN; j <= groupConfigMDMap[grpDest].gEndN; j++) {
4680 double rfDist =
getRFDist3D(connIt->connRadius,loc_i,loc_j);
4681 if (rfDist < 0.0 || rfDist > 1.0)
4689 double gauss = exp(-2.3026*rfDist);
4693 if (drand48() < connIt->connProbability) {
4694 float initWt = gauss * connIt->initWt;
4695 float maxWt = connIt->maxWt;
4696 uint8_t delay = connIt->minDelay + rand() % (connIt->maxDelay - connIt->minDelay + 1);
4697 assert((delay >= connIt->minDelay) && (delay <= connIt->maxDelay));
4699 connectNeurons(netId, grpSrc, grpDest, i, j, connIt->connId, initWt, maxWt, delay, externalNetId);
4700 connIt->numberOfConnections++;
4705 std::list<GroupConfigMD>::iterator grpIt;
4709 targetGrp.
gGrpId = grpSrc;
4710 grpIt = std::find(groupPartitionLists[netId].begin(), groupPartitionLists[netId].end(), targetGrp);
4711 assert(grpIt != groupPartitionLists[netId].end());
4712 grpIt->numPostSynapses += connIt->numberOfConnections;
4714 targetGrp.
gGrpId = grpDest;
4715 grpIt = std::find(groupPartitionLists[netId].begin(), groupPartitionLists[netId].end(), targetGrp);
4716 assert(grpIt != groupPartitionLists[netId].end());
4717 grpIt->numPreSynapses += connIt->numberOfConnections;
4721 targetGrp.
gGrpId = grpSrc;
4722 grpIt = std::find(groupPartitionLists[externalNetId].begin(), groupPartitionLists[externalNetId].end(), targetGrp);
4723 assert(grpIt != groupPartitionLists[externalNetId].end());
4724 grpIt->numPostSynapses += connIt->numberOfConnections;
4726 targetGrp.
gGrpId = grpDest;
4727 grpIt = std::find(groupPartitionLists[externalNetId].begin(), groupPartitionLists[externalNetId].end(), targetGrp);
4728 assert(grpIt != groupPartitionLists[externalNetId].end());
4729 grpIt->numPreSynapses += connIt->numberOfConnections;
4733 void SNN::connectOneToOne(
int netId, std::list<ConnectConfig>::iterator connIt,
bool isExternal) {
4734 int grpSrc = connIt->grpSrc;
4735 int grpDest = connIt->grpDest;
4736 int externalNetId = -1;
4739 externalNetId = groupConfigMDMap[grpDest].netId;
4740 assert(netId != externalNetId);
4743 assert( groupConfigMap[grpDest].numN == groupConfigMap[grpSrc].numN);
4746 for(
int gPreN = groupConfigMDMap[grpSrc].gStartN, gPostN = groupConfigMDMap[grpDest].gStartN; gPreN <= groupConfigMDMap[grpSrc].gEndN; gPreN++, gPostN++) {
4747 connectNeurons(netId, grpSrc, grpDest, gPreN, gPostN, connIt->connId, externalNetId);
4748 connIt->numberOfConnections++;
4751 std::list<GroupConfigMD>::iterator grpIt;
4755 targetGrp.
gGrpId = grpSrc;
4756 grpIt = std::find(groupPartitionLists[netId].begin(), groupPartitionLists[netId].end(), targetGrp);
4757 assert(grpIt != groupPartitionLists[netId].end());
4758 grpIt->numPostSynapses += connIt->numberOfConnections;
4760 targetGrp.
gGrpId = grpDest;
4761 grpIt = std::find(groupPartitionLists[netId].begin(), groupPartitionLists[netId].end(), targetGrp);
4762 assert(grpIt != groupPartitionLists[netId].end());
4763 grpIt->numPreSynapses += connIt->numberOfConnections;
4767 targetGrp.
gGrpId = grpSrc;
4768 grpIt = std::find(groupPartitionLists[externalNetId].begin(), groupPartitionLists[externalNetId].end(), targetGrp);
4769 assert(grpIt != groupPartitionLists[externalNetId].end());
4770 grpIt->numPostSynapses += connIt->numberOfConnections;
4772 targetGrp.
gGrpId = grpDest;
4773 grpIt = std::find(groupPartitionLists[externalNetId].begin(), groupPartitionLists[externalNetId].end(), targetGrp);
4774 assert(grpIt != groupPartitionLists[externalNetId].end());
4775 grpIt->numPreSynapses += connIt->numberOfConnections;
4780 void SNN::connectRandom(
int netId, std::list<ConnectConfig>::iterator connIt,
bool isExternal) {
4781 int grpSrc = connIt->grpSrc;
4782 int grpDest = connIt->grpDest;
4783 int externalNetId = -1;
4786 externalNetId = groupConfigMDMap[grpDest].netId;
4787 assert(netId != externalNetId);
4790 int gPreStart = groupConfigMDMap[grpSrc].gStartN;
4791 for(
int gPreN = groupConfigMDMap[grpSrc].gStartN; gPreN <= groupConfigMDMap[grpSrc].gEndN; gPreN++) {
4793 int gPostStart = groupConfigMDMap[grpDest].gStartN;
4794 for(
int gPostN = groupConfigMDMap[grpDest].gStartN; gPostN <= groupConfigMDMap[grpDest].gEndN; gPostN++) {
4800 if (drand48() < connIt->connProbability) {
4801 connectNeurons(netId, grpSrc, grpDest, gPreN, gPostN, connIt->connId, externalNetId);
4802 connIt->numberOfConnections++;
4807 std::list<GroupConfigMD>::iterator grpIt;
4811 targetGrp.
gGrpId = grpSrc;
4812 grpIt = std::find(groupPartitionLists[netId].begin(), groupPartitionLists[netId].end(), targetGrp);
4813 assert(grpIt != groupPartitionLists[netId].end());
4814 grpIt->numPostSynapses += connIt->numberOfConnections;
4816 targetGrp.
gGrpId = grpDest;
4817 grpIt = std::find(groupPartitionLists[netId].begin(), groupPartitionLists[netId].end(), targetGrp);
4818 assert(grpIt != groupPartitionLists[netId].end());
4819 grpIt->numPreSynapses += connIt->numberOfConnections;
4823 targetGrp.
gGrpId = grpSrc;
4824 grpIt = std::find(groupPartitionLists[externalNetId].begin(), groupPartitionLists[externalNetId].end(), targetGrp);
4825 assert(grpIt != groupPartitionLists[externalNetId].end());
4826 grpIt->numPostSynapses += connIt->numberOfConnections;
4828 targetGrp.
gGrpId = grpDest;
4829 grpIt = std::find(groupPartitionLists[externalNetId].begin(), groupPartitionLists[externalNetId].end(), targetGrp);
4830 assert(grpIt != groupPartitionLists[externalNetId].end());
4831 grpIt->numPreSynapses += connIt->numberOfConnections;
4835 #ifdef LN_SETUP_NETWORK_MT 4845 void SNN::connectRandomMT(
int netId, std::list<ConnectConfig>::iterator connIt,
bool isExternal) {
4846 int grpSrc = connIt->grpSrc;
4847 int grpDest = connIt->grpDest;
4848 int externalNetId = -1;
4851 externalNetId = groupConfigMDMap[grpDest].netId;
4852 assert(netId != externalNetId);
4855 int gPreStart = groupConfigMDMap[grpSrc].gStartN;
4857 #ifdef DEBUG_connectRandomMT_SEQ 4860 for (
int gPreN = groupConfigMDMap[grpSrc].gStartN; gPreN <= groupConfigMDMap[grpSrc].gEndN; gPreN++) {
4862 int gPostStart = groupConfigMDMap[grpDest].gStartN;
4864 for (
int gPostN = groupConfigMDMap[grpDest].gStartN; gPostN <= groupConfigMDMap[grpDest].gEndN; gPostN++) {
4870 if (drand48() < connIt->connProbability) {
4871 connectNeurons(netId, grpSrc, grpDest, gPreN, gPostN, connIt->connId, externalNetId);
4872 connIt->numberOfConnections++;
4881 std::atomic_int numberOfConnections = connIt->numberOfConnections;
4884 auto worker = [&, netId, externalNetId, grpSrc, grpDest, gPreStart]
4885 (
int gPreN,
RadiusRF &connRadius,
float connProbability,
int connId) {
4888 int gPostStart = groupConfigMDMap[grpDest].gStartN;
4889 for (
int gPostN = groupConfigMDMap[grpDest].gStartN; gPostN <= groupConfigMDMap[grpDest].gEndN; gPostN++) {
4900 double r = gPostN % 10;
4901 if (r < connProbability) {
4903 connectNeuronsMT(mtx, netId, grpSrc, grpDest, gPreN, gPostN, connId, externalNetId);
4904 numberOfConnections++;
4911 std::vector<std::thread> pool;
4913 for (
int gPreN = groupConfigMDMap[grpSrc].gStartN; gPreN <= groupConfigMDMap[grpSrc].gEndN; gPreN++)
4914 pool.push_back(move(std::thread(worker, gPreN,
4916 connIt->connProbability,
4919 for (
int i = 0; i < pool.size(); i++)
4922 connIt->numberOfConnections = numberOfConnections;
4926 printf(
"connectRandomMT connIt->connId: %d, ->numberOfConnections: %-10d\n", connIt->connId, connIt->numberOfConnections);
4928 std::list<GroupConfigMD>::iterator grpIt;
4932 targetGrp.
gGrpId = grpSrc;
4933 grpIt = std::find(groupPartitionLists[netId].begin(), groupPartitionLists[netId].end(), targetGrp);
4934 assert(grpIt != groupPartitionLists[netId].end());
4935 grpIt->numPostSynapses += connIt->numberOfConnections;
4937 targetGrp.
gGrpId = grpDest;
4938 grpIt = std::find(groupPartitionLists[netId].begin(), groupPartitionLists[netId].end(), targetGrp);
4939 assert(grpIt != groupPartitionLists[netId].end());
4940 grpIt->numPreSynapses += connIt->numberOfConnections;
4945 targetGrp.
gGrpId = grpSrc;
4946 grpIt = std::find(groupPartitionLists[externalNetId].begin(), groupPartitionLists[externalNetId].end(), targetGrp);
4947 assert(grpIt != groupPartitionLists[externalNetId].end());
4948 grpIt->numPostSynapses += connIt->numberOfConnections;
4950 targetGrp.
gGrpId = grpDest;
4951 grpIt = std::find(groupPartitionLists[externalNetId].begin(), groupPartitionLists[externalNetId].end(), targetGrp);
4952 assert(grpIt != groupPartitionLists[externalNetId].end());
4953 grpIt->numPreSynapses += connIt->numberOfConnections;
4963 void SNN::connectUserDefined(
int netId, std::list<ConnectConfig>::iterator connIt,
bool isExternal) {
4964 int grpSrc = connIt->grpSrc;
4965 int grpDest = connIt->grpDest;
4966 int externalNetId = -1;
4969 externalNetId = groupConfigMDMap[grpDest].netId;
4970 assert(netId != externalNetId);
4973 connIt->maxDelay = 0;
4974 int preStartN = groupConfigMDMap[grpSrc].gStartN;
4975 int postStartN = groupConfigMDMap[grpDest].gStartN;
4976 for (
int pre_nid = groupConfigMDMap[grpSrc].gStartN; pre_nid <= groupConfigMDMap[grpSrc].gEndN; pre_nid++) {
4978 for (
int post_nid = groupConfigMDMap[grpDest].gStartN; post_nid <= groupConfigMDMap[grpDest].gEndN; post_nid++) {
4979 float weight, maxWt, delay;
4982 connIt->conn->connect(
this, grpSrc, pre_nid - preStartN, grpDest, post_nid - postStartN, weight, maxWt, delay, connected);
4986 assert(abs(weight) <= abs(maxWt));
4991 if (fabs(maxWt) > connIt->maxWt)
4992 connIt->maxWt = fabs(maxWt);
4994 if (delay > connIt->maxDelay)
4995 connIt->maxDelay = delay;
4997 connectNeurons(netId, grpSrc, grpDest, pre_nid, post_nid, connIt->connId, weight, maxWt, delay, externalNetId);
4998 connIt->numberOfConnections++;
5003 std::list<GroupConfigMD>::iterator grpIt;
5007 targetGrp.
gGrpId = grpSrc;
5008 grpIt = std::find(groupPartitionLists[netId].begin(), groupPartitionLists[netId].end(), targetGrp);
5009 assert(grpIt != groupPartitionLists[netId].end());
5010 grpIt->numPostSynapses += connIt->numberOfConnections;
5012 targetGrp.
gGrpId = grpDest;
5013 grpIt = std::find(groupPartitionLists[netId].begin(), groupPartitionLists[netId].end(), targetGrp);
5014 assert(grpIt != groupPartitionLists[netId].end());
5015 grpIt->numPreSynapses += connIt->numberOfConnections;
5019 targetGrp.
gGrpId = grpSrc;
5020 grpIt = std::find(groupPartitionLists[externalNetId].begin(), groupPartitionLists[externalNetId].end(), targetGrp);
5021 assert(grpIt != groupPartitionLists[externalNetId].end());
5022 grpIt->numPostSynapses += connIt->numberOfConnections;
5024 targetGrp.
gGrpId = grpDest;
5025 grpIt = std::find(groupPartitionLists[externalNetId].begin(), groupPartitionLists[externalNetId].end(), targetGrp);
5026 assert(grpIt != groupPartitionLists[externalNetId].end());
5027 grpIt->numPreSynapses += connIt->numberOfConnections;
5203 void SNN::deleteRuntimeData() {
5207 CUDA_CHECK_ERRORS(cudaThreadSynchronize());
5210 #ifndef __NO_PTHREADS__ // POSIX 5211 pthread_t threads[numCores + 1];
5214 int threadCount = 0;
5218 if (!groupPartitionLists[netId].empty()) {
5220 deleteRuntimeData_GPU(netId);
5222 #ifdef __NO_PTHREADS__ 5223 deleteRuntimeData_CPU(netId);
5224 #else // Linux or MAC 5225 pthread_attr_t attr;
5226 pthread_attr_init(&attr);
5229 pthread_attr_setaffinity_np(&attr,
sizeof(cpu_set_t), &cpus);
5231 argsThreadRoutine[threadCount].
snn_pointer =
this;
5232 argsThreadRoutine[threadCount].
netId = netId;
5233 argsThreadRoutine[threadCount].
lGrpId = 0;
5234 argsThreadRoutine[threadCount].
startIdx = 0;
5235 argsThreadRoutine[threadCount].
endIdx = 0;
5236 argsThreadRoutine[threadCount].
GtoLOffset = 0;
5238 pthread_create(&threads[threadCount], &attr, &SNN::helperDeleteRuntimeData_CPU, (
void*)&argsThreadRoutine[threadCount]);
5239 pthread_attr_destroy(&attr);
5246 #ifndef __NO_PTHREADS__ // POSIX 5248 for (
int i=0; i<threadCount; i++){
5249 pthread_join(threads[i], NULL);
5254 CUDA_DELETE_TIMER(timer);
5259 void SNN::deleteObjects() {
5260 if (simulatorDeleted)
5266 resetMonitors(
true);
5267 resetConnectionConfigs(
true);
5268 #ifdef LN_I_CALC_TYPES 5269 resetGroupConfigs(
true);
5274 deleteManagerRuntimeData();
5276 deleteRuntimeData();
5279 if (loggerMode_ !=
CUSTOM) {
5281 if (fpInf_ != NULL && fpInf_ != stdout && fpInf_ != stderr)
5283 if (fpErr_ != NULL && fpErr_ != stdout && fpErr_ != stderr)
5285 if (fpDeb_ != NULL && fpDeb_ != stdout && fpDeb_ != stderr)
5287 if (fpLog_ != NULL && fpLog_ != stdout && fpLog_ != stderr)
5291 simulatorDeleted =
true;
5294 void SNN::findMaxNumSynapsesGroups(
int* _maxNumPostSynGrp,
int* _maxNumPreSynGrp) {
5295 *_maxNumPostSynGrp = 0;
5296 *_maxNumPreSynGrp = 0;
5299 for (
int gGrpId = 0; gGrpId < numGroups; gGrpId++) {
5302 if (groupConfigMDMap[gGrpId].numPostSynapses > *_maxNumPostSynGrp)
5303 *_maxNumPostSynGrp = groupConfigMDMap[gGrpId].numPostSynapses;
5304 if (groupConfigMDMap[gGrpId].numPreSynapses > *_maxNumPreSynGrp)
5305 *_maxNumPreSynGrp = groupConfigMDMap[gGrpId].numPreSynapses;
5309 void SNN::findMaxNumSynapsesNeurons(
int _netId,
int& _maxNumPostSynN,
int& _maxNumPreSynN) {
5310 int *tempNpre, *tempNpost;
5311 int nSrc, nDest, numNeurons;
5312 std::map<int, int> globalToLocalOffset;
5315 tempNpre =
new int[numNeurons];
5316 tempNpost =
new int[numNeurons];
5317 memset(tempNpre, 0,
sizeof(
int) * numNeurons);
5318 memset(tempNpost, 0,
sizeof(
int) * numNeurons);
5321 for (std::list<GroupConfigMD>::iterator grpIt = groupPartitionLists[_netId].begin(); grpIt != groupPartitionLists[_netId].end(); grpIt++) {
5322 globalToLocalOffset[grpIt->gGrpId] = grpIt->GtoLOffset;
5326 #ifdef LN_FIX_CONNLIST_ 5327 for (std::vector<ConnectionInfo>::iterator connIt = connectionLists[_netId].begin(); connIt != connectionLists[_netId].end(); connIt++) {
5329 for (std::list<ConnectionInfo>::iterator connIt = connectionLists[_netId].begin(); connIt != connectionLists[_netId].end(); connIt++) {
5331 nSrc = connIt->nSrc + globalToLocalOffset[connIt->grpSrc];
5332 nDest = connIt->nDest + globalToLocalOffset[connIt->grpDest];
5333 assert(nSrc < numNeurons); assert(nDest < numNeurons);
5339 _maxNumPostSynN = 0;
5341 for (
int nId = 0; nId < networkConfigs[_netId].
numN; nId++) {
5342 if (tempNpost[nId] > _maxNumPostSynN) _maxNumPostSynN = tempNpost[nId];
5343 if (tempNpre[nId] > _maxNumPreSynN) _maxNumPreSynN = tempNpre[nId];
5347 delete [] tempNpost;
5350 void SNN::findMaxSpikesD1D2(
int _netId,
unsigned int& _maxSpikesD1,
unsigned int& _maxSpikesD2) {
5351 _maxSpikesD1 = 0; _maxSpikesD2 = 0;
5352 for(std::list<GroupConfigMD>::iterator grpIt = groupPartitionLists[_netId].begin(); grpIt != groupPartitionLists[_netId].end(); grpIt++) {
5353 if (grpIt->maxOutgoingDelay == 1)
5360 void SNN::findNumN(
int _netId,
int& _numN,
int& _numNExternal,
int& _numNAssigned,
5361 int& _numNReg,
int& _numNExcReg,
int& _numNInhReg,
5362 int& _numNPois,
int& _numNExcPois,
int& _numNInhPois) {
5363 _numN = 0; _numNExternal = 0; _numNAssigned = 0;
5364 _numNReg = 0; _numNExcReg = 0; _numNInhReg = 0;
5365 _numNPois = 0; _numNExcPois = 0; _numNInhPois = 0;
5366 for (std::list<GroupConfigMD>::iterator grpIt = groupPartitionLists[_netId].begin(); grpIt != groupPartitionLists[_netId].end(); grpIt++) {
5367 int sizeN = groupConfigMap[grpIt->gGrpId].numN;
5368 unsigned int type = groupConfigMap[grpIt->gGrpId].type;
5370 _numN += sizeN; _numNPois += sizeN; _numNExcPois += sizeN;
5372 _numN += sizeN; _numNPois += sizeN; _numNInhPois += sizeN;
5374 _numN += sizeN; _numNReg += sizeN; _numNExcReg += sizeN;
5376 _numN += sizeN; _numNReg += sizeN; _numNInhReg += sizeN;
5377 }
else if (grpIt->netId != _netId) {
5378 _numNExternal += sizeN;
5380 KERNEL_ERROR(
"Can't find catagory for the group [%d] ", grpIt->gGrpId);
5383 _numNAssigned += sizeN;
5386 assert(_numNReg == _numNExcReg + _numNInhReg);
5387 assert(_numNPois == _numNExcPois + _numNInhPois);
5388 assert(_numN == _numNReg + _numNPois);
5389 assert(_numNAssigned == _numN + _numNExternal);
5392 void SNN::findNumNSpikeGenAndOffset(
int _netId) {
5395 for(
int lGrpId = 0; lGrpId < networkConfigs[_netId].
numGroups; lGrpId++) {
5396 if (_netId == groupConfigs[_netId][lGrpId].netId && groupConfigs[_netId][lGrpId].isSpikeGenerator && groupConfigs[_netId][lGrpId].isSpikeGenFunc) {
5402 assert(networkConfigs[_netId].numNSpikeGen <= networkConfigs[_netId].numNPois);
5405 void SNN::findNumSynapsesNetwork(
int _netId,
int& _numPostSynNet,
int& _numPreSynNet) {
5409 for (std::list<GroupConfigMD>::iterator grpIt = groupPartitionLists[_netId].begin(); grpIt != groupPartitionLists[_netId].end(); grpIt++) {
5410 _numPostSynNet += grpIt->numPostSynapses;
5411 _numPreSynNet += grpIt->numPreSynapses;
5412 assert(_numPostSynNet <
INT_MAX);
5413 assert(_numPreSynNet <
INT_MAX);
5416 assert(_numPreSynNet == _numPostSynNet);
5419 void SNN::fetchGroupState(
int netId,
int lGrpId) {
5421 copyGroupState(netId, lGrpId, &managerRuntimeData, &runtimeData[netId], cudaMemcpyDeviceToHost,
false);
5423 copyGroupState(netId, lGrpId, &managerRuntimeData, &runtimeData[netId],
false);
5426 void SNN::fetchWeightState(
int netId,
int lGrpId) {
5428 copyWeightState(netId, lGrpId, cudaMemcpyDeviceToHost);
5430 copyWeightState(netId, lGrpId);
5438 void SNN::fetchNeuronSpikeCount (
int gGrpId) {
5439 if (gGrpId ==
ALL) {
5440 for (
int gGrpId = 0; gGrpId < numGroups; gGrpId++) {
5441 fetchNeuronSpikeCount(gGrpId);
5444 int netId = groupConfigMDMap[gGrpId].netId;
5445 int lGrpId = groupConfigMDMap[gGrpId].lGrpId;
5446 int LtoGOffset = groupConfigMDMap[gGrpId].LtoGOffset;
5449 copyNeuronSpikeCount(netId, lGrpId, &managerRuntimeData, &runtimeData[netId], cudaMemcpyDeviceToHost,
false, LtoGOffset);
5451 copyNeuronSpikeCount(netId, lGrpId, &managerRuntimeData, &runtimeData[netId],
false, LtoGOffset);
5455 void SNN::fetchSTPState(
int gGrpId) {
5463 void SNN::fetchConductanceAMPA(
int gGrpId) {
5464 if (gGrpId ==
ALL) {
5465 for (
int gGrpId = 0; gGrpId < numGroups; gGrpId++) {
5466 fetchConductanceAMPA(gGrpId);
5469 int netId = groupConfigMDMap[gGrpId].netId;
5470 int lGrpId = groupConfigMDMap[gGrpId].lGrpId;
5471 int LtoGOffset = groupConfigMDMap[gGrpId].LtoGOffset;
5474 copyConductanceAMPA(netId, lGrpId, &managerRuntimeData, &runtimeData[netId], cudaMemcpyDeviceToHost,
false, LtoGOffset);
5476 copyConductanceAMPA(netId, lGrpId, &managerRuntimeData, &runtimeData[netId],
false, LtoGOffset);
5485 void SNN::fetchConductanceNMDA(
int gGrpId) {
5486 if (gGrpId ==
ALL) {
5487 for (
int gGrpId = 0; gGrpId < numGroups; gGrpId++) {
5488 fetchConductanceNMDA(gGrpId);
5491 int netId = groupConfigMDMap[gGrpId].netId;
5492 int lGrpId = groupConfigMDMap[gGrpId].lGrpId;
5493 int LtoGOffset = groupConfigMDMap[gGrpId].LtoGOffset;
5496 copyConductanceNMDA(netId, lGrpId, &managerRuntimeData, &runtimeData[netId], cudaMemcpyDeviceToHost,
false, LtoGOffset);
5498 copyConductanceNMDA(netId, lGrpId, &managerRuntimeData, &runtimeData[netId],
false, LtoGOffset);
5507 void SNN::fetchConductanceGABAa(
int gGrpId) {
5508 if (gGrpId ==
ALL) {
5509 for (
int gGrpId = 0; gGrpId < numGroups; gGrpId++) {
5510 fetchConductanceGABAa(gGrpId);
5513 int netId = groupConfigMDMap[gGrpId].netId;
5514 int lGrpId = groupConfigMDMap[gGrpId].lGrpId;
5515 int LtoGOffset = groupConfigMDMap[gGrpId].LtoGOffset;
5518 copyConductanceGABAa(netId, lGrpId, &managerRuntimeData, &runtimeData[netId], cudaMemcpyDeviceToHost,
false, LtoGOffset);
5520 copyConductanceGABAa(netId, lGrpId, &managerRuntimeData, &runtimeData[netId],
false, LtoGOffset);
5529 void SNN::fetchConductanceGABAb(
int gGrpId) {
5530 if (gGrpId ==
ALL) {
5531 for (
int gGrpId = 0; gGrpId < numGroups; gGrpId++) {
5532 fetchConductanceGABAb(gGrpId);
5535 int netId = groupConfigMDMap[gGrpId].netId;
5536 int lGrpId = groupConfigMDMap[gGrpId].lGrpId;
5537 int LtoGOffset = groupConfigMDMap[gGrpId].LtoGOffset;
5540 copyConductanceGABAb(netId, lGrpId, &managerRuntimeData, &runtimeData[netId], cudaMemcpyDeviceToHost,
false, LtoGOffset);
5542 copyConductanceGABAb(netId, lGrpId, &managerRuntimeData, &runtimeData[netId],
false, LtoGOffset);
5547 void SNN::fetchGrpIdsLookupArray(
int netId) {
5549 copyGrpIdsLookupArray(netId, cudaMemcpyDeviceToHost);
5551 copyGrpIdsLookupArray(netId);
5554 void SNN::fetchConnIdsLookupArray(
int netId) {
5556 copyConnIdsLookupArray(netId, cudaMemcpyDeviceToHost);
5558 copyConnIdsLookupArray(netId);
5561 void SNN::fetchLastSpikeTime(
int netId) {
5563 copyLastSpikeTime(netId, cudaMemcpyDeviceToHost);
5565 copyLastSpikeTime(netId);
5571 void SNN::fetchCurSpike(
int netId) {
5575 copyCurSpikes(netId, cudaMemcpyDeviceToHost);
5577 copyCurSpikes(netId);
5583 void SNN::fetchRandNum(
int netId) {
5587 copyRandNum(netId, cudaMemcpyDeviceToHost);
5595 void SNN::fetchPoissonFireRate(
int netId) {
5599 copyPoissonFireRate(netId, cudaMemcpyDeviceToHost);
5601 copyPoissonFireRate(netId);
5607 void SNN::fetchSpikeGenBits(
int netId) {
5611 copySpikeGenBits(netId, cudaMemcpyDeviceToHost);
5613 copySpikeGenBits(netId);
5620 void SNN::fetchPreConnectionInfo(
int netId) {
5622 copyPreConnectionInfo(netId,
ALL, &managerRuntimeData, &runtimeData[netId], cudaMemcpyDeviceToHost,
false);
5624 copyPreConnectionInfo(netId,
ALL, &managerRuntimeData, &runtimeData[netId],
false);
5627 void SNN::fetchPostConnectionInfo(
int netId) {
5629 copyPostConnectionInfo(netId,
ALL, &managerRuntimeData, &runtimeData[netId], cudaMemcpyDeviceToHost,
false);
5631 copyPostConnectionInfo(netId,
ALL, &managerRuntimeData, &runtimeData[netId],
false);
5634 void SNN::fetchSynapseState(
int netId) {
5636 copySynapseState(netId, &managerRuntimeData, &runtimeData[netId], cudaMemcpyDeviceToHost,
false);
5638 copySynapseState(netId, &managerRuntimeData, &runtimeData[netId],
false);
5645 void SNN::fetchNetworkSpikeCount() {
5646 unsigned int spikeCountD1, spikeCountD2, spikeCountExtD1, spikeCountExtD2;
5653 if (!groupPartitionLists[netId].empty()) {
5656 copyNetworkSpikeCount(netId, cudaMemcpyDeviceToHost,
5657 &spikeCountD1, &spikeCountD2,
5658 &spikeCountExtD1, &spikeCountExtD2);
5661 copyNetworkSpikeCount(netId,
5662 &spikeCountD1, &spikeCountD2,
5663 &spikeCountExtD1, &spikeCountExtD2);
5667 managerRuntimeData.
spikeCountD2 += spikeCountD2 - spikeCountExtD2;
5668 managerRuntimeData.
spikeCountD1 += spikeCountD1 - spikeCountExtD1;
5677 void SNN::fetchSpikeTables(
int netId) {
5679 copySpikeTables(netId, cudaMemcpyDeviceToHost);
5681 copySpikeTables(netId);
5684 void SNN::fetchNeuronStateBuffer(
int netId,
int lGrpId) {
5686 copyNeuronStateBuffer(netId, lGrpId, &managerRuntimeData, &runtimeData[netId], cudaMemcpyDeviceToHost,
false);
5688 copyNeuronStateBuffer(netId, lGrpId, &managerRuntimeData, &runtimeData[netId],
false);
5691 void SNN::fetchExtFiringTable(
int netId) {
5695 copyExtFiringTable(netId, cudaMemcpyDeviceToHost);
5697 copyExtFiringTable(netId);
5701 void SNN::fetchTimeTable(
int netId) {
5705 copyTimeTable(netId, cudaMemcpyDeviceToHost);
5707 copyTimeTable(netId,
true);
5711 void SNN::writeBackTimeTable(
int netId) {
5715 copyTimeTable(netId, cudaMemcpyHostToDevice);
5717 copyTimeTable(netId,
false);
5721 void SNN::transferSpikes(
void* dest,
int destNetId,
void* src,
int srcNetId,
int size) {
5724 checkAndSetGPUDevice(destNetId);
5725 CUDA_CHECK_ERRORS(cudaMemcpyPeer(dest, destNetId, src, srcNetId, size));
5727 checkAndSetGPUDevice(destNetId);
5728 CUDA_CHECK_ERRORS(cudaMemcpy(dest, src, size, cudaMemcpyHostToDevice));
5730 checkAndSetGPUDevice(srcNetId);
5731 CUDA_CHECK_ERRORS(cudaMemcpy(dest, src, size, cudaMemcpyDeviceToHost));
5733 memcpy(dest, src, size);
5737 memcpy(dest, src, size);
5741 void SNN::convertExtSpikesD2(
int netId,
int startIdx,
int endIdx,
int GtoLOffset) {
5743 convertExtSpikesD2_GPU(netId, startIdx, endIdx, GtoLOffset);
5745 convertExtSpikesD2_CPU(netId, startIdx, endIdx, GtoLOffset);
5748 void SNN::convertExtSpikesD1(
int netId,
int startIdx,
int endIdx,
int GtoLOffset) {
5750 convertExtSpikesD1_GPU(netId, startIdx, endIdx, GtoLOffset);
5752 convertExtSpikesD1_CPU(netId, startIdx, endIdx, GtoLOffset);
5755 void SNN::routeSpikes() {
5756 int firingTableIdxD2, firingTableIdxD1;
5759 for (std::list<RoutingTableEntry>::iterator rteItr = spikeRoutingTable.begin(); rteItr != spikeRoutingTable.end(); rteItr++) {
5760 int srcNetId = rteItr->srcNetId;
5761 int destNetId = rteItr->destNetId;
5763 fetchExtFiringTable(srcNetId);
5765 fetchTimeTable(destNetId);
5766 firingTableIdxD2 = managerRuntimeData.
timeTableD2[simTimeMs + glbNetworkConfig.
maxDelay + 1];
5767 firingTableIdxD1 = managerRuntimeData.
timeTableD1[simTimeMs + glbNetworkConfig.
maxDelay + 1];
5771 #ifndef __NO_PTHREADS__ // POSIX 5772 pthread_t threads[(2 * networkConfigs[srcNetId].
numGroups) + 1];
5775 int threadCount = 0;
5778 for (
int lGrpId = 0; lGrpId < networkConfigs[srcNetId].
numGroups; lGrpId++) {
5779 if (groupConfigs[srcNetId][lGrpId].hasExternalConnect && managerRuntimeData.
extFiringTableEndIdxD2[lGrpId] > 0) {
5781 bool isFound =
false;
5782 for (std::list<GroupConfigMD>::iterator grpIt = groupPartitionLists[destNetId].begin(); grpIt != groupPartitionLists[destNetId].end(); grpIt++) {
5783 if (grpIt->gGrpId == groupConfigs[srcNetId][lGrpId].
gGrpId) {
5791 transferSpikes(runtimeData[destNetId].firingTableD2 + firingTableIdxD2, destNetId,
5796 convertExtSpikesD2_GPU(destNetId, firingTableIdxD2,
5801 #ifdef __NO_PTHREADS__ 5802 convertExtSpikesD2_CPU(destNetId, firingTableIdxD2,
5805 #else // Linux or MAC 5806 pthread_attr_t attr;
5807 pthread_attr_init(&attr);
5810 pthread_attr_setaffinity_np(&attr,
sizeof(cpu_set_t), &cpus);
5812 argsThreadRoutine[threadCount].snn_pointer =
this;
5813 argsThreadRoutine[threadCount].netId = destNetId;
5814 argsThreadRoutine[threadCount].lGrpId = 0;
5815 argsThreadRoutine[threadCount].startIdx = firingTableIdxD2;
5816 argsThreadRoutine[threadCount].endIdx = firingTableIdxD2 + managerRuntimeData.
extFiringTableEndIdxD2[lGrpId];
5817 argsThreadRoutine[threadCount].GtoLOffset = GtoLOffset;
5819 pthread_create(&threads[threadCount], &attr, &SNN::helperConvertExtSpikesD2_CPU, (
void*)&argsThreadRoutine[threadCount]);
5820 pthread_attr_destroy(&attr);
5829 if (groupConfigs[srcNetId][lGrpId].hasExternalConnect && managerRuntimeData.
extFiringTableEndIdxD1[lGrpId] > 0) {
5831 bool isFound =
false;
5832 for (std::list<GroupConfigMD>::iterator grpIt = groupPartitionLists[destNetId].begin(); grpIt != groupPartitionLists[destNetId].end(); grpIt++) {
5833 if (grpIt->gGrpId == groupConfigs[srcNetId][lGrpId].
gGrpId) {
5834 GtoLOffset = grpIt->GtoLOffset;
5841 transferSpikes(runtimeData[destNetId].firingTableD1 + firingTableIdxD1, destNetId,
5845 convertExtSpikesD1_GPU(destNetId, firingTableIdxD1,
5850 #ifdef __NO_PTHREADS__ 5851 convertExtSpikesD1_CPU(destNetId, firingTableIdxD1,
5854 #else // Linux or MAC 5855 pthread_attr_t attr;
5856 pthread_attr_init(&attr);
5859 pthread_attr_setaffinity_np(&attr,
sizeof(cpu_set_t), &cpus);
5861 argsThreadRoutine[threadCount].snn_pointer =
this;
5862 argsThreadRoutine[threadCount].netId = destNetId;
5863 argsThreadRoutine[threadCount].lGrpId = 0;
5864 argsThreadRoutine[threadCount].startIdx = firingTableIdxD1;
5865 argsThreadRoutine[threadCount].endIdx = firingTableIdxD1 + managerRuntimeData.
extFiringTableEndIdxD1[lGrpId];
5866 argsThreadRoutine[threadCount].GtoLOffset = GtoLOffset;
5868 pthread_create(&threads[threadCount], &attr, &SNN::helperConvertExtSpikesD1_CPU, (
void*)&argsThreadRoutine[threadCount]);
5869 pthread_attr_destroy(&attr);
5879 #ifndef __NO_PTHREADS__ // POSIX 5881 for (
int i=0; i<threadCount; i++){
5882 pthread_join(threads[i], NULL);
5886 managerRuntimeData.
timeTableD2[simTimeMs + glbNetworkConfig.
maxDelay + 1] = firingTableIdxD2;
5887 managerRuntimeData.
timeTableD1[simTimeMs + glbNetworkConfig.
maxDelay + 1] = firingTableIdxD1;
5888 writeBackTimeTable(destNetId);
5895 float SNN::generateWeight(
int connProp,
float initWt,
float maxWt,
int nid,
int grpId) {
5916 assert(connId !=
ALL);
5917 assert(connId < numConnections);
5927 return (groupConfigMap[grpId].homeoConfig.WithHomeostasis);
5931 void SNN::verifyNetwork() {
5937 verifyCompartments();
5943 verifyHomeostasis();
5975 if (sim_with_stp && glbNetworkConfig.
maxDelay > 1) {
5976 KERNEL_ERROR(
"STP with delays > 1 ms is currently not supported.");
5981 KERNEL_ERROR(
"You are using a synaptic delay (%d) greater than MAX_SYN_DELAY defined in config.h", glbNetworkConfig.
maxDelay);
5986 void SNN::verifyCompartments() {
5987 for (std::map<int, compConnectConfig>::iterator it = compConnectConfigMap.begin(); it != compConnectConfigMap.end(); it++)
5989 int grpLower = it->second.grpSrc;
5990 int grpUpper = it->second.grpDest;
5993 if (!groupConfigMap[grpLower].withCompartments) {
5994 KERNEL_ERROR(
"Group %s(%d) is not compartmentally enabled, cannot be part of a compartmental connection.",
5995 groupConfigMap[grpLower].grpName.c_str(), grpLower);
5998 if (!groupConfigMap[grpUpper].withCompartments) {
5999 KERNEL_ERROR(
"Group %s(%d) is not compartmentally enabled, cannot be part of a compartmental connection.",
6000 groupConfigMap[grpUpper].grpName.c_str(), grpUpper);
6007 void SNN::verifySTDP() {
6009 if (groupConfigMap[gGrpId].WithSTDP) {
6011 bool isAnyPlastic =
false;
6012 for (std::map<int, ConnectConfig>::iterator it = connectConfigMap.begin(); it != connectConfigMap.end(); it++) {
6030 if (!isAnyPlastic) {
6031 KERNEL_ERROR(
"If STDP on group %d (%s) is set, group must have some incoming plastic connections.",
6032 gGrpId, groupConfigMap[gGrpId].grpName.c_str());
6040 void SNN::verifyHomeostasis() {
6042 if (groupConfigMap[gGrpId].homeoConfig.WithHomeostasis) {
6043 KERNEL_INFO(
"group %d STDP %d", gGrpId, groupConfigMap[gGrpId].WithSTDP);
6044 if (!groupConfigMap[gGrpId].WithSTDP) {
6045 KERNEL_ERROR(
"If homeostasis is enabled on group %d (%s), then STDP must be enabled, too.",
6046 gGrpId, groupConfigMap[gGrpId].grpName.c_str());
6108 return (rfDist >= 0.0 && rfDist <= 1.0);
6118 double rfDist = -1.0;
6124 if (radius.
radX==0 && pre.
x!=post.
x || radius.
radY==0 && pre.
y!=post.
y || radius.
radZ==0 && pre.
z!=post.
z) {
6128 double xTerm = (radius.
radX<=0) ? 0.0 : pow(pre.
x-post.
x,2)/pow(radius.
radX,2);
6129 double yTerm = (radius.
radY<=0) ? 0.0 : pow(pre.
y-post.
y,2)/pow(radius.
radY,2);
6130 double zTerm = (radius.
radZ<=0) ? 0.0 : pow(pre.
z-post.
z,2)/pow(radius.
radZ,2);
6131 rfDist = xTerm + yTerm + zTerm;
6137 void SNN::partitionSNN() {
6142 numAvailableGPUs = configGPUDevice();
6145 for (std::map<int, GroupConfigMD>::iterator grpIt = groupConfigMDMap.begin(); grpIt != groupConfigMDMap.end(); grpIt++) {
6147 int gGrpId = grpIt->second.gGrpId;
6148 int netId = groupConfigMap[gGrpId].preferredNetId;
6151 grpIt->second.netId = netId;
6152 numAssignedNeurons[netId] += groupConfigMap[gGrpId].numN;
6153 groupPartitionLists[netId].push_back(grpIt->second);
6158 if (preferredSimMode_ ==
CPU_MODE) {
6162 }
else if (preferredSimMode_ ==
GPU_MODE) {
6177 if (grpIt->second.netId == -1) {
6178 KERNEL_ERROR(
"Can't assign the group [%d] to any partition", grpIt->second.gGrpId);
6185 if (!groupPartitionLists[netId].empty()) {
6186 for (std::map<int, ConnectConfig>::iterator connIt = connectConfigMap.begin(); connIt != connectConfigMap.end(); connIt++) {
6187 if (groupConfigMDMap[connIt->second.grpSrc].netId == netId && groupConfigMDMap[connIt->second.grpDest].netId == netId) {
6188 localConnectLists[netId].push_back(connectConfigMap[connIt->second.connId]);
6193 for (std::map<int, compConnectConfig>::iterator connIt = compConnectConfigMap.begin(); connIt != compConnectConfigMap.end(); connIt++) {
6194 if (groupConfigMDMap[connIt->second.grpSrc].netId == netId && groupConfigMDMap[connIt->second.grpDest].netId == netId) {
6195 localCompConnectLists[netId].push_back(compConnectConfigMap[connIt->second.connId]);
6202 spikeRoutingTable.clear();
6204 if (!groupPartitionLists[netId].empty()) {
6205 for (std::map<int, ConnectConfig>::iterator connIt = connectConfigMap.begin(); connIt != connectConfigMap.end(); connIt++) {
6206 int srcNetId = groupConfigMDMap[connIt->second.grpSrc].netId;
6207 int destNetId = groupConfigMDMap[connIt->second.grpDest].netId;
6208 if (srcNetId == netId && destNetId != netId) {
6211 std::list<GroupConfigMD>::iterator srcGrpIt, destGrpIt;
6213 targetGroup.
gGrpId = connIt->second.grpSrc;
6214 srcGrpIt = find(groupPartitionLists[srcNetId].begin(), groupPartitionLists[srcNetId].end(), targetGroup);
6215 assert(srcGrpIt != groupPartitionLists[srcNetId].end());
6216 srcGrpIt->hasExternalConnect =
true;
6219 targetGroup.
gGrpId = connIt->second.grpDest;
6220 destGrpIt = find(groupPartitionLists[srcNetId].begin(), groupPartitionLists[srcNetId].end(), targetGroup);
6221 if (destGrpIt == groupPartitionLists[srcNetId].end()) {
6222 numAssignedNeurons[srcNetId] += groupConfigMap[connIt->second.grpDest].numN;
6223 groupPartitionLists[srcNetId].push_back(groupConfigMDMap[connIt->second.grpDest]);
6226 targetGroup.
gGrpId = connIt->second.grpSrc;
6227 srcGrpIt = find(groupPartitionLists[destNetId].begin(), groupPartitionLists[destNetId].end(), targetGroup);
6228 if (srcGrpIt == groupPartitionLists[destNetId].end()) {
6229 numAssignedNeurons[destNetId] += groupConfigMap[connIt->second.grpSrc].numN;
6230 groupPartitionLists[destNetId].push_back(groupConfigMDMap[connIt->second.grpSrc]);
6233 externalConnectLists[srcNetId].push_back(connectConfigMap[connIt->second.connId]);
6238 spikeRoutingTable.push_back(rte);
6244 spikeRoutingTable.unique();
6251 if (!groupPartitionLists[netId].empty()) {
6252 int availableNeuronId = 0;
6253 int localGroupId = 0;
6254 for (
int order = 0; order < 5; order++) {
6255 for (std::list<GroupConfigMD>::iterator grpIt = groupPartitionLists[netId].begin(); grpIt != groupPartitionLists[netId].end(); grpIt++) {
6256 unsigned int type = groupConfigMap[grpIt->gGrpId].type;
6258 availableNeuronId = assignGroup(grpIt, localGroupId, availableNeuronId);
6261 availableNeuronId = assignGroup(grpIt, localGroupId, availableNeuronId);
6263 }
else if (
IS_EXCITATORY_TYPE(type) && !(type & POISSON_NEURON) && order == 0 && grpIt->netId == netId) {
6264 availableNeuronId = assignGroup(grpIt, localGroupId, availableNeuronId);
6266 }
else if (
IS_INHIBITORY_TYPE(type) && !(type & POISSON_NEURON) && order == 1 && grpIt->netId == netId) {
6267 availableNeuronId = assignGroup(grpIt, localGroupId, availableNeuronId);
6269 }
else if (order == 4 && grpIt->netId != netId) {
6270 availableNeuronId = assignGroup(grpIt, localGroupId, availableNeuronId);
6275 assert(availableNeuronId == numAssignedNeurons[netId]);
6276 assert(localGroupId == groupPartitionLists[netId].size());
6284 if (loadSimFID == NULL) {
6288 loadSimulation_internal(
false);
6291 collectGlobalNetworkConfigP();
6295 if (!groupPartitionLists[netId].empty()) {
6298 for (std::list<GroupConfigMD>::iterator grpIt = groupPartitionLists[netId].begin(); grpIt != groupPartitionLists[netId].end(); grpIt++)
6299 printGroupInfo(netId, grpIt);
6302 if (!localConnectLists[netId].empty() || !externalConnectLists[netId].empty()) {
6304 for (std::list<ConnectConfig>::iterator connIt = localConnectLists[netId].begin(); connIt != localConnectLists[netId].end(); connIt++)
6305 printConnectionInfo(netId, connIt);
6307 for (std::list<ConnectConfig>::iterator connIt = externalConnectLists[netId].begin(); connIt != externalConnectLists[netId].end(); connIt++)
6308 printConnectionInfo(netId, connIt);
6313 printSikeRoutingInfo();
6318 #ifdef LN_SETUP_NETWORK_MT 6320 void SNN::partitionSNNMT() {
6324 numAvailableGPUs = configGPUDevice();
6326 for (std::map<int, GroupConfigMD>::iterator grpIt = groupConfigMDMap.begin(); grpIt != groupConfigMDMap.end(); grpIt++) {
6328 int gGrpId = grpIt->second.gGrpId;
6329 int netId = groupConfigMap[gGrpId].preferredNetId;
6332 grpIt->second.netId = netId;
6333 numAssignedNeurons[netId] += groupConfigMap[gGrpId].numN;
6334 groupPartitionLists[netId].push_back(grpIt->second);
6340 if (preferredSimMode_ ==
CPU_MODE) {
6345 else if (preferredSimMode_ ==
GPU_MODE) {
6362 if (grpIt->second.netId == -1) {
6363 KERNEL_ERROR(
"Can't assign the group [%d] to any partition", grpIt->second.gGrpId);
6370 if (!groupPartitionLists[netId].empty()) {
6371 for (std::map<int, ConnectConfig>::iterator connIt = connectConfigMap.begin(); connIt != connectConfigMap.end(); connIt++) {
6372 if (groupConfigMDMap[connIt->second.grpSrc].netId == netId && groupConfigMDMap[connIt->second.grpDest].netId == netId) {
6373 localConnectLists[netId].push_back(connectConfigMap[connIt->second.connId]);
6378 for (std::map<int, compConnectConfig>::iterator connIt = compConnectConfigMap.begin(); connIt != compConnectConfigMap.end(); connIt++) {
6379 if (groupConfigMDMap[connIt->second.grpSrc].netId == netId && groupConfigMDMap[connIt->second.grpDest].netId == netId) {
6380 localCompConnectLists[netId].push_back(compConnectConfigMap[connIt->second.connId]);
6387 spikeRoutingTable.clear();
6389 if (!groupPartitionLists[netId].empty()) {
6390 for (std::map<int, ConnectConfig>::iterator connIt = connectConfigMap.begin(); connIt != connectConfigMap.end(); connIt++) {
6391 int srcNetId = groupConfigMDMap[connIt->second.grpSrc].netId;
6392 int destNetId = groupConfigMDMap[connIt->second.grpDest].netId;
6393 if (srcNetId == netId && destNetId != netId) {
6396 std::list<GroupConfigMD>::iterator srcGrpIt, destGrpIt;
6398 targetGroup.
gGrpId = connIt->second.grpSrc;
6399 srcGrpIt = find(groupPartitionLists[srcNetId].begin(), groupPartitionLists[srcNetId].end(), targetGroup);
6400 assert(srcGrpIt != groupPartitionLists[srcNetId].end());
6401 srcGrpIt->hasExternalConnect =
true;
6404 targetGroup.
gGrpId = connIt->second.grpDest;
6405 destGrpIt = find(groupPartitionLists[srcNetId].begin(), groupPartitionLists[srcNetId].end(), targetGroup);
6406 if (destGrpIt == groupPartitionLists[srcNetId].end()) {
6407 numAssignedNeurons[srcNetId] += groupConfigMap[connIt->second.grpDest].numN;
6408 groupPartitionLists[srcNetId].push_back(groupConfigMDMap[connIt->second.grpDest]);
6411 targetGroup.
gGrpId = connIt->second.grpSrc;
6412 srcGrpIt = find(groupPartitionLists[destNetId].begin(), groupPartitionLists[destNetId].end(), targetGroup);
6413 if (srcGrpIt == groupPartitionLists[destNetId].end()) {
6414 numAssignedNeurons[destNetId] += groupConfigMap[connIt->second.grpSrc].numN;
6415 groupPartitionLists[destNetId].push_back(groupConfigMDMap[connIt->second.grpSrc]);
6418 externalConnectLists[srcNetId].push_back(connectConfigMap[connIt->second.connId]);
6423 spikeRoutingTable.push_back(rte);
6429 spikeRoutingTable.unique();
6436 if (!groupPartitionLists[netId].empty()) {
6437 int availableNeuronId = 0;
6438 int localGroupId = 0;
6439 for (
int order = 0; order < 5; order++) {
6440 for (std::list<GroupConfigMD>::iterator grpIt = groupPartitionLists[netId].begin(); grpIt != groupPartitionLists[netId].end(); grpIt++) {
6441 unsigned int type = groupConfigMap[grpIt->gGrpId].type;
6443 availableNeuronId = assignGroup(grpIt, localGroupId, availableNeuronId);
6447 availableNeuronId = assignGroup(grpIt, localGroupId, availableNeuronId);
6450 else if (
IS_EXCITATORY_TYPE(type) && !(type & POISSON_NEURON) && order == 0 && grpIt->netId == netId) {
6451 availableNeuronId = assignGroup(grpIt, localGroupId, availableNeuronId);
6454 else if (
IS_INHIBITORY_TYPE(type) && !(type & POISSON_NEURON) && order == 1 && grpIt->netId == netId) {
6455 availableNeuronId = assignGroup(grpIt, localGroupId, availableNeuronId);
6458 else if (order == 4 && grpIt->netId != netId) {
6459 availableNeuronId = assignGroup(grpIt, localGroupId, availableNeuronId);
6464 assert(availableNeuronId == numAssignedNeurons[netId]);
6465 assert(localGroupId == groupPartitionLists[netId].size());
6473 if (loadSimFID == NULL) {
6478 loadSimulation_internal(
false);
6481 collectGlobalNetworkConfigP();
6485 if (!groupPartitionLists[netId].empty()) {
6488 for (std::list<GroupConfigMD>::iterator grpIt = groupPartitionLists[netId].begin(); grpIt != groupPartitionLists[netId].end(); grpIt++)
6489 printGroupInfo(netId, grpIt);
6492 if (!localConnectLists[netId].empty() || !externalConnectLists[netId].empty()) {
6494 for (std::list<ConnectConfig>::iterator connIt = localConnectLists[netId].begin(); connIt != localConnectLists[netId].end(); connIt++)
6495 printConnectionInfo(netId, connIt);
6497 for (std::list<ConnectConfig>::iterator connIt = externalConnectLists[netId].begin(); connIt != externalConnectLists[netId].end(); connIt++)
6498 printConnectionInfo(netId, connIt);
6503 printSikeRoutingInfo();
6509 int SNN::loadSimulation_internal(
bool onlyPlastic) {
6512 long file_position = ftell(loadSimFID);
6517 bool readErr =
false;
6523 fseek(loadSimFID, 0, SEEK_SET);
6526 result = fread(&tmpInt,
sizeof(
int), 1, loadSimFID);
6527 readErr |= (result!=1);
6528 if (tmpInt != 294338571) {
6529 KERNEL_ERROR(
"loadSimulation: Unknown file signature. This does not seem to be a " 6530 "simulation file created with CARLsim::saveSimulation.");
6535 result = fread(&tmpFloat,
sizeof(
float), 1, loadSimFID);
6536 readErr |= (result!=1);
6537 if (tmpFloat > 0.3f) {
6538 KERNEL_ERROR(
"loadSimulation: Unsupported version number (%f)",tmpFloat);
6543 result = fread(&tmpFloat,
sizeof(
float), 1, loadSimFID);
6544 readErr |= (result!=1);
6547 result = fread(&tmpFloat,
sizeof(
float), 1, loadSimFID);
6548 readErr |= (result!=1);
6551 result = fread(&tmpInt,
sizeof(
int), 1, loadSimFID);
6552 readErr |= (result!=1);
6553 if (tmpInt != glbNetworkConfig.
numN) {
6554 KERNEL_ERROR(
"loadSimulation: Number of neurons in file (%d) and simulation (%d) don't match.",
6555 tmpInt, glbNetworkConfig.
numN);
6579 result = fread(&tmpInt,
sizeof(
int), 1, loadSimFID);
6580 readErr |= (result!=1);
6581 if (tmpInt != numGroups) {
6582 KERNEL_ERROR(
"loadSimulation: Number of groups in file (%d) and simulation (%d) don't match.",
6589 fprintf(stderr,
"loadSimulation: Error while reading file header");
6595 for (
int g=0; g<numGroups; g++) {
6597 result = fread(&tmpInt,
sizeof(
int), 1, loadSimFID);
6598 readErr |= (result!=1);
6599 if (tmpInt != groupConfigMDMap[g].gStartN) {
6600 KERNEL_ERROR(
"loadSimulation: StartN in file (%d) and grpInfo (%d) for group %d don't match.",
6601 tmpInt, groupConfigMDMap[g].gStartN, g);
6606 result = fread(&tmpInt,
sizeof(
int), 1, loadSimFID);
6607 readErr |= (result!=1);
6608 if (tmpInt != groupConfigMDMap[g].gEndN) {
6609 KERNEL_ERROR(
"loadSimulation: EndN in file (%d) and grpInfo (%d) for group %d don't match.",
6610 tmpInt, groupConfigMDMap[g].gEndN, g);
6615 result = fread(&tmpInt,
sizeof(
int), 1, loadSimFID);
6616 readErr |= (result!=1);
6617 if (tmpInt != groupConfigMap[g].grid.numX) {
6618 KERNEL_ERROR(
"loadSimulation: numX in file (%d) and grpInfo (%d) for group %d don't match.",
6619 tmpInt, groupConfigMap[g].grid.numX, g);
6625 result = fread(&tmpInt,
sizeof(
int), 1, loadSimFID);
6626 readErr |= (result!=1);
6627 if (tmpInt != groupConfigMap[g].grid.numY) {
6628 KERNEL_ERROR(
"loadSimulation: numY in file (%d) and grpInfo (%d) for group %d don't match.",
6629 tmpInt, groupConfigMap[g].grid.numY, g);
6635 result = fread(&tmpInt,
sizeof(
int), 1, loadSimFID);
6636 readErr |= (result!=1);
6637 if (tmpInt != groupConfigMap[g].grid.numZ) {
6638 KERNEL_ERROR(
"loadSimulation: numZ in file (%d) and grpInfo (%d) for group %d don't match.",
6639 tmpInt, groupConfigMap[g].grid.numZ, g);
6646 result = fread(name,
sizeof(
char), 100, loadSimFID);
6647 readErr |= (result!=100);
6648 if (strcmp(name,groupConfigMap[g].grpName.c_str()) != 0) {
6649 KERNEL_ERROR(
"loadSimulation: Group names in file (%s) and grpInfo (%s) don't match.", name,
6650 groupConfigMap[g].grpName.c_str());
6656 KERNEL_ERROR(
"loadSimulation: Error while reading group info");
6685 result = fread(&net_count,
sizeof(
int), 1, loadSimFID);
6686 readErr |= (result!=1);
6688 for (
int i = 0; i < net_count; i++) {
6689 int synapse_count = 0;
6690 result = fread(&synapse_count,
sizeof(
int), 1, loadSimFID);
6691 for (
int j = 0; j < synapse_count; j++) {
6702 result = fread(&gGrpIdPre,
sizeof(
int), 1, loadSimFID);
6703 readErr |= (result!=1);
6706 result = fread(&gGrpIdPost,
sizeof(
int), 1, loadSimFID);
6707 readErr |= (result!=1);
6710 result = fread(&grpNIdPre,
sizeof(
int), 1, loadSimFID);
6711 readErr |= (result!=1);
6714 result = fread(&grpNIdPost,
sizeof(
int), 1, loadSimFID);
6715 readErr |= (result!=1);
6718 result = fread(&connId,
sizeof(
int), 1, loadSimFID);
6719 readErr |= (result!=1);
6722 result = fread(&weight,
sizeof(
float), 1, loadSimFID);
6723 readErr |= (result!=1);
6726 result = fread(&maxWeight,
sizeof(
float), 1, loadSimFID);
6727 readErr |= (result!=1);
6730 result = fread(&delay,
sizeof(
int), 1, loadSimFID);
6731 readErr |= (result!=1);
6735 if (connectConfigMap[connId].grpSrc != gGrpIdPre) {
6736 KERNEL_ERROR(
"loadSimulation: source group in file (%d) and in simulation (%d) for connection %d don't match.",
6737 gGrpIdPre , connectConfigMap[connId].grpSrc, connId);
6741 if (connectConfigMap[connId].grpDest != gGrpIdPost) {
6742 KERNEL_ERROR(
"loadSimulation: dest group in file (%d) and in simulation (%d) for connection %d don't match.",
6743 gGrpIdPost , connectConfigMap[connId].grpDest, connId);
6749 int netIdPre = groupConfigMDMap[gGrpIdPre].netId;
6750 int netIdPost = groupConfigMDMap[gGrpIdPost].netId;
6751 bool isExternal = (netIdPre != netIdPost);
6754 int globalNIdPre = groupConfigMDMap[gGrpIdPre].gStartN + grpNIdPre;
6755 int globalNIdPost = groupConfigMDMap[gGrpIdPost].gStartN + grpNIdPost;
6757 bool connected =
false;
6759 for (std::list<ConnectConfig>::iterator connIt = localConnectLists[netIdPre].begin(); connIt != localConnectLists[netIdPre].end() && (!connected); connIt++) {
6760 if (connIt->connId == connId) {
6762 connectNeurons(netIdPre, gGrpIdPre, gGrpIdPost, globalNIdPre, globalNIdPost, connId, weight, maxWeight, delay, -1);
6765 connIt->numberOfConnections++;
6766 std::list<GroupConfigMD>::iterator grpIt;
6772 targetGrp.
gGrpId = gGrpIdPre;
6773 grpIt = std::find(groupPartitionLists[netIdPre].begin(), groupPartitionLists[netIdPre].end(), targetGrp);
6774 assert(grpIt != groupPartitionLists[netIdPre].end());
6775 grpIt->numPostSynapses += 1;
6777 targetGrp.
gGrpId = gGrpIdPost;
6778 grpIt = std::find(groupPartitionLists[netIdPre].begin(), groupPartitionLists[netIdPre].end(), targetGrp);
6779 assert(grpIt != groupPartitionLists[netIdPost].end());
6780 grpIt->numPreSynapses += 1;
6784 for (std::list<ConnectConfig>::iterator connIt = externalConnectLists[netIdPre].begin(); connIt != externalConnectLists[netIdPre].end() && (!connected); connIt++) {
6785 if (connIt->connId == connId) {
6787 connectNeurons(netIdPre, gGrpIdPre, gGrpIdPost, globalNIdPre, globalNIdPost, connId, weight, maxWeight, delay, netIdPost);
6790 connIt->numberOfConnections++;
6795 std::list<GroupConfigMD>::iterator grpIt;
6797 targetGrp.
gGrpId = gGrpIdPre;
6798 grpIt = std::find(groupPartitionLists[netIdPre].begin(), groupPartitionLists[netIdPre].end(), targetGrp);
6799 assert(grpIt != groupPartitionLists[netIdPre].end());
6800 grpIt->numPostSynapses += 1;
6802 targetGrp.
gGrpId = gGrpIdPost;
6803 grpIt = std::find(groupPartitionLists[netIdPre].begin(), groupPartitionLists[netIdPre].end(), targetGrp);
6804 assert(grpIt != groupPartitionLists[netIdPost].end());
6805 grpIt->numPreSynapses += 1;
6808 targetGrp.
gGrpId = gGrpIdPre;
6809 grpIt = std::find(groupPartitionLists[netIdPost].begin(), groupPartitionLists[netIdPost].end(), targetGrp);
6810 assert(grpIt != groupPartitionLists[netIdPost].end());
6811 grpIt->numPostSynapses += 1;
6813 targetGrp.
gGrpId = gGrpIdPost;
6814 grpIt = std::find(groupPartitionLists[netIdPost].begin(), groupPartitionLists[netIdPost].end(), targetGrp);
6815 assert(grpIt != groupPartitionLists[netIdPost].end());
6816 grpIt->numPreSynapses += 1;
6823 fseek(loadSimFID,file_position,SEEK_SET);
6828 void SNN::generateRuntimeSNN() {
6831 generateRuntimeGroupConfigs();
6834 generateRuntimeConnectConfigs();
6837 generateRuntimeNetworkConfigs();
6842 allocateManagerSpikeTables();
6848 allocateManagerRuntimeData();
6854 if (!groupPartitionLists[netId].empty()) {
6857 KERNEL_INFO(
"***************** Initializing GPU %d Runtime *************************", netId);
6864 for(
int lGrpId = 0; lGrpId < networkConfigs[netId].
numGroups; lGrpId++) {
6866 if (groupConfigs[netId][lGrpId].netId == netId && (groupConfigs[netId][lGrpId].Type &
POISSON_NEURON)) {
6870 generatePoissonGroupRuntime(netId, lGrpId);
6873 if (groupConfigs[netId][lGrpId].netId == netId && !(groupConfigs[netId][lGrpId].Type & POISSON_NEURON)) {
6878 generateGroupRuntime(netId, lGrpId);
6883 for (
int lNId = 0; lNId < networkConfigs[netId].
numNAssigned; lNId++) {
6884 managerRuntimeData.
grpIds[lNId] = -1;
6885 for(
int lGrpId = 0; lGrpId < networkConfigs[netId].
numGroupsAssigned; lGrpId++) {
6886 if (lNId >= groupConfigs[netId][lGrpId].lStartN && lNId <= groupConfigs[netId][lGrpId].lEndN) {
6887 managerRuntimeData.
grpIds[lNId] = (
short int)lGrpId;
6891 assert(managerRuntimeData.
grpIds[lNId] != -1);
6897 generateConnectionRuntime(netId);
6899 generateCompConnectionRuntime(netId);
6902 resetCurrent(netId);
6904 resetConductances(netId);
6908 resetSynapse(netId,
false);
6915 numGPUs = 0; numCores = 0;
6927 void SNN::resetConductances(
int netId) {
6928 #ifdef LN_I_CALC_TYPES 6930 if (networkConfigs[netId].sim_with_conductances) {
6931 memset(managerRuntimeData.
gAMPA, 0,
sizeof(
float) * networkConfigs[netId].
numNReg);
6932 memset(managerRuntimeData.
gNMDA_r, 0,
sizeof(
float) * networkConfigs[netId].
numNReg);
6933 memset(managerRuntimeData.
gNMDA_d, 0,
sizeof(
float) * networkConfigs[netId].
numNReg);
6934 memset(managerRuntimeData.
gNMDA, 0,
sizeof(
float) * networkConfigs[netId].
numNReg);
6935 memset(managerRuntimeData.
gGABAa, 0,
sizeof(
float) * networkConfigs[netId].
numNReg);
6936 memset(managerRuntimeData.
gGABAb_r, 0,
sizeof(
float) * networkConfigs[netId].
numNReg);
6937 memset(managerRuntimeData.
gGABAb_d, 0,
sizeof(
float) * networkConfigs[netId].
numNReg);
6938 memset(managerRuntimeData.
gGABAb, 0,
sizeof(
float) * networkConfigs[netId].
numNReg);
6941 if (networkConfigs[netId].sim_with_conductances) {
6942 memset(managerRuntimeData.
gAMPA, 0,
sizeof(
float) * networkConfigs[netId].
numNReg);
6943 if (networkConfigs[netId].sim_with_NMDA_rise) {
6944 memset(managerRuntimeData.
gNMDA_r, 0,
sizeof(
float) * networkConfigs[netId].
numNReg);
6945 memset(managerRuntimeData.
gNMDA_d, 0,
sizeof(
float) * networkConfigs[netId].
numNReg);
6947 memset(managerRuntimeData.
gNMDA, 0,
sizeof(
float) * networkConfigs[netId].
numNReg);
6949 memset(managerRuntimeData.
gGABAa, 0,
sizeof(
float) * networkConfigs[netId].
numNReg);
6950 if (networkConfigs[netId].sim_with_GABAb_rise) {
6951 memset(managerRuntimeData.
gGABAb_r, 0,
sizeof(
float) * networkConfigs[netId].
numNReg);
6952 memset(managerRuntimeData.
gGABAb_d, 0,
sizeof(
float) * networkConfigs[netId].
numNReg);
6954 memset(managerRuntimeData.
gGABAb, 0,
sizeof(
float) * networkConfigs[netId].
numNReg);
6960 void SNN::resetCurrent(
int netId) {
6961 assert(managerRuntimeData.
current != NULL);
6962 memset(managerRuntimeData.
current, 0,
sizeof(
float) * networkConfigs[netId].
numNReg);
6966 void SNN::resetFiringInformation() {
6975 resetPropogationBuffer();
6980 void SNN::resetTiming() {
6981 prevExecutionTime = cumExecutionTime;
6982 executionTime = 0.0f;
6985 void SNN::resetNeuromodulator(
int netId,
int lGrpId) {
6986 managerRuntimeData.
grpDA[lGrpId] = groupConfigs[netId][lGrpId].
baseDP;
6987 managerRuntimeData.
grp5HT[lGrpId] = groupConfigs[netId][lGrpId].
base5HT;
6988 managerRuntimeData.
grpACh[lGrpId] = groupConfigs[netId][lGrpId].
baseACh;
6989 managerRuntimeData.
grpNE[lGrpId] = groupConfigs[netId][lGrpId].
baseNE;
6995 void SNN::resetNeuron(
int netId,
int lGrpId,
int lNId) {
6996 int gGrpId = groupConfigs[netId][lGrpId].
gGrpId;
6997 assert(lNId < networkConfigs[netId].numNReg);
6999 if (groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_a == -1 && groupConfigMap[gGrpId].isLIF == 0) {
7000 KERNEL_ERROR(
"setNeuronParameters must be called for group %s (G:%d,L:%d)",groupConfigMap[gGrpId].grpName.c_str(), gGrpId, lGrpId);
7004 if (groupConfigMap[gGrpId].neuralDynamicsConfig.lif_tau_m == -1 && groupConfigMap[gGrpId].isLIF == 1) {
7005 KERNEL_ERROR(
"setNeuronParametersLIF must be called for group %s (G:%d,L:%d)",groupConfigMap[gGrpId].grpName.c_str(), gGrpId, lGrpId);
7009 managerRuntimeData.
Izh_a[lNId] = groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_a + groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_a_sd * (float)drand48();
7010 managerRuntimeData.
Izh_b[lNId] = groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_b + groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_b_sd * (float)drand48();
7011 managerRuntimeData.
Izh_c[lNId] = groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_c + groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_c_sd * (float)drand48();
7012 managerRuntimeData.
Izh_d[lNId] = groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_d + groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_d_sd * (float)drand48();
7013 managerRuntimeData.
Izh_C[lNId] = groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_C + groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_C_sd * (float)drand48();
7014 managerRuntimeData.
Izh_k[lNId] = groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_k + groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_k_sd * (float)drand48();
7015 managerRuntimeData.
Izh_vr[lNId] = groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_vr + groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_vr_sd * (float)drand48();
7016 managerRuntimeData.
Izh_vt[lNId] = groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_vt + groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_vt_sd * (float)drand48();
7017 managerRuntimeData.
Izh_vpeak[lNId] = groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_vpeak + groupConfigMap[gGrpId].neuralDynamicsConfig.Izh_vpeak_sd * (float)drand48();
7018 managerRuntimeData.
lif_tau_m[lNId] = groupConfigMap[gGrpId].neuralDynamicsConfig.lif_tau_m;
7019 managerRuntimeData.
lif_tau_ref[lNId] = groupConfigMap[gGrpId].neuralDynamicsConfig.lif_tau_ref;
7021 managerRuntimeData.
lif_vTh[lNId] = groupConfigMap[gGrpId].neuralDynamicsConfig.lif_vTh;
7022 managerRuntimeData.
lif_vReset[lNId] = groupConfigMap[gGrpId].neuralDynamicsConfig.lif_vReset;
7025 if (groupConfigs[netId][lGrpId].isLIF){
7027 float rmRange = (float)(groupConfigMap[gGrpId].neuralDynamicsConfig.lif_maxRmem - groupConfigMap[gGrpId].neuralDynamicsConfig.lif_minRmem);
7028 float minRmem = (float)groupConfigMap[gGrpId].neuralDynamicsConfig.lif_minRmem;
7029 managerRuntimeData.
lif_bias[lNId] = 0.0f;
7030 managerRuntimeData.
lif_gain[lNId] = minRmem + rmRange * (
float)drand48();
7036 if (groupConfigs[netId][lGrpId].WithHomeostasis) {
7038 if (drand48() > 0.5) {
7039 managerRuntimeData.
baseFiring[lNId] = groupConfigMap[gGrpId].homeoConfig.baseFiring + groupConfigMap[gGrpId].homeoConfig.baseFiringSD * -log(drand48());
7041 managerRuntimeData.
baseFiring[lNId] = groupConfigMap[gGrpId].homeoConfig.baseFiring - groupConfigMap[gGrpId].homeoConfig.baseFiringSD * -log(drand48());
7045 if (groupConfigMap[gGrpId].homeoConfig.baseFiring != 0.0f) {
7049 managerRuntimeData.
avgFiring[lNId] = 0.0f;
7055 if(groupConfigs[netId][lGrpId].WithSTP) {
7056 for (
int j = 0; j < networkConfigs[netId].
maxDelay + 1; j++) {
7057 int index =
STP_BUF_POS(lNId, j, networkConfigs[netId].maxDelay);
7058 managerRuntimeData.
stpu[index] = 0.0f;
7059 managerRuntimeData.
stpx[index] = 1.0f;
7064 void SNN::resetMonitors(
bool deallocate) {
7073 for (
int i=0; i<numSpikeMonitor; i++) {
7074 if (spikeMonList[i]!=NULL && deallocate)
delete spikeMonList[i];
7075 spikeMonList[i]=NULL;
7080 for (
int i = 0; i<numNeuronMonitor; i++) {
7081 if (neuronMonList[i] != NULL && deallocate)
delete neuronMonList[i];
7082 neuronMonList[i] = NULL;
7087 for (
int i=0; i<numGroupMonitor; i++) {
7088 if (groupMonList[i]!=NULL && deallocate)
delete groupMonList[i];
7089 groupMonList[i]=NULL;
7094 for (
int i=0; i<numConnectionMonitor; i++) {
7095 if (connMonList[i]!=NULL && deallocate)
delete connMonList[i];
7096 connMonList[i]=NULL;
7100 void SNN::resetGroupConfigs(
bool deallocate) {
7102 if (deallocate) groupConfigMap.clear();
7105 void SNN::resetConnectionConfigs(
bool deallocate) {
7107 if (deallocate) connectConfigMap.clear();
7110 void SNN::deleteManagerRuntimeData() {
7111 if (spikeBuf!=NULL)
delete spikeBuf;
7116 if (managerRuntimeData.
randNum!=NULL) {
7117 delete[] managerRuntimeData.
randNum;
7118 managerRuntimeData.
randNum = NULL;
7126 if (managerRuntimeData.
grpDA != NULL)
delete [] managerRuntimeData.
grpDA;
7127 if (managerRuntimeData.
grp5HT != NULL)
delete [] managerRuntimeData.
grp5HT;
7128 if (managerRuntimeData.
grpACh != NULL)
delete [] managerRuntimeData.
grpACh;
7129 if (managerRuntimeData.
grpNE != NULL)
delete [] managerRuntimeData.
grpNE;
7130 managerRuntimeData.
grpDA = NULL;
7131 managerRuntimeData.
grp5HT = NULL;
7132 managerRuntimeData.
grpACh = NULL;
7133 managerRuntimeData.
grpNE = NULL;
7145 if (managerRuntimeData.
voltage!=NULL)
delete[] managerRuntimeData.
voltage;
7147 if (managerRuntimeData.
recovery!=NULL)
delete[] managerRuntimeData.
recovery;
7148 if (managerRuntimeData.
current!=NULL)
delete[] managerRuntimeData.
current;
7151 if (managerRuntimeData.
curSpike != NULL)
delete[] managerRuntimeData.
curSpike;
7152 if (managerRuntimeData.
nVBuffer != NULL)
delete[] managerRuntimeData.
nVBuffer;
7153 if (managerRuntimeData.
nUBuffer != NULL)
delete[] managerRuntimeData.
nUBuffer;
7154 if (managerRuntimeData.
nIBuffer != NULL)
delete[] managerRuntimeData.
nIBuffer;
7159 if (managerRuntimeData.
Izh_a!=NULL)
delete[] managerRuntimeData.
Izh_a;
7160 if (managerRuntimeData.
Izh_b!=NULL)
delete[] managerRuntimeData.
Izh_b;
7161 if (managerRuntimeData.
Izh_c!=NULL)
delete[] managerRuntimeData.
Izh_c;
7162 if (managerRuntimeData.
Izh_d!=NULL)
delete[] managerRuntimeData.
Izh_d;
7163 if (managerRuntimeData.
Izh_C!=NULL)
delete[] managerRuntimeData.
Izh_C;
7164 if (managerRuntimeData.
Izh_k!=NULL)
delete[] managerRuntimeData.
Izh_k;
7165 if (managerRuntimeData.
Izh_vr!=NULL)
delete[] managerRuntimeData.
Izh_vr;
7166 if (managerRuntimeData.
Izh_vt!=NULL)
delete[] managerRuntimeData.
Izh_vt;
7168 managerRuntimeData.
Izh_a=NULL; managerRuntimeData.
Izh_b=NULL; managerRuntimeData.
Izh_c=NULL; managerRuntimeData.
Izh_d=NULL;
7169 managerRuntimeData.
Izh_C = NULL; managerRuntimeData.
Izh_k = NULL; managerRuntimeData.
Izh_vr = NULL; managerRuntimeData.
Izh_vt = NULL; managerRuntimeData.
Izh_vpeak = NULL;
7174 if (managerRuntimeData.
lif_vTh!=NULL)
delete[] managerRuntimeData.
lif_vTh;
7176 if (managerRuntimeData.
lif_gain!=NULL)
delete[] managerRuntimeData.
lif_gain;
7177 if (managerRuntimeData.
lif_bias!=NULL)
delete[] managerRuntimeData.
lif_bias;
7182 if (managerRuntimeData.
Npre!=NULL)
delete[] managerRuntimeData.
Npre;
7184 if (managerRuntimeData.
Npost!=NULL)
delete[] managerRuntimeData.
Npost;
7191 if (managerRuntimeData.
gAMPA!=NULL)
delete[] managerRuntimeData.
gAMPA;
7192 if (managerRuntimeData.
gNMDA!=NULL)
delete[] managerRuntimeData.
gNMDA;
7193 if (managerRuntimeData.
gNMDA_r!=NULL)
delete[] managerRuntimeData.
gNMDA_r;
7194 if (managerRuntimeData.
gNMDA_d!=NULL)
delete[] managerRuntimeData.
gNMDA_d;
7195 if (managerRuntimeData.
gGABAa!=NULL)
delete[] managerRuntimeData.
gGABAa;
7196 if (managerRuntimeData.
gGABAb!=NULL)
delete[] managerRuntimeData.
gGABAb;
7197 if (managerRuntimeData.
gGABAb_r!=NULL)
delete[] managerRuntimeData.
gGABAb_r;
7198 if (managerRuntimeData.
gGABAb_d!=NULL)
delete[] managerRuntimeData.
gGABAb_d;
7199 managerRuntimeData.
gAMPA=NULL; managerRuntimeData.
gNMDA=NULL; managerRuntimeData.
gNMDA_r=NULL; managerRuntimeData.
gNMDA_d=NULL;
7202 if (managerRuntimeData.
stpu!=NULL)
delete[] managerRuntimeData.
stpu;
7203 if (managerRuntimeData.
stpx!=NULL)
delete[] managerRuntimeData.
stpx;
7204 managerRuntimeData.
stpu=NULL; managerRuntimeData.
stpx=NULL;
7220 if (managerRuntimeData.
wt!=NULL)
delete[] managerRuntimeData.
wt;
7221 if (managerRuntimeData.
maxSynWt!=NULL)
delete[] managerRuntimeData.
maxSynWt;
7222 if (managerRuntimeData.
wtChange !=NULL)
delete[] managerRuntimeData.
wtChange;
7223 managerRuntimeData.
wt=NULL; managerRuntimeData.
maxSynWt=NULL; managerRuntimeData.
wtChange=NULL;
7225 if (mulSynFast!=NULL)
delete[] mulSynFast;
7226 if (mulSynSlow!=NULL)
delete[] mulSynSlow;
7228 mulSynFast=NULL; mulSynSlow=NULL; managerRuntimeData.
connIdsPreIdx=NULL;
7230 if (managerRuntimeData.
grpIds!=NULL)
delete[] managerRuntimeData.
grpIds;
7231 managerRuntimeData.
grpIds=NULL;
7243 #ifdef LN_AXON_PLAST 7264 void SNN::resetPoissonNeuron(
int netId,
int lGrpId,
int lNId) {
7265 assert(lNId < networkConfigs[netId].numN);
7267 if (groupConfigs[netId][lGrpId].WithHomeostasis)
7268 managerRuntimeData.
avgFiring[lNId] = 0.0f;
7270 if (groupConfigs[netId][lGrpId].WithSTP) {
7271 for (
int j = 0; j < networkConfigs[netId].
maxDelay + 1; j++) {
7272 int index =
STP_BUF_POS(lNId, j, networkConfigs[netId].maxDelay);
7273 managerRuntimeData.
stpu[index] = 0.0f;
7274 managerRuntimeData.
stpx[index] = 1.0f;
7279 void SNN::resetPropogationBuffer() {
7281 spikeBuf->
reset(0, 1023);
7289 void SNN::resetSynapse(
int netId,
bool changeWeights) {
7292 for (
int syn = 0; syn < networkConfigs[netId].
numPreSynNet; syn++)
7296 void SNN::resetTimeTable() {
7297 memset(managerRuntimeData.
timeTableD2, 0,
sizeof(
int) * (1000 + glbNetworkConfig.
maxDelay + 1));
7298 memset(managerRuntimeData.
timeTableD1, 0,
sizeof(
int) * (1000 + glbNetworkConfig.
maxDelay + 1));
7301 void SNN::resetFiringTable() {
7302 memset(managerRuntimeData.
firingTableD2, 0,
sizeof(
int) * managerRTDSize.maxMaxSpikeD2);
7303 memset(managerRuntimeData.
firingTableD1, 0,
sizeof(
int) * managerRTDSize.maxMaxSpikeD1);
7304 #ifdef LN_AXON_PLAST 7305 memset(managerRuntimeData.
firingTimesD2, 0,
sizeof(
unsigned int) * managerRTDSize.maxMaxSpikeD2);
7309 memset(managerRuntimeData.
extFiringTableD2, 0,
sizeof(
int*) * managerRTDSize.maxNumGroups);
7310 memset(managerRuntimeData.
extFiringTableD1, 0,
sizeof(
int*) * managerRTDSize.maxNumGroups);
7313 void SNN::resetSpikeCnt(
int gGrpId) {
7314 assert(gGrpId >=
ALL);
7316 if (gGrpId ==
ALL) {
7317 #ifndef __NO_PTHREADS__ // POSIX 7318 pthread_t threads[numCores + 1];
7321 int threadCount = 0;
7325 if (!groupPartitionLists[netId].empty()) {
7327 resetSpikeCnt_GPU(netId,
ALL);
7329 #ifdef __NO_PTHREADS__ 7330 resetSpikeCnt_CPU(netId,
ALL);
7331 #else // Linux or MAC 7332 pthread_attr_t attr;
7333 pthread_attr_init(&attr);
7336 pthread_attr_setaffinity_np(&attr,
sizeof(cpu_set_t), &cpus);
7338 argsThreadRoutine[threadCount].
snn_pointer =
this;
7339 argsThreadRoutine[threadCount].
netId = netId;
7340 argsThreadRoutine[threadCount].
lGrpId =
ALL;
7341 argsThreadRoutine[threadCount].
startIdx = 0;
7342 argsThreadRoutine[threadCount].
endIdx = 0;
7343 argsThreadRoutine[threadCount].
GtoLOffset = 0;
7345 pthread_create(&threads[threadCount], &attr, &SNN::helperResetSpikeCnt_CPU, (
void*)&argsThreadRoutine[threadCount]);
7346 pthread_attr_destroy(&attr);
7353 #ifndef __NO_PTHREADS__ // POSIX 7355 for (
int i=0; i<threadCount; i++){
7356 pthread_join(threads[i], NULL);
7361 int netId = groupConfigMDMap[gGrpId].netId;
7362 int lGrpId = groupConfigMDMap[gGrpId].lGrpId;
7365 resetSpikeCnt_GPU(netId, lGrpId);
7367 resetSpikeCnt_CPU(netId, lGrpId);
7373 inline SynInfo SNN::SET_CONN_ID(
int nId,
int sId,
int grpId) {
7389 void SNN::setGrpTimeSlice(
int gGrpId,
int timeSlice) {
7390 if (gGrpId ==
ALL) {
7391 for(
int grpId = 0; grpId < numGroups; grpId++) {
7392 if (groupConfigMap[grpId].isSpikeGenerator)
7393 setGrpTimeSlice(grpId, timeSlice);
7398 groupConfigMDMap[gGrpId].currTimeSlice = timeSlice;
7403 int SNN::setRandSeed(
int seed) {
7412 void SNN::fillSpikeGenBits(
int netId) {
7417 for (spikeBufIter = spikeBuf->
front(); spikeBufIter != spikeBufIterEnd; ++spikeBufIter) {
7419 int gGrpId = spikeBufIter->
grpId;
7421 if (groupConfigMDMap[gGrpId].netId == netId) {
7422 int lGrpId = groupConfigMDMap[gGrpId].lGrpId;
7423 int lNId = spikeBufIter->
neurId + groupConfigMDMap[gGrpId].GtoLOffset;
7426 assert(groupConfigMap[gGrpId].isSpikeGenerator ==
true);
7428 int nIdPos = (lNId - groupConfigs[netId][lGrpId].
lStartN + groupConfigs[netId][lGrpId].
Noffset);
7429 int nIdBitPos = nIdPos % 32;
7430 int nIdIndex = nIdPos / 32;
7432 assert(nIdIndex < (networkConfigs[netId].numNSpikeGen / 32 + 1));
7434 managerRuntimeData.
spikeGenBits[nIdIndex] |= (1 << nIdBitPos);
7439 void SNN::startTiming() { prevExecutionTime = cumExecutionTime; }
7440 void SNN::stopTiming() {
7441 executionTime += (cumExecutionTime - prevExecutionTime);
7442 prevExecutionTime = cumExecutionTime;
7451 if (shallUpdateWeights && !sim_in_testing) {
7453 if (wtANDwtChangeUpdateIntervalCnt_) {
7454 float storeScaleSTDP = stdpScaleFactor_;
7455 stdpScaleFactor_ = 1.0f/wtANDwtChangeUpdateIntervalCnt_;
7459 stdpScaleFactor_ = storeScaleSTDP;
7463 sim_in_testing =
true;
7466 if (!groupPartitionLists[netId].empty()) {
7468 updateNetworkConfig(netId);
7475 sim_in_testing =
false;
7478 if (!groupPartitionLists[netId].empty()) {
7480 updateNetworkConfig(netId);
7486 for (
int monId=0; monId<numConnectionMonitor; monId++) {
7489 if (timeInterval==1 || timeInterval>1 && (
getSimTime()%timeInterval)==0) {
7500 assert(connId >
ALL);
7501 std::vector< std::vector<float> > wtConnId;
7503 int grpIdPre = connectConfigMap[connId].grpSrc;
7504 int grpIdPost = connectConfigMap[connId].grpDest;
7506 int netIdPost = groupConfigMDMap[grpIdPost].netId;
7507 int lGrpIdPost = groupConfigMDMap[grpIdPost].lGrpId;
7510 for (
int i = 0; i < groupConfigMap[grpIdPre].numN; i++) {
7511 std::vector<float> wtSlice;
7512 for (
int j = 0; j < groupConfigMap[grpIdPost].numN; j++) {
7513 wtSlice.push_back(NAN);
7515 wtConnId.push_back(wtSlice);
7522 assert(grpIdPost >
ALL);
7525 fetchWeightState(netIdPost, lGrpIdPost);
7526 fetchConnIdsLookupArray(netIdPost);
7528 for (
int lNIdPost = groupConfigs[netIdPost][lGrpIdPost].lStartN; lNIdPost <= groupConfigs[netIdPost][lGrpIdPost].
lEndN; lNIdPost++) {
7529 unsigned int pos_ij = managerRuntimeData.
cumulativePre[lNIdPost];
7530 for (
int i = 0; i < managerRuntimeData.
Npre[lNIdPost]; i++, pos_ij++) {
7538 wtConnId[lNIdPre - groupConfigs[netIdPost][lGrpIdPre].
lStartN][lNIdPost - groupConfigs[netIdPost][lGrpIdPost].
lStartN] =
7539 fabs(managerRuntimeData.
wt[pos_ij]);
7548 if (!numGroupMonitor)
7551 if (gGrpId ==
ALL) {
7552 for (
int gGrpId = 0; gGrpId < numGroups; gGrpId++)
7555 int netId = groupConfigMDMap[gGrpId].netId;
7556 int lGrpId = groupConfigMDMap[gGrpId].lGrpId;
7559 int monitorId = groupConfigMDMap[gGrpId].groupMonitorId;
7562 if (monitorId < 0)
return;
7573 KERNEL_ERROR(
"updateGroupMonitor(grpId=%d) must be called at least once every second", gGrpId);
7576 fetchGroupState(netId, lGrpId);
7582 int numMsMin = lastUpdate % 1000;
7586 assert(numMsMin < numMsMax);
7599 bool writeGroupToFile = grpFileId != NULL;
7600 bool writeGroupToArray = grpMonObj->
isRecording();
7604 float data[4] = {.0f, .0f, .0f, .0f};
7614 for(
int t = numMsMin; t < numMsMax; t++) {
7616 data[0] = managerRuntimeData.
grpDABuffer[lGrpId * 1000 + t];
7619 #define LN_FIX_GRP_ALL_BUFFER 7620 data[1] = managerRuntimeData.
grp5HTBuffer[lGrpId * 1000 + t];
7622 data[2] = managerRuntimeData.
grpAChBuffer[lGrpId * 1000 + t];
7624 data[3] = managerRuntimeData.
grpNEBuffer[lGrpId * 1000 + t];
7627 int time = currentTimeSec * 1000 + t;
7629 if (writeGroupToFile) {
7633 cnt = fwrite(&time,
sizeof(
int), 1, grpFileId); assert(cnt==1);
7634 cnt = fwrite(&data,
sizeof(
float), nTransM, grpFileId); assert(cnt==nTransM);
7638 if (writeGroupToArray) {
7640 grpMonObj->
pushData(time, data[0], data[1], data[2], data[3]);
7642 grpMonObj->
pushData(time, data[0]);
7646 if (grpFileId!=NULL)
7652 void SNN::userDefinedSpikeGenerator(
int gGrpId) {
7655 int netId = groupConfigMDMap[gGrpId].netId;
7656 int timeSlice = groupConfigMDMap[gGrpId].currTimeSlice;
7657 int currTime = simTime;
7660 fetchLastSpikeTime(netId);
7662 for(
int gNId = groupConfigMDMap[gGrpId].gStartN; gNId <= groupConfigMDMap[gGrpId].gEndN; gNId++) {
7664 int lNId = gNId + groupConfigMDMap[gGrpId].GtoLOffset;
7671 int endOfTimeWindow = std::min<int>(currTime+timeSlice, simTimeRunStop);
7676 int nextSchedTime = spikeGenFunc->
nextSpikeTime(
this, gGrpId, gNId - groupConfigMDMap[gGrpId].gStartN, currTime, nextTime, endOfTimeWindow);
7683 if ((nextSchedTime==0 || nextSchedTime>nextTime) && nextSchedTime<endOfTimeWindow && nextSchedTime>=currTime) {
7688 nextTime = nextSchedTime;
7689 spikeBuf->
schedule(gNId, gGrpId, nextTime - currTime);
7697 void SNN::generateUserDefinedSpikes() {
7698 for(
int gGrpId = 0; gGrpId < numGroups; gGrpId++) {
7699 if (groupConfigMap[gGrpId].isSpikeGenerator) {
7705 if(((simTime - groupConfigMDMap[gGrpId].sliceUpdateTime) >= groupConfigMDMap[gGrpId].currTimeSlice || simTime == simTimeRunStart)) {
7706 int timeSlice = groupConfigMDMap[gGrpId].currTimeSlice;
7707 groupConfigMDMap[gGrpId].sliceUpdateTime = simTime;
7714 if (groupConfigMap[gGrpId].spikeGenFunc != NULL) {
7715 userDefinedSpikeGenerator(gGrpId);
7727 void SNN::allocateManagerSpikeTables() {
7728 managerRuntimeData.
firingTableD2 =
new int[managerRTDSize.maxMaxSpikeD2];
7729 managerRuntimeData.
firingTableD1 =
new int[managerRTDSize.maxMaxSpikeD1];
7731 #ifdef LN_AXON_PLAST 7732 managerRuntimeData.
firingTimesD2 =
new unsigned int[managerRTDSize.maxMaxSpikeD2];
7737 managerRuntimeData.
extFiringTableD2 =
new int*[managerRTDSize.maxNumGroups];
7738 managerRuntimeData.
extFiringTableD1 =
new int*[managerRTDSize.maxNumGroups];
7754 bool SNN::updateTime() {
7755 bool finishedOneSec =
false;
7759 if(++simTimeMs == 1000) {
7762 finishedOneSec =
true;
7768 KERNEL_WARN(
"Maximum Simulation Time Reached...Resetting simulation time");
7771 return finishedOneSec;
7774 #ifdef LN_UPDATE_CURSPIKES 7777 void SNN::updateCurSpike(std::vector<bool>& gFiring,
int netId) {
7781 if (!groupPartitionLists[
id].empty())
7782 updateCurSpike(gFiring,
id);
7786 int regLength = networkConfigs[netId].
numNReg;
7787 assert(gFiring.size() >= regLength);
7790 assert(gFiring.size() >= regLength + genLength);
7792 int nPois = networkConfigs[netId].
numNPois;
7793 int poisLength = nPois - genLength;
7794 assert(gFiring.size() >= regLength + poisLength);
7796 assert(networkConfigs[netId].numN >= regLength + genLength + poisLength);
7798 int rateGenLength = networkConfigs[netId].
numNRateGen;
7800 int length = networkConfigs[netId].
numN;
7801 std::vector<bool> lFiring(length,
false);
7803 #ifdef DEBUG_UPDATE_CURSPIKES 7804 printf(
"numN: %d numNReg:%d numNPois:%d numNSpikeGen:%d numNPoisGen:%d\n",
7805 length, regLength, poisLength, genLength, rateGenLength);
7809 fetchCurSpike(netId);
7812 if (poisLength > 0) {
7813 fetchRandNum(netId);
7814 fetchPoissonFireRate(netId);
7818 if (genLength > 0) {
7819 fetchSpikeGenBits(netId);
7823 if (genLength > 0) {
7824 #ifdef DEBUG_UPDATE_CURSPIKES 7825 printf(
"SpikGen: %d, Spikes (t=%01d.%03ds): ", regLength, simTimeMs / 1000, simTimeMs);
7827 for (
int lNId = regLength; lNId < genLength + regLength; lNId++) {
7828 const int nIdPos = lNId - regLength;
7830 const int nIdBitPos = nIdPos % 32;
7831 const int nIdIndex = nIdPos / 32;
7832 bool fired = ((managerRuntimeData.
spikeGenBits[nIdIndex] >> nIdBitPos) & 0x1);
7833 lFiring[lNId] = fired;
7834 #ifdef DEBUG_UPDATE_CURSPIKES 7835 printf(
"%s", fired ?
"^" :
"-");
7838 #ifdef DEBUG_UPDATE_CURSPIKES 7843 if (poisLength > 0) {
7844 #ifdef DEBUG_UPDATE_CURSPIKES 7845 printf(
"Poisson: %d, Spikes (t=%01d.%03ds): ", regLength, simTimeMs / 1000, simTimeMs);
7847 for (
int lNId = regLength + genLength; lNId < regLength + genLength + poisLength; lNId++) {
7849 bool fired = managerRuntimeData.
randNum[lNId - regLength] * 1000.0f
7851 lFiring[lNId] = fired;
7852 #ifdef DEBUG_UPDATE_CURSPIKES 7853 printf(
"%s", fired ?
"^" :
"-");
7856 #ifdef DEBUG_UPDATE_CURSPIKES 7861 #ifdef DEBUG_UPDATE_CURSPIKES 7862 printf(
"Regular: %d, Spikes (t=%01d.%03ds): ", regLength, simTimeMs / 1000, simTimeMs);
7865 for (
int lNId = 0; lNId < regLength; lNId++) {
7866 bool fired = managerRuntimeData.
curSpike[lNId];
7867 lFiring[lNId] = fired;
7868 #ifdef DEBUG_UPDATE_CURSPIKES 7869 printf(
"%s", fired ?
"^" :
"-");
7872 #ifdef DEBUG_UPDATE_CURSPIKES 7878 for (
auto iter = groupConfigMDMap.begin(); iter != groupConfigMDMap.end(); iter++) {
7879 int gGrpId = iter->first;
7881 if (groupConfig.
netId == netId) {
7883 lNId <= groupConfig.
lEndN && gNId <= groupConfig.
gEndN;
7886 assert(gNId == lNId + groupConfig.
LtoGOffset);
7887 assert(lNId == gNId + groupConfig.
GtoLOffset);
7888 gFiring[gNId] = lFiring[lNId];
7897 #ifdef LN_UPDATE_CURSPIKES_MT 7908 void SNN::updateCurSpikeMT(std::vector<bool>& gFiring,
int netId) {
7921 int regLength = networkConfigs[netId].
numNReg;
7922 assert(gFiring.size() >= regLength);
7925 assert(gFiring.size() >= regLength + genLength);
7927 int nPois = networkConfigs[netId].
numNPois;
7928 int poisLength = nPois - genLength;
7929 assert(gFiring.size() >= regLength + poisLength);
7931 assert(networkConfigs[netId].numN >= regLength + genLength + poisLength);
7933 int rateGenLength = networkConfigs[netId].
numNRateGen;
7935 int length = networkConfigs[netId].
numN;
7936 std::vector<bool> lFiring(length,
false);
7938 #ifdef DEBUG_UPDATE_CURSPIKES_MT 7939 printf(
"numN: %d numNReg:%d numNPois:%d numNSpikeGen:%d numNPoisGen:%d\n",
7940 length, regLength, poisLength, genLength, rateGenLength);
7944 fetchCurSpike(netId);
7947 if (poisLength > 0) {
7948 fetchRandNum(netId);
7949 fetchPoissonFireRate(netId);
7953 if (genLength > 0) {
7954 fetchSpikeGenBits(netId);
7957 std::vector<std::thread> gen_workers(genLength);
7958 std::vector<std::thread> pois_workers(poisLength);
7959 std::vector<std::thread> reg_workers(regLength);
7961 if (genLength > 0) {
7962 for (
int lNId = regLength; lNId < genLength + regLength; lNId++) {
7963 auto worker = [&, lNId]() {
7964 const int nIdPos = lNId - regLength;
7966 const int nIdBitPos = nIdPos % 32;
7967 const int nIdIndex = nIdPos / 32;
7968 bool fired = ((managerRuntimeData.
spikeGenBits[nIdIndex] >> nIdBitPos) & 0x1);
7969 #ifdef DEBUG_UPDATE_CURSPIKES_MT_TIMING 7970 std::this_thread::sleep_for(std::chrono::seconds(2));
7972 lFiring[lNId] = fired;
7974 gen_workers[lNId-regLength] = std::thread(worker);
7976 assert(gen_workers.size() == genLength);
7980 for (
int lNId = regLength + genLength; lNId<regLength + genLength + poisLength; lNId++) {
7981 auto worker = [&, lNId]() {
7983 bool fired = managerRuntimeData.
randNum[lNId - regLength] * 1000.0f
7985 #ifdef DEBUG_UPDATE_CURSPIKES_MT_TIMING 7986 std::this_thread::sleep_for(std::chrono::seconds(8));
7988 lFiring[lNId] = fired;
7990 pois_workers[lNId - regLength - genLength] = std::thread(worker);
7992 assert(pois_workers.size() == poisLength);
7995 if (regLength > 0) {
7996 for (
int lNId = 0; lNId < regLength; lNId++) {
7997 auto worker = [&, lNId]() {
7998 bool fired = managerRuntimeData.
curSpike[lNId];
7999 #ifdef DEBUG_UPDATE_CURSPIKES_MT_TIMING 8000 std::this_thread::sleep_for(std::chrono::seconds(10));
8002 lFiring[lNId] = fired;
8004 reg_workers[lNId] = std::thread(worker);
8006 assert(reg_workers.size() == regLength);
8010 for (
int lNId = regLength; lNId < genLength + regLength; lNId++)
8011 gen_workers[lNId-regLength].join();
8013 for (
int lNId = regLength + genLength; lNId<regLength + genLength + poisLength; lNId++)
8014 pois_workers[lNId - regLength - genLength].join();
8016 for (
int lNId = 0; lNId<regLength; lNId++)
8017 reg_workers[lNId].join();
8021 #ifdef DEBUG_UPDATE_CURSPIKES_MT 8022 if (genLength > 0) {
8023 printf(
"SpikGen: %d, Spikes (t=%01d.%03ds): ", regLength, simTimeMs / 1000, simTimeMs);
8024 for (
int lNId = regLength; lNId < genLength + regLength; lNId++)
8025 printf(
"%s", lFiring[lNId] ?
"^" :
"-");
8028 if (poisLength > 0) {
8029 printf(
"Poisson: %d, Spikes (t=%01d.%03ds): ", regLength, simTimeMs / 1000, simTimeMs);
8030 for (
int lNId = regLength + genLength; lNId < regLength + genLength + poisLength; lNId++)
8031 printf(
"%s", lFiring[lNId] ?
"^" :
"-");
8034 if (regLength > 0) {
8035 printf(
"Regular: %d, Spikes (t=%01d.%03ds): ", regLength, simTimeMs / 1000, simTimeMs);
8036 for (
int lNId = 0; lNId < regLength; lNId++)
8037 printf(
"%s", lFiring[lNId] ?
"^" :
"-");
8045 std::vector<std::thread> map_workers(groupConfigMDMap.size());
8046 for (
auto iter = groupConfigMDMap.begin(); iter != groupConfigMDMap.end(); iter++) {
8047 auto worker = [&, iter]() {
8048 int gGrpId = iter->first;
8050 if (groupConfig.
netId == netId) {
8052 lNId <= groupConfig.
lEndN && gNId <= groupConfig.
gEndN;
8055 assert(gNId == lNId + groupConfig.
LtoGOffset);
8056 assert(lNId == gNId + groupConfig.
GtoLOffset);
8057 #ifdef DEBUG_UPDATE_CURSPIKES_MT_MAP_TIMING 8059 std::this_thread::sleep_for(std::chrono::milliseconds(lNId));
8061 gFiring[gNId] = lFiring[lNId];
8065 #ifdef DEBUG_UPDATE_CURSPIKES_MT_MAP_SEQ 8068 map_workers[threadIdx++] = std::thread(worker);
8071 #ifndef DEBUG_UPDATE_CURSPIKES_MT_MAP_SEQ 8072 assert(threadIdx == groupConfigMDMap.size());
8073 for(threadIdx=0; threadIdx<map_workers.size(); threadIdx++)
8074 map_workers[threadIdx].join();
8079 #endif //CURSPIKES_MT 8082 #ifdef LN_AXON_PLAST 8083 void SNN::findWavefrontPath(std::vector<int>& path, std::vector<float>& eligibility,
int netId,
int grpId,
int startNId,
int goalNId) {
8087 findWavefrontPath_CPU(path, eligibility, netId, grpId, startNId, goalNId);
8093 bool SNN::updateDelays(
int gGrpIdPre,
int gGrpIdPost, std::vector<std::tuple<int, int, uint8_t>> connDelays) {
8094 int netIdPre = groupConfigMDMap[gGrpIdPre].netId;
8095 int netIdPost = groupConfigMDMap[gGrpIdPost].netId;
8096 assert(netIdPre == netIdPost);
8097 int netId = netIdPre;
8098 int lGrpIdPost = groupConfigMDMap[gGrpIdPost].lGrpId;
8100 for (
int lGrpId = 0; lGrpId < networkConfigs[netIdPost].
numGroupsAssigned; lGrpId++)
8101 if (groupConfigs[netIdPost][lGrpId].gGrpId == gGrpIdPre) {
8105 assert(lGrpIdPre != -1);
8107 bool success =
false;
8109 success = updateDelays_GPU(netId, lGrpIdPre, lGrpIdPost, connDelays);
8111 success = updateDelays_CPU(netId, lGrpIdPre, lGrpIdPost, connDelays);
8119 int netIdPre = groupConfigMDMap[gGrpIdPre].netId;
8120 int netIdPost = groupConfigMDMap[gGrpIdPost].netId;
8121 assert(netIdPre == netIdPost);
8122 int netId = netIdPre;
8123 int lGrpIdPost = groupConfigMDMap[gGrpIdPost].lGrpId;
8125 for (
int lGrpId = 0; lGrpId < networkConfigs[netIdPost].
numGroupsAssigned; lGrpId++)
8126 if (groupConfigs[netIdPost][lGrpId].gGrpId == gGrpIdPre) {
8130 assert(lGrpIdPre != -1);
8133 printEntrails_GPU(buffer, length, netId, lGrpIdPre, lGrpIdPost);
8136 printEntrails_CPU(buffer, length, netId, lGrpIdPre, lGrpIdPost);
8147 if (!numSpikeMonitor)
8150 if (gGrpId ==
ALL) {
8151 for (
int gGrpId = 0; gGrpId < numGroups; gGrpId++)
8154 int netId = groupConfigMDMap[gGrpId].netId;
8155 int lGrpId = groupConfigMDMap[gGrpId].lGrpId;
8158 int monitorId = groupConfigMDMap[gGrpId].spikeMonitorId;
8161 if (monitorId < 0)
return;
8168 if ( ((
long int)
getSimTime()) - lastUpdate <= 0)
8171 if ( ((
long int)
getSimTime()) - lastUpdate > 1000)
8172 KERNEL_ERROR(
"updateSpikeMonitor(grpId=%d) must be called at least once every second",gGrpId);
8186 fetchSpikeTables(netId);
8187 fetchGrpIdsLookupArray(netId);
8193 int numMsMin = lastUpdate % 1000;
8197 assert(numMsMin < numMsMax);
8210 bool writeSpikesToFile = spkFileId != NULL;
8215 for (
int k = 0; k < 2; k++) {
8218 for(
int t = numMsMin; t < numMsMax; t++) {
8219 for(
auto i = timeTablePtr[t + glbNetworkConfig.
maxDelay]; i < timeTablePtr[t + glbNetworkConfig.
maxDelay + 1]; i++) {
8221 int lNId = fireTablePtr[i];
8224 int this_grpId = managerRuntimeData.
grpIds[lNId];
8225 if (this_grpId != lGrpId)
8231 int nId = lNId - groupConfigs[netId][lGrpId].
lStartN;
8235 int time = currentTimeSec * 1000 + t;
8237 if (writeSpikesToFile) {
8239 cnt = fwrite(&time,
sizeof(
int), 1, spkFileId); assert(cnt==1);
8240 cnt = fwrite(&nId,
sizeof(
int), 1, spkFileId); assert(cnt==1);
8243 if (writeSpikesToArray) {
8244 spkMonObj->
pushAER(time, nId);
8250 if (spkFileId!=NULL)
8258 if (!numNeuronMonitor)
8263 if (gGrpId ==
ALL) {
8264 for (
int gGrpId = 0; gGrpId < numGroups; gGrpId++)
8269 int netId = groupConfigMDMap[gGrpId].netId;
8270 int lGrpId = groupConfigMDMap[gGrpId].lGrpId;
8273 int monitorId = groupConfigMDMap[gGrpId].neuronMonitorId;
8276 if (monitorId < 0)
return;
8283 if (((
long int)
getSimTime()) - lastUpdate <= 0)
8286 if (((
long int)
getSimTime()) - lastUpdate > 1000)
8287 KERNEL_ERROR(
"updateNeuronMonitor(grpId=%d) must be called at least once every second", gGrpId);
8302 fetchNeuronStateBuffer(netId, lGrpId);
8308 int numMsMin = lastUpdate % 1000;
8312 assert(numMsMin < numMsMax);
8326 bool writeNeuronStateToFile = nrnFileId != NULL;
8327 bool writeNeuronStateToArray = nrnMonObj->
isRecording();
8332 for (
int t = numMsMin; t < numMsMax; t++) {
8333 int grpNumNeurons = groupConfigs[netId][lGrpId].
lEndN - groupConfigs[netId][lGrpId].
lStartN + 1;
8337 int lNId = groupConfigs[netId][lGrpId].
lStartN + tmpNId;
8341 int this_grpId = managerRuntimeData.
grpIds[lNId];
8342 if (this_grpId != lGrpId)
8348 int nId = lNId - groupConfigs[netId][lGrpId].
lStartN;
8352 v = managerRuntimeData.
nVBuffer[idxBase + nId];
8353 u = managerRuntimeData.
nUBuffer[idxBase + nId];
8354 I = managerRuntimeData.
nIBuffer[idxBase + nId];
8359 int time = currentTimeSec * 1000 + t;
8364 if (writeNeuronStateToFile) {
8367 cnt = fwrite(&time,
sizeof(
int), 1, nrnFileId); assert(cnt == 1);
8368 cnt = fwrite(&nId,
sizeof(
int), 1, nrnFileId); assert(cnt == 1);
8369 cnt = fwrite(&v,
sizeof(
float), 1, nrnFileId); assert(cnt == 1);
8370 cnt = fwrite(&u,
sizeof(
float), 1, nrnFileId); assert(cnt == 1);
8371 cnt = fwrite(&I,
sizeof(
float), 1, nrnFileId); assert(cnt == 1);
8374 if (writeNeuronStateToArray) {
8381 if (nrnFileId != NULL)
8387 void SNN::printSimSummary() {
8392 etime = executionTime;
8394 fetchNetworkSpikeCount();
8397 KERNEL_INFO(
"******************** Simulation Summary ***************************");
8399 KERNEL_INFO(
"Network Parameters: \tnumNeurons = %d (numNExcReg:numNInhReg = %2.1f:%2.1f)",
8403 KERNEL_INFO(
"Simulation Mode:\t%s",sim_with_conductances?
"COBA":
"CUBA");
8405 KERNEL_INFO(
"Timing:\t\t\tModel Simulation Time = %lld sec", (
unsigned long long)simTimeSec);
8406 KERNEL_INFO(
"\t\t\tActual Execution Time = %4.2f sec", etime/1000.0f);
8407 float speed = float(simTimeSec) / std::max(.001f, etime / 1000.0f);
8409 const char* build =
"(Debug)";
8411 const char* build =
"";
8413 if (speed >= 10.f) {
8414 KERNEL_INFO(
"\t\t\tSpeed Factor (Model/Real) = %.0f x %s", speed, build);
8417 KERNEL_INFO(
"\t\t\tSpeed Factor (Model/Real) = %2.1f %% %s", speed*100.f, build);
8419 KERNEL_INFO(
"\t\t\tSpeed Factor (Model/Real) = %1.1f x %s", speed, build);
8420 KERNEL_INFO(
"Average Firing Rate:\t2+ms delay = %3.3f Hz",
8431 KERNEL_INFO(
"*********************************************************************************\n");
#define KERNEL_ERROR_POISSON_2
float * maxSynWt
maximum synaptic weight for a connection
float * voltage
membrane potential for each regular neuron
Class for generating Poisson spike trains.
#define KERNEL_ERROR_SRC_GRP_CONN
bool WithDA_MOD
True if at least one connection group is WithDA_MOD.
float rGABAb
multiplication factor for rise time of GABAb
float * randNum
firing random number. max value is 10,000
float ALPHA_MINUS_EXC
published by GroupConfig
float mulSynFast
factor to be applied to either gAMPA or gGABAa
int numNSpikeGen
number of poisson neurons generating spikes based on callback functions
FILE * getSpikeFileId()
returns a pointer to the spike file
int * synSpikeTime
stores the last spike time of a synapse
#define SET_CONN_PRESENT(a)
x86/x64 Multi Core Processor (LN20201016)
void setNeuronParametersLIF(int grpId, int tau_m, int tau_ref, float vTh, float vReset, double minRmem, double maxRmem)
Sets neuron parameters for a group of LIF spiking neurons.
float decayNE
decay rate for Noradrenaline, published by GroupConfig
#define KERNEL_ERROR_UNKNOWN_ICALC
int NM_PLC
published by GroupConfig
bool isPoissonGroup(int gGrpId)
virtual int nextSpikeTime(SNN *s, int grpId, int i, int currentTime, int lastScheduledSpikeTime, int endOfTimeSlice)
controls spike generation using a callback mechanism
int grpId
corresponding global group Id
float TAU_MINUS_INV_EXC
the inverse of time constant minus, if the exponential or timing-based E-STDP curve is used ...
Developer mode, for developing and debugging code.
STDPCurve WithISTDPcurve
published by GroupConfig
bool isSimulationWithGABAbRise()
float wstptaux[NM_NE+3]
Array size = last index + 1 + additional elementsnorm + base.
float KAPPA
published by GroupConfig
#define KERNEL_ERROR_INVALID_START
STDPType WithISTDPtype
the type of I-STDP (STANDARD or DA_MOD)
#define KERNEL_ERROR_CONN_MISSING3
void schedule(int neurId, int grpId, unsigned short int delay)
Schedule a spike.
int createGroupLIF(const std::string &grpName, const Grid3D &grid, int neurType, int preferredPartition, ComputingBackend preferredBackend)
Creates a group of LIF spiking neurons.
RangeDelay getDelayRange(short int connId)
returns the RangeDelay struct of a connection
int numNAssigned
number of total neurons assigned to the local network
float base5HT
baseline concentration of Serotonin
bool WithSTDP
True if at least one connection group is WithSTDP.
void findWavefrontPath(std::vector< int > &path, std::vector< float > &eligibility, int netId, int grpId, int startNId, int goalNId)
#define UNKNOWN_LOGGER_ERROR
Iterator to loop over the scheduled spikes at a certain delay.
A struct for retrieving STDP related information of a connection.
bool isRecording()
returns recording status
int numNPois
number of poisson neurons
float LAMBDA
published by GroupConfig
void pushNeuronState(int neurId, float V, float U, float I)
inserts a (time,neurId) tupel into the D Neuron State vector
#define KERNEL_ERROR_NUMX
NeuronMonitor * getNeuronMonitor(int grpId)
Returns pointer to existing NeuronMonitor object, NULL else.
int numPreSynNet
the total number of pre-connections in a network
float releaseDP
release per spike for Dopaamine
int GtoLOffset
published by GroupConfigMD
#define KERNEL_ERROR_INVALID_CONN2
void updateGroupMonitor(int grpId=ALL)
access group status (currently the concentration of neuromodulator)
float W_PLC
published by GroupConfig
float GAMMA
the turn over point if the timing-based E-STDP curve is used
#define KERNEL_ERROR_COMPARTMENT_DISABLED2
float timeStep
inverse of simNumStepsPerMs
#define ALL
CARLsim common definitions.
float homeostasisScale
published by GroupConfig
float dAMPA
multiplication factor for decay time of AMPA conductance (gAMPA[i] *= dAMPA)
FILE * getNeuronFileId()
returns a pointer to the neuron state file
unsigned int * timeTableD1
firing table, only used in CPU_MODE currently
int * nSpikeCnt
homeostatic plasticity variables
#define KERNEL_ERROR_INVALID_GROUP_INFO
int numNRateGen
number of poisson neurons generating spikes based on firing rate
#define KERNEL_ERROR_INVALID_HEADER
#define KERNEL_ERROR_INVALID_CONN
void setNM4weighted(int grpId, IcalcType type, float wDA, float w5HT, float wACh, float wNE, float wNorm, float wBase)
unsigned int spikeCountD1Sec
the total number of spikes with axonal delay == 1 in 1 second, used in CPU_MODE currently ...
model is run on GPU card(s)
GroupNeuromodulatorInfo getGroupNeuromodulatorInfo(int grpId)
#define KERNEL_ERROR_GROUP_MISMATCH
unsigned int spikeCountD1
the total number of spikes with anxonal delay == 1 in a simulation, used in CPU_MODE currently ...
bool sim_with_homeostasis
void setISTDP(int preGrpId, int postGrpId, bool isSet, STDPType type, STDPCurve curve, float ab1, float ab2, float tau1, float tau2)
Set the inhibitory spike-timing-dependent plasticity (STDP) with anti-hebbian curve for a neuron grou...
int numN2msDelay
number of neurons with maximum out going axonal delay >= 2 ms
float DELTA
published by GroupConfig
unsigned int spikeCountExtRxD2
the number of external spikes with axonal delay > 1 in a simulation, used in CPU_MODE currently ...
ConnectionMonitor * setConnectionMonitor(int grpIdPre, int grpIdPost, FILE *fid)
sets up a network monitor registered with a callback to process the spikes.
bool activeACh
flag for Acetylcholine
bool compareDelay(const ConnectionInfo &first, const ConnectionInfo &second)
#define KERNEL_ERROR_NO_CATAGORY
#define KERNEL_ERROR_STDP_HOMEO_INCONSIST
UpdateInterval
Update frequency for weights.
float ALPHA_MINUS_INB
the amplitude of alpha minus, if the exponential I-STDP curve is used
float GAMMA
published by GroupConfig
bool isRecording()
returns recording status
bool allocated
true if all data has been allocated
int getLastUpdated()
returns timestamp of last GroupMonitor update
float decayDP
decay rate for Dopaamine, published by GroupConfig
bool isBufferBig()
returns true if spike buffer is close to maxAllowedBufferSize
runtime data is allocated on CPU (main) memory
float TAU_PLUS_INV_INB
published by GroupConfig
float * gAMPA
conductance of gAMPA
bool WithISTDP
enable I-STDP flag
#define KERNEL_WARN(formatc,...)
int numSynNet
number of total synaptic connections in the global network
void setNeuromodulator(int grpId, float baseDP, float tauDP, float base5HT, float tau5HT, float baseACh, float tauACh, float baseNE, float tauNE)
Sets baseline concentration and decay time constant of neuromodulators (DP, 5HT, ACh, NE) for a neuron group.
#define MAX_NEURON_MON_GRP_SZIE
#define NEURON_MAX_FIRING_RATE
SpikeMonMode getMode()
returns recording mode
std::vector< float > getConductanceNMDA(int grpId)
float DELTA
the range of inhibitory LTD if the pulse I-STDP curve is used
int * lif_tau_m
parameters for a LIF spiking group
unsigned int * cumulativePre
void setNM4STP(int grpId, float wSTP_U[], float wSTP_tau_u[], float wSTP_tau_x[])
int maxDelay
maximum axonal delay in the gloabl network
bool updateDelays(int gGrpIdPre, int gGrpIdPost, std::vector< std::tuple< int, int, uint8_t >> connDelays)
void startTesting(bool shallUpdateWeights=true)
enters a testing phase, where all weight updates are disabled
bool activeNE
flag for Noradrenaline
NeuronMonitorCore * getNeuronMonitorCore(int grpId)
bool isLIF
True = a LIF spiking group.
static const char * IcalcType_string[]
unsigned * firingTimesD2
stores the actual firing time
bool isGroupWithHomeostasis(int grpId)
returns whether group has homeostasis enabled (true) or not (false)
unsigned int spikeCountD2
the total number of spikes with anxonal delay > 1 in a simulation, used in CPU_MODE currently ...
#define MAX_NUM_COMP_CONN
int numN
number of neurons in th local network
int gEndN
published by GroupConfigMD
void exitSimulation(int val=1)
deallocates all dynamical structures and exits
short int connId
connectID of the element in the linked list
float wstptauu[NM_NE+3]
Array size = last index + 1 + additional elementsnorm + base.
void setLastUpdated(long int lastUpdate)
sets timestamp of last SpikeMonitor update
#define KERNEL_ERROR_NO_PARTION_ASSIGNED
float sNMDA
scaling factor for NMDA amplitude
#define KERNEL_ERROR(formatc,...)
std::vector< float > getConductanceGABAb(int grpId)
float decayNE
decay rate for Noradrenaline
integrationMethod_t simIntegrationMethod
integration method (forward-Euler or Fourth-order Runge-Kutta)
float ALPHA_PLUS_EXC
published by GroupConfig
int * extFiringTableEndIdxD1
void scaleWeights(short int connId, float scale, bool updateWeightRange=false)
void setGroupFileId(FILE *groupFileId)
sets pointer to group data file
float ALPHA_MINUS_INB
published by GroupConfig
#define KERNEL_ERROR_POISSON_1
int numN
published by GroupConfig
float decay5HT
decay rate for Serotonin, published by GroupConfig
float * wt
stores the weight change of a synaptic connection
void printEntrails(char *buffer, unsigned length, int gGrpIdPre, int gGrpIdPost)
void pushData(int time, float data)
inserts group data (time, value) into the vectors , if monitor is in DA_MODE
long int getLastUpdated()
returns timestamp of last SpikeMonitor update
int createGroup(const std::string &grpName, const Grid3D &grid, int neurType, int preferredPartition, ComputingBackend preferredBackend)
Creates a group of Izhikevich spiking neurons.
float BETA_LTP
the amplitude of inhibitory LTP if the pulse I-STDP curve is used
float decayDP
decay rate for Dopaamine
used for relaying callback to ConnectionGenerator
bool active5HT
flag for Serotonin
float baseNE
baseline concentration of Noradrenaline, published by GroupConfig
int numPreSynapses
the total number of pre-connections of a group, published by GroupConfigMD
void updateNeuronMonitor(int grpId=ALL)
copy required neuron state values from ??? buffer to ??? buffer
bool isExcitatoryGroup(int gGrpId)
GroupMonitor * setGroupMonitor(int grpId, FILE *fid, int mode=0)
sets up a group monitor registered with a callback to process the spikes.
int netId
published by GroupConfigMD
The configuration of a connection.
int NM_PKA
published by GroupConfig
int ** extFiringTableD1
external firing table, only used on GPU
bool WithESTDP
enable E-STDP flag
void setLogsFp(FILE *fpInf=NULL, FILE *fpErr=NULL, FILE *fpDeb=NULL, FILE *fpLog=NULL)
Sets the file pointers for all log files file pointer NULL means don't change it. ...
float dNMDA
multiplication factor for decay time of NMDA
#define KERNEL_ERROR_UNKNOWN_SIM_MODE
bool isSpikeGenerator
published by GroupConfig
long int getLastUpdated()
returns timestamp of last NeuronMonitor update
short int getConnectId(int grpIdPre, int grpIdPost)
find connection ID based on pre-post group pair, O(N)
#define LARGE_SPIKE_MON_GRP_SIZE
float releaseDP
release per spike for Dopaamine
void setConnectFileId(FILE *connFileId)
sets pointer to connection file
bool active5HT
flag for Serotonin
unsigned short * Npre_plastic
stores the number of plastic input connections to a neuron
int gGrpId
published by GroupConfigMD
#define KERNEL_ERROR_NEURON_MISMATCH
Circular buffer for delivering spikes.
Grid3D getGroupGrid3D(int grpId)
bool hasExternalConnect
published by GroupConfigMD
void setupNetwork()
build the network
int numPostSynapses
the total number of post-connections of a group, published by GroupConfigMD
unsigned int spikeCountLastSecLeftD2
the nubmer of spike left in the last second, used in CPU_MODE currently
#define KERNEL_INFO(formatc,...)
A struct to arrange neurons on a 3D grid (a primitive cubic Bravais lattice with cubic side length 1)...
static const unsigned int MAJOR_VERSION
major release version, as in CARLsim X
int simNumStepsPerMs
number of steps per 1 millisecond
bool WithSTDP
published by GroupConfig
bool isSimulationWithCOBA()
void saveSimulation(FILE *fid, bool saveSynapseInfo=false)
stores the pre and post synaptic neuron ids with the weight and delay
float dGABAb
multiplication factor for decay time of GABAb
bool isSpikeGenFunc
published by GroupConfig
#define GET_FIXED_PLASTIC(a)
float BETA_LTP
published by GroupConfig
void setLastUpdated(unsigned int lastUpdate)
sets timestamp of last GroupMonitor update
float baseDP
baseline concentration of Dopamine, published by GroupConfig
void setSpikeFileId(FILE *spikeFileId)
sets pointer to spike file
int lGrpId
published by GroupConfigMD
void updateConnectionMonitor(short int connId=ALL)
polls connection weights
used for relaying callback to SpikeGenerator
int numN1msDelay
number of neurons with maximum out going axonal delay = 1 ms
float decayACh
decay rate for Acetylcholine, published by GroupConfig
float rNMDA
multiplication factor for rise time of NMDA
SpikeMonitor * getSpikeMonitor(int grpId)
Returns pointer to existing SpikeMonitor object, NULL else.
#define KERNEL_ERROR_CONN_MISSING4
NeuronMonitor * setNeuronMonitor(int gid, FILE *fid)
sets up a neuron monitor registered with a callback to process the neuron state values, there can only be one NeuronMonitor per group
std::string getGroupName(int grpId)
int maxDelay
maximum axonal delay in the gloabl network
void updateSpikeMonitor(int grpId=ALL)
copy required spikes from firing buffer to spike buffer
float release5HT
release per spike for Serotonin
short int * connIdsPreIdx
connectId, per synapse, presynaptic cumulative indexing
unsigned int spikeCount
the total number of spikes in a simulation, used in CPU_MODE currently
#define KERNEL_ERROR_LIF_PARAMS_NOT_SET
#define KERNEL_ERROR_CONNMON_SET
protein kinase/phospholiphase controlled LTP/LPD adopted from Nadim & Bucher (2014) ...
float mulSynSlow
factor to be applied to either gNMDA or gGABAb
bool WithNM4STP
if group has targeted STP
mode in which spike information is collected in AER format
float decay5HT
decay rate for Serotonin
int numNPois
number of poisson neurons in the global network
bool activeDP
flag for Dopaamine
dopamine-modulated STDP, nearest-neighbor
long int getAccumTime()
returns the total accumulated time
The configuration of a compartmental connection.
float OMEGA
published by GroupConfig
#define KERNEL_ERROR_INVALID_CONN3
#define KERNEL_ERROR_CONN_MISSING5
bool isSimulationWithNMDARise()
#define KERNEL_ERROR_COMPARTMENT_DISABLED
bool with_GABAb_rise
replaces sim_with_GABAb_rise
unsigned short * Npost
stores the number of output connections from a neuron.
int getNumNeurons()
Returns the number of neurons for which to generate Poisson spike trains.
SpikeMonitorCore * getSpikeMonitorCore(int grpId)
#define NO_LOGGER_DIR_ERROR
int numNExcPois
number of excitatory poisson neurons in the global network
#define KERNEL_ERROR_GROUPMON_SET
int8_t MaxDelay
published by GroupConfigMD
bool compareSrcNeuron(const ConnectionInfo &first, const ConnectionInfo &second)
bool withParamModel_9
False = 4 parameter model; 1 = 9 parameter model.
int * extFiringTableEndIdxD2
float avgTimeScaleInv
published by GroupConfig
float decayACh
decay rate for Acetylcholine
bool WithSTDP
published by GroupConfig
double getRFDist3D(const RadiusRF &radius, const Point3D &pre, const Point3D &post)
checks whether a point pre lies in the receptive field for point post
#define KERNEL_ERROR_COMP_CONNS_EXCEEDED2
User mode, for experiment-oriented simulations.
uint8_t * getDelays(int gGrpIdPre, int gGrpIdPost, int &numPreN, int &numPostN)
Returns the delay information for all synaptic connections between a pre-synaptic and a post-synaptic...
unsigned int Type
published by GroupConfig
#define KERNEL_ERROR_MAX_SYN_DELAY
bool WithHomeostasis
published by GroupConfig
void setSpikeRate(int grpId, PoissonRate *spikeRate, int refPeriod)
Sets the Poisson spike rate for a group. For information on how to set up spikeRate, see Section Poisson spike generators in the Tutorial.
float base5HT
baseline concentration of Serotonin, published by GroupConfig
IcalcType icalcType
published by GroupConfig
float connProbability
connection probability
IcalcType
input current calculation
int * lastSpikeTime
stores the last spike time of a neuron
float * gGABAa
conductance of gGABAa
void biasWeights(short int connId, float bias, bool updateWeightRange=false)
void writeConnectFileSnapshot(int simTimeMs, std::vector< std::vector< float > > wts)
writes each snapshot to connect file
STDPType WithISTDPtype
published by GroupConfig
int getNumSynapticConnections(short int connectionId)
gets number of connections associated with a connection ID
unsigned int spikeCountD2Sec
the total number of spikes with axonal delay > 1 in 1 second, used in CPU_MODE currently ...
SpikeIterator back()
pointer to the back of the spike buffer
float releaseACh
release per spike for Acetylcholine
STDPCurve WithISTDPcurve
the I-STDP curve
short int connect(int gIDpre, int gIDpost, const std::string &_type, float initWt, float maxWt, float prob, uint8_t minDelay, uint8_t maxDelay, RadiusRF radius, float mulSynFast, float mulSynSlow, bool synWtType)
make from each neuron in grpId1 to 'numPostSynapses' neurons in grpId2
unsigned short * Npre
stores the number of input connections to a neuron
integrationMethod_t
Integration methods.
Showtime mode, will only output warnings and errors.
void setNeuronParameters(int grpId, float izh_a, float izh_a_sd, float izh_b, float izh_b_sd, float izh_c, float izh_c_sd, float izh_d, float izh_d_sd)
Sets the Izhikevich parameters a, b, c, and d of a neuron group.
float wtChangeDecay
the wtChange decay
a range struct for synaptic delays
float BETA_LTD
the amplitude of inhibitory LTD if the pulse I-STDP curve is used
void setCompartmentParameters(int grpId, float couplingUp, float couplingDown)
Coupling constants for the compartment are set using this method.
float dGABAa
multiplication factor for decay time of GABAa
void setHomeoBaseFiringRate(int groupId, float baseFiring, float baseFiringSD)
Sets homeostatic target firing rate (enforced through homeostatic synaptic scaling) ...
int Noffset
the offset of spike generator (poisson) neurons [0, numNPois), published by GroupConfigMD ...
float baseACh
baseline concentration of Acetylcholine
STDPType WithESTDPtype
the type of E-STDP (STANDARD or DA_MOD)
#define GET_CONN_NEURON_ID(val)
float TAU_MINUS_INV_INB
published by GroupConfig
unsigned int spikeCountExtRxD1
the number of external spikes with axonal delay == 1 in a simulation, used in CPU_MODE currently ...
std::vector< float > getConductanceGABAa(int grpId)
The configuration of a group.
int gsId
group id and synapse id
SNN(const std::string &name, SimMode preferredSimMode, LoggerMode loggerMode, int randSeed)
SNN Constructor.
bool sim_with_GABAb_rise
a flag to inform whether to compute GABAb rise time
float releaseNE
release per spike for Noradrenaline
void setNeuronFileId(FILE *neuronFileId)
sets pointer to Neuron file
int runNetwork(int _nsec, int _nmsec, bool printRunSummary)
run the simulation for n sec
float ALPHA_PLUS_INB
the amplitude of alpha plus, if the exponential I-STDP curve is used
bool sim_with_conductances
#define KERNEL_ERROR_NUMZ
unsigned int * timeTableD2
firing table, only used in CPU_MODE currently
A struct for retrieving neuromodulator information of a group.
int numNReg
number of regular (spking) neurons
RangeWeight getWeightRange(short int connId)
returns RangeWeight struct of a connection
#define MAX_SIMULATION_TIME
#define GET_CONN_SYN_ID(val)
bool activeDP
flag for Dopaamine
int createSpikeGeneratorGroup(const std::string &grpName, const Grid3D &grid, int neurType, int preferredPartition, ComputingBackend preferredBackend)
Creates a spike generator group (dummy-neurons, not Izhikevich spiking neurons)
Point3D getNeuronLocation3D(int neurId)
void setIntegrationMethod(integrationMethod_t method, int numStepsPerMs)
Sets the integration method and the number of integration steps per 1ms simulation time step...
#define KERNEL_ERROR_DEST_GRP_CONN
float avgTimeScale_decay
published by GroupConfig
#define KERNEL_ERROR_STDP_NO_IN_PLASTIC
int numNInhReg
number of regular inhibitory neurons in the global network
int numN
number of neurons in the global network
int lEndN
published by GroupConfigMD
float * gGABAb
conductance of gGABAb
std::vector< float > getConductanceAMPA(int grpId)
ConnSTDPInfo getConnSTDPInfo(short int connId)
#define KERNEL_DEBUG(formatc,...)
DelayInfo * postDelayInfo
delay information
float baseACh
baseline concentration of Acetylcholine, published by GroupConfig
int numNInhPois
number of inhibitory poisson neurons in the global network
void reset(int minDelay, int maxDelay)
Reset buffer data.
int getNeuronId(int gGrpId, Point3D location)
the inverse of getNeuronLocation3D
int ** extFiringTableD2
external firing table, only used on GPU
int numGroups
number of local groups in this local network
#define IS_INHIBITORY_TYPE(type)
integrationMethod_t simIntegrationMethod
integration method (forward-Euler or Fourth-order Runge-Kutta)
int LtoGOffset
published by GroupConfigMD
void setExternalCurrent(int grpId, const std::vector< float > ¤t)
injects current (mA) into the soma of every neuron in the group
#define MAX_SPIKE_MON_BUFFER_SIZE
a range struct for synaptic weight magnitudes
#define GET_CONN_GRP_ID(val)
bool WithISTDP
published by GroupConfig
float STP_A
published by GroupConfig
Contains all of CARLsim's core functionality.
#define KERNEL_ERROR_COMP_CONNS_EXCEEDED
float STP_U
published by GroupConfig
ComputingBackend
computing backend
#define KERNEL_ERROR_IZH_PARAMS_NOT_SET
#define IS_EXCITATORY_TYPE(type)
int numNExcReg
number of regular excitatory neurons in the global network
float BETA_LTD
published by GroupConfig
float STP_tau_x_inv
published by GroupConfig
#define ID_OVERFLOW_ERROR
float LAMBDA
the range of inhibitory LTP if the pulse I-STDP curve is used
void setESTDP(int preGrpId, int postGrpId, bool isSet, STDPType type, STDPCurve curve, float alphaPlus, float tauPlus, float alphaMinus, float tauMinus, float gamma)
Set the spike-timing-dependent plasticity (STDP) for a neuron group.
float TAU_PLUS_INV_EXC
published by GroupConfig
#define KERNEL_ERROR_CONN_MISSING
SynInfo * postSynapticIds
10 bit syn id, 22 bit neuron id, ordered based on delay
int lStartN
published by GroupConfigMD
unsigned int * cumulativePost
int numConnections
number of local connections in this local network
void stopTesting()
exits a testing phase, making weight updates possible again
unsigned int maxSpikesD2
the estimated maximum number of spikes with delay >= 2 in a network
short int connectCompartments(int grpIdLower, int grpIdUpper)
Custom mode, the user can set the location of all the file pointers.
void setHomeostasis(int grpId, bool isSet, float homeoScale, float avgTimeScale)
Sets the homeostasis parameters. g is the grpID, enable=true(false) enables(disables) homeostasis...
used to initialize by default constructor
int numPostSynNet
the total number of post-connections in a network
#define LONG_SPIKE_MON_DURATION
runtime spike routing table entry
the update interval will be 10 ms, which is 100Hz update frequency
float TAU_PLUS_INV_INB
the inverse of tau plus, if the exponential I-STDP curve is used
#define ANY
used for create* method to specify any GPU or a specific GPU
unsigned int * spikeGenBits
void pushAER(int time, int neurId)
inserts a (time,neurId) tupel into the 2D spike vector
CPU multithreading subroutine (that takes single argument) struct argument.
std::vector< std::vector< float > > getWeightMatrix2D(short int connId)
bool isRecording()
returns recording status
void setSTP(int grpId, bool isSet, float STP_U, float STP_tau_u, float STP_tau_x)
Sets STP params U, tau_u, and tau_x of a neuron group (pre-synaptically) CARLsim implements the short...
int neurId
corresponding global neuron Id
int simNumStepsPerMs
number of steps per 1 millisecond
bool with_NMDA_rise
replaces sim_with_NMDA_rise
int numGroupsAssigned
number of groups assigned to this local network
int gStartN
published by GroupConfigMD
void setSpikeGenerator(int grpId, SpikeGeneratorCore *spikeGenFunc)
sets up a spike generator
bool isPoint3DinRF(const RadiusRF &radius, const Point3D &pre, const Point3D &post)
int numComp
number of compartmental neurons
standard exponential curve
int getGroupId(std::string grpName)
GroupMonitor private core implementation.
float TAU_MINUS_INV_EXC
published by GroupConfig
static const char * loggerMode_string[]
#define KERNEL_ERROR_UNKNOWN_FILE_SIGNATURE
void setWeightAndWeightChangeUpdate(UpdateInterval wtANDwtChangeUpdateInterval, bool enableWtChangeDecay, float wtChangeDecay)
Sets the weight and weight change update parameters.
model is run on CPU Core(s), GPU card(s) or both
bool WithSTDP
enable STDP flag
float baseDP
baseline concentration of Dopamine
runtime network configuration
int numNReg
number of regular (spking) neurons in the global network
float avgTimeScale
< homeostatic plasticity variables
float baseNE
baseline concentration of Noradrenaline
SpikeMonitor * setSpikeMonitor(int gid, FILE *fid)
sets up a spike monitor registered with a callback to process the spikes, there can only be one Spike...
int getUpdateTimeIntervalSec()
bool WithSTP
published by GroupConfig
void setLastUpdated(long int lastUpdate)
sets timestamp of last NeuronMonitor update
#define KERNEL_ERROR_INVALID_END
bool activeNE
flag for Noradrenaline
FILE * getGroupFileId()
returns a pointer to the group data file
#define KERNEL_ERROR_STDP_SYN_PLASIC
unsigned int spikeCountSec
the total number of spikes in 1 second, used in CPU_MODE currently
the update interval will be 1000 ms, which is 1Hz update frequency
float releaseACh
release per spike for Acetylcholine
float TAU_PLUS_INV_EXC
the inverse of time constant plus, if the exponential or timing-based E-STDP curve is used ...
bool isConnectionPlastic(short int connId)
returns whether synapses in connection are fixed (false) or plastic (true)
int getGroupNumNeurons(int gGrpId)
void setWeight(short int connId, int neurIdPre, int neurIdPost, float weight, bool updateWeightRange=false)
sets the weight value of a specific synapse
float * gNMDA
conductance of gNMDA
float sGABAb
scaling factor for GABAb amplitude
bool FixedInputWts
published by GroupConfigMD
Silent mode, no output is generated.
void setConductances(bool isSet, int tdAMPA, int trNMDA, int tdNMDA, int tdGABAa, int trGABAb, int tdGABAb)
Sets custom values for conductance decay () or disables conductances alltogether These will be applie...
STDPCurve WithESTDPcurve
the E-STDP curve
ConnectionGeneratorCore * conn
float STP_tau_u_inv
published by GroupConfig
unsigned int nPoissonSpikes
the total number of spikes of poisson neurons, used in CPU_MODE currently
#define KERNEL_ERROR_CONN_MISSING2
#define STP_BUF_POS(nid, t, maxDelay)
#define KERNEL_ERROR_MAX_STP_DELAY
STDPCurve WithESTDPcurve
published by GroupConfig
#define SET_FIXED_PLASTIC(a)
bool WithESTDP
published by GroupConfig
void setConnectionModulation(int preGrpId, int postGrpId, IcalcType icalcType)
bool activeACh
flag for Acetylcholine
#define KERNEL_ERROR_UNSUPPORTED_VERSION
void step()
advance to next time step
#define KERNEL_ERROR_GROUP_NAMES_MISMATCH
bool sim_with_NMDA_rise
a flag to inform whether to compute NMDA rise time
unsigned int maxSpikesD1
the estimated maximum number of spikes with delay == 1 in a network
float * wtChange
stores the weight change of a synaptic connection
static const unsigned int MINOR_VERSION
minor release version, as in CARLsim 2.X
float releaseNE
release per spike for Noradrenaline
STDPType WithESTDPtype
published by GroupConfig
#define CHECK_CONNECTION_ID(n, total)
< Used for in the function getConnectionId
float release5HT
release per spike for Serotonin
void loadSimulation(FILE *fid)
float ALPHA_PLUS_INB
published by GroupConfig
SpikeIterator front(int stepOffset=0)
pointer to the front of the spike buffer
float ALPHA_MINUS_EXC
the amplitude of alpha minus, if the exponential or timing-based E-STDP curve is used ...
float * nextVoltage
membrane potential buffer (next/future time step) for each regular neuron
float wstpu[NM_NE+3]
Array size = last index + 1 + additional elementsnorm + base.
ConnectConfig getConnectConfig(short int connectId)
required for homeostasis
model is run on CPU core(s)
float W_PKA
published by GroupConfig
float TAU_MINUS_INV_INB
the inverse of tau minus, if the exponential I-STDP curve is used
the update interval will be 100 ms, which is 10Hz update frequency
#define KERNEL_ERROR_NUMY
A struct to specify the receptive field (RF) radius in 3 dimensions.
float ALPHA_PLUS_EXC
the amplitude of alpha plus, if the exponential or timing-based E-STDP curve is used ...
float timeStep
inverse of simNumStepsPerMs