📄 node.h
字号:
/*************************************************************************** node.h - description ------------------- begin : Thu Dec 13 2001 copyright : (C) 2001 by Rudiger Koch email : rkoch@rkoch.org ***************************************************************************//*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/#ifndef NODE_H#define NODE_H#include <pthread.h>#include <amygdala/instance.h>class MpNetwork;/**@class Node node.h amygdala/node.h *A singleton class. Wraps the Network objects (instances) of one Node. *@author Rudiger Koch <rkoch@rkoch.org> */class Node {private: /** Users never create a Node object themselves * Changing this would require to have Network::SimTime a member of Node. */ Node(); /** New network threads start here (callback for the pthread library */ static void* NetworkThread(void* mpNetwork);public: ~Node(); /** run all instances * @param maxRunTime the maximum time the simulation will run */ void Run(unsigned int maxRunTime); /** create a Network instance * @return a pointer to the newly created MpNetwork */ MpNetwork* MakeNetwork(int instId); /** connect two neurons, possibly on different instances, possibly on different nodes * @param preInstId a valid instance in THIS Node * @param preNId a valid neuron ID in preInstId * @param postInstId a valid instance ID * @param postNId a valid neuron ID in postInstId * @param weight the weight of the synapse * @throw runtime_error One or both neurons do not exist */ void ConnectNeurons(AmIdInt preInstId, AmIdInt preNId, AmIdInt postInstId, AmIdInt postNId, float weight, AmTimeInt delay); /** @return A reference to the Node object */ static Node* GetNodeRef(); /** turn on listening on port for incoming spikes * @param port the UDP port to listen at */ void UdpListener(int port); unsigned int GetMaxRunTime(); /** a thread goes to sleep here. The last thread cannot go to sleep. In case we are the last, * false is returned. */ bool NNthreadSleep(unsigned int simTime); /** wake up all sleeping network threads */ void NNthreadWakeUp(); /** Save to a file. The file will get a .amg appended if it doesn't end on .amg. * It will be a gzipped file for each Instance. All gzipped files will be tarred. * @throw runtime_error If we cannot open the file, the temporary files or run out of disk space or an Instance is running */ void Save(string filename); /** Connect 2 layers of different network instances * @throw runtime_error If a layer doesn't exist * @see Layer::ConnectLayers() */ void ConnectLayers(AmIdInt preInstance, AmIdInt preLayer, AmIdInt postInstance, AmIdInt postLayer, GaussConnectType parms, float pctInhibitory=0.0); /** Load an Amygdala SMP network */ void Load(string filename); /** Delete an Instance. Note that synapses to neurons within this instance are not removed in other Instances */ void DeleteInstance(AmIdInt instId); /** @return the Network instance given by instId @param A valid instance ID */ Network* GetNetwork(AmIdInt instId); /** @return an Iterator for Amygdala Instance s in the Node */ hash_map <AmIdInt, Instance*>::iterator instance_begin(); /** @return an Iterator for Amygdala Instance s in the Node */ hash_map <AmIdInt, Instance*>::iterator instance_end(); /** @return a pointer to the instance specified by the parameter */ Instance * GetInstance(AmIdInt instId);protected: // Protected attributes /** Maps instance IDs to Instance objects. */ hash_map<AmIdInt, Instance*> instances; /** The one and only node object */ static Node theNode; /** the maximum time the networks of this node run */ unsigned int maxRunTime;/** number of threads that went to sleep after emptying their spike input buffers. * This doesn't mean that such a thread is simply waiting for the next timestep. If * more requests become available through the still active threads a sleeping thread * must be woken up. */ int sleepers;/** number of NN threads. This will remain constant after the simulation starts * On SMP only, sleepers == threads indicate that we can go to the next timestep of * the simulation */ int NNthreads; pthread_mutex_t mut_sleeper; pthread_cond_t cond_sleeper;};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -