MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Element.cpp File Reference
#include "header.h"
#include "FuncOrder.h"
#include "HopFunc.h"
#include "../msg/OneToAllMsg.h"
#include "../shell/Shell.h"
#include "../scheduling/Clock.h"
+ Include dependency graph for Element.cpp:

Go to the source code of this file.

Classes

class  matchMid
 

Functions

static bool addClockMsg (unsigned int tick, Id tgt, const Finfo *f2)
 
void filterOffNodeTargets (unsigned int start, unsigned int end, bool isSrcGlobal, unsigned int myNode, vector< vector< Eref > > &erefs, vector< vector< bool > > &targetNodes)
 
unsigned int findNumDigest (const vector< vector< MsgDigest > > &md, unsigned int totFunc, unsigned int numData, unsigned int funcNum)
 
vector< FuncOrderputFuncsInOrder (const Element *elm, const vector< MsgFuncBinding > &vec)
 

Function Documentation

static bool addClockMsg ( unsigned int  tick,
Id  tgt,
const Finfo f2 
)
static

Definition at line 228 of file Element.cpp.

References Finfo::addMsg(), Element::cinfo(), Id::element(), Id::eref(), Cinfo::findFinfo(), and Msg::mid().

Referenced by Element::setTick().

229 {
230  Id clockId( 1 );
231  stringstream ss;
232  ss << "proc" << tick;
233 
234  const Finfo* f1 = clockId.element()->cinfo()->findFinfo( ss.str() );
235  assert( f1 );
236  assert( f2 );
237  Msg* m = new OneToAllMsg( clockId.eref(), tgt.element(), 0 );
238  if ( m )
239  {
240  if ( f1->addMsg( f2, m->mid(), clockId.element() ) )
241  {
242  return true;
243  }
244  delete m;
245  }
246  cout << "Error: Element::setTick: failed to connect " << tgt <<
247  " to clock\n";
248  return false;
249 }
ObjId mid() const
Definition: Msg.h:106
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
virtual bool addMsg(const Finfo *target, ObjId mid, Element *src) const
Definition: Finfo.h:92
Definition: Msg.h:18
Element * element() const
Definition: ObjId.cpp:124
Definition: Id.h:17
Definition: Finfo.h:12

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void filterOffNodeTargets ( unsigned int  start,
unsigned int  end,
bool  isSrcGlobal,
unsigned int  myNode,
vector< vector< Eref > > &  erefs,
vector< vector< bool > > &  targetNodes 
)

Picks which messages we retain in the MsgDigest. Does so at two levels:

  • Builds an array[][] of bools to indicate messages sourced here that go off-node. These will have special HopFuncs added.
  • Retains entries in erefs that are sourced anywhere, but targetted here. Need to be able to handle off-node messages landing here, as well as the entirely local messages.

Definition at line 429 of file Element.cpp.

References ALLDATA, Eref::dataIndex(), Eref::element(), Eref::getNode(), Element::isGlobal(), and Shell::numNodes().

Referenced by Element::putTargetsInDigest(), and testFilterOffNodeTargets().

436 {
437  // i is index of src dataid
438  for ( unsigned int i = 0; i < erefs.size(); ++i )
439  {
440  vector< Eref > temp;
441  vector< Eref >& vec = erefs[i];
442  for ( unsigned int j = 0; j < vec.size(); ++j ) // list of tgts.
443  {
444  const Eref& er = vec[j];
445  unsigned int node = er.getNode();
446  if ( !isSrcGlobal && // Don't send any msgs
447  // off-node, as it will be dealt with by the off-node src.
448  i >= start && i < end ) // Sourced from current node.
449  {
450  if ( node != myNode ) // Target is off-node
451  targetNodes[i][node] = true;
452  if ( er.dataIndex() == ALLDATA || er.element()->isGlobal())
453  {
454  for ( unsigned int k = 0; k < Shell::numNodes(); ++k )
455  if ( k != myNode )
456  targetNodes[i][k] = true;
457  }
458  }
459  if ( node == myNode ) // Regardless of source, target is onNode.
460  temp.push_back( er );
461  }
462  erefs[i] = temp; // Swap out the original set with the new one.
463  }
464 }
unsigned int getNode() const
Definition: Eref.cpp:52
unsigned int dataIndex() const
Definition: Eref.h:50
Element * element() const
Definition: Eref.h:42
const unsigned int ALLDATA
Used by ObjId and Eref.
Definition: consts.cpp:22
static unsigned int myNode
Definition: Eref.h:26
virtual bool isGlobal() const =0
True if there is a copy of every dataEntry on all nodes.
static unsigned int numNodes()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

unsigned int findNumDigest ( const vector< vector< MsgDigest > > &  md,
unsigned int  totFunc,
unsigned int  numData,
unsigned int  funcNum 
)

Definition at line 558 of file Element.cpp.

Referenced by Element::digestMessages().

560 {
561  unsigned int ret = 0;
562  for ( unsigned int i = 0; i < numData; ++i )
563  {
564  ret += md[ totFunc * i + funcNum ].size();
565  }
566  return ret;
567 }

+ Here is the caller graph for this function:

vector< FuncOrder> putFuncsInOrder ( const Element elm,
const vector< MsgFuncBinding > &  vec 
)

Definition at line 392 of file Element.cpp.

References Element::cinfo(), Msg::e1(), Msg::e2(), MsgFuncBinding::fid, Msg::getMsg(), Cinfo::getOpFunc(), and MsgFuncBinding::mid.

Referenced by Element::digestMessages().

394 {
395  vector< FuncOrder > fo( vec.size() );
396  for ( unsigned int j = 0; j < vec.size(); ++j )
397  {
398  const MsgFuncBinding& mfb = vec[j];
399  const Msg* msg = Msg::getMsg( mfb.mid );
400  if ( msg->e1() == elm )
401  {
402  fo[j].set( msg->e2()->cinfo()->getOpFunc( mfb.fid ), j );
403  }
404  else
405  {
406  fo[j].set( msg->e1()->cinfo()->getOpFunc( mfb.fid ), j );
407  }
408  }
409  sort( fo.begin(), fo.end() );
410  return fo;
411 }
Element * e2() const
Definition: Msg.h:68
const OpFunc * getOpFunc(FuncId fid) const
Definition: Cinfo.cpp:240
const Cinfo * cinfo() const
Definition: Element.cpp:66
Definition: Msg.h:18
Element * e1() const
Definition: Msg.h:61
static const Msg * getMsg(ObjId m)
Definition: Msg.cpp:59

+ Here is the call graph for this function:

+ Here is the caller graph for this function: