bsp_memreg.h

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 
00035 #ifndef BSP_MEMREG_H
00036 #define BSP_MEMREG_H
00037 #include <stdlib.h>
00038 #include "bsp_abort.h"
00039 #include "bsp_exptable.h"
00040 #include <config.h>
00041 
00042 void
00043 memoryRegister_initialize (ExpandableTable * restrict , const unsigned int,
00044                            const unsigned int, const unsigned int);
00045 
00046 void memoryRegister_destruct (ExpandableTable * restrict );
00047 
00048 void memoryRegister_expand (ExpandableTable * restrict, const unsigned int);
00049 
00050 void memoryRegister_push (ExpandableTable * restrict, const unsigned int, const char * const restrict );
00051 
00052 void memoryRegister_pop (ExpandableTable * restrict, const unsigned int, const char * const restrict );
00053 
00054 void memoryRegister_pack (ExpandableTable * restrict);
00055 
00064 static inline MemRegElement
00065 memoryRegister_find (const ExpandableTable * restrict table, 
00066                      const unsigned int sp, const unsigned int dp,
00067                      const char * const pointer)
00068 {
00069   int count;
00070   const MemRegElement * restrict array;
00071   const unsigned int srccol = table->rows * sp;
00072   const unsigned int dstcol = table->rows * dp;
00073   array  = (MemRegElement *) table->data + srccol;
00074   for ( count = table->used_slot_count[sp]-1; count >= 0; count--)
00075     {
00076       if (array[count] == pointer && !table->info.reg.removed[count])
00077         return *(array + count - srccol + dstcol);
00078     }
00079   bsp_intern_abort (ERR_POP_REG_WITHOUT_PUSH, __func__, __FILE__, __LINE__);
00080   return NULL;
00081 }
00082 
00092 static inline MemRegElement
00093 memoryRegister_memoized_find (const ExpandableTable * restrict table,  
00094                               const unsigned int dp, const char * const pointer)
00095 {
00096   const unsigned int dstcol = table->rows * dp;
00097   const MemRegElement * restrict data_iter = table->info.reg.memoized_data_iter;
00098  
00099   /* WARNING: If element is not in register, then loop may not terminate */
00100   while(*data_iter != pointer)
00101     data_iter--;
00102 
00103   return *(data_iter - table->info.reg.memoized_srccol + dstcol);
00104 }
00105 
00106 #endif

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