First page Back Continue Last page Graphics
Main::Main(CkArgMsg *m) {
Main::Main(CkArgMsg *m) {
///// CODE REMOVED TO SAVE ROOM : Read Command Line Parameters /////
///// Setup the Quiescence Detection /////
CkCallback callback(CkIndex_Main::quiescenseHandler(), thishandle);
CkStartQD(callback);
///// Start the Computation /////
// Print out a message to let the user know the computation is about to start
CkPrintf("Running Bubble on %d processors for %d elements...\n", CkNumPes(), nElements);
// Set mainProxy to the proxy for this chare
mainProxy = thishandle;
// Create the array of chares (each element being a number in the array)
arr = CProxy_Bubble::ckNew(nElements);
// Tell each element in the array to check its neighboors
for (int i = 1; i < nElements; i+=2) {
if (i > 0) arr[i].initSwapSequenceWith(i - 1);
if (i < nElements - 1) arr[i].initSwapSequenceWith(i + 1);
}
}
void Main::quiescenseHandler() {
// After all the activity has stopped, start the final sequence of printing the array
// and exiting the program
arr[0].displayValue();
}
void Main::done(void) {
CkPrintf("All Done\n");
CkExit();
}