[cig-commits] r4350 - in long/3D/Gale/trunk/src/StGermain: . Base/Container/tests

walter at geodynamics.org walter at geodynamics.org
Thu Aug 17 17:18:01 PDT 2006


Author: walter
Date: 2006-08-17 17:18:00 -0700 (Thu, 17 Aug 2006)
New Revision: 4350

Added:
   long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testRangeSet.0of1.expected
   long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testRangeSet.0of1.sh
   long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testRangeSet.c
Modified:
   long/3D/Gale/trunk/src/StGermain/
   long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.0of1.expected
   long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.0of2.expected
   long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.0of3.expected
   long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.1of2.expected
   long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.1of3.expected
   long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.2of3.expected
   long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.c
Log:
 r2720 at earth:  boo | 2006-08-17 17:14:28 -0700
  r2674 at earth (orig r3755):  LukeHodkinson | 2006-08-07 22:23:23 -0700
  Updated the container class tests to reflect 
  recent additions and modifications.
  
 



Property changes on: long/3D/Gale/trunk/src/StGermain
___________________________________________________________________
Name: svk:merge
   - 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:2719
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3754
   + 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:2720
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3755

Modified: long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.0of1.expected
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.0of1.expected	2006-08-18 00:17:57 UTC (rev 4349)
+++ long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.0of1.expected	2006-08-18 00:18:00 UTC (rev 4350)
@@ -1,3 +1,4 @@
+Testing array broadcast... passed
 Testing array conversion... passed
 Testing array gather... passed
 Testing array gather to all... passed

Modified: long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.0of2.expected
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.0of2.expected	2006-08-18 00:17:57 UTC (rev 4349)
+++ long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.0of2.expected	2006-08-18 00:18:00 UTC (rev 4350)
@@ -1,3 +1,4 @@
+Testing array broadcast... passed
 Testing array conversion... passed
 Testing array gather... passed
 Testing array gather to all... passed

Modified: long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.0of3.expected
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.0of3.expected	2006-08-18 00:17:57 UTC (rev 4349)
+++ long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.0of3.expected	2006-08-18 00:18:00 UTC (rev 4350)
@@ -1,3 +1,4 @@
+Testing array broadcast... passed
 Testing array conversion... passed
 Testing array gather... passed
 Testing array gather to all... passed

Modified: long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.1of2.expected
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.1of2.expected	2006-08-18 00:17:57 UTC (rev 4349)
+++ long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.1of2.expected	2006-08-18 00:18:00 UTC (rev 4350)
@@ -1,3 +1,4 @@
+Testing array broadcast... passed
 Testing array conversion... passed
 Testing array gather... passed
 Testing array gather to all... passed

Modified: long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.1of3.expected
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.1of3.expected	2006-08-18 00:17:57 UTC (rev 4349)
+++ long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.1of3.expected	2006-08-18 00:18:00 UTC (rev 4350)
@@ -1,3 +1,4 @@
+Testing array broadcast... passed
 Testing array conversion... passed
 Testing array gather... passed
 Testing array gather to all... passed

Modified: long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.2of3.expected
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.2of3.expected	2006-08-18 00:17:57 UTC (rev 4349)
+++ long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.2of3.expected	2006-08-18 00:18:00 UTC (rev 4350)
@@ -1,3 +1,4 @@
+Testing array broadcast... passed
 Testing array conversion... passed
 Testing array gather... passed
 Testing array gather to all... passed

Modified: long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.c	2006-08-18 00:17:57 UTC (rev 4349)
+++ long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testMPIRoutines.c	2006-08-18 00:18:00 UTC (rev 4350)
@@ -37,6 +37,8 @@
 #include "Base/IO/IO.h"
 #include "Base/Container/Container.h"
 
+
+Bool testBcast( unsigned rank, unsigned nProcs, unsigned watch );
 Bool testArrayConv( unsigned rank, unsigned nProcs, unsigned watch );
 Bool testGather( unsigned rank, unsigned nProcs, unsigned watch );
 Bool testAllgather( unsigned rank, unsigned nProcs, unsigned watch );
@@ -62,6 +64,10 @@
 	watch = (argc >= 2) ? atoi( argv[1] ) : 0;
 
 	/* Run some tests. */
+	result = testBcast( rank, nProcs, watch );
+	if( rank == watch )
+		printf( "Testing array broadcast... %s\n", result ? "passed" : "failed" );
+
 	result = testArrayConv( rank, nProcs, watch );
 	if( rank == watch )
 		printf( "Testing array conversion... %s\n", result ? "passed" : "failed" );
@@ -85,6 +91,7 @@
 
 	/* Close off MPI */
 	MPI_Finalize();
+	mem_finalise();
 
 	return MPI_SUCCESS;
 }
@@ -157,14 +164,44 @@
 		array[i] = rank * size + i;
 }
 
+Bool testBcast( unsigned rank, unsigned nProcs, unsigned watch ) {
+	unsigned	size = 200;
+	unsigned*	src;
+
+	if( rank == 0 ) {
+		src = Memory_Alloc_Array_Unnamed( unsigned, size );
+		fillArray( src, size, rank );
+	}
+
+	MPIArray_Bcast( &size, (void**)&src, sizeof(unsigned), 
+			0, MPI_COMM_WORLD );
+
+	if( rank == watch ) {
+		unsigned	i;
+
+		for( i = 0; i < size; i++ )
+			if( src[i] != i ) break;
+		if( i < size ) {
+			if( rank != 0 )
+				FreeArray( src );
+			return False;
+		}
+	}
+
+	if( rank != 0 )
+		FreeArray( src );
+
+	return True;
+}
+
 Bool testGather( unsigned rank, unsigned nProcs, unsigned watch ) {
 	unsigned	size = 200;
 	unsigned	src[200];
 	unsigned*	dstSizes;
-	unsigned*	dstArray;
+	unsigned**	dstArrays;
 
 	fillArray( src, size, rank );
-	MPIArray_Gather( size, src, &dstSizes, (void**)&dstArray, sizeof(unsigned), watch, MPI_COMM_WORLD );
+	MPIArray_Gather( size, src, &dstSizes, (void***)&dstArrays, sizeof(unsigned), watch, MPI_COMM_WORLD );
 	if( rank == watch ) {
 		unsigned	 i;
 
@@ -172,20 +209,25 @@
 			if( dstSizes[i] != size ) break;
 		if( i < nProcs ) {
 			FreeArray( dstSizes );
-			FreeArray( dstArray );
+			FreeArray2D( nProcs, dstArrays );
 			return False;
 		}
 
-		for( i = 0; i < nProcs * size; i++ )
-			if( dstArray[i] != i ) break;
-		if( i < nProcs * size ) {
+		for( i = 0; i < nProcs; i++ ) {
+			unsigned	j;
+
+			for( j = 0; j < size; j++ )
+				if( dstArrays[i][j] != i * size + j ) break;
+			if( j < size ) break;
+		}
+		if( i < nProcs ) {
 			FreeArray( dstSizes );
-			FreeArray( dstArray );
+			FreeArray2D( nProcs, dstArrays );
 			return False;
 		}
 
 		FreeArray( dstSizes );
-		FreeArray( dstArray );
+		FreeArray2D( nProcs, dstArrays );
 	}
 
 	return True;

Added: long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testRangeSet.0of1.expected
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testRangeSet.0of1.expected	2006-08-18 00:17:57 UTC (rev 4349)
+++ long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testRangeSet.0of1.expected	2006-08-18 00:18:00 UTC (rev 4350)
@@ -0,0 +1,3 @@
+   Running test 'construct'... passed
+   Running test 'set indices'... passed
+   Running test 'ranges'... passed

Added: long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testRangeSet.0of1.sh
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testRangeSet.0of1.sh	2006-08-18 00:17:57 UTC (rev 4349)
+++ long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testRangeSet.0of1.sh	2006-08-18 00:18:00 UTC (rev 4350)
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+TEST_SCRIPT=./VMake/executableTester.sh
+until test -r ${TEST_SCRIPT} ; do
+        TEST_SCRIPT=../${TEST_SCRIPT}
+done
+. ${TEST_SCRIPT}
+
+runAndHandleSystemTest "testRangeSet " "$0" "$@"


Property changes on: long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testRangeSet.0of1.sh
___________________________________________________________________
Name: svn:executable
   + *

Added: long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testRangeSet.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testRangeSet.c	2006-08-18 00:17:57 UTC (rev 4349)
+++ long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testRangeSet.c	2006-08-18 00:18:00 UTC (rev 4350)
@@ -0,0 +1,190 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** 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: testRangeSet.c 2136 2004-09-30 02:47:13Z 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 "Base/Container/Container.h"
+
+
+Bool testConstruct( unsigned rank, unsigned nProcs, unsigned watch );
+Bool testSetIndices( unsigned rank, unsigned nProcs, unsigned watch );
+Bool testRanges( unsigned rank, unsigned nProcs, unsigned watch );
+
+
+void runTest( const char* desc, Bool (test)( unsigned, unsigned, unsigned ), 
+	      unsigned nReps, unsigned rank, unsigned nProcs, unsigned watch )
+{
+	unsigned	success = 0;
+	unsigned	failure = 1;
+	unsigned	r_i;
+
+	assert( desc );
+	assert( test );
+
+	if( rank == watch )
+		printf( "   Running test '%s'... ", desc );
+
+	for( r_i = 0; r_i < nReps; r_i++ ) {
+		Bool	result = test( rank, nProcs, watch );
+
+		if( rank == watch ) {
+			if( result )
+				MPI_Bcast( &success, 1, MPI_UNSIGNED, watch, MPI_COMM_WORLD );
+			else {
+				MPI_Bcast( &failure, 1, MPI_UNSIGNED, watch, MPI_COMM_WORLD );
+				break;
+			}
+		}
+		else {
+			unsigned	status;
+
+			MPI_Bcast( &status, 1, MPI_UNSIGNED, watch, MPI_COMM_WORLD );
+			if( status == failure ) break;
+		}
+	}
+
+	if( rank == watch )
+		printf( "%s\n", (r_i == nReps) ? "passed" : "failed" );
+}
+
+
+int main( int argc, char* argv[] ) {
+	unsigned	rank;
+	unsigned	nProcs;
+	unsigned	watch;
+
+	/* Initialise MPI, get world info. */
+	MPI_Init( &argc, &argv );
+	MPI_Comm_size( MPI_COMM_WORLD, (int*)&nProcs );
+	MPI_Comm_rank( MPI_COMM_WORLD, (int*)&rank );
+
+	/* Initialise StGermain. */
+	BaseFoundation_Init( &argc, &argv );
+	BaseIO_Init( &argc, &argv );
+	BaseContainer_Init( &argc, &argv );
+
+	/* Watching a particular processor? */
+	watch = (argc >= 2) ? atoi( argv[1] ) : 0;
+
+	/* Run some tests. */
+	runTest( "construct", testConstruct, 10, rank, nProcs, watch );
+	runTest( "set indices", testSetIndices, 10, rank, nProcs, watch );
+	runTest( "ranges", testRanges, 10, rank, nProcs, watch );
+
+	/* Finalise StGermain. */
+	BaseContainer_Finalise();
+	BaseIO_Finalise();
+	BaseFoundation_Finalise();
+
+	/* Close off MPI */
+	MPI_Finalize();
+
+	return MPI_SUCCESS;
+}
+
+
+Bool testConstruct( unsigned rank, unsigned nProcs, unsigned watch ) {
+	RangeSet*	set;
+
+	set = RangeSet_New();
+	FreeObject( set );
+
+	return True;
+}
+
+
+Bool testSetIndices( unsigned rank, unsigned nProcs, unsigned watch ) {
+	unsigned	nInds = 100;
+	unsigned	inds[100];
+	RangeSet*	set;
+	unsigned	i;
+
+	for( i = 0; i < nInds; i++ )
+		inds[i] = i;
+
+	set = RangeSet_New();
+
+	RangeSet_SetIndices( set, nInds, inds );
+	if( rank == watch ) {
+		if( set->nInds != nInds || 
+		    set->nRanges != 1 )
+		{
+			FreeObject( set );
+			return False;
+		}
+	}
+
+	FreeObject( set );
+
+	return True;
+}
+
+
+Bool testRanges( unsigned rank, unsigned nProcs, unsigned watch ) {
+	unsigned	nInds = 100;
+	unsigned	inds[100];
+	RangeSet*	set;
+	unsigned	i;
+
+	for( i = 0; i < nInds; i++ )
+		inds[i] = (i/10)*10 + i;
+
+	set = RangeSet_New();
+
+	RangeSet_SetIndices( set, nInds, inds );
+	if( rank == watch ) {
+		if( set->nInds != nInds || 
+		    set->nRanges != nInds/10 )
+		{
+			FreeObject( set );
+			return False;
+		}
+
+		for( i = 0; i < nInds; i++ ) {
+			if( set->ranges[i/10].begin != (i/10)*20 || 
+			    set->ranges[i/10].end != (i/10)*20 + 10 || 
+			    set->ranges[i/10].step != 1 )
+			{
+				FreeObject( set );
+				return False;
+			}
+		}
+	}
+
+	FreeObject( set );
+
+	return True;
+}



More information about the cig-commits mailing list