MOOSE - Multiscale Object Oriented Simulation Environment
|
#include <SparseMsg.h>
Public Member Functions | |
void | clear () |
Msg * | copy (Id origSrc, Id newSrc, Id newTgt, FuncId fid, unsigned int b, unsigned int n) const |
ObjId | findOtherEnd (ObjId end) const |
Eref | firstTgt (const Eref &src) const |
vector< unsigned int > | getColIndex () const |
vector< unsigned int > | getEntryPairs () const |
SparseMatrix< unsigned int > & | getMatrix () |
vector< unsigned int > | getMatrixEntry () const |
unsigned int | getNumColumns () const |
unsigned int | getNumEntries () const |
unsigned int | getNumRows () const |
double | getProbability () const |
vector< unsigned int > | getRowStart () const |
unsigned long | getSeed () const |
Id | managerId () const |
void | pairFill (vector< unsigned int > src, vector< unsigned int > dest) |
unsigned int | randomConnect (double probability) |
void | setEntry (unsigned int row, unsigned int column, unsigned int value) |
void | setEntryPairs (vector< unsigned int > entries) |
void | setMatrix (const SparseMatrix< unsigned int > &m) |
void | setProbability (double value) |
void | setRandomConnectivity (double probability, long seed) |
void | setSeed (unsigned long value) |
void | sources (vector< vector< Eref > > &v) const |
SparseMsg (Element *e1, Element *e2, unsigned int msgIndex) | |
void | targets (vector< vector< Eref > > &v) const |
void | transpose () |
void | tripletFill (vector< unsigned int > src, vector< unsigned int > dest, vector< unsigned int > field) |
void | tripletFill1 (vector< unsigned int > entries) |
void | unsetEntry (unsigned int row, unsigned int column) |
void | updateAfterFill () |
~SparseMsg () | |
![]() | |
Element * | e1 () const |
Element * | e2 () const |
ObjId | getAdjacent (ObjId) const |
vector< string > | getDestFieldsOnE1 () const |
vector< string > | getDestFieldsOnE2 () const |
Id | getE1 () const |
Id | getE2 () const |
vector< string > | getSrcFieldsOnE1 () const |
vector< string > | getSrcFieldsOnE2 () const |
bool | isForward (const Element *src) const |
ObjId | mid () const |
Msg (ObjId mid, Element *e1, Element *e2) | |
Constructor. More... | |
virtual void | sources (vector< vector< Eref > > &v) const =0 |
virtual void | targets (vector< vector< Eref > > &v) const =0 |
virtual | ~Msg () |
Destructor. More... | |
Static Public Member Functions | |
static const Cinfo * | initCinfo () |
static char * | lookupMsg (unsigned int index) |
Static function for Msg access. More... | |
static unsigned int | numMsg () |
Msg lookup functions. More... | |
![]() | |
static void | clearAllMsgs () |
static void | deleteMsg (ObjId mid) |
static const Msg * | getMsg (ObjId m) |
static const Cinfo * | initCinfo () |
static unsigned int | initMsgManagers () |
static bool | isLastTrump () |
True when MOOSE has been terminated and is being cleaned up. More... | |
static const Msg * | lastMsg () |
Private Attributes | |
moose::MOOSE_UNIFORM_DISTRIBUTION < double > | dist_ |
SparseMatrix< unsigned int > | matrix_ |
unsigned int | nrows_ |
unsigned int | numThreads_ |
double | p_ |
moose::MOOSE_RANDOM_DEVICE | rd_ |
moose::MOOSE_RNG_DEFAULT_ENGINE | rng_ |
unsigned long | seed_ |
Static Private Attributes | |
static Id | managerId_ |
static vector< SparseMsg * > | msg_ |
Friends | |
unsigned int | Msg::initMsgManagers () |
Additional Inherited Members | |
![]() | |
Element * | e1_ |
Index of this Msg on the msg_ vector. More... | |
Element * | e2_ |
Element 1 attached to Msg. More... | |
ObjId | mid_ |
![]() | |
static bool | lastTrump_ = false |
Flag to indicate termination of program. More... | |
static Id | msgManagerId_ |
Element 2 attached to Msg. More... | |
This is a parallelized sparse message. It is a general message type optimized for sparse matrix like projection patterns. For each source object[DataId] there can be a target object[DataId]. For parallel/multithreaded use, we need to guarantee that all requests to the same target object (and all its synapses) are on the same queue. So it builds up a separate SparseMatrix for each thread.
It has a function to do the node/thread decomposition to generate an equivalent of the original sparse matrix, but using only the appropriate RNG seed.
A typical case is from an array of IntFire objects to an array of Synapses, which are array fields of IntFire objects. The sparse connectivity maps between the source IntFire and target Synapses.
The location of the entry in the sparse matrix provides the index of the target IntFire. The data value in the sparse matrix provides the index of the Synapse at that specific connection. This assumes that only one Synapse mediates a given connection between any two IntFire objects.
It is optimized for input coming on Element e1, and going to Element e2. If you expect any significant backward data flow, please use BiSparseMsg. It can be modified after creation to add or remove message entries.
Definition at line 46 of file SparseMsg.h.
Definition at line 389 of file SparseMsg.cpp.
References matrix_, msg_, Element::numData(), rd_, rng_, seed_, and SparseMatrix< T >::setSize().
Referenced by copy().
SparseMsg::~SparseMsg | ( | ) |
void SparseMsg::clear | ( | ) |
Definition at line 289 of file SparseMsg.cpp.
References SparseMatrix< T >::clear(), and matrix_.
Referenced by initCinfo().
|
virtual |
Make a copy of this Msg. The original msg was on origSrc. The new Msg should go from newSrc to newTgt, and have the function fid, on bindIndex b. The copy may have to be a higher-order Msg type to handle arrays if n > 1. Note that n is not the number of msgs, but the multiplier by which numData will be scaled.
Implements Msg.
Definition at line 570 of file SparseMsg.cpp.
References Element::addMsgAndFunc(), Msg::e1(), Msg::e2(), Id::element(), matrix_, Msg::mid(), nrows_, setMatrix(), and SparseMsg().
Find the other end of this Msg. In most cases this is a straightforward return of e1 or e2, plus perhaps a DataId. But in some complex msgs we need to figure out DataIds that match with the target. In many-to-one cases we just return the first entry. If no Element match, return ObjId( Id(), DataId::bad() ) If Element e matches but not DataId, return ObjId( e.id(), DataId::bad() )
Implements Msg.
Definition at line 544 of file SparseMsg.cpp.
References BADINDEX, ObjId::dataIndex, Msg::e1(), Msg::e2(), ObjId::element(), SparseMatrix< T >::getColumn(), SparseMatrix< T >::getRow(), matrix_, and rowIndex().
Obtain the first target Eref for the specified Src Eref It is really meant only to work with messages with a single target ObjId for each given src, typically OneToOne.
Implements Msg.
Definition at line 433 of file SparseMsg.cpp.
References Eref::dataIndex(), Msg::e1_, Msg::e2_, Eref::element(), SparseMatrix< T >::getRow(), matrix_, and SparseMatrix< T >::nEntries().
vector< unsigned int > SparseMsg::getColIndex | ( | ) | const |
Definition at line 234 of file SparseMsg.cpp.
References SparseMatrix< T >::colIndex(), and matrix_.
Referenced by initCinfo().
vector< unsigned int > SparseMsg::getEntryPairs | ( | ) | const |
Definition at line 251 of file SparseMsg.cpp.
References SparseMatrix< T >::colIndex(), matrix_, SparseMatrix< T >::nRows(), and SparseMatrix< T >::rowStart().
Referenced by initCinfo().
SparseMatrix< unsigned int > & SparseMsg::getMatrix | ( | ) |
vector< unsigned int > SparseMsg::getMatrixEntry | ( | ) | const |
Definition at line 229 of file SparseMsg.cpp.
References matrix_, and SparseMatrix< T >::matrixEntry().
Referenced by initCinfo().
unsigned int SparseMsg::getNumColumns | ( | ) | const |
Definition at line 219 of file SparseMsg.cpp.
References matrix_, and SparseMatrix< T >::nColumns().
Referenced by initCinfo().
unsigned int SparseMsg::getNumEntries | ( | ) | const |
Definition at line 224 of file SparseMsg.cpp.
References matrix_, and SparseMatrix< T >::nEntries().
Referenced by initCinfo().
unsigned int SparseMsg::getNumRows | ( | ) | const |
Definition at line 214 of file SparseMsg.cpp.
References matrix_, and SparseMatrix< T >::nRows().
Referenced by initCinfo().
double SparseMsg::getProbability | ( | ) | const |
Definition at line 193 of file SparseMsg.cpp.
References p_.
Referenced by initCinfo().
vector< unsigned int > SparseMsg::getRowStart | ( | ) | const |
Definition at line 239 of file SparseMsg.cpp.
References matrix_, and SparseMatrix< T >::rowStart().
Referenced by initCinfo().
unsigned long SparseMsg::getSeed | ( | ) | const |
Definition at line 209 of file SparseMsg.cpp.
References seed_.
Referenced by initCinfo().
|
static |
Connection matrix entries to manipulate in Python.
connection matrix column indices to manipulate in Python.
connection matrix rowStart to manipulate in Python.
Definition at line 24 of file SparseMsg.cpp.
References clear(), getColIndex(), getEntryPairs(), getMatrixEntry(), getNumColumns(), getNumEntries(), getNumRows(), getProbability(), getRowStart(), getSeed(), Msg::initCinfo(), numEntries, pairFill(), setEntry(), setEntryPairs(), setProbability(), setRandomConnectivity(), setSeed(), sparseMsgCinfo, transpose(), tripletFill(), tripletFill1(), and unsetEntry().
Referenced by Msg::initMsgManagers().
|
static |
Static function for Msg access.
Definition at line 643 of file SparseMsg.cpp.
References msg_.
Referenced by Msg::clearAllMsgs(), and Msg::initMsgManagers().
Id SparseMsg::managerId | ( | ) | const |
|
static |
Msg lookup functions.
Static function for Msg access.
Definition at line 637 of file SparseMsg.cpp.
References msg_.
Referenced by Msg::clearAllMsgs(), and Msg::initMsgManagers().
void SparseMsg::pairFill | ( | vector< unsigned int > | src, |
vector< unsigned int > | dest | ||
) |
Fills up the entire message based on pairs of src,dest (i.e., row,column) values. All filled entries are set to zero.
We set retainSize flag to true since the # of src/dest objects doesn't change. We can explicitly assign it elsewhere if needed.
Definition at line 323 of file SparseMsg.cpp.
References Msg::e1(), Msg::e2(), matrix_, Element::numData(), SparseMatrix< T >::tripletFill(), and updateAfterFill().
Referenced by initCinfo(), and setEntryPairs().
unsigned int SparseMsg::randomConnect | ( | double | probability | ) |
Returns number of synapses formed. Fills it in transpose form, because we need to count and index the number of synapses on the target, so we need to iterate over the sources in the inner loop. Once full, does the transpose. Should really have a seed argument for the random number. Later need a way to fast-forward mtrand to just the entries we need to fill.
Definition at line 465 of file SparseMsg.cpp.
References SparseMatrix< T >::addRow(), SparseMatrix< T >::clear(), dist_, Msg::e1(), Msg::e2(), Msg::e2_, Element::localDataStart(), Element::markRewired(), matrix_, SparseMatrix< T >::nColumns(), SparseMatrix< T >::nRows(), Element::numData(), Element::numLocalData(), Element::resizeField(), rng_, and SparseMatrix< T >::transpose().
Referenced by setProbability(), setRandomConnectivity(), setSeed(), and testSparseMsg().
void SparseMsg::setEntry | ( | unsigned int | row, |
unsigned int | column, | ||
unsigned int | value | ||
) |
Definition at line 278 of file SparseMsg.cpp.
References matrix_, and SparseMatrix< T >::set().
Referenced by initCinfo().
void SparseMsg::setEntryPairs | ( | vector< unsigned int > | entries | ) |
Definition at line 244 of file SparseMsg.cpp.
References pairFill().
Referenced by initCinfo().
void SparseMsg::setMatrix | ( | const SparseMatrix< unsigned int > & | m | ) |
Assigns the whole connection matrix
Definition at line 534 of file SparseMsg.cpp.
References matrix_.
Referenced by copy().
void SparseMsg::setProbability | ( | double | value | ) |
Definition at line 187 of file SparseMsg.cpp.
References p_, and randomConnect().
Referenced by initCinfo().
void SparseMsg::setRandomConnectivity | ( | double | probability, |
long | seed | ||
) |
Definition at line 271 of file SparseMsg.cpp.
References p_, randomConnect(), and rng_.
Referenced by initCinfo().
void SparseMsg::setSeed | ( | unsigned long | value | ) |
Definition at line 198 of file SparseMsg.cpp.
References p_, randomConnect(), rd_, rng_, and seed_.
Referenced by initCinfo().
void SparseMsg::sources | ( | vector< vector< Eref > > & | v | ) | const |
Definition at line 624 of file SparseMsg.cpp.
References Msg::e1_, Msg::e2_, fillErefsFromMatrix(), matrix_, and SparseMatrix< T >::transpose().
void SparseMsg::targets | ( | vector< vector< Eref > > & | v | ) | const |
Definition at line 631 of file SparseMsg.cpp.
References Msg::e1_, Msg::e2_, fillErefsFromMatrix(), and matrix_.
void SparseMsg::transpose | ( | ) |
Definition at line 294 of file SparseMsg.cpp.
References Msg::e1(), Msg::e2(), Element::markRewired(), matrix_, and SparseMatrix< T >::transpose().
Referenced by initCinfo().
void SparseMsg::tripletFill | ( | vector< unsigned int > | src, |
vector< unsigned int > | dest, | ||
vector< unsigned int > | field | ||
) |
Fills up the entire message based on triplets of src,destDataIndex,destFieldIndex
Definition at line 366 of file SparseMsg.cpp.
References matrix_, SparseMatrix< T >::tripletFill(), and updateAfterFill().
Referenced by initCinfo(), and tripletFill1().
void SparseMsg::tripletFill1 | ( | vector< unsigned int > | entries | ) |
Fills up the entire message based on triplets of src,destDataIndex,destFieldIndex, but catenates them all into a single long vector since PyMoose doesn't know how to handle multiple vectors.
Definition at line 375 of file SparseMsg.cpp.
References tripletFill().
Referenced by initCinfo().
void SparseMsg::unsetEntry | ( | unsigned int | row, |
unsigned int | column | ||
) |
Definition at line 284 of file SparseMsg.cpp.
References matrix_, and SparseMatrix< T >::unset().
Referenced by initCinfo().
void SparseMsg::updateAfterFill | ( | ) |
Utility function to update all sorts of values after we've rebuilt the matrix.
Definition at line 301 of file SparseMsg.cpp.
References Msg::e1(), Msg::e2(), Msg::e2_, SparseMatrix< T >::getRow(), Element::localDataStart(), Element::markRewired(), matrix_, SparseMatrix< T >::nRows(), Element::numLocalData(), Element::resizeField(), and SparseMatrix< T >::transpose().
Referenced by pairFill(), and tripletFill().
|
friend |
|
private |
Definition at line 155 of file SparseMsg.h.
Referenced by randomConnect().
|
staticprivate |
Definition at line 148 of file SparseMsg.h.
Referenced by Msg::initMsgManagers(), and managerId().
|
private |
Definition at line 144 of file SparseMsg.h.
Referenced by clear(), copy(), findOtherEnd(), firstTgt(), getColIndex(), getEntryPairs(), getMatrix(), getMatrixEntry(), getNumColumns(), getNumEntries(), getNumRows(), getRowStart(), pairFill(), randomConnect(), setEntry(), setMatrix(), sources(), SparseMsg(), targets(), transpose(), tripletFill(), unsetEntry(), and updateAfterFill().
|
staticprivate |
Definition at line 149 of file SparseMsg.h.
Referenced by lookupMsg(), numMsg(), SparseMsg(), and ~SparseMsg().
|
private |
Definition at line 146 of file SparseMsg.h.
Referenced by copy().
|
private |
Definition at line 145 of file SparseMsg.h.
|
private |
Definition at line 147 of file SparseMsg.h.
Referenced by getProbability(), setProbability(), setRandomConnectivity(), and setSeed().
|
private |
Definition at line 153 of file SparseMsg.h.
Referenced by setSeed(), and SparseMsg().
|
private |
Definition at line 154 of file SparseMsg.h.
Referenced by randomConnect(), setRandomConnectivity(), setSeed(), and SparseMsg().
|
private |
Definition at line 152 of file SparseMsg.h.
Referenced by getSeed(), setSeed(), and SparseMsg().