bsp_delivtable.c

Go to the documentation of this file.
00001 /*
00002     BSPonMPI. This is an implementation of the BSPlib standard on top of MPI
00003     Copyright (C) 2006  Wijnand J. Suijlen
00004                                                                                 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Lesser General Public
00007     License as published by the Free Software Foundation; either
00008     version 2.1 of the License, or (at your option) any later version.
00009                                                                                 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Lesser General Public License for more details.
00014                                                                                 
00015     You should have received a copy of the GNU Lesser General Public
00016     License along with this library; if not, write to the Free Software
00017     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018                                                                                 
00019     You may contact me via electronic mail:
00020       wjsuijle@users.sourceforge.net
00021     or snail mail:
00022       W.J. Suijlen
00023       Kraaiheidelaan 10
00024       2803 VP Gouda
00025       The Netherlands
00026 */
00027 
00033 #include "bsp_exptable.h"
00034 #include "bsp_memreg.h"
00035 #include "bsp_mesgqueue.h"
00036 
00045 void
00046 deliveryTable_execute (ExpandableTable * restrict table, 
00047                        ExpandableTable * restrict memreg, 
00048                        MessageQueue * restrict mesgq, const int rank)
00049 {
00050   int p, i;
00051   const DelivElement *restrict element;
00052   DelivElement * restrict message = NULL;
00053   const ALIGNED_TYPE * restrict pointer;
00054   const unsigned int tag_size = 
00055     no_slots(sizeof(DelivElement), sizeof(ALIGNED_TYPE));
00056 
00057   for (p = 0; p < table->nprocs; p++)
00058     {
00059       /* do put's */
00060       pointer = (ALIGNED_TYPE *) table->data + p * table->rows + 
00061                   table->info.deliv.start[p][put] ;
00062      
00063       for (i = 0; i < table->info.deliv.count[p][put]; i++)
00064         {
00065           element = (DelivElement *) pointer;
00066           memcpy(element->info.put.dst, pointer + tag_size, element->size);
00067           pointer+=element->next;
00068         }  
00069 
00070       /* do pushreg's */        
00071       pointer = (ALIGNED_TYPE *) table->data + p * table->rows + 
00072                    table->info.deliv.start[p][pushreg];
00073      
00074       for (i = 0; i < table->info.deliv.count[p][pushreg]; i++)
00075         {
00076           element = (DelivElement *) pointer;
00077           memoryRegister_push( memreg, p, element->info.push.address);
00078           pointer+=element->next;
00079         }  
00080       
00081       /* gather data about send's */
00082       pointer = (ALIGNED_TYPE *) table->data + p * table->rows + 
00083                    table->info.deliv.start[p][send];
00084       /* link the last element of the previous column to the first of this
00085        * column */
00086       if (message != NULL) 
00087            message->next = ((unsigned long) pointer - (unsigned long) message) / sizeof(ALIGNED_TYPE);
00088 
00089       for (i = 0; i < table->info.deliv.count[p][send]; i++)
00090         {
00091           message = (DelivElement *) pointer;
00092           mesgq->accum_size += message->size;
00093           mesgq->n_mesg ++;
00094           pointer+=message->next;
00095         }  
00096 
00097     }   
00098       /* get's aren't supposed to be in this queue */
00099     
00100     /* do popreg's (they only appear in processor column 'rank') */
00101     pointer = (ALIGNED_TYPE *) table->data + rank * table->rows +
00102                    table->info.deliv.start[rank][popreg];
00103     for (i = 0; i < table->info.deliv.count[rank][popreg]; i++)
00104       {
00105         element = (DelivElement *) pointer;
00106         memoryRegister_pop( memreg, rank, element->info.pop.address);
00107         pointer+=element->next;
00108       }
00109     
00110     /* do settag's (they only appear in processor column 'rank') */
00111    pointer = (ALIGNED_TYPE *) table->data + rank * table->rows +
00112         table->info.deliv.start[rank][settag];
00113    for (i = 0; i < table->info.deliv.count[rank][settag]; i++)
00114       {
00115         element = (DelivElement *) pointer;
00116         mesgq->send_tag_size = element->info.settag.tag_size;
00117         pointer+=element->next;
00118       }
00119 
00120     /* look for the first message in the message queue */
00121     for (p = 0; p < table->nprocs; p++)
00122       {
00123         if ( table->info.deliv.count[p][send] > 0 )
00124           {
00125             mesgq->head = (ALIGNED_TYPE *) table->data + p * table->rows 
00126                  + table->info.deliv.start[p][send];
00127             break;
00128           }
00129       }   
00130 }
00131 
00132 
00133 

Generated on Sat Apr 8 20:12:29 2006 for BSPonMPI by  doxygen 1.4.6