MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
HopFunc.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 ** This program is part of 'MOOSE', the
3 ** Messaging Object Oriented Simulation Environment.
4 ** Copyright (C) 2003-2013 Upinder S. Bhalla. and NCBS
5 ** It is made available under the terms of the
6 ** GNU Lesser General Public License version 2.1
7 ** See the file COPYING.LIB for the full notice.
8 **********************************************************************/
9 #include "header.h"
10 #include "HopFunc.h"
11 #include "../mpi/PostMaster.h"
12 #include "../shell/Shell.h"
13 
14 static double testBuf[4096];
15 static double* addToTestBuf( const Eref& e, unsigned int i,
16  unsigned int size )
17 {
18  TgtInfo* tgt = reinterpret_cast< TgtInfo* >( &testBuf[0] );
19  tgt->set( e.objId(), i, size );
20  return &testBuf[ TgtInfo::headerSize ];
21 }
22 
23 const double* checkHopFuncTestBuffer()
24 {
25  return &testBuf[0];
26 }
27 
28 
29 double* addToBuf( const Eref& er, HopIndex hopIndex, unsigned int size )
30 {
31  static ObjId oi( 3 );
32  static PostMaster* p = reinterpret_cast< PostMaster* >( oi.data() );
33  if ( hopIndex.hopType() == MooseSendHop ) {
34  return p->addToSendBuf( er, hopIndex.bindIndex(), size );
35  } else if ( hopIndex.hopType() == MooseSetHop ||
36  hopIndex.hopType() == MooseSetVecHop ) {
37  p->clearPendingSetGet(); // Cannot touch set buffer if pending.
38  return p->addToSetBuf( er, hopIndex.bindIndex(),
39  size, hopIndex.hopType() );
40  } else if ( hopIndex.hopType() == MooseTestHop ) {
41  return addToTestBuf( er, hopIndex.bindIndex(), size );
42  }
43  assert( 0 ); // Should not get here.
44  return 0;
45 }
46 
47 void dispatchBuffers( const Eref& e, HopIndex hopIndex )
48 {
49  static ObjId oi( 3 );
50  static PostMaster* p = reinterpret_cast< PostMaster* >( oi.data() );
51  if ( Shell::numNodes() == 1 )
52  return;
53  if ( hopIndex.hopType() == MooseSetHop ||
54  hopIndex.hopType() == MooseGetHop ) {
55  p->dispatchSetBuf( e );
56  }
57  if ( hopIndex.hopType() == MooseSetVecHop ) {
58  p->dispatchSetBuf( e );
59  }
60  // More complicated stuff for get operations.
61 }
62 
63 double* remoteGet( const Eref& e, unsigned int bindIndex )
64 {
65  static ObjId oi( 3 );
66  static PostMaster* p = reinterpret_cast< PostMaster* >( oi.data() );
67  return p->remoteGet( e, bindIndex );
68 }
69 
70 void remoteGetVec( const Eref& e, unsigned int bindIndex,
71  vector< vector< double > >& getRecvBuf,
72  vector< unsigned int >& numOnNode )
73 {
74  static ObjId oi( 3 );
75  static PostMaster* p = reinterpret_cast< PostMaster* >( oi.data() );
76  p->remoteGetVec( e, bindIndex, getRecvBuf, numOnNode );
77 }
78 
79 void remoteFieldGetVec( const Eref& e, unsigned int bindIndex,
80  vector< double >& getRecvBuf )
81 {
82  static ObjId oi( 3 );
83  static PostMaster* p = reinterpret_cast< PostMaster* >( oi.data() );
84  p->remoteFieldGetVec( e, bindIndex, getRecvBuf );
85 }
86 
87 unsigned int mooseNumNodes()
88 {
89  return Shell::numNodes();
90 }
91 
92 unsigned int mooseMyNode()
93 {
94  return Shell::myNode();
95 }
static double * addToTestBuf(const Eref &e, unsigned int i, unsigned int size)
Definition: HopFunc.cpp:15
const unsigned char MooseSendHop
Definition: OpFuncBase.cpp:12
double * remoteGet(const Eref &e, unsigned int bindIndex)
Definition: HopFunc.cpp:63
char * data() const
Definition: ObjId.cpp:113
void dispatchSetBuf(const Eref &e)
Sends off contets of Set buffer.
Definition: PostMaster.cpp:487
unsigned short bindIndex() const
Definition: OpFuncBase.h:32
double * addToSendBuf(const Eref &e, unsigned int bindIndex, unsigned int size)
Returns pointer to Send buffer for filling in arguments.
Definition: PostMaster.cpp:442
static double testBuf[4096]
Definition: HopFunc.cpp:14
void remoteGetVec(const Eref &e, unsigned int bindIndex, vector< vector< double > > &getRecvBuf, vector< unsigned int > &size)
This is a blocking call. However, it must still handle other.
Definition: PostMaster.cpp:623
static const unsigned int headerSize
Definition: PostMaster.h:97
void remoteGetVec(const Eref &e, unsigned int bindIndex, vector< vector< double > > &getRecvBuf, vector< unsigned int > &numOnNode)
Definition: HopFunc.cpp:70
Definition: ObjId.h:20
void dispatchBuffers(const Eref &e, HopIndex hopIndex)
Definition: HopFunc.cpp:47
const unsigned char MooseGetHop
Definition: OpFuncBase.cpp:15
unsigned int mooseMyNode()
Definition: HopFunc.cpp:92
double * remoteGet(const Eref &e, unsigned int bindIndex)
Blocking call to get a value from a remote node.
Definition: PostMaster.cpp:520
double * addToBuf(const Eref &er, HopIndex hopIndex, unsigned int size)
Definition: HopFunc.cpp:29
void clearPendingSetGet()
Clears arrived set and get calls.
Definition: PostMaster.cpp:299
unsigned char hopType() const
Definition: OpFuncBase.h:36
ObjId objId() const
Definition: Eref.cpp:57
Definition: Eref.h:26
const unsigned char MooseSetVecHop
Definition: OpFuncBase.cpp:14
const unsigned char MooseSetHop
Definition: OpFuncBase.cpp:13
const double * checkHopFuncTestBuffer()
Definition: HopFunc.cpp:23
unsigned int mooseNumNodes()
Definition: HopFunc.cpp:87
void remoteFieldGetVec(const Eref &e, unsigned int bindIndex, vector< double > &getRecvBuf)
Definition: HopFunc.cpp:79
void set(ObjId id, unsigned int bindIndex, unsigned int size)
Definition: PostMaster.h:83
void remoteFieldGetVec(const Eref &e, unsigned int bindIndex, vector< double > &getRecvBuf)
This is a blocking call. However, it must still handle other.
Definition: PostMaster.cpp:568
static unsigned int myNode()
double * addToSetBuf(const Eref &e, unsigned int opIndex, unsigned int size, unsigned int hopType)
Returns pointer to Set buffer for filling in arguments.
Definition: PostMaster.cpp:463
static unsigned int numNodes()
const unsigned char MooseTestHop
Definition: OpFuncBase.cpp:18