[cig-commits] r4348 - in long/3D/Gale/trunk/src/StGermain: .
Base/Container/src
walter at geodynamics.org
walter at geodynamics.org
Thu Aug 17 17:17:58 PDT 2006
Author: walter
Date: 2006-08-17 17:17:57 -0700 (Thu, 17 Aug 2006)
New Revision: 4348
Added:
long/3D/Gale/trunk/src/StGermain/Base/Container/src/RangeSet.c
long/3D/Gale/trunk/src/StGermain/Base/Container/src/RangeSet.h
Modified:
long/3D/Gale/trunk/src/StGermain/
long/3D/Gale/trunk/src/StGermain/Base/Container/src/Container.h
long/3D/Gale/trunk/src/StGermain/Base/Container/src/types.h
Log:
r2719 at earth: boo | 2006-08-17 17:14:27 -0700
r2673 at earth (orig r3754): LukeHodkinson | 2006-08-07 22:22:36 -0700
Added a helper container class for compressing a set
of indices into ranges of indices. This guy should help
the new decomposition method to reduce communication times.
Property changes on: long/3D/Gale/trunk/src/StGermain
___________________________________________________________________
Name: svk:merge
- 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:2718
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3753
+ 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:2719
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3754
Modified: long/3D/Gale/trunk/src/StGermain/Base/Container/src/Container.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/Container/src/Container.h 2006-08-18 00:17:54 UTC (rev 4347)
+++ long/3D/Gale/trunk/src/StGermain/Base/Container/src/Container.h 2006-08-18 00:17:57 UTC (rev 4348)
@@ -64,6 +64,7 @@
#include "MaxHeap.h"
#include "MPIRoutines.h"
#include "UIntMap.h"
+ #include "RangeSet.h"
#include "Init.h"
#include "Finalise.h"
Added: long/3D/Gale/trunk/src/StGermain/Base/Container/src/RangeSet.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/Container/src/RangeSet.c 2006-08-18 00:17:54 UTC (rev 4347)
+++ long/3D/Gale/trunk/src/StGermain/Base/Container/src/RangeSet.c 2006-08-18 00:17:57 UTC (rev 4348)
@@ -0,0 +1,242 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: RangeSet.c 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <mpi.h>
+
+#include "Base/Foundation/Foundation.h"
+#include "Base/IO/IO.h"
+
+#include "types.h"
+#include "BTreeNode.h"
+#include "BTree.h"
+#include "RangeSet.h"
+
+
+/* Textual name of this class */
+const Type RangeSet_Type = "RangeSet";
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+RangeSet* RangeSet_New() {
+ return _RangeSet_New( sizeof(RangeSet),
+ RangeSet_Type,
+ _RangeSet_Delete,
+ _RangeSet_Print,
+ _RangeSet_Copy );
+}
+
+RangeSet* _RangeSet_New( RANGESET_DEFARGS ) {
+ RangeSet* self;
+
+ /* Allocate memory */
+ assert( sizeOfSelf >= sizeof(RangeSet) );
+ self = (RangeSet*)_Stg_Class_New( STG_CLASS_PASSARGS );
+
+ /* Virtual info */
+
+ /* RangeSet info */
+ _RangeSet_Init( self );
+
+ return self;
+}
+
+void _RangeSet_Init( RangeSet* self ) {
+ assert( self );
+
+ self->nInds = 0;
+ self->nRanges = 0;
+ self->ranges = NULL;
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _RangeSet_Delete( void* generator ) {
+ RangeSet* self = (RangeSet*)generator;
+
+ assert( self );
+
+ RangeSet_Destruct( self );
+
+ /* Delete the parent. */
+ _Stg_Class_Delete( self );
+}
+
+void _RangeSet_Print( void* generator, Stream* stream ) {
+ RangeSet* self = (RangeSet*)generator;
+
+ /* Set the Journal for printing informations */
+ Stream* generatorStream;
+ generatorStream = Journal_Register( InfoStream_Type, "RangeSetStream" );
+
+ /* Print parent */
+ Journal_Printf( stream, "RangeSet (ptr): (%p)\n", self );
+ _Stg_Class_Print( self, stream );
+}
+
+void* _RangeSet_Copy( void* generator, void* destProc_I, Bool deep, Name nameExt, PtrMap* ptrMap ) {
+#if 0
+ RangeSet* self = (RangeSet*)generator;
+ RangeSet* newRangeSet;
+ PtrMap* map = ptrMap;
+ Bool ownMap = False;
+
+ /* Damn me for making copying so difficult... what was I thinking? */
+
+ /* We need to create a map if it doesn't already exist. */
+ if( !map ) {
+ map = PtrMap_New( 10 );
+ ownMap = True;
+ }
+
+ newRangeSet = (RangeSet*)_Mesh_Copy( self, destProc_I, deep, nameExt, map );
+
+ /* Copy the virtual methods here. */
+
+ /* Deep or shallow? */
+ if( deep ) {
+ }
+ else {
+ }
+
+ /* If we own the map, get rid of it here. */
+ if( ownMap ) Stg_Class_Delete( map );
+
+ return (void*)newRangeSet;
+#endif
+
+ return NULL;
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+void RangeSet_SetIndices( void* rangeSet, unsigned nInds, unsigned* inds ) {
+ RangeSet* self = (RangeSet*)rangeSet;
+ unsigned* tmpInds;
+ unsigned curInd = 0;
+
+ assert( self );
+ assert( !nInds || inds );
+
+ RangeSet_Destruct( self );
+ if( !nInds ) return;
+
+ self->nInds = nInds;
+ tmpInds = Memory_Alloc_Array_Unnamed( unsigned, nInds );
+ memcpy( tmpInds, inds, nInds * sizeof(unsigned) );
+ qsort( tmpInds, nInds, sizeof(unsigned), RangeSet_SortCmp );
+
+ while( curInd < nInds ) {
+ RangeSet_Range* range;
+
+ if( !self->ranges ) {
+ self->ranges = Memory_Alloc_Array( RangeSet_Range, ++self->nRanges, "RangeSet::ranges" );
+ }
+ else {
+ self->ranges = Memory_Realloc_Array( self->ranges, RangeSet_Range, ++self->nRanges );
+ }
+
+ range = self->ranges + self->nRanges - 1;
+
+ range->begin = inds[curInd++];
+ while( inds[curInd] == inds[curInd - 1] ) {
+ curInd++;
+ self->nInds--;
+ }
+
+ range->end = inds[curInd++];
+ while( inds[curInd] == range->end ) {
+ curInd++;
+ self->nInds--;
+ }
+
+ range->step = range->end - range->begin;
+
+ while( inds[curInd] - range->end == range->step ) {
+ range->end = inds[curInd++];
+ while( inds[curInd] == range->end ) {
+ curInd++;
+ self->nInds--;
+ }
+ }
+ range->end++;
+ }
+
+ FreeArray( tmpInds );
+}
+
+
+Bool RangeSet_HasIndex( void* rangeSet, unsigned ind ) {
+ RangeSet* self = (RangeSet*)rangeSet;
+ unsigned r_i;
+
+ assert( self );
+
+ for( r_i = 0; r_i < self->nRanges; r_i++ ) {
+ RangeSet_Range* range = self->ranges + r_i;
+
+ if( ind >= range->begin && ind < range->end ) {
+ if( !((ind - range->begin) % range->step) )
+ return True;
+ }
+ }
+
+ return False;
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/
+
+int RangeSet_SortCmp( const void* itema, const void* itemb ) {
+ assert( itema && itemb );
+ return *((unsigned*)itema) - *((unsigned*)itemb);
+}
+
+
+void RangeSet_Destruct( RangeSet* self ) {
+ assert( self );
+
+ KillArray( self->ranges );
+ self->nRanges = 0;
+ self->nInds = 0;
+}
Added: long/3D/Gale/trunk/src/StGermain/Base/Container/src/RangeSet.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/Container/src/RangeSet.h 2006-08-18 00:17:54 UTC (rev 4347)
+++ long/3D/Gale/trunk/src/StGermain/Base/Container/src/RangeSet.h 2006-08-18 00:17:57 UTC (rev 4348)
@@ -0,0 +1,110 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+*/
+/** \file
+** Role:
+**
+** Assumptions:
+**
+** Invariants:
+**
+** Comments:
+**
+** $Id: RangeSet.h 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __Base_Container_RangeSet_h__
+#define __Base_Container_RangeSet_h__
+
+ /** Textual name of this class */
+ extern const Type RangeSet_Type;
+
+ /** Virtual function types */
+
+ /** Mesh class contents */
+ typedef struct {
+ unsigned begin;
+ unsigned end;
+ unsigned step;
+ } RangeSet_Range;
+
+ #define __RangeSet \
+ /* General info */ \
+ __Stg_Class \
+ \
+ /* Virtual info */ \
+ \
+ /* RangeSet info */ \
+ unsigned nInds; \
+ unsigned nRanges; \
+ RangeSet_Range* ranges;
+
+ struct RangeSet { __RangeSet };
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Constructors
+ */
+
+ #define RANGESET_DEFARGS \
+ STG_CLASS_DEFARGS
+
+ #define RANGESET_PASSARGS \
+ STG_CLASS_PASSARGS
+
+ RangeSet* RangeSet_New();
+ RangeSet* _RangeSet_New( RANGESET_DEFARGS );
+ void _RangeSet_Init( RangeSet* self );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Virtual functions
+ */
+
+ void _RangeSet_Delete( void* rangeSet );
+ void _RangeSet_Print( void* rangeSet, Stream* stream );
+
+ #define RangeSet_Copy( self ) \
+ (Mesh*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
+ #define RangeSet_DeepCopy( self ) \
+ (Mesh*)Stg_Class_Copy( self, NULL, True, NULL, NULL )
+ void* _RangeSet_Copy( void* rangeSet, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Public functions
+ */
+
+ void RangeSet_SetIndices( void* rangeSet, unsigned nInds, unsigned* inds );
+ Bool RangeSet_HasIndex( void* rangeSet, unsigned ind );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Private Member functions
+ */
+
+ int RangeSet_SortCmp( const void* itema, const void* itemb );
+ void RangeSet_Destruct( RangeSet* self );
+
+#endif /* __Base_Container_RangeSet_h__ */
Modified: long/3D/Gale/trunk/src/StGermain/Base/Container/src/types.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/Container/src/types.h 2006-08-18 00:17:54 UTC (rev 4347)
+++ long/3D/Gale/trunk/src/StGermain/Base/Container/src/types.h 2006-08-18 00:17:57 UTC (rev 4348)
@@ -64,6 +64,7 @@
typedef struct _Heap _Heap;
typedef struct MaxHeap MaxHeap;
typedef struct UIntMap UIntMap;
+ typedef struct RangeSet RangeSet;
typedef char BitField;
More information about the cig-commits
mailing list