2 #include "hello.decl.h"
4 /*readonly*/ CProxy_Main mainProxy;
5 /*readonly*/ int nElements;
8 class Main : public CBase_Main {
13 //Process command-line arguments
15 if (m->argc > 1) nElements = atoi(m->argv[1]);
18 //Start the computation
19 CkPrintf("Running Hello on %d processors for %d elements\n", CkNumPes(), nElements);
20 mainProxy = thisProxy;
22 CProxy_Hello arr = CProxy_Hello::ckNew(nElements);
23 char *msg = "Hello from Main";
24 arr[0].saySomething(strlen(msg) + 1, msg, -1);
28 CkPrintf("All done\n");
34 class Hello : public CBase_Hello {
36 // Declare the CkIndex_Hello class as a friend of this class so that the accelerated
37 // entry methods can access the member variables of this class
38 friend class CkIndex_Hello;
43 Hello(CkMigrateMessage *m) {}
46 void saySomething_callback() {
47 if (thisIndex < nElements - 1) {
49 int msgLen = sprintf(msgBuf, "Hello from %d", thisIndex) + 1;
50 thisProxy[thisIndex+1].saySomething(msgLen, msgBuf, thisIndex);
58 #include "hello.def.h"