
00001 00009 #include "prefixrouter.h" 00010 00011 #if 0 00012 #define PREFIXDEB printf 00013 #else 00014 #define PREFIXDEB /* printf */ 00015 #endif 00016 00017 void PrefixRouter::EachToManyMulticastQ(comID id, CkQ<MessageHolder *> &msgq) { 00018 PREFIXDEB("[%d]Sending through prefix router: ",CmiMyPe()); 00019 if(!msgq.isEmpty()){ 00020 MessageHolder *mhdl = msgq[0]; 00021 if(mhdl->dest_proc<0) // broadcast or multicast 00022 sendMulticast(msgq); 00023 else 00024 sendPointToPoint(msgq); 00025 } 00026 Done(id); 00027 } 00028 00029 void PrefixRouter::sendMulticast(CkQ<MessageHolder *> &msgq) { 00030 int count; 00031 PREFIXDEB("with a multicast\n"); 00032 while(!msgq.isEmpty()){ 00033 MessageHolder *mhdl = msgq.deq(); 00034 00035 if(mhdl->dest_proc == IS_BROADCAST) { 00036 for(count = 0; count < npes; count ++) { 00037 int curDest = gpes[MyPe ^ count]; 00038 char *msg = mhdl->getMessage(); 00039 CmiSyncSend(curDest, mhdl->size, msg); 00040 } 00041 } 00042 else { 00043 CmiAbort("Implement later"); 00044 } 00045 } 00046 } 00047 00048 void PrefixRouter::sendPointToPoint(CkQ<MessageHolder *> &msgq) { 00049 int count, i; 00050 PREFIXDEB("with a point-to-point\n"); 00051 int len = msgq.length(); 00052 for(count = 0; count < npes; count ++) { 00053 int curDest = gpes[MyPe ^ count]; 00054 00055 for(i = 0; i < len; i++) { 00056 MessageHolder *mhdl = msgq[i]; 00057 00058 CmiAssert(mhdl->dest_proc >= 0); 00059 if(mhdl->dest_proc == curDest) { 00060 char *msg = mhdl->getMessage(); 00061 CmiSyncSendAndFree(curDest, mhdl->size, msg); 00062 } 00063 } 00064 } 00065 00066 for(i = 0; i < len; i++) { 00067 MessageHolder *mhdl = msgq.deq(); 00068 delete mhdl; 00069 } 00070 }
1.5.5