OpenAtom  Version1.5a
pcSectionManager.h
1 #include "paircalc/ckPairCalculator.h"
2 
3 #ifndef PC_SECTION_MANAGER_H
4 #define PC_SECTION_MANAGER_H
5 
6 /// Forward declarations
7 class Ortho;
8 
9 /** @addtogroup Ortho
10  @{
11 */
12 
13 namespace cp {
14  namespace ortho {
15 
16 /// Class that manages the paircalc sections that each Ortho chare communicates with
18 {
19  friend class ::Ortho;
20 
21  public:
22  /// Constructor
24  /// An initializer method that fills this with data
25  void init(const CkIndex2D orthoIdx, const pc::pcConfig &pcCfg, CkArrayID pcAID, CkGroupID oMCastGID, CkGroupID oRedGID);
26  /// PUP serializer
27  void pup(PUP::er &p);
28  /// Creates a paircalc array section given the necessary info. Replaces initOneRedSect()
29  void setupArraySection(CkCallback cb, bool arePhantomsOn, bool useComlibForOrthoToPC);
30  /// Sends out the results to the paircalc section. Replaces finishPairCalcSection()
31  void sendResults(int n, internalType *ptr1, internalType *ptr2, int orthoX, int orthoY, int actionType, int priority);
32  /// Used to send OrthoT to the asymm instance. Replaces sendMatrix()
33  void sendMatrix(int n, internalType *ptr1, internalType *ptr2, int orthoX, int orthoY, int actionType, int priority);
34  /// Identify the state indices of the Paircalc chares this ortho chare needs to talk to
35  CkIndex2D computePCStateIndices(const int orthoX, const int orthoY);
36  /// Overloaded version that uses the stored ortho indices to compute the PC state indices
38 
39  private:
40  /// Create a paircalc section containing all chares with the specified two state indices
41  void createPCsection(const int s1, const int s2);
42 
43  /// Number of planes that GSpace is decomposed into
44  int numPlanes;
45  /// Number of states in this simulation
46  int numStates;
47  /// The number of chunks (4th dimension decomposition) of paircalcs
48  int numChunks;
49  /// The statewise decomposition grain size for the paircalcs
51  /// The statewise decomposition grain size for the ortho chares
53 
54  /// The array ID of the paircalc instance that I will manage comm with
55  CkArrayID pcArrayID;
56  /// Is this paircalc array a symmetric or asymmetric instance
58  /// The section of the array that my owner ortho chare will be talking to
59  CProxySection_PairCalculator pcSection;
60 
61  /// The index of the calling Ortho chare
62  CkIndex2D orthoIndex;
63  /// The multicast and reduction groups that handle comm
64  CkGroupID orthomCastGrpID, orthoRedGrpID;
65  /// The priority to use for messages to PC
67 };
68 
69 
70 
71 /**
72  * ortho and paircalc grainsizes do not complicate this discussion a whole lot because of the restriction that
73  * ortho grainsize = multiple of paircalc grain size. Because of this equal or exact multiple clause, ortho grains
74  * will line up perfectly inside a paircalc grain and, hence, every ortho chare will hold a bunch of states that
75  * will all get delivered to the same paircalc section.
76  *
77  * paircalcs on the other hand will have to chop up their data along the ortho tile boundaries and contribute to
78  * multiple reductions that end up at the respective ortho chares. Refer PairCalculator::contributeSubTiles.
79  *
80  */
81 inline CkIndex2D PCSectionManager::computePCStateIndices(const int orthoX, const int orthoY)
82 {
83  CkIndex2D pc;
84  pc.x = orthoX * orthoGrainSize;
85  pc.y = orthoY * orthoGrainSize;
86  // Do something clever if the grainsizes are not the same
87  if(orthoGrainSize != pcGrainSize)
88  {
89  int maxpcstateindex = (numStates/pcGrainSize - 1) * pcGrainSize;
90  pc.x = pc.x / pcGrainSize * pcGrainSize;
91  pc.y = pc.y / pcGrainSize * pcGrainSize;
92  pc.x = (pc.x>maxpcstateindex) ? maxpcstateindex :pc.x;
93  pc.y = (pc.y>maxpcstateindex) ? maxpcstateindex :pc.y;
94  }
95  return pc;
96 }
97 
98  } // end namespace ortho
99 } // end namespace cp
100 /*@}*/
101 #endif // PC_SECTION_MANAGER
102 
103 
For definition of CkDataMsg.
Definition: ortho.h:105
CkIndex2D computePCStateIndices()
Overloaded version that uses the stored ortho indices to compute the PC state indices.
Class that manages the paircalc sections that each Ortho chare communicates with. ...
CkArrayID pcArrayID
The array ID of the paircalc instance that I will manage comm with.
void pup(PUP::er &p)
PUP serializer.
int numStates
Number of states in this simulation.
void sendMatrix(int n, internalType *ptr1, internalType *ptr2, int orthoX, int orthoY, int actionType, int priority)
Used to send OrthoT to the asymm instance. Replaces sendMatrix()
CProxySection_PairCalculator pcSection
The section of the array that my owner ortho chare will be talking to.
void createPCsection(const int s1, const int s2)
Create a paircalc section containing all chares with the specified two state indices.
CkGroupID orthomCastGrpID
The multicast and reduction groups that handle comm.
int numChunks
The number of chunks (4th dimension decomposition) of paircalcs.
void sendResults(int n, internalType *ptr1, internalType *ptr2, int orthoX, int orthoY, int actionType, int priority)
Sends out the results to the paircalc section. Replaces finishPairCalcSection()
int pcGrainSize
The statewise decomposition grain size for the paircalcs.
int orthoGrainSize
The statewise decomposition grain size for the ortho chares.
Dumb structure that holds all the configuration inputs required for paircalc instantiation, functioning and interaction.
Definition: pcConfig.h:23
bool isSymmetric
Is this paircalc array a symmetric or asymmetric instance.
int numPlanes
Number of planes that GSpace is decomposed into.
void init(const CkIndex2D orthoIdx, const pc::pcConfig &pcCfg, CkArrayID pcAID, CkGroupID oMCastGID, CkGroupID oRedGID)
An initializer method that fills this with data.
CkIndex2D orthoIndex
The index of the calling Ortho chare.
int msgPriority
The priority to use for messages to PC.
void setupArraySection(CkCallback cb, bool arePhantomsOn, bool useComlibForOrthoToPC)
Creates a paircalc array section given the necessary info. Replaces initOneRedSect() ...