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 
00037 static inline void
00038 exec_put(const VarSizeElement element, const char * restrict offset )
00039 {
00040   int i;
00041   const int item_size = element.info.put.item_size;
00042   void * dst;
00043   
00044   for (i = 0; i < element.info.put.item_count; i++)
00045    {
00046       memcpy(&dst, offset, sizeof(void *)); // copy destination pointer
00047       offset += sizeof(void *);
00048       memcpy(dst, offset, item_size);
00049       offset += item_size;
00050    }
00051 }
00052 
00060 void
00061 deliveryTable_execute (ExpandableTable * restrict table, ExpandableTable * restrict memreg,
00062                        ExpandableTable * restrict mesgq)
00063 {
00064   int i, j, end;
00065   VarSizeElement *restrict elements;
00066 
00067   for (i = 0; i < table->nprocs; i++)
00068     {
00069       elements = (VarSizeElement *) table->data + i * table->rows;
00070       end = table->used_slot_count[i];
00071       j = 0;
00072       
00073       while( j < end)
00074         {
00075           switch (elements[j].type)
00076             {
00077             case popreg:
00078               memoryRegister_pop (memreg, i, elements[j].info.pop.address);
00079               break;
00080 
00081             case pushreg:
00082               memoryRegister_push (memreg, i, elements[j].info.push.address);
00083               break;
00084 
00085             case put:
00086               exec_put(elements[j], (char *) &elements[j + 1]);
00087               break;
00088 
00089             case send:
00090              /* there is no need to set elements[j].data because this value is
00091               * calculated in messageQueue */
00092               messageQueue_push (mesgq, (char *) &elements[j], 
00093                                   sizeof(VarSizeElement) + elements[j].size);
00094               break;
00095 
00096             case settag:
00097               messageQueue_setTagSize (mesgq, elements[j].info.settag.tag_size);
00098               break;
00099             
00100             case get:
00101               bsp_intern_abort(ERR_GET_DELIVERED, __func__, __FILE__,__LINE__);
00102             } //switch
00103            j+= 1 + (elements[j].size + sizeof(VarSizeElement) - 1) / sizeof(VarSizeElement);
00104         }//while
00105     }//for
00106 }
00107 
00108 
00109 

Generated on Sat Apr 8 12:56:54 2006 for BSPonMPI by  doxygen 1.4.6