Added a flag to control whether to notify the children elements that a reduction...
authorChao Mei <chaomei2@illinois.edu>
Wed, 16 Mar 2011 22:28:38 +0000 (17:28 -0500)
committerChao Mei <chaomei2@illinois.edu>
Wed, 16 Mar 2011 22:28:38 +0000 (17:28 -0500)
src/ck-core/ckarray.C
src/ck-core/ckarray.h
src/ck-core/ckreduction.C
src/ck-core/ckreduction.h
src/ck-core/init.C

index 1f5f6bfa9c59c9eec39bec4b42ec189f7fc74ec6..d08960b67b1686fa21441337f2fa3c0062bfe5bc 100644 (file)
@@ -61,6 +61,7 @@ Orion Sky Lawlor, olawlor@acm.org
 CpvDeclare(int ,serializer);
 
 bool _isAnytimeMigration;
+bool _isNotifyChildInRed;
 
 #define ARRAY_DEBUG_OUTPUT 0
 
@@ -454,6 +455,7 @@ void CkArrayOptions::init()
     anytimeMigration = _isAnytimeMigration;
     staticInsertion = false;
     reductionClient.type = CkCallback::invalid;
+    disableNotifyChildInRed = !_isNotifyChildInRed;
 }
 
 CkArrayOptions &CkArrayOptions::setStaticInsertion(bool b)
@@ -486,6 +488,7 @@ void CkArrayOptions::pup(PUP::er &p) {
        p|arrayListeners;
        p|reductionClient;
        p|anytimeMigration;
+       p|disableNotifyChildInRed;
        p|staticInsertion;
 }
 
@@ -621,7 +624,11 @@ CkArray::CkArray(CkArrayOptions &opts,
   if (!stableLocations)
       CcdCallOnConditionKeep(CcdPERIODIC_1minute,
                             staticSpringCleaning, (void *)this);
-
+  
+  //set the field in one my parent class (CkReductionMgr)
+  if(opts.disableNotifyChildInRed)
+         disableNotifyChildrenStart = CmiTrue; 
+  
   //Find, register, and initialize the arrayListeners
   listenerDataOffset=0;
   broadcaster=new CkArrayBroadcaster(stableLocations);
index a2139a11b27c5ca3ab67767f90a2dc217e8cc0dd..d835cd496062b81f85696750501cdd5b0bf3a9b5 100644 (file)
@@ -41,6 +41,12 @@ CpvExtern (int ,serializer);
  *  (in which case it can only happen between AtSync and ResumeFromSync). */
 extern bool _isAnytimeMigration;
 
+/** This flag is true when users are sure there is at least one charm array element
+ *  per processor. In such case, when doing reduction on the array, the children
+ *  don't need to be notified that reduction starts
+ */
+extern bool _isNotifyChildInRed;
+
 /**
 \addtogroup CkArray
 \brief Migratable Chare Arrays: user-visible classes.
@@ -295,6 +301,7 @@ class CkArrayOptions {
        CkPupAblePtrVec<CkArrayListener> arrayListeners; //CkArrayListeners for this array
        CkCallback reductionClient; // Default target of reductions
        bool anytimeMigration; // Elements are allowed to move freely
+       bool disableNotifyChildInRed; //Child elements are not notified when reduction starts
        bool staticInsertion; // Elements are only inserted at construction
 
        /// Set various safe defaults for all the constructors
index 6d9ed887bd848552490607713d8cbcc00883b840..a0dc85bef79f8d66c1dbef992ffa038d9e5399cd 100644 (file)
@@ -204,6 +204,7 @@ CkReductionMgr::CkReductionMgr()//Constructor
     totalCount = 0;
     processorCount = 0;
 #endif
+  disableNotifyChildrenStart = CmiFalse;
   DEBR((AA"In reductionMgr constructor at %d \n"AB,this));
 }
 
@@ -547,6 +548,8 @@ void CkReductionMgr::startReduction(int number,int srcPE)
        return;
   }
 
+  if(disableNotifyChildrenStart) return;
+  
 #if (defined(_FAULT_MLOG_) || defined(_FAULT_CAUSAL_)) 
   if(CmiMyPe() == 0 && redNo == 0){
             for(int j=0;j<CkNumPes();j++){
@@ -976,7 +979,7 @@ void CkReductionMgr::pup(PUP::er &p)
   p(redNo);
   p(completedRedNo);
   p(inProgress); p(creating); p(startRequested);
-  p(nContrib); p(nRemote);
+  p(nContrib); p(nRemote); p(disableNotifyChildrenStart);
   p|msgs;
   p|futureMsgs;
   p|futureRemoteMsgs;
@@ -1855,7 +1858,7 @@ void CkNodeReductionMgr::startReduction(int number,int srcNode)
        DEBR((AA"Starting Node reduction #%d on %p srcNode %d\n"AB,redNo,this,srcNode));
        inProgress=CmiTrue;
        //Sent start requests to our kids (in case they don't already know)
-
+       
        for (int k=0;k<treeKids();k++)
        {
 #ifdef BINOMIAL_TREE
index 646ac4a2acf69fa498200e320cab776b2011eb85..bd2a46de406e7b36e9e86aaff38247ed48f13455 100644 (file)
@@ -229,6 +229,10 @@ private:
        //Shift the list of countAdjustments down
        void shiftAdjVec(void);
 
+protected:
+       //whether to notify children that reduction starts
+       CmiBool disableNotifyChildrenStart;
+
 //Checkpointing utilities
 public:
 #if (defined(_FAULT_MLOG_) || defined(_FAULT_CAUSAL_))
index 9dcd6bd5164dd7f2d422b829dda7ddae96fe466f..26d46c14938d3c1fc1c97a479631744e06c7e6f9 100644 (file)
@@ -311,6 +311,11 @@ static inline void _parseCommandLineOpts(char **argv)
        if (CmiGetArgFlagDesc(argv,"+noAnytimeMigration","The program does not require support for anytime migration")) {
          _isAnytimeMigration = false;
        }
+       
+       _isNotifyChildInRed = true;
+       if (CmiGetArgFlagDesc(argv,"+noNotifyChildInReduction","The program has at least one element per processor for each charm array created")) {
+         _isNotifyChildInRed = false;
+       }
 
 
 #if ! CMK_WITH_CONTROLPOINT