00001 #include <stdio.h> 00002 00003 #include <moc.h> 00004 #include <internal/imoc.h> 00005 #include <internal/imoc_macros.h> 00006 #ifdef __SPU__ 00007 #include <internal/spu/imoc_core_spu.h> 00008 #else 00009 #include <internal/ppu/imoc_core_ppu.h> 00010 #endif 00011 00012 /*method looks for valid entries in the message queue*/ 00013 moc_message_envelope_t* IMOC_get_entry(int source, int tag, MOC_Comm comm, 00014 int isSpecial, MOC_Status *status) 00015 { 00016 moc_message_envelope_t *startQueue; 00017 int count; 00018 00019 /*check if source is ANY_SOURCE*/ 00020 if (source == MOC_ANY_SOURCE) 00021 { 00022 /*set start to base adress of the message queue*/ 00023 startQueue =( moc_message_envelope_t*) node_handle.message_queue_base; 00024 /*check if tag is ANY_TAG*/ 00025 if(tag == MOC_ANY_TAG) 00026 { 00027 for(count=0;count<(node_handle.queue_size*(node_handle.comm_size-1));count++) 00028 { 00029 /*search for a valid entry*/ 00030 if(startQueue[count].flags.bits.valid && startQueue[count].communicator == comm 00031 && startQueue[count].flags.bits.special == isSpecial) 00032 { 00033 /*calculate source*/ 00034 if(count/(node_handle.queue_size) >= node_handle.rank) 00035 status->MOC_SOURCE = count/(node_handle.queue_size)+1; 00036 else 00037 status->MOC_SOURCE = count/(node_handle.queue_size); 00038 return &startQueue[count]; 00039 } 00040 } 00041 } 00042 else 00043 { 00044 for(count=0;count<(node_handle.queue_size*(node_handle.comm_size-1));count++) 00045 { 00046 /*search for a valid entry with right tag*/ 00047 if(startQueue[count].flags.bits.valid && startQueue[count].tag == tag 00048 && startQueue[count].communicator == comm 00049 && startQueue[count].flags.bits.special == isSpecial) 00050 { 00051 /*calculate source*/ 00052 if(count/(node_handle.queue_size) >= node_handle.rank) 00053 status->MOC_SOURCE = count/(node_handle.queue_size)+1; 00054 else 00055 status->MOC_SOURCE = count/(node_handle.queue_size); 00056 00057 return &startQueue[count]; 00058 } 00059 } 00060 } 00061 } 00062 else 00063 { 00064 /*set start to the base adress of the message queue of source process*/ 00065 startQueue = (moc_message_envelope_t*) IMOC_LOCAL_QUEUE(source); 00066 /*check if tag is ANY_TAG*/ 00067 if(tag == MOC_ANY_TAG) 00068 { 00069 for(count=0;count<node_handle.queue_size;count++) 00070 { 00071 /*search for a valid entry from source*/ 00072 if(startQueue[count].flags.bits.valid && startQueue[count].communicator == comm 00073 && startQueue[count].flags.bits.special == isSpecial) 00074 return &startQueue[count]; 00075 } 00076 } 00077 else 00078 { 00079 for(count=0;count<node_handle.queue_size;count++) 00080 { 00081 /*search for a valid entry from source with right tag*/ 00082 if(startQueue[count].flags.bits.valid && startQueue[count].tag == tag 00083 && startQueue[count].communicator == comm 00084 && startQueue[count].flags.bits.special == isSpecial) 00085 return &startQueue[count]; 00086 } 00087 } 00088 } 00089 00090 return NULL; 00091 }
1.5.6