00001
00002
00003
00004
00005 #ifndef _MIDDLE_BLUE_H_
00006 #define _MIDDLE_BLUE_H_
00007
00008 #include <memory.h>
00009 #include "converse.h"
00010 #include "blue.h"
00011
00012 #undef CkMyPe
00013 #undef CkNumPes
00014 #undef CkMyRank
00015 #undef CkMyNode
00016 #undef CkNumNodes
00017 #undef CkMyNodeSize
00018 #undef CkNodeOf
00019 #undef CkNodeSize
00020 #undef CkNodeFirst
00021
00022 #undef CmiSyncSend
00023 #undef CmiSyncSendAndFree
00024 #undef CmiSyncBroadcast
00025 #undef CmiSyncBroadcastAndFree
00026 #undef CmiSyncBroadcastAll
00027 #undef CmiSyncBroadcastAllAndFree
00028
00029 #undef CmiSyncNodeSend
00030 #undef CmiSyncNodeSendAndFree
00031 #undef CmiSyncNodeBroadcast
00032 #undef CmiSyncNodeBroadcastAndFree
00033 #undef CmiSyncNodeBroadcastAll
00034 #undef CmiSyncNodeBroadcastAllAndFree
00035
00036
00037 #undef CkWallTimer
00038 #undef CkCpuTimer
00039 #define CkWallTimer BgGetTime
00040 #define CkCpuTimer BgGetTime
00041 #define CkVTimer BgGetTime
00042 #define CkElapse BgElapse
00043
00044 #define CkRegisterHandler(x) BgRegisterHandler((BgHandler)(x))
00045 #define CkRegisterHandlerEx(x, p) BgRegisterHandlerEx((BgHandlerEx)(x), p)
00046 #define CkNumberHandler(n, x) BgNumberHandler(n, (BgHandler)(x))
00047 #define CkNumberHandlerEx(n, x, p) BgNumberHandlerEx(n, (BgHandlerEx)(x), p)
00048
00049 #undef ConverseExit
00050 #define ConverseExit(...) BgCharmExit()
00051
00056 #if CMK_BIGSIM_NODE
00057
00058 #define CkpvDeclare BnvDeclare
00059 #define CkpvExtern BnvExtern
00060 #define CkpvStaticDeclare BnvStaticDeclare
00061 #define CkpvInitialize BnvInitialize
00062 #define CkpvInitialized BnvInitialized
00063 #define CkpvAccess BnvAccess
00064 #define CkpvAccessOther BnvAccessOther
00065
00066 namespace BGConverse {
00067
00068 inline int CkMyPe() { return BgMyNode(); }
00069 inline int CkNumPes() { int x,y,z; BgGetSize(&x, &y, &z); return (x*y*z); }
00070 inline int CkMyRank() { return 0; }
00071 inline int BgNodeRank() { return BgMyRank(); }
00072 inline int CkMyNodeSize() { return 1; }
00073
00074 #if 0
00075 static inline void CmiSyncSend(int pe, int nb, char *m)
00076 {
00077 int x,y,z;
00078 char *dupm = (char *)CmiAlloc(nb);
00079
00080
00081 memcpy(dupm, m, nb);
00082 BgGetXYZ(pe, &x, &y, &z);
00083 BgSendPacket(x,y,z, ANYTHREAD, CmiGetHandler(m), LARGE_WORK, nb, dupm);
00084 }
00085
00086 static inline void CmiSyncSendAndFree(int pe, int nb, char *m)
00087 {
00088 int x,y,z;
00089
00090 BgGetXYZ(pe, &x, &y, &z);
00091 BgSendPacket(x,y,z, ANYTHREAD, CmiGetHandler(m), LARGE_WORK, nb, m);
00092 }
00093
00094 static inline void CmiSyncBroadcast(int nb, char *m)
00095 {
00096 char *dupm = (char *)CmiAlloc(nb);
00097
00098 memcpy(dupm, m, nb);
00099 BgBroadcastPacketExcept(CkMyPe(), ANYTHREAD, CmiGetHandler(m), LARGE_WORK, nb, dupm);
00100 }
00101
00102 static inline void CmiSyncBroadcastAndFree(int nb, char *m)
00103 {
00104
00105 BgBroadcastPacketExcept(CkMyPe(), ANYTHREAD, CmiGetHandler(m), LARGE_WORK, nb, m);
00106 }
00107
00108 static inline void CmiSyncBroadcastAll(int nb, char *m)
00109 {
00110 char *dupm = (char *)CmiAlloc(nb);
00111
00112 memcpy(dupm, m, nb);
00113 BgBroadcastAllPacket(CmiGetHandler(m), LARGE_WORK, nb, dupm);
00114 }
00115
00116 static inline void CmiSyncBroadcastAllAndFree(int nb, char *m)
00117 {
00118
00119
00120 BgBroadcastAllPacket(CmiGetHandler(m), LARGE_WORK, nb, m);
00121 }
00122 #endif
00123
00124 }
00125
00126
00127 #else
00128
00134 #define CkpvDeclare BpvDeclare
00135 #define CkpvExtern BpvExtern
00136 #define CkpvStaticDeclare BpvStaticDeclare
00137 #define CkpvInitialize BpvInitialize
00138 #define CkpvInitialized BpvInitialized
00139 #define CkpvAccess BpvAccess
00140 #define CkpvAccessOther BpvAccessOther
00141
00142 #define CksvDeclare BnvDeclare
00143 #define CksvExtern BnvExtern
00144 #define CksvStaticDeclare BnvStaticDeclare
00145 #define CksvInitialize BnvInitialize
00146 #define CksvAccess BnvAccess
00147
00148 namespace BGConverse {
00149
00150 static inline int CkMyPe() { return BgGetGlobalWorkerThreadID(); }
00151 static inline int CkNumPes() { return BgNumNodes()*BgGetNumWorkThread(); }
00152 static inline int CkMyRank() { return BgGetThreadID(); }
00153 static inline int BgNodeRank() { return BgMyRank()*BgGetNumWorkThread()+BgGetThreadID(); }
00154 static inline int CkMyNode() { return BgMyNode(); }
00155 static inline int CkNodeOf(int pe) { return pe / BgGetNumWorkThread(); }
00156 static inline int CkNumNodes() { return BgNumNodes(); }
00157 static inline int CkMyNodeSize() { return BgGetNumWorkThread(); }
00158 static inline int CkNodeSize(int node) { return BgGetNumWorkThread(); }
00159 static inline int CkNodeFirst(int node) { return BgGetNumWorkThread()*node; }
00160
00161 static inline void CksdScheduler(int ret) { BgScheduler(ret); }
00162 static inline void CksdExitScheduler() { BgExitScheduler(); }
00163 static inline void CkDeliverMsgs(int nmsg) { BgDeliverMsgs(nmsg); }
00164
00165 #ifdef __cplusplus
00166 extern "C"
00167 #endif
00168 void CkReduce(void *msg, int size, CmiReduceMergeFn mergeFn);
00169
00170 }
00171
00172 #endif
00173
00174 #define CmiSyncSend BgSyncSend
00175 #define CmiSyncSendAndFree BgSyncSendAndFree
00176 #define CmiSyncBroadcast BgSyncBroadcast
00177 #define CmiSyncBroadcastAndFree BgSyncBroadcastAndFree
00178 #define CmiSyncBroadcastAll BgSyncBroadcastAll
00179 #define CmiSyncBroadcastAllAndFree BgSyncBroadcastAllAndFree
00180
00181 #define CmiSyncNodeSend BgSyncNodeSend
00182 #define CmiSyncNodeSendAndFree BgSyncNodeSendAndFree
00183 #define CmiSyncNodeBroadcast BgSyncNodeBroadcast
00184 #define CmiSyncNodeBroadcastAndFree BgSyncNodeBroadcastAndFree
00185 #define CmiSyncNodeBroadcastAll BgSyncNodeBroadcastAll
00186 #define CmiSyncNodeBroadcastAllAndFree BgSyncNodeBroadcastAllAndFree
00187
00188 #undef CmiSyncListSendAndFree
00189 #define CmiSyncListSendAndFree BgSyncListSendAndFree
00190
00191 #define CmiMultipleSend BgMultipleSend
00192
00193 #undef CsdEnqueueLifo
00194
00195 #define CsdEnqueueLifo(m) BgEnqueue((char*)m)
00196
00197 #undef CmiNodeAllBarrier
00198 #define CmiNodeAllBarrier()
00199
00200 #undef CmiBarrier
00201 #define CmiBarrier()
00202
00204 namespace BGConverse {
00205
00206 static inline void BgCharmExit()
00207 {
00208
00209 if (CkMyPe() == 0) BgShutdown();
00210 }
00211
00212 }
00213
00214
00215 #endif