CARLsim  5.0.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 * CARLsim5: HK, JX, KC
45  *
46  * CARLsim available from http://socsci.uci.edu/~jkrichma/CARLsim/
47  * Ver 12/31/2016
48  */
49 
50 /*
51  * Common Abbreviations used in CARLsim
52  * snn/SNN: spiking neural network
53  * stp/STP: short-term plasticity
54  * stdp/STDP: spike-timing dependent plasticity
55  * syn/SYN: synapse
56  * wt/WT: weight
57  * exc/Exc: excitatory
58  * inh/Inh: inhibitory
59  * grp: group
60  * nid/NId/NID: neuron id
61  * gid/GId/GID: group id
62  *
63  * conn: connection
64  * min: minimum
65  * max: maximum
66  * num: number
67  * mem: memory
68  * id/Id/ID: identification
69  * info: information
70  * cnt: count
71  * curr: current
72  * mon: monitor
73  * reg/Reg: regurlar
74  * pois/Pois: poisson
75  */
76 #ifndef _SNN_GOLD_H_
77 #define _SNN_GOLD_H_
78 
79 #include <map>
80 #include <list>
81 #include <cmath>
82 #include <cstring>
83 #include <cassert>
84 #include <cstdio>
85 #include <climits>
86 
87 #include <carlsim.h>
88 #include <callback_core.h>
89 
90 #include <snn_definitions.h>
91 #include <snn_datastructures.h>
92 
93 // #include <spike_buffer.h>
94 #include <poisson_rate.h>
95 
96 class SpikeMonitor;
97 class SpikeMonitorCore;
98 class NeuronMonitor;
99 class NeuronMonitorCore;
101 class ConnectionMonitor;
102 
103 class SpikeBuffer;
104 
105 
109 
115 class SNN {
116 
120 public:
122 
128  SNN(const std::string& name, SimMode preferredSimMode, LoggerMode loggerMode, int randSeed);
129 
131 
134  ~SNN();
135 
136  // +++++ PUBLIC PROPERTIES ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
137 
138  const static unsigned int MAJOR_VERSION = 4;
139  const static unsigned int MINOR_VERSION = 0;
140 
141 
142 
143  // +++++ PUBLIC METHODS: SETTING UP A SIMULATION ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
144 
145  // NOTE: there should be no default argument values in here, this should be handled by the user interface
146 
149 
164  short int connect(int gIDpre, int gIDpost, const std::string& _type, float initWt, float maxWt, float prob,
165  uint8_t minDelay, uint8_t maxDelay, RadiusRF radius,
166  float mulSynFast, float mulSynSlow, bool synWtType);
167 
168  /* Creates synaptic projections using a callback mechanism.
169  *
170  * \param _grpIdPre:ID of the pre-synaptic group
171  * \param _grpIdPost ID of the post-synaptic group
172  * \param _conn: pointer to an instance of class ConnectionGenerator
173  * \param _synWtType: (optional) connection type, either SYN_FIXED or SYN_PLASTIC, default = SYN_FIXED
174  * \return number of created synaptic projections
175  */
176  short int connect(int gIDpre, int gIDpost, ConnectionGeneratorCore* conn, float mulSynFast, float mulSynSlow,
177  bool synWtType);
178 
179  /* Creates synaptic projections using a callback mechanism.
180  *
181  * \param _grpId1:ID lower layer group
182  * \param _grpId2 ID upper level group
183  */
184  short int connectCompartments(int grpIdLower, int grpIdUpper);
185 
187 
192  int createGroup(const std::string& grpName, const Grid3D& grid, int neurType, int preferredPartition, ComputingBackend preferredBackend);
193 
195 
202  int createGroupLIF(const std::string& grpName, const Grid3D& grid, int neurType, int preferredPartition, ComputingBackend preferredBackend);
203 
205 
210  int createSpikeGeneratorGroup(const std::string& grpName, const Grid3D& grid, int neurType, int preferredPartition, ComputingBackend preferredBackend);
211 
218  void setCompartmentParameters(int grpId, float couplingUp, float couplingDown);
219 
231  void setConductances(bool isSet, int tdAMPA, int trNMDA, int tdNMDA, int tdGABAa, int trGABAb, int tdGABAb);
232 
233 
240  void setHomeostasis(int grpId, bool isSet, float homeoScale, float avgTimeScale);
241 
243  void setHomeoBaseFiringRate(int groupId, float baseFiring, float baseFiringSD);
244 
246  void setIntegrationMethod(integrationMethod_t method, int numStepsPerMs);
247 
249 
261  void setNeuronParameters(int grpId, float izh_a, float izh_a_sd, float izh_b, float izh_b_sd,
262  float izh_c, float izh_c_sd, float izh_d, float izh_d_sd);
263 
276  void setNeuronParametersLIF(int grpId, int tau_m, int tau_ref, float vTh, float vReset, double minRmem, double maxRmem);
277 
279 
302  void setNeuronParameters(int grpId, float izh_C, float izh_C_sd, float izh_k, float izh_k_sd,
303  float izh_vr, float izh_vr_sd, float izh_vt, float izh_vt_sd,
304  float izh_a, float izh_a_sd, float izh_b, float izh_b_sd,
305  float izh_vpeak, float izh_vpeak_sd, float izh_c, float izh_c_sd,
306  float izh_d, float izh_d_sd);
307 
309 
320  void setNeuromodulator(int grpId, float baseDP, float tauDP, float base5HT, float tau5HT,
321  float baseACh, float tauACh, float baseNE, float tauNE);
322 
324  /*
325  * \brief STDP must be defined post-synaptically; that is, if STP should be implemented on the connections from group 0 to group 1,
326  * call setSTP on group 1. Fore details on the phenomeon, see (for example) (Bi & Poo, 2001).
327  * \param[in] grpId ID of the neuron group
328  * \param[in] isSet_enable set to true to enable STDP for this group
329  * \param[in] type STDP type (STANDARD, DA_MOD)
330  * \param[in] alphaPlus max magnitude for LTP change
331  * \param[in] tauPlus decay time constant for LTP
332  * \param[in] alphaMinus max magnitude for LTD change (leave positive)
333  * \param[in] tauMinus decay time constant for LTD
334  */
335  void setESTDP(int grpId, bool isSet, STDPType type, STDPCurve curve, float alphaPlus, float tauPlus, float alphaMinus, float tauMinus, float gamma);
336 
338  /*
339  * \brief STDP must be defined post-synaptically; that is, if STP should be implemented on the connections from group 0 to group 1,
340  * call setSTP on group 1. Fore details on the phenomeon, see (for example) (Bi & Poo, 2001).
341  * \param[in] grpId ID of the neuron group
342  * \param[in] isSet_enable set to true to enable STDP for this group
343  * \param[in] type STDP type (STANDARD, DA_MOD)
344  * \param[in] curve STDP curve
345  * \param[in] ab1 magnitude for LTP change
346  * \param[in] ab2 magnitude for LTD change (leave positive)
347  * \param[in] tau1, the interval for LTP
348  * \param[in] tau2, the interval for LTD
349  */
350  void setISTDP(int grpId, bool isSet, STDPType type, STDPCurve curve, float ab1, float ab2, float tau1, float tau2);
351 
372  void setSTP(int grpId, bool isSet, float STP_U, float STP_tau_u, float STP_tau_x);
373 
375 
380  void setWeightAndWeightChangeUpdate(UpdateInterval wtANDwtChangeUpdateInterval, bool enableWtChangeDecay, float wtChangeDecay);
381 
382  // +++++ PUBLIC METHODS: RUNNING A SIMULATION +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
383 
389  int runNetwork(int _nsec, int _nmsec, bool printRunSummary);
390 
395  void setupNetwork();
396 
397  // +++++ PUBLIC METHODS: INTERACTING WITH A SIMULATION ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
398 
399  // adds a bias to every weight in the connection
400  void biasWeights(short int connId, float bias, bool updateWeightRange = false);
401 
403  void exitSimulation(int val = 1);
404 
407  /*
408  * \brief After calling SNN::loadSimulation, you should run SNN::runNetwork before calling fclose(fp).
409  * \param fid: file pointer
410  * \sa SNN::saveSimulation()
411  */
412  void loadSimulation(FILE* fid);
413 
414  // multiplies every weight with a scaling factor
415  void scaleWeights(short int connId, float scale, bool updateWeightRange = false);
416 
418 
422  GroupMonitor* setGroupMonitor(int grpId, FILE* fid);
423 
425 
430  ConnectionMonitor* setConnectionMonitor(int grpIdPre, int grpIdPost, FILE* fid);
431 
433  void setExternalCurrent(int grpId, const std::vector<float>& current);
434 
436  void setSpikeGenerator(int grpId, SpikeGeneratorCore* spikeGenFunc);
437 
439 
444  SpikeMonitor* setSpikeMonitor(int gid, FILE* fid);
445 
447 
452  NeuronMonitor* setNeuronMonitor(int gid, FILE* fid);
453 
455 
460  void setSpikeRate(int grpId, PoissonRate* spikeRate, int refPeriod);
461 
463  void setWeight(short int connId, int neurIdPre, int neurIdPost, float weight, bool updateWeightRange = false);
464 
466  void startTesting(bool shallUpdateWeights = true);
467 
469  void stopTesting();
470 
472  void updateConnectionMonitor(short int connId = ALL);
473 
475  void updateGroupMonitor(int grpId = ALL);
476 
487  void updateSpikeMonitor(int grpId = ALL);
488 
499  void updateNeuronMonitor(int grpId = ALL);
500 
502  /*
503  * \param fid file pointer
504  */
505  void saveSimulation(FILE* fid, bool saveSynapseInfo = false);
506 
508  //void writePopWeights(std::string fname, int gIDpre, int gIDpost);
509 
510 
511  // +++++ PUBLIC METHODS: LOGGING / PLOTTING +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
512 
514  const FILE* getLogFpInf() { return fpInf_; }
516  const FILE* getLogFpErr() { return fpErr_; }
518  const FILE* getLogFpDeb() { return fpDeb_; }
520  const FILE* getLogFpLog() { return fpLog_; }
521 
526  void setLogsFp(FILE* fpInf = NULL, FILE* fpErr = NULL, FILE* fpDeb = NULL, FILE* fpLog = NULL);
527 
528 
529  // +++++ PUBLIC METHODS: GETTERS / SETTERS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
530 
531  short int getConnectId(int grpIdPre, int grpIdPost);
532  ConnectConfig getConnectConfig(short int connectId);
533 
535  RangeDelay getDelayRange(short int connId);
536 
538 
546  uint8_t* getDelays(int gGrpIdPre, int gGrpIdPost, int& numPreN, int& numPostN);
547 
548  Grid3D getGroupGrid3D(int grpId);
549  int getGroupId(std::string grpName);
550  std::string getGroupName(int grpId);
551  GroupSTDPInfo getGroupSTDPInfo(int grpId);
553 
554  LoggerMode getLoggerMode() { return loggerMode_; }
555 
556  // get functions for GroupInfo
557  int getGroupStartNeuronId(int gGrpId) { return groupConfigMDMap[gGrpId].gStartN; }
558  int getGroupEndNeuronId(int gGrpId) { return groupConfigMDMap[gGrpId].gEndN; }
559  int getGroupNumNeurons(int gGrpId) { return groupConfigMap[gGrpId].numN; }
560 
561  std::string getNetworkName() { return networkName_; }
562 
563  Point3D getNeuronLocation3D(int neurId);
564  Point3D getNeuronLocation3D(int grpId, int relNeurId);
565 
566  int getNumConnections() { return numConnections; }
567  int getNumSynapticConnections(short int connectionId);
568  int getNumCompartmentConnections() { return numCompartmentConnections; }
569  int getNumGroups() { return numGroups; }
570  int getNumNeurons() { return glbNetworkConfig.numN; }
571  int getNumNeuronsReg() { return glbNetworkConfig.numNReg; }
572  int getNumNeuronsRegExc() { return glbNetworkConfig.numNExcReg; }
573  int getNumNeuronsRegInh() { return glbNetworkConfig.numNInhReg; }
574  int getNumNeuronsGen() { return glbNetworkConfig.numNPois; }
575  int getNumNeuronsGenExc() { return glbNetworkConfig.numNExcPois; }
576  int getNumNeuronsGenInh() { return glbNetworkConfig.numNInhPois; }
577  int getNumSynapses() { return glbNetworkConfig.numSynNet; }
578 
579  int getRandSeed() { return randSeed_; }
580 
581  int getSimTime() { return simTime; }
582  int getSimTimeSec() { return simTimeSec; }
583  int getSimTimeMs() { return simTimeMs; }
584 
586  SpikeMonitor* getSpikeMonitor(int grpId);
587 
591 
593  NeuronMonitor* getNeuronMonitor(int grpId);
594 
598 
600  float* getCurrent() { return managerRuntimeData.current; }
601 
602  std::vector< std::vector<float> > getWeightMatrix2D(short int connId);
603 
604  std::vector<float> getConductanceAMPA(int grpId);
605  std::vector<float> getConductanceNMDA(int grpId);
606  std::vector<float> getConductanceGABAa(int grpId);
607  std::vector<float> getConductanceGABAb(int grpId);
608 
610  float* getSTPu() { return managerRuntimeData.stpu; }
611 
613  float* getSTPx() { return managerRuntimeData.stpx; }
614 
616  bool isConnectionPlastic(short int connId);
617 
619  RangeWeight getWeightRange(short int connId);
620 
621  bool isExcitatoryGroup(int gGrpId) { return (groupConfigMap[gGrpId].type & TARGET_AMPA) || (groupConfigMap[gGrpId].type & TARGET_NMDA); }
622  bool isInhibitoryGroup(int gGrpId) { return (groupConfigMap[gGrpId].type & TARGET_GABAa) || (groupConfigMap[gGrpId].type & TARGET_GABAb); }
623  bool isPoissonGroup(int gGrpId) { return (groupConfigMap[gGrpId].type & POISSON_NEURON); }
624  bool isDopaminergicGroup(int gGrpId) { return (groupConfigMap[gGrpId].type & TARGET_DA); }
625 
627  bool isGroupWithHomeostasis(int grpId);
628 
630  double getRFDist3D(const RadiusRF& radius, const Point3D& pre, const Point3D& post);
631  bool isPoint3DinRF(const RadiusRF& radius, const Point3D& pre, const Point3D& post);
632 
633  bool isSimulationWithCompartments() { return sim_with_compartments; }
634  bool isSimulationWithCOBA() { return sim_with_conductances; }
635  bool isSimulationWithCUBA() { return !sim_with_conductances; }
636  bool isSimulationWithNMDARise() { return sim_with_NMDA_rise; }
637  bool isSimulationWithGABAbRise() { return sim_with_GABAb_rise; }
638  bool isSimulationWithFixedWeightsOnly() { return sim_with_fixedwts; }
639  bool isSimulationWithHomeostasis() { return sim_with_homeostasis; }
640  bool isSimulationWithPlasticWeights() { return !sim_with_fixedwts; }
641  bool isSimulationWithSTDP() { return sim_with_stdp; }
642  bool isSimulationWithSTP() { return sim_with_stp; }
643 
644  // **************************************************************************************************************** //
645  // PRIVATE METHODS
646  // **************************************************************************************************************** //
647 
648 private:
650  void SNNinit();
651 
653  void advSimStep();
654 
656  void allocateManagerRuntimeData();
657 
658  int assignGroup(int gGrpId, int availableNeuronId);
659  int assignGroup(std::list<GroupConfigMD>::iterator grpIt, int localGroupId, int availableNeuronId);
660  void generateGroupRuntime(int netId, int lGrpId);
661  void generatePoissonGroupRuntime(int netId, int lGrpId);
662  void generateConnectionRuntime(int netId);
663  void generateCompConnectionRuntime(int netId);
664 
668  void generateRuntimeNetworkConfigs();
669  void generateRuntimeGroupConfigs();
670  void generateRuntimeConnectConfigs();
671 
675  void collectGlobalNetworkConfigC();
676  void compileConnectConfig();
677  void compileGroupConfig();
678 
679  void collectGlobalNetworkConfigP();
680 
684  void connectNetwork();
685  inline void connectNeurons(int netId, int srcGrp, int destGrp, int srcN, int destN, short int connId, int externalNetId);
686  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);
687  void connectFull(int netId, std::list<ConnectConfig>::iterator connIt, bool isExternal);
688  void connectOneToOne(int netId, std::list<ConnectConfig>::iterator connIt, bool isExternal);
689  void connectRandom(int netId, std::list<ConnectConfig>::iterator connIt, bool isExternal);
690  void connectGaussian(int netId, std::list<ConnectConfig>::iterator connIt, bool isExternal);
691  void connectUserDefined(int netId, std::list<ConnectConfig>::iterator connIt, bool isExternal);
692 
693  void deleteObjects();
694 
695  void findMaxNumSynapsesGroups(int* _maxNumPostSynGrp, int* _maxNumPreSynGrp);
696  void findMaxNumSynapsesNeurons(int _netId, int& _maxNumPostSynN, int& _maxNumPreSynN);
697  void findMaxSpikesD1D2(int netId, unsigned int& _maxSpikesD1, unsigned int& _maxSpikesD2);
698  void findNumSynapsesNetwork(int netId, int& _numPostSynNet, int& _numPreSynNet);
699  void findNumN(int _netId, int& _numN, int& _nunNExternal, int& numNAssigned,
700  int& _numNReg, int& _numNExcReg, int& _numNInhReg,
701  int& _numNPois, int& _numNExcPois, int& _numNInhPois);
702  void findNumNSpikeGenAndOffset(int _netId);
703 
704  void generatePostSynapticSpike(int preNId, int postNId, int synId, int tD, int netId);
705  void fillSpikeGenBits(int netId);
706  void userDefinedSpikeGenerator(int gGrpId);
707 
708  float generateWeight(int connProp, float initWt, float maxWt, int nid, int grpId);
709 
711  void verifyNetwork();
712 
714  void verifySTDP();
715 
717  void verifyHomeostasis();
718 
720  void verifyCompartments();
721 
723  //void verifyNumNeurons();
724 
725  void compileSNN();
726 
727  void partitionSNN();
728 
729  void generateRuntimeSNN();
730 
749  //int poissonSpike(int currTime, float frate, int refractPeriod);
750 
751  void printConnectionInfo(short int connId);
752  void printConnectionInfo(int netId, std::list<ConnectConfig>::iterator connIt);
753  void printGroupInfo(int grpId);
754  void printGroupInfo(int netId, std::list<GroupConfigMD>::iterator grpIt);
755  void printSimSummary();
756  void printStatusConnectionMonitor(int connId = ALL);
757  void printStatusGroupMonitor(int gGrpId = ALL);
758  void printStatusSpikeMonitor(int gGrpId = ALL);
759  void printSikeRoutingInfo();
760 
761  int loadSimulation_internal(bool onlyPlastic);
762 
763  void resetConductances(int netId);
764  void resetCurrent(int netId);
765  void resetFiringInformation();
766  void resetGroupConfigs(bool deallocate = false);
767  void resetNeuromodulator(int netId, int lGrpId);
768  void resetNeuron(int netId, int lGrpId, int lNId);
769  void resetMonitors(bool deallocate = false);
770  void resetConnectionConfigs(bool deallocate = false);
771  void deleteManagerRuntimeData();
772  void resetPoissonNeuron(int netId, int lGrpId, int lNId);
773  void resetPropogationBuffer();
774  void resetSynapse(int netId, bool changeWeights = false);
775  void resetTimeTable();
776  void resetFiringTable();
777  void routeSpikes();
778  void transferSpikes(void* dest, int destNetId, void* src, int srcNetId, int size);
779  void resetTiming();
780 
781  inline SynInfo SET_CONN_ID(int nid, int sid, int grpId);
782 
783  void setGrpTimeSlice(int grpId, int timeSlice);
784  int setRandSeed(int seed);
785 
786  void startTiming();
787  void stopTiming();
788 
789  void generateUserDefinedSpikes();
790 
791  void allocateManagerSpikeTables();
792 
793  bool updateTime();
794 
795  float getCompCurrent(int netid, int lGrpId, int lneurId, float const0 = 0.0f, float const1 = 0.0f);
796 
797  // Abstract layer for setupNetwork() and runNetwork()
798  void allocateSNN(int netId);
799  void clearExtFiringTable();
800  void convertExtSpikesD1(int netId, int startIdx, int endIdx, int GtoLOffset);
801  void convertExtSpikesD2(int netId, int startIdx, int endIdx, int GtoLOffset);
802  void doCurrentUpdate();
803  void doSTPUpdateAndDecayCond();
804  void deleteRuntimeData();
805  void findFiring();
806  void globalStateUpdate();
807  void resetSpikeCnt(int gGrpId);
808  void shiftSpikeTables();
809  void spikeGeneratorUpdate();
810  void updateTimingTable();
811  void updateWeights();
812  void updateNetworkConfig(int netId);
813 
814  // Abstract layer for trasferring data (local-to-global copy)
815  void fetchConductanceAMPA(int gGrpId);
816  void fetchConductanceNMDA(int gGrpId);
817  void fetchConductanceGABAa(int gGrpId);
818  void fetchConductanceGABAb(int gGrpId);
819  void fetchNetworkSpikeCount();
820  void fetchNeuronSpikeCount(int gGrpId);
821  void fetchSTPState(int gGrpId);
822 
823  // Abstract layer for trasferring data (local-to-local copy)
824  void fetchSpikeTables(int netId);
825  void fetchNeuronStateBuffer(int netId, int lGrpId);
826  void fetchGroupState(int netId, int lGrpId);
827  void fetchWeightState(int netId, int lGrpId);
828  void fetchGrpIdsLookupArray(int netId);
829  void fetchConnIdsLookupArray(int netId);
830  void fetchLastSpikeTime(int netId);
831  void fetchPreConnectionInfo(int netId);
832  void fetchPostConnectionInfo(int netId);
833  void fetchSynapseState(int netId);
834  void fetchExtFiringTable(int netId);
835  void fetchTimeTable(int netId);
836  void writeBackTimeTable(int netId);
837 
838 #ifndef __NO_CUDA__
839  // GPU implementation for setupNetwork() and runNetwork()
840  void allocateSNN_GPU(int netId);
841  void assignPoissonFiringRate_GPU(int netId);
842  void clearExtFiringTable_GPU(int netId);
843  void convertExtSpikesD1_GPU(int netId, int startIdx, int endIdx, int GtoLOffset);
844  void convertExtSpikesD2_GPU(int netId, int startIdx, int endIdx, int GtoLOffset);
845  void doCurrentUpdateD1_GPU(int netId);
846  void doCurrentUpdateD2_GPU(int netId);
847  void doSTPUpdateAndDecayCond_GPU(int netId);
848  void deleteRuntimeData_GPU(int netId);
849  void findFiring_GPU(int netId);
850  void globalStateUpdate_C_GPU(int netId);
851  void globalStateUpdate_N_GPU(int netId);
852  void globalStateUpdate_G_GPU(int netId);
853  void resetSpikeCnt_GPU(int netId, int lGrpId);
854  void shiftSpikeTables_F_GPU(int netId);
855  void shiftSpikeTables_T_GPU(int netId);
856  void spikeGeneratorUpdate_GPU(int netId);
857  void updateTimingTable_GPU(int netId);
858  void updateWeights_GPU(int netId);
859 #else
860  void allocateSNN_GPU(int netId) { assert(false); }
861  void assignPoissonFiringRate_GPU(int netId) { assert(false); }
862  void clearExtFiringTable_GPU(int netId) { assert(false); }
863  void convertExtSpikesD1_GPU(int netId, int startIdx, int endIdx, int GtoLOffset) { assert(false); }
864  void convertExtSpikesD2_GPU(int netId, int startIdx, int endIdx, int GtoLOffset) { assert(false); }
865  void doCurrentUpdateD1_GPU(int netId) { assert(false); }
866  void doCurrentUpdateD2_GPU(int netId) { assert(false); }
867  void doSTPUpdateAndDecayCond_GPU(int netId) { assert(false); }
868  void deleteRuntimeData_GPU(int netId) { assert(false); }
869  void findFiring_GPU(int netId) { assert(false); }
870  void globalStateUpdate_C_GPU(int netId) { assert(false); }
871  void globalStateUpdate_N_GPU(int netId) { assert(false); }
872  void globalStateUpdate_G_GPU(int netId) { assert(false); }
873  void resetSpikeCnt_GPU(int netId, int lGrpId) { assert(false); }
874  void shiftSpikeTables_F_GPU(int netId) { assert(false); }
875  void shiftSpikeTables_T_GPU(int netId) { assert(false); }
876  void spikeGeneratorUpdate_GPU(int netId) { assert(false); }
877  void updateTimingTable_GPU(int netId) { assert(false); }
878  void updateWeights_GPU(int netId) { assert(false); }
879 #endif
880 
881 #ifndef __NO_CUDA__
882  // GPU backend: utility function
883  void allocateGroupId(int netId);
884  int allocateStaticLoad(int netId, int bufSize);
885  void checkAndSetGPUDevice(int netId);
886  void checkDestSrcPtrs(RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem, int grpId, int destOffset);
887  int configGPUDevice();
888  void initGPU(int netId);
889 #else
890  int configGPUDevice() { return 0; }
891 #endif
892 
893 #ifndef __NO_CUDA__
894  // GPU backend: data transfer functions
895  void copyAuxiliaryData(int netId, int lGrpId, RuntimeData* dest, cudaMemcpyKind kind, bool allocateMem);
896  void copyConductanceAMPA(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem, int destOffset);
897  void copyConductanceNMDA(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem, int destOffset);
898  void copyConductanceGABAa(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem, int destOffset);
899  void copyConductanceGABAb(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem, int destOffset);
900  void copyPreConnectionInfo(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem);
901  void copyPostConnectionInfo(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem);
902  void copyExternalCurrent(int netId, int lGrpId, RuntimeData* dest, cudaMemcpyKind kind, bool allocateMem);
903  void copyNeuronParameters(int netId, int lGrpId, RuntimeData* dest, cudaMemcpyKind kind, bool allocateMem);
904  void copyGroupState(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem);
905  void copyNeuronState(int netId, int lGrpId, RuntimeData* dest, cudaMemcpyKind kind, bool allocateMem);
906  void copyNeuronStateBuffer(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem);
907  void copyNeuronSpikeCount(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem, int destOffset);
908  void copySynapseState(int netId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem);
909  void copySTPState(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem);
910  void copyWeightState(int netId, int lGrpId, cudaMemcpyKind kind);
911  void copyNetworkConfig(int netId, cudaMemcpyKind kind);
912  void copyGroupConfigs(int netId);
913  void copyGrpIdsLookupArray(int netId, cudaMemcpyKind kind);
914  void copyConnIdsLookupArray(int netId, cudaMemcpyKind kind);
915  void copyLastSpikeTime(int netId, cudaMemcpyKind kind);
916  void copyNetworkSpikeCount(int netId, cudaMemcpyKind kind,
917  unsigned int* spikeCountD1, unsigned int* spikeCountD2,
918  unsigned int* spikeCountExtD1, unsigned int* spikeCountExtD2);
919  void copySpikeTables(int netId, cudaMemcpyKind kind);
920  void copyTimeTable(int netId, cudaMemcpyKind kind);
921  void copyExtFiringTable(int netId, cudaMemcpyKind kind);
922 #else
923  #define cudaMemcpyKind int
924  #define cudaMemcpyHostToHost 0
925  #define cudaMemcpyHostToDevice 0
926  #define cudaMemcpyDeviceToHost 0
927  #define cudaMemcpyDeviceToDevice 0
928  #define cudaMemcpyDefault 0
929 
930  void copyAuxiliaryData(int netId, int lGrpId, RuntimeData* dest, cudaMemcpyKind kind, bool allocateMem) { assert(false); }
931  void copyConductanceAMPA(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem, int destOffset) { assert(false); }
932  void copyConductanceNMDA(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem, int destOffset) { assert(false); }
933  void copyConductanceGABAa(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem, int destOffset) { assert(false); }
934  void copyConductanceGABAb(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem, int destOffset) { assert(false); }
935  void copyPreConnectionInfo(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem) { assert(false); }
936  void copyPostConnectionInfo(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem) { assert(false); }
937  void copyExternalCurrent(int netId, int lGrpId, RuntimeData* dest, cudaMemcpyKind kind, bool allocateMem) { assert(false); }
938  void copyNeuronParameters(int netId, int lGrpId, RuntimeData* dest, cudaMemcpyKind kind, bool allocateMem) { assert(false); }
939  void copyGroupState(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem) { assert(false); }
940  void copyNeuronState(int netId, int lGrpId, RuntimeData* dest, cudaMemcpyKind kind, bool allocateMem) { assert(false); }
941  void copyNeuronStateBuffer(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem) { assert(false); }
942  void copyNeuronSpikeCount(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem, int destOffset) { assert(false); }
943  void copySynapseState(int netId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem) { assert(false); }
944  void copySTPState(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, cudaMemcpyKind kind, bool allocateMem) { assert(false); }
945  void copyWeightState(int netId, int lGrpId, cudaMemcpyKind kind) { assert(false); }
946  void copyNetworkConfig(int netId, cudaMemcpyKind kind) { assert(false); }
947  void copyGroupConfigs(int netId) { assert(false); }
948  void copyGrpIdsLookupArray(int netId, cudaMemcpyKind kind) { assert(false); }
949  void copyConnIdsLookupArray(int netId, cudaMemcpyKind kind) { assert(false); }
950  void copyLastSpikeTime(int netId, cudaMemcpyKind kind) { assert(false); }
951  void copyNetworkSpikeCount(int netId, cudaMemcpyKind kind,
952  unsigned int* spikeCountD1, unsigned int* spikeCountD2,
953  unsigned int* spikeCountExtD1, unsigned int* spikeCountExtD2) { assert(false); }
954  void copySpikeTables(int netId, cudaMemcpyKind kind) { assert(false); }
955  void copyTimeTable(int netId, cudaMemcpyKind kind) { assert(false); }
956  void copyExtFiringTable(int netId, cudaMemcpyKind kind) { assert(false); }
957 #endif
958 
959  // CPU implementation for setupNetwork() and runNetwork()
960 
961  //allocates runtime data on CPU memory
962  void allocateSNN_CPU(int netId);
963 
964  // runNetwork functions - multithreaded in LINUX using pthreads
965 #if defined(WIN32) || defined(WIN64) || defined(__APPLE__)
966  void assignPoissonFiringRate_CPU(int netId);
967  void clearExtFiringTable_CPU(int netId);
968  void convertExtSpikesD2_CPU(int netId, int startIdx, int endIdx, int GtoLOffset);
969  void convertExtSpikesD1_CPU(int netId, int startIdx, int endIdx, int GtoLOffset);
970  void doCurrentUpdateD2_CPU(int netId);
971  void doCurrentUpdateD1_CPU(int netId);
972  void doSTPUpdateAndDecayCond_CPU(int netId);
973  void deleteRuntimeData_CPU(int netId);
974  void findFiring_CPU(int netId);
975  void globalStateUpdate_CPU(int netId);
976  void resetSpikeCnt_CPU(int netId, int lGrpId);
977  void shiftSpikeTables_CPU(int netId);
978  void spikeGeneratorUpdate_CPU(int netId);
979  void updateTimingTable_CPU(int netId);
980  void updateWeights_CPU(int netId);
981 #else // for APPLE and Win systems - returns a void* to pthread_create - only differ in the return type compared to the counterparts above
982  void* assignPoissonFiringRate_CPU(int netId);
983  void* clearExtFiringTable_CPU(int netId);
984  void* convertExtSpikesD2_CPU(int netId, int startIdx, int endIdx, int GtoLOffset);
985  void* convertExtSpikesD1_CPU(int netId, int startIdx, int endIdx, int GtoLOffset);
986  void* doCurrentUpdateD2_CPU(int netId);
987  void* doCurrentUpdateD1_CPU(int netId);
988  void* doSTPUpdateAndDecayCond_CPU(int netId);
989  void* deleteRuntimeData_CPU(int netId);
990  void* findFiring_CPU(int netId);
991  void* globalStateUpdate_CPU(int netId);
992  void* resetSpikeCnt_CPU(int netId, int lGrpId);
993  void* shiftSpikeTables_CPU(int netId);
994  void* spikeGeneratorUpdate_CPU(int netId);
995  void* updateTimingTable_CPU(int netId);
996  void* updateWeights_CPU(int netId);
997 
998  // static multithreading helper methods for the above CPU runNetwork() methods
999  static void* helperAssignPoissonFiringRate_CPU(void*);
1000  static void* helperClearExtFiringTable_CPU(void*);
1001  static void* helperConvertExtSpikesD2_CPU(void*);
1002  static void* helperConvertExtSpikesD1_CPU(void*);
1003  static void* helperDoCurrentUpdateD2_CPU(void*);
1004  static void* helperDoCurrentUpdateD1_CPU(void*);
1005  static void* helperDoSTPUpdateAndDecayCond_CPU(void*);
1006  static void* helperDeleteRuntimeData_CPU(void*);
1007  static void* helperFindFiring_CPU(void*);
1008  static void* helperGlobalStateUpdate_CPU(void*);
1009  static void* helperResetSpikeCnt_CPU(void*);
1010  static void* helperShiftSpikeTables_CPU(void*);
1011  static void* helperSpikeGeneratorUpdate_CPU(void*);
1012  static void* helperUpdateTimingTable_CPU(void*);
1013  static void* helperUpdateWeights_CPU(void*);
1014 #endif
1015 
1016  // CPU computing backend: data transfer function
1017  void copyAuxiliaryData(int netId, int lGrpId, RuntimeData* dest, bool allocateMem);
1018  void copyConductanceAMPA(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, bool allocateMem, int destOffset);
1019  void copyConductanceNMDA(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, bool allocateMem, int destOffset);
1020  void copyConductanceGABAa(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, bool allocateMem, int destOffset);
1021  void copyConductanceGABAb(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, bool allocateMem, int destOffset);
1022  void copyPreConnectionInfo(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, bool allocateMem);
1023  void copyPostConnectionInfo(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, bool allocateMem);
1024  void copyExternalCurrent(int netId, int lGrpId, RuntimeData* dest, bool allocateMem);
1025  void copyNeuronParameters(int netId, int lGrpId, RuntimeData* dest, bool allocateMem);
1026  void copyGroupState(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, bool allocateMem);
1027  void copyNeuronStateBuffer(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, bool allocateMem);
1028  void copyNeuronState(int netId, int lGrpId, RuntimeData* dest, bool allocateMem);
1029  void copyNeuronSpikeCount(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, bool allocateMem, int destOffset);
1030  void copySynapseState(int netId, RuntimeData* dest, RuntimeData* src, bool allocateMem);
1031  void copySTPState(int netId, int lGrpId, RuntimeData* dest, RuntimeData* src, bool allocateMem);
1032  void copyWeightState(int netId, int lGrpId);
1033  void copyNetworkConfig(int netId);
1034  void copyGrpIdsLookupArray(int netId);
1035  void copyConnIdsLookupArray(int netId);
1036  void copyLastSpikeTime(int netId);
1037  void copyNetworkSpikeCount(int netId,
1038  unsigned int* spikeCountD1, unsigned int* spikeCountD2,
1039  unsigned int* spikeCountExtD1, unsigned int* spikeCountExtD2);
1040  void copySpikeTables(int netId);
1041  void copyTimeTable(int netId, bool toManager);
1042  void copyExtFiringTable(int netId);
1043 
1044  // CPU backend: utility function
1045  void firingUpdateSTP(int lNId, int lGrpId, int netId);
1046  void updateLTP(int lNId, int lGrpId, int netId);
1047  void resetFiredNeuron(int lNId, short int lGrpId, int netId);
1048  bool getPoissonSpike(int lNId, int netId);
1049  bool getSpikeGenBit(unsigned int nIdPos, int netId);
1050 
1051  // +++++ PRIVATE PROPERTIES +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
1052  SNNState snnState;
1053  FILE* loadSimFID;
1054 
1055  const std::string networkName_;
1056  const LoggerMode loggerMode_;
1057  const SimMode preferredSimMode_;
1058  const int randSeed_;
1059 
1060  int numGPUs;
1061  int numCores;
1062 
1063  int numAvailableGPUs;
1064 
1065  bool simulatorDeleted;
1066  bool spikeRateUpdated;
1067 
1069  bool sim_in_testing;
1070 
1071  int numGroups;
1072  int numConnections;
1073  int numCompartmentConnections;
1074 
1075  std::map<int, GroupConfig> groupConfigMap;
1076  std::map<int, GroupConfigMD> groupConfigMDMap;
1077  std::map<int, ConnectConfig> connectConfigMap;
1078  std::map<int, compConnectConfig> compConnectConfigMap;
1079 
1080  // data structure assisting network partitioning
1081  std::list<GroupConfigMD> groupPartitionLists[MAX_NET_PER_SNN];
1082  std::list<ConnectConfig> localConnectLists[MAX_NET_PER_SNN];
1083  std::list<ConnectConfig> externalConnectLists[MAX_NET_PER_SNN];
1084  std::list<compConnectConfig> localCompConnectLists[MAX_NET_PER_SNN];
1085 
1086  std::list<ConnectionInfo> connectionLists[MAX_NET_PER_SNN];
1087 
1088  std::list<RoutingTableEntry> spikeRoutingTable;
1089 
1090  float *mulSynFast;
1091  float *mulSynSlow;
1092 
1094  SpikeBuffer* spikeBuf;
1095 
1096  bool sim_with_conductances;
1097  bool sim_with_NMDA_rise;
1098  bool sim_with_GABAb_rise;
1099  double dAMPA;
1100  double rNMDA;
1101  double dNMDA;
1102  double sNMDA;
1103  double dGABAa;
1104  double rGABAb;
1105  double dGABAb;
1106  double sGABAb;
1107 
1108  bool sim_with_compartments;
1109  bool sim_with_fixedwts;
1110  bool sim_with_stdp;
1111  bool sim_with_modulated_stdp;
1112  bool sim_with_homeostasis;
1113  bool sim_with_stp;
1114  bool sim_with_spikecounters;
1115 
1116  GlobalNetworkConfig glbNetworkConfig;
1117 
1118  //time and timestep
1119  int simTimeRunStart;
1120  int simTimeRunStop;
1121  int simTimeLastRunSummary;
1122  int simTimeMs;
1123  int simTimeSec;
1124  int simTime;
1125 
1127 #ifndef __NO_CUDA__
1128  StopWatchInterface* timer;
1129 #endif
1130  float cumExecutionTime;
1131  float lastExecutionTime;
1132  float prevExecutionTime;
1133  float executionTime;
1134 
1135  FILE* fpInf_;
1136  FILE* fpErr_;
1137  FILE* fpDeb_;
1138  FILE* fpLog_;
1139 
1140  // keep track of number of SpikeMonitor/SpikeMonitorCore objects
1141  int numSpikeMonitor;
1142  SpikeMonitorCore* spikeMonCoreList[MAX_GRP_PER_SNN];
1143  SpikeMonitor* spikeMonList[MAX_GRP_PER_SNN];
1144 
1145  // neuron monitor variables
1146  int numNeuronMonitor;
1147  NeuronMonitor* neuronMonList[MAX_GRP_PER_SNN];
1148  NeuronMonitorCore* neuronMonCoreList[MAX_GRP_PER_SNN];
1149 
1150  // \FIXME \DEPRECATED this one moved to group-based
1151  long int simTimeLastUpdSpkMon_;
1152 
1153  int numSpikeGenGrps;
1154 
1155  // keep track of number of GroupMonitor/GroupMonitorCore objects
1156  int numGroupMonitor;
1157  GroupMonitorCore* groupMonCoreList[MAX_GRP_PER_SNN];
1158  GroupMonitor* groupMonList[MAX_GRP_PER_SNN];
1159 
1160  // neuron monitor variables
1161  //NeuronMonitorCore* neurBufferCallback[MAX_]
1162  //int numNeuronMonitor;
1163 
1164  // connection monitor variables
1165  int numConnectionMonitor;
1166  ConnectionMonitorCore* connMonCoreList[MAX_CONN_PER_SNN];
1167  ConnectionMonitor* connMonList[MAX_CONN_PER_SNN];
1168 
1169  RuntimeData runtimeData[MAX_NET_PER_SNN];
1170  RuntimeData managerRuntimeData;
1171 
1172  typedef struct ManagerRuntimeDataSize_s {
1173  unsigned int maxMaxSpikeD1;
1174  unsigned int maxMaxSpikeD2;
1175  int maxNumN;
1176  int maxNumNReg;
1177  int maxNumNSpikeGen;
1178  int maxNumNAssigned;
1179  int maxNumGroups;
1180  int maxNumConnections;
1181  int maxNumPostSynNet;
1182  int maxNumPreSynNet;
1183  int maxNumNPerGroup;
1184  int glbNumN;
1185  int glbNumNReg;
1186  } ManagerRuntimeDataSize;
1187 
1188  ManagerRuntimeDataSize managerRTDSize;
1189 
1190  // runtime configurations
1191  NetworkConfigRT networkConfigs[MAX_NET_PER_SNN];
1194 
1195  // weight update parameter
1196  int wtANDwtChangeUpdateInterval_;
1197  int wtANDwtChangeUpdateIntervalCnt_;
1198  float stdpScaleFactor_;
1199  float wtChangeDecay_;
1200 };
1201 
1202 #endif
SNN::getNumNeuronsRegInh
int getNumNeuronsRegInh()
Definition: snn.h:573
SNN::getNeuronMonitor
NeuronMonitor * getNeuronMonitor(int grpId)
Returns pointer to existing NeuronMonitor object, NULL else.
Definition: snn_manager.cpp:1981
SNN::getSimTimeSec
int getSimTimeSec()
Definition: snn.h:582
POISSON_NEURON
#define POISSON_NEURON
Definition: carlsim_definitions.h:66
SNN::getGroupNumNeurons
int getGroupNumNeurons(int gGrpId)
Definition: snn.h:559
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:1088
SNN::getGroupStartNeuronId
int getGroupStartNeuronId(int gGrpId)
Definition: snn.h:557
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:409
TARGET_GABAb
#define TARGET_GABAb
Definition: carlsim_definitions.h:70
SynInfo_s
Definition: snn_datastructures.h:90
SimMode
SimMode
simulation mode
Definition: carlsim_datastructures.h:114
SNN::getNetworkName
std::string getNetworkName()
Definition: snn.h:561
integrationMethod_t
integrationMethod_t
Integration methods.
Definition: carlsim_datastructures.h:133
TARGET_DA
#define TARGET_DA
Definition: carlsim_definitions.h:71
GroupConfigRT_s
The runtime configuration of a group.
Definition: snn_datastructures.h:374
SpikeMonitorCore
Definition: spike_monitor_core.h:71
SNN::loadSimulation
void loadSimulation(FILE *fid)
Definition: snn_manager.cpp:1001
SNN::getNumGroups
int getNumGroups()
Definition: snn.h:569
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:575
SNN::biasWeights
void biasWeights(short int connId, float bias, bool updateWeightRange=false)
Definition: snn_manager.cpp:916
RangeWeight
a range struct for synaptic weight magnitudes
Definition: carlsim_datastructures.h:312
SpikeMonitor
Class SpikeMonitor.
Definition: spike_monitor.h:120
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:96
SNN::isSimulationWithGABAbRise
bool isSimulationWithGABAbRise()
Definition: snn.h:637
SNN::getNumNeuronsRegExc
int getNumNeuronsRegExc()
Definition: snn.h:572
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:1411
callback_core.h
MAX_CONN_PER_SNN
#define MAX_CONN_PER_SNN
Definition: snn_definitions.h:132
MAX_GRP_PER_SNN
#define MAX_GRP_PER_SNN
Definition: snn_definitions.h:133
SNN::getCurrent
float * getCurrent()
temporary getter to return pointer to current[]
Definition: snn.h:600
RuntimeData_s
Definition: snn_datastructures.h:451
SNN::getNumNeuronsGenExc
int getNumNeuronsGenExc()
Definition: snn.h:575
SNN::getConductanceGABAa
std::vector< float > getConductanceGABAa(int grpId)
Definition: snn_manager.cpp:1761
SNN::getGroupSTDPInfo
GroupSTDPInfo getGroupSTDPInfo(int grpId)
Definition: snn_manager.cpp:1874
SNN::setSpikeGenerator
void setSpikeGenerator(int grpId, SpikeGeneratorCore *spikeGenFunc)
sets up a spike generator
Definition: snn_manager.cpp:1174
SNN::isPoint3DinRF
bool isPoint3DinRF(const RadiusRF &radius, const Point3D &pre, const Point3D &post)
Definition: snn_manager.cpp:5062
SNN::runNetwork
int runNetwork(int _nsec, int _nmsec, bool printRunSummary)
run the simulation for n sec
Definition: snn_manager.cpp:794
SNN::setWeightAndWeightChangeUpdate
void setWeightAndWeightChangeUpdate(UpdateInterval wtANDwtChangeUpdateInterval, bool enableWtChangeDecay, float wtChangeDecay)
Sets the weight and weight change update parameters.
Definition: snn_manager.cpp:724
RuntimeData_s::stpx
float * stpx
Definition: snn_datastructures.h:512
SNN::getNeuronMonitorCore
NeuronMonitorCore * getNeuronMonitorCore(int grpId)
Definition: snn_manager.cpp:1992
ConnectionMonitorCore
Definition: connection_monitor_core.h:68
SpikeGeneratorCore
used for relaying callback to SpikeGenerator
Definition: callback_core.h:70
SNN::getNumSynapses
int getNumSynapses()
Definition: snn.h:577
SNN::updateGroupMonitor
void updateGroupMonitor(int grpId=ALL)
access group status (currently the concentration of neuromodulator)
Definition: snn_manager.cpp:6280
SNN::getSpikeMonitorCore
SpikeMonitorCore * getSpikeMonitorCore(int grpId)
Definition: snn_manager.cpp:1970
SNN::isConnectionPlastic
bool isConnectionPlastic(short int connId)
returns whether synapses in connection are fixed (false) or plastic (true)
Definition: snn_manager.cpp:4884
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:5071
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:1378
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:1672
NetworkConfigRT_s
runtime network configuration
Definition: snn_datastructures.h:626
RuntimeData_s::current
float * current
Definition: snn_datastructures.h:477
SNN::isSimulationWithHomeostasis
bool isSimulationWithHomeostasis()
Definition: snn.h:639
GroupSTDPInfo_s
A struct for retrieving STDP related information of a group.
Definition: carlsim_datastructures.h:412
SNN::getConnectConfig
ConnectConfig getConnectConfig(short int connectId)
required for homeostasis
Definition: snn_manager.cpp:1717
ConnectionGeneratorCore
used for relaying callback to ConnectionGenerator
Definition: callback_core.h:90
GlobalNetworkConfig_s
Definition: snn_datastructures.h:594
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:610
SNN::getConductanceNMDA
std::vector< float > getConductanceNMDA(int grpId)
Definition: snn_manager.cpp:1741
SNN::setCompartmentParameters
void setCompartmentParameters(int grpId, float couplingUp, float couplingDown)
Coupling constants for the compartment are set using this method.
Definition: snn_manager.cpp:393
SNN::startTesting
void startTesting(bool shallUpdateWeights=true)
enters a testing phase, where all weight updates are disabled
Definition: snn_manager.cpp:6181
ConnectConfigRT_s
The runtime configuration of a connection.
Definition: snn_datastructures.h:162
SNN::getNumNeuronsGenInh
int getNumNeuronsGenInh()
Definition: snn.h:576
SNN::isSimulationWithSTP
bool isSimulationWithSTP()
Definition: snn.h:642
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:597
SNN::updateConnectionMonitor
void updateConnectionMonitor(short int connId=ALL)
polls connection weights
Definition: snn_manager.cpp:6219
GroupMonitorCore
GroupMonitor private core implementation.
Definition: group_monitor_core.h:64
SNN::getNumNeurons
int getNumNeurons()
Definition: snn.h:570
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:1182
SNN::getSTPx
float * getSTPx()
temporary getter to return pointer to stpx[]
Definition: snn.h:613
SNN::isSimulationWithPlasticWeights
bool isSimulationWithPlasticWeights()
Definition: snn.h:640
SNN::updateNeuronMonitor
void updateNeuronMonitor(int grpId=ALL)
copy required neuron state values from ??? buffer to ??? buffer
Definition: snn_manager.cpp:6590
SNN::MINOR_VERSION
static const unsigned int MINOR_VERSION
minor release version, as in CARLsim 2.X
Definition: snn.h:139
SNN::getNumCompartmentConnections
int getNumCompartmentConnections()
Definition: snn.h:568
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:252
GlobalNetworkConfig_s::numNPois
int numNPois
number of poisson neurons in the global network
Definition: snn_datastructures.h:609
SNN::getGroupNeuromodulatorInfo
GroupNeuromodulatorInfo getGroupNeuromodulatorInfo(int grpId)
Definition: snn_manager.cpp:1901
RangeDelay
a range struct for synaptic delays
Definition: carlsim_datastructures.h:279
SNN::getGroupEndNeuronId
int getGroupEndNeuronId(int gGrpId)
Definition: snn.h:558
SNN::isSimulationWithCUBA
bool isSimulationWithCUBA()
Definition: snn.h:635
SNN::~SNN
~SNN()
SNN Destructor.
Definition: snn_manager.cpp:86
SNN::setupNetwork
void setupNetwork()
build the network
Definition: snn_manager.cpp:773
SNN::stopTesting
void stopTesting()
exits a testing phase, making weight updates possible again
Definition: snn_manager.cpp:6208
SNN::MAJOR_VERSION
static const unsigned int MAJOR_VERSION
major release version, as in CARLsim X
Definition: snn.h:138
GroupMonitor
Class GroupMonitor.
Definition: group_monitor.h:104
GlobalNetworkConfig_s::numNExcPois
int numNExcPois
number of excitatory poisson neurons in the global network
Definition: snn_datastructures.h:607
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:1222
SNN::isPoissonGroup
bool isPoissonGroup(int gGrpId)
Definition: snn.h:623
ALL
#define ALL
CARLsim common definitions.
Definition: carlsim_definitions.h:56
snn_definitions.h
SNN::getWeightMatrix2D
std::vector< std::vector< float > > getWeightMatrix2D(short int connId)
Definition: snn_manager.cpp:6233
SNN::getGroupId
int getGroupId(std::string grpName)
Definition: snn_manager.cpp:1853
ComputingBackend
ComputingBackend
computing backend
Definition: carlsim_datastructures.h:148
NeuronMonitorCore
Definition: neuron_monitor_core.h:59
SNN::getSpikeMonitor
SpikeMonitor * getSpikeMonitor(int grpId)
Returns pointer to existing SpikeMonitor object, NULL else.
Definition: snn_manager.cpp:1960
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:349
SNN::isSimulationWithNMDARise
bool isSimulationWithNMDARise()
Definition: snn.h:636
SNN::isSimulationWithCompartments
bool isSimulationWithCompartments()
Definition: snn.h:633
SNN::getConductanceAMPA
std::vector< float > getConductanceAMPA(int grpId)
Definition: snn_manager.cpp:1728
SNN::SNN
SNN(const std::string &name, SimMode preferredSimMode, LoggerMode loggerMode, int randSeed)
SNN Constructor.
Definition: snn_manager.cpp:77
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:1287
SNN::getSTPu
float * getSTPu()
temporary getter to return pointer to stpu[]
Definition: snn.h:610
SNN::getNeuronLocation3D
Point3D getNeuronLocation3D(int neurId)
Definition: snn_manager.cpp:1916
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:497
SNN::scaleWeights
void scaleWeights(short int connId, float scale, bool updateWeightRange=false)
Definition: snn_manager.cpp:1006
SNN::getLogFpErr
const FILE * getLogFpErr()
returns file pointer to error log
Definition: snn.h:516
STDPCurve
STDPCurve
STDP curves.
Definition: carlsim_datastructures.h:178
poisson_rate.h
Point3D
a point in 3D space
Definition: linear_algebra.h:57
SNN::isSimulationWithFixedWeightsOnly
bool isSimulationWithFixedWeightsOnly()
Definition: snn.h:638
SNN::getSimTimeMs
int getSimTimeMs()
Definition: snn.h:583
GlobalNetworkConfig_s::numNInhPois
int numNInhPois
number of inhibitory poisson neurons in the global network
Definition: snn_datastructures.h:608
SNN::getRandSeed
int getRandSeed()
Definition: snn.h:579
SNN::getLogFpInf
const FILE * getLogFpInf()
function writes population weights from gIDpre to gIDpost to file fname in binary.
Definition: snn.h:514
Grid3D
A struct to arrange neurons on a 3D grid (a primitive cubic Bravais lattice with cubic side length 1)
Definition: carlsim_datastructures.h:490
SNN::connectCompartments
short int connectCompartments(int grpIdLower, int grpIdUpper)
Definition: snn_manager.cpp:217
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:461
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:1271
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:621
GlobalNetworkConfig_s::numNExcReg
int numNExcReg
number of regular excitatory neurons in the global network
Definition: snn_datastructures.h:603
ConnectConfig_s
The configuration of a connection.
Definition: snn_datastructures.h:120
LoggerMode
LoggerMode
Logger modes.
Definition: carlsim_datastructures.h:91
SpikeBuffer
Circular buffer for delivering spikes.
Definition: spike_buffer.h:66
SNN::getNumSynapticConnections
int getNumSynapticConnections(short int connectionId)
gets number of connections associated with a connection ID
Definition: snn_manager.cpp:1949
carlsim.h
SNN::getNumNeuronsReg
int getNumNeuronsReg()
Definition: snn.h:571
GlobalNetworkConfig_s::numN
int numN
number of neurons in the global network
Definition: snn_datastructures.h:602
SNN::isSimulationWithCOBA
bool isSimulationWithCOBA()
Definition: snn.h:634
SNN::getSimTime
int getSimTime()
Definition: snn.h:581
SNN::getLogFpDeb
const FILE * getLogFpDeb()
returns file pointer to debug log
Definition: snn.h:518
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:505
NeuronMonitor
Definition: neuron_monitor.h:59
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:302
SNN::setHomeoBaseFiringRate
void setHomeoBaseFiringRate(int groupId, float baseFiring, float baseFiringSD)
Sets homeostatic target firing rate (enforced through homeostatic synaptic scaling)
Definition: snn_manager.cpp:481
SNN::isInhibitoryGroup
bool isInhibitoryGroup(int gGrpId)
Definition: snn.h:622
SNN::getGroupName
std::string getGroupName(int grpId)
Definition: snn_manager.cpp:1865
ConnectionMonitor
Class ConnectionMonitor.
Definition: connection_monitor.h:149
SNN::isGroupWithHomeostasis
bool isGroupWithHomeostasis(int grpId)
returns whether group has homeostasis enabled (true) or not (false)
Definition: snn_manager.cpp:4894
GlobalNetworkConfig_s::numNInhReg
int numNInhReg
number of regular inhibitory neurons in the global network
Definition: snn_datastructures.h:604
SNN::exitSimulation
void exitSimulation(int val=1)
deallocates all dynamical structures and exits
Definition: snn_manager.cpp:995
SNN::isSimulationWithSTDP
bool isSimulationWithSTDP()
Definition: snn.h:641
TARGET_NMDA
#define TARGET_NMDA
Definition: carlsim_definitions.h:68
GlobalNetworkConfig_s::numNReg
int numNReg
number of regular (spking) neurons in the global network
Definition: snn_datastructures.h:605
RuntimeData_s::stpu
float * stpu
Definition: snn_datastructures.h:513
SNN
Contains all of CARLsim's core functionality.
Definition: snn.h:115
SNN::getConductanceGABAb
std::vector< float > getConductanceGABAb(int grpId)
Definition: snn_manager.cpp:1774
SNN::getWeightRange
RangeWeight getWeightRange(short int connId)
returns RangeWeight struct of a connection
Definition: snn_manager.cpp:2003
GroupNeuromodulatorInfo_s
A struct for retrieving neuromodulator information of a group.
Definition: carlsim_datastructures.h:444
TARGET_AMPA
#define TARGET_AMPA
Definition: carlsim_definitions.h:67
SNN::getLoggerMode
LoggerMode getLoggerMode()
Definition: snn.h:554
UpdateInterval
UpdateInterval
Update frequency for weights.
Definition: carlsim_datastructures.h:238
SNN::isExcitatoryGroup
bool isExcitatoryGroup(int gGrpId)
Definition: snn.h:621
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:1802
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:654
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:1125
SNN::getConnectId
short int getConnectId(int grpIdPre, int grpIdPost)
find connection ID based on pre-post group pair, O(N)
Definition: snn_manager.cpp:1704
SNN::isDopaminergicGroup
bool isDopaminergicGroup(int gGrpId)
Definition: snn.h:624
MAX_NET_PER_SNN
#define MAX_NET_PER_SNN
Definition: snn_definitions.h:134
SNN::getGroupGrid3D
Grid3D getGroupGrid3D(int grpId)
Definition: snn_manager.cpp:1846
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:700
RadiusRF
A struct to specify the receptive field (RF) radius in 3 dimensions.
Definition: carlsim_datastructures.h:364
TARGET_GABAa
#define TARGET_GABAa
Definition: carlsim_definitions.h:69
snn_datastructures.h
SNN::getDelayRange
RangeDelay getDelayRange(short int connId)
returns the RangeDelay struct of a connection
Definition: snn_manager.cpp:1795
SNN::getNumNeuronsGen
int getNumNeuronsGen()
Definition: snn.h:574
SNN::updateSpikeMonitor
void updateSpikeMonitor(int grpId=ALL)
copy required spikes from firing buffer to spike buffer
Definition: snn_manager.cpp:6479
STDPType
STDPType
STDP flavors.
Definition: carlsim_datastructures.h:161
SNN::getNumConnections
int getNumConnections()
Definition: snn.h:566
SNN::getLogFpLog
const FILE * getLogFpLog()
returns file pointer to log file
Definition: snn.h:520
SNNState
SNNState
the state of spiking neural network, used with in kernel.
Definition: snn_datastructures.h:78