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

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