splited nodeinit to separate nodeinit and procinit.
authorGengbin Zheng <gzheng@illinois.edu>
Sat, 31 May 2003 20:45:16 +0000 (20:45 +0000)
committerGengbin Zheng <gzheng@illinois.edu>
Sat, 31 May 2003 20:45:16 +0000 (20:45 +0000)
ported tcharm onto BlueGene simualtor.

src/libs/ck-libs/tcharm/Makefile
src/libs/ck-libs/tcharm/libmoduletcharm.dep
src/libs/ck-libs/tcharm/tcharm.C
src/libs/ck-libs/tcharm/tcharm.ci
src/libs/ck-libs/tcharm/tcharm_impl.h

index 1abd29c8f200a5976e4566d652f80ddecb6342e8..0315691ac15bc14f46cd7607b5c9edbb1f2137ca 100644 (file)
@@ -9,7 +9,7 @@ LIBDIR=$(CDIR)/lib
 
 LIB=libmoduletcharm
 DEST=$(LIBDIR)/$(LIB).a
-COMPATLIB=$(LIBDIR)/libmoduletcharm-compat.a
+COMPATLIB=$(LIBDIR)/libtcharm-compat.a
 
 all: $(DEST) $(COMPATLIB)
 
index b712082036436b9a63a088931e179244fca4c999..ffdca0b748ad355134b61acb67f88ad43d0e1815 100644 (file)
@@ -1 +1 @@
--language charm++ -lmoduletcharm-compat
+-language charm++ -ltcharm-compat
index f0dbb58a6fc663e8b4e0ddf586c007f8391d5680..bc31a5df38e5f885295fdc21c4ad007e9ceafab6 100644 (file)
@@ -18,7 +18,7 @@ Orion Sky Lawlor, olawlor@acm.org, 11/19/2001
 #endif
 
 CtvDeclare(TCharm *,_curTCharm);
-CpvDeclare(inState,_stateTCharm);
+CkpvDeclare(inState,_stateTCharm);
 
 static int lastNumChunks=0;
 
@@ -43,6 +43,8 @@ public:
                for (i=0;0!=*lib;i++,lib++)
                        libNames[curLibs][i]=tolower(*lib);
                libNames[curLibs][i]=0;
+               // if already tracing, skip
+               if (checkIfTracing(libNames[curLibs])) return;
                curLibs++;
        }
        inline int isTracing(const char *lib) const {
@@ -58,8 +60,17 @@ void TCharm::nodeInit(void)
 {
   CtvInitialize(TCharm *,_curTCharm);
   CtvAccess(_curTCharm)=NULL;
-  CpvInitialize(inState,_stateTCharm);
-  CmiArgGroup("Library","TCharm");
+  CkpvInitialize(inState,_stateTCharm);
+
+  TCharm::setState(inNodeSetup);
+  TCHARM_User_node_setup();
+  FTN_NAME(TCHARM_USER_NODE_SETUP,tcharm_user_node_setup)();
+  TCharm::setState(inInit);
+}
+
+void TCharm::procInit(void)
+{
+  // called on every pe to east these arguments
   char **argv=CkGetArgv();
   tcharm_nomig=CmiGetArgFlagDesc(argv,"+tcharm_nomig","Disable migration support (debugging)");
   tcharm_nothreads=CmiGetArgFlagDesc(argv,"+tcharm_nothread","Disable thread support (debugging)");
@@ -73,11 +84,6 @@ void TCharm::nodeInit(void)
        while (CmiGetArgIntDesc(argv,"-vp",&ignored,NULL)) {}
        while (CmiGetArgIntDesc(argv,"+vp",&ignored,NULL)) {}
   }
-
-  TCharm::setState(inNodeSetup);
-  TCHARM_User_node_setup();
-  FTN_NAME(TCHARM_USER_NODE_SETUP,tcharm_user_node_setup)();
-  TCharm::setState(inInit);
 }
 
 void TCHARM_Api_trace(const char *routineName,const char *libraryName)
@@ -117,6 +123,9 @@ TCharm::TCharm(TCharmInitMsg *initMsg_)
     } else {
       tid=CthCreateMigratable((CthVoidFn)startTCharmThread,initMsg,initMsg->stackSize);
     }
+#if CMK_BLUEGENE_CHARM
+    BgAttach(tid);
+#endif
   }
   CtvAccessOther(tid,_curTCharm)=this;
   TCharm::setState(inInit);
index 2003d38bd60f84ace6842d98addfcb12a601d587..bee1baab9b805d71a45029e12907551bb73f439d 100644 (file)
@@ -6,6 +6,7 @@ module tcharm {
     entry TCharm(TCharmInitMsg *initMsg);
     entry void run(void);
     entry void migrateDelayed(int destPE);
+    initproc void procInit(void);
     initcall void nodeInit(void);
   };
   mainchare TCharmMain {
index 9a143137e1f5483e66a8bff023089a77d4e28e78..183bdbbe41ccd98f0509580830ae6c5a37fac761 100644 (file)
@@ -63,7 +63,7 @@ typedef enum {inNodeSetup,inInit,inDriver,inFramework,inPup} inState;
 
 //Thread-local variables:
 CtvExtern(TCharm *,_curTCharm);
-CpvExtern(inState,_stateTCharm);
+CkpvExtern(inState,_stateTCharm);
 
 CDECL {typedef void (*TCpupUserDataC)(pup_er p,void *data);};
 FDECL {typedef void (*TCpupUserDataF)(pup_er p,void *data);};
@@ -117,6 +117,7 @@ class TCharm: public CBase_TCharm
 
        //One-time initialization
        static void nodeInit(void);
+       static void procInit(void);
  private:
        //Informational data about the current thread:
        class ThreadInfo {
@@ -184,8 +185,8 @@ class TCharm: public CBase_TCharm
        void *lookupUserData(int ud);
        
        inline static TCharm *get(void) {check(); return CtvAccess(_curTCharm);}
-       inline static inState getState(void) {return CpvAccess(_stateTCharm);}
-       inline static void setState(inState to) {CpvAccess(_stateTCharm)=to;}
+       inline static inState getState(void) {return CkpvAccess(_stateTCharm);}
+       inline static void setState(inState to) {CkpvAccess(_stateTCharm)=to;}
        inline CthThread getThread(void) {return tid;}
        inline const CProxy_TCharm &getProxy(void) const {return threadInfo.tProxy;}
        inline int getElement(void) const {return threadInfo.thisElement;}