[cig-commits] r4872 - in long/3D/Gale/trunk/src/StGermain: .
Discretisation/Mesh/tests
walter at geodynamics.org
walter at geodynamics.org
Wed Oct 11 13:48:01 PDT 2006
Author: walter
Date: 2006-10-11 13:48:01 -0700 (Wed, 11 Oct 2006)
New Revision: 4872
Modified:
long/3D/Gale/trunk/src/StGermain/
long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/tests/testCartesianGenerator.c
long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/tests/testCommTopology.c
long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/tests/testMeshTopology.c
Log:
r2929 at earth: boo | 2006-10-11 13:42:45 -0700
r2845 at earth (orig r3833): LukeHodkinson | 2006-10-04 18:24:10 -0700
Updating the tests.
Property changes on: long/3D/Gale/trunk/src/StGermain
___________________________________________________________________
Name: svk:merge
- 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:2928
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3832
+ 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:2929
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3833
Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/tests/testCartesianGenerator.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/tests/testCartesianGenerator.c 2006-10-11 20:47:59 UTC (rev 4871)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/tests/testCartesianGenerator.c 2006-10-11 20:48:01 UTC (rev 4872)
@@ -39,17 +39,6 @@
#include "Discretisation/Mesh/Mesh.h"
-Bool testSetParams( unsigned rank, unsigned nProcs, unsigned watch );
-Bool testGen( unsigned rank, unsigned nProcs, unsigned watch );
-
-
-#define nTests 2
-
-TestSuite* suite;
-TestSuite_Test tests[nTests] = {{"set parameters", testSetParams},
- {"generate mesh", testGen}};
-
-
Bool testSetParams( unsigned rank, unsigned nProcs, unsigned watch ) {
CartesianGenerator* gen;
unsigned sizes[3];
@@ -70,14 +59,19 @@
CartesianGenerator* gen;
Mesh* mesh;
unsigned sizes[3];
+ double min[3] = {0, 0, 0};
+ double max[3] = {1, 1, 1};
- sizes[0] = 2;
- sizes[1] = 1;
- sizes[2] = 1;
+ sizes[0] = 128;
+ sizes[1] = 128;
+ sizes[2] = 128;
gen = CartesianGenerator_New( "" );
mesh = Mesh_DefaultNew( "" );
+ mesh->topo = MeshTopology_New( "" );
+ mesh->info = ExtensionManager_New_OfExistingObject( "mesh_info", mesh );
CartesianGenerator_SetTopologyParams( gen, 3, sizes );
+ CartesianGenerator_SetGeometryParams( gen, min, max );
CartesianGenerator_Generate( gen, mesh );
FreeObject( gen );
@@ -86,7 +80,15 @@
}
+#define nTests 2
+
+TestSuite_Test tests[nTests] = {{"set parameters", testSetParams, 0},
+ {"generate mesh", testGen, 1}};
+
+
int main( int argc, char* argv[] ) {
+ TestSuite* suite;
+
/* Initialise MPI, get world info. */
MPI_Init( &argc, &argv );
Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/tests/testCommTopology.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/tests/testCommTopology.c 2006-10-11 20:47:59 UTC (rev 4871)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/tests/testCommTopology.c 2006-10-11 20:48:01 UTC (rev 4872)
@@ -24,7 +24,7 @@
** 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: testRangeSet.c 2136 2004-09-30 02:47:13Z PatrickSunter $
+** $Id: testCommTopology.c 2136 2004-09-30 02:47:13Z PatrickSunter $
**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
@@ -39,111 +39,293 @@
#include "Discretisation/Mesh/Mesh.h"
+CommTopology* buildCompleteIncidence( unsigned rank, unsigned nProcs,
+ unsigned* nInc, unsigned** inc )
+{
+ CommTopology* commTopo;
+ unsigned inc_i;
+
+ commTopo = CommTopology_New( "" );
+
+ *nInc = nProcs - 1;
+ if( nProcs > 1 ) {
+ *inc = Memory_Alloc_Array_Unnamed( unsigned, *nInc );
+
+ for( inc_i = 0; inc_i < *nInc; inc_i++ )
+ (*inc)[inc_i] = (rank + 1) % nProcs;
+
+ CommTopology_SetIncidence( commTopo, *nInc, *inc );
+ }
+ else
+ *inc = NULL;
+
+ return commTopo;
+}
+
+CommTopology* buildPartialIncidence( unsigned rank, unsigned nProcs,
+ unsigned* nInc, unsigned** inc )
+{
+ CommTopology* commTopo;
+
+ commTopo = CommTopology_New( "" );
+
+ if( nProcs > 1 ) {
+ *nInc = (rank == 0 || rank == nProcs - 1) ? 1 : 2;
+ *inc = Memory_Alloc_Array_Unnamed( unsigned, *nInc );
+
+ if( rank > 0 )
+ (*inc)[0] = rank - 1;
+ if( rank < nProcs - 1 )
+ (*inc)[(rank > 0) ? 1 : 0] = rank + 1;
+
+ CommTopology_SetIncidence( commTopo, *nInc, *inc );
+ }
+ else {
+ *nInc = 0;
+ *inc = NULL;
+ }
+
+ return commTopo;
+}
+
+void buildGatherArrays( unsigned rank, unsigned nProcs,
+ unsigned* srcSize, unsigned** src )
+{
+ unsigned p_i;
+
+ *srcSize = nProcs;
+ *src = Memory_Alloc_Array_Unnamed( unsigned, *srcSize );
+ for( p_i = 0; p_i < *srcSize; p_i++ )
+ (*src)[p_i] = rank;
+}
+
+void buildAlltoallArrays( unsigned rank, unsigned nProcs, CommTopology* commTopo,
+ unsigned** srcSizes, unsigned*** srcs )
+{
+ unsigned p_i, p_j;
+
+ if( !commTopo->nInc ) {
+ *srcSizes = NULL;
+ *srcs = NULL;
+ return;
+ }
+
+ *srcSizes = Memory_Alloc_Array_Unnamed( unsigned, commTopo->nInc );
+ *srcs = Memory_Alloc_2DArray_Unnamed( unsigned, commTopo->nInc, nProcs );
+ for( p_i = 0; p_i < commTopo->nInc; p_i++ ) {
+ (*srcSizes)[p_i] = nProcs;
+ for( p_j = 0; p_j < nProcs; p_j++ )
+ (*srcs)[p_i][p_j] = rank;
+ }
+}
+
+
Bool testConstruct( unsigned rank, unsigned nProcs, unsigned watch ) {
- CommTopology* topo;
+ CommTopology* commTopo;
- topo = CommTopology_New( "" );
- FreeObject( topo );
+ commTopo = CommTopology_New( "" );
+ FreeObject( commTopo );
return True;
}
-
Bool testSetComm( unsigned rank, unsigned nProcs, unsigned watch ) {
- CommTopology* topo;
+ CommTopology* commTopo;
+ Bool result = True;
- topo = CommTopology_New( "" );
+ commTopo = CommTopology_New( "" );
- CommTopology_SetComm( topo, MPI_COMM_WORLD );
+ CommTopology_SetComm( commTopo, MPI_COMM_WORLD );
if( rank == watch ) {
- if( topo->comm != MPI_COMM_WORLD ||
- topo->nInc != 0 ||
- topo->inc != NULL )
+ if( commTopo->comm != MPI_COMM_WORLD ||
+ commTopo->nInc != 0 ||
+ commTopo->inc != NULL )
{
- FreeObject( topo );
- return False;
+ result = False;
+ goto done;
}
}
- FreeObject( topo );
+done:
+ FreeObject( commTopo );
- return True;
+ return result;
}
+Bool testEmptyInc( unsigned rank, unsigned nProcs, unsigned watch ) {
+ CommTopology* commTopo;
+ Bool result = True;
-Bool testIncidence( unsigned rank, unsigned nProcs, unsigned watch ) {
- CommTopology* topo;
- unsigned nInc = nProcs - 1;
+ commTopo = CommTopology_New( "" );
+ CommTopology_SetIncidence( commTopo, 0, NULL );
+
+ if( rank == watch ) {
+ if( commTopo->comm != MPI_COMM_WORLD ||
+ commTopo->nInc != 0 ||
+ commTopo->inc != NULL )
+ {
+ result = False;
+ goto done;
+ }
+ }
+
+done:
+ FreeObject( commTopo );
+
+ return result;
+}
+
+Bool testCompInc( unsigned rank, unsigned nProcs, unsigned watch ) {
+ CommTopology* commTopo;
+ Bool result = True;
+ unsigned nInc;
unsigned* inc;
unsigned inc_i;
- topo = CommTopology_New( "" );
+ commTopo = buildCompleteIncidence( rank, nProcs, &nInc, &inc );
- if( nInc )
- inc = Memory_Alloc_Array_Unnamed( unsigned, nInc );
- else
- inc = NULL;
- for( inc_i = 0; inc_i < nInc; inc_i++ )
- inc[inc_i] = (rank + 1) % nProcs;
+ if( rank == watch ) {
+ if( commTopo->comm != MPI_COMM_WORLD ||
+ commTopo->nInc != nInc )
+ {
+ result = False;
+ goto done;
+ }
- CommTopology_SetIncidence( topo, nInc, inc );
+ for( inc_i = 0; inc_i < nInc; inc_i++ )
+ if( commTopo->inc[inc_i] != inc[inc_i] ) break;
+ if( inc_i < nInc ) {
+ result = False;
+ goto done;
+ }
+ }
+done:
+ FreeArray( inc );
+ FreeObject( commTopo );
+
+ return result;
+}
+
+Bool testPartInc( unsigned rank, unsigned nProcs, unsigned watch ) {
+ CommTopology* commTopo;
+ Bool result = True;
+ unsigned nInc;
+ unsigned* inc;
+ unsigned inc_i;
+
+ commTopo = buildPartialIncidence( rank, nProcs, &nInc, &inc );
+
if( rank == watch ) {
- if( topo->comm != MPI_COMM_WORLD ||
- topo->nInc != nInc )
+ if( commTopo->comm != MPI_COMM_WORLD ||
+ commTopo->nInc != nInc )
{
- FreeArray( inc );
- FreeObject( topo );
- return False;
+ result = False;
+ goto done;
}
for( inc_i = 0; inc_i < nInc; inc_i++ )
- if( inc[inc_i] != (rank + 1) % nProcs ) break;
+ if( commTopo->inc[inc_i] != inc[inc_i] ) break;
if( inc_i < nInc ) {
- FreeArray( inc );
- FreeObject( topo );
- return False;
+ result = False;
+ goto done;
}
}
- FreeObject( topo );
+done:
+ FreeArray( inc );
+ FreeObject( commTopo );
- return True;
+ return result;
}
-
Bool testAllgather( unsigned rank, unsigned nProcs, unsigned watch ) {
- CommTopology* topo;
- unsigned nInc = nProcs - 1;
+ CommTopology* commTopo;
+ Bool result = True;
+ unsigned nInc;
unsigned* inc;
- unsigned inc_i;
+ unsigned srcSize;
+ unsigned* src;
+ unsigned* dstSizes;
+ unsigned** dst;
+ unsigned p_i, e_i;
- topo = CommTopology_New( "" );
+ commTopo = buildPartialIncidence( rank, nProcs, &nInc, &inc );
+ buildGatherArrays( rank, nProcs, &srcSize, &src );
- if( nInc )
- inc = Memory_Alloc_Array_Unnamed( unsigned, nInc );
- else
- inc = NULL;
- for( inc_i = 0; inc_i < nInc; inc_i++ )
- inc[inc_i] = (rank + 1) % nProcs;
+ CommTopology_Allgather( commTopo, srcSize, src, &dstSizes, (void***)&dst, sizeof(unsigned) );
- CommTopology_SetIncidence( topo, nInc, inc );
+ if( rank == watch ) {
+ for( p_i = 0; p_i < commTopo->nInc; p_i++ ) {
+ for( e_i = 0; e_i < srcSize; e_i++ ) {
+ if( dst[p_i][e_i] != commTopo->inc[p_i] ) {
+ result = False;
+ goto done;
+ }
+ }
+ }
+ }
- /* TODO */
+done:
+ FreeObject( commTopo );
+ FreeArray( inc );
+ FreeArray( src );
+ FreeArray( dst );
- FreeObject( topo );
+ return result;
+}
- return True;
+Bool testAlltoall( unsigned rank, unsigned nProcs, unsigned watch ) {
+ CommTopology* commTopo;
+ Bool result = True;
+ unsigned nInc;
+ unsigned* inc;
+ unsigned* srcSizes;
+ unsigned** srcs;
+ unsigned* dstSizes;
+ unsigned** dst;
+ unsigned p_i, e_i;
+
+ commTopo = buildPartialIncidence( rank, nProcs, &nInc, &inc );
+ buildAlltoallArrays( rank, nProcs, commTopo, &srcSizes, &srcs );
+
+ CommTopology_Alltoall( commTopo, srcSizes, srcs, &dstSizes, (void***)&dst, sizeof(unsigned) );
+
+ if( rank == watch ) {
+ for( p_i = 0; p_i < commTopo->nInc; p_i++ ) {
+ for( e_i = 0; e_i < srcSizes[p_i]; e_i++ ) {
+ if( dst[p_i][e_i] != commTopo->inc[p_i] ) {
+ result = False;
+ goto done;
+ }
+ }
+ }
+ }
+
+done:
+ FreeObject( commTopo );
+ FreeArray( inc );
+ FreeArray( srcSizes );
+ FreeArray( srcs );
+ FreeArray( dst );
+
+ return result;
}
+#define nTests 7
+
+TestSuite_Test tests[nTests] = {{"construct", testConstruct, 10},
+ {"set communicator", testSetComm, 10},
+ {"empty incidence", testEmptyInc, 10 },
+ {"partial incidence", testPartInc, 10},
+ {"complete incidence", testCompInc, 10},
+ {"all gather", testAllgather, 10},
+ {"all to all", testAlltoall, 10}};
+
+
int main( int argc, char* argv[] ) {
TestSuite* suite;
- unsigned nTests = 4;
- TestSuite_Test tests[4] = {{"construct", testConstruct},
- {"set communicator", testSetComm},
- {"incidence", testIncidence},
- {"all gather", testAllgather}};
/* Initialise MPI, get world info. */
MPI_Init( &argc, &argv );
Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/tests/testMeshTopology.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/tests/testMeshTopology.c 2006-10-11 20:47:59 UTC (rev 4871)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/tests/testMeshTopology.c 2006-10-11 20:48:01 UTC (rev 4872)
@@ -46,7 +46,6 @@
#define nTests 1
-TestSuite* suite;
TestSuite_Test tests[nTests] = {{"set elements", testSetElements}};
@@ -93,6 +92,8 @@
int main( int argc, char* argv[] ) {
+ TestSuite* suite;
+
/* Initialise MPI, get world info. */
MPI_Init( &argc, &argv );
More information about the cig-commits
mailing list