Factor pageArray creation into CacheGroup's constructor
authorPhil Miller <mille121@illinois.edu>
Mon, 9 Feb 2009 18:22:51 +0000 (12:22 -0600)
committerPhil Miller <mille121@illinois.edu>
Thu, 10 Dec 2009 22:22:35 +0000 (16:22 -0600)
The MSA class never needs to know anything about the underlying page
array, so it shouldn't be responsible for creating it, passing it to
the CacheGroup, and telling it about the CacheGroup. Make the
CacheGroup do that instead.

src/libs/ck-libs/multiphaseSharedArrays/msa-DistPageMgr.ci
src/libs/ck-libs/multiphaseSharedArrays/msa-DistPageMgr.h
src/libs/ck-libs/multiphaseSharedArrays/msa-distArray.h

index 4a6353dbd29d3a3930c38b12a9cd5ce79c624e30..f1e464e5173fdd98a563a27fff64f6f76e05c8a8 100644 (file)
@@ -6,9 +6,11 @@ module msa
     // this is the per processor cache of pages.
     template<class ENTRY_TYPE, class ENTRY_OPS_CLASS,unsigned int ENTRIES_PER_PAGE> group MSA_CacheGroup
     {
-        entry MSA_CacheGroup(unsigned int nPages, CkArrayID pageArrayID,
-                         unsigned int max_bytes, unsigned int nEntries, unsigned int numberOfWorkerThreads);
-        entry void AckPage(unsigned int page);
+           entry MSA_CacheGroup(unsigned int nPages,
+                                                        unsigned int max_bytes,
+                                                        unsigned int nEntries,
+                                                        unsigned int numberOfWorkerThreads);
+           entry void AckPage(unsigned int page);
         entry void ReceivePage(unsigned int page, ENTRY_TYPE pageData[size], int size);
         entry void ReceivePageWithPUP(unsigned int page, MSA_PageT<ENTRY_TYPE, ENTRY_OPS_CLASS, ENTRIES_PER_PAGE> pageData, int size);
         entry void enroll(unsigned int numberOfWorkerThreads);
index 13a0fa2f312975360e4ec6623699380e5d070522..ba04a87a3ec614500270d6c220cbfb0b827443bf 100644 (file)
@@ -785,15 +785,16 @@ public:
     // 
     //
     // MSA_CacheGroup::
-       inline MSA_CacheGroup(unsigned int nPages_, CkArrayID pageArrayID,
-                                                 unsigned int max_bytes_, unsigned int nEntries_, 
+       inline MSA_CacheGroup(unsigned int nPages_,
+                                                 unsigned int max_bytes_,
+                                                 unsigned int nEntries_,
                                                  unsigned int numberOfWorkerThreads_)
                : numberOfWorkerThreads(numberOfWorkerThreads_),
                  nPages(nPages_),
                  nEntries(nEntries_), 
                  pageTable(nPages, NULL),
                  pageStateStorage(nPages, NULL),
-                 pageArray(pageArrayID),
+                 pageArray(CProxy_PageArray_t::ckNew(nPages_)),
                  thisProxy(thisgroup),
                  max_resident_pages(max_bytes_/(sizeof(ENTRY_TYPE)*ENTRIES_PER_PAGE)),
                  entryOpsObject(new ENTRY_OPS_CLASS),
@@ -801,6 +802,9 @@ public:
                  outOfBufferInPrefetch(0), syncAckCount(0),syncThreadCount(0),
                  resident_pages(0),numberLocalWorkerThreads(0), enrollDoneq(0)
                {
+                       pageArray.setCacheProxy(thisProxy);
+                       pageArray.ckSetReductionClient(new CkCallback(CkIndex_MSA_CacheGroup<ENTRY_TYPE, ENTRY_OPS_CLASS, ENTRIES_PER_PAGE>::SyncDone(), thisProxy));
+
                        MSADEBPRINT(printf("MSA_CacheGroup nEntries %d \n",nEntries););
                }
 
index 2e1a1bd60c9ab9069f757aaa1d55ade863fe293d..e052c7d14cb92d9dd519714bf7ccf2473ab55074 100644 (file)
@@ -128,6 +128,15 @@ public:
             Handle::checkValid();
             Handle::msa.accumulate(idx, ent);
         }
+
+        void contribute(unsigned int idx, const ENTRY *begin, const ENTRY *end)
+        {
+            Handle::checkValid();
+            for (const ENTRY *e = begin; e != end; ++e, ++idx)
+                {
+                    Handle::msa.accumulate(idx, *e);
+                }
+        }
     };
 
 protected:
@@ -177,12 +186,8 @@ public:
                  unsigned int maxBytes=MSA_DEFAULT_MAX_BYTES) 
         : nEntries(nEntries_), initHandleGiven(false)
     {
-        // first create the Page Array and the Page Group
         unsigned int nPages = (nEntries + ENTRIES_PER_PAGE - 1)/ENTRIES_PER_PAGE;
-        CProxy_PageArray_t pageArray = CProxy_PageArray_t::ckNew(nPages);
-        cg = CProxy_CacheGroup_t::ckNew(nPages, pageArray, maxBytes, nEntries, num_wrkrs);
-        pageArray.setCacheProxy(cg);
-        pageArray.ckSetReductionClient(new CkCallback(CkIndex_MSA_CacheGroup<ENTRY, ENTRY_OPS_CLASS, ENTRIES_PER_PAGE>::SyncDone(), cg));
+        cg = CProxy_CacheGroup_t::ckNew(nPages, maxBytes, nEntries, num_wrkrs);
         cache = cg.ckLocalBranch();
     }