CARLsim  4.1.0
CARLsim: a GPU-accelerated SNN simulator
snn.h
Go to the documentation of this file.
1 /* * Copyright (c) 2016 Regents of the University of California. All rights reserved.
2  *
3  * Redistribution and use in source and binary forms, with or without
4  * modification, are permitted provided that the following conditions
5  * are met:
6  *
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  *
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  *
14  * 3. The names of its contributors may not be used to endorse or promote
15  * products derived from this software without specific prior written
16  * permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  * *********************************************************************************************** *
31  * CARLsim
32  * created by: (MDR) Micah Richert, (JN) Jayram M. Nageswaran
33  * maintained by:
34  * (MA) Mike Avery <averym@uci.edu>
35  * (MB) Michael Beyeler <mbeyeler@uci.edu>,
36  * (KDC) Kristofor Carlson <kdcarlso@uci.edu>
37  * (TSC) Ting-Shuo Chou <tingshuc@uci.edu>
38  * (HK) Hirak J Kashyap <kashyaph@uci.edu>
39  *
40  * CARLsim v1.0: JM, MDR
41  * CARLsim v2.0/v2.1/v2.2: JM, MDR, MA, MB, KDC
42  * CARLsim3: MB, KDC, TSC
43  * CARLsim4: TSC, HK
44  *
45  * CARLsim available from http://socsci.uci.edu/~jkrichma/CARLsim/
46  * Ver 12/31/2016
47  */
48 
49 /*
50  * Common Abbreviations used in CARLsim
51  * snn/SNN: spiking neural network
52  * stp/STP: short-term plasticity
53  * stdp/STDP: spike-timing dependent plasticity
54  * syn/SYN: synapse
55  * wt/WT: weight
56  * exc/Exc: excitatory
57  * inh/Inh: inhibitory
58  * grp: group
59  * nid/NId/NID: neuron id
60  * gid/GId/GID: group id
61  *
62  * conn: connection
63  * min: minimum
64  * max: maximum
65  * num: number
66  * mem: memory
67  * id/Id/ID: identification
68  * info: information
69  * cnt: count
70  * curr: current
71  * mon: monitor
72  * reg/Reg: regurlar
73  * pois/Pois: poisson
74  */
75 #ifndef _SNN_GOLD_H_
76 #define _SNN_GOLD_H_
77 
78 #include <map>
79 #include <list>
80 #include <cmath>
81 #include <cstring>
82 #include <cassert>
83 #include <cstdio>
84 #include <climits>
85 
86 #include <carlsim.h>
87 #include <callback_core.h>
88 
89 #include <snn_definitions.h>
90 #include <snn_datastructures.h>
91 
92 // #include <spike_buffer.h>
93 #include <poisson_rate.h>
94 
95 class SpikeMonitor;
96 class SpikeMonitorCore;
97 class NeuronMonitor;
98 class NeuronMonitorCore;
100 class ConnectionMonitor;
101 
102 class SpikeBuffer;
103 
104 
108 
114 class SNN {
115 
119 public:
121 
127  SNN(const std::string& name, SimMode preferredSimMode, LoggerMode loggerMode, int randSeed);
128 
130 
133  ~SNN();
134 
135  // +++++ PUBLIC PROPERTIES ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
136 
137  const static unsigned int MAJOR_VERSION = 4;
138  const static unsigned int MINOR_VERSION = 0;
139 
140 
141 
142  // +++++ PUBLIC METHODS: SETTING UP A SIMULATION ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
143 
144  // NOTE: there should be no default argument values in here, this should be handled by the user interface
145 
148 
163  short int connect(int gIDpre, int gIDpost, const std::string& _type, float initWt, float maxWt, float prob,
164  uint8_t minDelay, uint8_t maxDelay, RadiusRF radius,
165  float mulSynFast, float mulSynSlow, bool synWtType);
166 
167  /* Creates synaptic projections using a callback mechanism.
168  *
169  * \param _grpIdPre:ID of the pre-synaptic group
170  * \param _grpIdPost ID of the post-synaptic group
171  * \param _conn: pointer to an instance of class ConnectionGenerator
172  * \param _synWtType: (optional) connection type, either SYN_FIXED or SYN_PLASTIC, default = SYN_FIXED
173  * \return number of created synaptic projections
174  */
175  short int connect(int gIDpre, int gIDpost, ConnectionGeneratorCore* conn, float mulSynFast, float mulSynSlow,
176  bool synWtType);
177 
178  /* Creates synaptic projections using a callback mechanism.
179  *
180  * \param _grpId1:ID lower layer group
181  * \param _grpId2 ID upper level group
182  */
183  short int connectCompartments(int grpIdLower, int grpIdUpper);
184 
186 
191  int createGroup(const std::string& grpName, const Grid3D& grid, int neurType, int preferredPartition, ComputingBackend preferredBackend);
192 
194 
201  int createGroupLIF(const std::string& grpName, const Grid3D& grid, int neurType, int preferredPartition, ComputingBackend preferredBackend);
202 
204 
209  int createSpikeGeneratorGroup(const std::string& grpName, const Grid3D& grid, int neurType, int preferredPartition, ComputingBackend preferredBackend);
210 
217  void setCompartmentParameters(int grpId, float couplingUp, float couplingDown);
218 
230  void setConductances(bool isSet, int tdAMPA, int trNMDA, int tdNMDA, int tdGABAa, int trGABAb, int tdGABAb);
231 
232 
239  void setHomeostasis(int grpId, bool isSet, float homeoScale, float avgTimeScale);
240 
242  void setHomeoBaseFiringRate(int groupId, float baseFiring, float baseFiringSD);
243 
245  void setIntegrationMethod(integrationMethod_t method, int numStepsPerMs);
246 
248 
260  void setNeuronParameters(int grpId, float izh_a, float izh_a_sd, float izh_b, float izh_b_sd,
261  float izh_c, float izh_c_sd, float izh_d, float izh_d_sd);
262 
275  void setNeuronParametersLIF(int grpId, int tau_m, int tau_ref, float vTh, float vReset, double minRmem, double maxRmem);
276 
278 
301  void setNeuronParameters(int grpId, float izh_C, float izh_C_sd, float izh_k, float izh_k_sd,
302  float izh_vr, float izh_vr_sd, float izh_vt, float izh_vt_sd,
303  float izh_a, float izh_a_sd, float izh_b, float izh_b_sd,
304  float izh_vpeak, float izh_vpeak_sd, float izh_c, float izh_c_sd,
305  float izh_d, float izh_d_sd);
306 
308 
319  void setNeuromodulator(int grpId, float baseDP, float tauDP, float base5HT, float tau5HT,
320  float baseACh, float tauACh, float baseNE, float tauNE);
321 
323  /*
324  * \brief STDP must be defined post-synaptically; that is, if STP should be implemented on the connections from group 0 to group 1,
325  * call setSTP on group 1. Fore details on the phenomeon, see (for example) (Bi & Poo, 2001).
326  * \param[in] grpId ID of the neuron group
327  * \param[in] isSet_enable set to true to enable STDP for this group
328  * \param[in] type STDP type (STANDARD, DA_MOD)
329  * \param[in] alphaPlus max magnitude for LTP change
330  * \param[in] tauPlus decay time constant for LTP
331  * \param[in] alphaMinus max magnitude for LTD change (leave positive)
332  * \param[in] tauMinus decay time constant for LTD
333  */
334  void setESTDP(int grpId, bool isSet, STDPType type, STDPCurve curve, float alphaPlus, float tauPlus, float alphaMinus, float tauMinus, float gamma);
335 
337  /*
338  * \brief STDP must be defined post-synaptically; that is, if STP should be implemented on the connections from group 0 to group 1,
339  * call setSTP on group 1. Fore details on the phenomeon, see (for example) (Bi & Poo, 2001).
340  * \param[in] grpId ID of the neuron group
341  * \param[in] isSet_enable set to true to enable STDP for this group
342  * \param[in] type STDP type (STANDARD, DA_MOD)
343  * \param[in] curve STDP curve
344  * \param[in] ab1 magnitude for LTP change
345  * \param[in] ab2 magnitude for LTD change (leave positive)
346  * \param[in] tau1, the interval for LTP
347  * \param[in] tau2, the interval for LTD
348  */
349  void setISTDP(int grpId, bool isSet, STDPType type, STDPCurve curve, float ab1, float ab2, float tau1, float tau2);
350 
371  void setSTP(int grpId, bool isSet, float STP_U, float STP_tau_u, float STP_tau_x);
372 
374 
379  void setWeightAndWeightChangeUpdate(UpdateInterval wtANDwtChangeUpdateInterval, bool enableWtChangeDecay, float wtChangeDecay);
380 
381  // +++++ PUBLIC METHODS: RUNNING A SIMULATION +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
382 
388  int runNetwork(int _nsec, int _nmsec, bool printRunSummary);
389 
394  void setupNetwork();
395 
396  // +++++ PUBLIC METHODS: INTERACTING WITH A SIMULATION ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
397 
398  // adds a bias to every weight in the connection
399  void biasWeights(short int connId, float bias, bool updateWeightRange = false);
400 
402  void exitSimulation(int val = 1);
403 
406  /*
407  * \brief After calling SNN::loadSimulation, you should run SNN::runNetwork before calling fclose(fp).
408  * \param fid: file pointer
409  * \sa SNN::saveSimulation()
410  */
411  void loadSimulation(FILE* fid);
412 
413  // multiplies every weight with a scaling factor
414  void scaleWeights(short int connId, float scale, bool updateWeightRange = false);
415 
417 
421  GroupMonitor* setGroupMonitor(int grpId, FILE* fid);
422 
424 
429  ConnectionMonitor* setConnectionMonitor(int grpIdPre, int grpIdPost, FILE* fid);
430 
432  void setExternalCurrent(int grpId, const std::vector<float>& current);
433 
435  void setSpikeGenerator(int grpId, SpikeGeneratorCore* spikeGenFunc);
436 
438 
443  SpikeMonitor* setSpikeMonitor(int gid, FILE* fid);
444 
446 
451  NeuronMonitor* setNeuronMonitor(int gid, FILE* fid);
452 
454 
459  void setSpikeRate(int grpId, PoissonRate* spikeRate, int refPeriod);
460 
462  void setWeight(short int connId, int neurIdPre, int neurIdPost, float weight, bool updateWeightRange = false);
463 
465  void startTesting(bool shallUpdateWeights = true);
466 
468  void stopTesting();
469 
471  void updateConnectionMonitor(short int connId = ALL);
472 
474  void updateGroupMonitor(int grpId = ALL);
475 
486  void updateSpikeMonitor(int grpId = ALL);
487 
498  void updateNeuronMonitor(int grpId = ALL);
499 
501  /*
502  * \param fid file pointer
503  */
504  void saveSimulation(FILE* fid, bool saveSynapseInfo = false);
505 
507  //void writePopWeights(std::string fname, int gIDpre, int gIDpost);
508 
509 
510  // +++++ PUBLIC METHODS: LOGGING / PLOTTING +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
511 
513  const FILE* getLogFpInf() { return fpInf_; }
515  const FILE* getLogFpErr() { return fpErr_; }
517  const FILE* getLogFpDeb() { return fpDeb_; }
519  const FILE* getLogFpLog() { return fpLog_; }
520 
525  void setLogsFp(FILE* fpInf = NULL, FILE* fpErr = NULL, FILE* fpDeb = NULL, FILE* fpLog = NULL);
526 
527 
528  // +++++ PUBLIC METHODS: GETTERS / SETTERS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
529 
530  short int getConnectId(int grpIdPre, int grpIdPost);
531  ConnectConfig getConnectConfig(short int connectId);
532 
534  RangeDelay getDelayRange(short int connId);
535 
537 
545  uint8_t* getDelays(int gGrpIdPre, int gGrpIdPost, int& numPreN, int& numPostN);
546 
547  Grid3D getGroupGrid3D(int grpId);
548  int getGroupId(std::string grpName);
549  std::string getGroupName(int grpId);
550  GroupSTDPInfo getGroupSTDPInfo(int grpId);
552 
553  LoggerMode getLoggerMode() { return loggerMode_; }
554 
555  // get functions for GroupInfo
556  int getGroupStartNeuronId(int gGrpId) { return groupConfigMDMap[gGrpId].gStartN; }
557  int getGroupEndNeuronId(int gGrpId) { return groupConfigMDMap[gGrpId].gEndN; }
558  int getGroupNumNeurons(int gGrpId) { return groupConfigMap[gGrpId].numN; }
559 
560  std::string getNetworkName() { return networkName_; }
561 
562  Point3D getNeuronLocation3D(int neurId);
563  Point3D getNeuronLocation3D(int grpId, int relNeurId);
564 
565  int getNumConnections() { return numConnections; }
566  int getNumSynapticConnections(short int connectionId);
567  int getNumCompartmentConnections() { return numCompartmentConnections; }
568  int getNumGroups() { return numGroups; }
569  int getNumNeurons() { return glbNetworkConfig.numN; }
570  int getNumNeuronsReg() { return glbNetworkConfig.numNReg; }
571  int getNumNeuronsRegExc() { return glbNetworkConfig.numNExcReg; }
572  int getNumNeuronsRegInh() { return glbNetworkConfig.numNInhReg; }
573  int getNumNeuronsGen() { return glbNetworkConfig.numNPois; }
574  int getNumNeuronsGenExc() { return glbNetworkConfig.numNExcPois; }
575  int getNumNeuronsGenInh() { return glbNetworkConfig.numNInhPois; }
576  int getNumSynapses() { return glbNetworkConfig.numSynNet; }
577 
578  int getRandSeed() { return randSeed_; }
579 
580  int getSimTime() { return simTime; }
581  int getSimTimeSec() { return simTimeSec; }
582  int getSimTimeMs() { return simTimeMs; }
583 
585  SpikeMonitor* getSpikeMonitor(int grpId);
586 
590 
592  NeuronMonitor* getNeuronMonitor(int grpId);
593 
597 
599  float* getCurrent() { return managerRuntimeData.current; }
600 
601  std::vector< std::vector<float> > getWeightMatrix2D(short int connId);
602 
603  std::vector<float> getConductanceAMPA(int grpId);
604  std::vector<float> getConductanceNMDA(int grpId);
605  std::vector<float> getConductanceGABAa(int grpId);
606  std::vector<float> getConductanceGABAb(int grpId);
607 
609  float* getSTPu() { return managerRuntimeData.stpu; }
610 
612  float* getSTPx() { return managerRuntimeData.stpx; }
613 
615  bool isConnectionPlastic(short int connId);
616 
618  RangeWeight getWeightRange(short int connId);
619 
620  bool isExcitatoryGroup(int gGrpId) { return (groupConfigMap[gGrpId].type & TARGET_AMPA) || (groupConfigMap[gGrpId].type & TARGET_NMDA); }
621  bool isInhibitoryGroup(int gGrpId) { return (groupConfigMap[gGrpId].type & TARGET_GABAa) || (groupConfigMap[gGrpId].type & TARGET_GABAb); }
622  bool isPoissonGroup(int gGrpId) { return (groupConfigMap[gGrpId].type & POISSON_NEURON); }
623  bool isDopaminergicGroup(int gGrpId) { return (groupConfigMap[gGrpId].type & TARGET_DA); }
624 
626  bool isGroupWithHomeostasis(int grpId);
627 
629  double getRFDist3D(const RadiusRF& radius, const Point3D& pre, const Point3D& post);
630  bool isPoint3DinRF(const RadiusRF& radius, const Point3D& pre, const Point3D& post);
631 
632  bool isSimulationWithCompartments() { return sim_with_compartments; }
633  bool isSimulationWithCOBA() { return sim_with_conductances; }
634  bool isSimulationWithCUBA() { return !sim_with_conductances; }
635  bool isSimulationWithNMDARise() { return sim_with_NMDA_rise; }
636  bool isSimulationWithGABAbRise() { return sim_with_GABAb_rise; }
637  bool isSimulationWithFixedWeightsOnly() { return sim_with_fixedwts; }
638  bool isSimulationWithHomeostasis() { return sim_with_homeostasis; }
639  bool isSimulationWithPlasticWeights() { return !sim_with_fixedwts; }
640  bool isSimulationWithSTDP() { return sim_with_stdp; }
641  bool isSimulationWithSTP() { return sim_with_stp; }
642 
643  // **************************************************************************************************************** //
644  // PRIVATE METHODS
645  // **************************************************************************************************************** //
646 
647 private:
649  void SNNinit();
650 
652  void advSimStep();
653 
655  void allocateManagerRuntimeData();
656 
657  int assignGroup(int gGrpId, int availableNeuronId);
658  int assignGroup(std::list<GroupConfigMD>::iterator grpIt, int localGroupId, int availableNeuronId);
659  void generateGroupRuntime(int netId, int lGrpId);
660  void generatePoissonGroupRuntime(int netId, int lGrpId);
661  void generateConnectionRuntime(int netId);
662  void generateCompConnectionRuntime(int netId);
663 
667  void generateRuntimeNetworkConfigs();
668  void generateRuntimeGroupConfigs();
669  void generateRuntimeConnectConfigs();
670 
674  void collectGlobalNetworkConfigC();
675  void compileConnectConfig();
676  void compileGroupConfig();
677 
678  void collectGlobalNetworkConfigP();
679 
683  void connectNetwork();
684  inline void connectNeurons(int netId, int srcGrp, int destGrp, int srcN, int destN, short int connId, int externalNetId);
685  inline void connectNeurons(int netId, int _grpSrc, int _grpDest, int _nSrc, int _nDest, short int _connId, float initWt, float maxWt, uint8_t delay, int externalNetId);
686  void connectFull(int netId, std::list<ConnectConfig>::iterator connIt, bool isExternal);
687  void connectOneToOne(int netId, std::list<ConnectConfig>::iterator connIt, bool isExternal);
688  void connectRandom(int netId, std::list<ConnectConfig>::iterator connIt, bool isExternal);
689  void connectGaussian(int netId, std::list<ConnectConfig>::iterator connIt, bool isExternal);
690  void connectUserDefined(int netId, std::list<ConnectConfig>::iterator connIt, bool isExternal);
691 
692  void deleteObjects();
693 
694  void findMaxNumSynapsesGroups(int* _maxNumPostSynGrp, int* _maxNumPreSynGrp);
695  void findMaxNumSynapsesNeurons(int _netId, int& _maxNumPostSynN, int& _maxNumPreSynN);
696  void findMaxSpikesD1D2(int netId, unsigned int& _maxSpikesD1, unsigned int& _maxSpikesD2);
697  void findNumSynapsesNetwork(int netId, int& _numPostSynNet, int& _numPreSynNet);
698  void findNumN(int _netId, int& _numN, int& _nunNExternal, int& numNAssigned,
699  int& _numNReg, int& _numNExcReg, int& _numNInhReg,
700  int& _numNPois, int& _numNExcPois, int& _numNInhPois);
701  void findNumNSpikeGenAndOffset(int _netId);
702 
703  void generatePostSynapticSpike(int preNId, int postNId, int synId, int tD, int netId);
704  void fillSpikeGenBits(int netId);
705  void userDefinedSpikeGenerator(int gGrpId);
706 
707  float generateWeight(int connProp, float initWt, float maxWt, int nid, int grpId);
708 
710  void verifyNetwork();
711 
713  void verifySTDP();
714 
716  void verifyHomeostasis();
717 
719  void verifyCompartments();
720 
722  //void verifyNumNeurons();
723 
724  void compileSNN();
725 
726  void partitionSNN();
727 
728  void generateRuntimeSNN();
729 
748  //int poissonSpike(int currTime, float frate, int refractPeriod);
749 
750  void printConnectionInfo(short int connId);
751  void printConnectionInfo(int netId, std::list<ConnectConfig>::iterator connIt);
752  void printGroupInfo(int grpId);
753  void printGroupInfo(int netId, std::list<GroupConfigMD>::iterator grpIt);
754  void printSimSummary();
755  void printStatusConnectionMonitor(int connId = ALL);
756  void printStatusGroupMonitor(int gGrpId = ALL);
757  void printStatusSpikeMonitor(int gGrpId = ALL);
758  void printSikeRoutingInfo();
759 
760  int loadSimulation_internal(bool onlyPlastic);
761 
762  void resetConductances(int netId);
763  void resetCurrent(int netId);
764  void resetFiringInformation();
765  void resetGroupConfigs(bool deallocate = false);
766  void resetNeuromodulator(int netId, int lGrpId);
767  void resetNeuron(int netId, int lGrpId, int lNId);
768  void resetMonitors(bool deallocate = false);
769  void resetConnectionConfigs(bool deallocate = false);
770  void deleteManagerRuntimeData();
771  void resetPoissonNeuron(int netId, int lGrpId, int lNId);
772  void resetPropogationBuffer();
773  void resetSynapse(int netId, bool changeWeights = false);
774  void resetTimeTable();
775  void resetFiringTable();
776  void routeSpikes();
777  void transferSpikes(void* dest, int destNetId, void* src, int srcNetId, int size);
778  void resetTiming();
779 
780  inline SynInfo SET_CONN_ID(int nid, int sid, int grpId);
781 
782  void setGrpTimeSlice(int grpId, int timeSlice);
783  int setRandSeed(int seed);
784 
785  void startTiming();
786  void stopTiming();
787 
788  void generateUserDefinedSpikes();
789 
790  void allocateManagerSpikeTables();
791 
792  bool updateTime();
793 
794  float getCompCurrent(int netid, int lGrpId, int lneurId, float const0 = 0.0f, float const1 = 0.0f);
795 
796  // Abstract layer for setupNetwork() and runNetwork()
797  void allocateSNN(int netId);
798  void clearExtFiringTable();
799  void convertExtSpikesD1(int netId, int startIdx, int endIdx, int GtoLOffset);
800  void convertExtSpikesD2(int netId, int startIdx, int endIdx, int GtoLOffset);
801  void doCurrentUpdate();
802  void doSTPUpdateAndDecayCond();
803  void deleteRuntimeData();
804  void findFiring();
805  void globalStateUpdate();
806  void resetSpikeCnt(int gGrpId);
807  void shiftSpikeTables();
808  void spikeGeneratorUpdate();
809  void updateTimingTable();
810  void updateWeights();
811  void updateNetworkConfig(int netId);
812 
813  // Abstract layer for trasferring data (local-to-global copy)
814  void fetchConductanceAMPA(int gGrpId);
815  void fetchConductanceNMDA(int gGrpId);
816  void fetchConductanceGABAa(int gGrpId);
817  void fetchConductanceGABAb(int gGrpId);
818  void fetchNetworkSpikeCount();
819  void fetchNeuronSpikeCount(int gGrpId);
820  void fetchSTPState(int gGrpId);
821 
822  // Abstract layer for trasferring data (local-to-local copy)
823  void fetchSpikeTables(int netId);
824  void fetchNeuronStateBuffer(int netId, int lGrpId);
825  void fetchGroupState(int netId, int lGrpId);
826  void fetchWeightState(int netId, int lGrpId);
827  void fetchGrpIdsLookupArray(int netId);
828  void fetchConnIdsLookupArray(int netId);
829  void fetchLastSpikeTime(int netId);
830  void fetchPreConnectionInfo(int netId);
831  void fetchPostConnectionInfo(int netId);
832  void fetchSynapseState(int netId);
833  void fetchExtFiringTable(int netId);
834  void fetchTimeTable(int netId);
835  void writeBackTimeTable(int netId);
836 
837 #ifndef __NO_CUDA__
838  // GPU implementation for setupNetwork() and runNetwork()
839  void allocateSNN_GPU(int netId);
840  void assignPoissonFiringRate_GPU(int netId);
841  void clearExtFiringTable_GPU(int netId);
842  void convertExtSpikesD1_GPU(int netId, int startIdx, int endIdx, int GtoLOffset);
843  void convertExtSpikesD2_GPU(int netId, int startIdx, int endIdx, int GtoLOffset);
844  void doCurrentUpdateD1_GPU(int netId);
845  void doCurrentUpdateD2_GPU(int netId);
846  void doSTPUpdateAndDecayCond_GPU(int netId);
847  void deleteRuntimeData_GPU(int netId);
848  void findFiring_GPU(int netId);
849  void globalStateUpdate_C_GPU(int netId);
850  void globalStateUpdate_N_GPU(int netId);
851  void globalStateUpdate_G_GPU(int netId);
852  void resetSpikeCnt_GPU(int netId, int lGrpId);
853  void shiftSpikeTables_F_GPU(int netId);
854  void shiftSpikeTables_T_GPU(int netId);
855  void spikeGeneratorUpdate_GPU(int netId);
856  void updateTimingTable_GPU(int netId);
857  void updateWeights_GPU(int netId);
858 #else
859  void allocateSNN_GPU(int netId) { assert(false); }
860  void assignPoissonFiringRate_GPU(int netId) { assert(false); }
861  void clearExtFiringTable_GPU(int netId) { assert(false); }
862  void convertExtSpikesD1_GPU(int netId, int startIdx, int endIdx, int GtoLOffset) { assert(false); }
863  void convertExtSpikesD2_GPU(int netId, int startIdx, int endIdx, int GtoLOffset) { assert(false); }
864  void doCurrentUpdateD1_GPU(int netId) { assert(false); }
865  void doCurrentUpdateD2_GPU(int netId) { assert(false); }
866  void doSTPUpdateAndDecayCond_GPU(int netId) { assert(false); }
867  void deleteRuntimeData_GPU(int netId) { assert(false); }
868  void findFiring_GPU(int netId) { assert(false); }
869  void globalStateUpdate_C_GPU(int netId) { assert(false); }
870  void globalStateUpdate_N_GPU(int netId) { assert(false); }
871  void globalStateUpdate_G_GPU(int netId) { assert(false); }
872  void resetSpikeCnt_GPU(int netId, int lGrpId) { assert(false); }
873  void shiftSpikeTables_F_GPU(int netId) { assert(false); }
874  void shiftSpikeTables_T_GPU(int netId) { assert(false); }
875  void spikeGeneratorUpdate_GPU(int netId) { assert(false); }
876  void updateTimingTable_GPU(int netId) { assert(false); }
877  void updateWeights_GPU(int netId) { assert(false); }
878 #endif
879 
880 #ifndef __NO_CUDA__
881  // GPU backend: utility function
882  void allocateGroupId(int netId);
883  int allocateStaticLoad(int netId, int bufSize);
884  void checkAndSetGPUDevice(int netId);
885  void checkDestSrcPtrs(RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem, int grpId, int destOffset);
886  int configGPUDevice();
887  void initGPU(int netId);
888 #else
889  int configGPUDevice() { return 0; }
890 #endif
891 
892 #ifndef __NO_CUDA__
893  // GPU backend: data transfer functions
894  void copyAuxiliaryData(int netId, int lGrpId, RuntimeData* dest, cudaMemcpyKind kind, bool allocateMem);
895  void copyConductanceAMPA(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem, int destOffset);
896  void copyConductanceNMDA(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem, int destOffset);
897  void copyConductanceGABAa(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem, int destOffset);
898  void copyConductanceGABAb(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem, int destOffset);
899  void copyPreConnectionInfo(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem);
900  void copyPostConnectionInfo(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem);
901  void copyExternalCurrent(int netId, int lGrpId, RuntimeData* dest, cudaMemcpyKind kind, bool allocateMem);
902  void copyNeuronParameters(int netId, int lGrpId, RuntimeData* dest, cudaMemcpyKind kind, bool allocateMem);
903  void copyGroupState(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem);
904  void copyNeuronState(int netId, int lGrpId, RuntimeData* dest, cudaMemcpyKind kind, bool allocateMem);
905  void copyNeuronStateBuffer(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem);
906  void copyNeuronSpikeCount(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem, int destOffset);
907  void copySynapseState(int netId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem);
908  void copySTPState(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem);
909  void copyWeightState(int netId, int lGrpId, cudaMemcpyKind kind);
910  void copyNetworkConfig(int netId, cudaMemcpyKind kind);
911  void copyGroupConfigs(int netId);
912  void copyGrpIdsLookupArray(int netId, cudaMemcpyKind kind);
913  void copyConnIdsLookupArray(int netId, cudaMemcpyKind kind);
914  void copyLastSpikeTime(int netId, cudaMemcpyKind kind);
915  void copyNetworkSpikeCount(int netId, cudaMemcpyKind kind,
916  unsigned int* spikeCountD1, unsigned int* spikeCountD2,
917  unsigned int* spikeCountExtD1, unsigned int* spikeCountExtD2);
918  void copySpikeTables(int netId, cudaMemcpyKind kind);
919  void copyTimeTable(int netId, cudaMemcpyKind kind);
920  void copyExtFiringTable(int netId, cudaMemcpyKind kind);
921 #else
922  #define cudaMemcpyKind int
923  #define cudaMemcpyHostToHost 0
924  #define cudaMemcpyHostToDevice 0
925  #define cudaMemcpyDeviceToHost 0
926  #define cudaMemcpyDeviceToDevice 0
927  #define cudaMemcpyDefault 0
928 
929  void copyAuxiliaryData(int netId, int lGrpId, RuntimeData* dest, cudaMemcpyKind kind, bool allocateMem) { assert(false); }
930  void copyConductanceAMPA(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem, int destOffset) { assert(false); }
931  void copyConductanceNMDA(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem, int destOffset) { assert(false); }
932  void copyConductanceGABAa(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem, int destOffset) { assert(false); }
933  void copyConductanceGABAb(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem, int destOffset) { assert(false); }
934  void copyPreConnectionInfo(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem) { assert(false); }
935  void copyPostConnectionInfo(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem) { assert(false); }
936  void copyExternalCurrent(int netId, int lGrpId, RuntimeData* dest, cudaMemcpyKind kind, bool allocateMem) { assert(false); }
937  void copyNeuronParameters(int netId, int lGrpId, RuntimeData* dest, cudaMemcpyKind kind, bool allocateMem) { assert(false); }
938  void copyGroupState(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem) { assert(false); }
939  void copyNeuronState(int netId, int lGrpId, RuntimeData* dest, cudaMemcpyKind kind, bool allocateMem) { assert(false); }
940  void copyNeuronStateBuffer(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem) { assert(false); }
941  void copyNeuronSpikeCount(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem, int destOffset) { assert(false); }
942  void copySynapseState(int netId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem) { assert(false); }
943  void copySTPState(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem) { assert(false); }
944  void copyWeightState(int netId, int lGrpId, cudaMemcpyKind kind) { assert(false); }
945  void copyNetworkConfig(int netId, cudaMemcpyKind kind) { assert(false); }
946  void copyGroupConfigs(int netId) { assert(false); }
947  void copyGrpIdsLookupArray(int netId, cudaMemcpyKind kind) { assert(false); }
948  void copyConnIdsLookupArray(int netId, cudaMemcpyKind kind) { assert(false); }
949  void copyLastSpikeTime(int netId, cudaMemcpyKind kind) { assert(false); }
950  void copyNetworkSpikeCount(int netId, cudaMemcpyKind kind,
951  unsigned int* spikeCountD1, unsigned int* spikeCountD2,
952  unsigned int* spikeCountExtD1, unsigned int* spikeCountExtD2) { assert(false); }
953  void copySpikeTables(int netId, cudaMemcpyKind kind) { assert(false); }
954  void copyTimeTable(int netId, cudaMemcpyKind kind) { assert(false); }
955  void copyExtFiringTable(int netId, cudaMemcpyKind kind) { assert(false); }
956 #endif
957 
958  // CPU implementation for setupNetwork() and runNetwork()
959 
960  //allocates runtime data on CPU memory
961  void allocateSNN_CPU(int netId);
962 
963  // runNetwork functions - multithreaded in LINUX using pthreads
964 #if defined(WIN32) || defined(WIN64) || defined(__APPLE__)
965  void assignPoissonFiringRate_CPU(int netId);
966  void clearExtFiringTable_CPU(int netId);
967  void convertExtSpikesD2_CPU(int netId, int startIdx, int endIdx, int GtoLOffset);
968  void convertExtSpikesD1_CPU(int netId, int startIdx, int endIdx, int GtoLOffset);
969  void doCurrentUpdateD2_CPU(int netId);
970  void doCurrentUpdateD1_CPU(int netId);
971  void doSTPUpdateAndDecayCond_CPU(int netId);
972  void deleteRuntimeData_CPU(int netId);
973  void findFiring_CPU(int netId);
974  void globalStateUpdate_CPU(int netId);
975  void resetSpikeCnt_CPU(int netId, int lGrpId);
976  void shiftSpikeTables_CPU(int netId);
977  void spikeGeneratorUpdate_CPU(int netId);
978  void updateTimingTable_CPU(int netId);
979  void updateWeights_CPU(int netId);
980 #else // for APPLE and Win systems - returns a void* to pthread_create - only differ in the return type compared to the counterparts above
981  void* assignPoissonFiringRate_CPU(int netId);
982  void* clearExtFiringTable_CPU(int netId);
983  void* convertExtSpikesD2_CPU(int netId, int startIdx, int endIdx, int GtoLOffset);
984  void* convertExtSpikesD1_CPU(int netId, int startIdx, int endIdx, int GtoLOffset);
985  void* doCurrentUpdateD2_CPU(int netId);
986  void* doCurrentUpdateD1_CPU(int netId);
987  void* doSTPUpdateAndDecayCond_CPU(int netId);
988  void* deleteRuntimeData_CPU(int netId);
989  void* findFiring_CPU(int netId);
990  void* globalStateUpdate_CPU(int netId);
991  void* resetSpikeCnt_CPU(int netId, int lGrpId);
992  void* shiftSpikeTables_CPU(int netId);
993  void* spikeGeneratorUpdate_CPU(int netId);
994  void* updateTimingTable_CPU(int netId);
995  void* updateWeights_CPU(int netId);
996 
997  // static multithreading helper methods for the above CPU runNetwork() methods
998  static void* helperAssignPoissonFiringRate_CPU(void*);
999  static void* helperClearExtFiringTable_CPU(void*);
1000  static void* helperConvertExtSpikesD2_CPU(void*);
1001  static void* helperConvertExtSpikesD1_CPU(void*);
1002  static void* helperDoCurrentUpdateD2_CPU(void*);
1003  static void* helperDoCurrentUpdateD1_CPU(void*);
1004  static void* helperDoSTPUpdateAndDecayCond_CPU(void*);
1005  static void* helperDeleteRuntimeData_CPU(void*);
1006  static void* helperFindFiring_CPU(void*);
1007  static void* helperGlobalStateUpdate_CPU(void*);
1008  static void* helperResetSpikeCnt_CPU(void*);
1009  static void* helperShiftSpikeTables_CPU(void*);
1010  static void* helperSpikeGeneratorUpdate_CPU(void*);
1011  static void* helperUpdateTimingTable_CPU(void*);
1012  static void* helperUpdateWeights_CPU(void*);
1013 #endif
1014 
1015  // CPU computing backend: data transfer function
1016  void copyAuxiliaryData(int netId, int lGrpId, RuntimeData* dest, bool allocateMem);
1017  void copyConductanceAMPA(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, bool allocateMem, int destOffset);
1018  void copyConductanceNMDA(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, bool allocateMem, int destOffset);
1019  void copyConductanceGABAa(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, bool allocateMem, int destOffset);
1020  void copyConductanceGABAb(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, bool allocateMem, int destOffset);
1021  void copyPreConnectionInfo(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, bool allocateMem);
1022  void copyPostConnectionInfo(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, bool allocateMem);
1023  void copyExternalCurrent(int netId, int lGrpId, RuntimeData* dest, bool allocateMem);
1024  void copyNeuronParameters(int netId, int lGrpId, RuntimeData* dest, bool allocateMem);
1025  void copyGroupState(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, bool allocateMem);
1026  void copyNeuronStateBuffer(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, bool allocateMem);
1027  void copyNeuronState(int netId, int lGrpId, RuntimeData* dest, bool allocateMem);
1028  void copyNeuronSpikeCount(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, bool allocateMem, int destOffset);
1029  void copySynapseState(int netId, RuntimeData* dest, RuntimeData* src, bool allocateMem);
1030  void copySTPState(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, bool allocateMem);
1031  void copyWeightState(int netId, int lGrpId);
1032  void copyNetworkConfig(int netId);
1033  void copyGrpIdsLookupArray(int netId);
1034  void copyConnIdsLookupArray(int netId);
1035  void copyLastSpikeTime(int netId);
1036  void copyNetworkSpikeCount(int netId,
1037  unsigned int* spikeCountD1, unsigned int* spikeCountD2,
1038  unsigned int* spikeCountExtD1, unsigned int* spikeCountExtD2);
1039  void copySpikeTables(int netId);
1040  void copyTimeTable(int netId, bool toManager);
1041  void copyExtFiringTable(int netId);
1042 
1043  // CPU backend: utility function
1044  void firingUpdateSTP(int lNId, int lGrpId, int netId);
1045  void updateLTP(int lNId, int lGrpId, int netId);
1046  void resetFiredNeuron(int lNId, short int lGrpId, int netId);
1047  bool getPoissonSpike(int lNId, int netId);
1048  bool getSpikeGenBit(unsigned int nIdPos, int netId);
1049 
1050  // +++++ PRIVATE PROPERTIES +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
1051  SNNState snnState;
1052  FILE* loadSimFID;
1053 
1054  const std::string networkName_;
1055  const LoggerMode loggerMode_;
1056  const SimMode preferredSimMode_;
1057  const int randSeed_;
1058 
1059  int numGPUs;
1060  int numCores;
1061 
1062  int numAvailableGPUs;
1063 
1064  bool simulatorDeleted;
1065  bool spikeRateUpdated;
1066 
1068  bool sim_in_testing;
1069 
1070  int numGroups;
1071  int numConnections;
1072  int numCompartmentConnections;
1073 
1074  std::map<int, GroupConfig> groupConfigMap;
1075  std::map<int, GroupConfigMD> groupConfigMDMap;
1076  std::map<int, ConnectConfig> connectConfigMap;
1077  std::map<int, compConnectConfig> compConnectConfigMap;
1078 
1079  // data structure assisting network partitioning
1080  std::list<GroupConfigMD> groupPartitionLists[MAX_NET_PER_SNN];
1081  std::list<ConnectConfig> localConnectLists[MAX_NET_PER_SNN];
1082  std::list<ConnectConfig> externalConnectLists[MAX_NET_PER_SNN];
1083  std::list<compConnectConfig> localCompConnectLists[MAX_NET_PER_SNN];
1084 
1085  std::list<ConnectionInfo> connectionLists[MAX_NET_PER_SNN];
1086 
1087  std::list<RoutingTableEntry> spikeRoutingTable;
1088 
1089  float *mulSynFast;
1090  float *mulSynSlow;
1091 
1093  SpikeBuffer* spikeBuf;
1094 
1095  bool sim_with_conductances;
1096  bool sim_with_NMDA_rise;
1097  bool sim_with_GABAb_rise;
1098  double dAMPA;
1099  double rNMDA;
1100  double dNMDA;
1101  double sNMDA;
1102  double dGABAa;
1103  double rGABAb;
1104  double dGABAb;
1105  double sGABAb;
1106 
1107  bool sim_with_compartments;
1108  bool sim_with_fixedwts;
1109  bool sim_with_stdp;
1110  bool sim_with_modulated_stdp;
1111  bool sim_with_homeostasis;
1112  bool sim_with_stp;
1113  bool sim_with_spikecounters;
1114 
1115  GlobalNetworkConfig glbNetworkConfig;
1116 
1117  //time and timestep
1118  int simTimeRunStart;
1119  int simTimeRunStop;
1120  int simTimeLastRunSummary;
1121  int simTimeMs;
1122  int simTimeSec;
1123  int simTime;
1124 
1126 #ifndef __NO_CUDA__
1127  StopWatchInterface* timer;
1128 #endif
1129  float cumExecutionTime;
1130  float lastExecutionTime;
1131  float prevExecutionTime;
1132  float executionTime;
1133 
1134  FILE* fpInf_;
1135  FILE* fpErr_;
1136  FILE* fpDeb_;
1137  FILE* fpLog_;
1138 
1139  // keep track of number of SpikeMonitor/SpikeMonitorCore objects
1140  int numSpikeMonitor;
1141  SpikeMonitorCore* spikeMonCoreList[MAX_GRP_PER_SNN];
1142  SpikeMonitor* spikeMonList[MAX_GRP_PER_SNN];
1143 
1144  // neuron monitor variables
1145  int numNeuronMonitor;
1146  NeuronMonitor* neuronMonList[MAX_GRP_PER_SNN];
1147  NeuronMonitorCore* neuronMonCoreList[MAX_GRP_PER_SNN];
1148 
1149  // \FIXME \DEPRECATED this one moved to group-based
1150  long int simTimeLastUpdSpkMon_;
1151 
1152  int numSpikeGenGrps;
1153 
1154  // keep track of number of GroupMonitor/GroupMonitorCore objects
1155  int numGroupMonitor;
1156  GroupMonitorCore* groupMonCoreList[MAX_GRP_PER_SNN];
1157  GroupMonitor* groupMonList[MAX_GRP_PER_SNN];
1158 
1159  // neuron monitor variables
1160  //NeuronMonitorCore* neurBufferCallback[MAX_]
1161  //int numNeuronMonitor;
1162 
1163  // connection monitor variables
1164  int numConnectionMonitor;
1165  ConnectionMonitorCore* connMonCoreList[MAX_CONN_PER_SNN];
1166  ConnectionMonitor* connMonList[MAX_CONN_PER_SNN];
1167 
1168  RuntimeData runtimeData[MAX_NET_PER_SNN];
1169  RuntimeData managerRuntimeData;
1170 
1171  typedef struct ManagerRuntimeDataSize_s {
1172  unsigned int maxMaxSpikeD1;
1173  unsigned int maxMaxSpikeD2;
1174  int maxNumN;
1175  int maxNumNReg;
1176  int maxNumNSpikeGen;
1177  int maxNumNAssigned;
1178  int maxNumGroups;
1179  int maxNumConnections;
1180  int maxNumPostSynNet;
1181  int maxNumPreSynNet;
1182  int maxNumNPerGroup;
1183  int glbNumN;
1184  int glbNumNReg;
1185  } ManagerRuntimeDataSize;
1186 
1187  ManagerRuntimeDataSize managerRTDSize;
1188 
1189  // runtime configurations
1190  NetworkConfigRT networkConfigs[MAX_NET_PER_SNN];
1193 
1194  // weight update parameter
1195  int wtANDwtChangeUpdateInterval_;
1196  int wtANDwtChangeUpdateIntervalCnt_;
1197  float stdpScaleFactor_;
1198  float wtChangeDecay_;
1199 };
1200 
1201 #endif
SNN::getNumNeuronsRegInh
int getNumNeuronsRegInh()
Definition: snn.h:572
SNN::getNeuronMonitor
NeuronMonitor * getNeuronMonitor(int grpId)
Returns pointer to existing NeuronMonitor object, NULL else.
Definition: snn_manager.cpp:1980
SNN::getSimTimeSec
int getSimTimeSec()
Definition: snn.h:581
POISSON_NEURON
#define POISSON_NEURON
Definition: carlsim_definitions.h:65
SNN::getGroupNumNeurons
int getGroupNumNeurons(int gGrpId)
Definition: snn.h:558
SNN::setGroupMonitor
GroupMonitor * setGroupMonitor(int grpId, FILE *fid)
sets up a group monitor registered with a callback to process the spikes.
Definition: snn_manager.cpp:1087
SNN::getGroupStartNeuronId
int getGroupStartNeuronId(int gGrpId)
Definition: snn.h:556
SNN::setConductances
void setConductances(bool isSet, int tdAMPA, int trNMDA, int tdNMDA, int tdGABAa, int trGABAb, int tdGABAb)
Sets custom values for conductance decay (\tau_decay) or disables conductances alltogether These will...
Definition: snn_manager.cpp:408
TARGET_GABAb
#define TARGET_GABAb
Definition: carlsim_definitions.h:69
SynInfo_s
Definition: snn_datastructures.h:89
SimMode
SimMode
simulation mode
Definition: carlsim_datastructures.h:113
SNN::getNetworkName
std::string getNetworkName()
Definition: snn.h:560
integrationMethod_t
integrationMethod_t
Integration methods.
Definition: carlsim_datastructures.h:132
TARGET_DA
#define TARGET_DA
Definition: carlsim_definitions.h:70
GroupConfigRT_s
The runtime configuration of a group.
Definition: snn_datastructures.h:373
SpikeMonitorCore
Definition: spike_monitor_core.h:70
SNN::loadSimulation
void loadSimulation(FILE *fid)
Definition: snn_manager.cpp:1000
SNN::getNumGroups
int getNumGroups()
Definition: snn.h:568
SNN::setNeuronParametersLIF
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.
Definition: snn_manager.cpp:574
SNN::biasWeights
void biasWeights(short int connId, float bias, bool updateWeightRange=false)
Definition: snn_manager.cpp:915
RangeWeight
a range struct for synaptic weight magnitudes
Definition: carlsim_datastructures.h:311
SpikeMonitor
Class SpikeMonitor.
Definition: spike_monitor.h:119
SNN::connect
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
Definition: snn_manager.cpp:95
SNN::isSimulationWithGABAbRise
bool isSimulationWithGABAbRise()
Definition: snn.h:636
SNN::getNumNeuronsRegExc
int getNumNeuronsRegExc()
Definition: snn.h:571
SNN::saveSimulation
void saveSimulation(FILE *fid, bool saveSynapseInfo=false)
stores the pre and post synaptic neuron ids with the weight and delay
Definition: snn_manager.cpp:1410
callback_core.h
MAX_CONN_PER_SNN
#define MAX_CONN_PER_SNN
Definition: snn_definitions.h:131
MAX_GRP_PER_SNN
#define MAX_GRP_PER_SNN
Definition: snn_definitions.h:132
SNN::getCurrent
float * getCurrent()
temporary getter to return pointer to current[]
Definition: snn.h:599
RuntimeData_s
Definition: snn_datastructures.h:450
SNN::getNumNeuronsGenExc
int getNumNeuronsGenExc()
Definition: snn.h:574
SNN::getConductanceGABAa
std::vector< float > getConductanceGABAa(int grpId)
Definition: snn_manager.cpp:1760
SNN::getGroupSTDPInfo
GroupSTDPInfo getGroupSTDPInfo(int grpId)
Definition: snn_manager.cpp:1873
SNN::setSpikeGenerator
void setSpikeGenerator(int grpId, SpikeGeneratorCore *spikeGenFunc)
sets up a spike generator
Definition: snn_manager.cpp:1173
SNN::isPoint3DinRF
bool isPoint3DinRF(const RadiusRF &radius, const Point3D &pre, const Point3D &post)
Definition: snn_manager.cpp:5061
SNN::runNetwork
int runNetwork(int _nsec, int _nmsec, bool printRunSummary)
run the simulation for n sec
Definition: snn_manager.cpp:793
SNN::setWeightAndWeightChangeUpdate
void setWeightAndWeightChangeUpdate(UpdateInterval wtANDwtChangeUpdateInterval, bool enableWtChangeDecay, float wtChangeDecay)
Sets the weight and weight change update parameters.
Definition: snn_manager.cpp:723
RuntimeData_s::stpx
float * stpx
Definition: snn_datastructures.h:511
SNN::getNeuronMonitorCore
NeuronMonitorCore * getNeuronMonitorCore(int grpId)
Definition: snn_manager.cpp:1991
ConnectionMonitorCore
Definition: connection_monitor_core.h:67
SpikeGeneratorCore
used for relaying callback to SpikeGenerator
Definition: callback_core.h:69
SNN::getNumSynapses
int getNumSynapses()
Definition: snn.h:576
SNN::updateGroupMonitor
void updateGroupMonitor(int grpId=ALL)
access group status (currently the concentration of neuromodulator)
Definition: snn_manager.cpp:6279
SNN::getSpikeMonitorCore
SpikeMonitorCore * getSpikeMonitorCore(int grpId)
Definition: snn_manager.cpp:1969
SNN::isConnectionPlastic
bool isConnectionPlastic(short int connId)
returns whether synapses in connection are fixed (false) or plastic (true)
Definition: snn_manager.cpp:4883
SNN::getRFDist3D
double getRFDist3D(const RadiusRF &radius, const Point3D &pre, const Point3D &post)
checks whether a point pre lies in the receptive field for point post
Definition: snn_manager.cpp:5070
SNN::setExternalCurrent
void setExternalCurrent(int grpId, const std::vector< float > &current)
injects current (mA) into the soma of every neuron in the group
Definition: snn_manager.cpp:1377
SNN::setLogsFp
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.
Definition: snn_manager.cpp:1671
NetworkConfigRT_s
runtime network configuration
Definition: snn_datastructures.h:625
RuntimeData_s::current
float * current
Definition: snn_datastructures.h:476
SNN::isSimulationWithHomeostasis
bool isSimulationWithHomeostasis()
Definition: snn.h:638
GroupSTDPInfo_s
A struct for retrieving STDP related information of a group.
Definition: carlsim_datastructures.h:411
SNN::getConnectConfig
ConnectConfig getConnectConfig(short int connectId)
required for homeostasis
Definition: snn_manager.cpp:1716
ConnectionGeneratorCore
used for relaying callback to ConnectionGenerator
Definition: callback_core.h:89
GlobalNetworkConfig_s
Definition: snn_datastructures.h:593
PoissonRate
Class for generating Poisson spike trains.
Definition: poisson_rate.h:84
GlobalNetworkConfig_s::numSynNet
int numSynNet
number of total synaptic connections in the global network
Definition: snn_datastructures.h:609
SNN::getConductanceNMDA
std::vector< float > getConductanceNMDA(int grpId)
Definition: snn_manager.cpp:1740
SNN::setCompartmentParameters
void setCompartmentParameters(int grpId, float couplingUp, float couplingDown)
Coupling constants for the compartment are set using this method.
Definition: snn_manager.cpp:392
SNN::startTesting
void startTesting(bool shallUpdateWeights=true)
enters a testing phase, where all weight updates are disabled
Definition: snn_manager.cpp:6180
ConnectConfigRT_s
The runtime configuration of a connection.
Definition: snn_datastructures.h:161
SNN::getNumNeuronsGenInh
int getNumNeuronsGenInh()
Definition: snn.h:575
SNN::isSimulationWithSTP
bool isSimulationWithSTP()
Definition: snn.h:641
SNN::setNeuromodulator
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,...
Definition: snn_manager.cpp:596
SNN::updateConnectionMonitor
void updateConnectionMonitor(short int connId=ALL)
polls connection weights
Definition: snn_manager.cpp:6218
GroupMonitorCore
GroupMonitor private core implementation.
Definition: group_monitor_core.h:63
SNN::getNumNeurons
int getNumNeurons()
Definition: snn.h:569
SNN::setSpikeMonitor
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...
Definition: snn_manager.cpp:1181
SNN::getSTPx
float * getSTPx()
temporary getter to return pointer to stpx[]
Definition: snn.h:612
SNN::isSimulationWithPlasticWeights
bool isSimulationWithPlasticWeights()
Definition: snn.h:639
SNN::updateNeuronMonitor
void updateNeuronMonitor(int grpId=ALL)
copy required neuron state values from ??? buffer to ??? buffer
Definition: snn_manager.cpp:6589
SNN::MINOR_VERSION
static const unsigned int MINOR_VERSION
minor release version, as in CARLsim 2.X
Definition: snn.h:138
SNN::getNumCompartmentConnections
int getNumCompartmentConnections()
Definition: snn.h:567
SNN::createGroup
int createGroup(const std::string &grpName, const Grid3D &grid, int neurType, int preferredPartition, ComputingBackend preferredBackend)
Creates a group of Izhikevich spiking neurons.
Definition: snn_manager.cpp:251
GlobalNetworkConfig_s::numNPois
int numNPois
number of poisson neurons in the global network
Definition: snn_datastructures.h:608
SNN::getGroupNeuromodulatorInfo
GroupNeuromodulatorInfo getGroupNeuromodulatorInfo(int grpId)
Definition: snn_manager.cpp:1900
RangeDelay
a range struct for synaptic delays
Definition: carlsim_datastructures.h:278
SNN::getGroupEndNeuronId
int getGroupEndNeuronId(int gGrpId)
Definition: snn.h:557
SNN::isSimulationWithCUBA
bool isSimulationWithCUBA()
Definition: snn.h:634
SNN::~SNN
~SNN()
SNN Destructor.
Definition: snn_manager.cpp:85
SNN::setupNetwork
void setupNetwork()
build the network
Definition: snn_manager.cpp:772
SNN::stopTesting
void stopTesting()
exits a testing phase, making weight updates possible again
Definition: snn_manager.cpp:6207
SNN::MAJOR_VERSION
static const unsigned int MAJOR_VERSION
major release version, as in CARLsim X
Definition: snn.h:137
GroupMonitor
Class GroupMonitor.
Definition: group_monitor.h:103
GlobalNetworkConfig_s::numNExcPois
int numNExcPois
number of excitatory poisson neurons in the global network
Definition: snn_datastructures.h:606
SNN::setNeuronMonitor
NeuronMonitor * setNeuronMonitor(int gid, FILE *fid)
sets up a neuron monitor registered with a callback to process the neuron state values,...
Definition: snn_manager.cpp:1221
SNN::isPoissonGroup
bool isPoissonGroup(int gGrpId)
Definition: snn.h:622
ALL
#define ALL
CARLsim common definitions.
Definition: carlsim_definitions.h:55
snn_definitions.h
SNN::getWeightMatrix2D
std::vector< std::vector< float > > getWeightMatrix2D(short int connId)
Definition: snn_manager.cpp:6232
SNN::getGroupId
int getGroupId(std::string grpName)
Definition: snn_manager.cpp:1852
ComputingBackend
ComputingBackend
computing backend
Definition: carlsim_datastructures.h:147
NeuronMonitorCore
Definition: neuron_monitor_core.h:58
SNN::getSpikeMonitor
SpikeMonitor * getSpikeMonitor(int grpId)
Returns pointer to existing SpikeMonitor object, NULL else.
Definition: snn_manager.cpp:1959
SNN::createSpikeGeneratorGroup
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)
Definition: snn_manager.cpp:348
SNN::isSimulationWithNMDARise
bool isSimulationWithNMDARise()
Definition: snn.h:635
SNN::isSimulationWithCompartments
bool isSimulationWithCompartments()
Definition: snn.h:632
SNN::getConductanceAMPA
std::vector< float > getConductanceAMPA(int grpId)
Definition: snn_manager.cpp:1727
SNN::SNN
SNN(const std::string &name, SimMode preferredSimMode, LoggerMode loggerMode, int randSeed)
SNN Constructor.
Definition: snn_manager.cpp:76
SNN::setWeight
void setWeight(short int connId, int neurIdPre, int neurIdPost, float weight, bool updateWeightRange=false)
sets the weight value of a specific synapse
Definition: snn_manager.cpp:1286
SNN::getSTPu
float * getSTPu()
temporary getter to return pointer to stpu[]
Definition: snn.h:609
SNN::getNeuronLocation3D
Point3D getNeuronLocation3D(int neurId)
Definition: snn_manager.cpp:1915
SNN::setIntegrationMethod
void setIntegrationMethod(integrationMethod_t method, int numStepsPerMs)
Sets the integration method and the number of integration steps per 1ms simulation time step.
Definition: snn_manager.cpp:496
SNN::scaleWeights
void scaleWeights(short int connId, float scale, bool updateWeightRange=false)
Definition: snn_manager.cpp:1005
SNN::getLogFpErr
const FILE * getLogFpErr()
returns file pointer to error log
Definition: snn.h:515
STDPCurve
STDPCurve
STDP curves.
Definition: carlsim_datastructures.h:177
poisson_rate.h
Point3D
a point in 3D space
Definition: linear_algebra.h:57
SNN::isSimulationWithFixedWeightsOnly
bool isSimulationWithFixedWeightsOnly()
Definition: snn.h:637
SNN::getSimTimeMs
int getSimTimeMs()
Definition: snn.h:582
GlobalNetworkConfig_s::numNInhPois
int numNInhPois
number of inhibitory poisson neurons in the global network
Definition: snn_datastructures.h:607
SNN::getRandSeed
int getRandSeed()
Definition: snn.h:578
SNN::getLogFpInf
const FILE * getLogFpInf()
function writes population weights from gIDpre to gIDpost to file fname in binary.
Definition: snn.h:513
Grid3D
A struct to arrange neurons on a 3D grid (a primitive cubic Bravais lattice with cubic side length 1)
Definition: carlsim_datastructures.h:489
SNN::connectCompartments
short int connectCompartments(int grpIdLower, int grpIdUpper)
Definition: snn_manager.cpp:216
SNN::setHomeostasis
void setHomeostasis(int grpId, bool isSet, float homeoScale, float avgTimeScale)
Sets the homeostasis parameters. g is the grpID, enable=true(false) enables(disables) homeostasis,...
Definition: snn_manager.cpp:460
SNN::setSpikeRate
void setSpikeRate(int grpId, PoissonRate *spikeRate, int refPeriod)
Sets the Poisson spike rate for a group. For information on how to set up spikeRate,...
Definition: snn_manager.cpp:1270
SNN::setESTDP
void setESTDP(int grpId, 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.
Definition: snn_manager.cpp:620
GlobalNetworkConfig_s::numNExcReg
int numNExcReg
number of regular excitatory neurons in the global network
Definition: snn_datastructures.h:602
ConnectConfig_s
The configuration of a connection.
Definition: snn_datastructures.h:119
LoggerMode
LoggerMode
Logger modes.
Definition: carlsim_datastructures.h:90
SpikeBuffer
Circular buffer for delivering spikes.
Definition: spike_buffer.h:65
SNN::getNumSynapticConnections
int getNumSynapticConnections(short int connectionId)
gets number of connections associated with a connection ID
Definition: snn_manager.cpp:1948
carlsim.h
SNN::getNumNeuronsReg
int getNumNeuronsReg()
Definition: snn.h:570
GlobalNetworkConfig_s::numN
int numN
number of neurons in the global network
Definition: snn_datastructures.h:601
SNN::isSimulationWithCOBA
bool isSimulationWithCOBA()
Definition: snn.h:633
SNN::getSimTime
int getSimTime()
Definition: snn.h:580
SNN::getLogFpDeb
const FILE * getLogFpDeb()
returns file pointer to debug log
Definition: snn.h:517
SNN::setNeuronParameters
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.
Definition: snn_manager.cpp:504
NeuronMonitor
Definition: neuron_monitor.h:58
SNN::createGroupLIF
int createGroupLIF(const std::string &grpName, const Grid3D &grid, int neurType, int preferredPartition, ComputingBackend preferredBackend)
Creates a group of LIF spiking neurons.
Definition: snn_manager.cpp:301
SNN::setHomeoBaseFiringRate
void setHomeoBaseFiringRate(int groupId, float baseFiring, float baseFiringSD)
Sets homeostatic target firing rate (enforced through homeostatic synaptic scaling)
Definition: snn_manager.cpp:480
SNN::isInhibitoryGroup
bool isInhibitoryGroup(int gGrpId)
Definition: snn.h:621
SNN::getGroupName
std::string getGroupName(int grpId)
Definition: snn_manager.cpp:1864
ConnectionMonitor
Class ConnectionMonitor.
Definition: connection_monitor.h:148
SNN::isGroupWithHomeostasis
bool isGroupWithHomeostasis(int grpId)
returns whether group has homeostasis enabled (true) or not (false)
Definition: snn_manager.cpp:4893
GlobalNetworkConfig_s::numNInhReg
int numNInhReg
number of regular inhibitory neurons in the global network
Definition: snn_datastructures.h:603
SNN::exitSimulation
void exitSimulation(int val=1)
deallocates all dynamical structures and exits
Definition: snn_manager.cpp:994
SNN::isSimulationWithSTDP
bool isSimulationWithSTDP()
Definition: snn.h:640
TARGET_NMDA
#define TARGET_NMDA
Definition: carlsim_definitions.h:67
GlobalNetworkConfig_s::numNReg
int numNReg
number of regular (spking) neurons in the global network
Definition: snn_datastructures.h:604
RuntimeData_s::stpu
float * stpu
Definition: snn_datastructures.h:512
SNN
Contains all of CARLsim's core functionality.
Definition: snn.h:114
SNN::getConductanceGABAb
std::vector< float > getConductanceGABAb(int grpId)
Definition: snn_manager.cpp:1773
SNN::getWeightRange
RangeWeight getWeightRange(short int connId)
returns RangeWeight struct of a connection
Definition: snn_manager.cpp:2002
GroupNeuromodulatorInfo_s
A struct for retrieving neuromodulator information of a group.
Definition: carlsim_datastructures.h:443
TARGET_AMPA
#define TARGET_AMPA
Definition: carlsim_definitions.h:66
SNN::getLoggerMode
LoggerMode getLoggerMode()
Definition: snn.h:553
UpdateInterval
UpdateInterval
Update frequency for weights.
Definition: carlsim_datastructures.h:237
SNN::isExcitatoryGroup
bool isExcitatoryGroup(int gGrpId)
Definition: snn.h:620
SNN::getDelays
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...
Definition: snn_manager.cpp:1801
SNN::setISTDP
void setISTDP(int grpId, 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...
Definition: snn_manager.cpp:653
SNN::setConnectionMonitor
ConnectionMonitor * setConnectionMonitor(int grpIdPre, int grpIdPost, FILE *fid)
sets up a network monitor registered with a callback to process the spikes.
Definition: snn_manager.cpp:1124
SNN::getConnectId
short int getConnectId(int grpIdPre, int grpIdPost)
find connection ID based on pre-post group pair, O(N)
Definition: snn_manager.cpp:1703
SNN::isDopaminergicGroup
bool isDopaminergicGroup(int gGrpId)
Definition: snn.h:623
MAX_NET_PER_SNN
#define MAX_NET_PER_SNN
Definition: snn_definitions.h:133
SNN::getGroupGrid3D
Grid3D getGroupGrid3D(int grpId)
Definition: snn_manager.cpp:1845
SNN::setSTP
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...
Definition: snn_manager.cpp:699
RadiusRF
A struct to specify the receptive field (RF) radius in 3 dimensions.
Definition: carlsim_datastructures.h:363
TARGET_GABAa
#define TARGET_GABAa
Definition: carlsim_definitions.h:68
snn_datastructures.h
SNN::getDelayRange
RangeDelay getDelayRange(short int connId)
returns the RangeDelay struct of a connection
Definition: snn_manager.cpp:1794
SNN::getNumNeuronsGen
int getNumNeuronsGen()
Definition: snn.h:573
SNN::updateSpikeMonitor
void updateSpikeMonitor(int grpId=ALL)
copy required spikes from firing buffer to spike buffer
Definition: snn_manager.cpp:6478
STDPType
STDPType
STDP flavors.
Definition: carlsim_datastructures.h:160
SNN::getNumConnections
int getNumConnections()
Definition: snn.h:565
SNN::getLogFpLog
const FILE * getLogFpLog()
returns file pointer to log file
Definition: snn.h:519
SNNState
SNNState
the state of spiking neural network, used with in kernel.
Definition: snn_datastructures.h:77