tweak pxshm to work for SMP build
[charm.git] / src / arch / util / machine-common-core.c
index 7179d8dbfb1248121730172e146c03a444a54d8e..dca377b74132975daf03d10406b77e61f9b4ba5f 100644 (file)
@@ -459,25 +459,13 @@ void CmiFreeSendFn(int destPE, int size, char *msg) {
         if (phs) curphs++;
 #endif
     } else {
-#if CMK_USE_PXSHM
-        int ret=CmiValidPxshm(destPE, size);
-        if (ret) {
-          CMI_DEST_RANK(msg) = CmiRankOf(destPE);
-          CmiSendMessagePxshm(msg, size, destPE, &refcount, CmiRankOf(destPE), 0);
-          //for (int i=0; i<refcount; i++) CmiReference(msg);
 #if CMK_PERSISTENT_COMM
-        if (phs) curphs++;
-#endif
-          return;
+        if (phs && size > 8192) {
+            CmiAssert(curphs < phsSize);
+            LrtsSendPersistentMsg(phs[curphs++], destPE, size, msg);
+            return;
         }
 #endif
-#if CMK_PERSISTENT_COMM
-    if (phs && size > 8192) {
-        CmiAssert(curphs < phsSize);
-        LrtsSendPersistentMsg(phs[curphs++], destPE, size, msg);
-        return;
-    }
-#endif
 
         int destNode = CmiNodeOf(destPE);
 #if CMK_SMP
@@ -487,6 +475,17 @@ void CmiFreeSendFn(int destPE, int size, char *msg) {
         }
 #endif
         CMI_DEST_RANK(msg) = CmiRankOf(destPE);
+#if CMK_USE_PXSHM
+        int ret=CmiValidPxshm(destPE, size);
+        if (ret) {
+          CmiSendMessagePxshm(msg, size, destPE, &refcount, CmiRankOf(destPE), 0);
+          //for (int i=0; i<refcount; i++) CmiReference(msg);
+#if CMK_PERSISTENT_COMM
+          if (phs) curphs++;
+#endif
+          return;
+        }
+#endif
 if (  MSG_STATISTIC)
 {
     int ret_log = _cmi_log2(size);
@@ -759,6 +758,9 @@ static void CommunicationServer(int sleepTime) {
 
         ConverseCommonExit();
 
+#if CMK_USE_PXSHM
+        CmiExitPxshm();
+#endif
         LrtsExit();
     }
 #endif
@@ -777,9 +779,6 @@ void ConverseExit(void) {
     LrtsDrainResources();
 #endif
 
-#if CMK_USE_PXSHM
-        CmiExitPxshm();
-#endif
     ConverseCommonExit();
 
 if (MSG_STATISTIC)
@@ -797,6 +796,9 @@ if (MSG_STATISTIC)
 #endif
 
 #if !CMK_SMP
+#if CMK_USE_PXSHM
+    CmiExitPxshm();
+#endif
     LrtsExit();
 #else
     /* In SMP, the communication thread will exit */