A sample X10 like library/application.
authorIsaac Dooley <idooley2@illinois.edu>
Fri, 21 Apr 2006 19:08:41 +0000 (19:08 +0000)
committerIsaac Dooley <idooley2@illinois.edu>
Fri, 21 Apr 2006 19:08:41 +0000 (19:08 +0000)
examples/charm++/X10/Makefile [new file with mode: 0644]
examples/charm++/X10/X10_test.decl.h [new file with mode: 0644]
examples/charm++/X10/X10_test.def.h [new file with mode: 0644]
examples/charm++/X10/X10_test2.C [new file with mode: 0644]
examples/charm++/X10/X10_test2.ci [new file with mode: 0644]
examples/charm++/X10/X10_test2.o [new file with mode: 0644]

diff --git a/examples/charm++/X10/Makefile b/examples/charm++/X10/Makefile
new file mode 100644 (file)
index 0000000..9611951
--- /dev/null
@@ -0,0 +1,16 @@
+CHARMC=$(HOME)/src/charm/bin/charmc -g
+
+all : X10_test2
+
+X10_test.decl.h : X10_test2.ci
+       $(CHARMC) X10_test2.ci
+
+X10_test2.o : X10_test2.C X10_test.decl.h
+       $(CHARMC) -c X10_test2.C
+
+X10_test2 : X10_test2.o
+       $(CHARMC) -language charm++ -o X10_test2 X10_test2.o 
+
+
+clean : 
+       rm -f a.out *~  X10_test2 charmrun
diff --git a/examples/charm++/X10/X10_test.decl.h b/examples/charm++/X10/X10_test.decl.h
new file mode 100644 (file)
index 0000000..1503480
--- /dev/null
@@ -0,0 +1,300 @@
+#ifndef _DECL_X10_test_H_
+#define _DECL_X10_test_H_
+#include "charm++.h"
+/* DECLS: message asyncMsg;
+ */
+class asyncMsg;
+class CMessage_asyncMsg:public CkMessage{
+  public:
+    static int __idx;
+    void* operator new(size_t, void*p) { return p; }
+    void* operator new(size_t);
+    void* operator new(size_t, int*, const int);
+    void* operator new(size_t, int*);
+#if CMK_MULTIPLE_DELETE
+    void operator delete(void*p, void*){CkFreeMsg(p);}
+    void operator delete(void*p){ CkFreeMsg(p);}
+    void operator delete(void*p, int*, const int){CkFreeMsg(p);}
+    void operator delete(void*p, int*){CkFreeMsg(p);}
+#endif
+    void operator delete(void*p, size_t){CkFreeMsg(p);}
+    static void* alloc(int,size_t, int*, int);
+    CMessage_asyncMsg() {};
+    static void *pack(asyncMsg *p);
+    static asyncMsg* unpack(void* p);
+    void *operator new(size_t, const int);
+#if CMK_MULTIPLE_DELETE
+    void operator delete(void *p, const int){CkFreeMsg(p);}
+#endif
+    static void __register(const char *s, size_t size, CkPackFnPtr pack, CkUnpackFnPtr unpack) {
+      __idx = CkRegisterMsg(s, pack, unpack, size);
+    }
+};
+
+/* DECLS: readonly CProxy_Main mainProxy;
+ */
+
+/* DECLS: readonly int nPlaces;
+ */
+
+/* DECLS: readonly CProxy_Places placesProxy;
+ */
+
+/* DECLS: mainchare Main: Chare{
+Main(CkArgMsg* impl_msg);
+threaded void libThread(void);
+};
+ */
+ class Main;
+ class CkIndex_Main;
+ class CProxy_Main;
+/* --------------- index object ------------------ */
+class CkIndex_Main:public CProxy_Chare{
+  public:
+    typedef Main local_t;
+    typedef CkIndex_Main index_t;
+    typedef CProxy_Main proxy_t;
+    typedef CProxy_Main element_t;
+
+    static int __idx;
+    static void __register(const char *s, size_t size);
+/* DECLS: Main(CkArgMsg* impl_msg);
+ */
+    static int __idx_Main_CkArgMsg;
+    static int ckNew(CkArgMsg* impl_msg) { return __idx_Main_CkArgMsg; }
+    static void _call_Main_CkArgMsg(void* impl_msg,Main* impl_obj);
+
+/* DECLS: threaded void libThread(void);
+ */
+    static int __idx_libThread_void;
+    static int libThread(void) { return __idx_libThread_void; }
+    static void _call_libThread_void(void* impl_msg,Main* impl_obj);
+    static void _callthr_libThread_void(CkThrCallArg *);
+};
+/* --------------- element proxy ------------------ */
+class CProxy_Main:public CProxy_Chare{
+  public:
+    typedef Main local_t;
+    typedef CkIndex_Main index_t;
+    typedef CProxy_Main proxy_t;
+    typedef CProxy_Main element_t;
+
+    CProxy_Main(void) {};
+    CProxy_Main(CkChareID __cid) : CProxy_Chare(__cid){  }
+    CProxy_Main(const Chare *c) : CProxy_Chare(c){  }
+    CK_DISAMBIG_CHARE(CProxy_Chare)
+    void ckDelegate(CkDelegateMgr *dTo,CkDelegateData *dPtr=NULL) {
+      CProxy_Chare::ckDelegate(dTo,dPtr);
+    }
+    void ckUndelegate(void) {
+      CProxy_Chare::ckUndelegate();
+    }
+    void pup(PUP::er &p) {
+      CProxy_Chare::pup(p);
+    }
+    void ckSetChareID(const CkChareID &c) {
+      CProxy_Chare::ckSetChareID(c);
+    }
+    Main *ckLocal(void) const
+     { return (Main *)CkLocalChare(&ckGetChareID()); }
+/* DECLS: Main(CkArgMsg* impl_msg);
+ */
+    static CkChareID ckNew(CkArgMsg* impl_msg, int onPE=CK_PE_ANY);
+    static void ckNew(CkArgMsg* impl_msg, CkChareID* pcid, int onPE=CK_PE_ANY);
+    CProxy_Main(CkArgMsg* impl_msg, int onPE=CK_PE_ANY);
+
+/* DECLS: threaded void libThread(void);
+ */
+    void libThread(void);
+};
+PUPmarshall(CProxy_Main);
+typedef CBaseT<Chare,CProxy_Main>  CBase_Main;
+
+/* DECLS: array Places: ArrayElement{
+Places(CkMigrateMessage* impl_msg);
+void Places(void);
+threaded void startAsync(int which_statement, const CkFutureID &ftHandle, int pe_src);
+};
+ */
+ class Places;
+ class CkIndex_Places;
+ class CProxy_Places;
+ class CProxyElement_Places;
+ class CProxySection_Places;
+/* --------------- index object ------------------ */
+class CkIndex_Places:public CProxyElement_ArrayElement{
+  public:
+    typedef Places local_t;
+    typedef CkIndex_Places index_t;
+    typedef CProxy_Places proxy_t;
+    typedef CProxyElement_Places element_t;
+    typedef CProxySection_Places section_t;
+
+    static int __idx;
+    static void __register(const char *s, size_t size);
+/* DECLS: Places(CkMigrateMessage* impl_msg);
+ */
+    static int __idx_Places_CkMigrateMessage;
+    static int ckNew(CkMigrateMessage* impl_msg) { return __idx_Places_CkMigrateMessage; }
+    static void _call_Places_CkMigrateMessage(void* impl_msg,Places* impl_obj);
+
+/* DECLS: void Places(void);
+ */
+    static int __idx_Places_void;
+    static int ckNew(void) { return __idx_Places_void; }
+    static void _call_Places_void(void* impl_msg,Places* impl_obj);
+
+/* DECLS: threaded void startAsync(int which_statement, const CkFutureID &ftHandle, int pe_src);
+ */
+    static int __idx_startAsync_marshall2;
+    static int startAsync(int which_statement, const CkFutureID &ftHandle, int pe_src) { return __idx_startAsync_marshall2; }
+    static void _call_startAsync_marshall2(void* impl_msg,Places* impl_obj);
+    static void _callthr_startAsync_marshall2(CkThrCallArg *);
+    static void _marshallmessagepup_startAsync_marshall2(PUP::er &p,void *msg);
+};
+/* --------------- element proxy ------------------ */
+ class CProxyElement_Places : public CProxyElement_ArrayElement{
+  public:
+    typedef Places local_t;
+    typedef CkIndex_Places index_t;
+    typedef CProxy_Places proxy_t;
+    typedef CProxyElement_Places element_t;
+    typedef CProxySection_Places section_t;
+
+    CProxyElement_Places(void) {}
+    CProxyElement_Places(const ArrayElement *e) : CProxyElement_ArrayElement(e){  }
+    void ckDelegate(CkDelegateMgr *dTo,CkDelegateData *dPtr=NULL) {
+      CProxyElement_ArrayElement::ckDelegate(dTo,dPtr);
+    }
+    void ckUndelegate(void) {
+      CProxyElement_ArrayElement::ckUndelegate();
+    }
+    void pup(PUP::er &p) {
+      CProxyElement_ArrayElement::pup(p);
+    }
+    CK_DISAMBIG_ARRAY_ELEMENT(CProxyElement_ArrayElement)
+    Places *ckLocal(void) const
+      { return (Places *)CProxyElement_ArrayElement::ckLocal(); }
+    CProxyElement_Places(const CkArrayID &aid,const CkArrayIndex1D &idx,CK_DELCTOR_PARAM)
+        :CProxyElement_ArrayElement(aid,idx,CK_DELCTOR_ARGS) {}
+    CProxyElement_Places(const CkArrayID &aid,const CkArrayIndex1D &idx)
+        :CProxyElement_ArrayElement(aid,idx) {}
+/* DECLS: Places(CkMigrateMessage* impl_msg);
+ */
+
+/* DECLS: void Places(void);
+ */
+    void insert(int onPE=-1);
+/* DECLS: threaded void startAsync(int which_statement, const CkFutureID &ftHandle, int pe_src);
+ */
+    void startAsync(int which_statement, const CkFutureID &ftHandle, int pe_src, const CkEntryOptions *impl_e_opts=NULL) ;
+};
+PUPmarshall(CProxyElement_Places);
+/* ---------------- collective proxy -------------- */
+ class CProxy_Places : public CProxy_ArrayElement{
+  public:
+    typedef Places local_t;
+    typedef CkIndex_Places index_t;
+    typedef CProxy_Places proxy_t;
+    typedef CProxyElement_Places element_t;
+    typedef CProxySection_Places section_t;
+
+    CProxy_Places(void) {}
+    CProxy_Places(const ArrayElement *e) : CProxy_ArrayElement(e){  }
+    void ckDelegate(CkDelegateMgr *dTo,CkDelegateData *dPtr=NULL) {
+      CProxy_ArrayElement::ckDelegate(dTo,dPtr);
+    }
+    void ckUndelegate(void) {
+      CProxy_ArrayElement::ckUndelegate();
+    }
+    void pup(PUP::er &p) {
+      CProxy_ArrayElement::pup(p);
+    }
+    CK_DISAMBIG_ARRAY(CProxy_ArrayElement)
+    static CkArrayID ckNew(void) {return ckCreateEmptyArray();}
+//Generalized array indexing:
+    CProxyElement_Places operator [] (const CkArrayIndex1D &idx) const
+        {return CProxyElement_Places(ckGetArrayID(), idx, CK_DELCTOR_CALL);}
+    CProxyElement_Places operator() (const CkArrayIndex1D &idx) const
+        {return CProxyElement_Places(ckGetArrayID(), idx, CK_DELCTOR_CALL);}
+    CProxyElement_Places operator [] (int idx) const 
+        {return CProxyElement_Places(ckGetArrayID(), CkArrayIndex1D(idx), CK_DELCTOR_CALL);}
+    CProxyElement_Places operator () (int idx) const 
+        {return CProxyElement_Places(ckGetArrayID(), CkArrayIndex1D(idx), CK_DELCTOR_CALL);}
+    CProxy_Places(const CkArrayID &aid,CK_DELCTOR_PARAM) 
+        :CProxy_ArrayElement(aid,CK_DELCTOR_ARGS) {}
+    CProxy_Places(const CkArrayID &aid) 
+        :CProxy_ArrayElement(aid) {}
+/* DECLS: Places(CkMigrateMessage* impl_msg);
+ */
+
+/* DECLS: void Places(void);
+ */
+    static CkArrayID ckNew(const CkArrayOptions &opts);
+
+/* DECLS: threaded void startAsync(int which_statement, const CkFutureID &ftHandle, int pe_src);
+ */
+    void startAsync(int which_statement, const CkFutureID &ftHandle, int pe_src, const CkEntryOptions *impl_e_opts=NULL) ;
+};
+PUPmarshall(CProxy_Places);
+/* ---------------- section proxy -------------- */
+ class CProxySection_Places : public CProxySection_ArrayElement{
+  public:
+    typedef Places local_t;
+    typedef CkIndex_Places index_t;
+    typedef CProxy_Places proxy_t;
+    typedef CProxyElement_Places element_t;
+    typedef CProxySection_Places section_t;
+
+    CProxySection_Places(void) {}
+    void ckDelegate(CkDelegateMgr *dTo,CkDelegateData *dPtr=NULL) {
+      CProxySection_ArrayElement::ckDelegate(dTo,dPtr);
+    }
+    void ckUndelegate(void) {
+      CProxySection_ArrayElement::ckUndelegate();
+    }
+    void pup(PUP::er &p) {
+      CProxySection_ArrayElement::pup(p);
+    }
+    CK_DISAMBIG_ARRAY_SECTION(CProxySection_ArrayElement)
+//Generalized array indexing:
+    CProxyElement_Places operator [] (const CkArrayIndex1D &idx) const
+        {return CProxyElement_Places(ckGetArrayID(), idx, CK_DELCTOR_CALL);}
+    CProxyElement_Places operator() (const CkArrayIndex1D &idx) const
+        {return CProxyElement_Places(ckGetArrayID(), idx, CK_DELCTOR_CALL);}
+    CProxyElement_Places operator [] (int idx) const 
+        {return CProxyElement_Places(ckGetArrayID(), *(CkArrayIndex1D*)&ckGetArrayElements()[idx], CK_DELCTOR_CALL);}
+    CProxyElement_Places operator () (int idx) const 
+        {return CProxyElement_Places(ckGetArrayID(), *(CkArrayIndex1D*)&ckGetArrayElements()[idx], CK_DELCTOR_CALL);}
+    static CkSectionID ckNew(const CkArrayID &aid, CkArrayIndex1D *elems, int nElems) {
+      return CkSectionID(aid, elems, nElems);
+    } 
+    static CkSectionID ckNew(const CkArrayID &aid, int l, int u, int s) {
+      CkVec<CkArrayIndex1D> al;
+      for (int i=l; i<=u; i+=s) al.push_back(CkArrayIndex1D(i));
+      return CkSectionID(aid, al.getVec(), al.size());
+    } 
+    CProxySection_Places(const CkArrayID &aid, CkArrayIndexMax *elems, int nElems, CK_DELCTOR_PARAM) 
+        :CProxySection_ArrayElement(aid,elems,nElems,CK_DELCTOR_ARGS) {}
+    CProxySection_Places(const CkArrayID &aid, CkArrayIndexMax *elems, int nElems) 
+        :CProxySection_ArrayElement(aid,elems,nElems) {}
+    CProxySection_Places(const CkSectionID &sid)       :CProxySection_ArrayElement(sid) {}
+    static CkSectionID ckNew(const CkArrayID &aid, CkArrayIndexMax *elems, int nElems) {
+      return CkSectionID(aid, elems, nElems);
+    } 
+/* DECLS: Places(CkMigrateMessage* impl_msg);
+ */
+
+/* DECLS: void Places(void);
+ */
+
+/* DECLS: threaded void startAsync(int which_statement, const CkFutureID &ftHandle, int pe_src);
+ */
+    void startAsync(int which_statement, const CkFutureID &ftHandle, int pe_src, const CkEntryOptions *impl_e_opts=NULL) ;
+};
+PUPmarshall(CProxySection_Places);
+typedef CBaseT<ArrayElementT<CkIndex1D>,CProxy_Places>  CBase_Places;
+
+extern void _registerX10_test(void);
+extern "C" void CkRegisterMainModule(void);
+#endif
diff --git a/examples/charm++/X10/X10_test.def.h b/examples/charm++/X10/X10_test.def.h
new file mode 100644 (file)
index 0000000..6994502
--- /dev/null
@@ -0,0 +1,362 @@
+/* DEFS: message asyncMsg;
+ */
+#ifndef CK_TEMPLATES_ONLY
+void *CMessage_asyncMsg::operator new(size_t s){
+  return asyncMsg::alloc(__idx, s, 0, 0);
+}
+void *CMessage_asyncMsg::operator new(size_t s, int* sz){
+  return asyncMsg::alloc(__idx, s, sz, 0);
+}
+void *CMessage_asyncMsg::operator new(size_t s, int* sz,const int pb){
+  return asyncMsg::alloc(__idx, s, sz, pb);
+}
+void *CMessage_asyncMsg::operator new(size_t s, const int p) {
+  return asyncMsg::alloc(__idx, s, 0, p);
+}
+void* CMessage_asyncMsg::alloc(int msgnum, size_t sz, int *sizes, int pb) {
+  int offsets[1];
+  offsets[0] = ALIGN8(sz);
+  asyncMsg *newmsg = (asyncMsg *) CkAllocMsg(msgnum, offsets[0], pb);
+  return (void *) newmsg;
+}
+void* CMessage_asyncMsg::pack(asyncMsg *msg) {
+  return (void *) msg;
+}
+asyncMsg* CMessage_asyncMsg::unpack(void* buf) {
+  asyncMsg *msg = (asyncMsg *) buf;
+  return msg;
+}
+int CMessage_asyncMsg::__idx=0;
+#endif
+
+/* DEFS: readonly CProxy_Main mainProxy;
+ */
+extern CProxy_Main mainProxy;
+#ifndef CK_TEMPLATES_ONLY
+extern "C" void __xlater_roPup_mainProxy(void *_impl_pup_er) {
+  PUP::er &_impl_p=*(PUP::er *)_impl_pup_er;
+  _impl_p|mainProxy;
+}
+#endif
+
+/* DEFS: readonly int nPlaces;
+ */
+extern int nPlaces;
+#ifndef CK_TEMPLATES_ONLY
+extern "C" void __xlater_roPup_nPlaces(void *_impl_pup_er) {
+  PUP::er &_impl_p=*(PUP::er *)_impl_pup_er;
+  _impl_p|nPlaces;
+}
+#endif
+
+/* DEFS: readonly CProxy_Places placesProxy;
+ */
+extern CProxy_Places placesProxy;
+#ifndef CK_TEMPLATES_ONLY
+extern "C" void __xlater_roPup_placesProxy(void *_impl_pup_er) {
+  PUP::er &_impl_p=*(PUP::er *)_impl_pup_er;
+  _impl_p|placesProxy;
+}
+#endif
+
+/* DEFS: mainchare Main: Chare{
+Main(CkArgMsg* impl_msg);
+threaded void libThread(void);
+};
+ */
+#ifndef CK_TEMPLATES_ONLY
+ int CkIndex_Main::__idx=0;
+#endif
+#ifndef CK_TEMPLATES_ONLY
+/* DEFS: Main(CkArgMsg* impl_msg);
+ */
+CkChareID CProxy_Main::ckNew(CkArgMsg* impl_msg, int impl_onPE)
+{
+  CkChareID impl_ret;
+  CkCreateChare(CkIndex_Main::__idx, CkIndex_Main::__idx_Main_CkArgMsg, impl_msg, &impl_ret, impl_onPE);
+  return impl_ret;
+}
+void CProxy_Main::ckNew(CkArgMsg* impl_msg, CkChareID* pcid, int impl_onPE)
+{
+  CkCreateChare(CkIndex_Main::__idx, CkIndex_Main::__idx_Main_CkArgMsg, impl_msg, pcid, impl_onPE);
+}
+  CProxy_Main::CProxy_Main(CkArgMsg* impl_msg, int impl_onPE)
+{
+  CkChareID impl_ret;
+  CkCreateChare(CkIndex_Main::__idx, CkIndex_Main::__idx_Main_CkArgMsg, impl_msg, &impl_ret, impl_onPE);
+  ckSetChareID(impl_ret);
+}
+ int CkIndex_Main::__idx_Main_CkArgMsg=0;
+void CkIndex_Main::_call_Main_CkArgMsg(void* impl_msg,Main * impl_obj)
+{
+  new (impl_obj) Main((CkArgMsg*)impl_msg);
+}
+
+/* DEFS: threaded void libThread(void);
+ */
+void CProxy_Main::libThread(void)
+{
+  ckCheck();
+  void *impl_msg = CkAllocSysMsg();
+  if (ckIsDelegated()) {
+    int destPE=CkChareMsgPrep(CkIndex_Main::__idx_libThread_void, impl_msg, &ckGetChareID());
+    if (destPE!=-1) ckDelegatedTo()->ChareSend(ckDelegatedPtr(),CkIndex_Main::__idx_libThread_void, impl_msg, &ckGetChareID(),destPE);
+  }
+  else CkSendMsg(CkIndex_Main::__idx_libThread_void, impl_msg, &ckGetChareID(),0);
+}
+ int CkIndex_Main::__idx_libThread_void=0;
+void CkIndex_Main::_call_libThread_void(void* impl_msg,Main * impl_obj)
+{
+  CthThread tid = CthCreate((CthVoidFn)_callthr_libThread_void, new CkThrCallArg(impl_msg,impl_obj), 0);
+  ((Chare *)impl_obj)->CkAddThreadListeners(tid,impl_msg);
+  CthAwaken(tid);
+}
+void CkIndex_Main::_callthr_libThread_void(CkThrCallArg *impl_arg)
+{
+  void *impl_msg = impl_arg->msg;
+  Main *impl_obj = (Main *) impl_arg->obj;
+  delete impl_arg;
+  CkFreeSysMsg(impl_msg);
+  impl_obj->libThread();
+}
+#endif /*CK_TEMPLATES_ONLY*/
+#ifndef CK_TEMPLATES_ONLY
+void CkIndex_Main::__register(const char *s, size_t size) {
+  __idx = CkRegisterChare(s, size);
+  CkRegisterBase(__idx, CkIndex_Chare::__idx);
+// REG: Main(CkArgMsg* impl_msg);
+  __idx_Main_CkArgMsg = CkRegisterEp("Main(CkArgMsg* impl_msg)",
+     (CkCallFnPtr)_call_Main_CkArgMsg, CMessage_CkArgMsg::__idx, __idx, 0);
+  CkRegisterMainChare(__idx, __idx_Main_CkArgMsg);
+
+// REG: threaded void libThread(void);
+  __idx_libThread_void = CkRegisterEp("libThread(void)",
+     (CkCallFnPtr)_call_libThread_void, 0, __idx, 0);
+}
+#endif
+
+/* DEFS: array Places: ArrayElement{
+Places(CkMigrateMessage* impl_msg);
+void Places(void);
+threaded void startAsync(int which_statement, const CkFutureID &ftHandle, int pe_src);
+};
+ */
+#ifndef CK_TEMPLATES_ONLY
+ int CkIndex_Places::__idx=0;
+#endif
+#ifndef CK_TEMPLATES_ONLY
+/* DEFS: Places(CkMigrateMessage* impl_msg);
+ */
+
+/* DEFS: void Places(void);
+ */
+void CProxyElement_Places::insert(int onPE)
+{ 
+  void *impl_msg = CkAllocSysMsg();
+   ckInsert((CkArrayMessage *)impl_msg,CkIndex_Places::__idx_Places_void,onPE);
+}
+
+/* DEFS: threaded void startAsync(int which_statement, const CkFutureID &ftHandle, int pe_src);
+ */
+void CProxyElement_Places::startAsync(int which_statement, const CkFutureID &ftHandle, int pe_src, const CkEntryOptions *impl_e_opts) 
+{
+  ckCheck();
+  //Marshall: int which_statement, const CkFutureID &ftHandle, int pe_src
+  int impl_off=0;
+  { //Find the size of the PUP'd data
+    PUP::sizer implP;
+    implP|which_statement;
+    //Have to cast away const-ness to get pup routine
+    implP|(CkFutureID &)ftHandle;
+    implP|pe_src;
+    impl_off+=implP.size();
+  }
+  CkMarshallMsg *impl_msg=CkAllocateMarshallMsg(impl_off,impl_e_opts);
+  { //Copy over the PUP'd data
+    PUP::toMem implP((void *)impl_msg->msgBuf);
+    implP|which_statement;
+    //Have to cast away const-ness to get pup routine
+    implP|(CkFutureID &)ftHandle;
+    implP|pe_src;
+  }
+  CkArrayMessage *impl_amsg=(CkArrayMessage *)impl_msg;
+  impl_amsg->array_setIfNotThere(CkArray_IfNotThere_buffer);
+  ckSend(impl_amsg, CkIndex_Places::__idx_startAsync_marshall2,0);
+}
+/* DEFS: Places(CkMigrateMessage* impl_msg);
+ */
+ int CkIndex_Places::__idx_Places_CkMigrateMessage=0;
+void CkIndex_Places::_call_Places_CkMigrateMessage(void* impl_msg,Places * impl_obj)
+{
+  new (impl_obj) Places((CkMigrateMessage*)impl_msg);
+}
+
+/* DEFS: void Places(void);
+ */
+CkArrayID CProxy_Places::ckNew(const CkArrayOptions &opts)
+{ 
+  void *impl_msg = CkAllocSysMsg();
+   return ckCreateArray((CkArrayMessage *)impl_msg,CkIndex_Places::__idx_Places_void,opts);
+}
+ int CkIndex_Places::__idx_Places_void=0;
+void CkIndex_Places::_call_Places_void(void* impl_msg,Places * impl_obj)
+{
+  CkFreeSysMsg(impl_msg);
+  new (impl_obj) Places();
+}
+
+/* DEFS: threaded void startAsync(int which_statement, const CkFutureID &ftHandle, int pe_src);
+ */
+void CProxy_Places::startAsync(int which_statement, const CkFutureID &ftHandle, int pe_src, const CkEntryOptions *impl_e_opts) 
+{
+  ckCheck();
+  //Marshall: int which_statement, const CkFutureID &ftHandle, int pe_src
+  int impl_off=0;
+  { //Find the size of the PUP'd data
+    PUP::sizer implP;
+    implP|which_statement;
+    //Have to cast away const-ness to get pup routine
+    implP|(CkFutureID &)ftHandle;
+    implP|pe_src;
+    impl_off+=implP.size();
+  }
+  CkMarshallMsg *impl_msg=CkAllocateMarshallMsg(impl_off,impl_e_opts);
+  { //Copy over the PUP'd data
+    PUP::toMem implP((void *)impl_msg->msgBuf);
+    implP|which_statement;
+    //Have to cast away const-ness to get pup routine
+    implP|(CkFutureID &)ftHandle;
+    implP|pe_src;
+  }
+  CkArrayMessage *impl_amsg=(CkArrayMessage *)impl_msg;
+  impl_amsg->array_setIfNotThere(CkArray_IfNotThere_buffer);
+  ckBroadcast(impl_amsg, CkIndex_Places::__idx_startAsync_marshall2,0);
+}
+ int CkIndex_Places::__idx_startAsync_marshall2=0;
+void CkIndex_Places::_call_startAsync_marshall2(void* impl_msg,Places * impl_obj)
+{
+  CthThread tid = CthCreate((CthVoidFn)_callthr_startAsync_marshall2, new CkThrCallArg(impl_msg,impl_obj), 0);
+  ((Chare *)impl_obj)->CkAddThreadListeners(tid,impl_msg);
+  CthAwaken(tid);
+}
+void CkIndex_Places::_callthr_startAsync_marshall2(CkThrCallArg *impl_arg)
+{
+  void *impl_msg = impl_arg->msg;
+  Places *impl_obj = (Places *) impl_arg->obj;
+  delete impl_arg;
+  char *impl_buf=((CkMarshallMsg *)impl_msg)->msgBuf;
+  /*Unmarshall pup'd fields: int which_statement, const CkFutureID &ftHandle, int pe_src*/
+  PUP::fromMem implP(impl_buf);
+  int which_statement; implP|which_statement;
+  CkFutureID ftHandle; implP|ftHandle;
+  int pe_src; implP|pe_src;
+  impl_buf+=CK_ALIGN(implP.size(),16);
+  /*Unmarshall arrays:*/
+  impl_obj->startAsync(which_statement, ftHandle, pe_src);
+  delete (CkMarshallMsg *)impl_msg;
+}
+void CkIndex_Places::_marshallmessagepup_startAsync_marshall2(PUP::er &implDestP,void *impl_msg) {
+  char *impl_buf=((CkMarshallMsg *)impl_msg)->msgBuf;
+  /*Unmarshall pup'd fields: int which_statement, const CkFutureID &ftHandle, int pe_src*/
+  PUP::fromMem implP(impl_buf);
+  int which_statement; implP|which_statement;
+  CkFutureID ftHandle; implP|ftHandle;
+  int pe_src; implP|pe_src;
+  impl_buf+=CK_ALIGN(implP.size(),16);
+  /*Unmarshall arrays:*/
+  if (implDestP.hasComments()) implDestP.comment("which_statement");
+  implDestP|which_statement;
+  if (implDestP.hasComments()) implDestP.comment("ftHandle");
+  implDestP|ftHandle;
+  if (implDestP.hasComments()) implDestP.comment("pe_src");
+  implDestP|pe_src;
+}
+/* DEFS: Places(CkMigrateMessage* impl_msg);
+ */
+
+/* DEFS: void Places(void);
+ */
+
+/* DEFS: threaded void startAsync(int which_statement, const CkFutureID &ftHandle, int pe_src);
+ */
+void CProxySection_Places::startAsync(int which_statement, const CkFutureID &ftHandle, int pe_src, const CkEntryOptions *impl_e_opts) 
+{
+  ckCheck();
+  //Marshall: int which_statement, const CkFutureID &ftHandle, int pe_src
+  int impl_off=0;
+  { //Find the size of the PUP'd data
+    PUP::sizer implP;
+    implP|which_statement;
+    //Have to cast away const-ness to get pup routine
+    implP|(CkFutureID &)ftHandle;
+    implP|pe_src;
+    impl_off+=implP.size();
+  }
+  CkMarshallMsg *impl_msg=CkAllocateMarshallMsg(impl_off,impl_e_opts);
+  { //Copy over the PUP'd data
+    PUP::toMem implP((void *)impl_msg->msgBuf);
+    implP|which_statement;
+    //Have to cast away const-ness to get pup routine
+    implP|(CkFutureID &)ftHandle;
+    implP|pe_src;
+  }
+  CkArrayMessage *impl_amsg=(CkArrayMessage *)impl_msg;
+  impl_amsg->array_setIfNotThere(CkArray_IfNotThere_buffer);
+  ckSend(impl_amsg, CkIndex_Places::__idx_startAsync_marshall2,0);
+}
+#endif /*CK_TEMPLATES_ONLY*/
+#ifndef CK_TEMPLATES_ONLY
+void CkIndex_Places::__register(const char *s, size_t size) {
+  __idx = CkRegisterChare(s, size);
+  CkRegisterBase(__idx, CkIndex_ArrayElement::__idx);
+// REG: Places(CkMigrateMessage* impl_msg);
+  __idx_Places_CkMigrateMessage = CkRegisterEp("Places(CkMigrateMessage* impl_msg)",
+     (CkCallFnPtr)_call_Places_CkMigrateMessage, 0, __idx, 0);
+  CkRegisterMigCtor(__idx, __idx_Places_CkMigrateMessage);
+
+// REG: void Places(void);
+  __idx_Places_void = CkRegisterEp("Places(void)",
+     (CkCallFnPtr)_call_Places_void, 0, __idx, 0);
+  CkRegisterDefaultCtor(__idx, __idx_Places_void);
+
+// REG: threaded void startAsync(int which_statement, const CkFutureID &ftHandle, int pe_src);
+  __idx_startAsync_marshall2 = CkRegisterEp("startAsync(int which_statement, const CkFutureID &ftHandle, int pe_src)",
+     (CkCallFnPtr)_call_startAsync_marshall2, CkMarshallMsg::__idx, __idx, 0);
+  CkRegisterMessagePupFn(__idx_startAsync_marshall2,(CkMessagePupFn)_marshallmessagepup_startAsync_marshall2);
+}
+#endif
+
+#ifndef CK_TEMPLATES_ONLY
+void _registerX10_test(void)
+{
+  static int _done = 0; if(_done) return; _done = 1;
+/* REG: message asyncMsg;
+*/
+CMessage_asyncMsg::__register("asyncMsg", sizeof(asyncMsg),(CkPackFnPtr) asyncMsg::pack,(CkUnpackFnPtr) asyncMsg::unpack);
+
+  CkRegisterReadonly("mainProxy","CProxy_Main",sizeof(mainProxy),(void *) &mainProxy,__xlater_roPup_mainProxy);
+
+  CkRegisterReadonly("nPlaces","int",sizeof(nPlaces),(void *) &nPlaces,__xlater_roPup_nPlaces);
+
+  CkRegisterReadonly("placesProxy","CProxy_Places",sizeof(placesProxy),(void *) &placesProxy,__xlater_roPup_placesProxy);
+
+/* REG: mainchare Main: Chare{
+Main(CkArgMsg* impl_msg);
+threaded void libThread(void);
+};
+*/
+  CkIndex_Main::__register("Main", sizeof(Main));
+
+/* REG: array Places: ArrayElement{
+Places(CkMigrateMessage* impl_msg);
+void Places(void);
+threaded void startAsync(int which_statement, const CkFutureID &ftHandle, int pe_src);
+};
+*/
+  CkIndex_Places::__register("Places", sizeof(Places));
+
+}
+extern "C" void CkRegisterMainModule(void) {
+  _registerX10_test();
+}
+#endif
diff --git a/examples/charm++/X10/X10_test2.C b/examples/charm++/X10/X10_test2.C
new file mode 100644 (file)
index 0000000..f4e1c73
--- /dev/null
@@ -0,0 +1,130 @@
+//-------------------------------------------------------------
+// file   : X10_test2.C
+// author : Isaac Dooley
+// date   : April 2006
+//
+
+#include <pup.h>
+#include <converse.h>
+#include "X10_test.decl.h"
+
+
+/*readonly*/ CProxy_Main mainProxy;
+/*readonly*/ CProxy_Places placesProxy;
+/*readonly*/ int nPlaces;
+
+class asyncMsg : public CMessage_asyncMsg{
+ public:
+  int temp;
+  asyncMsg& operator=(const asyncMsg& obj) {
+       temp = obj.temp;
+    return *this;
+  }
+
+  asyncMsg(){temp=1;}
+
+};
+
+
+typedef CkVec<CkFutureID> *finishHandle;
+
+CkVec<CkFutureID> *beginFinish(){
+  CkVec<CkFutureID> *FinishFutureList = new CkVec<CkFutureID>;
+  return FinishFutureList;
+} 
+
+void endFinish(CkVec<CkFutureID> * FinishFutureList){
+  int last = FinishFutureList->length();
+  CkPrintf("MainThread: Future waiting   last=%d\n", last);
+  int len = FinishFutureList->length();
+  while(len > 0){
+       CkPrintf("len=%d\n", len);
+       asyncMsg *msg = (asyncMsg *)CkWaitFuture((*FinishFutureList)[len-1]);
+       FinishFutureList->remove(len-1);
+       len = FinishFutureList->length();
+
+  }
+
+  CkPrintf("MainThread: Future awaken\n");
+  delete FinishFutureList;
+}
+
+void asyncCall(CkVec<CkFutureID> *FinishFutureList, int place, int whichFunction, void *packedParams){
+  asyncMsg *msg = new asyncMsg;
+  CkFutureID ftHandle = CkCreateAttachedFuture((void*)msg);
+  CkAssert(FinishFutureList->size()==0);
+  FinishFutureList->push_back(ftHandle);
+  CkPrintf("MainThread: Created Future with handle %d\n", ftHandle);
+  (*FinishFutureList)[FinishFutureList->length()]=ftHandle;
+  placesProxy[place].startAsync(whichFunction,ftHandle,CkMyPe());
+  CkPrintf("MainThread: Created Async call with handle %d\n", ftHandle);
+}
+
+
+void foo(){}
+
+
+void mainThread(){
+
+       CkVec<CkFutureID> *f = beginFinish();
+
+       CkAssert(f);
+       asyncCall(f,1,1,NULL); // An X11 async method with place, whichFunction, and packed variables
+       foo();  // Do local work
+       
+       endFinish(f);   //      Wait on async to finish
+}
+
+
+
+
+
+/*mainchare*/
+class Main : public CBase_Main
+{
+ public:
+
+  Main(CkArgMsg* m)
+  {
+       nPlaces=CkNumPes();
+       CkPrintf("Starting Up: %d Places(Processors)\n", nPlaces);  
+       mainProxy = thishandle;
+
+       CkAssert(nPlaces >= 2);
+
+    // Create X10 Places       
+       placesProxy = CProxy_Places::ckNew(nPlaces);
+
+       mainProxy.libThread();
+
+  }
+  
+  void libThread(){
+       CkPrintf("MainThread: executing in Main Chare\n");
+       mainThread();   
+       CkExit();
+  }
+  
+};
+
+/*mainchare*/
+class Places : public CBase_Places
+{
+public:
+  
+  Places(CkMigrateMessage *m){}
+  Places(){}
+  
+  void startAsync(int whichStatement, CkFutureID ftHandle, int pe_src){
+       asyncMsg *msg = new asyncMsg;
+       CkPrintf("Place %d: faking execution of statement %d\n", thisIndex, whichStatement);
+       CkPrintf("Place %d: Finished work, sending result to Future [%d] \n", thisIndex, ftHandle);
+       CkSendToFuture(ftHandle, (void *)msg, pe_src);
+  }
+  
+};
+
+
+
+  
+#include "X10_test.def.h"  
diff --git a/examples/charm++/X10/X10_test2.ci b/examples/charm++/X10/X10_test2.ci
new file mode 100644 (file)
index 0000000..b2acc7c
--- /dev/null
@@ -0,0 +1,23 @@
+
+mainmodule X10_test {
+
+  message asyncMsg;
+
+  /*  extern module CkFutures;*/
+
+  readonly CProxy_Main mainProxy;
+  readonly int nPlaces;
+  readonly CProxy_Places placesProxy;
+
+  mainchare Main {
+    entry Main(CkArgMsg *m);            // cannot be threaded
+       entry [threaded] void libThread();
+  };
+  
+
+  array [1D] Places {
+       entry void Places(void);
+       entry [threaded] void startAsync(int which_statement, CkFutureID ftHandle, int pe_src);
+  };
+
+};  
diff --git a/examples/charm++/X10/X10_test2.o b/examples/charm++/X10/X10_test2.o
new file mode 100644 (file)
index 0000000..41a41f0
Binary files /dev/null and b/examples/charm++/X10/X10_test2.o differ