[mpich-commits] [mpich] MPICH primary repository branch, master, updated. v3.2b4-37-gb722a24
Service Account
noreply at mpich.org
Thu Jul 30 13:35:10 CDT 2015
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "MPICH primary repository".
The branch, master has been updated
via b722a2422dbda5c0a54c60b0be1eff1c47e34845 (commit)
from 6f6a07100dacb5d2ee2e61d4829fd7fe20b8929c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.mpich.org/mpich.git/commitdiff/b722a2422dbda5c0a54c60b0be1eff1c47e34845
commit b722a2422dbda5c0a54c60b0be1eff1c47e34845
Author: Pavan Balaji <balaji at anl.gov>
Date: Thu Jul 30 13:31:13 2015 -0500
White space cleanup of the test suite.
Signed-off-by: Ken Raffenetti <raffenet at mcs.anl.gov>
diff --git a/test/mpi/attr/attr2type.c b/test/mpi/attr/attr2type.c
index 68072c1..1ab9e20 100644
--- a/test/mpi/attr/attr2type.c
+++ b/test/mpi/attr/attr2type.c
@@ -14,10 +14,10 @@ int foo_initialize(void);
void foo_finalize(void);
int foo_copy_attr_function(MPI_Datatype type, int type_keyval,
- void *extra_state, void *attribute_val_in,
- void *attribute_val_out, int *flag);
+ void *extra_state, void *attribute_val_in,
+ void *attribute_val_out, int *flag);
int foo_delete_attr_function(MPI_Datatype type, int type_keyval,
- void *attribute_val, void *extra_state);
+ void *attribute_val, void *extra_state);
static const char *my_func = 0;
static int verbose = 0;
static int delete_called = 0;
@@ -30,8 +30,8 @@ int main(int argc, char *argv[])
int rank;
MPI_Init(&argc, &argv);
-
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
foo_initialize();
@@ -50,22 +50,22 @@ int main(int argc, char *argv[])
foo_finalize();
if (rank == 0) {
- int errs = 0;
- if (copy_called != 1) {
- printf( "Copy called %d times; expected once\n", copy_called );
- errs++;
- }
- if (delete_called != 2) {
- printf( "Delete called %d times; expected twice\n", delete_called );
- errs++;
- }
- if (errs == 0) {
- printf( " No Errors\n" );
- }
- else {
- printf( " Found %d errors\n", errs );
- }
- fflush(stdout);
+ int errs = 0;
+ if (copy_called != 1) {
+ printf("Copy called %d times; expected once\n", copy_called);
+ errs++;
+ }
+ if (delete_called != 2) {
+ printf("Delete called %d times; expected twice\n", delete_called);
+ errs++;
+ }
+ if (errs == 0) {
+ printf(" No Errors\n");
+ }
+ else {
+ printf(" Found %d errors\n", errs);
+ }
+ fflush(stdout);
}
MPI_Finalize();
@@ -73,27 +73,25 @@ int main(int argc, char *argv[])
}
int foo_copy_attr_function(MPI_Datatype type,
- int type_keyval,
- void *extra_state,
- void *attribute_val_in,
- void *attribute_val_out,
- int *flag)
+ int type_keyval,
+ void *extra_state,
+ void *attribute_val_in, void *attribute_val_out, int *flag)
{
- if (verbose) printf("copy fn. called\n");
- copy_called ++;
- * (char **) attribute_val_out = NULL;
+ if (verbose)
+ printf("copy fn. called\n");
+ copy_called++;
+ *(char **) attribute_val_out = NULL;
*flag = 1;
return MPI_SUCCESS;
}
int foo_delete_attr_function(MPI_Datatype type,
- int type_keyval,
- void *attribute_val,
- void *extra_state)
+ int type_keyval, void *attribute_val, void *extra_state)
{
- if (verbose) printf("delete fn. called in %s\n", my_func );
- delete_called ++;
+ if (verbose)
+ printf("delete fn. called in %s\n", my_func);
+ delete_called++;
return MPI_SUCCESS;
}
@@ -104,10 +102,9 @@ int foo_initialize(void)
/* create keyval for use later */
mpi_errno = MPI_Type_create_keyval(foo_copy_attr_function,
- foo_delete_attr_function,
- &foo_keyval,
- NULL);
- if (verbose) printf("created keyval\n");
+ foo_delete_attr_function, &foo_keyval, NULL);
+ if (verbose)
+ printf("created keyval\n");
return 0;
}
@@ -119,7 +116,8 @@ void foo_finalize(void)
/* remove keyval */
mpi_errno = MPI_Type_free_keyval(&foo_keyval);
- if (verbose) printf("freed keyval\n");
+ if (verbose)
+ printf("freed keyval\n");
return;
}
diff --git a/test/mpi/attr/attrdeleteget.c b/test/mpi/attr/attrdeleteget.c
index f709579..fdfea46 100644
--- a/test/mpi/attr/attrdeleteget.c
+++ b/test/mpi/attr/attrdeleteget.c
@@ -12,9 +12,9 @@
int key = MPI_KEYVAL_INVALID;
char a[100];
-int delete_fn (MPI_Comm, int, void *, void *);
+int delete_fn(MPI_Comm, int, void *, void *);
-int main(int argc,char **argv)
+int main(int argc, char **argv)
{
MPI_Comm scomm;
int errs = 0;
@@ -24,28 +24,29 @@ int main(int argc,char **argv)
MPI_Comm_create_keyval(MPI_NULL_COPY_FN, delete_fn, &key, &errs);
MPI_Comm_set_attr(scomm, key, a);
MPI_Comm_free(&scomm);
- MPI_Comm_free_keyval( &key );
+ MPI_Comm_free_keyval(&key);
MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
-int delete_fn(MPI_Comm comm,int keyval,void *attr_val,void *extra_state)
+int delete_fn(MPI_Comm comm, int keyval, void *attr_val, void *extra_state)
{
/* The standard is not explicit that the 'comm' argument of
* delete_fn must be valid, so this test is only in effect when
* !USE_STRICT_MPI. */
#ifndef USE_STRICT_MPI
- int err,flg,*errs = extra_state;
+ int err, flg, *errs = extra_state;
void *ptr;
if (comm == MPI_COMM_NULL) {
printf("MPI_COMM_NULL passed to delete_fn\n");
(*errs)++;
}
- err = MPI_Comm_get_attr(comm,key,&ptr,&flg);
+ err = MPI_Comm_get_attr(comm, key, &ptr, &flg);
if (err != MPI_SUCCESS) {
- printf("MPI_Comm_get_attr returned error %d, presumably due to invalid communicator\n", err);
+ printf("MPI_Comm_get_attr returned error %d, presumably due to invalid communicator\n",
+ err);
(*errs)++;
}
#endif
diff --git a/test/mpi/attr/attrend.c b/test/mpi/attr/attrend.c
index 37c4a1b..4e897c4 100644
--- a/test/mpi/attr/attrend.c
+++ b/test/mpi/attr/attrend.c
@@ -5,9 +5,9 @@
* See COPYRIGHT in top-level directory.
*/
/*
- The MPI-2 specification makes it clear that delect attributes are
+ The MPI-2 specification makes it clear that delect attributes are
called on MPI_COMM_WORLD and MPI_COMM_SELF at the very beginning of
- MPI_Finalize. This is useful for tools that want to perform the MPI
+ MPI_Finalize. This is useful for tools that want to perform the MPI
equivalent of an "at_exit" action.
*/
#include <stdio.h>
@@ -18,65 +18,64 @@ int exit_key = MPI_KEYVAL_INVALID;
int wasCalled = 0;
int foundError = 0;
/* #define DEBUG */
-int delete_fn ( MPI_Comm, int, void *, void * );
+int delete_fn(MPI_Comm, int, void *, void *);
#ifdef DEBUG
#define FFLUSH fflush(stdout);
#else
#define FFLUSH
#endif
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
int errs = 0, wrank;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
+
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
-
/* create the keyval for the exit handler */
- MPI_Keyval_create( MPI_NULL_COPY_FN, delete_fn, &exit_key, (void *)0 );
+ MPI_Keyval_create(MPI_NULL_COPY_FN, delete_fn, &exit_key, (void *) 0);
/* Attach to comm_self */
- MPI_Attr_put( MPI_COMM_SELF, exit_key, (void*)0 );
+ MPI_Attr_put(MPI_COMM_SELF, exit_key, (void *) 0);
/* We can free the key now */
- MPI_Keyval_free( &exit_key );
+ MPI_Keyval_free(&exit_key);
/* Now, exit MPI */
- /* MTest_Finalize( errs ); */
+ /* MTest_Finalize(errs); */
MPI_Finalize();
/* Check that the exit handler was called, and without error */
if (wrank == 0) {
- /* In case more than one process exits MPI_Finalize */
- if (wasCalled != 1) {
- errs++;
- printf( "Attribute delete function on MPI_COMM_SELF was not called\n" );
- }
- if (foundError != 0) {
- errs++;
- printf( "Found %d errors while executing delete function in MPI_COMM_SELF\n", foundError );
- }
- if (errs == 0) {
- printf( " No Errors\n" );
- }
- else {
- printf( " Found %d errors\n", errs );
- }
- fflush(stdout );
+ /* In case more than one process exits MPI_Finalize */
+ if (wasCalled != 1) {
+ errs++;
+ printf("Attribute delete function on MPI_COMM_SELF was not called\n");
+ }
+ if (foundError != 0) {
+ errs++;
+ printf("Found %d errors while executing delete function in MPI_COMM_SELF\n",
+ foundError);
+ }
+ if (errs == 0) {
+ printf(" No Errors\n");
+ }
+ else {
+ printf(" Found %d errors\n", errs);
+ }
+ fflush(stdout);
}
return 0;
}
-int delete_fn( MPI_Comm comm, int keyval, void *attribute_val,
- void *extra_state)
+int delete_fn(MPI_Comm comm, int keyval, void *attribute_val, void *extra_state)
{
int flag;
wasCalled++;
- MPI_Finalized( &flag );
+ MPI_Finalized(&flag);
if (flag) {
- foundError++;
+ foundError++;
}
return MPI_SUCCESS;
}
-
diff --git a/test/mpi/attr/attrend2.c b/test/mpi/attr/attrend2.c
index 8e4abc9..d71592b 100644
--- a/test/mpi/attr/attrend2.c
+++ b/test/mpi/attr/attrend2.c
@@ -22,10 +22,10 @@
* assuming a decent hash function is used. */
#define NUM_TEST_ATTRS (20)
-static int exit_keys[NUM_TEST_ATTRS]; /* init to MPI_KEYVAL_INVALID */
+static int exit_keys[NUM_TEST_ATTRS]; /* init to MPI_KEYVAL_INVALID */
static int was_called[NUM_TEST_ATTRS];
int foundError = 0;
-int delete_fn (MPI_Comm, int, void *, void *);
+int delete_fn(MPI_Comm, int, void *, void *);
int main(int argc, char **argv)
{
@@ -44,7 +44,7 @@ int main(int argc, char **argv)
/* create the keyval for the exit handler */
MPI_Comm_create_keyval(MPI_COMM_NULL_COPY_FN, delete_fn, &exit_keys[i], NULL);
/* attach to comm_self */
- MPI_Comm_set_attr(MPI_COMM_SELF, exit_keys[i], (void*)(long)i);
+ MPI_Comm_set_attr(MPI_COMM_SELF, exit_keys[i], (void *) (long) i);
}
/* we can free the keys now */
@@ -65,12 +65,15 @@ int main(int argc, char **argv)
}
else if (was_called[i] > 1) {
errs++;
- printf("Attribute delete function on MPI_COMM_SELF was called multiple times for idx=%d\n", i);
+ printf
+ ("Attribute delete function on MPI_COMM_SELF was called multiple times for idx=%d\n",
+ i);
}
}
if (foundError != 0) {
errs++;
- printf("Found %d errors while executing delete function in MPI_COMM_SELF\n", foundError);
+ printf("Found %d errors while executing delete function in MPI_COMM_SELF\n",
+ foundError);
}
if (errs == 0) {
printf(" No Errors\n");
@@ -93,7 +96,7 @@ int delete_fn(MPI_Comm comm, int keyval, void *attribute_val, void *extra_state)
{
int flag;
int i;
- int my_idx = (int)(long)attribute_val;
+ int my_idx = (int) (long) attribute_val;
if (my_idx < 0 || my_idx > NUM_TEST_ATTRS) {
printf("internal error, my_idx=%d is invalid!\n", my_idx);
@@ -125,4 +128,3 @@ int delete_fn(MPI_Comm comm, int keyval, void *attribute_val, void *extra_state)
return MPI_SUCCESS;
}
-
diff --git a/test/mpi/attr/attrerr.c b/test/mpi/attr/attrerr.c
index 39e3611..1799443 100644
--- a/test/mpi/attr/attrerr.c
+++ b/test/mpi/attr/attrerr.c
@@ -16,35 +16,35 @@
#include "mpi.h"
#include "mpitest.h"
-int test_communicators ( void );
-void abort_msg ( const char *, int );
-int copybomb_fn ( MPI_Comm, int, void *, void *, void *, int * );
-int deletebomb_fn ( MPI_Comm, int, void *, void * );
+int test_communicators(void);
+void abort_msg(const char *, int);
+int copybomb_fn(MPI_Comm, int, void *, void *, void *, int *);
+int deletebomb_fn(MPI_Comm, int, void *, void *);
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
int errs;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
errs = test_communicators();
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
-/*
- * MPI 1.2 Clarification: Clarification of Error Behavior of
- * Attribute Callback Functions
+/*
+ * MPI 1.2 Clarification: Clarification of Error Behavior of
+ * Attribute Callback Functions
* Any return value other than MPI_SUCCESS is erroneous. The specific value
* returned to the user is undefined (other than it can't be MPI_SUCCESS).
* Proposals to specify particular values (e.g., user's value) failed.
*/
/* Return an error as the value */
-int copybomb_fn( MPI_Comm oldcomm, int keyval, void *extra_state,
- void *attribute_val_in, void *attribute_val_out, int *flag)
+int copybomb_fn(MPI_Comm oldcomm, int keyval, void *extra_state,
+ void *attribute_val_in, void *attribute_val_out, int *flag)
{
/* Note that if (sizeof(int) < sizeof(void *), just setting the int
- part of attribute_val_out may leave some dirty bits
- */
+ * part of attribute_val_out may leave some dirty bits
+ */
*flag = 1;
return MPI_ERR_OTHER;
}
@@ -52,81 +52,79 @@ int copybomb_fn( MPI_Comm oldcomm, int keyval, void *extra_state,
/* Set delete flag to 1 to allow the attribute to be deleted */
static int delete_flag = 0;
-int deletebomb_fn( MPI_Comm comm, int keyval, void *attribute_val,
- void *extra_state)
+int deletebomb_fn(MPI_Comm comm, int keyval, void *attribute_val, void *extra_state)
{
- if (delete_flag) return MPI_SUCCESS;
+ if (delete_flag)
+ return MPI_SUCCESS;
return MPI_ERR_OTHER;
}
-void abort_msg( const char *str, int code )
+void abort_msg(const char *str, int code)
{
- fprintf( stderr, "%s, err = %d\n", str, code );
- MPI_Abort( MPI_COMM_WORLD, code );
+ fprintf(stderr, "%s, err = %d\n", str, code);
+ MPI_Abort(MPI_COMM_WORLD, code);
}
-int test_communicators( void )
+int test_communicators(void)
{
MPI_Comm dup_comm_world, d2;
int world_rank, world_size, key_1;
int err, errs = 0;
MPI_Aint value;
- MPI_Comm_rank( MPI_COMM_WORLD, &world_rank );
- MPI_Comm_size( MPI_COMM_WORLD, &world_size );
+ MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &world_size);
#ifdef DEBUG
if (world_rank == 0) {
- printf( "*** Attribute copy/delete return codes ***\n" );
+ printf("*** Attribute copy/delete return codes ***\n");
}
#endif
- MPI_Comm_dup( MPI_COMM_WORLD, &dup_comm_world );
- MPI_Barrier( dup_comm_world );
+ MPI_Comm_dup(MPI_COMM_WORLD, &dup_comm_world);
+ MPI_Barrier(dup_comm_world);
- MPI_Errhandler_set( dup_comm_world, MPI_ERRORS_RETURN );
+ MPI_Errhandler_set(dup_comm_world, MPI_ERRORS_RETURN);
- value = - 11;
- if ((err=MPI_Keyval_create( copybomb_fn, deletebomb_fn, &key_1, &value )))
- abort_msg( "Keyval_create", err );
+ value = -11;
+ if ((err = MPI_Keyval_create(copybomb_fn, deletebomb_fn, &key_1, &value)))
+ abort_msg("Keyval_create", err);
- err = MPI_Attr_put( dup_comm_world, key_1, (void *) (MPI_Aint) world_rank );
+ err = MPI_Attr_put(dup_comm_world, key_1, (void *) (MPI_Aint) world_rank);
if (err) {
- errs++;
- printf( "Error with first put\n" );
+ errs++;
+ printf("Error with first put\n");
}
- err = MPI_Attr_put( dup_comm_world, key_1,
- (void *) (MPI_Aint) (2*world_rank) );
+ err = MPI_Attr_put(dup_comm_world, key_1, (void *) (MPI_Aint) (2 * world_rank));
if (err == MPI_SUCCESS) {
- errs++;
- printf( "delete function return code was MPI_SUCCESS in put\n" );
+ errs++;
+ printf("delete function return code was MPI_SUCCESS in put\n");
}
/* Because the attribute delete function should fail, the attribute
- should *not be removed* */
- err = MPI_Attr_delete( dup_comm_world, key_1 );
+ * should *not be removed* */
+ err = MPI_Attr_delete(dup_comm_world, key_1);
if (err == MPI_SUCCESS) {
- errs++;
- printf( "delete function return code was MPI_SUCCESS in delete\n" );
+ errs++;
+ printf("delete function return code was MPI_SUCCESS in delete\n");
}
-
- err = MPI_Comm_dup( dup_comm_world, &d2 );
+
+ err = MPI_Comm_dup(dup_comm_world, &d2);
if (err == MPI_SUCCESS) {
- errs++;
- printf( "copy function return code was MPI_SUCCESS in dup\n" );
+ errs++;
+ printf("copy function return code was MPI_SUCCESS in dup\n");
}
#ifndef USE_STRICT_MPI
/* Another interpretation is to leave d2 unchanged on error */
if (err && d2 != MPI_COMM_NULL) {
- errs++;
- printf( "dup did not return MPI_COMM_NULL on error\n" );
+ errs++;
+ printf("dup did not return MPI_COMM_NULL on error\n");
}
#endif
delete_flag = 1;
- MPI_Comm_free( &dup_comm_world );
- MPI_Keyval_free( &key_1 );
+ MPI_Comm_free(&dup_comm_world);
+ MPI_Keyval_free(&key_1);
return errs;
}
-
diff --git a/test/mpi/attr/attrerrcomm.c b/test/mpi/attr/attrerrcomm.c
index df42e48..a8947bd 100644
--- a/test/mpi/attr/attrerrcomm.c
+++ b/test/mpi/attr/attrerrcomm.c
@@ -16,35 +16,35 @@
#include "mpi.h"
#include "mpitest.h"
-int test_communicators ( void );
-void abort_msg ( const char *, int );
-int copybomb_fn ( MPI_Comm, int, void *, void *, void *, int * );
-int deletebomb_fn ( MPI_Comm, int, void *, void * );
+int test_communicators(void);
+void abort_msg(const char *, int);
+int copybomb_fn(MPI_Comm, int, void *, void *, void *, int *);
+int deletebomb_fn(MPI_Comm, int, void *, void *);
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
int errs;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
errs = test_communicators();
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
-/*
- * MPI 1.2 Clarification: Clarification of Error Behavior of
- * Attribute Callback Functions
+/*
+ * MPI 1.2 Clarification: Clarification of Error Behavior of
+ * Attribute Callback Functions
* Any return value other than MPI_SUCCESS is erroneous. The specific value
* returned to the user is undefined (other than it can't be MPI_SUCCESS).
* Proposals to specify particular values (e.g., user's value) failed.
*/
/* Return an error as the value */
-int copybomb_fn( MPI_Comm oldcomm, int keyval, void *extra_state,
- void *attribute_val_in, void *attribute_val_out, int *flag)
+int copybomb_fn(MPI_Comm oldcomm, int keyval, void *extra_state,
+ void *attribute_val_in, void *attribute_val_out, int *flag)
{
/* Note that if (sizeof(int) < sizeof(void *), just setting the int
- part of attribute_val_out may leave some dirty bits
- */
+ * part of attribute_val_out may leave some dirty bits
+ */
*flag = 1;
return MPI_ERR_OTHER;
}
@@ -52,90 +52,89 @@ int copybomb_fn( MPI_Comm oldcomm, int keyval, void *extra_state,
/* Set delete flag to 1 to allow the attribute to be deleted */
static int delete_flag = 0;
-int deletebomb_fn( MPI_Comm comm, int keyval, void *attribute_val,
- void *extra_state)
+int deletebomb_fn(MPI_Comm comm, int keyval, void *attribute_val, void *extra_state)
{
- if (delete_flag) return MPI_SUCCESS;
+ if (delete_flag)
+ return MPI_SUCCESS;
return MPI_ERR_OTHER;
}
-void abort_msg( const char *str, int code )
+void abort_msg(const char *str, int code)
{
- fprintf( stderr, "%s, err = %d\n", str, code );
- MPI_Abort( MPI_COMM_WORLD, code );
+ fprintf(stderr, "%s, err = %d\n", str, code);
+ MPI_Abort(MPI_COMM_WORLD, code);
}
-int test_communicators( void )
+int test_communicators(void)
{
MPI_Comm dup_comm_world, d2;
int world_rank, world_size, key_1;
int err, errs = 0;
MPI_Aint value;
- MPI_Comm_rank( MPI_COMM_WORLD, &world_rank );
- MPI_Comm_size( MPI_COMM_WORLD, &world_size );
+ MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &world_size);
#ifdef DEBUG
if (world_rank == 0) {
- printf( "*** Attribute copy/delete return codes ***\n" );
+ printf("*** Attribute copy/delete return codes ***\n");
}
#endif
- MPI_Comm_dup( MPI_COMM_WORLD, &dup_comm_world );
- MPI_Barrier( dup_comm_world );
+ MPI_Comm_dup(MPI_COMM_WORLD, &dup_comm_world);
+ MPI_Barrier(dup_comm_world);
- MPI_Errhandler_set( dup_comm_world, MPI_ERRORS_RETURN );
+ MPI_Errhandler_set(dup_comm_world, MPI_ERRORS_RETURN);
- value = - 11;
- if ((err=MPI_Comm_create_keyval( copybomb_fn, deletebomb_fn, &key_1, &value )))
- abort_msg( "Keyval_create", err );
+ value = -11;
+ if ((err = MPI_Comm_create_keyval(copybomb_fn, deletebomb_fn, &key_1, &value)))
+ abort_msg("Keyval_create", err);
- err = MPI_Comm_set_attr( dup_comm_world, key_1, (void *) (MPI_Aint) world_rank );
+ err = MPI_Comm_set_attr(dup_comm_world, key_1, (void *) (MPI_Aint) world_rank);
if (err) {
- errs++;
- printf( "Error with first put\n" );
+ errs++;
+ printf("Error with first put\n");
}
- err = MPI_Comm_set_attr( dup_comm_world, key_1, (void *) (MPI_Aint) (2*world_rank) );
+ err = MPI_Comm_set_attr(dup_comm_world, key_1, (void *) (MPI_Aint) (2 * world_rank));
if (err == MPI_SUCCESS) {
- errs++;
- printf( "delete function return code was MPI_SUCCESS in put\n" );
+ errs++;
+ printf("delete function return code was MPI_SUCCESS in put\n");
}
/* Because the attribute delete function should fail, the attribute
- should *not be removed* */
- err = MPI_Comm_delete_attr( dup_comm_world, key_1 );
+ * should *not be removed* */
+ err = MPI_Comm_delete_attr(dup_comm_world, key_1);
if (err == MPI_SUCCESS) {
- errs++;
- printf( "delete function return code was MPI_SUCCESS in delete\n" );
+ errs++;
+ printf("delete function return code was MPI_SUCCESS in delete\n");
}
-
- err = MPI_Comm_dup( dup_comm_world, &d2 );
+
+ err = MPI_Comm_dup(dup_comm_world, &d2);
if (err == MPI_SUCCESS) {
- errs++;
- printf( "copy function return code was MPI_SUCCESS in dup\n" );
+ errs++;
+ printf("copy function return code was MPI_SUCCESS in dup\n");
}
if (err != MPI_ERR_OTHER) {
- int lerrclass;
- MPI_Error_class( err, &lerrclass );
- if (lerrclass != MPI_ERR_OTHER) {
- errs++;
- printf( "dup did not return an error code of class ERR_OTHER; " );
- printf( "err = %d, class = %d\n", err, lerrclass );
- }
+ int lerrclass;
+ MPI_Error_class(err, &lerrclass);
+ if (lerrclass != MPI_ERR_OTHER) {
+ errs++;
+ printf("dup did not return an error code of class ERR_OTHER; ");
+ printf("err = %d, class = %d\n", err, lerrclass);
+ }
}
#ifndef USE_STRICT_MPI
/* Another interpretation is to leave d2 unchanged on error */
if (err && d2 != MPI_COMM_NULL) {
- errs++;
- printf( "dup did not return MPI_COMM_NULL on error\n" );
+ errs++;
+ printf("dup did not return MPI_COMM_NULL on error\n");
}
#endif
delete_flag = 1;
- MPI_Comm_free( &dup_comm_world );
+ MPI_Comm_free(&dup_comm_world);
- MPI_Comm_free_keyval( &key_1 );
+ MPI_Comm_free_keyval(&key_1);
return errs;
}
-
diff --git a/test/mpi/attr/attrerrtype.c b/test/mpi/attr/attrerrtype.c
index d3d9a39..567ea9e 100644
--- a/test/mpi/attr/attrerrtype.c
+++ b/test/mpi/attr/attrerrtype.c
@@ -16,35 +16,35 @@
#include "mpi.h"
#include "mpitest.h"
-int test_attrs ( void );
-void abort_msg ( const char *, int );
-int copybomb_fn ( MPI_Datatype, int, void *, void *, void *, int * );
-int deletebomb_fn ( MPI_Datatype, int, void *, void * );
+int test_attrs(void);
+void abort_msg(const char *, int);
+int copybomb_fn(MPI_Datatype, int, void *, void *, void *, int *);
+int deletebomb_fn(MPI_Datatype, int, void *, void *);
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
int errs;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
errs = test_attrs();
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
-/*
- * MPI 1.2 Clarification: Clarification of Error Behavior of
- * Attribute Callback Functions
+/*
+ * MPI 1.2 Clarification: Clarification of Error Behavior of
+ * Attribute Callback Functions
* Any return value other than MPI_SUCCESS is erroneous. The specific value
* returned to the user is undefined (other than it can't be MPI_SUCCESS).
* Proposals to specify particular values (e.g., user's value) failed.
*/
/* Return an error as the value */
-int copybomb_fn( MPI_Datatype oldtype, int keyval, void *extra_state,
- void *attribute_val_in, void *attribute_val_out, int *flag)
+int copybomb_fn(MPI_Datatype oldtype, int keyval, void *extra_state,
+ void *attribute_val_in, void *attribute_val_out, int *flag)
{
/* Note that if (sizeof(int) < sizeof(void *), just setting the int
- part of attribute_val_out may leave some dirty bits
- */
+ * part of attribute_val_out may leave some dirty bits
+ */
*flag = 1;
return MPI_ERR_OTHER;
}
@@ -53,87 +53,87 @@ int copybomb_fn( MPI_Datatype oldtype, int keyval, void *extra_state,
static int delete_flag = 0;
static int deleteCalled = 0;
-int deletebomb_fn( MPI_Datatype type, int keyval, void *attribute_val,
- void *extra_state)
+int deletebomb_fn(MPI_Datatype type, int keyval, void *attribute_val, void *extra_state)
{
- deleteCalled ++;
- if (delete_flag) return MPI_SUCCESS;
+ deleteCalled++;
+ if (delete_flag)
+ return MPI_SUCCESS;
return MPI_ERR_OTHER;
}
-void abort_msg( const char *str, int code )
+void abort_msg(const char *str, int code)
{
- fprintf( stderr, "%s, err = %d\n", str, code );
- MPI_Abort( MPI_COMM_WORLD, code );
+ fprintf(stderr, "%s, err = %d\n", str, code);
+ MPI_Abort(MPI_COMM_WORLD, code);
}
-int test_attrs( void )
+int test_attrs(void)
{
MPI_Datatype dup_type, d2;
int world_rank, world_size, key_1;
int err, errs = 0;
MPI_Aint value;
- MPI_Comm_rank( MPI_COMM_WORLD, &world_rank );
- MPI_Comm_size( MPI_COMM_WORLD, &world_size );
+ MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &world_size);
#ifdef DEBUG
if (world_rank == 0) {
- printf( "*** Attribute copy/delete return codes ***\n" );
+ printf("*** Attribute copy/delete return codes ***\n");
}
#endif
-
- MPI_Type_dup( MPI_DOUBLE, &dup_type );
- MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ MPI_Type_dup(MPI_DOUBLE, &dup_type);
+
+ MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
- value = - 11;
- if ((err=MPI_Type_create_keyval( copybomb_fn, deletebomb_fn, &key_1, &value )))
- abort_msg( "Keyval_create", err );
+ value = -11;
+ if ((err = MPI_Type_create_keyval(copybomb_fn, deletebomb_fn, &key_1, &value)))
+ abort_msg("Keyval_create", err);
- err = MPI_Type_set_attr( dup_type, key_1, (void *) (MPI_Aint) world_rank );
+ err = MPI_Type_set_attr(dup_type, key_1, (void *) (MPI_Aint) world_rank);
if (err) {
- errs++;
- printf( "Error with first put\n" );
+ errs++;
+ printf("Error with first put\n");
}
- err = MPI_Type_set_attr( dup_type, key_1, (void *) (MPI_Aint) (2*world_rank) );
+ err = MPI_Type_set_attr(dup_type, key_1, (void *) (MPI_Aint) (2 * world_rank));
if (err == MPI_SUCCESS) {
- errs++;
- printf( "delete function return code was MPI_SUCCESS in put\n" );
+ errs++;
+ printf("delete function return code was MPI_SUCCESS in put\n");
}
/* Because the attribute delete function should fail, the attribute
- should *not be removed* */
- err = MPI_Type_delete_attr( dup_type, key_1 );
+ * should *not be removed* */
+ err = MPI_Type_delete_attr(dup_type, key_1);
if (err == MPI_SUCCESS) {
- errs++;
- printf( "delete function return code was MPI_SUCCESS in delete\n" );
+ errs++;
+ printf("delete function return code was MPI_SUCCESS in delete\n");
}
-
- err = MPI_Type_dup( dup_type, &d2 );
+
+ err = MPI_Type_dup(dup_type, &d2);
if (err == MPI_SUCCESS) {
- errs++;
- printf( "copy function return code was MPI_SUCCESS in dup\n" );
+ errs++;
+ printf("copy function return code was MPI_SUCCESS in dup\n");
}
#ifndef USE_STRICT_MPI
/* Another interpretation is to leave d2 unchanged on error */
if (err && d2 != MPI_DATATYPE_NULL) {
- errs++;
- printf( "dup did not return MPI_DATATYPE_NULL on error\n" );
+ errs++;
+ printf("dup did not return MPI_DATATYPE_NULL on error\n");
}
#endif
- delete_flag = 1;
+ delete_flag = 1;
deleteCalled = 0;
- if (d2 != MPI_DATATYPE_NULL)
- MPI_Type_free(&d2);
- MPI_Type_free( &dup_type );
+ if (d2 != MPI_DATATYPE_NULL)
+ MPI_Type_free(&d2);
+ MPI_Type_free(&dup_type);
if (deleteCalled == 0) {
- errs++;
- printf( "Free of a datatype did not invoke the attribute delete routine\n" );
+ errs++;
+ printf("Free of a datatype did not invoke the attribute delete routine\n");
}
- MPI_Type_free_keyval( &key_1 );
+ MPI_Type_free_keyval(&key_1);
return errs;
}
diff --git a/test/mpi/attr/attric.c b/test/mpi/attr/attric.c
index c71e96c..25d7a6d 100644
--- a/test/mpi/attr/attric.c
+++ b/test/mpi/attr/attric.c
@@ -17,139 +17,137 @@
#include "mpitest.h"
/* #define DEBUG */
-int test_communicators ( void );
-int copy_fn ( MPI_Comm, int, void *, void *, void *, int * );
-int delete_fn ( MPI_Comm, int, void *, void * );
+int test_communicators(void);
+int copy_fn(MPI_Comm, int, void *, void *, void *, int *);
+int delete_fn(MPI_Comm, int, void *, void *);
#ifdef DEBUG
#define FFLUSH fflush(stdout);
#else
#define FFLUSH
#endif
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
int errs = 0;
- MTest_Init( &argc, &argv );
-
+ MTest_Init(&argc, &argv);
+
errs = test_communicators();
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
-int copy_fn( MPI_Comm oldcomm, int keyval, void *extra_state,
- void *attribute_val_in, void *attribute_val_out, int *flag)
+int copy_fn(MPI_Comm oldcomm, int keyval, void *extra_state,
+ void *attribute_val_in, void *attribute_val_out, int *flag)
{
/* Note that if (sizeof(int) < sizeof(void *), just setting the int
- part of attribute_val_out may leave some dirty bits
- */
- *(MPI_Aint *)attribute_val_out = (MPI_Aint)attribute_val_in;
+ * part of attribute_val_out may leave some dirty bits
+ */
+ *(MPI_Aint *) attribute_val_out = (MPI_Aint) attribute_val_in;
*flag = 1;
return MPI_SUCCESS;
}
-int delete_fn( MPI_Comm comm, int keyval, void *attribute_val,
- void *extra_state)
+int delete_fn(MPI_Comm comm, int keyval, void *attribute_val, void *extra_state)
{
int world_rank;
- MPI_Comm_rank( MPI_COMM_WORLD, &world_rank );
- if ((MPI_Aint)attribute_val != (MPI_Aint)world_rank) {
- printf( "incorrect attribute value %d\n", *(int*)attribute_val );
- MPI_Abort(MPI_COMM_WORLD, 1005 );
+ MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
+ if ((MPI_Aint) attribute_val != (MPI_Aint) world_rank) {
+ printf("incorrect attribute value %d\n", *(int *) attribute_val);
+ MPI_Abort(MPI_COMM_WORLD, 1005);
}
return MPI_SUCCESS;
}
-int test_communicators( void )
+int test_communicators(void)
{
MPI_Comm dup_comm, comm;
void *vvalue;
int flag, world_rank, world_size, key_1, key_3;
int errs = 0;
MPI_Aint value;
- int isLeft;
+ int isLeft;
- MPI_Comm_rank( MPI_COMM_WORLD, &world_rank );
- MPI_Comm_size( MPI_COMM_WORLD, &world_size );
+ MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &world_size);
#ifdef DEBUG
if (world_rank == 0) {
- printf( "*** Communicators ***\n" ); fflush(stdout);
+ printf("*** Communicators ***\n");
+ fflush(stdout);
}
#endif
- while (MTestGetIntercomm( &comm, &isLeft, 2 )) {
+ while (MTestGetIntercomm(&comm, &isLeft, 2)) {
MTestPrintfMsg(1, "start while loop, isLeft=%s\n", (isLeft ? "TRUE" : "FALSE"));
- if (comm == MPI_COMM_NULL) {
+ if (comm == MPI_COMM_NULL) {
MTestPrintfMsg(1, "got COMM_NULL, skipping\n");
continue;
}
- /*
- Check Comm_dup by adding attributes to comm & duplicating
- */
-
- value = 9;
- MPI_Keyval_create(copy_fn, delete_fn, &key_1, &value );
+ /*
+ * Check Comm_dup by adding attributes to comm & duplicating
+ */
+
+ value = 9;
+ MPI_Keyval_create(copy_fn, delete_fn, &key_1, &value);
MTestPrintfMsg(1, "Keyval_create key=%#x value=%d\n", key_1, value);
- value = 7;
- MPI_Keyval_create(MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN,
- &key_3, &value );
+ value = 7;
+ MPI_Keyval_create(MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN, &key_3, &value);
MTestPrintfMsg(1, "Keyval_create key=%#x value=%d\n", key_3, value);
- /* This may generate a compilation warning; it is, however, an
- easy way to cache a value instead of a pointer */
- /* printf( "key1 = %x key3 = %x\n", key_1, key_3 ); */
- MPI_Attr_put(comm, key_1, (void *) (MPI_Aint) world_rank );
- MPI_Attr_put(comm, key_3, (void *)0 );
-
- MTestPrintfMsg(1, "Comm_dup\n" );
- MPI_Comm_dup(comm, &dup_comm );
-
- /* Note that if sizeof(int) < sizeof(void *), we can't use
- (void **)&value to get the value we passed into Attr_put. To avoid
- problems (e.g., alignment errors), we recover the value into
- a (void *) and cast to int. Note that this may generate warning
- messages from the compiler. */
- MPI_Attr_get(dup_comm, key_1, (void **)&vvalue, &flag );
- value = (MPI_Aint)vvalue;
-
- if (! flag) {
- errs++;
- printf( "dup_comm key_1 not found on %d\n", world_rank );
- fflush( stdout );
- MPI_Abort(MPI_COMM_WORLD, 3004 );
- }
-
- if (value != world_rank) {
- errs++;
- printf( "dup_comm key_1 value incorrect: %ld\n", (long)value );
- fflush( stdout );
- MPI_Abort(MPI_COMM_WORLD, 3005 );
- }
-
- MPI_Attr_get(dup_comm, key_3, (void **)&vvalue, &flag );
- value = (MPI_Aint)vvalue;
- if (flag) {
- errs++;
- printf( "dup_comm key_3 found!\n" );
- fflush( stdout );
- MPI_Abort(MPI_COMM_WORLD, 3008 );
- }
+ /* This may generate a compilation warning; it is, however, an
+ * easy way to cache a value instead of a pointer */
+ /* printf("key1 = %x key3 = %x\n", key_1, key_3); */
+ MPI_Attr_put(comm, key_1, (void *) (MPI_Aint) world_rank);
+ MPI_Attr_put(comm, key_3, (void *) 0);
+
+ MTestPrintfMsg(1, "Comm_dup\n");
+ MPI_Comm_dup(comm, &dup_comm);
+
+ /* Note that if sizeof(int) < sizeof(void *), we can't use
+ * (void **)&value to get the value we passed into Attr_put. To avoid
+ * problems (e.g., alignment errors), we recover the value into
+ * a (void *) and cast to int. Note that this may generate warning
+ * messages from the compiler. */
+ MPI_Attr_get(dup_comm, key_1, (void **) &vvalue, &flag);
+ value = (MPI_Aint) vvalue;
+
+ if (!flag) {
+ errs++;
+ printf("dup_comm key_1 not found on %d\n", world_rank);
+ fflush(stdout);
+ MPI_Abort(MPI_COMM_WORLD, 3004);
+ }
+
+ if (value != world_rank) {
+ errs++;
+ printf("dup_comm key_1 value incorrect: %ld\n", (long) value);
+ fflush(stdout);
+ MPI_Abort(MPI_COMM_WORLD, 3005);
+ }
+
+ MPI_Attr_get(dup_comm, key_3, (void **) &vvalue, &flag);
+ value = (MPI_Aint) vvalue;
+ if (flag) {
+ errs++;
+ printf("dup_comm key_3 found!\n");
+ fflush(stdout);
+ MPI_Abort(MPI_COMM_WORLD, 3008);
+ }
MTestPrintfMsg(1, "Keyval_free key=%#x\n", key_1);
- MPI_Keyval_free(&key_1 );
+ MPI_Keyval_free(&key_1);
MTestPrintfMsg(1, "Keyval_free key=%#x\n", key_3);
- MPI_Keyval_free(&key_3 );
- /*
- Free all communicators created
- */
+ MPI_Keyval_free(&key_3);
+ /*
+ * Free all communicators created
+ */
MTestPrintfMsg(1, "Comm_free comm\n");
- MPI_Comm_free( &comm );
+ MPI_Comm_free(&comm);
MTestPrintfMsg(1, "Comm_free dup_comm\n");
- MPI_Comm_free( &dup_comm );
+ MPI_Comm_free(&dup_comm);
}
return errs;
}
-
diff --git a/test/mpi/attr/attrorder.c b/test/mpi/attr/attrorder.c
index 09827fe..0fd53bd 100644
--- a/test/mpi/attr/attrorder.c
+++ b/test/mpi/attr/attrorder.c
@@ -13,111 +13,108 @@ static char MTestDescrip[] = "Test creating and inserting attributes in \
different orders to ensure that the list management code handles all cases.";
*/
-int checkAttrs( MPI_Comm comm, int n, int key[], int attrval[] );
-int checkNoAttrs( MPI_Comm comm, int n, int key[] );
+int checkAttrs(MPI_Comm comm, int n, int key[], int attrval[]);
+int checkNoAttrs(MPI_Comm comm, int n, int key[]);
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int key[3], attrval[3];
int i;
MPI_Comm comm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
{
- comm = MPI_COMM_WORLD;
- /* Create key values */
- for (i=0; i<3; i++) {
- MPI_Keyval_create( MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN,
- &key[i], (void *)0 );
- attrval[i] = 1024 * i;
- }
-
- /* Insert attribute in several orders. Test after put with get,
- then delete, then confirm delete with get. */
-
- MPI_Attr_put( comm, key[2], &attrval[2] );
- MPI_Attr_put( comm, key[1], &attrval[1] );
- MPI_Attr_put( comm, key[0], &attrval[0] );
-
- errs += checkAttrs( comm, 3, key, attrval );
-
- MPI_Attr_delete( comm, key[0] );
- MPI_Attr_delete( comm, key[1] );
- MPI_Attr_delete( comm, key[2] );
-
- errs += checkNoAttrs( comm, 3, key );
-
- MPI_Attr_put( comm, key[1], &attrval[1] );
- MPI_Attr_put( comm, key[2], &attrval[2] );
- MPI_Attr_put( comm, key[0], &attrval[0] );
-
- errs += checkAttrs( comm, 3, key, attrval );
-
- MPI_Attr_delete( comm, key[2] );
- MPI_Attr_delete( comm, key[1] );
- MPI_Attr_delete( comm, key[0] );
-
- errs += checkNoAttrs( comm, 3, key );
-
- MPI_Attr_put( comm, key[0], &attrval[0] );
- MPI_Attr_put( comm, key[1], &attrval[1] );
- MPI_Attr_put( comm, key[2], &attrval[2] );
-
- errs += checkAttrs( comm, 3, key, attrval );
-
- MPI_Attr_delete( comm, key[1] );
- MPI_Attr_delete( comm, key[2] );
- MPI_Attr_delete( comm, key[0] );
-
- errs += checkNoAttrs( comm, 3, key );
-
- for (i=0; i<3; i++) {
- MPI_Keyval_free( &key[i] );
- }
+ comm = MPI_COMM_WORLD;
+ /* Create key values */
+ for (i = 0; i < 3; i++) {
+ MPI_Keyval_create(MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN, &key[i], (void *) 0);
+ attrval[i] = 1024 * i;
+ }
+
+ /* Insert attribute in several orders. Test after put with get,
+ * then delete, then confirm delete with get. */
+
+ MPI_Attr_put(comm, key[2], &attrval[2]);
+ MPI_Attr_put(comm, key[1], &attrval[1]);
+ MPI_Attr_put(comm, key[0], &attrval[0]);
+
+ errs += checkAttrs(comm, 3, key, attrval);
+
+ MPI_Attr_delete(comm, key[0]);
+ MPI_Attr_delete(comm, key[1]);
+ MPI_Attr_delete(comm, key[2]);
+
+ errs += checkNoAttrs(comm, 3, key);
+
+ MPI_Attr_put(comm, key[1], &attrval[1]);
+ MPI_Attr_put(comm, key[2], &attrval[2]);
+ MPI_Attr_put(comm, key[0], &attrval[0]);
+
+ errs += checkAttrs(comm, 3, key, attrval);
+
+ MPI_Attr_delete(comm, key[2]);
+ MPI_Attr_delete(comm, key[1]);
+ MPI_Attr_delete(comm, key[0]);
+
+ errs += checkNoAttrs(comm, 3, key);
+
+ MPI_Attr_put(comm, key[0], &attrval[0]);
+ MPI_Attr_put(comm, key[1], &attrval[1]);
+ MPI_Attr_put(comm, key[2], &attrval[2]);
+
+ errs += checkAttrs(comm, 3, key, attrval);
+
+ MPI_Attr_delete(comm, key[1]);
+ MPI_Attr_delete(comm, key[2]);
+ MPI_Attr_delete(comm, key[0]);
+
+ errs += checkNoAttrs(comm, 3, key);
+
+ for (i = 0; i < 3; i++) {
+ MPI_Keyval_free(&key[i]);
+ }
}
-
- MTest_Finalize( errs );
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
-int checkAttrs( MPI_Comm comm, int n, int key[], int attrval[] )
+int checkAttrs(MPI_Comm comm, int n, int key[], int attrval[])
{
int errs = 0;
int i, flag, *val_p;
- for (i=0; i<n; i++) {
- MPI_Attr_get( comm, key[i], &val_p, &flag );
- if (!flag) {
- errs++;
- fprintf( stderr, "Attribute for key %d not set\n", i );
- }
- else if (val_p != &attrval[i]) {
- errs++;
- fprintf( stderr, "Atribute value for key %d not correct\n",
- i );
- }
+ for (i = 0; i < n; i++) {
+ MPI_Attr_get(comm, key[i], &val_p, &flag);
+ if (!flag) {
+ errs++;
+ fprintf(stderr, "Attribute for key %d not set\n", i);
+ }
+ else if (val_p != &attrval[i]) {
+ errs++;
+ fprintf(stderr, "Atribute value for key %d not correct\n", i);
+ }
}
return errs;
}
-int checkNoAttrs( MPI_Comm comm, int n, int key[] )
+int checkNoAttrs(MPI_Comm comm, int n, int key[])
{
int errs = 0;
int i, flag, *val_p;
- for (i=0; i<n; i++) {
- MPI_Attr_get( comm, key[i], &val_p, &flag );
- if (flag) {
- errs++;
- fprintf( stderr, "Attribute for key %d set but should be deleted\n", i );
- }
+ for (i = 0; i < n; i++) {
+ MPI_Attr_get(comm, key[i], &val_p, &flag);
+ if (flag) {
+ errs++;
+ fprintf(stderr, "Attribute for key %d set but should be deleted\n", i);
+ }
}
return errs;
}
-
diff --git a/test/mpi/attr/attrordercomm.c b/test/mpi/attr/attrordercomm.c
index 852e2d5..f2ea4e8 100644
--- a/test/mpi/attr/attrordercomm.c
+++ b/test/mpi/attr/attrordercomm.c
@@ -13,111 +13,108 @@ static char MTestDescrip[] = "Test creating and inserting attributes in \
different orders to ensure that the list management code handles all cases.";
*/
-int checkAttrs( MPI_Comm comm, int n, int key[], int attrval[] );
-int checkNoAttrs( MPI_Comm comm, int n, int key[] );
+int checkAttrs(MPI_Comm comm, int n, int key[], int attrval[]);
+int checkNoAttrs(MPI_Comm comm, int n, int key[]);
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int key[3], attrval[3];
int i;
MPI_Comm comm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
{
- comm = MPI_COMM_WORLD;
- /* Create key values */
- for (i=0; i<3; i++) {
- MPI_Comm_create_keyval( MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN,
- &key[i], (void *)0 );
- attrval[i] = 1024 * i;
- }
-
- /* Insert attribute in several orders. Test after put with get,
- then delete, then confirm delete with get. */
-
- MPI_Comm_set_attr( comm, key[2], &attrval[2] );
- MPI_Comm_set_attr( comm, key[1], &attrval[1] );
- MPI_Comm_set_attr( comm, key[0], &attrval[0] );
-
- errs += checkAttrs( comm, 3, key, attrval );
-
- MPI_Comm_delete_attr( comm, key[0] );
- MPI_Comm_delete_attr( comm, key[1] );
- MPI_Comm_delete_attr( comm, key[2] );
-
- errs += checkNoAttrs( comm, 3, key );
-
- MPI_Comm_set_attr( comm, key[1], &attrval[1] );
- MPI_Comm_set_attr( comm, key[2], &attrval[2] );
- MPI_Comm_set_attr( comm, key[0], &attrval[0] );
-
- errs += checkAttrs( comm, 3, key, attrval );
-
- MPI_Comm_delete_attr( comm, key[2] );
- MPI_Comm_delete_attr( comm, key[1] );
- MPI_Comm_delete_attr( comm, key[0] );
-
- errs += checkNoAttrs( comm, 3, key );
-
- MPI_Comm_set_attr( comm, key[0], &attrval[0] );
- MPI_Comm_set_attr( comm, key[1], &attrval[1] );
- MPI_Comm_set_attr( comm, key[2], &attrval[2] );
-
- errs += checkAttrs( comm, 3, key, attrval );
-
- MPI_Comm_delete_attr( comm, key[1] );
- MPI_Comm_delete_attr( comm, key[2] );
- MPI_Comm_delete_attr( comm, key[0] );
-
- errs += checkNoAttrs( comm, 3, key );
-
- for (i=0; i<3; i++) {
- MPI_Comm_free_keyval( &key[i] );
- }
+ comm = MPI_COMM_WORLD;
+ /* Create key values */
+ for (i = 0; i < 3; i++) {
+ MPI_Comm_create_keyval(MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN, &key[i], (void *) 0);
+ attrval[i] = 1024 * i;
+ }
+
+ /* Insert attribute in several orders. Test after put with get,
+ * then delete, then confirm delete with get. */
+
+ MPI_Comm_set_attr(comm, key[2], &attrval[2]);
+ MPI_Comm_set_attr(comm, key[1], &attrval[1]);
+ MPI_Comm_set_attr(comm, key[0], &attrval[0]);
+
+ errs += checkAttrs(comm, 3, key, attrval);
+
+ MPI_Comm_delete_attr(comm, key[0]);
+ MPI_Comm_delete_attr(comm, key[1]);
+ MPI_Comm_delete_attr(comm, key[2]);
+
+ errs += checkNoAttrs(comm, 3, key);
+
+ MPI_Comm_set_attr(comm, key[1], &attrval[1]);
+ MPI_Comm_set_attr(comm, key[2], &attrval[2]);
+ MPI_Comm_set_attr(comm, key[0], &attrval[0]);
+
+ errs += checkAttrs(comm, 3, key, attrval);
+
+ MPI_Comm_delete_attr(comm, key[2]);
+ MPI_Comm_delete_attr(comm, key[1]);
+ MPI_Comm_delete_attr(comm, key[0]);
+
+ errs += checkNoAttrs(comm, 3, key);
+
+ MPI_Comm_set_attr(comm, key[0], &attrval[0]);
+ MPI_Comm_set_attr(comm, key[1], &attrval[1]);
+ MPI_Comm_set_attr(comm, key[2], &attrval[2]);
+
+ errs += checkAttrs(comm, 3, key, attrval);
+
+ MPI_Comm_delete_attr(comm, key[1]);
+ MPI_Comm_delete_attr(comm, key[2]);
+ MPI_Comm_delete_attr(comm, key[0]);
+
+ errs += checkNoAttrs(comm, 3, key);
+
+ for (i = 0; i < 3; i++) {
+ MPI_Comm_free_keyval(&key[i]);
+ }
}
-
- MTest_Finalize( errs );
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
-int checkAttrs( MPI_Comm comm, int n, int key[], int attrval[] )
+int checkAttrs(MPI_Comm comm, int n, int key[], int attrval[])
{
int errs = 0;
int i, flag, *val_p;
- for (i=0; i<n; i++) {
- MPI_Comm_get_attr( comm, key[i], &val_p, &flag );
- if (!flag) {
- errs++;
- fprintf( stderr, "Attribute for key %d not set\n", i );
- }
- else if (val_p != &attrval[i]) {
- errs++;
- fprintf( stderr, "Atribute value for key %d not correct\n",
- i );
- }
+ for (i = 0; i < n; i++) {
+ MPI_Comm_get_attr(comm, key[i], &val_p, &flag);
+ if (!flag) {
+ errs++;
+ fprintf(stderr, "Attribute for key %d not set\n", i);
+ }
+ else if (val_p != &attrval[i]) {
+ errs++;
+ fprintf(stderr, "Atribute value for key %d not correct\n", i);
+ }
}
return errs;
}
-int checkNoAttrs( MPI_Comm comm, int n, int key[] )
+int checkNoAttrs(MPI_Comm comm, int n, int key[])
{
int errs = 0;
int i, flag, *val_p;
- for (i=0; i<n; i++) {
- MPI_Comm_get_attr( comm, key[i], &val_p, &flag );
- if (flag) {
- errs++;
- fprintf( stderr, "Attribute for key %d set but should be deleted\n", i );
- }
+ for (i = 0; i < n; i++) {
+ MPI_Comm_get_attr(comm, key[i], &val_p, &flag);
+ if (flag) {
+ errs++;
+ fprintf(stderr, "Attribute for key %d set but should be deleted\n", i);
+ }
}
return errs;
}
-
diff --git a/test/mpi/attr/attrordertype.c b/test/mpi/attr/attrordertype.c
index ac7ac61..d3de828 100644
--- a/test/mpi/attr/attrordertype.c
+++ b/test/mpi/attr/attrordertype.c
@@ -13,111 +13,108 @@ static char MTestDescrip[] = "Test creating and inserting attributes in \
different orders to ensure that the list management code handles all cases.";
*/
-int checkAttrs( MPI_Datatype type, int n, int key[], int attrval[] );
-int checkNoAttrs( MPI_Datatype type, int n, int key[] );
+int checkAttrs(MPI_Datatype type, int n, int key[], int attrval[]);
+int checkNoAttrs(MPI_Datatype type, int n, int key[]);
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int key[3], attrval[3];
int i;
MPI_Datatype type;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
{
- type = MPI_INT;
- /* Create key values */
- for (i=0; i<3; i++) {
- MPI_Type_create_keyval( MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN,
- &key[i], (void *)0 );
- attrval[i] = 1024 * i;
- }
-
- /* Insert attribute in several orders. Test after put with get,
- then delete, then confirm delete with get. */
-
- MPI_Type_set_attr( type, key[2], &attrval[2] );
- MPI_Type_set_attr( type, key[1], &attrval[1] );
- MPI_Type_set_attr( type, key[0], &attrval[0] );
-
- errs += checkAttrs( type, 3, key, attrval );
-
- MPI_Type_delete_attr( type, key[0] );
- MPI_Type_delete_attr( type, key[1] );
- MPI_Type_delete_attr( type, key[2] );
-
- errs += checkNoAttrs( type, 3, key );
-
- MPI_Type_set_attr( type, key[1], &attrval[1] );
- MPI_Type_set_attr( type, key[2], &attrval[2] );
- MPI_Type_set_attr( type, key[0], &attrval[0] );
-
- errs += checkAttrs( type, 3, key, attrval );
-
- MPI_Type_delete_attr( type, key[2] );
- MPI_Type_delete_attr( type, key[1] );
- MPI_Type_delete_attr( type, key[0] );
-
- errs += checkNoAttrs( type, 3, key );
-
- MPI_Type_set_attr( type, key[0], &attrval[0] );
- MPI_Type_set_attr( type, key[1], &attrval[1] );
- MPI_Type_set_attr( type, key[2], &attrval[2] );
-
- errs += checkAttrs( type, 3, key, attrval );
-
- MPI_Type_delete_attr( type, key[1] );
- MPI_Type_delete_attr( type, key[2] );
- MPI_Type_delete_attr( type, key[0] );
-
- errs += checkNoAttrs( type, 3, key );
-
- for (i=0; i<3; i++) {
- MPI_Type_free_keyval( &key[i] );
- }
+ type = MPI_INT;
+ /* Create key values */
+ for (i = 0; i < 3; i++) {
+ MPI_Type_create_keyval(MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN, &key[i], (void *) 0);
+ attrval[i] = 1024 * i;
+ }
+
+ /* Insert attribute in several orders. Test after put with get,
+ * then delete, then confirm delete with get. */
+
+ MPI_Type_set_attr(type, key[2], &attrval[2]);
+ MPI_Type_set_attr(type, key[1], &attrval[1]);
+ MPI_Type_set_attr(type, key[0], &attrval[0]);
+
+ errs += checkAttrs(type, 3, key, attrval);
+
+ MPI_Type_delete_attr(type, key[0]);
+ MPI_Type_delete_attr(type, key[1]);
+ MPI_Type_delete_attr(type, key[2]);
+
+ errs += checkNoAttrs(type, 3, key);
+
+ MPI_Type_set_attr(type, key[1], &attrval[1]);
+ MPI_Type_set_attr(type, key[2], &attrval[2]);
+ MPI_Type_set_attr(type, key[0], &attrval[0]);
+
+ errs += checkAttrs(type, 3, key, attrval);
+
+ MPI_Type_delete_attr(type, key[2]);
+ MPI_Type_delete_attr(type, key[1]);
+ MPI_Type_delete_attr(type, key[0]);
+
+ errs += checkNoAttrs(type, 3, key);
+
+ MPI_Type_set_attr(type, key[0], &attrval[0]);
+ MPI_Type_set_attr(type, key[1], &attrval[1]);
+ MPI_Type_set_attr(type, key[2], &attrval[2]);
+
+ errs += checkAttrs(type, 3, key, attrval);
+
+ MPI_Type_delete_attr(type, key[1]);
+ MPI_Type_delete_attr(type, key[2]);
+ MPI_Type_delete_attr(type, key[0]);
+
+ errs += checkNoAttrs(type, 3, key);
+
+ for (i = 0; i < 3; i++) {
+ MPI_Type_free_keyval(&key[i]);
+ }
}
-
- MTest_Finalize( errs );
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
-int checkAttrs( MPI_Datatype type, int n, int key[], int attrval[] )
+int checkAttrs(MPI_Datatype type, int n, int key[], int attrval[])
{
int errs = 0;
int i, flag, *val_p;
- for (i=0; i<n; i++) {
- MPI_Type_get_attr( type, key[i], &val_p, &flag );
- if (!flag) {
- errs++;
- fprintf( stderr, "Attribute for key %d not set\n", i );
- }
- else if (val_p != &attrval[i]) {
- errs++;
- fprintf( stderr, "Atribute value for key %d not correct\n",
- i );
- }
+ for (i = 0; i < n; i++) {
+ MPI_Type_get_attr(type, key[i], &val_p, &flag);
+ if (!flag) {
+ errs++;
+ fprintf(stderr, "Attribute for key %d not set\n", i);
+ }
+ else if (val_p != &attrval[i]) {
+ errs++;
+ fprintf(stderr, "Atribute value for key %d not correct\n", i);
+ }
}
return errs;
}
-int checkNoAttrs( MPI_Datatype type, int n, int key[] )
+int checkNoAttrs(MPI_Datatype type, int n, int key[])
{
int errs = 0;
int i, flag, *val_p;
- for (i=0; i<n; i++) {
- MPI_Type_get_attr( type, key[i], &val_p, &flag );
- if (flag) {
- errs++;
- fprintf( stderr, "Attribute for key %d set but should be deleted\n", i );
- }
+ for (i = 0; i < n; i++) {
+ MPI_Type_get_attr(type, key[i], &val_p, &flag);
+ if (flag) {
+ errs++;
+ fprintf(stderr, "Attribute for key %d set but should be deleted\n", i);
+ }
}
return errs;
}
-
diff --git a/test/mpi/attr/attrt.c b/test/mpi/attr/attrt.c
index 4ee317c..77fe577 100644
--- a/test/mpi/attr/attrt.c
+++ b/test/mpi/attr/attrt.c
@@ -16,53 +16,51 @@
#include "mpitest.h"
/* #define DEBUG */
-int test_communicators ( void );
-int copy_fn ( MPI_Comm, int, void *, void *, void *, int * );
-int delete_fn ( MPI_Comm, int, void *, void * );
+int test_communicators(void);
+int copy_fn(MPI_Comm, int, void *, void *, void *, int *);
+int delete_fn(MPI_Comm, int, void *, void *);
#ifdef DEBUG
#define FFLUSH fflush(stdout);
#else
#define FFLUSH
#endif
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
int errs = 0;
- MTest_Init( &argc, &argv );
-
+ MTest_Init(&argc, &argv);
+
errs = test_communicators();
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
-int copy_fn( MPI_Comm oldcomm, int keyval, void *extra_state,
- void *attribute_val_in, void *attribute_val_out, int *flag)
+int copy_fn(MPI_Comm oldcomm, int keyval, void *extra_state,
+ void *attribute_val_in, void *attribute_val_out, int *flag)
{
/* Note that if (sizeof(int) < sizeof(void *), just setting the int
- part of attribute_val_out may leave some dirty bits
- */
- *(MPI_Aint *)attribute_val_out = (MPI_Aint)attribute_val_in;
+ * part of attribute_val_out may leave some dirty bits
+ */
+ *(MPI_Aint *) attribute_val_out = (MPI_Aint) attribute_val_in;
*flag = 1;
return MPI_SUCCESS;
}
-int delete_fn( MPI_Comm comm, int keyval, void *attribute_val,
- void *extra_state)
+int delete_fn(MPI_Comm comm, int keyval, void *attribute_val, void *extra_state)
{
int world_rank;
- MPI_Comm_rank( MPI_COMM_WORLD, &world_rank );
- if ((MPI_Aint)attribute_val != (MPI_Aint)world_rank) {
- printf( "incorrect attribute value %d\n", *(int*)attribute_val );
- MPI_Abort(MPI_COMM_WORLD, 1005 );
+ MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
+ if ((MPI_Aint) attribute_val != (MPI_Aint) world_rank) {
+ printf("incorrect attribute value %d\n", *(int *) attribute_val);
+ MPI_Abort(MPI_COMM_WORLD, 1005);
}
return MPI_SUCCESS;
}
-int test_communicators( void )
+int test_communicators(void)
{
- MPI_Comm dup_comm_world, lo_comm, rev_comm, dup_comm,
- split_comm, world_comm;
+ MPI_Comm dup_comm_world, lo_comm, rev_comm, dup_comm, split_comm, world_comm;
MPI_Group world_group, lo_group, rev_group;
void *vvalue;
int ranges[1][3];
@@ -71,34 +69,36 @@ int test_communicators( void )
int errs = 0;
MPI_Aint value;
- MPI_Comm_rank( MPI_COMM_WORLD, &world_rank );
- MPI_Comm_size( MPI_COMM_WORLD, &world_size );
+ MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &world_size);
#ifdef DEBUG
if (world_rank == 0) {
- printf( "*** Communicators ***\n" ); fflush(stdout);
+ printf("*** Communicators ***\n");
+ fflush(stdout);
}
#endif
- MPI_Comm_dup( MPI_COMM_WORLD, &dup_comm_world );
+ MPI_Comm_dup(MPI_COMM_WORLD, &dup_comm_world);
/*
- Exercise Comm_create by creating an equivalent to dup_comm_world
- (sans attributes) and a half-world communicator.
- */
+ * Exercise Comm_create by creating an equivalent to dup_comm_world
+ * (sans attributes) and a half-world communicator.
+ */
#ifdef DEBUG
if (world_rank == 0) {
- printf( " Comm_create\n" ); fflush(stdout);
+ printf(" Comm_create\n");
+ fflush(stdout);
}
#endif
- MPI_Comm_group( dup_comm_world, &world_group );
- MPI_Comm_create( dup_comm_world, world_group, &world_comm );
- MPI_Comm_rank( world_comm, &rank );
+ MPI_Comm_group(dup_comm_world, &world_group);
+ MPI_Comm_create(dup_comm_world, world_group, &world_comm);
+ MPI_Comm_rank(world_comm, &rank);
if (rank != world_rank) {
- errs++;
- printf( "incorrect rank in world comm: %d\n", rank );
- MPI_Abort(MPI_COMM_WORLD, 3001 );
+ errs++;
+ printf("incorrect rank in world comm: %d\n", rank);
+ MPI_Abort(MPI_COMM_WORLD, 3001);
}
n = world_size / 2;
@@ -108,204 +108,210 @@ int test_communicators( void )
ranges[0][2] = 1;
#ifdef DEBUG
- printf( "world rank = %d before range incl\n", world_rank );FFLUSH;
+ printf("world rank = %d before range incl\n", world_rank);
+ FFLUSH;
#endif
- MPI_Group_range_incl(world_group, 1, ranges, &lo_group );
+ MPI_Group_range_incl(world_group, 1, ranges, &lo_group);
#ifdef DEBUG
- printf( "world rank = %d after range incl\n", world_rank );FFLUSH;
+ printf("world rank = %d after range incl\n", world_rank);
+ FFLUSH;
#endif
- MPI_Comm_create(world_comm, lo_group, &lo_comm );
+ MPI_Comm_create(world_comm, lo_group, &lo_comm);
#ifdef DEBUG
- printf( "world rank = %d before group free\n", world_rank );FFLUSH;
+ printf("world rank = %d before group free\n", world_rank);
+ FFLUSH;
#endif
- MPI_Group_free( &lo_group );
+ MPI_Group_free(&lo_group);
#ifdef DEBUG
- printf( "world rank = %d after group free\n", world_rank );FFLUSH;
+ printf("world rank = %d after group free\n", world_rank);
+ FFLUSH;
#endif
if (world_rank < (world_size - n)) {
- MPI_Comm_rank(lo_comm, &rank );
- if (rank == MPI_UNDEFINED) {
- errs++;
- printf( "incorrect lo group rank: %d\n", rank ); fflush(stdout);
- MPI_Abort(MPI_COMM_WORLD, 3002 );
- }
- else {
- /* printf( "lo in\n" );FFLUSH; */
- MPI_Barrier(lo_comm );
- /* printf( "lo out\n" );FFLUSH; */
- }
+ MPI_Comm_rank(lo_comm, &rank);
+ if (rank == MPI_UNDEFINED) {
+ errs++;
+ printf("incorrect lo group rank: %d\n", rank);
+ fflush(stdout);
+ MPI_Abort(MPI_COMM_WORLD, 3002);
+ }
+ else {
+ /* printf("lo in\n");FFLUSH; */
+ MPI_Barrier(lo_comm);
+ /* printf("lo out\n");FFLUSH; */
+ }
}
else {
- if (lo_comm != MPI_COMM_NULL) {
- errs++;
- printf( "incorrect lo comm:\n" ); fflush(stdout);
- MPI_Abort(MPI_COMM_WORLD, 3003 );
- }
+ if (lo_comm != MPI_COMM_NULL) {
+ errs++;
+ printf("incorrect lo comm:\n");
+ fflush(stdout);
+ MPI_Abort(MPI_COMM_WORLD, 3003);
+ }
}
#ifdef DEBUG
- printf( "worldrank = %d\n", world_rank );FFLUSH;
+ printf("worldrank = %d\n", world_rank);
+ FFLUSH;
#endif
MPI_Barrier(world_comm);
#ifdef DEBUG
- printf( "bar!\n" );FFLUSH;
+ printf("bar!\n");
+ FFLUSH;
#endif
/*
- Check Comm_dup by adding attributes to lo_comm & duplicating
- */
+ * Check Comm_dup by adding attributes to lo_comm & duplicating
+ */
#ifdef DEBUG
if (world_rank == 0) {
- printf( " Comm_dup\n" );
- fflush(stdout);
+ printf(" Comm_dup\n");
+ fflush(stdout);
}
#endif
-
+
if (lo_comm != MPI_COMM_NULL) {
- value = 9;
- MPI_Keyval_create(copy_fn, delete_fn, &key_1, &value );
- value = 8;
- value = 7;
- MPI_Keyval_create(MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN,
- &key_3, &value );
-
- /* This may generate a compilation warning; it is, however, an
- easy way to cache a value instead of a pointer */
- /* printf( "key1 = %x key3 = %x\n", key_1, key_3 ); */
- MPI_Attr_put(lo_comm, key_1, (void *) (MPI_Aint) world_rank );
- MPI_Attr_put(lo_comm, key_3, (void *)0 );
-
- MPI_Comm_dup(lo_comm, &dup_comm );
-
- /* Note that if sizeof(int) < sizeof(void *), we can't use
- (void **)&value to get the value we passed into Attr_put. To avoid
- problems (e.g., alignment errors), we recover the value into
- a (void *) and cast to int. Note that this may generate warning
- messages from the compiler. */
- MPI_Attr_get(dup_comm, key_1, (void **)&vvalue, &flag );
- value = (MPI_Aint)vvalue;
-
- if (! flag) {
- errs++;
- printf( "dup_comm key_1 not found on %d\n", world_rank );
- fflush( stdout );
- MPI_Abort(MPI_COMM_WORLD, 3004 );
- }
-
- if (value != world_rank) {
- errs++;
- printf( "dup_comm key_1 value incorrect: %ld, expected %d\n",
- (long)value, world_rank );
- fflush( stdout );
- MPI_Abort(MPI_COMM_WORLD, 3005 );
- }
-
- MPI_Attr_get(dup_comm, key_3, (void **)&vvalue, &flag );
- value = (MPI_Aint)vvalue;
- if (flag) {
- errs++;
- printf( "dup_comm key_3 found!\n" );
- fflush( stdout );
- MPI_Abort(MPI_COMM_WORLD, 3008 );
- }
- MPI_Keyval_free(&key_1 );
- MPI_Keyval_free(&key_3 );
+ value = 9;
+ MPI_Keyval_create(copy_fn, delete_fn, &key_1, &value);
+ value = 8;
+ value = 7;
+ MPI_Keyval_create(MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN, &key_3, &value);
+
+ /* This may generate a compilation warning; it is, however, an
+ * easy way to cache a value instead of a pointer */
+ /* printf("key1 = %x key3 = %x\n", key_1, key_3); */
+ MPI_Attr_put(lo_comm, key_1, (void *) (MPI_Aint) world_rank);
+ MPI_Attr_put(lo_comm, key_3, (void *) 0);
+
+ MPI_Comm_dup(lo_comm, &dup_comm);
+
+ /* Note that if sizeof(int) < sizeof(void *), we can't use
+ * (void **)&value to get the value we passed into Attr_put. To avoid
+ * problems (e.g., alignment errors), we recover the value into
+ * a (void *) and cast to int. Note that this may generate warning
+ * messages from the compiler. */
+ MPI_Attr_get(dup_comm, key_1, (void **) &vvalue, &flag);
+ value = (MPI_Aint) vvalue;
+
+ if (!flag) {
+ errs++;
+ printf("dup_comm key_1 not found on %d\n", world_rank);
+ fflush(stdout);
+ MPI_Abort(MPI_COMM_WORLD, 3004);
+ }
+
+ if (value != world_rank) {
+ errs++;
+ printf("dup_comm key_1 value incorrect: %ld, expected %d\n", (long) value, world_rank);
+ fflush(stdout);
+ MPI_Abort(MPI_COMM_WORLD, 3005);
+ }
+
+ MPI_Attr_get(dup_comm, key_3, (void **) &vvalue, &flag);
+ value = (MPI_Aint) vvalue;
+ if (flag) {
+ errs++;
+ printf("dup_comm key_3 found!\n");
+ fflush(stdout);
+ MPI_Abort(MPI_COMM_WORLD, 3008);
+ }
+ MPI_Keyval_free(&key_1);
+ MPI_Keyval_free(&key_3);
}
- /*
- Split the world into even & odd communicators with reversed ranks.
- */
+ /*
+ * Split the world into even & odd communicators with reversed ranks.
+ */
#ifdef DEBUG
if (world_rank == 0) {
- printf( " Comm_split\n" );
- fflush(stdout);
+ printf(" Comm_split\n");
+ fflush(stdout);
}
#endif
-
+
color = world_rank % 2;
- key = world_size - world_rank;
-
- MPI_Comm_split(dup_comm_world, color, key, &split_comm );
- MPI_Comm_size(split_comm, &size );
- MPI_Comm_rank(split_comm, &rank );
- if (rank != ((size - world_rank/2) - 1)) {
- errs++;
- printf( "incorrect split rank: %d\n", rank ); fflush(stdout);
- MPI_Abort(MPI_COMM_WORLD, 3009 );
+ key = world_size - world_rank;
+
+ MPI_Comm_split(dup_comm_world, color, key, &split_comm);
+ MPI_Comm_size(split_comm, &size);
+ MPI_Comm_rank(split_comm, &rank);
+ if (rank != ((size - world_rank / 2) - 1)) {
+ errs++;
+ printf("incorrect split rank: %d\n", rank);
+ fflush(stdout);
+ MPI_Abort(MPI_COMM_WORLD, 3009);
}
-
- MPI_Barrier(split_comm );
+
+ MPI_Barrier(split_comm);
/*
- Test each possible Comm_compare result
- */
+ * Test each possible Comm_compare result
+ */
#ifdef DEBUG
if (world_rank == 0) {
- printf( " Comm_compare\n" );
- fflush(stdout);
+ printf(" Comm_compare\n");
+ fflush(stdout);
}
#endif
-
- MPI_Comm_compare(world_comm, world_comm, &result );
+
+ MPI_Comm_compare(world_comm, world_comm, &result);
if (result != MPI_IDENT) {
- errs++;
- printf( "incorrect ident result: %d\n", result );
- MPI_Abort(MPI_COMM_WORLD, 3010 );
+ errs++;
+ printf("incorrect ident result: %d\n", result);
+ MPI_Abort(MPI_COMM_WORLD, 3010);
}
-
+
if (lo_comm != MPI_COMM_NULL) {
- MPI_Comm_compare(lo_comm, dup_comm, &result );
- if (result != MPI_CONGRUENT) {
- errs++;
- printf( "incorrect congruent result: %d\n", result );
- MPI_Abort(MPI_COMM_WORLD, 3011 );
- }
+ MPI_Comm_compare(lo_comm, dup_comm, &result);
+ if (result != MPI_CONGRUENT) {
+ errs++;
+ printf("incorrect congruent result: %d\n", result);
+ MPI_Abort(MPI_COMM_WORLD, 3011);
+ }
}
-
+
ranges[0][0] = world_size - 1;
ranges[0][1] = 0;
ranges[0][2] = -1;
- MPI_Group_range_incl(world_group, 1, ranges, &rev_group );
- MPI_Comm_create(world_comm, rev_group, &rev_comm );
+ MPI_Group_range_incl(world_group, 1, ranges, &rev_group);
+ MPI_Comm_create(world_comm, rev_group, &rev_comm);
- MPI_Comm_compare(world_comm, rev_comm, &result );
+ MPI_Comm_compare(world_comm, rev_comm, &result);
if (result != MPI_SIMILAR && world_size != 1) {
- errs++;
- printf( "incorrect similar result: %d\n", result );
- MPI_Abort(MPI_COMM_WORLD, 3012 );
+ errs++;
+ printf("incorrect similar result: %d\n", result);
+ MPI_Abort(MPI_COMM_WORLD, 3012);
}
-
+
if (lo_comm != MPI_COMM_NULL) {
- MPI_Comm_compare(world_comm, lo_comm, &result );
- if (result != MPI_UNEQUAL && world_size != 1) {
- errs++;
- printf( "incorrect unequal result: %d\n", result );
- MPI_Abort(MPI_COMM_WORLD, 3013 );
- }
+ MPI_Comm_compare(world_comm, lo_comm, &result);
+ if (result != MPI_UNEQUAL && world_size != 1) {
+ errs++;
+ printf("incorrect unequal result: %d\n", result);
+ MPI_Abort(MPI_COMM_WORLD, 3013);
+ }
}
/*
- Free all communicators created
- */
+ * Free all communicators created
+ */
#ifdef DEBUG
- if (world_rank == 0)
- printf( " Comm_free\n" );
+ if (world_rank == 0)
+ printf(" Comm_free\n");
#endif
-
- MPI_Comm_free( &world_comm );
- MPI_Comm_free( &dup_comm_world );
-
- MPI_Comm_free( &rev_comm );
- MPI_Comm_free( &split_comm );
-
- MPI_Group_free( &world_group );
- MPI_Group_free( &rev_group );
-
+
+ MPI_Comm_free(&world_comm);
+ MPI_Comm_free(&dup_comm_world);
+
+ MPI_Comm_free(&rev_comm);
+ MPI_Comm_free(&split_comm);
+
+ MPI_Group_free(&world_group);
+ MPI_Group_free(&rev_group);
+
if (lo_comm != MPI_COMM_NULL) {
- MPI_Comm_free( &lo_comm );
- MPI_Comm_free( &dup_comm );
+ MPI_Comm_free(&lo_comm);
+ MPI_Comm_free(&dup_comm);
}
-
+
return errs;
}
-
diff --git a/test/mpi/attr/baseattr2.c b/test/mpi/attr/baseattr2.c
index 58190f6..2b04fcb 100644
--- a/test/mpi/attr/baseattr2.c
+++ b/test/mpi/attr/baseattr2.c
@@ -8,167 +8,167 @@
#include "mpi.h"
#include "mpitest.h"
-void MissingKeyval( int rc, const char keyname[] );
+void MissingKeyval(int rc, const char keyname[]);
-int main( int argc, char **argv)
+int main(int argc, char **argv)
{
- int errs = 0;
- int rc;
+ int errs = 0;
+ int rc;
void *v;
- int flag;
- int vval;
- int rank, size;
+ int flag;
+ int vval;
+ int rank, size;
- MTest_Init( &argc, &argv );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- /* Set errors return so that we can provide better information
- should a routine reject one of the attribute values */
- MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ /* Set errors return so that we can provide better information
+ * should a routine reject one of the attribute values */
+ MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
- rc = MPI_Attr_get( MPI_COMM_WORLD, MPI_TAG_UB, &v, &flag );
+ rc = MPI_Attr_get(MPI_COMM_WORLD, MPI_TAG_UB, &v, &flag);
if (rc) {
- MissingKeyval( rc, "MPI_TAG_UB" );
- errs++;
+ MissingKeyval(rc, "MPI_TAG_UB");
+ errs++;
}
else {
- if (!flag) {
- errs++;
- fprintf( stderr, "Could not get TAG_UB\n" );
- }
- else {
- vval = *(int*)v;
- if (vval < 32767) {
- errs++;
- fprintf( stderr, "Got too-small value (%d) for TAG_UB\n", vval );
- }
- }
+ if (!flag) {
+ errs++;
+ fprintf(stderr, "Could not get TAG_UB\n");
+ }
+ else {
+ vval = *(int *) v;
+ if (vval < 32767) {
+ errs++;
+ fprintf(stderr, "Got too-small value (%d) for TAG_UB\n", vval);
+ }
+ }
}
- rc = MPI_Attr_get( MPI_COMM_WORLD, MPI_HOST, &v, &flag );
+ rc = MPI_Attr_get(MPI_COMM_WORLD, MPI_HOST, &v, &flag);
if (rc) {
- MissingKeyval( rc, "MPI_HOST" );
- errs++;
+ MissingKeyval(rc, "MPI_HOST");
+ errs++;
}
else {
- if (!flag) {
- errs++;
- fprintf( stderr, "Could not get HOST\n" );
- }
- else {
- vval = *(int*)v;
- if ((vval < 0 || vval >= size) && vval != MPI_PROC_NULL) {
- errs++;
- fprintf( stderr, "Got invalid value %d for HOST\n", vval );
- }
- }
+ if (!flag) {
+ errs++;
+ fprintf(stderr, "Could not get HOST\n");
+ }
+ else {
+ vval = *(int *) v;
+ if ((vval < 0 || vval >= size) && vval != MPI_PROC_NULL) {
+ errs++;
+ fprintf(stderr, "Got invalid value %d for HOST\n", vval);
+ }
+ }
}
- rc = MPI_Attr_get( MPI_COMM_WORLD, MPI_IO, &v, &flag );
+ rc = MPI_Attr_get(MPI_COMM_WORLD, MPI_IO, &v, &flag);
if (rc) {
- MissingKeyval( rc, "MPI_IO" );
- errs++;
+ MissingKeyval(rc, "MPI_IO");
+ errs++;
}
else {
- if (!flag) {
- errs++;
- fprintf( stderr, "Could not get IO\n" );
- }
- else {
- vval = *(int*)v;
- if ((vval < 0 || vval >= size) && vval != MPI_ANY_SOURCE &&
- vval != MPI_PROC_NULL) {
- errs++;
- fprintf( stderr, "Got invalid value %d for IO\n", vval );
- }
- }
+ if (!flag) {
+ errs++;
+ fprintf(stderr, "Could not get IO\n");
+ }
+ else {
+ vval = *(int *) v;
+ if ((vval < 0 || vval >= size) && vval != MPI_ANY_SOURCE && vval != MPI_PROC_NULL) {
+ errs++;
+ fprintf(stderr, "Got invalid value %d for IO\n", vval);
+ }
+ }
}
- rc = MPI_Attr_get( MPI_COMM_WORLD, MPI_WTIME_IS_GLOBAL, &v, &flag );
+ rc = MPI_Attr_get(MPI_COMM_WORLD, MPI_WTIME_IS_GLOBAL, &v, &flag);
if (rc) {
- MissingKeyval( rc, "MPI_WTIME_IS_GLOBAL" );
- errs++;
+ MissingKeyval(rc, "MPI_WTIME_IS_GLOBAL");
+ errs++;
}
else {
- if (flag) {
- /* Wtime need not be set */
- vval = *(int*)v;
- if (vval < 0 || vval > 1) {
- errs++;
- fprintf( stderr, "Invalid value for WTIME_IS_GLOBAL (got %d)\n",
- vval );
- }
- }
+ if (flag) {
+ /* Wtime need not be set */
+ vval = *(int *) v;
+ if (vval < 0 || vval > 1) {
+ errs++;
+ fprintf(stderr, "Invalid value for WTIME_IS_GLOBAL (got %d)\n", vval);
+ }
+ }
}
- rc = MPI_Attr_get( MPI_COMM_WORLD, MPI_APPNUM, &v, &flag );
+ rc = MPI_Attr_get(MPI_COMM_WORLD, MPI_APPNUM, &v, &flag);
if (rc) {
- MissingKeyval( rc, "MPI_APPNUM" );
- errs++;
+ MissingKeyval(rc, "MPI_APPNUM");
+ errs++;
}
else {
- /* appnum need not be set */
- if (flag) {
- vval = *(int *)v;
- if (vval < 0) {
- errs++;
- fprintf( stderr, "MPI_APPNUM is defined as %d but must be nonnegative\n", vval );
- }
- }
+ /* appnum need not be set */
+ if (flag) {
+ vval = *(int *) v;
+ if (vval < 0) {
+ errs++;
+ fprintf(stderr, "MPI_APPNUM is defined as %d but must be nonnegative\n", vval);
+ }
+ }
}
- rc = MPI_Attr_get( MPI_COMM_WORLD, MPI_UNIVERSE_SIZE, &v, &flag );
+ rc = MPI_Attr_get(MPI_COMM_WORLD, MPI_UNIVERSE_SIZE, &v, &flag);
if (rc) {
- MissingKeyval( rc, "MPI_UNIVERSE_SIZE" );
- errs++;
+ MissingKeyval(rc, "MPI_UNIVERSE_SIZE");
+ errs++;
}
else {
- /* MPI_UNIVERSE_SIZE need not be set */
- if (flag) {
- vval = *(int *)v;
- if (vval < size) {
- errs++;
- fprintf( stderr, "MPI_UNIVERSE_SIZE = %d, less than comm world (%d)\n", vval, size );
- }
- }
+ /* MPI_UNIVERSE_SIZE need not be set */
+ if (flag) {
+ vval = *(int *) v;
+ if (vval < size) {
+ errs++;
+ fprintf(stderr, "MPI_UNIVERSE_SIZE = %d, less than comm world (%d)\n", vval, size);
+ }
+ }
}
- rc = MPI_Attr_get( MPI_COMM_WORLD, MPI_LASTUSEDCODE, &v, &flag );
+ rc = MPI_Attr_get(MPI_COMM_WORLD, MPI_LASTUSEDCODE, &v, &flag);
if (rc) {
- MissingKeyval( rc, "MPI_LASTUSEDCODE" );
- errs++;
+ MissingKeyval(rc, "MPI_LASTUSEDCODE");
+ errs++;
}
else {
- /* Last used code must be defined and >= MPI_ERR_LASTCODE */
- if (flag) {
- vval = *(int*)v;
- if (vval < MPI_ERR_LASTCODE) {
- errs++;
- fprintf( stderr, "MPI_LASTUSEDCODE points to an integer (%d) smaller than MPI_ERR_LASTCODE (%d)\n", vval, MPI_ERR_LASTCODE );
- }
- }
- else {
- errs++;
- fprintf( stderr, "MPI_LASTUSECODE is not defined\n" );
- }
+ /* Last used code must be defined and >= MPI_ERR_LASTCODE */
+ if (flag) {
+ vval = *(int *) v;
+ if (vval < MPI_ERR_LASTCODE) {
+ errs++;
+ fprintf(stderr,
+ "MPI_LASTUSEDCODE points to an integer (%d) smaller than MPI_ERR_LASTCODE (%d)\n",
+ vval, MPI_ERR_LASTCODE);
+ }
+ }
+ else {
+ errs++;
+ fprintf(stderr, "MPI_LASTUSECODE is not defined\n");
+ }
}
- MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL );
+ MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL);
+
+ MTest_Finalize(errs);
+ MPI_Finalize();
- MTest_Finalize( errs );
- MPI_Finalize( );
-
return 0;
}
-void MissingKeyval( int errcode, const char keyname[] )
+void MissingKeyval(int errcode, const char keyname[])
{
int errclass, slen;
char string[MPI_MAX_ERROR_STRING];
-
- MPI_Error_class( errcode, &errclass );
- MPI_Error_string( errcode, string, &slen );
- printf( "For key %s: Error class %d (%s)\n", keyname, errclass, string );
- fflush( stdout );
+
+ MPI_Error_class(errcode, &errclass);
+ MPI_Error_string(errcode, string, &slen);
+ printf("For key %s: Error class %d (%s)\n", keyname, errclass, string);
+ fflush(stdout);
}
diff --git a/test/mpi/attr/baseattrcomm.c b/test/mpi/attr/baseattrcomm.c
index aaa7622..83c7971 100644
--- a/test/mpi/attr/baseattrcomm.c
+++ b/test/mpi/attr/baseattrcomm.c
@@ -8,111 +8,111 @@
#include "mpi.h"
#include "mpitest.h"
-int main( int argc, char **argv)
+int main(int argc, char **argv)
{
- int errs = 0;
+ int errs = 0;
void *v;
- int flag;
- int vval;
- int rank, size;
+ int flag;
+ int vval;
+ int rank, size;
- MTest_Init( &argc, &argv );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- MPI_Comm_get_attr( MPI_COMM_WORLD, MPI_TAG_UB, &v, &flag );
+ MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_TAG_UB, &v, &flag);
if (!flag) {
- errs++;
- fprintf( stderr, "Could not get TAG_UB\n" );
+ errs++;
+ fprintf(stderr, "Could not get TAG_UB\n");
}
else {
- vval = *(int*)v;
- if (vval < 32767) {
- errs++;
- fprintf( stderr, "Got too-small value (%d) for TAG_UB\n", vval );
- }
+ vval = *(int *) v;
+ if (vval < 32767) {
+ errs++;
+ fprintf(stderr, "Got too-small value (%d) for TAG_UB\n", vval);
+ }
}
- MPI_Comm_get_attr( MPI_COMM_WORLD, MPI_HOST, &v, &flag );
+ MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_HOST, &v, &flag);
if (!flag) {
- errs++;
- fprintf( stderr, "Could not get HOST\n" );
+ errs++;
+ fprintf(stderr, "Could not get HOST\n");
}
else {
- vval = *(int*)v;
- if ((vval < 0 || vval >= size) && vval != MPI_PROC_NULL) {
- errs++;
- fprintf( stderr, "Got invalid value %d for HOST\n", vval );
- }
+ vval = *(int *) v;
+ if ((vval < 0 || vval >= size) && vval != MPI_PROC_NULL) {
+ errs++;
+ fprintf(stderr, "Got invalid value %d for HOST\n", vval);
+ }
}
- MPI_Comm_get_attr( MPI_COMM_WORLD, MPI_IO, &v, &flag );
+ MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_IO, &v, &flag);
if (!flag) {
- errs++;
- fprintf( stderr, "Could not get IO\n" );
+ errs++;
+ fprintf(stderr, "Could not get IO\n");
}
else {
- vval = *(int*)v;
- if ((vval < 0 || vval >= size) && vval != MPI_ANY_SOURCE &&
- vval != MPI_PROC_NULL) {
- errs++;
- fprintf( stderr, "Got invalid value %d for IO\n", vval );
- }
+ vval = *(int *) v;
+ if ((vval < 0 || vval >= size) && vval != MPI_ANY_SOURCE && vval != MPI_PROC_NULL) {
+ errs++;
+ fprintf(stderr, "Got invalid value %d for IO\n", vval);
+ }
}
- MPI_Comm_get_attr( MPI_COMM_WORLD, MPI_WTIME_IS_GLOBAL, &v, &flag );
+ MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_WTIME_IS_GLOBAL, &v, &flag);
if (flag) {
- /* Wtime need not be set */
- vval = *(int*)v;
- if (vval < 0 || vval > 1) {
- errs++;
- fprintf( stderr, "Invalid value for WTIME_IS_GLOBAL (got %d)\n",
- vval );
- }
+ /* Wtime need not be set */
+ vval = *(int *) v;
+ if (vval < 0 || vval > 1) {
+ errs++;
+ fprintf(stderr, "Invalid value for WTIME_IS_GLOBAL (got %d)\n", vval);
+ }
}
/* MPI 2.0, section 5.5.3 - MPI_APPNUM should be set if the program is
- started with more than one executable name (e.g., in MPMD instead
- of SPMD mode). This is independent of the dynamic process routines,
- and should be supported even if MPI_COMM_SPAWN and friends are not. */
- MPI_Comm_get_attr( MPI_COMM_WORLD, MPI_APPNUM, &v, &flag );
+ * started with more than one executable name (e.g., in MPMD instead
+ * of SPMD mode). This is independent of the dynamic process routines,
+ * and should be supported even if MPI_COMM_SPAWN and friends are not. */
+ MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_APPNUM, &v, &flag);
/* appnum need not be set */
if (flag) {
- vval = *(int *)v;
- if (vval < 0) {
- errs++;
- fprintf( stderr, "MPI_APPNUM is defined as %d but must be nonnegative\n", vval );
- }
+ vval = *(int *) v;
+ if (vval < 0) {
+ errs++;
+ fprintf(stderr, "MPI_APPNUM is defined as %d but must be nonnegative\n", vval);
+ }
}
/* MPI 2.0 section 5.5.1. MPI_UNIVERSE_SIZE need not be set, but
- should be present. */
- MPI_Comm_get_attr( MPI_COMM_WORLD, MPI_UNIVERSE_SIZE, &v, &flag );
+ * should be present. */
+ MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_UNIVERSE_SIZE, &v, &flag);
/* MPI_UNIVERSE_SIZE need not be set */
if (flag) {
- /* But if it is set, it must be at least the size of comm_world */
- vval = *(int *)v;
- if (vval < size) {
- errs++;
- fprintf( stderr, "MPI_UNIVERSE_SIZE = %d, less than comm world (%d)\n", vval, size );
- }
+ /* But if it is set, it must be at least the size of comm_world */
+ vval = *(int *) v;
+ if (vval < size) {
+ errs++;
+ fprintf(stderr, "MPI_UNIVERSE_SIZE = %d, less than comm world (%d)\n", vval, size);
+ }
}
-
- MPI_Comm_get_attr( MPI_COMM_WORLD, MPI_LASTUSEDCODE, &v, &flag );
+
+ MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_LASTUSEDCODE, &v, &flag);
/* Last used code must be defined and >= MPI_ERR_LASTCODE */
if (flag) {
- vval = *(int*)v;
- if (vval < MPI_ERR_LASTCODE) {
- errs++;
- fprintf( stderr, "MPI_LASTUSEDCODE points to an integer (%d) smaller than MPI_ERR_LASTCODE (%d)\n", vval, MPI_ERR_LASTCODE );
- }
+ vval = *(int *) v;
+ if (vval < MPI_ERR_LASTCODE) {
+ errs++;
+ fprintf(stderr,
+ "MPI_LASTUSEDCODE points to an integer (%d) smaller than MPI_ERR_LASTCODE (%d)\n",
+ vval, MPI_ERR_LASTCODE);
+ }
}
else {
- errs++;
- fprintf( stderr, "MPI_LASTUSECODE is not defined\n" );
+ errs++;
+ fprintf(stderr, "MPI_LASTUSECODE is not defined\n");
}
- MTest_Finalize( errs );
- MPI_Finalize( );
-
+ MTest_Finalize(errs);
+ MPI_Finalize();
+
return 0;
}
diff --git a/test/mpi/attr/fkeyval.c b/test/mpi/attr/fkeyval.c
index 48722c1..ecaff99 100644
--- a/test/mpi/attr/fkeyval.c
+++ b/test/mpi/attr/fkeyval.c
@@ -15,99 +15,92 @@ executed";
*/
/* Function prototypes to keep compilers happy */
-int copy_fn( MPI_Comm oldcomm, int keyval, void *extra_state,
- void *attribute_val_in, void *attribute_val_out,
- int *flag);
-int delete_fn( MPI_Comm comm, int keyval, void *attribute_val,
- void *extra_state);
+int copy_fn(MPI_Comm oldcomm, int keyval, void *extra_state,
+ void *attribute_val_in, void *attribute_val_out, int *flag);
+int delete_fn(MPI_Comm comm, int keyval, void *attribute_val, void *extra_state);
/* Copy increments the attribute value */
-int copy_fn( MPI_Comm oldcomm, int keyval, void *extra_state,
- void *attribute_val_in, void *attribute_val_out,
- int *flag)
+int copy_fn(MPI_Comm oldcomm, int keyval, void *extra_state,
+ void *attribute_val_in, void *attribute_val_out, int *flag)
{
/* Copy the address of the attribute */
- *(void **)attribute_val_out = attribute_val_in;
+ *(void **) attribute_val_out = attribute_val_in;
/* Change the value */
- *(int *)attribute_val_in = *(int *)attribute_val_in + 1;
+ *(int *) attribute_val_in = *(int *) attribute_val_in + 1;
/* set flag to 1 to tell comm dup to insert this attribute
- into the new communicator */
+ * into the new communicator */
*flag = 1;
return MPI_SUCCESS;
}
/* Delete decrements the attribute value */
-int delete_fn( MPI_Comm comm, int keyval, void *attribute_val,
- void *extra_state)
+int delete_fn(MPI_Comm comm, int keyval, void *attribute_val, void *extra_state)
{
- *(int *)attribute_val = *(int *)attribute_val - 1;
+ *(int *) attribute_val = *(int *) attribute_val - 1;
return MPI_SUCCESS;
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int attrval;
int i, key[32], keyval, saveKeyval;
MPI_Comm comm, dupcomm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- while (MTestGetIntracomm( &comm, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
+ while (MTestGetIntracomm(&comm, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
- MPI_Keyval_create( copy_fn, delete_fn, &keyval, (void *)0 );
- saveKeyval = keyval; /* in case we need to free explicitly */
- attrval = 1;
- MPI_Attr_put( comm, keyval, (void*)&attrval );
- /* See MPI-1, 5.7.1. Freeing the keyval does not remove it if it
- is in use in an attribute */
- MPI_Keyval_free( &keyval );
-
- /* We create some dummy keyvals here in case the same keyval
- is reused */
- for (i=0; i<32; i++) {
- MPI_Keyval_create( MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN,
- &key[i], (void *)0 );
- }
+ MPI_Keyval_create(copy_fn, delete_fn, &keyval, (void *) 0);
+ saveKeyval = keyval; /* in case we need to free explicitly */
+ attrval = 1;
+ MPI_Attr_put(comm, keyval, (void *) &attrval);
+ /* See MPI-1, 5.7.1. Freeing the keyval does not remove it if it
+ * is in use in an attribute */
+ MPI_Keyval_free(&keyval);
- MPI_Comm_dup( comm, &dupcomm );
- /* Check that the attribute was copied */
- if (attrval != 2) {
- errs++;
- printf( "Attribute not incremented when comm dup'ed (%s)\n",
- MTestGetIntracommName() );
- }
- MPI_Comm_free( &dupcomm );
- if (attrval != 1) {
- errs++;
- printf( "Attribute not decremented when dupcomm %s freed\n",
- MTestGetIntracommName() );
- }
- /* Check that the attribute was freed in the dupcomm */
+ /* We create some dummy keyvals here in case the same keyval
+ * is reused */
+ for (i = 0; i < 32; i++) {
+ MPI_Keyval_create(MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN, &key[i], (void *) 0);
+ }
- if (comm != MPI_COMM_WORLD && comm != MPI_COMM_SELF) {
- MPI_Comm_free( &comm );
- /* Check that the original attribute was freed */
- if (attrval != 0) {
- errs++;
- printf( "Attribute not decremented when comm %s freed\n",
- MTestGetIntracommName() );
- }
- }
- else {
- /* Explicitly delete the attributes from world and self */
- MPI_Attr_delete( comm, saveKeyval );
- }
- /* Free those other keyvals */
- for (i=0; i<32; i++) {
- MPI_Keyval_free( &key[i] );
- }
+ MPI_Comm_dup(comm, &dupcomm);
+ /* Check that the attribute was copied */
+ if (attrval != 2) {
+ errs++;
+ printf("Attribute not incremented when comm dup'ed (%s)\n", MTestGetIntracommName());
+ }
+ MPI_Comm_free(&dupcomm);
+ if (attrval != 1) {
+ errs++;
+ printf("Attribute not decremented when dupcomm %s freed\n", MTestGetIntracommName());
+ }
+ /* Check that the attribute was freed in the dupcomm */
+
+ if (comm != MPI_COMM_WORLD && comm != MPI_COMM_SELF) {
+ MPI_Comm_free(&comm);
+ /* Check that the original attribute was freed */
+ if (attrval != 0) {
+ errs++;
+ printf("Attribute not decremented when comm %s freed\n", MTestGetIntracommName());
+ }
+ }
+ else {
+ /* Explicitly delete the attributes from world and self */
+ MPI_Attr_delete(comm, saveKeyval);
+ }
+ /* Free those other keyvals */
+ for (i = 0; i < 32; i++) {
+ MPI_Keyval_free(&key[i]);
+ }
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
- /* The attributes on comm self and world were deleted by finalize
- (see separate test) */
-
+ /* The attributes on comm self and world were deleted by finalize
+ * (see separate test) */
+
return 0;
}
diff --git a/test/mpi/attr/fkeyvalcomm.c b/test/mpi/attr/fkeyvalcomm.c
index e2e6614..c647896 100644
--- a/test/mpi/attr/fkeyvalcomm.c
+++ b/test/mpi/attr/fkeyvalcomm.c
@@ -15,100 +15,93 @@ executed";
*/
/* Function prototypes to keep compilers happy */
-int copy_fn( MPI_Comm oldcomm, int keyval, void *extra_state,
- void *attribute_val_in, void *attribute_val_out,
- int *flag);
-int delete_fn( MPI_Comm comm, int keyval, void *attribute_val,
- void *extra_state);
+int copy_fn(MPI_Comm oldcomm, int keyval, void *extra_state,
+ void *attribute_val_in, void *attribute_val_out, int *flag);
+int delete_fn(MPI_Comm comm, int keyval, void *attribute_val, void *extra_state);
/* Copy increments the attribute value */
-int copy_fn( MPI_Comm oldcomm, int keyval, void *extra_state,
- void *attribute_val_in, void *attribute_val_out,
- int *flag)
+int copy_fn(MPI_Comm oldcomm, int keyval, void *extra_state,
+ void *attribute_val_in, void *attribute_val_out, int *flag)
{
/* Copy the address of the attribute */
- *(void **)attribute_val_out = attribute_val_in;
+ *(void **) attribute_val_out = attribute_val_in;
/* Change the value */
- *(int *)attribute_val_in = *(int *)attribute_val_in + 1;
+ *(int *) attribute_val_in = *(int *) attribute_val_in + 1;
/* set flag to 1 to tell comm dup to insert this attribute
- into the new communicator */
+ * into the new communicator */
*flag = 1;
return MPI_SUCCESS;
}
/* Delete decrements the attribute value */
-int delete_fn( MPI_Comm comm, int keyval, void *attribute_val,
- void *extra_state)
+int delete_fn(MPI_Comm comm, int keyval, void *attribute_val, void *extra_state)
{
- *(int *)attribute_val = *(int *)attribute_val - 1;
+ *(int *) attribute_val = *(int *) attribute_val - 1;
return MPI_SUCCESS;
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int attrval;
int i, key[32], keyval, saveKeyval;
MPI_Comm comm, dupcomm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- while (MTestGetIntracomm( &comm, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
+ while (MTestGetIntracomm(&comm, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
- MPI_Comm_create_keyval( copy_fn, delete_fn, &keyval, (void *)0 );
- saveKeyval = keyval; /* in case we need to free explicitly */
- attrval = 1;
- MPI_Comm_set_attr( comm, keyval, (void*)&attrval );
- /* See MPI-1, 5.7.1. Freeing the keyval does not remove it if it
- is in use in an attribute */
- MPI_Comm_free_keyval( &keyval );
-
- /* We create some dummy keyvals here in case the same keyval
- is reused */
- for (i=0; i<32; i++) {
- MPI_Comm_create_keyval( MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN,
- &key[i], (void *)0 );
- }
+ MPI_Comm_create_keyval(copy_fn, delete_fn, &keyval, (void *) 0);
+ saveKeyval = keyval; /* in case we need to free explicitly */
+ attrval = 1;
+ MPI_Comm_set_attr(comm, keyval, (void *) &attrval);
+ /* See MPI-1, 5.7.1. Freeing the keyval does not remove it if it
+ * is in use in an attribute */
+ MPI_Comm_free_keyval(&keyval);
- MPI_Comm_dup( comm, &dupcomm );
- /* Check that the attribute was copied */
- if (attrval != 2) {
- errs++;
- printf( "Attribute not incremented when comm dup'ed (%s)\n",
- MTestGetIntracommName() );
- }
- MPI_Comm_free( &dupcomm );
- if (attrval != 1) {
- errs++;
- printf( "Attribute not decremented when dupcomm %s freed\n",
- MTestGetIntracommName() );
- }
- /* Check that the attribute was freed in the dupcomm */
+ /* We create some dummy keyvals here in case the same keyval
+ * is reused */
+ for (i = 0; i < 32; i++) {
+ MPI_Comm_create_keyval(MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN, &key[i], (void *) 0);
+ }
- if (comm != MPI_COMM_WORLD && comm != MPI_COMM_SELF) {
- MPI_Comm_free( &comm );
- /* Check that the original attribute was freed */
- if (attrval != 0) {
- errs++;
- printf( "Attribute not decremented when comm %s freed\n",
- MTestGetIntracommName() );
- }
- }
- else {
- /* Explicitly delete the attributes from world and self */
- MPI_Comm_delete_attr( comm, saveKeyval );
- }
- /* Free those other keyvals */
- for (i=0; i<32; i++) {
- MPI_Comm_free_keyval( &key[i] );
- }
+ MPI_Comm_dup(comm, &dupcomm);
+ /* Check that the attribute was copied */
+ if (attrval != 2) {
+ errs++;
+ printf("Attribute not incremented when comm dup'ed (%s)\n", MTestGetIntracommName());
+ }
+ MPI_Comm_free(&dupcomm);
+ if (attrval != 1) {
+ errs++;
+ printf("Attribute not decremented when dupcomm %s freed\n", MTestGetIntracommName());
+ }
+ /* Check that the attribute was freed in the dupcomm */
+
+ if (comm != MPI_COMM_WORLD && comm != MPI_COMM_SELF) {
+ MPI_Comm_free(&comm);
+ /* Check that the original attribute was freed */
+ if (attrval != 0) {
+ errs++;
+ printf("Attribute not decremented when comm %s freed\n", MTestGetIntracommName());
+ }
+ }
+ else {
+ /* Explicitly delete the attributes from world and self */
+ MPI_Comm_delete_attr(comm, saveKeyval);
+ }
+ /* Free those other keyvals */
+ for (i = 0; i < 32; i++) {
+ MPI_Comm_free_keyval(&key[i]);
+ }
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
- /* The attributes on comm self and world were deleted by finalize
- (see separate test) */
-
+ /* The attributes on comm self and world were deleted by finalize
+ * (see separate test) */
+
return 0;
-
+
}
diff --git a/test/mpi/attr/fkeyvaltype.c b/test/mpi/attr/fkeyvaltype.c
index 392e51d..59cfe0b 100644
--- a/test/mpi/attr/fkeyvaltype.c
+++ b/test/mpi/attr/fkeyvaltype.c
@@ -16,34 +16,30 @@ executed";
*/
/* Copy increments the attribute value */
-int copy_fn( MPI_Datatype oldtype, int keyval, void *extra_state,
- void *attribute_val_in, void *attribute_val_out,
- int *flag);
-int copy_fn( MPI_Datatype oldtype, int keyval, void *extra_state,
- void *attribute_val_in, void *attribute_val_out,
- int *flag)
+int copy_fn(MPI_Datatype oldtype, int keyval, void *extra_state,
+ void *attribute_val_in, void *attribute_val_out, int *flag);
+int copy_fn(MPI_Datatype oldtype, int keyval, void *extra_state,
+ void *attribute_val_in, void *attribute_val_out, int *flag)
{
/* Copy the address of the attribute */
- *(void **)attribute_val_out = attribute_val_in;
+ *(void **) attribute_val_out = attribute_val_in;
/* Change the value */
- *(int *)attribute_val_in = *(int *)attribute_val_in + 1;
+ *(int *) attribute_val_in = *(int *) attribute_val_in + 1;
/* set flag to 1 to tell comm dup to insert this attribute
- into the new communicator */
+ * into the new communicator */
*flag = 1;
return MPI_SUCCESS;
}
/* Delete decrements the attribute value */
-int delete_fn( MPI_Datatype type, int keyval, void *attribute_val,
- void *extra_state);
-int delete_fn( MPI_Datatype type, int keyval, void *attribute_val,
- void *extra_state)
+int delete_fn(MPI_Datatype type, int keyval, void *attribute_val, void *extra_state);
+int delete_fn(MPI_Datatype type, int keyval, void *attribute_val, void *extra_state)
{
- *(int *)attribute_val = *(int *)attribute_val - 1;
+ *(int *) attribute_val = *(int *) attribute_val - 1;
return MPI_SUCCESS;
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int attrval;
@@ -53,75 +49,70 @@ int main( int argc, char *argv[] )
char typename[MPI_MAX_OBJECT_NAME];
int tnlen;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- while (MTestGetDatatypes( &mstype, &mrtype, 1 )) {
- type = mstype.datatype;
- MPI_Type_create_keyval( copy_fn, delete_fn, &keyval, (void *)0 );
- saveKeyval = keyval; /* in case we need to free explicitly */
- attrval = 1;
- MPI_Type_set_attr( type, keyval, (void*)&attrval );
- /* See MPI-1, 5.7.1. Freeing the keyval does not remove it if it
- is in use in an attribute */
- MPI_Type_free_keyval( &keyval );
-
- /* We create some dummy keyvals here in case the same keyval
- is reused */
- for (i=0; i<32; i++) {
- MPI_Type_create_keyval( MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN,
- &key[i], (void *)0 );
- }
+ while (MTestGetDatatypes(&mstype, &mrtype, 1)) {
+ type = mstype.datatype;
+ MPI_Type_create_keyval(copy_fn, delete_fn, &keyval, (void *) 0);
+ saveKeyval = keyval; /* in case we need to free explicitly */
+ attrval = 1;
+ MPI_Type_set_attr(type, keyval, (void *) &attrval);
+ /* See MPI-1, 5.7.1. Freeing the keyval does not remove it if it
+ * is in use in an attribute */
+ MPI_Type_free_keyval(&keyval);
- if (attrval != 1) {
- errs++;
- MPI_Type_get_name( type, typename, &tnlen );
- printf( "attrval is %d, should be 1, before dup in type %s\n",
- attrval, typename );
- }
- MPI_Type_dup( type, &duptype );
- /* Check that the attribute was copied */
- if (attrval != 2) {
- errs++;
- MPI_Type_get_name( type, typename, &tnlen );
- printf( "Attribute not incremented when type dup'ed (%s)\n",
- typename );
- }
- MPI_Type_free( &duptype );
- if (attrval != 1) {
- errs++;
- MPI_Type_get_name( type, typename, &tnlen );
- printf( "Attribute not decremented when duptype %s freed\n",
- typename );
- }
- /* Check that the attribute was freed in the duptype */
+ /* We create some dummy keyvals here in case the same keyval
+ * is reused */
+ for (i = 0; i < 32; i++) {
+ MPI_Type_create_keyval(MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN, &key[i], (void *) 0);
+ }
- if (!mstype.isBasic) {
- MPI_Type_get_name( type, typename, &tnlen );
+ if (attrval != 1) {
+ errs++;
+ MPI_Type_get_name(type, typename, &tnlen);
+ printf("attrval is %d, should be 1, before dup in type %s\n", attrval, typename);
+ }
+ MPI_Type_dup(type, &duptype);
+ /* Check that the attribute was copied */
+ if (attrval != 2) {
+ errs++;
+ MPI_Type_get_name(type, typename, &tnlen);
+ printf("Attribute not incremented when type dup'ed (%s)\n", typename);
+ }
+ MPI_Type_free(&duptype);
+ if (attrval != 1) {
+ errs++;
+ MPI_Type_get_name(type, typename, &tnlen);
+ printf("Attribute not decremented when duptype %s freed\n", typename);
+ }
+ /* Check that the attribute was freed in the duptype */
+
+ if (!mstype.isBasic) {
+ MPI_Type_get_name(type, typename, &tnlen);
MTestFreeDatatype(&mstype);
- /* Check that the original attribute was freed */
- if (attrval != 0) {
- errs++;
- printf( "Attribute not decremented when type %s freed\n",
- typename );
- }
- }
- else {
- /* Explicitly delete the attributes from world and self */
- MPI_Type_delete_attr( type, saveKeyval );
+ /* Check that the original attribute was freed */
+ if (attrval != 0) {
+ errs++;
+ printf("Attribute not decremented when type %s freed\n", typename);
+ }
+ }
+ else {
+ /* Explicitly delete the attributes from world and self */
+ MPI_Type_delete_attr(type, saveKeyval);
if (mstype.buf) {
free(mstype.buf);
mstype.buf = 0;
}
- }
- /* Free those other keyvals */
- for (i=0; i<32; i++) {
- MPI_Type_free_keyval( &key[i] );
- }
+ }
+ /* Free those other keyvals */
+ for (i = 0; i < 32; i++) {
+ MPI_Type_free_keyval(&key[i]);
+ }
MTestFreeDatatype(&mrtype);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/attr/keyval_double_free.c b/test/mpi/attr/keyval_double_free.c
index 9b5eaa6..b331d9a 100644
--- a/test/mpi/attr/keyval_double_free.c
+++ b/test/mpi/attr/keyval_double_free.c
@@ -12,31 +12,32 @@
/* tests multiple invocations of Keyval_free on the same keyval */
int delete_fn(MPI_Comm comm, int keyval, void *attr, void *extra);
-int delete_fn(MPI_Comm comm, int keyval, void *attr, void *extra) {
+int delete_fn(MPI_Comm comm, int keyval, void *attr, void *extra)
+{
MPI_Keyval_free(&keyval);
return MPI_SUCCESS;
}
-int main (int argc, char **argv)
+int main(int argc, char **argv)
{
MPI_Comm duped;
int keyval = MPI_KEYVAL_INVALID;
int keyval_copy = MPI_KEYVAL_INVALID;
- int errs=0;
+ int errs = 0;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
MPI_Comm_dup(MPI_COMM_SELF, &duped);
- MPI_Keyval_create(MPI_NULL_COPY_FN, delete_fn, &keyval, NULL);
+ MPI_Keyval_create(MPI_NULL_COPY_FN, delete_fn, &keyval, NULL);
keyval_copy = keyval;
MPI_Attr_put(MPI_COMM_SELF, keyval, NULL);
MPI_Attr_put(duped, keyval, NULL);
- MPI_Comm_free(&duped); /* first MPI_Keyval_free */
- MPI_Keyval_free(&keyval); /* second MPI_Keyval_free */
- MPI_Keyval_free(&keyval_copy); /* third MPI_Keyval_free */
- MTest_Finalize( errs );
- MPI_Finalize(); /* fourth MPI_Keyval_free */
+ MPI_Comm_free(&duped); /* first MPI_Keyval_free */
+ MPI_Keyval_free(&keyval); /* second MPI_Keyval_free */
+ MPI_Keyval_free(&keyval_copy); /* third MPI_Keyval_free */
+ MTest_Finalize(errs);
+ MPI_Finalize(); /* fourth MPI_Keyval_free */
return 0;
}
diff --git a/test/mpi/basic/GetOpt.c b/test/mpi/basic/GetOpt.c
index 9f99d74..0ad2dd7 100644
--- a/test/mpi/basic/GetOpt.c
+++ b/test/mpi/basic/GetOpt.c
@@ -7,108 +7,95 @@
#include "GetOpt.h"
#include <stdio.h>
-bool GetOpt(int *argc, LPTSTR **argv, CLPTSTR flag)
+bool GetOpt(int *argc, LPTSTR ** argv, CLPTSTR flag)
{
- int i,j;
- if (flag == NULL)
- return false;
-
- for (i=0; i<*argc; i++)
- {
- if (_tcsicmp((*argv)[i], flag) == 0)
- {
- for (j=i; j<*argc; j++)
- {
- (*argv)[j] = (*argv)[j+1];
- }
- *argc -= 1;
- return true;
- }
+ int i, j;
+ if (flag == NULL)
+ return false;
+
+ for (i = 0; i < *argc; i++) {
+ if (_tcsicmp((*argv)[i], flag) == 0) {
+ for (j = i; j < *argc; j++) {
+ (*argv)[j] = (*argv)[j + 1];
+ }
+ *argc -= 1;
+ return true;
+ }
}
- return false;
+ return false;
}
-bool GetOptInt(int *argc, LPTSTR **argv, CLPTSTR flag, int *n)
+bool GetOptInt(int *argc, LPTSTR ** argv, CLPTSTR flag, int *n)
{
- int i,j;
- if (flag == NULL)
- return false;
-
- for (i=0; i<*argc; i++)
- {
- if (_tcsicmp((*argv)[i], flag) == 0)
- {
- if (i+1 == *argc)
- return false;
- *n = _ttoi((*argv)[i+1]);
- for (j=i; j<*argc-1; j++)
- {
- (*argv)[j] = (*argv)[j+2];
- }
- *argc -= 2;
- return true;
- }
+ int i, j;
+ if (flag == NULL)
+ return false;
+
+ for (i = 0; i < *argc; i++) {
+ if (_tcsicmp((*argv)[i], flag) == 0) {
+ if (i + 1 == *argc)
+ return false;
+ *n = _ttoi((*argv)[i + 1]);
+ for (j = i; j < *argc - 1; j++) {
+ (*argv)[j] = (*argv)[j + 2];
+ }
+ *argc -= 2;
+ return true;
+ }
}
- return false;
+ return false;
}
-bool GetOptLong(int *argc, LPTSTR **argv, CLPTSTR flag, long *n)
+bool GetOptLong(int *argc, LPTSTR ** argv, CLPTSTR flag, long *n)
{
- int i;
- if (GetOptInt(argc, argv, flag, &i))
- {
- *n = (long)i;
- return true;
+ int i;
+ if (GetOptInt(argc, argv, flag, &i)) {
+ *n = (long) i;
+ return true;
}
- return false;
+ return false;
}
-bool GetOptDouble(int *argc, LPTSTR **argv, CLPTSTR flag, double *d)
+bool GetOptDouble(int *argc, LPTSTR ** argv, CLPTSTR flag, double *d)
{
- int i,j;
+ int i, j;
- if (flag == NULL)
- return false;
-
- for (i=0; i<*argc; i++)
- {
- if (_tcsicmp((*argv)[i], flag) == 0)
- {
- if (i+1 == *argc)
- return false;
- *d = _tcstod((*argv)[i+1], NULL);
- for (j=i; j<*argc-1; j++)
- {
- (*argv)[j] = (*argv)[j+2];
- }
- *argc -= 2;
- return true;
- }
+ if (flag == NULL)
+ return false;
+
+ for (i = 0; i < *argc; i++) {
+ if (_tcsicmp((*argv)[i], flag) == 0) {
+ if (i + 1 == *argc)
+ return false;
+ *d = _tcstod((*argv)[i + 1], NULL);
+ for (j = i; j < *argc - 1; j++) {
+ (*argv)[j] = (*argv)[j + 2];
+ }
+ *argc -= 2;
+ return true;
+ }
}
- return false;
+ return false;
}
-bool GetOptString(int *argc, LPTSTR **argv, CLPTSTR flag, char *str)
+bool GetOptString(int *argc, LPTSTR ** argv, CLPTSTR flag, char *str)
{
- int i,j;
+ int i, j;
- if (flag == NULL)
- return false;
+ if (flag == NULL)
+ return false;
- for (i=0; i<*argc; i++)
- {
- if (_tcsicmp((*argv)[i], flag) == 0)
- {
- if (i+1 == *argc)
- return false;
- strcpy(str, (*argv)[i+1]);
- for (j=i; j<*argc-1; j++)
- {
- (*argv)[j] = (*argv)[j+2];
- }
- *argc -= 2;
- return true;
- }
+ for (i = 0; i < *argc; i++) {
+ if (_tcsicmp((*argv)[i], flag) == 0) {
+ if (i + 1 == *argc)
+ return false;
+ strcpy(str, (*argv)[i + 1]);
+ for (j = i; j < *argc - 1; j++) {
+ (*argv)[j] = (*argv)[j + 2];
+ }
+ *argc -= 2;
+ return true;
+ }
}
- return false;
+ return false;
}
diff --git a/test/mpi/basic/GetOpt.h b/test/mpi/basic/GetOpt.h
index 6fafb8e..5b55056 100644
--- a/test/mpi/basic/GetOpt.h
+++ b/test/mpi/basic/GetOpt.h
@@ -22,10 +22,10 @@
#define true 1
#define false 0
-bool GetOpt(int *argc, char ***argv, const char * flag);
-bool GetOptInt(int *argc, char ***argv, const char * flag, int *n);
-bool GetOptLong(int *argc, char ***argv, const char * flag, long *n);
-bool GetOptDouble(int *argc, char ***argv, const char * flag, double *d);
-bool GetOptString(int *argc, char ***argv, const char * flag, char *str);
+bool GetOpt(int *argc, char ***argv, const char *flag);
+bool GetOptInt(int *argc, char ***argv, const char *flag, int *n);
+bool GetOptLong(int *argc, char ***argv, const char *flag, long *n);
+bool GetOptDouble(int *argc, char ***argv, const char *flag, double *d);
+bool GetOptString(int *argc, char ***argv, const char *flag, char *str);
#endif
diff --git a/test/mpi/basic/adapt.c b/test/mpi/basic/adapt.c
index e0d8e12..4819a20 100644
--- a/test/mpi/basic/adapt.c
+++ b/test/mpi/basic/adapt.c
@@ -27,9 +27,9 @@ typedef int BOOL;
#define MAX(x, y) (((x) > (y))?(x):(y))
#ifdef HAVE_WINDOWS_H
-#define POINTER_TO_INT(a) ( ( int )( 0xffffffff & (__int64) ( a ) ) )
+#define POINTER_TO_INT(a) ((int)(0xffffffff & (__int64) (a)))
#else
-#define POINTER_TO_INT(a) ( ( MPI_Aint )( a ) )
+#define POINTER_TO_INT(a) ((MPI_Aint)(a))
#endif
#define CREATE_DIFFERENCE_CURVES
@@ -50,47 +50,45 @@ typedef int BOOL;
#define MSG_TAG_12 9912
#define MSG_TAG_012 9012
-int g_left_rank = -1;
-int g_middle_rank = -1;
-int g_right_rank = -1;
-int g_proc_loc = -1;
-int g_NSAMP = 250;
-double g_STOPTM = 0.1;
-int g_latency012_reps = 1000;
-int g_nIproc = 0;
-int g_nNproc = 0;
-
-typedef struct ArgStruct
-{
- char *sbuff; /* Send buffer */
- char *rbuff; /* Recv buffer */
- int bufflen; /* Length of buffer */
- int nbor, nbor2; /* neighbor */
- int iproc; /* rank */
- int tr; /* transmitter/receiver flag */
- int latency_reps; /* reps needed to time latency */
+int g_left_rank = -1;
+int g_middle_rank = -1;
+int g_right_rank = -1;
+int g_proc_loc = -1;
+int g_NSAMP = 250;
+double g_STOPTM = 0.1;
+int g_latency012_reps = 1000;
+int g_nIproc = 0;
+int g_nNproc = 0;
+
+typedef struct ArgStruct {
+ char *sbuff; /* Send buffer */
+ char *rbuff; /* Recv buffer */
+ int bufflen; /* Length of buffer */
+ int nbor, nbor2; /* neighbor */
+ int iproc; /* rank */
+ int tr; /* transmitter/receiver flag */
+ int latency_reps; /* reps needed to time latency */
} ArgStruct;
-typedef struct Data
-{
+typedef struct Data {
double t;
double bps;
- int bits;
- int repeat;
+ int bits;
+ int repeat;
} Data;
-int Setup(int middle_rank, ArgStruct *p01, ArgStruct *p12, ArgStruct *p012);
-void Sync(ArgStruct *p);
-void Sync012(ArgStruct *p);
-void SendTime(ArgStruct *p, double *t);
-void RecvTime(ArgStruct *p, double *t);
-void SendReps(ArgStruct *p, int *rpt);
-void RecvReps(ArgStruct *p, int *rpt);
-double TestLatency(ArgStruct *p);
-double TestLatency012(ArgStruct *p);
+int Setup(int middle_rank, ArgStruct * p01, ArgStruct * p12, ArgStruct * p012);
+void Sync(ArgStruct * p);
+void Sync012(ArgStruct * p);
+void SendTime(ArgStruct * p, double *t);
+void RecvTime(ArgStruct * p, double *t);
+void SendReps(ArgStruct * p, int *rpt);
+void RecvReps(ArgStruct * p, int *rpt);
+double TestLatency(ArgStruct * p);
+double TestLatency012(ArgStruct * p);
void PrintOptions(void);
-int DetermineLatencyReps(ArgStruct *p);
-int DetermineLatencyReps012(ArgStruct *p);
+int DetermineLatencyReps(ArgStruct * p);
+int DetermineLatencyReps012(ArgStruct * p);
void PrintOptions()
{
@@ -112,55 +110,53 @@ void PrintOptions()
int main(int argc, char *argv[])
{
- FILE *out=0; /* Output data file */
- char s[255]; /* Generic string */
+ FILE *out = 0; /* Output data file */
+ char s[255]; /* Generic string */
char *memtmp;
char *memtmp1;
MPI_Status status;
- int ii, i, j, k, n, nq, /* Loop indices */
- bufoffset = 0, /* Align buffer to this */
- bufalign = 16*1024, /* Boundary to align buffer to */
- nrepeat01, nrepeat12, /* Number of time to do the transmission*/
- nrepeat012,
- len, /* Number of bytes to be transmitted */
- inc = 1, /* Increment value */
- pert, /* Perturbation value */
- ipert, /* index of the perturbation loop */
- start = 0, /* Starting value for signature curve */
- end = MAXINT, /* Ending value for signature curve */
- printopt = 1, /* Debug print statements flag */
- middle_rank = 0, /* rank 0, 1 or 2 where 2-0-1 or 0-1-2 or 1-2-0 */
- tint;
-
- ArgStruct args01, args12, args012;/* Argumentsfor all the calls */
-
- double t, t0, t1, /* Time variables */
- tlast01, tlast12, tlast012,/* Time for the last transmission */
- latency01, latency12, /* Network message latency */
- latency012, tdouble; /* Network message latency to go from 0 -> 1 -> 2 */
+ int ii, i, j, k, n, nq, /* Loop indices */
+ bufoffset = 0, /* Align buffer to this */
+ bufalign = 16 * 1024, /* Boundary to align buffer to */
+ nrepeat01, nrepeat12, /* Number of time to do the transmission */
+ nrepeat012, len, /* Number of bytes to be transmitted */
+ inc = 1, /* Increment value */
+ pert, /* Perturbation value */
+ ipert, /* index of the perturbation loop */
+ start = 0, /* Starting value for signature curve */
+ end = MAXINT, /* Ending value for signature curve */
+ printopt = 1, /* Debug print statements flag */
+ middle_rank = 0, /* rank 0, 1 or 2 where 2-0-1 or 0-1-2 or 1-2-0 */
+ tint;
+
+ ArgStruct args01, args12, args012; /* Argumentsfor all the calls */
+
+ double t, t0, t1, /* Time variables */
+ tlast01, tlast12, tlast012, /* Time for the last transmission */
+ latency01, latency12, /* Network message latency */
+ latency012, tdouble; /* Network message latency to go from 0 -> 1 -> 2 */
#ifdef CREATE_DIFFERENCE_CURVES
int itrial, ntrials;
double *dtrials;
#endif
- Data *bwdata01, *bwdata12, *bwdata012;/* Bandwidth curve data */
-
+ Data *bwdata01, *bwdata12, *bwdata012; /* Bandwidth curve data */
+
BOOL bNoCache = FALSE;
BOOL bSavePert = FALSE;
BOOL bUseMegaBytes = FALSE;
MPI_Init(&argc, &argv);
-
+
MPI_Comm_size(MPI_COMM_WORLD, &g_nNproc);
MPI_Comm_rank(MPI_COMM_WORLD, &g_nIproc);
-
- if (g_nNproc != 3)
- {
- if (g_nIproc == 0)
- PrintOptions();
- MPI_Finalize();
- exit(0);
+
+ if (g_nNproc != 3) {
+ if (g_nIproc == 0)
+ PrintOptions();
+ MPI_Finalize();
+ exit(0);
}
GetOptDouble(&argc, &argv, "-time", &g_STOPTM);
@@ -170,1065 +166,996 @@ int main(int argc, char *argv[])
bNoCache = GetOpt(&argc, &argv, "-nocache");
bUseMegaBytes = GetOpt(&argc, &argv, "-mb");
if (GetOpt(&argc, &argv, "-noprint"))
- printopt = 0;
+ printopt = 0;
bSavePert = GetOpt(&argc, &argv, "-pert");
GetOptInt(&argc, &argv, "-middle", &middle_rank);
if (middle_rank < 0 || middle_rank > 2)
- middle_rank = 0;
+ middle_rank = 0;
- bwdata01 = malloc((g_NSAMP+1) * sizeof(Data));
- bwdata12 = malloc((g_NSAMP+1) * sizeof(Data));
- bwdata012 = malloc((g_NSAMP+1) * sizeof(Data));
+ bwdata01 = malloc((g_NSAMP + 1) * sizeof(Data));
+ bwdata12 = malloc((g_NSAMP + 1) * sizeof(Data));
+ bwdata012 = malloc((g_NSAMP + 1) * sizeof(Data));
if (g_nIproc == 0)
- strcpy(s, "adapt.out");
+ strcpy(s, "adapt.out");
GetOptString(&argc, &argv, "-out", s);
-
- if (start > end)
- {
- fprintf(stdout, "Start MUST be LESS than end\n");
- exit(420132);
+
+ if (start > end) {
+ fprintf(stdout, "Start MUST be LESS than end\n");
+ exit(420132);
}
Setup(middle_rank, &args01, &args12, &args012);
- if (g_nIproc == 0)
- {
- if ((out = fopen(s, "w")) == NULL)
- {
- fprintf(stdout,"Can't open %s for output\n", s);
- exit(1);
- }
+ if (g_nIproc == 0) {
+ if ((out = fopen(s, "w")) == NULL) {
+ fprintf(stdout, "Can't open %s for output\n", s);
+ exit(1);
+ }
}
/* Calculate latency */
- switch (g_proc_loc)
- {
+ switch (g_proc_loc) {
case LEFT_PROCESS:
- latency01 = TestLatency(&args01);
- /*printf("[0] latency01 = %0.9f\n", latency01);fflush(stdout);*/
- RecvTime(&args01, &latency12);
- /*printf("[0] latency12 = %0.9f\n", latency12);fflush(stdout);*/
- break;
+ latency01 = TestLatency(&args01);
+ /*printf("[0] latency01 = %0.9f\n", latency01);fflush(stdout); */
+ RecvTime(&args01, &latency12);
+ /*printf("[0] latency12 = %0.9f\n", latency12);fflush(stdout); */
+ break;
case MIDDLE_PROCESS:
- latency01 = TestLatency(&args01);
- /*printf("[1] latency01 = %0.9f\n", latency01);fflush(stdout);*/
- SendTime(&args12, &latency01);
- latency12 = TestLatency(&args12);
- /*printf("[1] latency12 = %0.9f\n", latency12);fflush(stdout);*/
- SendTime(&args01, &latency12);
- break;
+ latency01 = TestLatency(&args01);
+ /*printf("[1] latency01 = %0.9f\n", latency01);fflush(stdout); */
+ SendTime(&args12, &latency01);
+ latency12 = TestLatency(&args12);
+ /*printf("[1] latency12 = %0.9f\n", latency12);fflush(stdout); */
+ SendTime(&args01, &latency12);
+ break;
case RIGHT_PROCESS:
- RecvTime(&args12, &latency01);
- /*printf("[2] latency01 = %0.9f\n", latency01);fflush(stdout);*/
- latency12 = TestLatency(&args12);
- /*printf("[2] latency12 = %0.9f\n", latency12);fflush(stdout);*/
- break;
+ RecvTime(&args12, &latency01);
+ /*printf("[2] latency01 = %0.9f\n", latency01);fflush(stdout); */
+ latency12 = TestLatency(&args12);
+ /*printf("[2] latency12 = %0.9f\n", latency12);fflush(stdout); */
+ break;
}
latency012 = TestLatency012(&args012);
- if ((g_nIproc == 0) && printopt)
- {
- printf("Latency%d%d_ : %0.9f\n", g_left_rank, g_middle_rank, latency01);
- printf("Latency_%d%d : %0.9f\n", g_middle_rank, g_right_rank, latency12);
- printf("Latency%d%d%d : %0.9f\n", g_left_rank, g_middle_rank, g_right_rank, latency012);
- fflush(stdout);
- printf("Now starting main loop\n");
- fflush(stdout);
+ if ((g_nIproc == 0) && printopt) {
+ printf("Latency%d%d_ : %0.9f\n", g_left_rank, g_middle_rank, latency01);
+ printf("Latency_%d%d : %0.9f\n", g_middle_rank, g_right_rank, latency12);
+ printf("Latency%d%d%d : %0.9f\n", g_left_rank, g_middle_rank, g_right_rank, latency012);
+ fflush(stdout);
+ printf("Now starting main loop\n");
+ fflush(stdout);
}
tlast01 = latency01;
tlast12 = latency12;
tlast012 = latency012;
- inc = (start > 1) ? start/2: inc;
+ inc = (start > 1) ? start / 2 : inc;
args01.bufflen = start;
args12.bufflen = start;
args012.bufflen = start;
#ifdef CREATE_DIFFERENCE_CURVES
/* print the header line of the output file */
- if (g_nIproc == 0)
- {
- fprintf(out, "bytes\tMbits/s\ttime\tMbits/s\ttime");
- for (ii=1, itrial=0; itrial<MAX_NUM_O12_TRIALS; ii <<= 1, itrial++)
- fprintf(out, "\t%d", ii);
- fprintf(out, "\n");
- fflush(out);
+ if (g_nIproc == 0) {
+ fprintf(out, "bytes\tMbits/s\ttime\tMbits/s\ttime");
+ for (ii = 1, itrial = 0; itrial < MAX_NUM_O12_TRIALS; ii <<= 1, itrial++)
+ fprintf(out, "\t%d", ii);
+ fprintf(out, "\n");
+ fflush(out);
}
ntrials = MAX_NUM_O12_TRIALS;
- dtrials = malloc(sizeof(double)*ntrials);
+ dtrials = malloc(sizeof(double) * ntrials);
#endif
/* Main loop of benchmark */
- for (nq = n = 0, len = start;
- n < g_NSAMP && tlast012 < g_STOPTM && len <= end;
- len = len + inc, nq++)
- {
- if (nq > 2)
- inc = (nq % 2) ? inc + inc : inc;
-
- /* clear the old values */
- for (itrial = 0; itrial < ntrials; itrial++)
- {
- dtrials[itrial] = LONGTIME;
- }
-
- /* This is a perturbation loop to test nearby values */
- for (ipert = 0, pert = (inc > PERT + 1) ? -PERT : 0;
- pert <= PERT;
- ipert++, n++, pert += (inc > PERT + 1) ? PERT : PERT + 1)
- {
-
-
- /*****************************************************/
- /* Run a trial between rank 0 and 1 */
- /*****************************************************/
-
- MPI_Barrier(MPI_COMM_WORLD);
-
-
- if (g_proc_loc == RIGHT_PROCESS)
- goto skip_01_trial;
-
- /* Calculate howmany times to repeat the experiment. */
- if (args01.tr)
- {
- if (args01.bufflen == 0)
- nrepeat01 = args01.latency_reps;
- else
- nrepeat01 = (int)(MAX((RUNTM / ((double)args01.bufflen /
- (args01.bufflen - inc + 1.0) * tlast01)), TRIALS));
- SendReps(&args01, &nrepeat01);
- }
- else
- {
- RecvReps(&args01, &nrepeat01);
- }
-
- /* Allocate the buffer */
- args01.bufflen = len + pert;
- /* printf("allocating %d bytes\n", args01.bufflen * nrepeat01 + bufalign); */
- if (bNoCache)
- {
- if ((args01.sbuff = (char *)malloc(args01.bufflen * nrepeat01 + bufalign)) == (char *)NULL)
- {
- fprintf(stdout,"Couldn't allocate memory\n");
- fflush(stdout);
- break;
- }
- }
- else
- {
- if ((args01.sbuff = (char *)malloc(args01.bufflen + bufalign)) == (char *)NULL)
- {
- fprintf(stdout,"Couldn't allocate memory\n");
- fflush(stdout);
- break;
- }
- }
- /* if ((args01.rbuff = (char *)malloc(args01.bufflen * nrepeat01 + bufalign)) == (char *)NULL) */
- if ((args01.rbuff = (char *)malloc(args01.bufflen + bufalign)) == (char *)NULL)
- {
- fprintf(stdout,"Couldn't allocate memory\n");
- fflush(stdout);
- break;
- }
-
- /* save the original pointers in case alignment moves them */
- memtmp = args01.sbuff;
- memtmp1 = args01.rbuff;
-
- /* Possibly align the data buffer */
- if (!bNoCache)
- {
- if (bufalign != 0)
- {
- args01.sbuff += (bufalign - (POINTER_TO_INT(args01.sbuff) % bufalign) + bufoffset) % bufalign;
- /* args01.rbuff += (bufalign - ((MPI_Aint)args01.rbuff % bufalign) + bufoffset) % bufalign; */
- }
- }
- args01.rbuff += (bufalign - (POINTER_TO_INT(args01.rbuff) % bufalign) + bufoffset) % bufalign;
-
- if (args01.tr && printopt)
- {
- fprintf(stdout,"%3d: %9d bytes %4d times --> ",
- n, args01.bufflen, nrepeat01);
- fflush(stdout);
- }
-
- /* Finally, we get to transmit or receive and time */
- if (args01.tr)
- {
- bwdata01[n].t = LONGTIME;
- t1 = 0;
- for (i = 0; i < TRIALS; i++)
- {
- if (bNoCache)
- {
- if (bufalign != 0)
- {
- args01.sbuff = memtmp + ((bufalign - (POINTER_TO_INT(args01.sbuff) % bufalign) + bufoffset) % bufalign);
- /* args01.rbuff = memtmp1 + ((bufalign - ((MPI_Aint)args01.rbuff % bufalign) + bufoffset) % bufalign); */
- }
- else
- {
- args01.sbuff = memtmp;
- /* args01.rbuff = memtmp1; */
- }
- }
-
- Sync(&args01);
- t0 = MPI_Wtime();
- for (j = 0; j < nrepeat01; j++)
- {
- MPI_Send(args01.sbuff, args01.bufflen, MPI_BYTE, args01.nbor, MSG_TAG_01, MPI_COMM_WORLD);
- MPI_Recv(args01.rbuff, args01.bufflen, MPI_BYTE, args01.nbor, MSG_TAG_01, MPI_COMM_WORLD, &status);
- if (bNoCache)
- {
- args01.sbuff += args01.bufflen;
- /* args01.rbuff += args01.bufflen; */
- }
- }
- t = (MPI_Wtime() - t0)/(2 * nrepeat01);
-
- t1 += t;
- bwdata01[n].t = MIN(bwdata01[n].t, t);
- }
- SendTime(&args01, &bwdata01[n].t);
- }
- else
- {
- bwdata01[n].t = LONGTIME;
- t1 = 0;
- for (i = 0; i < TRIALS; i++)
- {
- if (bNoCache)
- {
- if (bufalign != 0)
- {
- args01.sbuff = memtmp + ((bufalign - (POINTER_TO_INT(args01.sbuff) % bufalign) + bufoffset) % bufalign);
- /* args01.rbuff = memtmp1 + ((bufalign - ((MPI_Aint)args01.rbuff % bufalign) + bufoffset) % bufalign); */
- }
- else
- {
- args01.sbuff = memtmp;
- /* args01.rbuff = memtmp1; */
- }
- }
-
- Sync(&args01);
- t0 = MPI_Wtime();
- for (j = 0; j < nrepeat01; j++)
- {
- MPI_Recv(args01.rbuff, args01.bufflen, MPI_BYTE, args01.nbor, MSG_TAG_01, MPI_COMM_WORLD, &status);
- MPI_Send(args01.sbuff, args01.bufflen, MPI_BYTE, args01.nbor, MSG_TAG_01, MPI_COMM_WORLD);
- if (bNoCache)
- {
- args01.sbuff += args01.bufflen;
- /* args01.rbuff += args01.bufflen; */
- }
- }
- t = (MPI_Wtime() - t0)/(2 * nrepeat01);
- }
- RecvTime(&args01, &bwdata01[n].t);
- }
- tlast01 = bwdata01[n].t;
- bwdata01[n].bits = args01.bufflen * CHARSIZE;
- bwdata01[n].bps = bwdata01[n].bits / (bwdata01[n].t * 1024 * 1024);
- bwdata01[n].repeat = nrepeat01;
-
- if (args01.tr)
- {
- if (bSavePert)
- {
- if (args01.iproc == 0)
- {
- if (bUseMegaBytes)
- fprintf(out, "%d\t%f\t%0.9f\t", bwdata01[n].bits / 8, bwdata01[n].bps / 8, bwdata01[n].t);
- else
- fprintf(out, "%d\t%f\t%0.9f\t", bwdata01[n].bits / 8, bwdata01[n].bps, bwdata01[n].t);
- fflush(out);
- }
- else
- {
- MPI_Send(&bwdata01[n].bits, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
- MPI_Send(&bwdata01[n].bps, 1, MPI_DOUBLE, 0, 1, MPI_COMM_WORLD);
- MPI_Send(&bwdata01[n].t, 1, MPI_DOUBLE, 0, 1, MPI_COMM_WORLD);
- }
- }
- }
-
- free(memtmp);
- free(memtmp1);
-
- if (args01.tr && printopt)
- {
- if (bUseMegaBytes)
- printf(" %6.2f MBps in %0.9f sec\n", bwdata01[n].bps / 8, tlast01);
- else
- printf(" %6.2f Mbps in %0.9f sec\n", bwdata01[n].bps, tlast01);
- fflush(stdout);
- }
-
-skip_01_trial:
- if (g_proc_loc == RIGHT_PROCESS && g_nIproc == 0 && bSavePert)
- {
- MPI_Recv(&tint, 1, MPI_INT, g_left_rank, 1, MPI_COMM_WORLD, &status);
- fprintf(out, "%d\t", tint/8);
- MPI_Recv(&tdouble, 1, MPI_DOUBLE, g_left_rank, 1, MPI_COMM_WORLD, &status);
- if (bUseMegaBytes)
- tdouble = tdouble / 8.0;
- fprintf(out, "%f\t", tdouble);
- MPI_Recv(&tdouble, 1, MPI_DOUBLE, g_left_rank, 1, MPI_COMM_WORLD, &status);
- fprintf(out, "%0.9f\t", tdouble);
- fflush(out);
- }
-
-
- /*****************************************************/
- /* Run a trial between rank 1 and 2 */
- /*****************************************************/
-
- MPI_Barrier(MPI_COMM_WORLD);
-
-
- if (g_proc_loc == LEFT_PROCESS)
- goto skip_12_trial;
-
- /* Calculate howmany times to repeat the experiment. */
- if (args12.tr)
- {
- if (args12.bufflen == 0)
- nrepeat12 = args12.latency_reps;
- else
- nrepeat12 = (int)(MAX((RUNTM / ((double)args12.bufflen /
- (args12.bufflen - inc + 1.0) * tlast12)), TRIALS));
- SendReps(&args12, &nrepeat12);
- }
- else
- {
- RecvReps(&args12, &nrepeat12);
- }
-
- /* Allocate the buffer */
- args12.bufflen = len + pert;
- /* printf("allocating %d bytes\n", args12.bufflen * nrepeat12 + bufalign); */
- if (bNoCache)
- {
- if ((args12.sbuff = (char *)malloc(args12.bufflen * nrepeat12 + bufalign)) == (char *)NULL)
- {
- fprintf(stdout,"Couldn't allocate memory\n");
- fflush(stdout);
- break;
- }
- }
- else
- {
- if ((args12.sbuff = (char *)malloc(args12.bufflen + bufalign)) == (char *)NULL)
- {
- fprintf(stdout,"Couldn't allocate memory\n");
- fflush(stdout);
- break;
- }
- }
- /* if ((args12.rbuff = (char *)malloc(args12.bufflen * nrepeat12 + bufalign)) == (char *)NULL) */
- if ((args12.rbuff = (char *)malloc(args12.bufflen + bufalign)) == (char *)NULL)
- {
- fprintf(stdout,"Couldn't allocate memory\n");
- fflush(stdout);
- break;
- }
-
- /* save the original pointers in case alignment moves them */
- memtmp = args12.sbuff;
- memtmp1 = args12.rbuff;
-
- /* Possibly align the data buffer */
- if (!bNoCache)
- {
- if (bufalign != 0)
- {
- args12.sbuff += (bufalign - (POINTER_TO_INT(args12.sbuff) % bufalign) + bufoffset) % bufalign;
- /* args12.rbuff += (bufalign - ((MPI_Aint)args12.rbuff % bufalign) + bufoffset) % bufalign; */
- }
- }
- args12.rbuff += (bufalign - (POINTER_TO_INT(args12.rbuff) % bufalign) + bufoffset) % bufalign;
-
- if (args12.tr && printopt)
- {
- printf("%3d: %9d bytes %4d times --> ", n, args12.bufflen, nrepeat12);
- fflush(stdout);
- }
-
- /* Finally, we get to transmit or receive and time */
- if (args12.tr)
- {
- bwdata12[n].t = LONGTIME;
- t1 = 0;
- for (i = 0; i < TRIALS; i++)
- {
- if (bNoCache)
- {
- if (bufalign != 0)
- {
- args12.sbuff = memtmp + ((bufalign - (POINTER_TO_INT(args12.sbuff) % bufalign) + bufoffset) % bufalign);
- /* args12.rbuff = memtmp1 + ((bufalign - ((MPI_Aint)args12.rbuff % bufalign) + bufoffset) % bufalign); */
- }
- else
- {
- args12.sbuff = memtmp;
- /* args12.rbuff = memtmp1; */
- }
- }
-
- Sync(&args12);
- t0 = MPI_Wtime();
- for (j = 0; j < nrepeat12; j++)
- {
- MPI_Send(args12.sbuff, args12.bufflen, MPI_BYTE, args12.nbor, MSG_TAG_12, MPI_COMM_WORLD);
- MPI_Recv(args12.rbuff, args12.bufflen, MPI_BYTE, args12.nbor, MSG_TAG_12, MPI_COMM_WORLD, &status);
- if (bNoCache)
- {
- args12.sbuff += args12.bufflen;
- /* args12.rbuff += args12.bufflen; */
- }
- }
- t = (MPI_Wtime() - t0)/(2 * nrepeat12);
-
- t1 += t;
- bwdata12[n].t = MIN(bwdata12[n].t, t);
- }
- SendTime(&args12, &bwdata12[n].t);
- }
- else
- {
- bwdata12[n].t = LONGTIME;
- t1 = 0;
- for (i = 0; i < TRIALS; i++)
- {
- if (bNoCache)
- {
- if (bufalign != 0)
- {
- args12.sbuff = memtmp + ((bufalign - (POINTER_TO_INT(args12.sbuff) % bufalign) + bufoffset) % bufalign);
- /* args12.rbuff = memtmp1 + ((bufalign - ((MPI_Aint)args12.rbuff % bufalign) + bufoffset) % bufalign); */
- }
- else
- {
- args12.sbuff = memtmp;
- /* args12.rbuff = memtmp1; */
- }
- }
-
- Sync(&args12);
- t0 = MPI_Wtime();
- for (j = 0; j < nrepeat12; j++)
- {
- MPI_Recv(args12.rbuff, args12.bufflen, MPI_BYTE, args12.nbor, MSG_TAG_12, MPI_COMM_WORLD, &status);
- MPI_Send(args12.sbuff, args12.bufflen, MPI_BYTE, args12.nbor, MSG_TAG_12, MPI_COMM_WORLD);
- if (bNoCache)
- {
- args12.sbuff += args12.bufflen;
- /* args12.rbuff += args12.bufflen; */
- }
- }
- t = (MPI_Wtime() - t0)/(2 * nrepeat12);
- }
- RecvTime(&args12, &bwdata12[n].t);
- }
- tlast12 = bwdata12[n].t;
- bwdata12[n].bits = args12.bufflen * CHARSIZE;
- bwdata12[n].bps = bwdata12[n].bits / (bwdata12[n].t * 1024 * 1024);
- bwdata12[n].repeat = nrepeat12;
-
- if (args12.tr)
- {
- if (bSavePert)
- {
- if (g_nIproc == 0)
- {
- if (bUseMegaBytes)
- fprintf(out,"%f\t%0.9f\t", bwdata12[n].bps / 8, bwdata12[n].t);
- else
- fprintf(out,"%f\t%0.9f\t", bwdata12[n].bps, bwdata12[n].t);
- fflush(out);
- }
- else
- {
- MPI_Send(&bwdata12[n].bps, 1, MPI_DOUBLE, 0, 1, MPI_COMM_WORLD);
- MPI_Send(&bwdata12[n].t, 1, MPI_DOUBLE, 0, 1, MPI_COMM_WORLD);
- }
- }
- }
-
- free(memtmp);
- free(memtmp1);
-
- if (args12.tr && printopt)
- {
- if (bUseMegaBytes)
- printf(" %6.2f MBps in %0.9f sec\n", bwdata12[n].bps / 8, tlast12);
- else
- printf(" %6.2f Mbps in %0.9f sec\n", bwdata12[n].bps, tlast12);
- fflush(stdout);
- }
-
-skip_12_trial:
- if (g_proc_loc == LEFT_PROCESS && g_nIproc == 0 && bSavePert)
- {
- MPI_Recv(&tdouble, 1, MPI_DOUBLE, g_middle_rank, 1, MPI_COMM_WORLD, &status);
- if (bUseMegaBytes)
- tdouble = tdouble / 8.0;
- fprintf(out, "%f\t", tdouble);
- MPI_Recv(&tdouble, 1, MPI_DOUBLE, g_middle_rank, 1, MPI_COMM_WORLD, &status);
- fprintf(out, "%0.9f\t", tdouble);
- fflush(out);
- }
+ for (nq = n = 0, len = start;
+ n < g_NSAMP && tlast012 < g_STOPTM && len <= end; len = len + inc, nq++) {
+ if (nq > 2)
+ inc = (nq % 2) ? inc + inc : inc;
+
+ /* clear the old values */
+ for (itrial = 0; itrial < ntrials; itrial++) {
+ dtrials[itrial] = LONGTIME;
+ }
+
+ /* This is a perturbation loop to test nearby values */
+ for (ipert = 0, pert = (inc > PERT + 1) ? -PERT : 0;
+ pert <= PERT; ipert++, n++, pert += (inc > PERT + 1) ? PERT : PERT + 1) {
+
+
+ /*****************************************************/
+ /* Run a trial between rank 0 and 1 */
+ /*****************************************************/
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+
+ if (g_proc_loc == RIGHT_PROCESS)
+ goto skip_01_trial;
+
+ /* Calculate howmany times to repeat the experiment. */
+ if (args01.tr) {
+ if (args01.bufflen == 0)
+ nrepeat01 = args01.latency_reps;
+ else
+ nrepeat01 = (int) (MAX((RUNTM / ((double) args01.bufflen /
+ (args01.bufflen - inc + 1.0) * tlast01)),
+ TRIALS));
+ SendReps(&args01, &nrepeat01);
+ }
+ else {
+ RecvReps(&args01, &nrepeat01);
+ }
+
+ /* Allocate the buffer */
+ args01.bufflen = len + pert;
+ /* printf("allocating %d bytes\n", args01.bufflen * nrepeat01 + bufalign); */
+ if (bNoCache) {
+ if ((args01.sbuff =
+ (char *) malloc(args01.bufflen * nrepeat01 + bufalign)) == (char *) NULL) {
+ fprintf(stdout, "Couldn't allocate memory\n");
+ fflush(stdout);
+ break;
+ }
+ }
+ else {
+ if ((args01.sbuff = (char *) malloc(args01.bufflen + bufalign)) == (char *) NULL) {
+ fprintf(stdout, "Couldn't allocate memory\n");
+ fflush(stdout);
+ break;
+ }
+ }
+ /* if ((args01.rbuff = (char *)malloc(args01.bufflen * nrepeat01 + bufalign)) == (char *)NULL) */
+ if ((args01.rbuff = (char *) malloc(args01.bufflen + bufalign)) == (char *) NULL) {
+ fprintf(stdout, "Couldn't allocate memory\n");
+ fflush(stdout);
+ break;
+ }
+
+ /* save the original pointers in case alignment moves them */
+ memtmp = args01.sbuff;
+ memtmp1 = args01.rbuff;
+
+ /* Possibly align the data buffer */
+ if (!bNoCache) {
+ if (bufalign != 0) {
+ args01.sbuff +=
+ (bufalign - (POINTER_TO_INT(args01.sbuff) % bufalign) +
+ bufoffset) % bufalign;
+ /* args01.rbuff += (bufalign - ((MPI_Aint)args01.rbuff % bufalign) + bufoffset) % bufalign; */
+ }
+ }
+ args01.rbuff +=
+ (bufalign - (POINTER_TO_INT(args01.rbuff) % bufalign) + bufoffset) % bufalign;
+
+ if (args01.tr && printopt) {
+ fprintf(stdout, "%3d: %9d bytes %4d times --> ", n, args01.bufflen, nrepeat01);
+ fflush(stdout);
+ }
+
+ /* Finally, we get to transmit or receive and time */
+ if (args01.tr) {
+ bwdata01[n].t = LONGTIME;
+ t1 = 0;
+ for (i = 0; i < TRIALS; i++) {
+ if (bNoCache) {
+ if (bufalign != 0) {
+ args01.sbuff =
+ memtmp +
+ ((bufalign - (POINTER_TO_INT(args01.sbuff) % bufalign) +
+ bufoffset) % bufalign);
+ /* args01.rbuff = memtmp1 + ((bufalign - ((MPI_Aint)args01.rbuff % bufalign) + bufoffset) % bufalign); */
+ }
+ else {
+ args01.sbuff = memtmp;
+ /* args01.rbuff = memtmp1; */
+ }
+ }
+
+ Sync(&args01);
+ t0 = MPI_Wtime();
+ for (j = 0; j < nrepeat01; j++) {
+ MPI_Send(args01.sbuff, args01.bufflen, MPI_BYTE, args01.nbor, MSG_TAG_01,
+ MPI_COMM_WORLD);
+ MPI_Recv(args01.rbuff, args01.bufflen, MPI_BYTE, args01.nbor, MSG_TAG_01,
+ MPI_COMM_WORLD, &status);
+ if (bNoCache) {
+ args01.sbuff += args01.bufflen;
+ /* args01.rbuff += args01.bufflen; */
+ }
+ }
+ t = (MPI_Wtime() - t0) / (2 * nrepeat01);
+
+ t1 += t;
+ bwdata01[n].t = MIN(bwdata01[n].t, t);
+ }
+ SendTime(&args01, &bwdata01[n].t);
+ }
+ else {
+ bwdata01[n].t = LONGTIME;
+ t1 = 0;
+ for (i = 0; i < TRIALS; i++) {
+ if (bNoCache) {
+ if (bufalign != 0) {
+ args01.sbuff =
+ memtmp +
+ ((bufalign - (POINTER_TO_INT(args01.sbuff) % bufalign) +
+ bufoffset) % bufalign);
+ /* args01.rbuff = memtmp1 + ((bufalign - ((MPI_Aint)args01.rbuff % bufalign) + bufoffset) % bufalign); */
+ }
+ else {
+ args01.sbuff = memtmp;
+ /* args01.rbuff = memtmp1; */
+ }
+ }
+
+ Sync(&args01);
+ t0 = MPI_Wtime();
+ for (j = 0; j < nrepeat01; j++) {
+ MPI_Recv(args01.rbuff, args01.bufflen, MPI_BYTE, args01.nbor, MSG_TAG_01,
+ MPI_COMM_WORLD, &status);
+ MPI_Send(args01.sbuff, args01.bufflen, MPI_BYTE, args01.nbor, MSG_TAG_01,
+ MPI_COMM_WORLD);
+ if (bNoCache) {
+ args01.sbuff += args01.bufflen;
+ /* args01.rbuff += args01.bufflen; */
+ }
+ }
+ t = (MPI_Wtime() - t0) / (2 * nrepeat01);
+ }
+ RecvTime(&args01, &bwdata01[n].t);
+ }
+ tlast01 = bwdata01[n].t;
+ bwdata01[n].bits = args01.bufflen * CHARSIZE;
+ bwdata01[n].bps = bwdata01[n].bits / (bwdata01[n].t * 1024 * 1024);
+ bwdata01[n].repeat = nrepeat01;
+
+ if (args01.tr) {
+ if (bSavePert) {
+ if (args01.iproc == 0) {
+ if (bUseMegaBytes)
+ fprintf(out, "%d\t%f\t%0.9f\t", bwdata01[n].bits / 8,
+ bwdata01[n].bps / 8, bwdata01[n].t);
+ else
+ fprintf(out, "%d\t%f\t%0.9f\t", bwdata01[n].bits / 8, bwdata01[n].bps,
+ bwdata01[n].t);
+ fflush(out);
+ }
+ else {
+ MPI_Send(&bwdata01[n].bits, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
+ MPI_Send(&bwdata01[n].bps, 1, MPI_DOUBLE, 0, 1, MPI_COMM_WORLD);
+ MPI_Send(&bwdata01[n].t, 1, MPI_DOUBLE, 0, 1, MPI_COMM_WORLD);
+ }
+ }
+ }
+
+ free(memtmp);
+ free(memtmp1);
+
+ if (args01.tr && printopt) {
+ if (bUseMegaBytes)
+ printf(" %6.2f MBps in %0.9f sec\n", bwdata01[n].bps / 8, tlast01);
+ else
+ printf(" %6.2f Mbps in %0.9f sec\n", bwdata01[n].bps, tlast01);
+ fflush(stdout);
+ }
+
+ skip_01_trial:
+ if (g_proc_loc == RIGHT_PROCESS && g_nIproc == 0 && bSavePert) {
+ MPI_Recv(&tint, 1, MPI_INT, g_left_rank, 1, MPI_COMM_WORLD, &status);
+ fprintf(out, "%d\t", tint / 8);
+ MPI_Recv(&tdouble, 1, MPI_DOUBLE, g_left_rank, 1, MPI_COMM_WORLD, &status);
+ if (bUseMegaBytes)
+ tdouble = tdouble / 8.0;
+ fprintf(out, "%f\t", tdouble);
+ MPI_Recv(&tdouble, 1, MPI_DOUBLE, g_left_rank, 1, MPI_COMM_WORLD, &status);
+ fprintf(out, "%0.9f\t", tdouble);
+ fflush(out);
+ }
+
+
+ /*****************************************************/
+ /* Run a trial between rank 1 and 2 */
+ /*****************************************************/
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+
+ if (g_proc_loc == LEFT_PROCESS)
+ goto skip_12_trial;
+
+ /* Calculate howmany times to repeat the experiment. */
+ if (args12.tr) {
+ if (args12.bufflen == 0)
+ nrepeat12 = args12.latency_reps;
+ else
+ nrepeat12 = (int) (MAX((RUNTM / ((double) args12.bufflen /
+ (args12.bufflen - inc + 1.0) * tlast12)),
+ TRIALS));
+ SendReps(&args12, &nrepeat12);
+ }
+ else {
+ RecvReps(&args12, &nrepeat12);
+ }
+
+ /* Allocate the buffer */
+ args12.bufflen = len + pert;
+ /* printf("allocating %d bytes\n", args12.bufflen * nrepeat12 + bufalign); */
+ if (bNoCache) {
+ if ((args12.sbuff =
+ (char *) malloc(args12.bufflen * nrepeat12 + bufalign)) == (char *) NULL) {
+ fprintf(stdout, "Couldn't allocate memory\n");
+ fflush(stdout);
+ break;
+ }
+ }
+ else {
+ if ((args12.sbuff = (char *) malloc(args12.bufflen + bufalign)) == (char *) NULL) {
+ fprintf(stdout, "Couldn't allocate memory\n");
+ fflush(stdout);
+ break;
+ }
+ }
+ /* if ((args12.rbuff = (char *)malloc(args12.bufflen * nrepeat12 + bufalign)) == (char *)NULL) */
+ if ((args12.rbuff = (char *) malloc(args12.bufflen + bufalign)) == (char *) NULL) {
+ fprintf(stdout, "Couldn't allocate memory\n");
+ fflush(stdout);
+ break;
+ }
+
+ /* save the original pointers in case alignment moves them */
+ memtmp = args12.sbuff;
+ memtmp1 = args12.rbuff;
+
+ /* Possibly align the data buffer */
+ if (!bNoCache) {
+ if (bufalign != 0) {
+ args12.sbuff +=
+ (bufalign - (POINTER_TO_INT(args12.sbuff) % bufalign) +
+ bufoffset) % bufalign;
+ /* args12.rbuff += (bufalign - ((MPI_Aint)args12.rbuff % bufalign) + bufoffset) % bufalign; */
+ }
+ }
+ args12.rbuff +=
+ (bufalign - (POINTER_TO_INT(args12.rbuff) % bufalign) + bufoffset) % bufalign;
+
+ if (args12.tr && printopt) {
+ printf("%3d: %9d bytes %4d times --> ", n, args12.bufflen, nrepeat12);
+ fflush(stdout);
+ }
+
+ /* Finally, we get to transmit or receive and time */
+ if (args12.tr) {
+ bwdata12[n].t = LONGTIME;
+ t1 = 0;
+ for (i = 0; i < TRIALS; i++) {
+ if (bNoCache) {
+ if (bufalign != 0) {
+ args12.sbuff =
+ memtmp +
+ ((bufalign - (POINTER_TO_INT(args12.sbuff) % bufalign) +
+ bufoffset) % bufalign);
+ /* args12.rbuff = memtmp1 + ((bufalign - ((MPI_Aint)args12.rbuff % bufalign) + bufoffset) % bufalign); */
+ }
+ else {
+ args12.sbuff = memtmp;
+ /* args12.rbuff = memtmp1; */
+ }
+ }
+
+ Sync(&args12);
+ t0 = MPI_Wtime();
+ for (j = 0; j < nrepeat12; j++) {
+ MPI_Send(args12.sbuff, args12.bufflen, MPI_BYTE, args12.nbor, MSG_TAG_12,
+ MPI_COMM_WORLD);
+ MPI_Recv(args12.rbuff, args12.bufflen, MPI_BYTE, args12.nbor, MSG_TAG_12,
+ MPI_COMM_WORLD, &status);
+ if (bNoCache) {
+ args12.sbuff += args12.bufflen;
+ /* args12.rbuff += args12.bufflen; */
+ }
+ }
+ t = (MPI_Wtime() - t0) / (2 * nrepeat12);
+
+ t1 += t;
+ bwdata12[n].t = MIN(bwdata12[n].t, t);
+ }
+ SendTime(&args12, &bwdata12[n].t);
+ }
+ else {
+ bwdata12[n].t = LONGTIME;
+ t1 = 0;
+ for (i = 0; i < TRIALS; i++) {
+ if (bNoCache) {
+ if (bufalign != 0) {
+ args12.sbuff =
+ memtmp +
+ ((bufalign - (POINTER_TO_INT(args12.sbuff) % bufalign) +
+ bufoffset) % bufalign);
+ /* args12.rbuff = memtmp1 + ((bufalign - ((MPI_Aint)args12.rbuff % bufalign) + bufoffset) % bufalign); */
+ }
+ else {
+ args12.sbuff = memtmp;
+ /* args12.rbuff = memtmp1; */
+ }
+ }
+
+ Sync(&args12);
+ t0 = MPI_Wtime();
+ for (j = 0; j < nrepeat12; j++) {
+ MPI_Recv(args12.rbuff, args12.bufflen, MPI_BYTE, args12.nbor, MSG_TAG_12,
+ MPI_COMM_WORLD, &status);
+ MPI_Send(args12.sbuff, args12.bufflen, MPI_BYTE, args12.nbor, MSG_TAG_12,
+ MPI_COMM_WORLD);
+ if (bNoCache) {
+ args12.sbuff += args12.bufflen;
+ /* args12.rbuff += args12.bufflen; */
+ }
+ }
+ t = (MPI_Wtime() - t0) / (2 * nrepeat12);
+ }
+ RecvTime(&args12, &bwdata12[n].t);
+ }
+ tlast12 = bwdata12[n].t;
+ bwdata12[n].bits = args12.bufflen * CHARSIZE;
+ bwdata12[n].bps = bwdata12[n].bits / (bwdata12[n].t * 1024 * 1024);
+ bwdata12[n].repeat = nrepeat12;
+
+ if (args12.tr) {
+ if (bSavePert) {
+ if (g_nIproc == 0) {
+ if (bUseMegaBytes)
+ fprintf(out, "%f\t%0.9f\t", bwdata12[n].bps / 8, bwdata12[n].t);
+ else
+ fprintf(out, "%f\t%0.9f\t", bwdata12[n].bps, bwdata12[n].t);
+ fflush(out);
+ }
+ else {
+ MPI_Send(&bwdata12[n].bps, 1, MPI_DOUBLE, 0, 1, MPI_COMM_WORLD);
+ MPI_Send(&bwdata12[n].t, 1, MPI_DOUBLE, 0, 1, MPI_COMM_WORLD);
+ }
+ }
+ }
+
+ free(memtmp);
+ free(memtmp1);
+
+ if (args12.tr && printopt) {
+ if (bUseMegaBytes)
+ printf(" %6.2f MBps in %0.9f sec\n", bwdata12[n].bps / 8, tlast12);
+ else
+ printf(" %6.2f Mbps in %0.9f sec\n", bwdata12[n].bps, tlast12);
+ fflush(stdout);
+ }
+
+ skip_12_trial:
+ if (g_proc_loc == LEFT_PROCESS && g_nIproc == 0 && bSavePert) {
+ MPI_Recv(&tdouble, 1, MPI_DOUBLE, g_middle_rank, 1, MPI_COMM_WORLD, &status);
+ if (bUseMegaBytes)
+ tdouble = tdouble / 8.0;
+ fprintf(out, "%f\t", tdouble);
+ MPI_Recv(&tdouble, 1, MPI_DOUBLE, g_middle_rank, 1, MPI_COMM_WORLD, &status);
+ fprintf(out, "%0.9f\t", tdouble);
+ fflush(out);
+ }
#ifdef CREATE_DIFFERENCE_CURVES
- /*****************************************************/
- /* Run a trial between rank 0, 1 and 2 */
- /*****************************************************/
-
- MPI_Barrier(MPI_COMM_WORLD);
-
-
- /* Calculate howmany times to repeat the experiment. */
- if (g_nIproc == 0)
- {
- if (args012.bufflen == 0)
- nrepeat012 = g_latency012_reps;
- else
- nrepeat012 = (int)(MAX((RUNTM / ((double)args012.bufflen /
- (args012.bufflen - inc + 1.0) * tlast012)), TRIALS));
- MPI_Bcast(&nrepeat012, 1, MPI_INT, 0, MPI_COMM_WORLD);
- }
- else
- {
- MPI_Bcast(&nrepeat012, 1, MPI_INT, 0, MPI_COMM_WORLD);
- }
-
- /* Allocate the buffer */
- args012.bufflen = len + pert;
- /* printf("allocating %d bytes\n", args12.bufflen * nrepeat012 + bufalign); */
- if (bNoCache)
- {
- if ((args012.sbuff = (char *)malloc(args012.bufflen * nrepeat012 + bufalign)) == (char *)NULL)
- {
- fprintf(stdout,"Couldn't allocate memory\n");
- fflush(stdout);
- break;
- }
- }
- else
- {
- if ((args012.sbuff = (char *)malloc(args012.bufflen + bufalign)) == (char *)NULL)
- {
- fprintf(stdout,"Couldn't allocate memory\n");
- fflush(stdout);
- break;
- }
- }
- /* if ((args012.rbuff = (char *)malloc(args012.bufflen * nrepeat012 + bufalign)) == (char *)NULL) */
- if ((args012.rbuff = (char *)malloc(args012.bufflen + bufalign)) == (char *)NULL)
- {
- fprintf(stdout,"Couldn't allocate memory\n");
- fflush(stdout);
- break;
- }
-
- /* save the original pointers in case alignment moves them */
- memtmp = args012.sbuff;
- memtmp1 = args012.rbuff;
-
- /* Possibly align the data buffer */
- if (!bNoCache)
- {
- if (bufalign != 0)
- {
- args012.sbuff += (bufalign - (POINTER_TO_INT(args012.sbuff) % bufalign) + bufoffset) % bufalign;
- /* args12.rbuff += (bufalign - ((MPI_Aint)args12.rbuff % bufalign) + bufoffset) % bufalign; */
- }
- }
- args012.rbuff += (bufalign - (POINTER_TO_INT(args012.rbuff) % bufalign) + bufoffset) % bufalign;
-
- if (g_nIproc == 0 && printopt)
- {
- printf("%3d: %9d bytes %4d times --> ", n, args012.bufflen, nrepeat012);
- fflush(stdout);
- }
-
- for (itrial=0, ii=1; ii <= nrepeat012 && itrial < ntrials; ii <<= 1, itrial++)
- {
- /* Finally, we get to transmit or receive and time */
- switch (g_proc_loc)
- {
- case LEFT_PROCESS:
- bwdata012[n].t = LONGTIME;
- t1 = 0;
- for (i = 0; i < TRIALS; i++)
- {
- if (bNoCache)
- {
- if (bufalign != 0)
- {
- args012.sbuff = memtmp + ((bufalign - (POINTER_TO_INT(args012.sbuff) % bufalign) + bufoffset) % bufalign);
- /* args012.rbuff = memtmp1 + ((bufalign - ((MPI_Aint)args012.rbuff % bufalign) + bufoffset) % bufalign); */
- }
- else
- {
- args012.sbuff = memtmp;
- /* args012.rbuff = memtmp1; */
- }
- }
-
- Sync012(&args012);
- t0 = MPI_Wtime();
- for (j = 0; j < nrepeat012; j++)
- {
- MPI_Send(args012.sbuff, args012.bufflen, MPI_BYTE, args012.nbor, MSG_TAG_012, MPI_COMM_WORLD);
- MPI_Recv(args012.rbuff, args012.bufflen, MPI_BYTE, args012.nbor, MSG_TAG_012, MPI_COMM_WORLD, &status);
- if (bNoCache)
- {
- args012.sbuff += args012.bufflen;
- /* args012.rbuff += args012.bufflen; */
- }
- }
- t = (MPI_Wtime() - t0)/(2 * nrepeat012);
-
- t1 += t;
- bwdata012[n].t = MIN(bwdata012[n].t, t);
- }
- MPI_Bcast(&bwdata012[n].t, 1, MPI_DOUBLE, g_left_rank, MPI_COMM_WORLD);
- break;
- case MIDDLE_PROCESS:
- bwdata012[n].t = LONGTIME;
- t1 = 0;
- for (i = 0; i < TRIALS; i++)
- {
- if (bNoCache)
- {
- if (bufalign != 0)
- {
- args012.sbuff = memtmp + ((bufalign - (POINTER_TO_INT(args012.sbuff) % bufalign) + bufoffset) % bufalign);
- /* args012.rbuff = memtmp1 + ((bufalign - ((MPI_Aint)args012.rbuff % bufalign) + bufoffset) % bufalign); */
- }
- else
- {
- args012.sbuff = memtmp;
- /* args012.rbuff = memtmp1; */
- }
- }
-
- Sync012(&args012);
- t0 = MPI_Wtime();
-
- /******* use the ii variable here !!! ******/
-
- for (j = 0; j <= nrepeat012-ii; j+=ii)
- {
- for (k=0; k<ii; k++)
- {
- MPI_Send(args012.sbuff, args012.bufflen, MPI_BYTE, args012.nbor2, MSG_TAG_012, MPI_COMM_WORLD);
- MPI_Recv(args012.rbuff, args012.bufflen, MPI_BYTE, args012.nbor2, MSG_TAG_012, MPI_COMM_WORLD, &status);
- }
- /* do the left process second because it does the timing and needs to include time to send to the right process. */
- for (k=0; k<ii; k++)
- {
- MPI_Recv(args012.rbuff, args012.bufflen, MPI_BYTE, args012.nbor, MSG_TAG_012, MPI_COMM_WORLD, &status);
- MPI_Send(args012.sbuff, args012.bufflen, MPI_BYTE, args012.nbor, MSG_TAG_012, MPI_COMM_WORLD);
- }
- if (bNoCache)
- {
- args012.sbuff += args012.bufflen;
- /* args012.rbuff += args012.bufflen; */
- }
- }
- j = nrepeat012 % ii;
- for (k=0; k < j; k++)
- {
- MPI_Send(args012.sbuff, args012.bufflen, MPI_BYTE, args012.nbor2, MSG_TAG_012, MPI_COMM_WORLD);
- MPI_Recv(args012.rbuff, args012.bufflen, MPI_BYTE, args012.nbor2, MSG_TAG_012, MPI_COMM_WORLD, &status);
- }
- /* do the left process second because it does the timing and needs to include time to send to the right process. */
- for (k=0; k < j; k++)
- {
- MPI_Recv(args012.rbuff, args012.bufflen, MPI_BYTE, args012.nbor, MSG_TAG_012, MPI_COMM_WORLD, &status);
- MPI_Send(args012.sbuff, args012.bufflen, MPI_BYTE, args012.nbor, MSG_TAG_012, MPI_COMM_WORLD);
- }
- t = (MPI_Wtime() - t0)/(2 * nrepeat012);
- }
- MPI_Bcast(&bwdata012[n].t, 1, MPI_DOUBLE, g_left_rank, MPI_COMM_WORLD);
- break;
- case RIGHT_PROCESS:
- bwdata012[n].t = LONGTIME;
- t1 = 0;
- for (i = 0; i < TRIALS; i++)
- {
- if (bNoCache)
- {
- if (bufalign != 0)
- {
- args012.sbuff = memtmp + ((bufalign - (POINTER_TO_INT(args012.sbuff) % bufalign) + bufoffset) % bufalign);
- /* args012.rbuff = memtmp1 + ((bufalign - ((MPI_Aint)args012.rbuff % bufalign) + bufoffset) % bufalign); */
- }
- else
- {
- args012.sbuff = memtmp;
- /* args012.rbuff = memtmp1; */
- }
- }
-
- Sync012(&args012);
- t0 = MPI_Wtime();
- for (j = 0; j < nrepeat012; j++)
- {
- MPI_Recv(args012.rbuff, args012.bufflen, MPI_BYTE, args012.nbor, MSG_TAG_012, MPI_COMM_WORLD, &status);
- MPI_Send(args012.sbuff, args012.bufflen, MPI_BYTE, args012.nbor, MSG_TAG_012, MPI_COMM_WORLD);
- if (bNoCache)
- {
- args012.sbuff += args012.bufflen;
- /* args012.rbuff += args012.bufflen; */
- }
- }
- t = (MPI_Wtime() - t0)/(2 * nrepeat012);
- }
- MPI_Bcast(&bwdata012[n].t, 1, MPI_DOUBLE, g_left_rank, MPI_COMM_WORLD);
- break;
- }
- tlast012 = bwdata012[n].t;
- bwdata012[n].bits = args012.bufflen * CHARSIZE;
- bwdata012[n].bps = bwdata012[n].bits / (bwdata012[n].t * 1024 * 1024);
- bwdata012[n].repeat = nrepeat012;
- if (itrial < ntrials)
- {
- dtrials[itrial] = MIN(dtrials[itrial], bwdata012[n].t);
- }
-
- if (g_nIproc == 0)
- {
- if (bSavePert)
- {
- fprintf(out, "\t%0.9f", bwdata012[n].t);
- fflush(out);
- }
- if (printopt)
- {
- printf(" %0.9f", tlast012);
- fflush(stdout);
- }
- }
- }
- if (g_nIproc == 0)
- {
- if (bSavePert)
- {
- fprintf(out, "\n");
- fflush(out);
- }
- if (printopt)
- {
- printf("\n");
- fflush(stdout);
- }
- }
-
- free(memtmp);
- free(memtmp1);
+ /*****************************************************/
+ /* Run a trial between rank 0, 1 and 2 */
+ /*****************************************************/
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+
+ /* Calculate howmany times to repeat the experiment. */
+ if (g_nIproc == 0) {
+ if (args012.bufflen == 0)
+ nrepeat012 = g_latency012_reps;
+ else
+ nrepeat012 = (int) (MAX((RUNTM / ((double) args012.bufflen /
+ (args012.bufflen - inc + 1.0) * tlast012)),
+ TRIALS));
+ MPI_Bcast(&nrepeat012, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ }
+ else {
+ MPI_Bcast(&nrepeat012, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ }
+
+ /* Allocate the buffer */
+ args012.bufflen = len + pert;
+ /* printf("allocating %d bytes\n", args12.bufflen * nrepeat012 + bufalign); */
+ if (bNoCache) {
+ if ((args012.sbuff =
+ (char *) malloc(args012.bufflen * nrepeat012 + bufalign)) == (char *) NULL) {
+ fprintf(stdout, "Couldn't allocate memory\n");
+ fflush(stdout);
+ break;
+ }
+ }
+ else {
+ if ((args012.sbuff = (char *) malloc(args012.bufflen + bufalign)) == (char *) NULL) {
+ fprintf(stdout, "Couldn't allocate memory\n");
+ fflush(stdout);
+ break;
+ }
+ }
+ /* if ((args012.rbuff = (char *)malloc(args012.bufflen * nrepeat012 + bufalign)) == (char *)NULL) */
+ if ((args012.rbuff = (char *) malloc(args012.bufflen + bufalign)) == (char *) NULL) {
+ fprintf(stdout, "Couldn't allocate memory\n");
+ fflush(stdout);
+ break;
+ }
+
+ /* save the original pointers in case alignment moves them */
+ memtmp = args012.sbuff;
+ memtmp1 = args012.rbuff;
+
+ /* Possibly align the data buffer */
+ if (!bNoCache) {
+ if (bufalign != 0) {
+ args012.sbuff +=
+ (bufalign - (POINTER_TO_INT(args012.sbuff) % bufalign) +
+ bufoffset) % bufalign;
+ /* args12.rbuff += (bufalign - ((MPI_Aint)args12.rbuff % bufalign) + bufoffset) % bufalign; */
+ }
+ }
+ args012.rbuff +=
+ (bufalign - (POINTER_TO_INT(args012.rbuff) % bufalign) + bufoffset) % bufalign;
+
+ if (g_nIproc == 0 && printopt) {
+ printf("%3d: %9d bytes %4d times --> ", n, args012.bufflen, nrepeat012);
+ fflush(stdout);
+ }
+
+ for (itrial = 0, ii = 1; ii <= nrepeat012 && itrial < ntrials; ii <<= 1, itrial++) {
+ /* Finally, we get to transmit or receive and time */
+ switch (g_proc_loc) {
+ case LEFT_PROCESS:
+ bwdata012[n].t = LONGTIME;
+ t1 = 0;
+ for (i = 0; i < TRIALS; i++) {
+ if (bNoCache) {
+ if (bufalign != 0) {
+ args012.sbuff =
+ memtmp +
+ ((bufalign - (POINTER_TO_INT(args012.sbuff) % bufalign) +
+ bufoffset) % bufalign);
+ /* args012.rbuff = memtmp1 + ((bufalign - ((MPI_Aint)args012.rbuff % bufalign) + bufoffset) % bufalign); */
+ }
+ else {
+ args012.sbuff = memtmp;
+ /* args012.rbuff = memtmp1; */
+ }
+ }
+
+ Sync012(&args012);
+ t0 = MPI_Wtime();
+ for (j = 0; j < nrepeat012; j++) {
+ MPI_Send(args012.sbuff, args012.bufflen, MPI_BYTE, args012.nbor,
+ MSG_TAG_012, MPI_COMM_WORLD);
+ MPI_Recv(args012.rbuff, args012.bufflen, MPI_BYTE, args012.nbor,
+ MSG_TAG_012, MPI_COMM_WORLD, &status);
+ if (bNoCache) {
+ args012.sbuff += args012.bufflen;
+ /* args012.rbuff += args012.bufflen; */
+ }
+ }
+ t = (MPI_Wtime() - t0) / (2 * nrepeat012);
+
+ t1 += t;
+ bwdata012[n].t = MIN(bwdata012[n].t, t);
+ }
+ MPI_Bcast(&bwdata012[n].t, 1, MPI_DOUBLE, g_left_rank, MPI_COMM_WORLD);
+ break;
+ case MIDDLE_PROCESS:
+ bwdata012[n].t = LONGTIME;
+ t1 = 0;
+ for (i = 0; i < TRIALS; i++) {
+ if (bNoCache) {
+ if (bufalign != 0) {
+ args012.sbuff =
+ memtmp +
+ ((bufalign - (POINTER_TO_INT(args012.sbuff) % bufalign) +
+ bufoffset) % bufalign);
+ /* args012.rbuff = memtmp1 + ((bufalign - ((MPI_Aint)args012.rbuff % bufalign) + bufoffset) % bufalign); */
+ }
+ else {
+ args012.sbuff = memtmp;
+ /* args012.rbuff = memtmp1; */
+ }
+ }
+
+ Sync012(&args012);
+ t0 = MPI_Wtime();
+
+ /******* use the ii variable here !!! ******/
+
+ for (j = 0; j <= nrepeat012 - ii; j += ii) {
+ for (k = 0; k < ii; k++) {
+ MPI_Send(args012.sbuff, args012.bufflen, MPI_BYTE, args012.nbor2,
+ MSG_TAG_012, MPI_COMM_WORLD);
+ MPI_Recv(args012.rbuff, args012.bufflen, MPI_BYTE, args012.nbor2,
+ MSG_TAG_012, MPI_COMM_WORLD, &status);
+ }
+ /* do the left process second because it does the timing and needs to include time to send to the right process. */
+ for (k = 0; k < ii; k++) {
+ MPI_Recv(args012.rbuff, args012.bufflen, MPI_BYTE, args012.nbor,
+ MSG_TAG_012, MPI_COMM_WORLD, &status);
+ MPI_Send(args012.sbuff, args012.bufflen, MPI_BYTE, args012.nbor,
+ MSG_TAG_012, MPI_COMM_WORLD);
+ }
+ if (bNoCache) {
+ args012.sbuff += args012.bufflen;
+ /* args012.rbuff += args012.bufflen; */
+ }
+ }
+ j = nrepeat012 % ii;
+ for (k = 0; k < j; k++) {
+ MPI_Send(args012.sbuff, args012.bufflen, MPI_BYTE, args012.nbor2,
+ MSG_TAG_012, MPI_COMM_WORLD);
+ MPI_Recv(args012.rbuff, args012.bufflen, MPI_BYTE, args012.nbor2,
+ MSG_TAG_012, MPI_COMM_WORLD, &status);
+ }
+ /* do the left process second because it does the timing and needs to include time to send to the right process. */
+ for (k = 0; k < j; k++) {
+ MPI_Recv(args012.rbuff, args012.bufflen, MPI_BYTE, args012.nbor,
+ MSG_TAG_012, MPI_COMM_WORLD, &status);
+ MPI_Send(args012.sbuff, args012.bufflen, MPI_BYTE, args012.nbor,
+ MSG_TAG_012, MPI_COMM_WORLD);
+ }
+ t = (MPI_Wtime() - t0) / (2 * nrepeat012);
+ }
+ MPI_Bcast(&bwdata012[n].t, 1, MPI_DOUBLE, g_left_rank, MPI_COMM_WORLD);
+ break;
+ case RIGHT_PROCESS:
+ bwdata012[n].t = LONGTIME;
+ t1 = 0;
+ for (i = 0; i < TRIALS; i++) {
+ if (bNoCache) {
+ if (bufalign != 0) {
+ args012.sbuff =
+ memtmp +
+ ((bufalign - (POINTER_TO_INT(args012.sbuff) % bufalign) +
+ bufoffset) % bufalign);
+ /* args012.rbuff = memtmp1 + ((bufalign - ((MPI_Aint)args012.rbuff % bufalign) + bufoffset) % bufalign); */
+ }
+ else {
+ args012.sbuff = memtmp;
+ /* args012.rbuff = memtmp1; */
+ }
+ }
+
+ Sync012(&args012);
+ t0 = MPI_Wtime();
+ for (j = 0; j < nrepeat012; j++) {
+ MPI_Recv(args012.rbuff, args012.bufflen, MPI_BYTE, args012.nbor,
+ MSG_TAG_012, MPI_COMM_WORLD, &status);
+ MPI_Send(args012.sbuff, args012.bufflen, MPI_BYTE, args012.nbor,
+ MSG_TAG_012, MPI_COMM_WORLD);
+ if (bNoCache) {
+ args012.sbuff += args012.bufflen;
+ /* args012.rbuff += args012.bufflen; */
+ }
+ }
+ t = (MPI_Wtime() - t0) / (2 * nrepeat012);
+ }
+ MPI_Bcast(&bwdata012[n].t, 1, MPI_DOUBLE, g_left_rank, MPI_COMM_WORLD);
+ break;
+ }
+ tlast012 = bwdata012[n].t;
+ bwdata012[n].bits = args012.bufflen * CHARSIZE;
+ bwdata012[n].bps = bwdata012[n].bits / (bwdata012[n].t * 1024 * 1024);
+ bwdata012[n].repeat = nrepeat012;
+ if (itrial < ntrials) {
+ dtrials[itrial] = MIN(dtrials[itrial], bwdata012[n].t);
+ }
+
+ if (g_nIproc == 0) {
+ if (bSavePert) {
+ fprintf(out, "\t%0.9f", bwdata012[n].t);
+ fflush(out);
+ }
+ if (printopt) {
+ printf(" %0.9f", tlast012);
+ fflush(stdout);
+ }
+ }
+ }
+ if (g_nIproc == 0) {
+ if (bSavePert) {
+ fprintf(out, "\n");
+ fflush(out);
+ }
+ if (printopt) {
+ printf("\n");
+ fflush(stdout);
+ }
+ }
+
+ free(memtmp);
+ free(memtmp1);
#endif
#ifdef CREATE_SINGLE_CURVE
- /*****************************************************/
- /* Run a trial between rank 0, 1 and 2 */
- /*****************************************************/
-
- MPI_Barrier(MPI_COMM_WORLD);
-
-
- /* Calculate howmany times to repeat the experiment. */
- if (g_nIproc == 0)
- {
- if (args012.bufflen == 0)
- nrepeat012 = g_latency012_reps;
- else
- nrepeat012 = (int)(MAX((RUNTM / ((double)args012.bufflen /
- (args012.bufflen - inc + 1.0) * tlast012)), TRIALS));
- MPI_Bcast(&nrepeat012, 1, MPI_INT, 0, MPI_COMM_WORLD);
- }
- else
- {
- MPI_Bcast(&nrepeat012, 1, MPI_INT, 0, MPI_COMM_WORLD);
- }
-
- /* Allocate the buffer */
- args012.bufflen = len + pert;
- /* printf("allocating %d bytes\n", args12.bufflen * nrepeat012 + bufalign); */
- if (bNoCache)
- {
- if ((args012.sbuff = (char *)malloc(args012.bufflen * nrepeat012 + bufalign)) == (char *)NULL)
- {
- fprintf(stdout,"Couldn't allocate memory\n");
- fflush(stdout);
- break;
- }
- }
- else
- {
- if ((args012.sbuff = (char *)malloc(args012.bufflen + bufalign)) == (char *)NULL)
- {
- fprintf(stdout,"Couldn't allocate memory\n");
- fflush(stdout);
- break;
- }
- }
- /* if ((args012.rbuff = (char *)malloc(args012.bufflen * nrepeat012 + bufalign)) == (char *)NULL) */
- if ((args012.rbuff = (char *)malloc(args012.bufflen + bufalign)) == (char *)NULL)
- {
- fprintf(stdout,"Couldn't allocate memory\n");
- fflush(stdout);
- break;
- }
-
- /* save the original pointers in case alignment moves them */
- memtmp = args012.sbuff;
- memtmp1 = args012.rbuff;
-
- /* Possibly align the data buffer */
- if (!bNoCache)
- {
- if (bufalign != 0)
- {
- args012.sbuff += (bufalign - (POINTER_TO_INT(args012.sbuff) % bufalign) + bufoffset) % bufalign;
- /* args12.rbuff += (bufalign - ((MPI_Aint)args12.rbuff % bufalign) + bufoffset) % bufalign; */
- }
- }
- args012.rbuff += (bufalign - (POINTER_TO_INT(args012.rbuff) % bufalign) + bufoffset) % bufalign;
-
- if (g_nIproc == 0 && printopt)
- {
- printf("%3d: %9d bytes %4d times --> ", n, args012.bufflen, nrepeat012);
- fflush(stdout);
- }
-
- /* Finally, we get to transmit or receive and time */
- switch (g_proc_loc)
- {
- case LEFT_PROCESS:
- bwdata012[n].t = LONGTIME;
- t1 = 0;
- for (i = 0; i < TRIALS; i++)
- {
- if (bNoCache)
- {
- if (bufalign != 0)
- {
- args012.sbuff = memtmp + ((bufalign - (POINTER_TO_INT(args012.sbuff) % bufalign) + bufoffset) % bufalign);
- /* args012.rbuff = memtmp1 + ((bufalign - ((MPI_Aint)args012.rbuff % bufalign) + bufoffset) % bufalign); */
- }
- else
- {
- args012.sbuff = memtmp;
- /* args012.rbuff = memtmp1; */
- }
- }
-
- Sync012(&args012);
- t0 = MPI_Wtime();
- for (j = 0; j < nrepeat012; j++)
- {
- MPI_Send(args012.sbuff, args012.bufflen, MPI_BYTE, args012.nbor, MSG_TAG_012, MPI_COMM_WORLD);
- MPI_Recv(args012.rbuff, args012.bufflen, MPI_BYTE, args012.nbor, MSG_TAG_012, MPI_COMM_WORLD, &status);
- if (bNoCache)
- {
- args012.sbuff += args012.bufflen;
- /* args012.rbuff += args012.bufflen; */
- }
- }
- t = (MPI_Wtime() - t0)/(2 * nrepeat012);
-
- t1 += t;
- bwdata012[n].t = MIN(bwdata012[n].t, t);
- }
- MPI_Bcast(&bwdata012[n].t, 1, MPI_DOUBLE, g_left_rank, MPI_COMM_WORLD);
- break;
- case MIDDLE_PROCESS:
- bwdata012[n].t = LONGTIME;
- t1 = 0;
- for (i = 0; i < TRIALS; i++)
- {
- if (bNoCache)
- {
- if (bufalign != 0)
- {
- args012.sbuff = memtmp + ((bufalign - (POINTER_TO_INT(args012.sbuff) % bufalign) + bufoffset) % bufalign);
- /* args012.rbuff = memtmp1 + ((bufalign - ((MPI_Aint)args012.rbuff % bufalign) + bufoffset) % bufalign); */
- }
- else
- {
- args012.sbuff = memtmp;
- /* args012.rbuff = memtmp1; */
- }
- }
-
- Sync012(&args012);
- t0 = MPI_Wtime();
- for (j = 0; j < nrepeat012; j++)
- {
- MPI_Recv(args012.rbuff, args012.bufflen, MPI_BYTE, args012.nbor, MSG_TAG_012, MPI_COMM_WORLD, &status);
- MPI_Send(args012.sbuff, args012.bufflen, MPI_BYTE, args012.nbor2, MSG_TAG_012, MPI_COMM_WORLD);
- MPI_Recv(args012.rbuff, args012.bufflen, MPI_BYTE, args012.nbor2, MSG_TAG_012, MPI_COMM_WORLD, &status);
- MPI_Send(args012.sbuff, args012.bufflen, MPI_BYTE, args012.nbor, MSG_TAG_012, MPI_COMM_WORLD);
- if (bNoCache)
- {
- args012.sbuff += args012.bufflen;
- /* args012.rbuff += args012.bufflen; */
- }
- }
- t = (MPI_Wtime() - t0)/(2 * nrepeat012);
- }
- MPI_Bcast(&bwdata012[n].t, 1, MPI_DOUBLE, g_left_rank, MPI_COMM_WORLD);
- break;
- case RIGHT_PROCESS:
- bwdata012[n].t = LONGTIME;
- t1 = 0;
- for (i = 0; i < TRIALS; i++)
- {
- if (bNoCache)
- {
- if (bufalign != 0)
- {
- args012.sbuff = memtmp + ((bufalign - (POINTER_TO_INT(args012.sbuff) % bufalign) + bufoffset) % bufalign);
- /* args012.rbuff = memtmp1 + ((bufalign - ((MPI_Aint)args012.rbuff % bufalign) + bufoffset) % bufalign); */
- }
- else
- {
- args012.sbuff = memtmp;
- /* args012.rbuff = memtmp1; */
- }
- }
-
- Sync012(&args012);
- t0 = MPI_Wtime();
- for (j = 0; j < nrepeat012; j++)
- {
- MPI_Recv(args012.rbuff, args012.bufflen, MPI_BYTE, args012.nbor, MSG_TAG_012, MPI_COMM_WORLD, &status);
- MPI_Send(args012.sbuff, args012.bufflen, MPI_BYTE, args012.nbor, MSG_TAG_012, MPI_COMM_WORLD);
- if (bNoCache)
- {
- args012.sbuff += args012.bufflen;
- /* args012.rbuff += args012.bufflen; */
- }
- }
- t = (MPI_Wtime() - t0)/(2 * nrepeat012);
- }
- MPI_Bcast(&bwdata012[n].t, 1, MPI_DOUBLE, g_left_rank, MPI_COMM_WORLD);
- break;
- }
- tlast012 = bwdata012[n].t;
- bwdata012[n].bits = args012.bufflen * CHARSIZE;
- bwdata012[n].bps = bwdata012[n].bits / (bwdata012[n].t * 1024 * 1024);
- bwdata012[n].repeat = nrepeat012;
-
- if (g_nIproc == 0)
- {
- if (bSavePert)
- {
- if (bUseMegaBytes)
- fprintf(out, "%f\t%0.9f\n", bwdata012[n].bps / 8, bwdata012[n].t);
- else
- fprintf(out, "%f\t%0.9f\n", bwdata012[n].bps, bwdata012[n].t);
- fflush(out);
- }
- }
-
- free(memtmp);
- free(memtmp1);
-
- if (g_nIproc == 0 && printopt)
- {
- if (bUseMegaBytes)
- printf(" %6.2f MBps in %0.9f sec\n", bwdata012[n].bps / 8, tlast012);
- else
- printf(" %6.2f Mbps in %0.9f sec\n", bwdata012[n].bps, tlast012);
- fflush(stdout);
- }
+ /*****************************************************/
+ /* Run a trial between rank 0, 1 and 2 */
+ /*****************************************************/
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+
+ /* Calculate howmany times to repeat the experiment. */
+ if (g_nIproc == 0) {
+ if (args012.bufflen == 0)
+ nrepeat012 = g_latency012_reps;
+ else
+ nrepeat012 = (int) (MAX((RUNTM / ((double) args012.bufflen /
+ (args012.bufflen - inc + 1.0) * tlast012)),
+ TRIALS));
+ MPI_Bcast(&nrepeat012, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ }
+ else {
+ MPI_Bcast(&nrepeat012, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ }
+
+ /* Allocate the buffer */
+ args012.bufflen = len + pert;
+ /* printf("allocating %d bytes\n", args12.bufflen * nrepeat012 + bufalign); */
+ if (bNoCache) {
+ if ((args012.sbuff =
+ (char *) malloc(args012.bufflen * nrepeat012 + bufalign)) == (char *) NULL) {
+ fprintf(stdout, "Couldn't allocate memory\n");
+ fflush(stdout);
+ break;
+ }
+ }
+ else {
+ if ((args012.sbuff = (char *) malloc(args012.bufflen + bufalign)) == (char *) NULL) {
+ fprintf(stdout, "Couldn't allocate memory\n");
+ fflush(stdout);
+ break;
+ }
+ }
+ /* if ((args012.rbuff = (char *)malloc(args012.bufflen * nrepeat012 + bufalign)) == (char *)NULL) */
+ if ((args012.rbuff = (char *) malloc(args012.bufflen + bufalign)) == (char *) NULL) {
+ fprintf(stdout, "Couldn't allocate memory\n");
+ fflush(stdout);
+ break;
+ }
+
+ /* save the original pointers in case alignment moves them */
+ memtmp = args012.sbuff;
+ memtmp1 = args012.rbuff;
+
+ /* Possibly align the data buffer */
+ if (!bNoCache) {
+ if (bufalign != 0) {
+ args012.sbuff +=
+ (bufalign - (POINTER_TO_INT(args012.sbuff) % bufalign) +
+ bufoffset) % bufalign;
+ /* args12.rbuff += (bufalign - ((MPI_Aint)args12.rbuff % bufalign) + bufoffset) % bufalign; */
+ }
+ }
+ args012.rbuff +=
+ (bufalign - (POINTER_TO_INT(args012.rbuff) % bufalign) + bufoffset) % bufalign;
+
+ if (g_nIproc == 0 && printopt) {
+ printf("%3d: %9d bytes %4d times --> ", n, args012.bufflen, nrepeat012);
+ fflush(stdout);
+ }
+
+ /* Finally, we get to transmit or receive and time */
+ switch (g_proc_loc) {
+ case LEFT_PROCESS:
+ bwdata012[n].t = LONGTIME;
+ t1 = 0;
+ for (i = 0; i < TRIALS; i++) {
+ if (bNoCache) {
+ if (bufalign != 0) {
+ args012.sbuff =
+ memtmp +
+ ((bufalign - (POINTER_TO_INT(args012.sbuff) % bufalign) +
+ bufoffset) % bufalign);
+ /* args012.rbuff = memtmp1 + ((bufalign - ((MPI_Aint)args012.rbuff % bufalign) + bufoffset) % bufalign); */
+ }
+ else {
+ args012.sbuff = memtmp;
+ /* args012.rbuff = memtmp1; */
+ }
+ }
+
+ Sync012(&args012);
+ t0 = MPI_Wtime();
+ for (j = 0; j < nrepeat012; j++) {
+ MPI_Send(args012.sbuff, args012.bufflen, MPI_BYTE, args012.nbor,
+ MSG_TAG_012, MPI_COMM_WORLD);
+ MPI_Recv(args012.rbuff, args012.bufflen, MPI_BYTE, args012.nbor,
+ MSG_TAG_012, MPI_COMM_WORLD, &status);
+ if (bNoCache) {
+ args012.sbuff += args012.bufflen;
+ /* args012.rbuff += args012.bufflen; */
+ }
+ }
+ t = (MPI_Wtime() - t0) / (2 * nrepeat012);
+
+ t1 += t;
+ bwdata012[n].t = MIN(bwdata012[n].t, t);
+ }
+ MPI_Bcast(&bwdata012[n].t, 1, MPI_DOUBLE, g_left_rank, MPI_COMM_WORLD);
+ break;
+ case MIDDLE_PROCESS:
+ bwdata012[n].t = LONGTIME;
+ t1 = 0;
+ for (i = 0; i < TRIALS; i++) {
+ if (bNoCache) {
+ if (bufalign != 0) {
+ args012.sbuff =
+ memtmp +
+ ((bufalign - (POINTER_TO_INT(args012.sbuff) % bufalign) +
+ bufoffset) % bufalign);
+ /* args012.rbuff = memtmp1 + ((bufalign - ((MPI_Aint)args012.rbuff % bufalign) + bufoffset) % bufalign); */
+ }
+ else {
+ args012.sbuff = memtmp;
+ /* args012.rbuff = memtmp1; */
+ }
+ }
+
+ Sync012(&args012);
+ t0 = MPI_Wtime();
+ for (j = 0; j < nrepeat012; j++) {
+ MPI_Recv(args012.rbuff, args012.bufflen, MPI_BYTE, args012.nbor,
+ MSG_TAG_012, MPI_COMM_WORLD, &status);
+ MPI_Send(args012.sbuff, args012.bufflen, MPI_BYTE, args012.nbor2,
+ MSG_TAG_012, MPI_COMM_WORLD);
+ MPI_Recv(args012.rbuff, args012.bufflen, MPI_BYTE, args012.nbor2,
+ MSG_TAG_012, MPI_COMM_WORLD, &status);
+ MPI_Send(args012.sbuff, args012.bufflen, MPI_BYTE, args012.nbor,
+ MSG_TAG_012, MPI_COMM_WORLD);
+ if (bNoCache) {
+ args012.sbuff += args012.bufflen;
+ /* args012.rbuff += args012.bufflen; */
+ }
+ }
+ t = (MPI_Wtime() - t0) / (2 * nrepeat012);
+ }
+ MPI_Bcast(&bwdata012[n].t, 1, MPI_DOUBLE, g_left_rank, MPI_COMM_WORLD);
+ break;
+ case RIGHT_PROCESS:
+ bwdata012[n].t = LONGTIME;
+ t1 = 0;
+ for (i = 0; i < TRIALS; i++) {
+ if (bNoCache) {
+ if (bufalign != 0) {
+ args012.sbuff =
+ memtmp +
+ ((bufalign - (POINTER_TO_INT(args012.sbuff) % bufalign) +
+ bufoffset) % bufalign);
+ /* args012.rbuff = memtmp1 + ((bufalign - ((MPI_Aint)args012.rbuff % bufalign) + bufoffset) % bufalign); */
+ }
+ else {
+ args012.sbuff = memtmp;
+ /* args012.rbuff = memtmp1; */
+ }
+ }
+
+ Sync012(&args012);
+ t0 = MPI_Wtime();
+ for (j = 0; j < nrepeat012; j++) {
+ MPI_Recv(args012.rbuff, args012.bufflen, MPI_BYTE, args012.nbor,
+ MSG_TAG_012, MPI_COMM_WORLD, &status);
+ MPI_Send(args012.sbuff, args012.bufflen, MPI_BYTE, args012.nbor,
+ MSG_TAG_012, MPI_COMM_WORLD);
+ if (bNoCache) {
+ args012.sbuff += args012.bufflen;
+ /* args012.rbuff += args012.bufflen; */
+ }
+ }
+ t = (MPI_Wtime() - t0) / (2 * nrepeat012);
+ }
+ MPI_Bcast(&bwdata012[n].t, 1, MPI_DOUBLE, g_left_rank, MPI_COMM_WORLD);
+ break;
+ }
+ tlast012 = bwdata012[n].t;
+ bwdata012[n].bits = args012.bufflen * CHARSIZE;
+ bwdata012[n].bps = bwdata012[n].bits / (bwdata012[n].t * 1024 * 1024);
+ bwdata012[n].repeat = nrepeat012;
+
+ if (g_nIproc == 0) {
+ if (bSavePert) {
+ if (bUseMegaBytes)
+ fprintf(out, "%f\t%0.9f\n", bwdata012[n].bps / 8, bwdata012[n].t);
+ else
+ fprintf(out, "%f\t%0.9f\n", bwdata012[n].bps, bwdata012[n].t);
+ fflush(out);
+ }
+ }
+
+ free(memtmp);
+ free(memtmp1);
+
+ if (g_nIproc == 0 && printopt) {
+ if (bUseMegaBytes)
+ printf(" %6.2f MBps in %0.9f sec\n", bwdata012[n].bps / 8, tlast012);
+ else
+ printf(" %6.2f Mbps in %0.9f sec\n", bwdata012[n].bps, tlast012);
+ fflush(stdout);
+ }
#endif
- } /* End of perturbation loop */
+ } /* End of perturbation loop */
- if (!bSavePert)/* && g_nIproc == 0)*/
- {
- /* if we didn't save all of the perturbation loops, find the max and save it */
- int index01 = 1, index12 = 1;
- double dmax01 = bwdata01[n-1].bps;
- double dmax12 = bwdata12[n-1].bps;
+ if (!bSavePert) { /* && g_nIproc == 0) */
+ /* if we didn't save all of the perturbation loops, find the max and save it */
+ int index01 = 1, index12 = 1;
+ double dmax01 = bwdata01[n - 1].bps;
+ double dmax12 = bwdata12[n - 1].bps;
#ifdef CREATE_SINGLE_CURVE
- int index012 = 1;
- double dmax012 = bwdata012[n-1].bps;
+ int index012 = 1;
+ double dmax012 = bwdata012[n - 1].bps;
#endif
- for (; ipert > 1; ipert--)
- {
- if (bwdata01[n-ipert].bps > dmax01)
- {
- index01 = ipert;
- dmax01 = bwdata01[n-ipert].bps;
- }
- if (bwdata12[n-ipert].bps > dmax12)
- {
- index12 = ipert;
- dmax12 = bwdata12[n-ipert].bps;
- }
+ for (; ipert > 1; ipert--) {
+ if (bwdata01[n - ipert].bps > dmax01) {
+ index01 = ipert;
+ dmax01 = bwdata01[n - ipert].bps;
+ }
+ if (bwdata12[n - ipert].bps > dmax12) {
+ index12 = ipert;
+ dmax12 = bwdata12[n - ipert].bps;
+ }
#ifdef CREATE_SINGLE_CURVE
- if (bwdata012[n-ipert].bps > dmax012)
- {
- index012 = ipert;
- dmax012 = bwdata012[n-ipert].bps;
- }
+ if (bwdata012[n - ipert].bps > dmax012) {
+ index012 = ipert;
+ dmax012 = bwdata012[n - ipert].bps;
+ }
#endif
- }
- /* get the left stuff out */
- MPI_Bcast(&index01, 1, MPI_INT, g_left_rank, MPI_COMM_WORLD);
- MPI_Bcast(&bwdata01[n-index01].bits, 1, MPI_INT, g_left_rank, MPI_COMM_WORLD);
- MPI_Bcast(&bwdata01[n-index01].bps, 1, MPI_DOUBLE, g_left_rank, MPI_COMM_WORLD);
- MPI_Bcast(&bwdata01[n-index01].t, 1, MPI_DOUBLE, g_left_rank, MPI_COMM_WORLD);
- /* get the right stuff out */
- MPI_Bcast(&index12, 1, MPI_INT, g_middle_rank, MPI_COMM_WORLD);
- MPI_Bcast(&bwdata12[n-index12].bps, 1, MPI_DOUBLE, g_middle_rank, MPI_COMM_WORLD);
- MPI_Bcast(&bwdata12[n-index12].t, 1, MPI_DOUBLE, g_middle_rank, MPI_COMM_WORLD);
- if (g_nIproc == 0)
- {
- if (bUseMegaBytes)
- {
- fprintf(out, "%d\t%f\t%0.9f\t", bwdata01[n-index01].bits / 8, bwdata01[n-index01].bps / 8, bwdata01[n-index01].t);
- fprintf(out, "%f\t%0.9f\t", bwdata12[n-index12].bps / 8, bwdata12[n-index12].t);
+ }
+ /* get the left stuff out */
+ MPI_Bcast(&index01, 1, MPI_INT, g_left_rank, MPI_COMM_WORLD);
+ MPI_Bcast(&bwdata01[n - index01].bits, 1, MPI_INT, g_left_rank, MPI_COMM_WORLD);
+ MPI_Bcast(&bwdata01[n - index01].bps, 1, MPI_DOUBLE, g_left_rank, MPI_COMM_WORLD);
+ MPI_Bcast(&bwdata01[n - index01].t, 1, MPI_DOUBLE, g_left_rank, MPI_COMM_WORLD);
+ /* get the right stuff out */
+ MPI_Bcast(&index12, 1, MPI_INT, g_middle_rank, MPI_COMM_WORLD);
+ MPI_Bcast(&bwdata12[n - index12].bps, 1, MPI_DOUBLE, g_middle_rank, MPI_COMM_WORLD);
+ MPI_Bcast(&bwdata12[n - index12].t, 1, MPI_DOUBLE, g_middle_rank, MPI_COMM_WORLD);
+ if (g_nIproc == 0) {
+ if (bUseMegaBytes) {
+ fprintf(out, "%d\t%f\t%0.9f\t", bwdata01[n - index01].bits / 8,
+ bwdata01[n - index01].bps / 8, bwdata01[n - index01].t);
+ fprintf(out, "%f\t%0.9f\t", bwdata12[n - index12].bps / 8,
+ bwdata12[n - index12].t);
#ifdef CREATE_SINGLE_CURVE
- fprintf(out, "%f\t%0.9f\n", bwdata012[n-index012].bps / 8, bwdata012[n-index012].t);
+ fprintf(out, "%f\t%0.9f\n", bwdata012[n - index012].bps / 8,
+ bwdata012[n - index012].t);
#endif
- }
- else
- {
- fprintf(out, "%d\t%f\t%0.9f\t", bwdata01[n-index01].bits / 8, bwdata01[n-index01].bps, bwdata01[n-index01].t);
- fprintf(out, "%f\t%0.9f\t", bwdata12[n-index12].bps, bwdata12[n-index12].t);
+ }
+ else {
+ fprintf(out, "%d\t%f\t%0.9f\t", bwdata01[n - index01].bits / 8,
+ bwdata01[n - index01].bps, bwdata01[n - index01].t);
+ fprintf(out, "%f\t%0.9f\t", bwdata12[n - index12].bps, bwdata12[n - index12].t);
#ifdef CREATE_SINGLE_CURVE
- fprintf(out, "%f\t%0.9f\n", bwdata012[n-index012].bps, bwdata012[n-index012].t);
+ fprintf(out, "%f\t%0.9f\n", bwdata012[n - index012].bps,
+ bwdata012[n - index012].t);
#endif
- }
+ }
#ifdef CREATE_DIFFERENCE_CURVES
- for (itrial = 0; itrial < ntrials && dtrials[itrial] != LONGTIME; itrial++)
- {
- fprintf(out, "%0.9f\t", dtrials[itrial]);
- }
- fprintf(out, "\n");
+ for (itrial = 0; itrial < ntrials && dtrials[itrial] != LONGTIME; itrial++) {
+ fprintf(out, "%0.9f\t", dtrials[itrial]);
+ }
+ fprintf(out, "\n");
#endif
- fflush(out);
- }
- }
- } /* End of main loop */
-
+ fflush(out);
+ }
+ }
+ } /* End of main loop */
+
if (g_nIproc == 0)
- fclose(out);
- /* THE_END: */
+ fclose(out);
+ /* THE_END: */
MPI_Finalize();
free(bwdata01);
free(bwdata12);
@@ -1236,174 +1163,167 @@ skip_12_trial:
return 0;
}
-int Setup(int middle_rank, ArgStruct *p01, ArgStruct *p12, ArgStruct *p012)
+int Setup(int middle_rank, ArgStruct * p01, ArgStruct * p12, ArgStruct * p012)
{
char s[255];
int len = 255;
-
+
p01->iproc = p12->iproc = p012->iproc = g_nIproc;
-
+
MPI_Get_processor_name(s, &len);
- /*gethostname(s, len);*/
+ /*gethostname(s, len); */
printf("%d: %s\n", p01->iproc, s);
fflush(stdout);
- switch (middle_rank)
- {
+ switch (middle_rank) {
case 0:
- switch (g_nIproc)
- {
- case 0:
- g_proc_loc = MIDDLE_PROCESS;
- p01->nbor = 2;
- p01->tr = FALSE;
- p12->nbor = 1;
- p12->tr = TRUE;
- p012->nbor = 2;
- p012->nbor2 = 1;
- break;
- case 1:
- g_proc_loc = RIGHT_PROCESS;
- p01->nbor = -1;
- p01->tr = FALSE;
- p12->nbor = 0;
- p12->tr = FALSE;
- p012->nbor = 0;
- p012->nbor2 = -1;
- break;
- case 2:
- g_proc_loc = LEFT_PROCESS;
- p01->nbor = 0;
- p01->tr = TRUE;
- p12->nbor = -1;
- p12->tr = FALSE;
- p012->nbor = 0;
- p012->nbor2 = -1;
- break;
- }
- g_left_rank = 2;
- g_middle_rank = 0;
- g_right_rank = 1;
- break;
+ switch (g_nIproc) {
+ case 0:
+ g_proc_loc = MIDDLE_PROCESS;
+ p01->nbor = 2;
+ p01->tr = FALSE;
+ p12->nbor = 1;
+ p12->tr = TRUE;
+ p012->nbor = 2;
+ p012->nbor2 = 1;
+ break;
+ case 1:
+ g_proc_loc = RIGHT_PROCESS;
+ p01->nbor = -1;
+ p01->tr = FALSE;
+ p12->nbor = 0;
+ p12->tr = FALSE;
+ p012->nbor = 0;
+ p012->nbor2 = -1;
+ break;
+ case 2:
+ g_proc_loc = LEFT_PROCESS;
+ p01->nbor = 0;
+ p01->tr = TRUE;
+ p12->nbor = -1;
+ p12->tr = FALSE;
+ p012->nbor = 0;
+ p012->nbor2 = -1;
+ break;
+ }
+ g_left_rank = 2;
+ g_middle_rank = 0;
+ g_right_rank = 1;
+ break;
case 1:
- switch (g_nIproc)
- {
- case 0:
- g_proc_loc = LEFT_PROCESS;
- p01->nbor = 1;
- p01->tr = TRUE;
- p12->nbor = -1;
- p12->tr = FALSE;
- p012->nbor = 1;
- p012->nbor2 = -1;
- break;
- case 1:
- g_proc_loc = MIDDLE_PROCESS;
- p01->nbor = 0;
- p01->tr = FALSE;
- p12->nbor = 2;
- p12->tr = TRUE;
- p012->nbor = 0;
- p012->nbor2 = 2;
- break;
- case 2:
- g_proc_loc = RIGHT_PROCESS;
- p01->nbor = -1;
- p01->tr = FALSE;
- p12->nbor = 1;
- p12->tr = FALSE;
- p012->nbor = 1;
- p012->nbor2 = -1;
- break;
- }
- g_left_rank = 0;
- g_middle_rank = 1;
- g_right_rank = 2;
- break;
+ switch (g_nIproc) {
+ case 0:
+ g_proc_loc = LEFT_PROCESS;
+ p01->nbor = 1;
+ p01->tr = TRUE;
+ p12->nbor = -1;
+ p12->tr = FALSE;
+ p012->nbor = 1;
+ p012->nbor2 = -1;
+ break;
+ case 1:
+ g_proc_loc = MIDDLE_PROCESS;
+ p01->nbor = 0;
+ p01->tr = FALSE;
+ p12->nbor = 2;
+ p12->tr = TRUE;
+ p012->nbor = 0;
+ p012->nbor2 = 2;
+ break;
+ case 2:
+ g_proc_loc = RIGHT_PROCESS;
+ p01->nbor = -1;
+ p01->tr = FALSE;
+ p12->nbor = 1;
+ p12->tr = FALSE;
+ p012->nbor = 1;
+ p012->nbor2 = -1;
+ break;
+ }
+ g_left_rank = 0;
+ g_middle_rank = 1;
+ g_right_rank = 2;
+ break;
case 2:
- switch (g_nIproc)
- {
- case 0:
- g_proc_loc = RIGHT_PROCESS;
- p01->nbor = -1;
- p01->tr = FALSE;
- p12->nbor = 2;
- p12->tr = FALSE;
- p012->nbor = 2;
- p012->nbor2 = -1;
- break;
- case 1:
- g_proc_loc = LEFT_PROCESS;
- p01->nbor = 2;
- p01->tr = TRUE;
- p12->nbor = -1;
- p12->tr = FALSE;
- p012->nbor = 2;
- p012->nbor2 = -1;
- break;
- case 2:
- g_proc_loc = MIDDLE_PROCESS;
- p01->nbor = 1;
- p01->tr = FALSE;
- p12->nbor = 0;
- p12->tr = TRUE;
- p012->nbor = 1;
- p012->nbor2 = 0;
- break;
- }
- g_left_rank = 1;
- g_middle_rank = 2;
- g_right_rank = 0;
- break;
+ switch (g_nIproc) {
+ case 0:
+ g_proc_loc = RIGHT_PROCESS;
+ p01->nbor = -1;
+ p01->tr = FALSE;
+ p12->nbor = 2;
+ p12->tr = FALSE;
+ p012->nbor = 2;
+ p012->nbor2 = -1;
+ break;
+ case 1:
+ g_proc_loc = LEFT_PROCESS;
+ p01->nbor = 2;
+ p01->tr = TRUE;
+ p12->nbor = -1;
+ p12->tr = FALSE;
+ p012->nbor = 2;
+ p012->nbor2 = -1;
+ break;
+ case 2:
+ g_proc_loc = MIDDLE_PROCESS;
+ p01->nbor = 1;
+ p01->tr = FALSE;
+ p12->nbor = 0;
+ p12->tr = TRUE;
+ p012->nbor = 1;
+ p012->nbor2 = 0;
+ break;
+ }
+ g_left_rank = 1;
+ g_middle_rank = 2;
+ g_right_rank = 0;
+ break;
}
- return 1;
-}
+ return 1;
+}
-void Sync(ArgStruct *p)
+void Sync(ArgStruct * p)
{
MPI_Status status;
- if (p->tr)
- {
- MPI_Send(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD);
- MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
- MPI_Send(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD);
+ if (p->tr) {
+ MPI_Send(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD);
+ MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
+ MPI_Send(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD);
}
- else
- {
- MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
- MPI_Send(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD);
- MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
+ else {
+ MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
+ MPI_Send(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD);
+ MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
}
}
-void Sync012(ArgStruct *p)
+void Sync012(ArgStruct * p)
{
MPI_Status status;
- switch (g_proc_loc)
- {
+ switch (g_proc_loc) {
case LEFT_PROCESS:
- MPI_Send(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD);
- MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
- MPI_Send(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD);
- break;
+ MPI_Send(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD);
+ MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
+ MPI_Send(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD);
+ break;
case MIDDLE_PROCESS:
- MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
- MPI_Send(NULL, 0, MPI_BYTE, p->nbor2, 1, MPI_COMM_WORLD);
- MPI_Recv(NULL, 0, MPI_BYTE, p->nbor2, 1, MPI_COMM_WORLD, &status);
- MPI_Send(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD);
- MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
- MPI_Send(NULL, 0, MPI_BYTE, p->nbor2, 1, MPI_COMM_WORLD);
- break;
+ MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
+ MPI_Send(NULL, 0, MPI_BYTE, p->nbor2, 1, MPI_COMM_WORLD);
+ MPI_Recv(NULL, 0, MPI_BYTE, p->nbor2, 1, MPI_COMM_WORLD, &status);
+ MPI_Send(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD);
+ MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
+ MPI_Send(NULL, 0, MPI_BYTE, p->nbor2, 1, MPI_COMM_WORLD);
+ break;
case RIGHT_PROCESS:
- MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
- MPI_Send(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD);
- MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
- break;
+ MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
+ MPI_Send(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD);
+ MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
+ break;
}
}
-int DetermineLatencyReps(ArgStruct *p)
+int DetermineLatencyReps(ArgStruct * p)
{
MPI_Status status;
double t0, duration = 0;
@@ -1415,35 +1335,32 @@ int DetermineLatencyReps(ArgStruct *p)
Sync(p);
Sync(p);
- /* test how long it takes to send n messages
+ /* test how long it takes to send n messages
* where n = 1, 2, 4, 8, 16, 32, ...
*/
t0 = MPI_Wtime();
t0 = MPI_Wtime();
t0 = MPI_Wtime();
- while ( (duration < RUNTM) ||
- (duration < MAX_LAT_TIME && reps < 1000))
- {
- t0 = MPI_Wtime();
- for (i=0; i<reps-prev_reps; i++)
- {
- Sync(p);
- }
- duration += MPI_Wtime() - t0;
- prev_reps = reps;
- reps = reps * 2;
-
- /* use duration from the root only */
- if (p->tr)
- MPI_Send(&duration, 1, MPI_DOUBLE, p->nbor, 2, MPI_COMM_WORLD);
- else
- MPI_Recv(&duration, 1, MPI_DOUBLE, p->nbor, 2, MPI_COMM_WORLD, &status);
+ while ((duration < RUNTM) || (duration < MAX_LAT_TIME && reps < 1000)) {
+ t0 = MPI_Wtime();
+ for (i = 0; i < reps - prev_reps; i++) {
+ Sync(p);
+ }
+ duration += MPI_Wtime() - t0;
+ prev_reps = reps;
+ reps = reps * 2;
+
+ /* use duration from the root only */
+ if (p->tr)
+ MPI_Send(&duration, 1, MPI_DOUBLE, p->nbor, 2, MPI_COMM_WORLD);
+ else
+ MPI_Recv(&duration, 1, MPI_DOUBLE, p->nbor, 2, MPI_COMM_WORLD, &status);
}
return reps;
}
-int DetermineLatencyReps012(ArgStruct *p)
+int DetermineLatencyReps012(ArgStruct * p)
{
double t0, duration = 0;
int reps = 1, prev_reps = 0;
@@ -1454,32 +1371,29 @@ int DetermineLatencyReps012(ArgStruct *p)
Sync012(p);
Sync012(p);
- /* test how long it takes to send n messages
+ /* test how long it takes to send n messages
* where n = 1, 2, 4, 8, 16, 32, ...
*/
t0 = MPI_Wtime();
t0 = MPI_Wtime();
t0 = MPI_Wtime();
- while ( (duration < RUNTM) ||
- (duration < MAX_LAT_TIME && reps < 1000))
- {
- t0 = MPI_Wtime();
- for (i=0; i<reps-prev_reps; i++)
- {
- Sync012(p);
- }
- duration += MPI_Wtime() - t0;
- prev_reps = reps;
- reps = reps * 2;
-
- /* use duration from the root only */
- MPI_Bcast(&duration, 1, MPI_DOUBLE, g_left_rank, MPI_COMM_WORLD);
+ while ((duration < RUNTM) || (duration < MAX_LAT_TIME && reps < 1000)) {
+ t0 = MPI_Wtime();
+ for (i = 0; i < reps - prev_reps; i++) {
+ Sync012(p);
+ }
+ duration += MPI_Wtime() - t0;
+ prev_reps = reps;
+ reps = reps * 2;
+
+ /* use duration from the root only */
+ MPI_Bcast(&duration, 1, MPI_DOUBLE, g_left_rank, MPI_COMM_WORLD);
}
return reps;
}
-double TestLatency(ArgStruct *p)
+double TestLatency(ArgStruct * p)
{
double latency, t0, min_latency = LONGTIME;
int i, j;
@@ -1488,112 +1402,102 @@ double TestLatency(ArgStruct *p)
/* calculate the latency between rank 0 and rank 1 */
p->latency_reps = DetermineLatencyReps(p);
- if (/*p->latency_reps < 1024 &&*/ p->tr)
- {
- if (g_proc_loc == LEFT_PROCESS)
- {
- sprintf(str, "%d <-> %d ", p->iproc, p->nbor);
- }
- else
- {
- sprintf(str, " %d <-> %d", p->iproc, p->nbor);
- }
- /*printf("To determine %s latency, using %d reps\n", p->iproc == 0 ? "0 -> 1 " : " 1 -> 2", p->latency_reps);*/
- printf("To determine %s latency, using %d reps.\n", str, p->latency_reps);
- fflush(stdout);
+ if (/*p->latency_reps < 1024 && */ p->tr) {
+ if (g_proc_loc == LEFT_PROCESS) {
+ sprintf(str, "%d <-> %d ", p->iproc, p->nbor);
+ }
+ else {
+ sprintf(str, " %d <-> %d", p->iproc, p->nbor);
+ }
+ /*printf("To determine %s latency, using %d reps\n", p->iproc == 0 ? "0 -> 1 " : " 1 -> 2", p->latency_reps); */
+ printf("To determine %s latency, using %d reps.\n", str, p->latency_reps);
+ fflush(stdout);
}
- for (j=0; j<TRIALS; j++)
- {
- Sync(p);
- t0 = MPI_Wtime();
- t0 = MPI_Wtime();
- t0 = MPI_Wtime();
- t0 = MPI_Wtime();
- for (i = 0; i < p->latency_reps; i++)
- {
- if (p->tr)
- {
- MPI_Send(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD);
- MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
- }
- else
- {
- MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
- MPI_Send(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD);
- }
- }
- latency = (MPI_Wtime() - t0)/(2 * p->latency_reps);
- min_latency = MIN(min_latency, latency);
+ for (j = 0; j < TRIALS; j++) {
+ Sync(p);
+ t0 = MPI_Wtime();
+ t0 = MPI_Wtime();
+ t0 = MPI_Wtime();
+ t0 = MPI_Wtime();
+ for (i = 0; i < p->latency_reps; i++) {
+ if (p->tr) {
+ MPI_Send(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD);
+ MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
+ }
+ else {
+ MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
+ MPI_Send(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD);
+ }
+ }
+ latency = (MPI_Wtime() - t0) / (2 * p->latency_reps);
+ min_latency = MIN(min_latency, latency);
}
return min_latency;
}
-double TestLatency012(ArgStruct *p)
+double TestLatency012(ArgStruct * p)
{
double latency, t0, min_latency = LONGTIME;
int i, j;
MPI_Status status;
g_latency012_reps = DetermineLatencyReps012(p);
- if (g_proc_loc == MIDDLE_PROCESS)
- {
- printf("To determine %d <-- %d --> %d latency, using %d reps\n", p->nbor, p->iproc, p->nbor2, g_latency012_reps);
- fflush(stdout);
+ if (g_proc_loc == MIDDLE_PROCESS) {
+ printf("To determine %d <-- %d --> %d latency, using %d reps\n", p->nbor, p->iproc,
+ p->nbor2, g_latency012_reps);
+ fflush(stdout);
}
- for (j=0; j<TRIALS; j++)
- {
- Sync012(p);
- t0 = MPI_Wtime();
- t0 = MPI_Wtime();
- t0 = MPI_Wtime();
- t0 = MPI_Wtime();
- for (i = 0; i < g_latency012_reps; i++)
- {
- switch (g_proc_loc)
- {
- case LEFT_PROCESS:
- MPI_Send(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD);
- MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
- break;
- case MIDDLE_PROCESS:
- MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
- MPI_Send(NULL, 0, MPI_BYTE, p->nbor2, 1, MPI_COMM_WORLD);
- MPI_Recv(NULL, 0, MPI_BYTE, p->nbor2, 1, MPI_COMM_WORLD, &status);
- MPI_Send(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD);
- break;
- case RIGHT_PROCESS:
- MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
- MPI_Send(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD);
- break;
- }
- }
- latency = (MPI_Wtime() - t0)/(2 * g_latency012_reps);
- min_latency = MIN(min_latency, latency);
+ for (j = 0; j < TRIALS; j++) {
+ Sync012(p);
+ t0 = MPI_Wtime();
+ t0 = MPI_Wtime();
+ t0 = MPI_Wtime();
+ t0 = MPI_Wtime();
+ for (i = 0; i < g_latency012_reps; i++) {
+ switch (g_proc_loc) {
+ case LEFT_PROCESS:
+ MPI_Send(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD);
+ MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
+ break;
+ case MIDDLE_PROCESS:
+ MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
+ MPI_Send(NULL, 0, MPI_BYTE, p->nbor2, 1, MPI_COMM_WORLD);
+ MPI_Recv(NULL, 0, MPI_BYTE, p->nbor2, 1, MPI_COMM_WORLD, &status);
+ MPI_Send(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD);
+ break;
+ case RIGHT_PROCESS:
+ MPI_Recv(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD, &status);
+ MPI_Send(NULL, 0, MPI_BYTE, p->nbor, 1, MPI_COMM_WORLD);
+ break;
+ }
+ }
+ latency = (MPI_Wtime() - t0) / (2 * g_latency012_reps);
+ min_latency = MIN(min_latency, latency);
}
return min_latency;
}
-void SendTime(ArgStruct *p, double *t)
+void SendTime(ArgStruct * p, double *t)
{
MPI_Send(t, 1, MPI_DOUBLE, p->nbor, 2, MPI_COMM_WORLD);
}
-void RecvTime(ArgStruct *p, double *t)
+void RecvTime(ArgStruct * p, double *t)
{
MPI_Status status;
MPI_Recv(t, 1, MPI_DOUBLE, p->nbor, 2, MPI_COMM_WORLD, &status);
}
-void SendReps(ArgStruct *p, int *rpt)
+void SendReps(ArgStruct * p, int *rpt)
{
MPI_Send(rpt, 1, MPI_INT, p->nbor, 2, MPI_COMM_WORLD);
}
-void RecvReps(ArgStruct *p, int *rpt)
+void RecvReps(ArgStruct * p, int *rpt)
{
MPI_Status status;
MPI_Recv(rpt, 1, MPI_INT, p->nbor, 2, MPI_COMM_WORLD, &status);
diff --git a/test/mpi/basic/netmpi.c b/test/mpi/basic/netmpi.c
index 3767c5d..33a7608 100644
--- a/test/mpi/basic/netmpi.c
+++ b/test/mpi/basic/netmpi.c
@@ -26,15 +26,15 @@ typedef int BOOL;
#define TRIALS 3
#define REPEAT 1000
-int g_NSAMP = 250;
+int g_NSAMP = 250;
#define PERT 3
/*#define LATENCYREPS 1000*/
-int g_LATENCYREPS = 1000;
+int g_LATENCYREPS = 1000;
#define LONGTIME 1e99
#define CHARSIZE 8
#define PATIENCE 50
#define RUNTM 0.25
-double g_STOPTM = 0.1;
+double g_STOPTM = 0.1;
#define MAXINT 2147483647
#define ABS(x) (((x) < 0)?(-(x)):(x))
@@ -44,50 +44,47 @@ double g_STOPTM = 0.1;
int g_nIproc = 0, g_nNproc = 0;
typedef struct protocolstruct ProtocolStruct;
-struct protocolstruct
-{
+struct protocolstruct {
int nbor, iproc;
};
typedef struct argstruct ArgStruct;
-struct argstruct
-{
- /* This is the common information that is needed for all tests */
- char *host; /* Name of receiving host */
- char *buff; /* Transmitted buffer */
- char *buff1; /* Transmitted buffer */
- int bufflen, /* Length of transmitted buffer */
- tr, /* Transmit flag */
- nbuff; /* Number of buffers to transmit */
-
+struct argstruct {
+ /* This is the common information that is needed for all tests */
+ char *host; /* Name of receiving host */
+ char *buff; /* Transmitted buffer */
+ char *buff1; /* Transmitted buffer */
+ int bufflen, /* Length of transmitted buffer */
+ tr, /* Transmit flag */
+ nbuff; /* Number of buffers to transmit */
+
/* Now we work with a union of information for protocol dependent stuff */
- ProtocolStruct prot; /* Structure holding necessary info for TCP */
+ ProtocolStruct prot; /* Structure holding necessary info for TCP */
};
typedef struct data Data;
-struct data
-{
+struct data {
double t;
double bps;
double variance;
- int bits;
- int repeat;
+ int bits;
+ int repeat;
};
double When(void);
-int Setup(ArgStruct *p);
-void Sync(ArgStruct *p);
-void SendData(ArgStruct *p);
-void RecvData(ArgStruct *p);
-void SendRecvData(ArgStruct *p);
-void SendTime(ArgStruct *p, double *t, int *rpt);
-void RecvTime(ArgStruct *p, double *t, int *rpt);
-int Establish(ArgStruct *p);
-int CleanUp(ArgStruct *p);
-double TestLatency(ArgStruct *p);
-double TestSyncTime(ArgStruct *p);
+int Setup(ArgStruct * p);
+void Sync(ArgStruct * p);
+void SendData(ArgStruct * p);
+void RecvData(ArgStruct * p);
+void SendRecvData(ArgStruct * p);
+void SendTime(ArgStruct * p, double *t, int *rpt);
+void RecvTime(ArgStruct * p, double *t, int *rpt);
+int Establish(ArgStruct * p);
+int CleanUp(ArgStruct * p);
+double TestLatency(ArgStruct * p);
+double TestSyncTime(ArgStruct * p);
void PrintOptions(void);
-int DetermineLatencyReps(ArgStruct *p);
+int DetermineLatencyReps(ArgStruct * p);
void PrintOptions()
{
@@ -110,415 +107,367 @@ void PrintOptions()
int main(int argc, char *argv[])
{
- FILE *out=0; /* Output data file */
- char s[255]; /* Generic string */
+ FILE *out = 0; /* Output data file */
+ char s[255]; /* Generic string */
char *memtmp;
char *memtmp1;
-
- int i, j, n, nq, /* Loop indices */
- bufoffset = 0, /* Align buffer to this */
- bufalign = 16*1024, /* Boundary to align buffer to */
- nrepeat, /* Number of time to do the transmission*/
- nzero = 0,
- len, /* Number of bytes to be transmitted */
- inc = 1, /* Increment value */
- detailflag = 0, /* Set to examine the signature curve detail*/
- pert, /* Perturbation value */
- ipert, /* index of the perturbation loop */
- start = 0, /* Starting value for signature curve */
- end = MAXINT, /* Ending value for signature curve */
- streamopt = 0, /* Streaming mode flag */
- printopt = 1; /* Debug print statements flag */
+
+ int i, j, n, nq, /* Loop indices */
+ bufoffset = 0, /* Align buffer to this */
+ bufalign = 16 * 1024, /* Boundary to align buffer to */
+ nrepeat, /* Number of time to do the transmission */
+ nzero = 0, len, /* Number of bytes to be transmitted */
+ inc = 1, /* Increment value */
+ detailflag = 0, /* Set to examine the signature curve detail */
+ pert, /* Perturbation value */
+ ipert, /* index of the perturbation loop */
+ start = 0, /* Starting value for signature curve */
+ end = MAXINT, /* Ending value for signature curve */
+ streamopt = 0, /* Streaming mode flag */
+ printopt = 1; /* Debug print statements flag */
int one_buffer = 0;
- int onebuffersize = 100*1024*1024;
+ int onebuffersize = 100 * 1024 * 1024;
int quit = 0;
-
- ArgStruct args; /* Argumentsfor all the calls */
-
- double t, t0, t1, t2, /* Time variables */
- tlast, /* Time for the last transmission */
- tzero = 0,
- latency, /* Network message latency */
- synctime; /* Network synchronization time */
-
- Data *bwdata; /* Bandwidth curve data */
-
+
+ ArgStruct args; /* Argumentsfor all the calls */
+
+ double t, t0, t1, t2, /* Time variables */
+ tlast, /* Time for the last transmission */
+ tzero = 0, latency, /* Network message latency */
+ synctime; /* Network synchronization time */
+
+ Data *bwdata; /* Bandwidth curve data */
+
BOOL bNoCache = FALSE;
BOOL bHeadToHead = FALSE;
BOOL bSavePert = FALSE;
BOOL bUseMegaBytes = FALSE;
MPI_Init(&argc, &argv);
-
+
MPI_Comm_size(MPI_COMM_WORLD, &g_nNproc);
MPI_Comm_rank(MPI_COMM_WORLD, &g_nIproc);
-
- if (g_nNproc != 2)
- {
- if (g_nIproc == 0)
- PrintOptions();
- MPI_Finalize();
- exit(0);
+
+ if (g_nNproc != 2) {
+ if (g_nIproc == 0)
+ PrintOptions();
+ MPI_Finalize();
+ exit(0);
}
-
+
GetOptDouble(&argc, &argv, "-time", &g_STOPTM);
GetOptInt(&argc, &argv, "-reps", &g_NSAMP);
GetOptInt(&argc, &argv, "-start", &start);
GetOptInt(&argc, &argv, "-end", &end);
one_buffer = GetOptInt(&argc, &argv, "-onebuffer", &onebuffersize);
- if (one_buffer)
- {
- if (onebuffersize < 1)
- {
- one_buffer = 0;
- }
- else
- {
- onebuffersize += bufalign;
- }
+ if (one_buffer) {
+ if (onebuffersize < 1) {
+ one_buffer = 0;
+ }
+ else {
+ onebuffersize += bufalign;
+ }
}
bNoCache = GetOpt(&argc, &argv, "-nocache");
bHeadToHead = GetOpt(&argc, &argv, "-headtohead");
bUseMegaBytes = GetOpt(&argc, &argv, "-mb");
if (GetOpt(&argc, &argv, "-noprint"))
- printopt = 0;
+ printopt = 0;
bSavePert = GetOpt(&argc, &argv, "-pert");
-
- bwdata = malloc((g_NSAMP+1) * sizeof(Data));
+
+ bwdata = malloc((g_NSAMP + 1) * sizeof(Data));
if (g_nIproc == 0)
- strcpy(s, "Netpipe.out");
+ strcpy(s, "Netpipe.out");
GetOptString(&argc, &argv, "-out", s);
-
- if (start > end)
- {
- fprintf(stdout, "Start MUST be LESS than end\n");
- exit(420132);
+
+ if (start > end) {
+ fprintf(stdout, "Start MUST be LESS than end\n");
+ exit(420132);
}
-
+
args.nbuff = TRIALS;
-
+
Setup(&args);
Establish(&args);
-
- if (args.tr)
- {
- if ((out = fopen(s, "w")) == NULL)
- {
- fprintf(stdout,"Can't open %s for output\n", s);
- exit(1);
- }
+
+ if (args.tr) {
+ if ((out = fopen(s, "w")) == NULL) {
+ fprintf(stdout, "Can't open %s for output\n", s);
+ exit(1);
+ }
}
-
+
latency = TestLatency(&args);
synctime = TestSyncTime(&args);
-
-
- if (args.tr)
- {
- SendTime(&args, &latency, &nzero);
+
+
+ if (args.tr) {
+ SendTime(&args, &latency, &nzero);
}
- else
- {
- RecvTime(&args, &latency, &nzero);
+ else {
+ RecvTime(&args, &latency, &nzero);
}
- if (args.tr && printopt)
- {
- printf("Latency: %0.9f\n", latency);
- fflush(stdout);
- printf("Sync Time: %0.9f\n", synctime);
- fflush(stdout);
- printf("Now starting main loop\n");
- fflush(stdout);
+ if (args.tr && printopt) {
+ printf("Latency: %0.9f\n", latency);
+ fflush(stdout);
+ printf("Sync Time: %0.9f\n", synctime);
+ fflush(stdout);
+ printf("Now starting main loop\n");
+ fflush(stdout);
}
tlast = latency;
- inc = (start > 1 && !detailflag) ? start/2: inc;
+ inc = (start > 1 && !detailflag) ? start / 2 : inc;
args.bufflen = start;
- if (one_buffer)
- {
- args.buff = (char *)malloc(onebuffersize);
- args.buff1 = (char*)malloc(onebuffersize);
+ if (one_buffer) {
+ args.buff = (char *) malloc(onebuffersize);
+ args.buff1 = (char *) malloc(onebuffersize);
}
/* Main loop of benchmark */
- for (nq = n = 0, len = start;
- n < g_NSAMP && tlast < g_STOPTM && len <= end && !quit;
- len = len + inc, nq++)
- {
- if (nq > 2 && !detailflag)
- inc = ((nq % 2))? inc + inc: inc;
-
- /* This is a perturbation loop to test nearby values */
- for (ipert = 0, pert = (!detailflag && inc > PERT + 1)? -PERT: 0;
- pert <= PERT && !quit;
- ipert++, n++,
- pert += (!detailflag && inc > PERT + 1)? PERT: PERT + 1)
- {
-
- /* Calculate howmany times to repeat the experiment. */
- if (args.tr)
- {
- if (args.bufflen == 0)
- nrepeat = g_LATENCYREPS;
- else
- nrepeat = (int)(MAX((RUNTM / ((double)args.bufflen /
- (args.bufflen - inc + 1.0) * tlast)), TRIALS));
- SendTime(&args, &tzero, &nrepeat);
- }
- else
- {
- nrepeat = 1; /* Just needs to be greater than zero */
- RecvTime(&args, &tzero, &nrepeat);
- }
-
- /* Allocate the buffer */
- args.bufflen = len + pert;
- if (one_buffer)
- {
- if (bNoCache)
- {
- if (args.bufflen * nrepeat + bufalign > onebuffersize)
- {
- fprintf(stdout, "Exceeded user specified buffer size\n");
- fflush(stdout);
- quit = 1;
- break;
- }
- }
- else
- {
- if (args.bufflen + bufalign > onebuffersize)
- {
- fprintf(stdout, "Exceeded user specified buffer size\n");
- fflush(stdout);
- quit = 1;
- break;
- }
- }
- }
- else
- {
- /* printf("allocating %d bytes\n",
- args.bufflen * nrepeat + bufalign); */
- if (bNoCache)
- {
- if ((args.buff = (char *)malloc(args.bufflen * nrepeat + bufalign)) == (char *)NULL)
- {
- fprintf(stdout,"Couldn't allocate memory\n");
- fflush(stdout);
- break;
- }
- }
- else
- {
- if ((args.buff = (char *)malloc(args.bufflen + bufalign)) == (char *)NULL)
- {
- fprintf(stdout,"Couldn't allocate memory\n");
- fflush(stdout);
- break;
- }
- }
- /* if ((args.buff1 = (char *)malloc(args.bufflen * nrepeat + bufalign)) == (char *)NULL) */
- if ((args.buff1 = (char *)malloc(args.bufflen + bufalign)) == (char *)NULL)
- {
- fprintf(stdout,"Couldn't allocate memory\n");
- fflush(stdout);
- break;
- }
- }
- /* Possibly align the data buffer */
- memtmp = args.buff;
- memtmp1 = args.buff1;
-
- if (!bNoCache)
- {
- if (bufalign != 0)
- {
- args.buff += (bufalign - ((MPI_Aint)args.buff % bufalign) + bufoffset) % bufalign;
- /* args.buff1 += (bufalign - ((MPI_Aint)args.buff1 % bufalign) + bufoffset) % bufalign; */
- }
- }
- args.buff1 += (bufalign - ((MPI_Aint)args.buff1 % bufalign) + bufoffset) % bufalign;
-
- if (args.tr && printopt)
- {
- fprintf(stdout,"%3d: %9d bytes %4d times --> ",
- n, args.bufflen, nrepeat);
- fflush(stdout);
- }
-
- /* Finally, we get to transmit or receive and time */
- if (args.tr)
- {
- bwdata[n].t = LONGTIME;
- t2 = t1 = 0;
- for (i = 0; i < TRIALS; i++)
- {
- if (bNoCache)
- {
- if (bufalign != 0)
- {
- args.buff = memtmp + ((bufalign - ((MPI_Aint)args.buff % bufalign) + bufoffset) % bufalign);
- /* args.buff1 = memtmp1 + ((bufalign - ((MPI_Aint)args.buff1 % bufalign) + bufoffset) % bufalign); */
- }
- else
- {
- args.buff = memtmp;
- /* args.buff1 = memtmp1; */
- }
- }
-
- Sync(&args);
- t0 = When();
- for (j = 0; j < nrepeat; j++)
- {
- if (bHeadToHead)
- SendRecvData(&args);
- else
- {
- SendData(&args);
- if (!streamopt)
- {
- RecvData(&args);
- }
- }
- if (bNoCache)
- {
- args.buff += args.bufflen;
- /* args.buff1 += args.bufflen; */
- }
- }
- t = (When() - t0)/((1 + !streamopt) * nrepeat);
-
- if (!streamopt)
- {
- t2 += t*t;
- t1 += t;
- bwdata[n].t = MIN(bwdata[n].t, t);
- }
- }
- if (!streamopt)
- SendTime(&args, &bwdata[n].t, &nzero);
- else
- RecvTime(&args, &bwdata[n].t, &nzero);
-
- if (!streamopt)
- bwdata[n].variance = t2/TRIALS - t1/TRIALS * t1/TRIALS;
-
- }
- else
- {
- bwdata[n].t = LONGTIME;
- t2 = t1 = 0;
- for (i = 0; i < TRIALS; i++)
- {
- if (bNoCache)
- {
- if (bufalign != 0)
- {
- args.buff = memtmp + ((bufalign - ((MPI_Aint)args.buff % bufalign) + bufoffset) % bufalign);
- /* args.buff1 = memtmp1 + ((bufalign - ((MPI_Aint)args.buff1 % bufalign) + bufoffset) % bufalign); */
- }
- else
- {
- args.buff = memtmp;
- /* args.buff1 = memtmp1; */
- }
- }
-
- Sync(&args);
- t0 = When();
- for (j = 0; j < nrepeat; j++)
- {
- if (bHeadToHead)
- SendRecvData(&args);
- else
- {
- RecvData(&args);
- if (!streamopt)
- SendData(&args);
- }
- if (bNoCache)
- {
- args.buff += args.bufflen;
- /* args.buff1 += args.bufflen; */
- }
- }
- t = (When() - t0)/((1 + !streamopt) * nrepeat);
-
- if (streamopt)
- {
- t2 += t*t;
- t1 += t;
- bwdata[n].t = MIN(bwdata[n].t, t);
- }
- }
- if (streamopt)
- SendTime(&args, &bwdata[n].t, &nzero);
- else
- RecvTime(&args, &bwdata[n].t, &nzero);
-
- if (streamopt)
- bwdata[n].variance = t2/TRIALS - t1/TRIALS * t1/TRIALS;
-
- }
- tlast = bwdata[n].t;
- bwdata[n].bits = args.bufflen * CHARSIZE;
- bwdata[n].bps = bwdata[n].bits / (bwdata[n].t * 1024 * 1024);
- bwdata[n].repeat = nrepeat;
-
- if (args.tr)
- {
- if (bSavePert)
- {
- /* fprintf(out,"%f\t%f\t%d\t%d\t%f\n", bwdata[n].t, bwdata[n].bps,
- bwdata[n].bits, bwdata[n].bits / 8, bwdata[n].variance); */
- if (bUseMegaBytes)
- fprintf(out,"%d\t%f\t%0.9f\n", bwdata[n].bits / 8, bwdata[n].bps / 8, bwdata[n].t);
- else
- fprintf(out,"%d\t%f\t%0.9f\n", bwdata[n].bits / 8, bwdata[n].bps, bwdata[n].t);
- fflush(out);
- }
- }
- if (!one_buffer)
- {
- free(memtmp);
- free(memtmp1);
- }
- if (args.tr && printopt)
- {
- if (bUseMegaBytes)
- fprintf(stdout," %6.2f MBps in %0.9f sec\n", bwdata[n].bps / 8, tlast);
- else
- fprintf(stdout," %6.2f Mbps in %0.9f sec\n", bwdata[n].bps, tlast);
- fflush(stdout);
- }
- } /* End of perturbation loop */
- if (!bSavePert && args.tr)
- {
- /* if we didn't save all of the perturbation loops, find the max and save it */
- int index = 1;
- double dmax = bwdata[n-1].bps;
- for (; ipert > 1; ipert--)
- {
- if (bwdata[n-ipert].bps > dmax)
- {
- index = ipert;
- dmax = bwdata[n-ipert].bps;
- }
- }
- if (bUseMegaBytes)
- fprintf(out,"%d\t%f\t%0.9f\n", bwdata[n-index].bits / 8, bwdata[n-index].bps / 8, bwdata[n-index].t);
- else
- fprintf(out,"%d\t%f\t%0.9f\n", bwdata[n-index].bits / 8, bwdata[n-index].bps, bwdata[n-index].t);
- fflush(out);
- }
- } /* End of main loop */
-
+ for (nq = n = 0, len = start;
+ n < g_NSAMP && tlast < g_STOPTM && len <= end && !quit; len = len + inc, nq++) {
+ if (nq > 2 && !detailflag)
+ inc = ((nq % 2)) ? inc + inc : inc;
+
+ /* This is a perturbation loop to test nearby values */
+ for (ipert = 0, pert = (!detailflag && inc > PERT + 1) ? -PERT : 0;
+ pert <= PERT && !quit;
+ ipert++, n++, pert += (!detailflag && inc > PERT + 1) ? PERT : PERT + 1) {
+
+ /* Calculate howmany times to repeat the experiment. */
+ if (args.tr) {
+ if (args.bufflen == 0)
+ nrepeat = g_LATENCYREPS;
+ else
+ nrepeat = (int) (MAX((RUNTM / ((double) args.bufflen /
+ (args.bufflen - inc + 1.0) * tlast)), TRIALS));
+ SendTime(&args, &tzero, &nrepeat);
+ }
+ else {
+ nrepeat = 1; /* Just needs to be greater than zero */
+ RecvTime(&args, &tzero, &nrepeat);
+ }
+
+ /* Allocate the buffer */
+ args.bufflen = len + pert;
+ if (one_buffer) {
+ if (bNoCache) {
+ if (args.bufflen * nrepeat + bufalign > onebuffersize) {
+ fprintf(stdout, "Exceeded user specified buffer size\n");
+ fflush(stdout);
+ quit = 1;
+ break;
+ }
+ }
+ else {
+ if (args.bufflen + bufalign > onebuffersize) {
+ fprintf(stdout, "Exceeded user specified buffer size\n");
+ fflush(stdout);
+ quit = 1;
+ break;
+ }
+ }
+ }
+ else {
+ /* printf("allocating %d bytes\n",
+ * args.bufflen * nrepeat + bufalign); */
+ if (bNoCache) {
+ if ((args.buff =
+ (char *) malloc(args.bufflen * nrepeat + bufalign)) == (char *) NULL) {
+ fprintf(stdout, "Couldn't allocate memory\n");
+ fflush(stdout);
+ break;
+ }
+ }
+ else {
+ if ((args.buff = (char *) malloc(args.bufflen + bufalign)) == (char *) NULL) {
+ fprintf(stdout, "Couldn't allocate memory\n");
+ fflush(stdout);
+ break;
+ }
+ }
+ /* if ((args.buff1 = (char *)malloc(args.bufflen * nrepeat + bufalign)) == (char *)NULL) */
+ if ((args.buff1 = (char *) malloc(args.bufflen + bufalign)) == (char *) NULL) {
+ fprintf(stdout, "Couldn't allocate memory\n");
+ fflush(stdout);
+ break;
+ }
+ }
+ /* Possibly align the data buffer */
+ memtmp = args.buff;
+ memtmp1 = args.buff1;
+
+ if (!bNoCache) {
+ if (bufalign != 0) {
+ args.buff +=
+ (bufalign - ((MPI_Aint) args.buff % bufalign) + bufoffset) % bufalign;
+ /* args.buff1 += (bufalign - ((MPI_Aint)args.buff1 % bufalign) + bufoffset) % bufalign; */
+ }
+ }
+ args.buff1 += (bufalign - ((MPI_Aint) args.buff1 % bufalign) + bufoffset) % bufalign;
+
+ if (args.tr && printopt) {
+ fprintf(stdout, "%3d: %9d bytes %4d times --> ", n, args.bufflen, nrepeat);
+ fflush(stdout);
+ }
+
+ /* Finally, we get to transmit or receive and time */
+ if (args.tr) {
+ bwdata[n].t = LONGTIME;
+ t2 = t1 = 0;
+ for (i = 0; i < TRIALS; i++) {
+ if (bNoCache) {
+ if (bufalign != 0) {
+ args.buff =
+ memtmp +
+ ((bufalign - ((MPI_Aint) args.buff % bufalign) +
+ bufoffset) % bufalign);
+ /* args.buff1 = memtmp1 + ((bufalign - ((MPI_Aint)args.buff1 % bufalign) + bufoffset) % bufalign); */
+ }
+ else {
+ args.buff = memtmp;
+ /* args.buff1 = memtmp1; */
+ }
+ }
+
+ Sync(&args);
+ t0 = When();
+ for (j = 0; j < nrepeat; j++) {
+ if (bHeadToHead)
+ SendRecvData(&args);
+ else {
+ SendData(&args);
+ if (!streamopt) {
+ RecvData(&args);
+ }
+ }
+ if (bNoCache) {
+ args.buff += args.bufflen;
+ /* args.buff1 += args.bufflen; */
+ }
+ }
+ t = (When() - t0) / ((1 + !streamopt) * nrepeat);
+
+ if (!streamopt) {
+ t2 += t * t;
+ t1 += t;
+ bwdata[n].t = MIN(bwdata[n].t, t);
+ }
+ }
+ if (!streamopt)
+ SendTime(&args, &bwdata[n].t, &nzero);
+ else
+ RecvTime(&args, &bwdata[n].t, &nzero);
+
+ if (!streamopt)
+ bwdata[n].variance = t2 / TRIALS - t1 / TRIALS * t1 / TRIALS;
+
+ }
+ else {
+ bwdata[n].t = LONGTIME;
+ t2 = t1 = 0;
+ for (i = 0; i < TRIALS; i++) {
+ if (bNoCache) {
+ if (bufalign != 0) {
+ args.buff =
+ memtmp +
+ ((bufalign - ((MPI_Aint) args.buff % bufalign) +
+ bufoffset) % bufalign);
+ /* args.buff1 = memtmp1 + ((bufalign - ((MPI_Aint)args.buff1 % bufalign) + bufoffset) % bufalign); */
+ }
+ else {
+ args.buff = memtmp;
+ /* args.buff1 = memtmp1; */
+ }
+ }
+
+ Sync(&args);
+ t0 = When();
+ for (j = 0; j < nrepeat; j++) {
+ if (bHeadToHead)
+ SendRecvData(&args);
+ else {
+ RecvData(&args);
+ if (!streamopt)
+ SendData(&args);
+ }
+ if (bNoCache) {
+ args.buff += args.bufflen;
+ /* args.buff1 += args.bufflen; */
+ }
+ }
+ t = (When() - t0) / ((1 + !streamopt) * nrepeat);
+
+ if (streamopt) {
+ t2 += t * t;
+ t1 += t;
+ bwdata[n].t = MIN(bwdata[n].t, t);
+ }
+ }
+ if (streamopt)
+ SendTime(&args, &bwdata[n].t, &nzero);
+ else
+ RecvTime(&args, &bwdata[n].t, &nzero);
+
+ if (streamopt)
+ bwdata[n].variance = t2 / TRIALS - t1 / TRIALS * t1 / TRIALS;
+
+ }
+ tlast = bwdata[n].t;
+ bwdata[n].bits = args.bufflen * CHARSIZE;
+ bwdata[n].bps = bwdata[n].bits / (bwdata[n].t * 1024 * 1024);
+ bwdata[n].repeat = nrepeat;
+
+ if (args.tr) {
+ if (bSavePert) {
+ /* fprintf(out,"%f\t%f\t%d\t%d\t%f\n", bwdata[n].t, bwdata[n].bps,
+ * bwdata[n].bits, bwdata[n].bits / 8, bwdata[n].variance); */
+ if (bUseMegaBytes)
+ fprintf(out, "%d\t%f\t%0.9f\n", bwdata[n].bits / 8, bwdata[n].bps / 8,
+ bwdata[n].t);
+ else
+ fprintf(out, "%d\t%f\t%0.9f\n", bwdata[n].bits / 8, bwdata[n].bps,
+ bwdata[n].t);
+ fflush(out);
+ }
+ }
+ if (!one_buffer) {
+ free(memtmp);
+ free(memtmp1);
+ }
+ if (args.tr && printopt) {
+ if (bUseMegaBytes)
+ fprintf(stdout, " %6.2f MBps in %0.9f sec\n", bwdata[n].bps / 8, tlast);
+ else
+ fprintf(stdout, " %6.2f Mbps in %0.9f sec\n", bwdata[n].bps, tlast);
+ fflush(stdout);
+ }
+ } /* End of perturbation loop */
+ if (!bSavePert && args.tr) {
+ /* if we didn't save all of the perturbation loops, find the max and save it */
+ int index = 1;
+ double dmax = bwdata[n - 1].bps;
+ for (; ipert > 1; ipert--) {
+ if (bwdata[n - ipert].bps > dmax) {
+ index = ipert;
+ dmax = bwdata[n - ipert].bps;
+ }
+ }
+ if (bUseMegaBytes)
+ fprintf(out, "%d\t%f\t%0.9f\n", bwdata[n - index].bits / 8,
+ bwdata[n - index].bps / 8, bwdata[n - index].t);
+ else
+ fprintf(out, "%d\t%f\t%0.9f\n", bwdata[n - index].bits / 8, bwdata[n - index].bps,
+ bwdata[n - index].t);
+ fflush(out);
+ }
+ } /* End of main loop */
+
if (args.tr)
- fclose(out);
- /* THE_END: */
+ fclose(out);
+ /* THE_END: */
CleanUp(&args);
free(bwdata);
return 0;
@@ -531,58 +480,55 @@ double When()
return MPI_Wtime();
}
-int Setup(ArgStruct *p)
+int Setup(ArgStruct * p)
{
int nproc;
char s[255];
int len = 255;
-
+
MPI_Comm_rank(MPI_COMM_WORLD, &p->prot.iproc);
MPI_Comm_size(MPI_COMM_WORLD, &nproc);
-
+
MPI_Get_processor_name(s, &len);
- /*gethostname(s, len);*/
+ /*gethostname(s, len); */
printf("%d: %s\n", p->prot.iproc, s);
fflush(stdout);
-
+
if (p->prot.iproc == 0)
- p->prot.nbor = 1;
+ p->prot.nbor = 1;
else
- p->prot.nbor = 0;
-
- if (nproc < 2)
- {
- printf("Need two processes\n");
- printf("nproc: %i\n", nproc);
- exit(-2);
+ p->prot.nbor = 0;
+
+ if (nproc < 2) {
+ printf("Need two processes\n");
+ printf("nproc: %i\n", nproc);
+ exit(-2);
}
-
+
if (p->prot.iproc == 0)
- p->tr = 1;
+ p->tr = 1;
else
- p->tr = 0;
- return 1;
-}
+ p->tr = 0;
+ return 1;
+}
-void Sync(ArgStruct *p)
+void Sync(ArgStruct * p)
{
char ch;
MPI_Status status;
- if (p->tr)
- {
- MPI_Send(&ch, 0, MPI_BYTE, p->prot.nbor, 1, MPI_COMM_WORLD);
- MPI_Recv(&ch, 0, MPI_BYTE, p->prot.nbor, 1, MPI_COMM_WORLD, &status);
- MPI_Send(&ch, 0, MPI_BYTE, p->prot.nbor, 1, MPI_COMM_WORLD);
+ if (p->tr) {
+ MPI_Send(&ch, 0, MPI_BYTE, p->prot.nbor, 1, MPI_COMM_WORLD);
+ MPI_Recv(&ch, 0, MPI_BYTE, p->prot.nbor, 1, MPI_COMM_WORLD, &status);
+ MPI_Send(&ch, 0, MPI_BYTE, p->prot.nbor, 1, MPI_COMM_WORLD);
}
- else
- {
- MPI_Recv(&ch, 0, MPI_BYTE, p->prot.nbor, 1, MPI_COMM_WORLD, &status);
- MPI_Send(&ch, 0, MPI_BYTE, p->prot.nbor, 1, MPI_COMM_WORLD);
- MPI_Recv(&ch, 0, MPI_BYTE, p->prot.nbor, 1, MPI_COMM_WORLD, &status);
+ else {
+ MPI_Recv(&ch, 0, MPI_BYTE, p->prot.nbor, 1, MPI_COMM_WORLD, &status);
+ MPI_Send(&ch, 0, MPI_BYTE, p->prot.nbor, 1, MPI_COMM_WORLD);
+ MPI_Recv(&ch, 0, MPI_BYTE, p->prot.nbor, 1, MPI_COMM_WORLD, &status);
}
}
-int DetermineLatencyReps(ArgStruct *p)
+int DetermineLatencyReps(ArgStruct * p)
{
MPI_Status status;
double t0, duration = 0;
@@ -594,77 +540,70 @@ int DetermineLatencyReps(ArgStruct *p)
Sync(p);
Sync(p);
- /* test how long it takes to send n messages
+ /* test how long it takes to send n messages
* where n = 1, 2, 4, 8, 16, 32, ...
*/
t0 = When();
t0 = When();
t0 = When();
- while ( (duration < 1) ||
- (duration < 3 && reps < 1000))
- {
- t0 = When();
- for (i=0; i<reps-prev_reps; i++)
- {
- Sync(p);
- }
- duration += When() - t0;
- prev_reps = reps;
- reps = reps * 2;
-
- /* use duration from the root only */
- if (p->prot.iproc == 0)
- MPI_Send(&duration, 1, MPI_DOUBLE, p->prot.nbor, 2, MPI_COMM_WORLD);
- else
- MPI_Recv(&duration, 1, MPI_DOUBLE, p->prot.nbor, 2, MPI_COMM_WORLD, &status);
+ while ((duration < 1) || (duration < 3 && reps < 1000)) {
+ t0 = When();
+ for (i = 0; i < reps - prev_reps; i++) {
+ Sync(p);
+ }
+ duration += When() - t0;
+ prev_reps = reps;
+ reps = reps * 2;
+
+ /* use duration from the root only */
+ if (p->prot.iproc == 0)
+ MPI_Send(&duration, 1, MPI_DOUBLE, p->prot.nbor, 2, MPI_COMM_WORLD);
+ else
+ MPI_Recv(&duration, 1, MPI_DOUBLE, p->prot.nbor, 2, MPI_COMM_WORLD, &status);
}
return reps;
}
-double TestLatency(ArgStruct *p)
+double TestLatency(ArgStruct * p)
{
double latency, t0;
int i;
g_LATENCYREPS = DetermineLatencyReps(p);
- if (g_LATENCYREPS < 1024 && p->prot.iproc == 0)
- {
- printf("Using %d reps to determine latency\n", g_LATENCYREPS);
- fflush(stdout);
+ if (g_LATENCYREPS < 1024 && p->prot.iproc == 0) {
+ printf("Using %d reps to determine latency\n", g_LATENCYREPS);
+ fflush(stdout);
}
p->bufflen = 0;
- p->buff = NULL; /*(char *)malloc(p->bufflen);*/
- p->buff1 = NULL; /*(char *)malloc(p->bufflen);*/
+ p->buff = NULL; /*(char *)malloc(p->bufflen); */
+ p->buff1 = NULL; /*(char *)malloc(p->bufflen); */
Sync(p);
t0 = When();
t0 = When();
t0 = When();
t0 = When();
- for (i = 0; i < g_LATENCYREPS; i++)
- {
- if (p->tr)
- {
- SendData(p);
- RecvData(p);
- }
- else
- {
- RecvData(p);
- SendData(p);
- }
+ for (i = 0; i < g_LATENCYREPS; i++) {
+ if (p->tr) {
+ SendData(p);
+ RecvData(p);
+ }
+ else {
+ RecvData(p);
+ SendData(p);
+ }
}
- latency = (When() - t0)/(2 * g_LATENCYREPS);
+ latency = (When() - t0) / (2 * g_LATENCYREPS);
/*
- free(p->buff);
- free(p->buff1);
- */
+ * free(p->buff);
+ * free(p->buff1);
+ */
return latency;
}
-double TestSyncTime(ArgStruct *p)
+double TestSyncTime(ArgStruct * p)
{
double synctime, t0;
int i;
@@ -676,17 +615,17 @@ double TestSyncTime(ArgStruct *p)
t0 = When();
t0 = When();
for (i = 0; i < g_LATENCYREPS; i++)
- Sync(p);
- synctime = (When() - t0)/g_LATENCYREPS;
+ Sync(p);
+ synctime = (When() - t0) / g_LATENCYREPS;
return synctime;
}
-void SendRecvData(ArgStruct *p)
+void SendRecvData(ArgStruct * p)
{
MPI_Status status;
-
- /*MPI_Sendrecv(p->buff, p->bufflen, MPI_BYTE, p->prot.nbor, 1, p->buff1, p->bufflen, MPI_BYTE, p->prot.nbor, 1, MPI_COMM_WORLD, &status);*/
+
+ /*MPI_Sendrecv(p->buff, p->bufflen, MPI_BYTE, p->prot.nbor, 1, p->buff1, p->bufflen, MPI_BYTE, p->prot.nbor, 1, MPI_COMM_WORLD, &status); */
MPI_Request request;
MPI_Irecv(p->buff1, p->bufflen, MPI_BYTE, p->prot.nbor, 1, MPI_COMM_WORLD, &request);
@@ -694,49 +633,48 @@ void SendRecvData(ArgStruct *p)
MPI_Wait(&request, &status);
/*
- MPI_Send(p->buff, p->bufflen, MPI_BYTE, p->prot.nbor, 1, MPI_COMM_WORLD);
- MPI_Recv(p->buff1, p->bufflen, MPI_BYTE, p->prot.nbor, 1, MPI_COMM_WORLD, &status);
- */
+ * MPI_Send(p->buff, p->bufflen, MPI_BYTE, p->prot.nbor, 1, MPI_COMM_WORLD);
+ * MPI_Recv(p->buff1, p->bufflen, MPI_BYTE, p->prot.nbor, 1, MPI_COMM_WORLD, &status);
+ */
}
-void SendData(ArgStruct *p)
+void SendData(ArgStruct * p)
{
MPI_Send(p->buff, p->bufflen, MPI_BYTE, p->prot.nbor, 1, MPI_COMM_WORLD);
}
-void RecvData(ArgStruct *p)
+void RecvData(ArgStruct * p)
{
MPI_Status status;
MPI_Recv(p->buff1, p->bufflen, MPI_BYTE, p->prot.nbor, 1, MPI_COMM_WORLD, &status);
}
-void SendTime(ArgStruct *p, double *t, int *rpt)
+void SendTime(ArgStruct * p, double *t, int *rpt)
{
if (*rpt > 0)
- MPI_Send(rpt, 1, MPI_INT, p->prot.nbor, 2, MPI_COMM_WORLD);
+ MPI_Send(rpt, 1, MPI_INT, p->prot.nbor, 2, MPI_COMM_WORLD);
else
- MPI_Send(t, 1, MPI_DOUBLE, p->prot.nbor, 2, MPI_COMM_WORLD);
+ MPI_Send(t, 1, MPI_DOUBLE, p->prot.nbor, 2, MPI_COMM_WORLD);
}
-void RecvTime(ArgStruct *p, double *t, int *rpt)
+void RecvTime(ArgStruct * p, double *t, int *rpt)
{
MPI_Status status;
if (*rpt > 0)
- MPI_Recv(rpt, 1, MPI_INT, p->prot.nbor, 2, MPI_COMM_WORLD, &status);
+ MPI_Recv(rpt, 1, MPI_INT, p->prot.nbor, 2, MPI_COMM_WORLD, &status);
else
- MPI_Recv(t, 1, MPI_DOUBLE, p->prot.nbor, 2, MPI_COMM_WORLD, &status);
+ MPI_Recv(t, 1, MPI_DOUBLE, p->prot.nbor, 2, MPI_COMM_WORLD, &status);
}
-int Establish(ArgStruct *p)
+int Establish(ArgStruct * p)
{
return 1;
}
-int CleanUp(ArgStruct *p)
+int CleanUp(ArgStruct * p)
{
- /*MPI_Barrier(MPI_COMM_WORLD);*/
+ /*MPI_Barrier(MPI_COMM_WORLD); */
MPI_Finalize();
return 1;
}
-
diff --git a/test/mpi/basic/patterns.c b/test/mpi/basic/patterns.c
index c9c8d3d..3bfafad 100644
--- a/test/mpi/basic/patterns.c
+++ b/test/mpi/basic/patterns.c
@@ -20,10 +20,10 @@
/* Prototypes */
int SendRecvTest(int, int);
int IsendIrecvTest(int);
-int IsenIrecvTest2(int,int);
-int OutOfOrderTest(int,int);
-int ForceUnexpectedTest(int,int);
-int RndvTest(int,int,int);
+int IsenIrecvTest2(int, int);
+int OutOfOrderTest(int, int);
+int ForceUnexpectedTest(int, int);
+int RndvTest(int, int, int);
int SendRecvTest(int rank, int n)
{
@@ -32,17 +32,15 @@ int SendRecvTest(int rank, int n)
char buffer[100];
int i;
- if (rank == 0)
- {
- strcpy(buffer, "Hello process one.");
- for (i=0; i<n; i++)
- MPI_Send(buffer, 100, MPI_BYTE, 1, tag, MPI_COMM_WORLD);
+ if (rank == 0) {
+ strcpy(buffer, "Hello process one.");
+ for (i = 0; i < n; i++)
+ MPI_Send(buffer, 100, MPI_BYTE, 1, tag, MPI_COMM_WORLD);
}
- else if (rank == 1)
- {
- for (i=0; i<n; i++)
- MPI_Recv(buffer, 100, MPI_BYTE, 0, tag, MPI_COMM_WORLD, &status);
- /*printf("Rank 1: received message '%s'\n", buffer);fflush(stdout);*/
+ else if (rank == 1) {
+ for (i = 0; i < n; i++)
+ MPI_Recv(buffer, 100, MPI_BYTE, 0, tag, MPI_COMM_WORLD, &status);
+ /*printf("Rank 1: received message '%s'\n", buffer);fflush(stdout); */
}
return TRUE;
@@ -55,17 +53,15 @@ int IsendIrecvTest(int rank)
MPI_Request request;
char buffer[100];
- if (rank == 0)
- {
- strcpy(buffer, "Hello process one.");
- MPI_Isend(buffer, 100, MPI_BYTE, 1, tag, MPI_COMM_WORLD, &request);
- MPI_Wait(&request, &status);
+ if (rank == 0) {
+ strcpy(buffer, "Hello process one.");
+ MPI_Isend(buffer, 100, MPI_BYTE, 1, tag, MPI_COMM_WORLD, &request);
+ MPI_Wait(&request, &status);
}
- else if (rank == 1)
- {
- MPI_Irecv(buffer, 100, MPI_BYTE, 0, tag, MPI_COMM_WORLD, &request);
- MPI_Wait(&request, &status);
- /*printf("Rank 1: received message '%s'\n", buffer);fflush(stdout);*/
+ else if (rank == 1) {
+ MPI_Irecv(buffer, 100, MPI_BYTE, 0, tag, MPI_COMM_WORLD, &request);
+ MPI_Wait(&request, &status);
+ /*printf("Rank 1: received message '%s'\n", buffer);fflush(stdout); */
}
return TRUE;
@@ -80,24 +76,22 @@ int IsendIrecvTest2(int rank, int buf_size)
MPI_Request request1, request2;
char *buffer;
- buffer = (char*)malloc(buf_size);
+ buffer = (char *) malloc(buf_size);
if (buffer == NULL)
- return FALSE;
- if (rank == 0)
- {
- strcpy(buffer, "Hello process one.");
- MPI_Isend(buffer, buf_size, MPI_BYTE, 1, tag1, MPI_COMM_WORLD, &request1);
- MPI_Isend(buffer, buf_size, MPI_BYTE, 1, tag2, MPI_COMM_WORLD, &request2);
- MPI_Wait(&request1, &status);
- MPI_Wait(&request2, &status);
+ return FALSE;
+ if (rank == 0) {
+ strcpy(buffer, "Hello process one.");
+ MPI_Isend(buffer, buf_size, MPI_BYTE, 1, tag1, MPI_COMM_WORLD, &request1);
+ MPI_Isend(buffer, buf_size, MPI_BYTE, 1, tag2, MPI_COMM_WORLD, &request2);
+ MPI_Wait(&request1, &status);
+ MPI_Wait(&request2, &status);
}
- else if (rank == 1)
- {
- MPI_Irecv(buffer, buf_size, MPI_BYTE, 0, tag1, MPI_COMM_WORLD, &request1);
- MPI_Irecv(buffer, buf_size, MPI_BYTE, 0, tag2, MPI_COMM_WORLD, &request2);
- MPI_Wait(&request1, &status);
- MPI_Wait(&request2, &status);
- /*printf("Rank 1: received message '%s'\n", buffer);fflush(stdout);*/
+ else if (rank == 1) {
+ MPI_Irecv(buffer, buf_size, MPI_BYTE, 0, tag1, MPI_COMM_WORLD, &request1);
+ MPI_Irecv(buffer, buf_size, MPI_BYTE, 0, tag2, MPI_COMM_WORLD, &request2);
+ MPI_Wait(&request1, &status);
+ MPI_Wait(&request2, &status);
+ /*printf("Rank 1: received message '%s'\n", buffer);fflush(stdout); */
}
free(buffer);
@@ -112,24 +106,22 @@ int OutOfOrderTest(int rank, int buf_size)
MPI_Request request1, request2;
char *buffer;
- buffer = (char*)malloc(buf_size);
+ buffer = (char *) malloc(buf_size);
if (buffer == NULL)
- return FALSE;
- if (rank == 0)
- {
- strcpy(buffer, "Hello process one.");
- MPI_Isend(buffer, buf_size, MPI_BYTE, 1, tag1, MPI_COMM_WORLD, &request1);
- MPI_Isend(buffer, buf_size, MPI_BYTE, 1, tag2, MPI_COMM_WORLD, &request2);
- MPI_Wait(&request1, &status);
- MPI_Wait(&request2, &status);
+ return FALSE;
+ if (rank == 0) {
+ strcpy(buffer, "Hello process one.");
+ MPI_Isend(buffer, buf_size, MPI_BYTE, 1, tag1, MPI_COMM_WORLD, &request1);
+ MPI_Isend(buffer, buf_size, MPI_BYTE, 1, tag2, MPI_COMM_WORLD, &request2);
+ MPI_Wait(&request1, &status);
+ MPI_Wait(&request2, &status);
}
- else if (rank == 1)
- {
- MPI_Irecv(buffer, buf_size, MPI_BYTE, 0, tag2, MPI_COMM_WORLD, &request1);
- MPI_Irecv(buffer, buf_size, MPI_BYTE, 0, tag1, MPI_COMM_WORLD, &request2);
- MPI_Wait(&request2, &status);
- MPI_Wait(&request1, &status);
- /*printf("Rank 1: received message '%s'\n", buffer);fflush(stdout);*/
+ else if (rank == 1) {
+ MPI_Irecv(buffer, buf_size, MPI_BYTE, 0, tag2, MPI_COMM_WORLD, &request1);
+ MPI_Irecv(buffer, buf_size, MPI_BYTE, 0, tag1, MPI_COMM_WORLD, &request2);
+ MPI_Wait(&request2, &status);
+ MPI_Wait(&request1, &status);
+ /*printf("Rank 1: received message '%s'\n", buffer);fflush(stdout); */
}
free(buffer);
@@ -144,27 +136,25 @@ int ForceUnexpectedTest(int rank, int buf_size)
MPI_Request request1, request2;
char *buffer;
- buffer = (char*)malloc(buf_size);
+ buffer = (char *) malloc(buf_size);
if (buffer == NULL)
- return FALSE;
-
- if (rank == 0)
- {
- strcpy(buffer, "Hello process one.");
- MPI_Isend(buffer, buf_size, MPI_BYTE, 1, tag1, MPI_COMM_WORLD, &request1);
- MPI_Isend(buffer, buf_size, MPI_BYTE, 1, tag2, MPI_COMM_WORLD, &request2);
- MPI_Wait(&request1, &status);
- MPI_Wait(&request2, &status);
- MPI_Recv(buffer, buf_size, MPI_BYTE, 1, tag1, MPI_COMM_WORLD, &status);
+ return FALSE;
+
+ if (rank == 0) {
+ strcpy(buffer, "Hello process one.");
+ MPI_Isend(buffer, buf_size, MPI_BYTE, 1, tag1, MPI_COMM_WORLD, &request1);
+ MPI_Isend(buffer, buf_size, MPI_BYTE, 1, tag2, MPI_COMM_WORLD, &request2);
+ MPI_Wait(&request1, &status);
+ MPI_Wait(&request2, &status);
+ MPI_Recv(buffer, buf_size, MPI_BYTE, 1, tag1, MPI_COMM_WORLD, &status);
}
- else if (rank == 1)
- {
- MPI_Irecv(buffer, buf_size, MPI_BYTE, 0, tag2, MPI_COMM_WORLD, &request2);
- MPI_Wait(&request2, &status);
- MPI_Irecv(buffer, buf_size, MPI_BYTE, 0, tag1, MPI_COMM_WORLD, &request1);
- MPI_Wait(&request1, &status);
- /*printf("Rank 1: received message '%s'\n", buffer);fflush(stdout);*/
- MPI_Send(buffer, buf_size, MPI_BYTE, 0, tag1, MPI_COMM_WORLD);
+ else if (rank == 1) {
+ MPI_Irecv(buffer, buf_size, MPI_BYTE, 0, tag2, MPI_COMM_WORLD, &request2);
+ MPI_Wait(&request2, &status);
+ MPI_Irecv(buffer, buf_size, MPI_BYTE, 0, tag1, MPI_COMM_WORLD, &request1);
+ MPI_Wait(&request1, &status);
+ /*printf("Rank 1: received message '%s'\n", buffer);fflush(stdout); */
+ MPI_Send(buffer, buf_size, MPI_BYTE, 0, tag1, MPI_COMM_WORLD);
}
free(buffer);
@@ -179,57 +169,46 @@ int RndvTest(int rank, int size, int reps)
char *buffer;
int i;
- buffer = (char*)malloc(size);
- if (buffer == NULL)
- {
- printf("malloc failed to allocate %d bytes.\n", size);
- exit(0);
+ buffer = (char *) malloc(size);
+ if (buffer == NULL) {
+ printf("malloc failed to allocate %d bytes.\n", size);
+ exit(0);
}
- if (rank == 0)
- {
- for (i=0; i<reps; i++)
- {
- if (reps == 1)
- {
- printf("0: sending to process 1\n");
- fflush(stdout);
- }
- MPI_Send(buffer, size, MPI_BYTE, 1, tag, MPI_COMM_WORLD);
- if (reps == 1)
- {
- printf("0: receiving from process 1\n");
- fflush(stdout);
- }
- MPI_Recv(buffer, size, MPI_BYTE, 1, tag, MPI_COMM_WORLD, &status);
- if (reps == 1)
- {
- printf("0: done\n");
- fflush(stdout);
- }
- }
+ if (rank == 0) {
+ for (i = 0; i < reps; i++) {
+ if (reps == 1) {
+ printf("0: sending to process 1\n");
+ fflush(stdout);
+ }
+ MPI_Send(buffer, size, MPI_BYTE, 1, tag, MPI_COMM_WORLD);
+ if (reps == 1) {
+ printf("0: receiving from process 1\n");
+ fflush(stdout);
+ }
+ MPI_Recv(buffer, size, MPI_BYTE, 1, tag, MPI_COMM_WORLD, &status);
+ if (reps == 1) {
+ printf("0: done\n");
+ fflush(stdout);
+ }
+ }
}
- else if (rank == 1)
- {
- for (i=0; i<reps; i++)
- {
- if (reps == 1)
- {
- printf("1: receiving from process 0\n");
- fflush(stdout);
- }
- MPI_Recv(buffer, size, MPI_BYTE, 0, tag, MPI_COMM_WORLD, &status);
- if (reps == 1)
- {
- printf("1: sending to process 0\n");
- fflush(stdout);
- }
- MPI_Send(buffer, size, MPI_BYTE, 0, tag, MPI_COMM_WORLD);
- if (reps == 1)
- {
- printf("1: done\n");
- fflush(stdout);
- }
- }
+ else if (rank == 1) {
+ for (i = 0; i < reps; i++) {
+ if (reps == 1) {
+ printf("1: receiving from process 0\n");
+ fflush(stdout);
+ }
+ MPI_Recv(buffer, size, MPI_BYTE, 0, tag, MPI_COMM_WORLD, &status);
+ if (reps == 1) {
+ printf("1: sending to process 0\n");
+ fflush(stdout);
+ }
+ MPI_Send(buffer, size, MPI_BYTE, 0, tag, MPI_COMM_WORLD);
+ if (reps == 1) {
+ printf("1: done\n");
+ fflush(stdout);
+ }
+ }
}
free(buffer);
@@ -248,192 +227,162 @@ int main(int argc, char *argv[])
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- if (size < 2)
- {
- printf("Two processes needed.\n");
- printf("options:\n");
- printf(" sr [reps] ............... send/recv\n");
- printf(" isr ..................... isend/irecv\n");
- printf(" iisr .................... isend,isend/irecv,irecv wait\n");
- printf(" oo ...................... out of order isend/irecv\n");
- printf(" unex .................... force unexpected msg\n");
- printf(" rndv [size] ............. rndv\n");
- printf(" rndv_reps [reps] [size] . rndv\n");
- printf(" rndv_iisr [size] ........ rndv iisr\n");
- printf(" rndv_oo [size] .......... rndv oo\n");
- printf(" rndv_unex [size] ........ rndv unex\n");
- printf("default rndv size = %d bytes\n", DEFAULT_RNDV_SIZE);
- MPI_Finalize();
- return 0;
+ if (size < 2) {
+ printf("Two processes needed.\n");
+ printf("options:\n");
+ printf(" sr [reps] ............... send/recv\n");
+ printf(" isr ..................... isend/irecv\n");
+ printf(" iisr .................... isend,isend/irecv,irecv wait\n");
+ printf(" oo ...................... out of order isend/irecv\n");
+ printf(" unex .................... force unexpected msg\n");
+ printf(" rndv [size] ............. rndv\n");
+ printf(" rndv_reps [reps] [size] . rndv\n");
+ printf(" rndv_iisr [size] ........ rndv iisr\n");
+ printf(" rndv_oo [size] .......... rndv oo\n");
+ printf(" rndv_unex [size] ........ rndv unex\n");
+ printf("default rndv size = %d bytes\n", DEFAULT_RNDV_SIZE);
+ MPI_Finalize();
+ return 0;
}
- if (rank > 1)
- {
- printf("Rank %d, I am not participating.\n", rank);
- fflush(stdout);
+ if (rank > 1) {
+ printf("Rank %d, I am not participating.\n", rank);
+ fflush(stdout);
}
- else
- {
- if (argc < 2)
- bDoAll = TRUE;
-
- if (bDoAll || (strcmp(argv[1], "sr") == 0))
- {
- reps = 1;
- if (argc > 2)
- {
- reps = atoi(argv[2]);
- if (reps < 1)
- reps = 1;
- }
- if (rank == 0)
- {
- printf("Send/recv test: %d reps\n", reps);
- fflush(stdout);
- }
- result = SendRecvTest(rank, reps);
- printf(result ? "%d:SUCCESS - sr\n" : "%d:FAILURE - sr\n", rank);
- fflush(stdout);
- }
-
- if (bDoAll || (strcmp(argv[1], "isr") == 0))
- {
- if (rank == 0)
- {
- printf("Isend/irecv wait test\n");
- fflush(stdout);
- }
- result = IsendIrecvTest(rank);
- printf(result ? "%d:SUCCESS - isr\n" : "%d:FAILURE - isr\n", rank);
- fflush(stdout);
- }
-
- if (bDoAll || (strcmp(argv[1], "iisr") == 0))
- {
- if (rank == 0)
- {
- printf("Isend,isend/irecv,irecv wait wait test\n");
- fflush(stdout);
- }
- result = IsendIrecvTest2(rank, 100);
- printf(result ? "%d:SUCCESS - iisr\n" : "%d:FAILURE - iisr\n", rank);
- fflush(stdout);
- }
-
- if (bDoAll || (strcmp(argv[1], "oo") == 0))
- {
- if (rank == 0)
- {
- printf("Out of order isend/irecv test\n");
- fflush(stdout);
- }
- result = OutOfOrderTest(rank, 100);
- printf(result ? "%d:SUCCESS - oo\n" : "%d:FAILURE - oo\n", rank);
- fflush(stdout);
- }
-
- if (bDoAll || (strcmp(argv[1], "unex") == 0))
- {
- if (rank == 0)
- {
- printf("Force unexpected message test\n");
- fflush(stdout);
- }
- result = ForceUnexpectedTest(rank, 100);
- printf(result ? "%d:SUCCESS - unex\n" : "%d:FAILURE - unex\n", rank);
- fflush(stdout);
- }
-
- if (bDoAll || (strcmp(argv[1], "rndv") == 0))
- {
- if (argc > 2)
- {
- rndv_size = atoi(argv[2]);
- if (rndv_size < 1024)
- rndv_size = 1024;
- }
- if (rank == 0)
- {
- printf("Rndv test\n");
- fflush(stdout);
- }
- result = RndvTest(rank, rndv_size, 1);
- printf(result ? "%d:SUCCESS - rndv\n" : "%d:FAILURE - rndv\n", rank);
- fflush(stdout);
- }
-
- if (bDoAll || (strcmp(argv[1], "rndv_reps") == 0))
- {
- reps = 100;
- if (argc > 2)
- {
- reps = atoi(argv[2]);
- if (reps < 1)
- reps = 1;
- }
- if (argc > 3)
- {
- rndv_size = atoi(argv[3]);
- }
- if (rank == 0)
- {
- printf("Rndv test: %d reps of size %d\n", reps, rndv_size);
- fflush(stdout);
- }
- result = RndvTest(rank, rndv_size, reps);
- printf(result ? "%d:SUCCESS - rndv_reps\n" : "%d:FAILURE - rndv_reps\n", rank);
- fflush(stdout);
- }
-
- if (bDoAll || (strcmp(argv[1], "rndv_iisr") == 0))
- {
- if (rank == 0)
- {
- printf("Rndv isend,isend/irecv,irecv wait wait test\n");
- fflush(stdout);
- }
- if (argc > 2)
- {
- rndv_size = atoi(argv[2]);
- }
- result = IsendIrecvTest2(rank, rndv_size);
- printf(result ? "%d:SUCCESS - rndv_iisr\n" : "%d:FAILURE - rndv_iisr\n", rank);
- fflush(stdout);
- }
-
- if (bDoAll || (strcmp(argv[1], "rndv_oo") == 0))
- {
- if (rank == 0)
- {
- printf("Rndv out of order isend/irecv test\n");
- fflush(stdout);
- }
- if (argc > 2)
- {
- rndv_size = atoi(argv[2]);
- }
- result = OutOfOrderTest(rank, rndv_size);
- printf(result ? "%d:SUCCESS - rndv_oo\n" : "%d:FAILURE - rndv_oo\n", rank);
- fflush(stdout);
- }
-
- if (bDoAll || (strcmp(argv[1], "rndv_unex") == 0))
- {
- if (argc > 2)
- {
- rndv_size = atoi(argv[2]);
- if (rndv_size < 1024)
- rndv_size = 1024;
- }
- if (rank == 0)
- {
- printf("Force unexpected rndv message test\n");
- fflush(stdout);
- }
- result = ForceUnexpectedTest(rank, rndv_size);
- printf(result ? "%d:SUCCESS - rndv_unex\n" : "%d:FAILURE - rndv_unex\n", rank);
- fflush(stdout);
- }
+ else {
+ if (argc < 2)
+ bDoAll = TRUE;
+
+ if (bDoAll || (strcmp(argv[1], "sr") == 0)) {
+ reps = 1;
+ if (argc > 2) {
+ reps = atoi(argv[2]);
+ if (reps < 1)
+ reps = 1;
+ }
+ if (rank == 0) {
+ printf("Send/recv test: %d reps\n", reps);
+ fflush(stdout);
+ }
+ result = SendRecvTest(rank, reps);
+ printf(result ? "%d:SUCCESS - sr\n" : "%d:FAILURE - sr\n", rank);
+ fflush(stdout);
+ }
+
+ if (bDoAll || (strcmp(argv[1], "isr") == 0)) {
+ if (rank == 0) {
+ printf("Isend/irecv wait test\n");
+ fflush(stdout);
+ }
+ result = IsendIrecvTest(rank);
+ printf(result ? "%d:SUCCESS - isr\n" : "%d:FAILURE - isr\n", rank);
+ fflush(stdout);
+ }
+
+ if (bDoAll || (strcmp(argv[1], "iisr") == 0)) {
+ if (rank == 0) {
+ printf("Isend,isend/irecv,irecv wait wait test\n");
+ fflush(stdout);
+ }
+ result = IsendIrecvTest2(rank, 100);
+ printf(result ? "%d:SUCCESS - iisr\n" : "%d:FAILURE - iisr\n", rank);
+ fflush(stdout);
+ }
+
+ if (bDoAll || (strcmp(argv[1], "oo") == 0)) {
+ if (rank == 0) {
+ printf("Out of order isend/irecv test\n");
+ fflush(stdout);
+ }
+ result = OutOfOrderTest(rank, 100);
+ printf(result ? "%d:SUCCESS - oo\n" : "%d:FAILURE - oo\n", rank);
+ fflush(stdout);
+ }
+
+ if (bDoAll || (strcmp(argv[1], "unex") == 0)) {
+ if (rank == 0) {
+ printf("Force unexpected message test\n");
+ fflush(stdout);
+ }
+ result = ForceUnexpectedTest(rank, 100);
+ printf(result ? "%d:SUCCESS - unex\n" : "%d:FAILURE - unex\n", rank);
+ fflush(stdout);
+ }
+
+ if (bDoAll || (strcmp(argv[1], "rndv") == 0)) {
+ if (argc > 2) {
+ rndv_size = atoi(argv[2]);
+ if (rndv_size < 1024)
+ rndv_size = 1024;
+ }
+ if (rank == 0) {
+ printf("Rndv test\n");
+ fflush(stdout);
+ }
+ result = RndvTest(rank, rndv_size, 1);
+ printf(result ? "%d:SUCCESS - rndv\n" : "%d:FAILURE - rndv\n", rank);
+ fflush(stdout);
+ }
+
+ if (bDoAll || (strcmp(argv[1], "rndv_reps") == 0)) {
+ reps = 100;
+ if (argc > 2) {
+ reps = atoi(argv[2]);
+ if (reps < 1)
+ reps = 1;
+ }
+ if (argc > 3) {
+ rndv_size = atoi(argv[3]);
+ }
+ if (rank == 0) {
+ printf("Rndv test: %d reps of size %d\n", reps, rndv_size);
+ fflush(stdout);
+ }
+ result = RndvTest(rank, rndv_size, reps);
+ printf(result ? "%d:SUCCESS - rndv_reps\n" : "%d:FAILURE - rndv_reps\n", rank);
+ fflush(stdout);
+ }
+
+ if (bDoAll || (strcmp(argv[1], "rndv_iisr") == 0)) {
+ if (rank == 0) {
+ printf("Rndv isend,isend/irecv,irecv wait wait test\n");
+ fflush(stdout);
+ }
+ if (argc > 2) {
+ rndv_size = atoi(argv[2]);
+ }
+ result = IsendIrecvTest2(rank, rndv_size);
+ printf(result ? "%d:SUCCESS - rndv_iisr\n" : "%d:FAILURE - rndv_iisr\n", rank);
+ fflush(stdout);
+ }
+
+ if (bDoAll || (strcmp(argv[1], "rndv_oo") == 0)) {
+ if (rank == 0) {
+ printf("Rndv out of order isend/irecv test\n");
+ fflush(stdout);
+ }
+ if (argc > 2) {
+ rndv_size = atoi(argv[2]);
+ }
+ result = OutOfOrderTest(rank, rndv_size);
+ printf(result ? "%d:SUCCESS - rndv_oo\n" : "%d:FAILURE - rndv_oo\n", rank);
+ fflush(stdout);
+ }
+
+ if (bDoAll || (strcmp(argv[1], "rndv_unex") == 0)) {
+ if (argc > 2) {
+ rndv_size = atoi(argv[2]);
+ if (rndv_size < 1024)
+ rndv_size = 1024;
+ }
+ if (rank == 0) {
+ printf("Force unexpected rndv message test\n");
+ fflush(stdout);
+ }
+ result = ForceUnexpectedTest(rank, rndv_size);
+ printf(result ? "%d:SUCCESS - rndv_unex\n" : "%d:FAILURE - rndv_unex\n", rank);
+ fflush(stdout);
+ }
}
MPI_Finalize();
diff --git a/test/mpi/basic/self.c b/test/mpi/basic/self.c
index 71501f8..2e66977 100644
--- a/test/mpi/basic/self.c
+++ b/test/mpi/basic/self.c
@@ -11,11 +11,9 @@ int main(int argc, char *argv[])
int i, j;
MPI_Status status;
- MPI_Init(&argc,&argv);
+ MPI_Init(&argc, &argv);
- MPI_Sendrecv ( &i, 1, MPI_INT, 0, 100,
- &j, 1, MPI_INT, 0, 100,
- MPI_COMM_WORLD, &status );
+ MPI_Sendrecv(&i, 1, MPI_INT, 0, 100, &j, 1, MPI_INT, 0, 100, MPI_COMM_WORLD, &status);
MPI_Finalize();
return (0);
diff --git a/test/mpi/basic/sendrecv.c b/test/mpi/basic/sendrecv.c
index 09c4543..e11961c 100644
--- a/test/mpi/basic/sendrecv.c
+++ b/test/mpi/basic/sendrecv.c
@@ -21,75 +21,73 @@ int main(int argc, char *argv[])
int reps = 1;
int i;
- printf("Simple Send/Recv test.\n"); fflush(stdout);
+ printf("Simple Send/Recv test.\n");
+ fflush(stdout);
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- if (size < 2)
- {
- printf("Two processes needed.\n");
- MPI_Finalize();
- return 0;
+ if (size < 2) {
+ printf("Two processes needed.\n");
+ MPI_Finalize();
+ return 0;
}
- if (argc > 1)
- {
- reps = atoi(argv[1]);
- if (reps < 1)
- reps = 1;
+ if (argc > 1) {
+ reps = atoi(argv[1]);
+ if (reps < 1)
+ reps = 1;
}
- if (rank == 0)
- {
- printf("Rank 0: sending 100 bytes messages to process 1.\n"); fflush(stdout);
- strcpy(buffer, "Hello process one.");
- for (i = 0; i<reps; i++)
- {
- MPI_Send(buffer, 100, MPI_BYTE, 1, tag, MPI_COMM_WORLD);
- MPI_Recv(buffer, 100, MPI_BYTE, 1, tag, MPI_COMM_WORLD, &status);
- }
- strcpy(big_buffer, "Hello again process one.");
- printf("Rank 0: sending %dk bytes messages to process 1.\n", LARGE_SIZE/1024); fflush(stdout);
- for (i = 0; i<reps; i++)
- {
- MPI_Send(big_buffer, LARGE_SIZE, MPI_BYTE, 1, tag, MPI_COMM_WORLD);
- MPI_Recv(big_buffer, LARGE_SIZE, MPI_BYTE, 1, tag, MPI_COMM_WORLD, &status);
- }
- strcpy(big_buffer, "Hello yet again process one.");
- printf("Rank 0: sending %dk bytes messages to process 1.\n", RNDV_SIZE/1024); fflush(stdout);
- for (i = 0; i<reps; i++)
- {
- MPI_Send(big_buffer, RNDV_SIZE, MPI_BYTE, 1, tag, MPI_COMM_WORLD);
- MPI_Recv(big_buffer, RNDV_SIZE, MPI_BYTE, 1, tag, MPI_COMM_WORLD, &status);
- }
+ if (rank == 0) {
+ printf("Rank 0: sending 100 bytes messages to process 1.\n");
+ fflush(stdout);
+ strcpy(buffer, "Hello process one.");
+ for (i = 0; i < reps; i++) {
+ MPI_Send(buffer, 100, MPI_BYTE, 1, tag, MPI_COMM_WORLD);
+ MPI_Recv(buffer, 100, MPI_BYTE, 1, tag, MPI_COMM_WORLD, &status);
+ }
+ strcpy(big_buffer, "Hello again process one.");
+ printf("Rank 0: sending %dk bytes messages to process 1.\n", LARGE_SIZE / 1024);
+ fflush(stdout);
+ for (i = 0; i < reps; i++) {
+ MPI_Send(big_buffer, LARGE_SIZE, MPI_BYTE, 1, tag, MPI_COMM_WORLD);
+ MPI_Recv(big_buffer, LARGE_SIZE, MPI_BYTE, 1, tag, MPI_COMM_WORLD, &status);
+ }
+ strcpy(big_buffer, "Hello yet again process one.");
+ printf("Rank 0: sending %dk bytes messages to process 1.\n", RNDV_SIZE / 1024);
+ fflush(stdout);
+ for (i = 0; i < reps; i++) {
+ MPI_Send(big_buffer, RNDV_SIZE, MPI_BYTE, 1, tag, MPI_COMM_WORLD);
+ MPI_Recv(big_buffer, RNDV_SIZE, MPI_BYTE, 1, tag, MPI_COMM_WORLD, &status);
+ }
}
- else if (rank == 1)
- {
- printf("Rank 1: receiving messages from process 0.\n"); fflush(stdout);
- for (i = 0; i<reps; i++)
- {
- MPI_Recv(buffer, 100, MPI_BYTE, 0, tag, MPI_COMM_WORLD, &status);
- MPI_Send(buffer, 100, MPI_BYTE, 0, tag, MPI_COMM_WORLD);
- }
- printf("Rank 1: received message '%s'\n", buffer); fflush(stdout);
- for (i = 0; i<reps; i++)
- {
- MPI_Recv(big_buffer, LARGE_SIZE, MPI_BYTE, 0, tag, MPI_COMM_WORLD, &status);
- MPI_Send(big_buffer, LARGE_SIZE, MPI_BYTE, 0, tag, MPI_COMM_WORLD);
- }
- printf("Rank 1: received message '%s'\n", big_buffer); fflush(stdout);
- for (i = 0; i<reps; i++)
- {
- MPI_Recv(big_buffer, RNDV_SIZE, MPI_BYTE, 0, tag, MPI_COMM_WORLD, &status);
- MPI_Send(big_buffer, RNDV_SIZE, MPI_BYTE, 0, tag, MPI_COMM_WORLD);
- }
- printf("Rank 1: received message '%s'\n", big_buffer); fflush(stdout);
+ else if (rank == 1) {
+ printf("Rank 1: receiving messages from process 0.\n");
+ fflush(stdout);
+ for (i = 0; i < reps; i++) {
+ MPI_Recv(buffer, 100, MPI_BYTE, 0, tag, MPI_COMM_WORLD, &status);
+ MPI_Send(buffer, 100, MPI_BYTE, 0, tag, MPI_COMM_WORLD);
+ }
+ printf("Rank 1: received message '%s'\n", buffer);
+ fflush(stdout);
+ for (i = 0; i < reps; i++) {
+ MPI_Recv(big_buffer, LARGE_SIZE, MPI_BYTE, 0, tag, MPI_COMM_WORLD, &status);
+ MPI_Send(big_buffer, LARGE_SIZE, MPI_BYTE, 0, tag, MPI_COMM_WORLD);
+ }
+ printf("Rank 1: received message '%s'\n", big_buffer);
+ fflush(stdout);
+ for (i = 0; i < reps; i++) {
+ MPI_Recv(big_buffer, RNDV_SIZE, MPI_BYTE, 0, tag, MPI_COMM_WORLD, &status);
+ MPI_Send(big_buffer, RNDV_SIZE, MPI_BYTE, 0, tag, MPI_COMM_WORLD);
+ }
+ printf("Rank 1: received message '%s'\n", big_buffer);
+ fflush(stdout);
}
- else
- {
- printf("Rank %d, I am not participating.\n", rank); fflush(stdout);
+ else {
+ printf("Rank %d, I am not participating.\n", rank);
+ fflush(stdout);
}
MPI_Finalize();
diff --git a/test/mpi/basic/srtest.c b/test/mpi/basic/srtest.c
index d8bdfb8..4e34acc 100644
--- a/test/mpi/basic/srtest.c
+++ b/test/mpi/basic/srtest.c
@@ -15,37 +15,33 @@ int main(int argc, char *argv[])
char buffer[BUFLEN], processor_name[MPI_MAX_PROCESSOR_NAME];
MPI_Status status;
- MPI_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&numprocs);
- MPI_Comm_rank(MPI_COMM_WORLD,&myid);
- MPI_Get_processor_name(processor_name,&namelen);
- fprintf(stderr,"Process %d of %d is alive on %s\n", myid, numprocs, processor_name);
+ MPI_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &myid);
+ MPI_Get_processor_name(processor_name, &namelen);
+ fprintf(stderr, "Process %d of %d is alive on %s\n", myid, numprocs, processor_name);
- strcpy(buffer,"hello there");
- if (myid == numprocs-1)
- next = 0;
+ strcpy(buffer, "hello there");
+ if (myid == numprocs - 1)
+ next = 0;
else
- next = myid+1;
+ next = myid + 1;
- if (myid == 0)
- {
- printf("%d sending '%s' \n",myid,buffer);
- MPI_Send(buffer, (int)strlen(buffer)+1, MPI_CHAR, next, 99, MPI_COMM_WORLD);
- printf("%d receiving \n",myid);
- MPI_Recv(buffer, BUFLEN, MPI_CHAR, MPI_ANY_SOURCE, 99, MPI_COMM_WORLD,
- &status);
- printf("%d received '%s' \n",myid,buffer);
- /* mpdprintf(001,"%d receiving \n",myid); */
+ if (myid == 0) {
+ printf("%d sending '%s' \n", myid, buffer);
+ MPI_Send(buffer, (int) strlen(buffer) + 1, MPI_CHAR, next, 99, MPI_COMM_WORLD);
+ printf("%d receiving \n", myid);
+ MPI_Recv(buffer, BUFLEN, MPI_CHAR, MPI_ANY_SOURCE, 99, MPI_COMM_WORLD, &status);
+ printf("%d received '%s' \n", myid, buffer);
+ /* mpdprintf(001,"%d receiving \n",myid); */
}
- else
- {
- printf("%d receiving \n",myid);
- MPI_Recv(buffer, BUFLEN, MPI_CHAR, MPI_ANY_SOURCE, 99, MPI_COMM_WORLD,
- &status);
- printf("%d received '%s' \n",myid,buffer);
- /* mpdprintf(001,"%d receiving \n",myid); */
- MPI_Send(buffer, (int)strlen(buffer)+1, MPI_CHAR, next, 99, MPI_COMM_WORLD);
- printf("%d sent '%s' \n",myid,buffer);
+ else {
+ printf("%d receiving \n", myid);
+ MPI_Recv(buffer, BUFLEN, MPI_CHAR, MPI_ANY_SOURCE, 99, MPI_COMM_WORLD, &status);
+ printf("%d received '%s' \n", myid, buffer);
+ /* mpdprintf(001,"%d receiving \n",myid); */
+ MPI_Send(buffer, (int) strlen(buffer) + 1, MPI_CHAR, next, 99, MPI_COMM_WORLD);
+ printf("%d sent '%s' \n", myid, buffer);
}
MPI_Barrier(MPI_COMM_WORLD);
MPI_Finalize();
diff --git a/test/mpi/basic/wtime.c b/test/mpi/basic/wtime.c
index ec09cb3..c00b696 100644
--- a/test/mpi/basic/wtime.c
+++ b/test/mpi/basic/wtime.c
@@ -9,19 +9,19 @@
int main(int argc, char *argv[])
{
- int i;
- double dStart, dFinish, dDuration;
+ int i;
+ double dStart, dFinish, dDuration;
- MPI_Init(&argc, &argv);
- MPI_Comm_rank(MPI_COMM_WORLD, &i);
+ MPI_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &i);
- dStart = MPI_Wtime();
+ dStart = MPI_Wtime();
MTestSleep(1);
- dFinish = MPI_Wtime();
- dDuration = dFinish - dStart;
+ dFinish = MPI_Wtime();
+ dDuration = dFinish - dStart;
- printf("start:%g\nfinish:%g\nduration:%g\n", dStart, dFinish, dDuration);
+ printf("start:%g\nfinish:%g\nduration:%g\n", dStart, dFinish, dDuration);
- MPI_Finalize();
- return 0;
+ MPI_Finalize();
+ return 0;
}
diff --git a/test/mpi/ckpoint/write_ckpoint.c b/test/mpi/ckpoint/write_ckpoint.c
index 1ddd46d..d232cab 100644
--- a/test/mpi/ckpoint/write_ckpoint.c
+++ b/test/mpi/ckpoint/write_ckpoint.c
@@ -10,29 +10,31 @@
#include <sys/stat.h>
#include <sys/types.h>
-int main(int argc,char *argv[])
+int main(int argc, char *argv[])
{
int numprocs, myid, i;
- int namelen;
+ int namelen;
char processor_name[MPI_MAX_PROCESSOR_NAME];
struct stat fileStat;
- MPI_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&numprocs);
- MPI_Comm_rank(MPI_COMM_WORLD,&myid);
- MPI_Get_processor_name(processor_name,&namelen);
+ MPI_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &myid);
+ MPI_Get_processor_name(processor_name, &namelen);
- for ( i = 0 ; i < 22; i++ ) {
+ for (i = 0; i < 22; i++) {
MPI_Barrier(MPI_COMM_WORLD);
MTestSleep(1);
}
if (myid == 0) {
- if (stat("/tmp/context-num2-0-0",&fileStat) < 0) {
+ if (stat("/tmp/context-num2-0-0", &fileStat) < 0) {
printf("failed to find ckpoint file\n");
- } else if (fileStat.st_size == 0) {
+ }
+ else if (fileStat.st_size == 0) {
printf("ckpoint file is empty\n");
- } else {
+ }
+ else {
printf("No Errors\n");
}
}
diff --git a/test/mpi/coll/allgather2.c b/test/mpi/coll/allgather2.c
index 9ac5731..01cf4ab 100644
--- a/test/mpi/coll/allgather2.c
+++ b/test/mpi/coll/allgather2.c
@@ -12,48 +12,45 @@
/* Gather data from a vector to contiguous. Use IN_PLACE */
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
double *vecout;
MPI_Comm comm;
- int count, minsize = 2;
- int i, errs = 0;
- int rank, size;
-
- MTest_Init( &argc, &argv );
-
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
- /* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
-
+ int count, minsize = 2;
+ int i, errs = 0;
+ int rank, size;
+
+ MTest_Init(&argc, &argv);
+
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ /* Determine the sender and receiver */
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+
for (count = 1; count < 9000; count = count * 2) {
- vecout = (double *)malloc( size * count * sizeof(double) );
-
- for (i=0; i<count; i++) {
- vecout[rank*count+i] = rank*count+i;
+ vecout = (double *) malloc(size * count * sizeof(double));
+
+ for (i = 0; i < count; i++) {
+ vecout[rank * count + i] = rank * count + i;
}
- MPI_Allgather( MPI_IN_PLACE, -1, MPI_DATATYPE_NULL,
- vecout, count, MPI_DOUBLE, comm );
- for (i=0; i<count*size; i++) {
+ MPI_Allgather(MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, vecout, count, MPI_DOUBLE, comm);
+ for (i = 0; i < count * size; i++) {
if (vecout[i] != i) {
errs++;
if (errs < 10) {
- fprintf( stderr, "vecout[%d]=%d\n",
- i, (int)vecout[i] );
+ fprintf(stderr, "vecout[%d]=%d\n", i, (int) vecout[i]);
}
}
}
- free( vecout );
+ free(vecout);
}
- MTestFreeComm( &comm );
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
-
-
diff --git a/test/mpi/coll/allgather3.c b/test/mpi/coll/allgather3.c
index 66389b5..408ac2e 100644
--- a/test/mpi/coll/allgather3.c
+++ b/test/mpi/coll/allgather3.c
@@ -12,53 +12,50 @@
/* Gather data from a vector to contiguous. */
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
double *vecout, *invec;
MPI_Comm comm;
- int count, minsize = 2;
- int i, errs = 0;
- int rank, size;
+ int count, minsize = 2;
+ int i, errs = 0;
+ int rank, size;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
+
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ /* Determine the sender and receiver */
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
- /* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
-
for (count = 1; count < 9000; count = count * 2) {
- invec = (double *)malloc( count * sizeof(double) );
- vecout = (double *)malloc( size * count * sizeof(double) );
-
- for (i=0; i<count; i++) {
- invec[i] = rank*count+i;
+ invec = (double *) malloc(count * sizeof(double));
+ vecout = (double *) malloc(size * count * sizeof(double));
+
+ for (i = 0; i < count; i++) {
+ invec[i] = rank * count + i;
}
- MPI_Allgather( invec, count, MPI_DOUBLE,
- vecout, count, MPI_DOUBLE, comm );
- for (i=0; i<count*size; i++) {
+ MPI_Allgather(invec, count, MPI_DOUBLE, vecout, count, MPI_DOUBLE, comm);
+ for (i = 0; i < count * size; i++) {
if (vecout[i] != i) {
errs++;
if (errs < 10) {
- fprintf( stderr, "vecout[%d]=%d\n",
- i, (int)vecout[i] );
+ fprintf(stderr, "vecout[%d]=%d\n", i, (int) vecout[i]);
}
}
}
- free( invec );
- free( vecout );
+ free(invec);
+ free(vecout);
}
- MTestFreeComm( &comm );
+ MTestFreeComm(&comm);
}
/* Do a zero byte gather */
- MPI_Allgather( MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, NULL, 0, MPI_BYTE, MPI_COMM_WORLD );
+ MPI_Allgather(MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, NULL, 0, MPI_BYTE, MPI_COMM_WORLD);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
-
-
diff --git a/test/mpi/coll/allgatherv2.c b/test/mpi/coll/allgatherv2.c
index ed78723..0d4248e 100644
--- a/test/mpi/coll/allgatherv2.c
+++ b/test/mpi/coll/allgatherv2.c
@@ -10,62 +10,60 @@
#include <stdlib.h>
#include <stdio.h>
-/* Gather data from a vector to contiguous. Use IN_PLACE. This is
+/* Gather data from a vector to contiguous. Use IN_PLACE. This is
the trivial version based on the allgather test (allgatherv but with
constant data sizes) */
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
double *vecout;
MPI_Comm comm;
- int count, minsize = 2;
- int i, errs = 0;
- int rank, size;
- int *displs, *recvcounts;
+ int count, minsize = 2;
+ int i, errs = 0;
+ int rank, size;
+ int *displs, *recvcounts;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
- /* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ /* Determine the sender and receiver */
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+
+ displs = (int *) malloc(size * sizeof(int));
+ recvcounts = (int *) malloc(size * sizeof(int));
- displs = (int *)malloc( size * sizeof(int) );
- recvcounts = (int *)malloc( size * sizeof(int) );
-
for (count = 1; count < 9000; count = count * 2) {
- vecout = (double *)malloc( size * count * sizeof(double) );
-
- for (i=0; i<count; i++) {
- vecout[rank*count+i] = rank*count+i;
+ vecout = (double *) malloc(size * count * sizeof(double));
+
+ for (i = 0; i < count; i++) {
+ vecout[rank * count + i] = rank * count + i;
}
- for (i=0; i<size; i++) {
+ for (i = 0; i < size; i++) {
recvcounts[i] = count;
- displs[i] = i * count;
+ displs[i] = i * count;
}
- MPI_Allgatherv( MPI_IN_PLACE, -1, MPI_DATATYPE_NULL,
- vecout, recvcounts, displs, MPI_DOUBLE, comm );
- for (i=0; i<count*size; i++) {
+ MPI_Allgatherv(MPI_IN_PLACE, -1, MPI_DATATYPE_NULL,
+ vecout, recvcounts, displs, MPI_DOUBLE, comm);
+ for (i = 0; i < count * size; i++) {
if (vecout[i] != i) {
errs++;
if (errs < 10) {
- fprintf( stderr, "vecout[%d]=%d\n",
- i, (int)vecout[i] );
+ fprintf(stderr, "vecout[%d]=%d\n", i, (int) vecout[i]);
}
}
}
- free( vecout );
+ free(vecout);
}
- free( displs );
- free( recvcounts );
- MTestFreeComm( &comm );
+ free(displs);
+ free(recvcounts);
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
-
-
diff --git a/test/mpi/coll/allgatherv3.c b/test/mpi/coll/allgatherv3.c
index 7ba9a66..25066aa 100644
--- a/test/mpi/coll/allgatherv3.c
+++ b/test/mpi/coll/allgatherv3.c
@@ -10,63 +10,60 @@
#include <stdlib.h>
#include <stdio.h>
-/* Gather data from a vector to contiguous. This is
+/* Gather data from a vector to contiguous. This is
the trivial version based on the allgather test (allgatherv but with
constant data sizes) */
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
double *vecout, *invec;
MPI_Comm comm;
- int count, minsize = 2;
- int i, errs = 0;
- int rank, size;
- int *displs, *recvcounts;
+ int count, minsize = 2;
+ int i, errs = 0;
+ int rank, size;
+ int *displs, *recvcounts;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
- /* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ /* Determine the sender and receiver */
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+
+ displs = (int *) malloc(size * sizeof(int));
+ recvcounts = (int *) malloc(size * sizeof(int));
- displs = (int *)malloc( size * sizeof(int) );
- recvcounts = (int *)malloc( size * sizeof(int) );
-
for (count = 1; count < 9000; count = count * 2) {
- invec = (double *)malloc( count * sizeof(double) );
- vecout = (double *)malloc( size * count * sizeof(double) );
-
- for (i=0; i<count; i++) {
- invec[i] = rank*count+i;
+ invec = (double *) malloc(count * sizeof(double));
+ vecout = (double *) malloc(size * count * sizeof(double));
+
+ for (i = 0; i < count; i++) {
+ invec[i] = rank * count + i;
}
- for (i=0; i<size; i++) {
+ for (i = 0; i < size; i++) {
recvcounts[i] = count;
- displs[i] = i * count;
+ displs[i] = i * count;
}
- MPI_Allgatherv( invec, count, MPI_DOUBLE,
- vecout, recvcounts, displs, MPI_DOUBLE, comm );
- for (i=0; i<count*size; i++) {
+ MPI_Allgatherv(invec, count, MPI_DOUBLE, vecout, recvcounts, displs, MPI_DOUBLE, comm);
+ for (i = 0; i < count * size; i++) {
if (vecout[i] != i) {
errs++;
if (errs < 10) {
- fprintf( stderr, "vecout[%d]=%d\n",
- i, (int)vecout[i] );
+ fprintf(stderr, "vecout[%d]=%d\n", i, (int) vecout[i]);
}
}
}
- free( invec );
- free( vecout );
+ free(invec);
+ free(vecout);
}
- free( displs );
- free( recvcounts );
- MTestFreeComm( &comm );
+ free(displs);
+ free(recvcounts);
+ MTestFreeComm(&comm);
}
-
- MTest_Finalize( errs );
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
-
-
diff --git a/test/mpi/coll/allgatherv4.c b/test/mpi/coll/allgatherv4.c
index 363ace4..b1e1c5a 100644
--- a/test/mpi/coll/allgatherv4.c
+++ b/test/mpi/coll/allgatherv4.c
@@ -25,8 +25,8 @@
#define MAX_BUF (128 * 1024 * 1024)
#define LOOPS 10
-char * sbuf, * rbuf;
-int * recvcounts, * displs;
+char *sbuf, *rbuf;
+int *recvcounts, *displs;
int errs = 0;
/* #define dprintf printf */
@@ -42,9 +42,9 @@ typedef enum {
} test_t;
void comm_tests(MPI_Comm comm);
-double run_test(long long msg_size, MPI_Comm comm, test_t test_type, double * max_time);
+double run_test(long long msg_size, MPI_Comm comm, test_t test_type, double *max_time);
-int main(int argc, char ** argv)
+int main(int argc, char **argv)
{
int comm_size, comm_rank;
MPI_Comm comm;
@@ -65,10 +65,14 @@ int main(int argc, char ** argv)
displs = (void *) malloc(comm_size * sizeof(int));
if (!recvcounts || !displs || !sbuf || !rbuf) {
fprintf(stderr, "Unable to allocate memory:\n");
- if (!sbuf) fprintf(stderr,"\tsbuf of %d bytes\n", MAX_BUF );
- if (!rbuf) fprintf(stderr,"\trbuf of %d bytes\n", MAX_BUF );
- if (!recvcounts) fprintf(stderr,"\trecvcounts of %zd bytes\n", comm_size * sizeof(int) );
- if (!displs) fprintf(stderr,"\tdispls of %zd bytes\n", comm_size * sizeof(int) );
+ if (!sbuf)
+ fprintf(stderr, "\tsbuf of %d bytes\n", MAX_BUF);
+ if (!rbuf)
+ fprintf(stderr, "\trbuf of %d bytes\n", MAX_BUF);
+ if (!recvcounts)
+ fprintf(stderr, "\trecvcounts of %zd bytes\n", comm_size * sizeof(int));
+ if (!displs)
+ fprintf(stderr, "\tdispls of %zd bytes\n", comm_size * sizeof(int));
fflush(stderr);
MPI_Abort(MPI_COMM_WORLD, -1);
}
@@ -113,7 +117,7 @@ int main(int argc, char ** argv)
free(recvcounts);
free(displs);
-fn_exit:
+ fn_exit:
MTest_Finalize(errs);
MPI_Finalize();
@@ -173,8 +177,7 @@ void comm_tests(MPI_Comm comm)
}
}
-double run_test(long long msg_size, MPI_Comm comm, test_t test_type,
- double * max_time)
+double run_test(long long msg_size, MPI_Comm comm, test_t test_type, double *max_time)
{
int i, j;
int comm_size, comm_rank;
@@ -197,36 +200,39 @@ double run_test(long long msg_size, MPI_Comm comm, test_t test_type,
recvcounts[i] = (i < (comm_size / 2)) ? (2 * msg_size) : 0;
else if (test_type == LINEAR_DECREASE) {
tmp = 2 * msg_size * (comm_size - 1 - i) / (comm_size - 1);
- if (tmp != (int)tmp) {
- fprintf( stderr, "Integer overflow in variable tmp\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
+ if (tmp != (int) tmp) {
+ fprintf(stderr, "Integer overflow in variable tmp\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
recvcounts[i] = (int) tmp;
/* If the maximum message size is too large, don't run */
- if (tmp > MAX_BUF) return 0;
+ if (tmp > MAX_BUF)
+ return 0;
}
else if (test_type == BELL_CURVE) {
for (j = 0; j < i; j++) {
- if (i - 1 + j >= comm_size) continue;
+ if (i - 1 + j >= comm_size)
+ continue;
tmp = msg_size * comm_size / (log(comm_size) * i);
recvcounts[i - 1 + j] = (int) tmp;
displs[i - 1 + j] = 0;
/* If the maximum message size is too large, don't run */
- if (tmp > MAX_BUF) return 0;
+ if (tmp > MAX_BUF)
+ return 0;
}
}
if (i < comm_size - 1)
- displs[i+1] = displs[i] + recvcounts[i];
+ displs[i + 1] = displs[i] + recvcounts[i];
}
/* Test that:
- 1: sbuf is large enough
- 2: rbuf is large enough
- 3: There were no failures (e.g., tmp nowhere > rbuf size
- */
+ * 1: sbuf is large enough
+ * 2: rbuf is large enough
+ * 3: There were no failures (e.g., tmp nowhere > rbuf size
+ */
MPI_Barrier(comm);
start = MPI_Wtime();
for (i = 0; i < LOOPS; i++) {
diff --git a/test/mpi/coll/allred.c b/test/mpi/coll/allred.c
index d33f876..ea6fff5 100644
--- a/test/mpi/coll/allred.c
+++ b/test/mpi/coll/allred.c
@@ -20,11 +20,26 @@
int count, size, rank;
int cerrcnt;
-struct int_test { int a; int b; };
-struct long_test { long a; int b; };
-struct short_test { short a; int b; };
-struct float_test { float a; int b; };
-struct double_test { double a; int b; };
+struct int_test {
+ int a;
+ int b;
+};
+struct long_test {
+ long a;
+ int b;
+};
+struct short_test {
+ short a;
+ int b;
+};
+struct float_test {
+ float a;
+ int b;
+};
+struct double_test {
+ double a;
+ int b;
+};
#define mpi_op2str(op) \
((op == MPI_SUM) ? "MPI_SUM" : \
@@ -89,19 +104,19 @@ struct double_test { double a; int b; };
rank, name, mpi_op2str(mpi_op)); \
} \
free(in); free(out); free(sol); \
- } while(0)
+ } while (0)
-/* The logic on the error check on MPI_Allreduce assumes that all
+/* The logic on the error check on MPI_Allreduce assumes that all
MPI_Allreduce routines return a failure if any do - this is sufficient
for MPI implementations that reject some of the valid op/datatype pairs
- (and motivated this addition, as some versions of the IBM MPI
+ (and motivated this addition, as some versions of the IBM MPI
failed in just this way).
*/
#define ALLREDUCE_AND_FREE(mpi_type, mpi_op, in, out, sol) \
{ \
int i, rc, lerrcnt = 0; \
rc = MPI_Allreduce(in, out, count, mpi_type, mpi_op, MPI_COMM_WORLD); \
- if (rc) { lerrcnt++; cerrcnt++; MTestPrintError( rc ); } \
+ if (rc) { lerrcnt++; cerrcnt++; MTestPrintError(rc); } \
else { \
for (i = 0; i < count; i++) { \
if (out[i] != sol[i]) { \
@@ -117,7 +132,7 @@ struct double_test { double a; int b; };
{ \
int i, rc, lerrcnt = 0; \
rc = MPI_Allreduce(in, out, count, mpi_type, mpi_op, MPI_COMM_WORLD); \
- if (rc) { lerrcnt++; cerrcnt++; MTestPrintError( rc ); } \
+ if (rc) { lerrcnt++; cerrcnt++; MTestPrintError(rc); } \
else { \
for (i = 0; i < count; i++) { \
if ((out[i].a != sol[i].a) || (out[i].b != sol[i].b)) { \
@@ -313,7 +328,7 @@ struct double_test { double a; int b; };
op##_test##post(unsigned char, MPI_BYTE); \
}
-/* Make sure that we test complex and double complex, even if long
+/* Make sure that we test complex and double complex, even if long
double complex is not available */
#if defined(USE_LONG_DOUBLE_COMPLEX)
@@ -335,7 +350,7 @@ struct double_test { double a; int b; };
#else
#if MTEST_HAVE_MIN_MPI_VERSION(2,2) && defined(HAVE_FLOAT__COMPLEX) \
- && defined(HAVE_DOUBLE__COMPLEX)
+ && defined(HAVE_DOUBLE__COMPLEX)
#define test_types_set4(op, post) \
do { \
op##_test##post(float _Complex, MPI_C_FLOAT_COMPLEX); \
@@ -358,32 +373,32 @@ struct double_test { double a; int b; };
#define test_types_set5(op, post) do { } while (0)
#endif
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (size < 2) {
- fprintf( stderr, "At least 2 processes required\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "At least 2 processes required\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- /* Set errors return so that we can provide better information
- should a routine reject one of the operand/datatype pairs */
- MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ /* Set errors return so that we can provide better information
+ * should a routine reject one of the operand/datatype pairs */
+ MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
count = 10;
/* Allow an argument to override the count.
- Note that the product tests may fail if the count is very large.
+ * Note that the product tests may fail if the count is very large.
*/
if (argc >= 2) {
- count = atoi( argv[1] );
- if (count <= 0) {
- fprintf( stderr, "Invalid count argument %s\n", argv[1] );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
+ count = atoi(argv[1]);
+ if (count <= 0) {
+ fprintf(stderr, "Invalid count argument %s\n", argv[1]);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
}
test_types_set2(sum, 1);
@@ -440,8 +455,8 @@ int main( int argc, char **argv )
minloc_test(struct float_test, MPI_FLOAT_INT);
minloc_test(struct double_test, MPI_DOUBLE_INT);
- MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL );
- MTest_Finalize( cerrcnt );
+ MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL);
+ MTest_Finalize(cerrcnt);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/allred2.c b/test/mpi/coll/allred2.c
index f33b245..ece4009 100644
--- a/test/mpi/coll/allred2.c
+++ b/test/mpi/coll/allred2.c
@@ -13,43 +13,44 @@
static char MTEST_Descrip[] = "Test MPI_Allreduce with MPI_IN_PLACE";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size;
- int minsize = 2, count;
- MPI_Comm comm;
+ int minsize = 2, count;
+ MPI_Comm comm;
int *buf, i;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
- MPI_Comm_size( comm, &size );
- MPI_Comm_rank( comm, &rank );
-
- for (count = 1; count < 65000; count = count * 2) {
- /* Contiguous data */
- buf = (int *)malloc( count * sizeof(int) );
- for (i=0; i<count; i++) buf[i] = rank + i;
- MPI_Allreduce( MPI_IN_PLACE, buf, count, MPI_INT, MPI_SUM, comm );
- /* Check the results */
- for (i=0; i<count; i++) {
- int result = i * size + (size*(size-1))/2;
- if (buf[i] != result) {
- errs ++;
- if (errs < 10) {
- fprintf( stderr, "buf[%d] = %d expected %d\n",
- i, buf[i], result );
- }
- }
- }
- free( buf );
- }
- MTestFreeComm( &comm );
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
+
+ for (count = 1; count < 65000; count = count * 2) {
+ /* Contiguous data */
+ buf = (int *) malloc(count * sizeof(int));
+ for (i = 0; i < count; i++)
+ buf[i] = rank + i;
+ MPI_Allreduce(MPI_IN_PLACE, buf, count, MPI_INT, MPI_SUM, comm);
+ /* Check the results */
+ for (i = 0; i < count; i++) {
+ int result = i * size + (size * (size - 1)) / 2;
+ if (buf[i] != result) {
+ errs++;
+ if (errs < 10) {
+ fprintf(stderr, "buf[%d] = %d expected %d\n", i, buf[i], result);
+ }
+ }
+ }
+ free(buf);
+ }
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/allred3.c b/test/mpi/coll/allred3.c
index 4fc59b5..6c5d680 100644
--- a/test/mpi/coll/allred3.c
+++ b/test/mpi/coll/allred3.c
@@ -14,7 +14,7 @@ static char MTEST_Descrip[] = "Test MPI_Allreduce with non-commutative user-defi
*/
/* We make the error count global so that we can easily control the output
- of error information (in particular, limiting it after the first 10
+ of error information (in particular, limiting it after the first 10
errors */
int errs = 0;
@@ -25,39 +25,39 @@ int errs = 0;
c(i,j) is cin[j+i*matSize]
*/
#define MAXCOL 256
-static int matSize = 0; /* Must be < MAXCOL */
+static int matSize = 0; /* Must be < MAXCOL */
static int max_offset = 0;
-void uop( void *, void *, int *, MPI_Datatype * );
-void uop( void *cinPtr, void *coutPtr, int *count, MPI_Datatype *dtype )
+void uop(void *, void *, int *, MPI_Datatype *);
+void uop(void *cinPtr, void *coutPtr, int *count, MPI_Datatype * dtype)
{
- const int *cin = (const int *)cinPtr;
- int *cout = (int *)coutPtr;
+ const int *cin = (const int *) cinPtr;
+ int *cout = (int *) coutPtr;
int i, j, k, nmat;
int tempcol[MAXCOL];
int offset1, offset2;
- int matsize2 = matSize*matSize;
+ int matsize2 = matSize * matSize;
for (nmat = 0; nmat < *count; nmat++) {
- for (j=0; j<matSize; j++) {
- for (i=0; i<matSize; i++) {
- tempcol[i] = 0;
- for (k=0; k<matSize; k++) {
- /* col[i] += cin(i,k) * cout(k,j) */
- offset1 = k+i*matSize;
- offset2 = j+k*matSize;
- assert(offset1 < max_offset);
- assert(offset2 < max_offset);
- tempcol[i] += cin[offset1] * cout[offset2];
- }
- }
- for (i=0; i<matSize; i++) {
- offset1 = j+i*matSize;
- assert(offset1 < max_offset);
- cout[offset1] = tempcol[i];
- }
- }
- cin += matsize2;
- cout += matsize2;
+ for (j = 0; j < matSize; j++) {
+ for (i = 0; i < matSize; i++) {
+ tempcol[i] = 0;
+ for (k = 0; k < matSize; k++) {
+ /* col[i] += cin(i,k) * cout(k,j) */
+ offset1 = k + i * matSize;
+ offset2 = j + k * matSize;
+ assert(offset1 < max_offset);
+ assert(offset2 < max_offset);
+ tempcol[i] += cin[offset1] * cout[offset2];
+ }
+ }
+ for (i = 0; i < matSize; i++) {
+ offset1 = j + i * matSize;
+ assert(offset1 < max_offset);
+ cout[offset1] = tempcol[i];
+ }
+ }
+ cin += matsize2;
+ cout += matsize2;
}
}
@@ -66,147 +66,148 @@ void uop( void *cinPtr, void *coutPtr, int *count, MPI_Datatype *dtype )
is the the matrix representing the permutation that shifts left by one.
As the final matrix (in the size-1 position), we use the matrix that
shifts RIGHT by one
-*/
-static void initMat( MPI_Comm comm, int mat[] )
+*/
+static void initMat(MPI_Comm comm, int mat[])
{
int i, j, size, rank;
int offset;
-
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
- for (i=0; i<size*size; i++) {
- assert(i < max_offset);
- mat[i] = 0;
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+
+ for (i = 0; i < size * size; i++) {
+ assert(i < max_offset);
+ mat[i] = 0;
}
- if (rank < size-1) {
- /* Create the permutation matrix that exchanges r with r+1 */
- for (i=0; i<size; i++) {
- if (i == rank) {
- offset = ((i+1)%size) + i * size;
- assert(offset < max_offset);
- mat[offset] = 1;
- }
- else if (i == ((rank + 1)%size)) {
- offset = ((i+size-1)%size) + i * size;
- assert(offset < max_offset);
- mat[offset] = 1;
- }
- else {
- offset = i+i*size;
- assert(offset < max_offset);
- mat[offset] = 1;
- }
- }
+ if (rank < size - 1) {
+ /* Create the permutation matrix that exchanges r with r+1 */
+ for (i = 0; i < size; i++) {
+ if (i == rank) {
+ offset = ((i + 1) % size) + i * size;
+ assert(offset < max_offset);
+ mat[offset] = 1;
+ }
+ else if (i == ((rank + 1) % size)) {
+ offset = ((i + size - 1) % size) + i * size;
+ assert(offset < max_offset);
+ mat[offset] = 1;
+ }
+ else {
+ offset = i + i * size;
+ assert(offset < max_offset);
+ mat[offset] = 1;
+ }
+ }
}
else {
- /* Create the permutation matrix that shifts right by one */
- for (i=0; i<size; i++) {
- for (j=0; j<size; j++) {
- offset = j + i * size; /* location of c(i,j) */
- mat[offset] = 0;
- if ( ((j-i+size)%size) == 1 ) mat[offset] = 1;
- }
- }
-
+ /* Create the permutation matrix that shifts right by one */
+ for (i = 0; i < size; i++) {
+ for (j = 0; j < size; j++) {
+ offset = j + i * size; /* location of c(i,j) */
+ mat[offset] = 0;
+ if (((j - i + size) % size) == 1)
+ mat[offset] = 1;
+ }
+ }
+
}
}
/* Compare a matrix with the identity matrix */
-static int isIdentity( MPI_Comm comm, int mat[] )
+static int isIdentity(MPI_Comm comm, int mat[])
{
int i, j, size, rank, lerrs = 0;
int offset;
-
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
-
- for (i=0; i<size; i++) {
- for (j=0; j<size; j++) {
- if (i == j) {
- offset = j+i*size;
- assert(offset < max_offset);
- if (mat[offset] != 1) {
- lerrs++;
- if (errs + lerrs< 10) {
- printf( "[%d] mat[%d,%d] = %d, expected 1 for comm %s\n",
- rank, i,j, mat[offset], MTestGetIntracommName() );
- }
- }
- }
- else {
- offset = j+i*size;
- assert(offset < max_offset);
- if (mat[offset] != 0) {
- lerrs++;
- if (errs + lerrs< 10) {
- printf( "[%d] mat[%d,%d] = %d, expected 0 for comm %s\n",
- rank, i,j, mat[offset], MTestGetIntracommName() );
- }
- }
- }
- }
+
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+
+ for (i = 0; i < size; i++) {
+ for (j = 0; j < size; j++) {
+ if (i == j) {
+ offset = j + i * size;
+ assert(offset < max_offset);
+ if (mat[offset] != 1) {
+ lerrs++;
+ if (errs + lerrs < 10) {
+ printf("[%d] mat[%d,%d] = %d, expected 1 for comm %s\n",
+ rank, i, j, mat[offset], MTestGetIntracommName());
+ }
+ }
+ }
+ else {
+ offset = j + i * size;
+ assert(offset < max_offset);
+ if (mat[offset] != 0) {
+ lerrs++;
+ if (errs + lerrs < 10) {
+ printf("[%d] mat[%d,%d] = %d, expected 0 for comm %s\n",
+ rank, i, j, mat[offset], MTestGetIntracommName());
+ }
+ }
+ }
+ }
}
return lerrs;
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int size;
- int minsize = 2, count;
- MPI_Comm comm;
+ int minsize = 2, count;
+ MPI_Comm comm;
int *buf, *bufout;
MPI_Op op;
MPI_Datatype mattype;
- MTest_Init( &argc, &argv );
-
- MPI_Op_create( uop, 0, &op );
-
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) {
- continue;
- }
- MPI_Comm_size( comm, &size );
- matSize = size;
-
- /* Only one matrix for now */
- count = 1;
-
- /* A single matrix, the size of the communicator */
- MPI_Type_contiguous( size*size, MPI_INT, &mattype );
- MPI_Type_commit( &mattype );
-
- max_offset = count * size * size;
- buf = (int *)malloc( max_offset * sizeof(int) );
- if (!buf) {
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- bufout = (int *)malloc( max_offset * sizeof(int) );
- if (!bufout) {
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
-
- initMat( comm, buf );
- MPI_Allreduce( buf, bufout, count, mattype, op, comm );
- errs += isIdentity( comm, bufout );
-
- /* Try the same test, but using MPI_IN_PLACE */
- initMat( comm, bufout );
- MPI_Allreduce( MPI_IN_PLACE, bufout, count, mattype, op, comm );
- errs += isIdentity( comm, bufout );
-
- free( buf );
- free( bufout );
-
- MPI_Type_free( &mattype );
- MTestFreeComm( &comm );
+ MTest_Init(&argc, &argv);
+
+ MPI_Op_create(uop, 0, &op);
+
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL) {
+ continue;
+ }
+ MPI_Comm_size(comm, &size);
+ matSize = size;
+
+ /* Only one matrix for now */
+ count = 1;
+
+ /* A single matrix, the size of the communicator */
+ MPI_Type_contiguous(size * size, MPI_INT, &mattype);
+ MPI_Type_commit(&mattype);
+
+ max_offset = count * size * size;
+ buf = (int *) malloc(max_offset * sizeof(int));
+ if (!buf) {
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ bufout = (int *) malloc(max_offset * sizeof(int));
+ if (!bufout) {
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+
+ initMat(comm, buf);
+ MPI_Allreduce(buf, bufout, count, mattype, op, comm);
+ errs += isIdentity(comm, bufout);
+
+ /* Try the same test, but using MPI_IN_PLACE */
+ initMat(comm, bufout);
+ MPI_Allreduce(MPI_IN_PLACE, bufout, count, mattype, op, comm);
+ errs += isIdentity(comm, bufout);
+
+ free(buf);
+ free(bufout);
+
+ MPI_Type_free(&mattype);
+ MTestFreeComm(&comm);
}
- MPI_Op_free( &op );
+ MPI_Op_free(&op);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/allred4.c b/test/mpi/coll/allred4.c
index 32e0c00..0efc440 100644
--- a/test/mpi/coll/allred4.c
+++ b/test/mpi/coll/allred4.c
@@ -13,7 +13,7 @@
static char MTEST_Descrip[] = "Test MPI_Allreduce with non-commutative user-defined operations using matrix rotations";
*/
-/* This example is similar to allred3.c, but uses only 3x3 matrics with
+/* This example is similar to allred3.c, but uses only 3x3 matrics with
integer-valued entries. This is an associative but not commutative
operation.
The number of matrices is the count argument. The matrix is stored
@@ -26,209 +26,214 @@ static char MTEST_Descrip[] = "Test MPI_Allreduce with non-commutative user-defi
0 0 1 1 0 0
0 1 0) 0 0 1)
- The product
+ The product
I^k A I^(p-2-k-j) B I^j
- is
+ is
- ( 0 1 0
+ (0 1 0
0 0 1
- 1 0 0 )
+ 1 0 0)
- for all values of k, p, and j.
+ for all values of k, p, and j.
*/
-void matmult( void *cinPtr, void *coutPtr, int *count, MPI_Datatype *dtype );
+void matmult(void *cinPtr, void *coutPtr, int *count, MPI_Datatype * dtype);
-void matmult( void *cinPtr, void *coutPtr, int *count, MPI_Datatype *dtype )
+void matmult(void *cinPtr, void *coutPtr, int *count, MPI_Datatype * dtype)
{
- const int *cin = (const int *)cinPtr;
- int *cout = (int *)coutPtr;
+ const int *cin = (const int *) cinPtr;
+ int *cout = (int *) coutPtr;
int i, j, k, nmat;
int tempcol[3];
int offset1, offset2;
for (nmat = 0; nmat < *count; nmat++) {
- for (j=0; j<3; j++) {
- for (i=0; i<3; i++) {
- tempcol[i] = 0;
- for (k=0; k<3; k++) {
- /* col[i] += cin(i,k) * cout(k,j) */
- offset1 = k+i*3;
- offset2 = j+k*3;
- tempcol[i] += cin[offset1] * cout[offset2];
- }
- }
- for (i=0; i<3; i++) {
- offset1 = j+i*3;
- cout[offset1] = tempcol[i];
- }
- }
- /* Advance to the next matrix */
- cin += 9;
- cout += 9;
+ for (j = 0; j < 3; j++) {
+ for (i = 0; i < 3; i++) {
+ tempcol[i] = 0;
+ for (k = 0; k < 3; k++) {
+ /* col[i] += cin(i,k) * cout(k,j) */
+ offset1 = k + i * 3;
+ offset2 = j + k * 3;
+ tempcol[i] += cin[offset1] * cout[offset2];
+ }
+ }
+ for (i = 0; i < 3; i++) {
+ offset1 = j + i * 3;
+ cout[offset1] = tempcol[i];
+ }
+ }
+ /* Advance to the next matrix */
+ cin += 9;
+ cout += 9;
}
}
-/* Initialize the integer matrix as one of the
+/* Initialize the integer matrix as one of the
above matrix entries, as a function of count.
We guarantee that both the A and B matrices are included.
-*/
-static void initMat( int rank, int size, int nmat, int mat[] )
+*/
+static void initMat(int rank, int size, int nmat, int mat[])
{
int i, kind;
/* Zero the matrix */
- for (i=0; i<9; i++) {
- mat[i] = 0;
+ for (i = 0; i < 9; i++) {
+ mat[i] = 0;
}
/* Decide which matrix to create (I, A, or B) */
- if ( size == 2) {
- /* rank 0 is A, 1 is B */
- kind = 1 + rank;
+ if (size == 2) {
+ /* rank 0 is A, 1 is B */
+ kind = 1 + rank;
}
else {
- int tmpA, tmpB;
- /* Most ranks are identity matrices */
- kind = 0;
- /* Make sure exactly one rank gets the A matrix
- and one the B matrix */
- tmpA = size / 4;
- tmpB = (3 * size) / 4;
-
- if (rank == tmpA) kind = 1;
- if (rank == tmpB) kind = 2;
+ int tmpA, tmpB;
+ /* Most ranks are identity matrices */
+ kind = 0;
+ /* Make sure exactly one rank gets the A matrix
+ * and one the B matrix */
+ tmpA = size / 4;
+ tmpB = (3 * size) / 4;
+
+ if (rank == tmpA)
+ kind = 1;
+ if (rank == tmpB)
+ kind = 2;
}
-
+
switch (kind) {
- case 0: /* Identity */
- mat[0] = 1;
- mat[4] = 1;
- mat[8] = 1;
- break;
- case 1: /* A */
- mat[0] = 1;
- mat[5] = 1;
- mat[7] = 1;
- break;
- case 2: /* B */
- mat[1] = 1;
- mat[3] = 1;
- mat[8] = 1;
- break;
+ case 0: /* Identity */
+ mat[0] = 1;
+ mat[4] = 1;
+ mat[8] = 1;
+ break;
+ case 1: /* A */
+ mat[0] = 1;
+ mat[5] = 1;
+ mat[7] = 1;
+ break;
+ case 2: /* B */
+ mat[1] = 1;
+ mat[3] = 1;
+ mat[8] = 1;
+ break;
}
}
/* Compare a matrix with the known result */
-static int checkResult( int nmat, int mat[], const char *msg )
+static int checkResult(int nmat, int mat[], const char *msg)
{
int n, k, errs = 0, wrank;
- static int solution[9] = { 0, 1, 0,
- 0, 0, 1,
- 1, 0, 0 };
-
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
-
- for (n=0; n<nmat; n++) {
- for (k=0; k<9; k++) {
- if (mat[k] != solution[k]) {
- errs ++;
- if (errs == 1) {
- printf( "Errors for communicators %s\n",
- MTestGetIntracommName() ); fflush(stdout);
-
- }
- if (errs < 10) {
- printf( "[%d]matrix #%d(%s): Expected mat[%d,%d] = %d, got %d\n",
- wrank, n, msg, k / 3, k % 3, solution[k], mat[k] );
- fflush(stdout);
- }
- }
- }
- /* Advance to the next matrix */
- mat += 9;
+ static int solution[9] = { 0, 1, 0,
+ 0, 0, 1,
+ 1, 0, 0
+ };
+
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
+
+ for (n = 0; n < nmat; n++) {
+ for (k = 0; k < 9; k++) {
+ if (mat[k] != solution[k]) {
+ errs++;
+ if (errs == 1) {
+ printf("Errors for communicators %s\n", MTestGetIntracommName());
+ fflush(stdout);
+
+ }
+ if (errs < 10) {
+ printf("[%d]matrix #%d(%s): Expected mat[%d,%d] = %d, got %d\n",
+ wrank, n, msg, k / 3, k % 3, solution[k], mat[k]);
+ fflush(stdout);
+ }
+ }
+ }
+ /* Advance to the next matrix */
+ mat += 9;
}
return errs;
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int size, rank;
- int minsize = 2, count;
- MPI_Comm comm;
+ int minsize = 2, count;
+ MPI_Comm comm;
int *buf, *bufout;
MPI_Op op;
MPI_Datatype mattype;
int i;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
+
+ MPI_Op_create(matmult, 0, &op);
- MPI_Op_create( matmult, 0, &op );
-
/* A single rotation matrix (3x3, stored as 9 consequetive elements) */
- MPI_Type_contiguous( 9, MPI_INT, &mattype );
- MPI_Type_commit( &mattype );
+ MPI_Type_contiguous(9, MPI_INT, &mattype);
+ MPI_Type_commit(&mattype);
/* Sanity check: test that our routines work properly */
- { int one = 1;
- buf = (int *)malloc( 4*9 * sizeof(int) );
- initMat( 0, 4, 0, &buf[0] );
- initMat( 1, 4, 0, &buf[9] );
- initMat( 2, 4, 0, &buf[18] );
- initMat( 3, 4, 0, &buf[27] );
- matmult( &buf[0], &buf[9], &one, &mattype );
- matmult( &buf[9], &buf[18], &one, &mattype );
- matmult( &buf[18], &buf[27], &one, &mattype );
- checkResult( 1, &buf[27], "Sanity Check" );
- free(buf);
+ {
+ int one = 1;
+ buf = (int *) malloc(4 * 9 * sizeof(int));
+ initMat(0, 4, 0, &buf[0]);
+ initMat(1, 4, 0, &buf[9]);
+ initMat(2, 4, 0, &buf[18]);
+ initMat(3, 4, 0, &buf[27]);
+ matmult(&buf[0], &buf[9], &one, &mattype);
+ matmult(&buf[9], &buf[18], &one, &mattype);
+ matmult(&buf[18], &buf[27], &one, &mattype);
+ checkResult(1, &buf[27], "Sanity Check");
+ free(buf);
}
-
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
-
- MPI_Comm_size( comm, &size );
- MPI_Comm_rank( comm, &rank );
-
- for (count = 1; count < size; count ++ ) {
-
- /* Allocate the matrices */
- buf = (int *)malloc( count * 9 * sizeof(int) );
- if (!buf) {
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
-
- bufout = (int *)malloc( count * 9 * sizeof(int) );
- if (!bufout) {
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
-
- for (i=0; i < count; i++) {
- initMat( rank, size, i, &buf[i*9] );
- }
-
- MPI_Allreduce( buf, bufout, count, mattype, op, comm );
- errs += checkResult( count, bufout, "" );
-
- /* Try the same test, but using MPI_IN_PLACE */
- for (i=0; i < count; i++) {
- initMat( rank, size, i, &bufout[i*9] );
- }
- MPI_Allreduce( MPI_IN_PLACE, bufout, count, mattype, op, comm );
- errs += checkResult( count, bufout, "IN_PLACE" );
-
- free( buf );
- free( bufout );
- }
- MTestFreeComm( &comm );
+
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
+
+ for (count = 1; count < size; count++) {
+
+ /* Allocate the matrices */
+ buf = (int *) malloc(count * 9 * sizeof(int));
+ if (!buf) {
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+
+ bufout = (int *) malloc(count * 9 * sizeof(int));
+ if (!bufout) {
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+
+ for (i = 0; i < count; i++) {
+ initMat(rank, size, i, &buf[i * 9]);
+ }
+
+ MPI_Allreduce(buf, bufout, count, mattype, op, comm);
+ errs += checkResult(count, bufout, "");
+
+ /* Try the same test, but using MPI_IN_PLACE */
+ for (i = 0; i < count; i++) {
+ initMat(rank, size, i, &bufout[i * 9]);
+ }
+ MPI_Allreduce(MPI_IN_PLACE, bufout, count, mattype, op, comm);
+ errs += checkResult(count, bufout, "IN_PLACE");
+
+ free(buf);
+ free(bufout);
+ }
+ MTestFreeComm(&comm);
}
-
- MPI_Op_free( &op );
- MPI_Type_free( &mattype );
- MTest_Finalize( errs );
+ MPI_Op_free(&op);
+ MPI_Type_free(&mattype);
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/allred5.c b/test/mpi/coll/allred5.c
index a442550..1e6d0e2 100644
--- a/test/mpi/coll/allred5.c
+++ b/test/mpi/coll/allred5.c
@@ -14,52 +14,50 @@ static char MTEST_Descrip[] = "Test MPI_Allreduce with count greater than the nu
*/
/* We make the error count global so that we can easily control the output
- of error information (in particular, limiting it after the first 10
+ of error information (in particular, limiting it after the first 10
errors */
int errs = 0;
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Comm comm;
MPI_Datatype dtype;
- int count, *bufin, *bufout, size, i, minsize=1;
+ int count, *bufin, *bufout, size, i, minsize = 1;
- MTest_Init( &argc, &argv );
-
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) {
- continue;
- }
- MPI_Comm_size( comm, &size );
- count = size * 2;
- bufin = (int *)malloc( count * sizeof(int) );
- bufout = (int *)malloc( count * sizeof(int) );
- if (!bufin || !bufout) {
- fprintf( stderr, "Unable to allocated space for buffers (%d)\n",
- count );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- for (i=0; i<count; i++) {
- bufin[i] = i;
- bufout[i] = -1;
- }
+ MTest_Init(&argc, &argv);
- dtype = MPI_INT;
- MPI_Allreduce( bufin, bufout, count, dtype, MPI_SUM, comm );
- /* Check output */
- for (i=0; i<count; i++) {
- if (bufout[i] != i * size) {
- fprintf( stderr, "Expected bufout[%d] = %d but found %d\n",
- i, i * size, bufout[i] );
- errs++;
- }
- }
- free( bufin );
- free( bufout );
- MTestFreeComm( &comm );
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL) {
+ continue;
+ }
+ MPI_Comm_size(comm, &size);
+ count = size * 2;
+ bufin = (int *) malloc(count * sizeof(int));
+ bufout = (int *) malloc(count * sizeof(int));
+ if (!bufin || !bufout) {
+ fprintf(stderr, "Unable to allocated space for buffers (%d)\n", count);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ for (i = 0; i < count; i++) {
+ bufin[i] = i;
+ bufout[i] = -1;
+ }
+
+ dtype = MPI_INT;
+ MPI_Allreduce(bufin, bufout, count, dtype, MPI_SUM, comm);
+ /* Check output */
+ for (i = 0; i < count; i++) {
+ if (bufout[i] != i * size) {
+ fprintf(stderr, "Expected bufout[%d] = %d but found %d\n", i, i * size, bufout[i]);
+ errs++;
+ }
+ }
+ free(bufin);
+ free(bufout);
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/allred6.c b/test/mpi/coll/allred6.c
index ba829e1..dec9a00 100644
--- a/test/mpi/coll/allred6.c
+++ b/test/mpi/coll/allred6.c
@@ -13,61 +13,63 @@
static char MTEST_Descrip[] = "Test MPI_Allreduce with apparent non-commutative operators";
*/
/* While the operator is in fact commutative, this forces the MPI code to
- run the code that is used for non-commutative operators, and for
- various message lengths. Other tests check truly non-commutative
+ run the code that is used for non-commutative operators, and for
+ various message lengths. Other tests check truly non-commutative
operators */
-void mysum( void *cinPtr, void *coutPtr, int *count, MPI_Datatype *dtype );
+void mysum(void *cinPtr, void *coutPtr, int *count, MPI_Datatype * dtype);
-void mysum( void *cinPtr, void *coutPtr, int *count, MPI_Datatype *dtype )
+void mysum(void *cinPtr, void *coutPtr, int *count, MPI_Datatype * dtype)
{
- const int *cin = (const int *)cinPtr;
- int *cout = (int *)coutPtr;
- int i, n = *count;
- for (i=0; i<n; i++)
- cout[i] += cin[i];
+ const int *cin = (const int *) cinPtr;
+ int *cout = (int *) coutPtr;
+ int i, n = *count;
+ for (i = 0; i < n; i++)
+ cout[i] += cin[i];
}
-int main( int argc, char *argv[] )
+
+int main(int argc, char *argv[])
{
- int errs = 0;
- int rank, size;
- int minsize = 2, count;
+ int errs = 0;
+ int rank, size;
+ int minsize = 2, count;
MPI_Comm comm;
- MPI_Op op;
- int *buf, i;
+ MPI_Op op;
+ int *buf, i;
+
+ MTest_Init(&argc, &argv);
- MTest_Init( &argc, &argv );
+ MPI_Op_create(mysum, 0, &op);
- MPI_Op_create( mysum, 0, &op );
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
- MPI_Comm_size( comm, &size );
- MPI_Comm_rank( comm, &rank );
-
- for (count = 1; count < 65000; count = count * 2) {
- /* Contiguous data */
- buf = (int *)malloc( count * sizeof(int) );
- for (i=0; i<count; i++) buf[i] = rank + i;
- MPI_Allreduce( MPI_IN_PLACE, buf, count, MPI_INT, op, comm );
- /* Check the results */
- for (i=0; i<count; i++) {
- int result = i * size + (size*(size-1))/2;
- if (buf[i] != result) {
- errs ++;
- if (errs < 10) {
- fprintf( stderr, "buf[%d] = %d expected %d\n",
- i, buf[i], result );
- }
- }
- }
- free( buf );
- }
- MTestFreeComm( &comm );
+ for (count = 1; count < 65000; count = count * 2) {
+ /* Contiguous data */
+ buf = (int *) malloc(count * sizeof(int));
+ for (i = 0; i < count; i++)
+ buf[i] = rank + i;
+ MPI_Allreduce(MPI_IN_PLACE, buf, count, MPI_INT, op, comm);
+ /* Check the results */
+ for (i = 0; i < count; i++) {
+ int result = i * size + (size * (size - 1)) / 2;
+ if (buf[i] != result) {
+ errs++;
+ if (errs < 10) {
+ fprintf(stderr, "buf[%d] = %d expected %d\n", i, buf[i], result);
+ }
+ }
+ }
+ free(buf);
+ }
+ MTestFreeComm(&comm);
}
- MPI_Op_free( &op );
+ MPI_Op_free(&op);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/allredmany.c b/test/mpi/coll/allredmany.c
index 438119e..49aa6f9 100644
--- a/test/mpi/coll/allredmany.c
+++ b/test/mpi/coll/allredmany.c
@@ -11,24 +11,24 @@
* implementation to handle a flood of one-way messages.
*/
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- double wscale = 10.0, scale;
- int numprocs, myid,i;
+ double wscale = 10.0, scale;
+ int numprocs, myid, i;
- MPI_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&numprocs);
- MPI_Comm_rank(MPI_COMM_WORLD,&myid);
+ MPI_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &myid);
- for ( i=0; i<10000; i++) {
- MPI_Allreduce(&wscale,&scale,1,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD);
- }
+ for (i = 0; i < 10000; i++) {
+ MPI_Allreduce(&wscale, &scale, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
+ }
- if (myid == 0) {
- /* If we get here at all, we're ok */
- printf( " No Errors\n" );
- }
- MPI_Finalize();
-
- return 0;
+ if (myid == 0) {
+ /* If we get here at all, we're ok */
+ printf(" No Errors\n");
+ }
+ MPI_Finalize();
+
+ return 0;
}
diff --git a/test/mpi/coll/alltoall1.c b/test/mpi/coll/alltoall1.c
index c17f926..41739af 100644
--- a/test/mpi/coll/alltoall1.c
+++ b/test/mpi/coll/alltoall1.c
@@ -14,95 +14,96 @@
static char MTEST_Descrip[] = "";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size;
- int minsize = 2, count;
- MPI_Comm comm;
+ int minsize = 2, count;
+ MPI_Comm comm;
int *sendbuf, *recvbuf, *p;
int sendcount, recvcount;
int i, j;
MPI_Datatype sendtype, recvtype;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- /* The following illustrates the use of the routines to
- run through a selection of communicators and datatypes.
- Use subsets of these for tests that do not involve combinations
- of communicators, datatypes, and counts of datatypes */
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
+ /* The following illustrates the use of the routines to
+ * run through a selection of communicators and datatypes.
+ * Use subsets of these for tests that do not involve combinations
+ * of communicators, datatypes, and counts of datatypes */
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
- /* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
-
- /* printf( "Size of comm = %d\n", size ); */
- for (count = 1; count < 65000; count = count * 2) {
-
- /* Create a send buf and a receive buf suitable for testing
- all to all. */
- sendcount = count;
- recvcount = count;
- sendbuf = (int *)malloc( count * size * sizeof(int) );
- recvbuf = (int *)malloc( count * size * sizeof(int) );
- sendtype = MPI_INT;
- recvtype = MPI_INT;
+ /* Determine the sender and receiver */
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
- if (!sendbuf || !recvbuf) {
- errs++;
- fprintf( stderr, "Failed to allocate sendbuf and/or recvbuf\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- for (i=0; i<count*size; i++)
- recvbuf[i] = -1;
- p = sendbuf;
- for (j=0; j<size; j++) {
- for (i=0; i<count; i++) {
- *p++ = j * size + rank + i;
- }
- }
+ /* printf("Size of comm = %d\n", size); */
+ for (count = 1; count < 65000; count = count * 2) {
- MTest_Alltoall( sendbuf, sendcount, sendtype,
- recvbuf, recvcount, recvtype, comm );
+ /* Create a send buf and a receive buf suitable for testing
+ * all to all. */
+ sendcount = count;
+ recvcount = count;
+ sendbuf = (int *) malloc(count * size * sizeof(int));
+ recvbuf = (int *) malloc(count * size * sizeof(int));
+ sendtype = MPI_INT;
+ recvtype = MPI_INT;
- p = recvbuf;
- for (j=0; j<size; j++) {
- for (i=0; i<count; i++) {
- if (*p != rank * size + j + i) {
- errs++;
- if (errs < 10) {
- fprintf( stderr, "Error with communicator %s and size=%d count=%d\n",
- MTestGetIntracommName(), size, count );
- fprintf( stderr, "recvbuf[%d,%d] = %d, should %d\n",
- j,i, *p, rank * size + j + i );
- }
- }
- p++;
- }
- }
+ if (!sendbuf || !recvbuf) {
+ errs++;
+ fprintf(stderr, "Failed to allocate sendbuf and/or recvbuf\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ for (i = 0; i < count * size; i++)
+ recvbuf[i] = -1;
+ p = sendbuf;
+ for (j = 0; j < size; j++) {
+ for (i = 0; i < count; i++) {
+ *p++ = j * size + rank + i;
+ }
+ }
+
+ MTest_Alltoall(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
+
+ p = recvbuf;
+ for (j = 0; j < size; j++) {
+ for (i = 0; i < count; i++) {
+ if (*p != rank * size + j + i) {
+ errs++;
+ if (errs < 10) {
+ fprintf(stderr, "Error with communicator %s and size=%d count=%d\n",
+ MTestGetIntracommName(), size, count);
+ fprintf(stderr, "recvbuf[%d,%d] = %d, should %d\n",
+ j, i, *p, rank * size + j + i);
+ }
+ }
+ p++;
+ }
+ }
#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
/* check MPI_IN_PLACE, added in MPI-2.2 */
p = recvbuf;
- for (j=0; j<size; j++) {
- for (i=0; i<count; i++) {
+ for (j = 0; j < size; j++) {
+ for (i = 0; i < count; i++) {
*p++ = j * size + rank + i;
}
}
- MPI_Alltoall( MPI_IN_PLACE, -1/*ignored*/, MPI_DATATYPE_NULL/*ignored*/,
- recvbuf, recvcount, recvtype, comm );
+ MPI_Alltoall(MPI_IN_PLACE, -1 /*ignored */ , MPI_DATATYPE_NULL /*ignored */ ,
+ recvbuf, recvcount, recvtype, comm);
p = recvbuf;
- for (j=0; j<size; j++) {
- for (i=0; i<count; i++) {
+ for (j = 0; j < size; j++) {
+ for (i = 0; i < count; i++) {
if (*p != rank * size + j + i) {
errs++;
if (errs < 10) {
- fprintf( stderr, "Error (MPI_IN_PLACE) with communicator %s and size=%d count=%d\n",
- MTestGetIntracommName(), size, count );
- fprintf(stderr, "recvbuf[%d,%d] = %d, should be %d\n",
- j,i, *p, rank * size + j + i );
+ fprintf(stderr,
+ "Error (MPI_IN_PLACE) with communicator %s and size=%d count=%d\n",
+ MTestGetIntracommName(), size, count);
+ fprintf(stderr, "recvbuf[%d,%d] = %d, should be %d\n", j, i, *p,
+ rank * size + j + i);
}
}
p++;
@@ -110,13 +111,13 @@ int main( int argc, char *argv[] )
}
#endif
- free( recvbuf );
- free( sendbuf );
- }
- MTestFreeComm( &comm );
+ free(recvbuf);
+ free(sendbuf);
+ }
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/alltoallv.c b/test/mpi/coll/alltoallv.c
index bcae133..bc286c2 100644
--- a/test/mpi/coll/alltoallv.c
+++ b/test/mpi/coll/alltoallv.c
@@ -15,122 +15,121 @@
Because there are separate send and receive types to alltoallv,
there need to be tests to rearrange data on the fly. Not done yet.
-
+
The first test sends i items to processor i from all processors.
Currently, the test uses only MPI_INT; this is adequate for testing systems
that use point-to-point operations
*/
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
MPI_Comm comm;
- int *sbuf, *rbuf;
- int rank, size;
- int *sendcounts, *recvcounts, *rdispls, *sdispls;
- int i, j, *p, err;
-
- MTest_Init( &argc, &argv );
+ int *sbuf, *rbuf;
+ int rank, size;
+ int *sendcounts, *recvcounts, *rdispls, *sdispls;
+ int i, j, *p, err;
+
+ MTest_Init(&argc, &argv);
err = 0;
-
- while (MTestGetIntracommGeneral( &comm, 2, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
-
- /* Create the buffer */
- MPI_Comm_size( comm, &size );
- MPI_Comm_rank( comm, &rank );
- sbuf = (int *)malloc( size * size * sizeof(int) );
- rbuf = (int *)malloc( size * size * sizeof(int) );
- if (!sbuf || !rbuf) {
- fprintf( stderr, "Could not allocated buffers!\n" );
- MPI_Abort( comm, 1 );
- }
-
- /* Load up the buffers */
- for (i=0; i<size*size; i++) {
- sbuf[i] = i + 100*rank;
- rbuf[i] = -i;
- }
-
- /* Create and load the arguments to alltoallv */
- sendcounts = (int *)malloc( size * sizeof(int) );
- recvcounts = (int *)malloc( size * sizeof(int) );
- rdispls = (int *)malloc( size * sizeof(int) );
- sdispls = (int *)malloc( size * sizeof(int) );
- if (!sendcounts || !recvcounts || !rdispls || !sdispls) {
- fprintf( stderr, "Could not allocate arg items!\n" );
- MPI_Abort( comm, 1 );
- }
- for (i=0; i<size; i++) {
- sendcounts[i] = i;
- recvcounts[i] = rank;
- rdispls[i] = i * rank;
- sdispls[i] = (i * (i+1))/2;
- }
- MPI_Alltoallv( sbuf, sendcounts, sdispls, MPI_INT,
- rbuf, recvcounts, rdispls, MPI_INT, comm );
-
- /* Check rbuf */
- for (i=0; i<size; i++) {
- p = rbuf + rdispls[i];
- for (j=0; j<rank; j++) {
- if (p[j] != i * 100 + (rank*(rank+1))/2 + j) {
- fprintf( stderr, "[%d] got %d expected %d for %dth\n",
- rank, p[j],(i*(i+1))/2 + j, j );
- err++;
- }
- }
- }
-
- free( sdispls );
- free( sendcounts );
- free( sbuf );
+
+ while (MTestGetIntracommGeneral(&comm, 2, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+
+ /* Create the buffer */
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
+ sbuf = (int *) malloc(size * size * sizeof(int));
+ rbuf = (int *) malloc(size * size * sizeof(int));
+ if (!sbuf || !rbuf) {
+ fprintf(stderr, "Could not allocated buffers!\n");
+ MPI_Abort(comm, 1);
+ }
+
+ /* Load up the buffers */
+ for (i = 0; i < size * size; i++) {
+ sbuf[i] = i + 100 * rank;
+ rbuf[i] = -i;
+ }
+
+ /* Create and load the arguments to alltoallv */
+ sendcounts = (int *) malloc(size * sizeof(int));
+ recvcounts = (int *) malloc(size * sizeof(int));
+ rdispls = (int *) malloc(size * sizeof(int));
+ sdispls = (int *) malloc(size * sizeof(int));
+ if (!sendcounts || !recvcounts || !rdispls || !sdispls) {
+ fprintf(stderr, "Could not allocate arg items!\n");
+ MPI_Abort(comm, 1);
+ }
+ for (i = 0; i < size; i++) {
+ sendcounts[i] = i;
+ recvcounts[i] = rank;
+ rdispls[i] = i * rank;
+ sdispls[i] = (i * (i + 1)) / 2;
+ }
+ MPI_Alltoallv(sbuf, sendcounts, sdispls, MPI_INT, rbuf, recvcounts, rdispls, MPI_INT, comm);
+
+ /* Check rbuf */
+ for (i = 0; i < size; i++) {
+ p = rbuf + rdispls[i];
+ for (j = 0; j < rank; j++) {
+ if (p[j] != i * 100 + (rank * (rank + 1)) / 2 + j) {
+ fprintf(stderr, "[%d] got %d expected %d for %dth\n",
+ rank, p[j], (i * (i + 1)) / 2 + j, j);
+ err++;
+ }
+ }
+ }
+
+ free(sdispls);
+ free(sendcounts);
+ free(sbuf);
#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
- /* check MPI_IN_PLACE, added in MPI-2.2 */
- free( rbuf );
- rbuf = (int *)malloc( size * (2 * size) * sizeof(int) );
- if (!rbuf) {
- fprintf( stderr, "Could not reallocate rbuf!\n" );
- MPI_Abort( comm, 1 );
- }
-
- /* Load up the buffers */
- for (i = 0; i < size; i++) {
- recvcounts[i] = i + rank;
- rdispls[i] = i * (2 * size);
- }
- memset(rbuf, -1, size * (2 * size) * sizeof(int));
- for (i=0; i < size; i++) {
- p = rbuf + rdispls[i];
- for (j = 0; j < recvcounts[i]; ++j) {
- p[j] = 100 * rank + 10 * i + j;
+ /* check MPI_IN_PLACE, added in MPI-2.2 */
+ free(rbuf);
+ rbuf = (int *) malloc(size * (2 * size) * sizeof(int));
+ if (!rbuf) {
+ fprintf(stderr, "Could not reallocate rbuf!\n");
+ MPI_Abort(comm, 1);
+ }
+
+ /* Load up the buffers */
+ for (i = 0; i < size; i++) {
+ recvcounts[i] = i + rank;
+ rdispls[i] = i * (2 * size);
+ }
+ memset(rbuf, -1, size * (2 * size) * sizeof(int));
+ for (i = 0; i < size; i++) {
+ p = rbuf + rdispls[i];
+ for (j = 0; j < recvcounts[i]; ++j) {
+ p[j] = 100 * rank + 10 * i + j;
+ }
}
- }
- MPI_Alltoallv( MPI_IN_PLACE, NULL, NULL, MPI_INT,
- rbuf, recvcounts, rdispls, MPI_INT, comm );
- /* Check rbuf */
- for (i=0; i<size; i++) {
- p = rbuf + rdispls[i];
- for (j=0; j<recvcounts[i]; j++) {
- int expected = 100 * i + 10 * rank + j;
- if (p[j] != expected) {
- fprintf(stderr, "[%d] got %d expected %d for block=%d, element=%dth\n",
- rank, p[j], expected, i, j);
- ++err;
- }
+ MPI_Alltoallv(MPI_IN_PLACE, NULL, NULL, MPI_INT, rbuf, recvcounts, rdispls, MPI_INT, comm);
+ /* Check rbuf */
+ for (i = 0; i < size; i++) {
+ p = rbuf + rdispls[i];
+ for (j = 0; j < recvcounts[i]; j++) {
+ int expected = 100 * i + 10 * rank + j;
+ if (p[j] != expected) {
+ fprintf(stderr, "[%d] got %d expected %d for block=%d, element=%dth\n",
+ rank, p[j], expected, i, j);
+ ++err;
+ }
+ }
}
- }
#endif
- free( rdispls );
- free( recvcounts );
- free( rbuf );
- MTestFreeComm( &comm );
+ free(rdispls);
+ free(recvcounts);
+ free(rbuf);
+ MTestFreeComm(&comm);
}
- MTest_Finalize( err );
+ MTest_Finalize(err);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/alltoallv0.c b/test/mpi/coll/alltoallv0.c
index e1c8785..a771c76 100644
--- a/test/mpi/coll/alltoallv0.c
+++ b/test/mpi/coll/alltoallv0.c
@@ -9,124 +9,126 @@
#include <stdio.h>
/*
- This program tests MPI_Alltoallv by having processor each process
+ This program tests MPI_Alltoallv by having processor each process
send data to two neighbors only, using counts of 0 for the other processes.
This idiom is sometimes used for halo exchange operations.
Because there are separate send and receive types to alltoallv,
there need to be tests to rearrange data on the fly. Not done yet.
-
+
Currently, the test uses only MPI_INT; this is adequate for testing systems
that use point-to-point operations
*/
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
MPI_Comm comm;
- int *sbuf, *rbuf;
- int rank, size;
- int *sendcounts, *recvcounts, *rdispls, *sdispls;
- int i, *p, err;
- int left, right, length;
-
- MTest_Init( &argc, &argv );
+ int *sbuf, *rbuf;
+ int rank, size;
+ int *sendcounts, *recvcounts, *rdispls, *sdispls;
+ int i, *p, err;
+ int left, right, length;
+
+ MTest_Init(&argc, &argv);
err = 0;
-
- while (MTestGetIntracommGeneral( &comm, 2, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
-
- MPI_Comm_size( comm, &size );
- MPI_Comm_rank( comm, &rank );
-
- if (size < 3) continue;
-
- /* Create and load the arguments to alltoallv */
- sendcounts = (int *)malloc( size * sizeof(int) );
- recvcounts = (int *)malloc( size * sizeof(int) );
- rdispls = (int *)malloc( size * sizeof(int) );
- sdispls = (int *)malloc( size * sizeof(int) );
- if (!sendcounts || !recvcounts || !rdispls || !sdispls) {
- fprintf( stderr, "Could not allocate arg items!\n" );
- MPI_Abort( comm, 1 );
- }
-
- /* Get the neighbors */
- left = (rank - 1 + size) % size;
- right = (rank + 1) % size;
-
- /* Set the defaults */
- for (i=0; i<size; i++) {
- sendcounts[i] = 0;
- recvcounts[i] = 0;
- rdispls[i] = 0;
- sdispls[i] = 0;
- }
-
- for (length=1; length < 66000; length = length*2+1 ) {
- /* Get the buffers */
- sbuf = (int *)malloc( 2 * length * sizeof(int) );
- rbuf = (int *)malloc( 2 * length * sizeof(int) );
- if (!sbuf || !rbuf) {
- fprintf( stderr, "Could not allocate buffers!\n" );
- MPI_Abort( comm, 1 );
- }
-
- /* Load up the buffers */
- for (i=0; i<length; i++) {
- sbuf[i] = i + 100000*rank;
- sbuf[i+length] = i + 100000*rank;
- rbuf[i] = -i;
- rbuf[i+length] = -i-length;
- }
- sendcounts[left] = length;
- sendcounts[right] = length;
- recvcounts[left] = length;
- recvcounts[right] = length;
- rdispls[left] = 0;
- rdispls[right] = length;
- sdispls[left] = 0;
- sdispls[right] = length;
-
- MPI_Alltoallv( sbuf, sendcounts, sdispls, MPI_INT,
- rbuf, recvcounts, rdispls, MPI_INT, comm );
-
- /* Check rbuf */
- p = rbuf; /* left */
-
- for (i=0; i<length; i++) {
- if (p[i] != i + 100000 * left) {
- if (err < 10) {
- fprintf( stderr, "[%d from %d] got %d expected %d for %dth\n",
- rank, left, p[i], i + 100000 * left, i );
- }
- err++;
- }
- }
-
- p = rbuf + length; /* right */
- for (i=0; i<length; i++) {
- if (p[i] != i + 100000 * right) {
- if (err < 10) {
- fprintf( stderr, "[%d from %d] got %d expected %d for %dth\n",
- rank, right, p[i], i + 100000 * right, i );
- }
- err++;
- }
- }
-
- free( rbuf );
- free( sbuf );
- }
-
- free( sdispls );
- free( rdispls );
- free( recvcounts );
- free( sendcounts );
- MTestFreeComm( &comm );
+
+ while (MTestGetIntracommGeneral(&comm, 2, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
+
+ if (size < 3)
+ continue;
+
+ /* Create and load the arguments to alltoallv */
+ sendcounts = (int *) malloc(size * sizeof(int));
+ recvcounts = (int *) malloc(size * sizeof(int));
+ rdispls = (int *) malloc(size * sizeof(int));
+ sdispls = (int *) malloc(size * sizeof(int));
+ if (!sendcounts || !recvcounts || !rdispls || !sdispls) {
+ fprintf(stderr, "Could not allocate arg items!\n");
+ MPI_Abort(comm, 1);
+ }
+
+ /* Get the neighbors */
+ left = (rank - 1 + size) % size;
+ right = (rank + 1) % size;
+
+ /* Set the defaults */
+ for (i = 0; i < size; i++) {
+ sendcounts[i] = 0;
+ recvcounts[i] = 0;
+ rdispls[i] = 0;
+ sdispls[i] = 0;
+ }
+
+ for (length = 1; length < 66000; length = length * 2 + 1) {
+ /* Get the buffers */
+ sbuf = (int *) malloc(2 * length * sizeof(int));
+ rbuf = (int *) malloc(2 * length * sizeof(int));
+ if (!sbuf || !rbuf) {
+ fprintf(stderr, "Could not allocate buffers!\n");
+ MPI_Abort(comm, 1);
+ }
+
+ /* Load up the buffers */
+ for (i = 0; i < length; i++) {
+ sbuf[i] = i + 100000 * rank;
+ sbuf[i + length] = i + 100000 * rank;
+ rbuf[i] = -i;
+ rbuf[i + length] = -i - length;
+ }
+ sendcounts[left] = length;
+ sendcounts[right] = length;
+ recvcounts[left] = length;
+ recvcounts[right] = length;
+ rdispls[left] = 0;
+ rdispls[right] = length;
+ sdispls[left] = 0;
+ sdispls[right] = length;
+
+ MPI_Alltoallv(sbuf, sendcounts, sdispls, MPI_INT,
+ rbuf, recvcounts, rdispls, MPI_INT, comm);
+
+ /* Check rbuf */
+ p = rbuf; /* left */
+
+ for (i = 0; i < length; i++) {
+ if (p[i] != i + 100000 * left) {
+ if (err < 10) {
+ fprintf(stderr, "[%d from %d] got %d expected %d for %dth\n",
+ rank, left, p[i], i + 100000 * left, i);
+ }
+ err++;
+ }
+ }
+
+ p = rbuf + length; /* right */
+ for (i = 0; i < length; i++) {
+ if (p[i] != i + 100000 * right) {
+ if (err < 10) {
+ fprintf(stderr, "[%d from %d] got %d expected %d for %dth\n",
+ rank, right, p[i], i + 100000 * right, i);
+ }
+ err++;
+ }
+ }
+
+ free(rbuf);
+ free(sbuf);
+ }
+
+ free(sdispls);
+ free(rdispls);
+ free(recvcounts);
+ free(sendcounts);
+ MTestFreeComm(&comm);
}
- MTest_Finalize( err );
+ MTest_Finalize(err);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/alltoallw1.c b/test/mpi/coll/alltoallw1.c
index ba655ab..fe5fd00 100644
--- a/test/mpi/coll/alltoallw1.c
+++ b/test/mpi/coll/alltoallw1.c
@@ -6,10 +6,10 @@
*/
/*
- * This example is taken from MPI-The complete reference, Vol 1,
+ * This example is taken from MPI-The complete reference, Vol 1,
* pages 222-224.
- *
- * Lines after the "--CUT HERE--" were added to make this into a complete
+ *
+ * Lines after the "--CUT HERE--" were added to make this into a complete
* test program.
*/
@@ -27,241 +27,239 @@ MPI_Datatype transpose_type(int M, int m, int n, MPI_Datatype type);
MPI_Datatype submatrix_type(int N, int m, int n, MPI_Datatype type);
void Transpose(float *localA, float *localB, int M, int N, MPI_Comm comm);
void Transpose(float *localA, float *localB, int M, int N, MPI_Comm comm)
-/* transpose MxN matrix A that is block distributed (1-D) on
+/* transpose MxN matrix A that is block distributed (1-D) on
processes of comm onto block distributed matrix B */
{
- int i, j, extent, myrank, p, n[2], m[2];
- int lasti, lastj;
- int *sendcounts, *recvcounts;
- int *sdispls, *rdispls;
- MPI_Datatype xtype[2][2], stype[2][2], *sendtypes, *recvtypes;
-
- MTestPrintfMsg( 2, "M = %d, N = %d\n", M, N );
-
- /* compute parameters */
- MPI_Comm_size(comm, &p);
- MPI_Comm_rank(comm, &myrank);
- extent = sizeof(float);
-
- /* allocate arrays */
- sendcounts = (int *)malloc(p*sizeof(int));
- recvcounts = (int *)malloc(p*sizeof(int));
- sdispls = (int *)malloc(p*sizeof(int));
- rdispls = (int *)malloc(p*sizeof(int));
- sendtypes = (MPI_Datatype *)malloc(p*sizeof(MPI_Datatype));
- recvtypes = (MPI_Datatype *)malloc(p*sizeof(MPI_Datatype));
-
- /* compute block sizes */
- m[0] = M/p;
- m[1] = M - (p-1)*(M/p);
- n[0] = N/p;
- n[1] = N - (p-1)*(N/p);
-
- /* compute types */
- for (i=0; i <= 1; i++)
- for (j=0; j <= 1; j++) {
- xtype[i][j] = transpose_type(N, m[i], n[j], MPI_FLOAT);
- stype[i][j] = submatrix_type(M, m[i], n[j], MPI_FLOAT);
- }
-
- /* prepare collective operation arguments */
- lasti = myrank == p-1;
- for (j=0; j < p; j++) {
- lastj = j == p-1;
- sendcounts[j] = 1;
- sdispls[j] = j*n[0]*extent;
- sendtypes[j] = xtype[lasti][lastj];
- recvcounts[j] = 1;
- rdispls[j] = j*m[0]*extent;
- recvtypes[j] = stype[lastj][lasti];
- }
-
- /* communicate */
- MTestPrintfMsg( 2, "Begin Alltoallw...\n" );
- /* -- Note that the book incorrectly uses &localA and &localB
- as arguments to MPI_Alltoallw */
- MPI_Alltoallw(localA, sendcounts, sdispls, sendtypes,
- localB, recvcounts, rdispls, recvtypes, comm);
- MTestPrintfMsg( 2, "Done with Alltoallw\n" );
-
- /* Free buffers */
- free( sendcounts );
- free( recvcounts );
- free( sdispls );
- free( rdispls );
- free( sendtypes );
- free( recvtypes );
-
- /* Free datatypes */
- for (i=0; i <= 1; i++)
- for (j=0; j <= 1; j++) {
- MPI_Type_free( &xtype[i][j] );
- MPI_Type_free( &stype[i][j] );
- }
+ int i, j, extent, myrank, p, n[2], m[2];
+ int lasti, lastj;
+ int *sendcounts, *recvcounts;
+ int *sdispls, *rdispls;
+ MPI_Datatype xtype[2][2], stype[2][2], *sendtypes, *recvtypes;
+
+ MTestPrintfMsg(2, "M = %d, N = %d\n", M, N);
+
+ /* compute parameters */
+ MPI_Comm_size(comm, &p);
+ MPI_Comm_rank(comm, &myrank);
+ extent = sizeof(float);
+
+ /* allocate arrays */
+ sendcounts = (int *) malloc(p * sizeof(int));
+ recvcounts = (int *) malloc(p * sizeof(int));
+ sdispls = (int *) malloc(p * sizeof(int));
+ rdispls = (int *) malloc(p * sizeof(int));
+ sendtypes = (MPI_Datatype *) malloc(p * sizeof(MPI_Datatype));
+ recvtypes = (MPI_Datatype *) malloc(p * sizeof(MPI_Datatype));
+
+ /* compute block sizes */
+ m[0] = M / p;
+ m[1] = M - (p - 1) * (M / p);
+ n[0] = N / p;
+ n[1] = N - (p - 1) * (N / p);
+
+ /* compute types */
+ for (i = 0; i <= 1; i++)
+ for (j = 0; j <= 1; j++) {
+ xtype[i][j] = transpose_type(N, m[i], n[j], MPI_FLOAT);
+ stype[i][j] = submatrix_type(M, m[i], n[j], MPI_FLOAT);
+ }
+
+ /* prepare collective operation arguments */
+ lasti = myrank == p - 1;
+ for (j = 0; j < p; j++) {
+ lastj = j == p - 1;
+ sendcounts[j] = 1;
+ sdispls[j] = j * n[0] * extent;
+ sendtypes[j] = xtype[lasti][lastj];
+ recvcounts[j] = 1;
+ rdispls[j] = j * m[0] * extent;
+ recvtypes[j] = stype[lastj][lasti];
+ }
+
+ /* communicate */
+ MTestPrintfMsg(2, "Begin Alltoallw...\n");
+ /* -- Note that the book incorrectly uses &localA and &localB
+ * as arguments to MPI_Alltoallw */
+ MPI_Alltoallw(localA, sendcounts, sdispls, sendtypes,
+ localB, recvcounts, rdispls, recvtypes, comm);
+ MTestPrintfMsg(2, "Done with Alltoallw\n");
+
+ /* Free buffers */
+ free(sendcounts);
+ free(recvcounts);
+ free(sdispls);
+ free(rdispls);
+ free(sendtypes);
+ free(recvtypes);
+
+ /* Free datatypes */
+ for (i = 0; i <= 1; i++)
+ for (j = 0; j <= 1; j++) {
+ MPI_Type_free(&xtype[i][j]);
+ MPI_Type_free(&stype[i][j]);
+ }
}
-/* Define an n x m submatrix in a n x M local matrix (this is the
+/* Define an n x m submatrix in a n x M local matrix (this is the
destination in the transpose matrix */
MPI_Datatype submatrix_type(int M, int m, int n, MPI_Datatype type)
-/* computes a datatype for an mxn submatrix within an MxN matrix
+/* computes a datatype for an mxn submatrix within an MxN matrix
with entries of type type */
{
- /* MPI_Datatype subrow; */
- MPI_Datatype submatrix;
-
- /* The book, MPI: The Complete Reference, has the wrong type constructor
- here. Since the stride in the vector type is relative to the input
- type, the stride in the book's code is n times as long as is intended.
- Since n may not exactly divide N, it is better to simply use the
- blocklength argument in Type_vector */
- /*
- MPI_Type_contiguous(n, type, &subrow);
- MPI_Type_vector(m, 1, N, subrow, &submatrix);
- */
- MPI_Type_vector(n, m, M, type, &submatrix );
- MPI_Type_commit(&submatrix);
-
- /* Add a consistency test: the size of submatrix should be
- n * m * sizeof(type) and the extent should be ((n-1)*M+m) * sizeof(type) */
- {
- int tsize;
- MPI_Aint textent, lb;
- MPI_Type_size( type, &tsize );
- MPI_Type_get_extent( submatrix, &lb, &textent );
-
- if (textent != tsize * (M * (n-1)+m)) {
- fprintf( stderr, "Submatrix extent is %ld, expected %ld (%d,%d,%d)\n",
- (long)textent, (long)(tsize * (M * (n-1)+m)), M, n, m );
- }
- }
- return(submatrix);
+ /* MPI_Datatype subrow; */
+ MPI_Datatype submatrix;
+
+ /* The book, MPI: The Complete Reference, has the wrong type constructor
+ * here. Since the stride in the vector type is relative to the input
+ * type, the stride in the book's code is n times as long as is intended.
+ * Since n may not exactly divide N, it is better to simply use the
+ * blocklength argument in Type_vector */
+ /*
+ * MPI_Type_contiguous(n, type, &subrow);
+ * MPI_Type_vector(m, 1, N, subrow, &submatrix);
+ */
+ MPI_Type_vector(n, m, M, type, &submatrix);
+ MPI_Type_commit(&submatrix);
+
+ /* Add a consistency test: the size of submatrix should be
+ * n * m * sizeof(type) and the extent should be ((n-1)*M+m) * sizeof(type) */
+ {
+ int tsize;
+ MPI_Aint textent, lb;
+ MPI_Type_size(type, &tsize);
+ MPI_Type_get_extent(submatrix, &lb, &textent);
+
+ if (textent != tsize * (M * (n - 1) + m)) {
+ fprintf(stderr, "Submatrix extent is %ld, expected %ld (%d,%d,%d)\n",
+ (long) textent, (long) (tsize * (M * (n - 1) + m)), M, n, m);
+ }
+ }
+ return (submatrix);
}
/* Extract an m x n submatrix within an m x N matrix and transpose it.
Assume storage by rows; the defined datatype accesses by columns */
MPI_Datatype transpose_type(int N, int m, int n, MPI_Datatype type)
-/* computes a datatype for the transpose of an mxn matrix
+/* computes a datatype for the transpose of an mxn matrix
with entries of type type */
{
- MPI_Datatype subrow, subrow1, submatrix;
- MPI_Aint lb, extent;
-
- MPI_Type_vector(m, 1, N, type, &subrow);
- MPI_Type_get_extent(type, &lb, &extent);
- MPI_Type_create_resized(subrow, 0, extent, &subrow1);
- MPI_Type_contiguous(n, subrow1, &submatrix);
- MPI_Type_commit(&submatrix);
- MPI_Type_free( &subrow );
- MPI_Type_free( &subrow1 );
-
- /* Add a consistency test: the size of submatrix should be
- n * m * sizeof(type) and the extent should be ((m-1)*N+n) * sizeof(type) */
- {
- int tsize;
- MPI_Aint textent, llb;
- MPI_Type_size( type, &tsize );
- MPI_Type_get_true_extent( submatrix, &llb, &textent );
-
- if (textent != tsize * (N * (m-1)+n)) {
- fprintf( stderr, "Transpose Submatrix extent is %ld, expected %ld (%d,%d,%d)\n",
- (long)textent, (long)(tsize * (N * (m-1)+n)), N, n, m );
- }
- }
-
- return(submatrix);
+ MPI_Datatype subrow, subrow1, submatrix;
+ MPI_Aint lb, extent;
+
+ MPI_Type_vector(m, 1, N, type, &subrow);
+ MPI_Type_get_extent(type, &lb, &extent);
+ MPI_Type_create_resized(subrow, 0, extent, &subrow1);
+ MPI_Type_contiguous(n, subrow1, &submatrix);
+ MPI_Type_commit(&submatrix);
+ MPI_Type_free(&subrow);
+ MPI_Type_free(&subrow1);
+
+ /* Add a consistency test: the size of submatrix should be
+ * n * m * sizeof(type) and the extent should be ((m-1)*N+n) * sizeof(type) */
+ {
+ int tsize;
+ MPI_Aint textent, llb;
+ MPI_Type_size(type, &tsize);
+ MPI_Type_get_true_extent(submatrix, &llb, &textent);
+
+ if (textent != tsize * (N * (m - 1) + n)) {
+ fprintf(stderr, "Transpose Submatrix extent is %ld, expected %ld (%d,%d,%d)\n",
+ (long) textent, (long) (tsize * (N * (m - 1) + n)), N, n, m);
+ }
+ }
+
+ return (submatrix);
}
/* -- CUT HERE -- */
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int gM, gN, lm, lmlast, ln, lnlast, i, j, errs = 0;
int size, rank;
float *localA, *localB;
MPI_Comm comm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
-
- MPI_Comm_size( comm, &size );
- MPI_Comm_rank( comm, &rank );
+
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
gM = 20;
gN = 30;
- /* Each block is lm x ln in size, except for the last process,
- which has lmlast x lnlast */
- lm = gM/size;
- lmlast = gM - (size - 1)*lm;
- ln = gN/size;
- lnlast = gN - (size - 1)*ln;
+ /* Each block is lm x ln in size, except for the last process,
+ * which has lmlast x lnlast */
+ lm = gM / size;
+ lmlast = gM - (size - 1) * lm;
+ ln = gN / size;
+ lnlast = gN - (size - 1) * ln;
/* Create the local matrices.
- Initialize the input matrix so that the entries are
- consequtive integers, by row, starting at 0.
+ * Initialize the input matrix so that the entries are
+ * consequtive integers, by row, starting at 0.
*/
if (rank == size - 1) {
- localA = (float *)malloc( gN * lmlast * sizeof(float) );
- localB = (float *)malloc( gM * lnlast * sizeof(float) );
- for (i=0; i<lmlast; i++) {
- for (j=0; j<gN; j++) {
- localA[i*gN+j] = (float)(i*gN+j + rank * gN * lm);
- }
- }
-
+ localA = (float *) malloc(gN * lmlast * sizeof(float));
+ localB = (float *) malloc(gM * lnlast * sizeof(float));
+ for (i = 0; i < lmlast; i++) {
+ for (j = 0; j < gN; j++) {
+ localA[i * gN + j] = (float) (i * gN + j + rank * gN * lm);
+ }
+ }
+
}
else {
- localA = (float *)malloc( gN * lm * sizeof(float) );
- localB = (float *)malloc( gM * ln * sizeof(float) );
- for (i=0; i<lm; i++) {
- for (j=0; j<gN; j++) {
- localA[i*gN+j] = (float)(i*gN+j + rank * gN * lm);
- }
- }
+ localA = (float *) malloc(gN * lm * sizeof(float));
+ localB = (float *) malloc(gM * ln * sizeof(float));
+ for (i = 0; i < lm; i++) {
+ for (j = 0; j < gN; j++) {
+ localA[i * gN + j] = (float) (i * gN + j + rank * gN * lm);
+ }
+ }
}
- MTestPrintfMsg( 2, "Allocated local arrays\n" );
+ MTestPrintfMsg(2, "Allocated local arrays\n");
/* Transpose */
- Transpose( localA, localB, gM, gN, comm );
+ Transpose(localA, localB, gM, gN, comm);
/* check the transposed matrix
- In the global matrix, the transpose has consequtive integers,
- organized by columns.
+ * In the global matrix, the transpose has consequtive integers,
+ * organized by columns.
*/
if (rank == size - 1) {
- for (i=0; i<lnlast; i++) {
- for (j=0; j<gM; j++) {
- int expected = i+gN*j + rank * ln;
- if ((int)localB[i*gM+j] != expected) {
- if (errs < MAX_ERRORS)
- printf( "Found %d but expected %d\n",
- (int)localB[i*gM+j], expected );
- errs++;
- }
- }
- }
-
+ for (i = 0; i < lnlast; i++) {
+ for (j = 0; j < gM; j++) {
+ int expected = i + gN * j + rank * ln;
+ if ((int) localB[i * gM + j] != expected) {
+ if (errs < MAX_ERRORS)
+ printf("Found %d but expected %d\n", (int) localB[i * gM + j], expected);
+ errs++;
+ }
+ }
+ }
+
}
else {
- for (i=0; i<ln; i++) {
- for (j=0; j<gM; j++) {
- int expected = i+gN*j + rank * ln;
- if ((int)localB[i*gM+j] != expected) {
- if (errs < MAX_ERRORS)
- printf( "Found %d but expected %d\n",
- (int)localB[i*gM+j], expected );
- errs++;
- }
- }
- }
+ for (i = 0; i < ln; i++) {
+ for (j = 0; j < gM; j++) {
+ int expected = i + gN * j + rank * ln;
+ if ((int) localB[i * gM + j] != expected) {
+ if (errs < MAX_ERRORS)
+ printf("Found %d but expected %d\n", (int) localB[i * gM + j], expected);
+ errs++;
+ }
+ }
+ }
}
/* Free storage */
- free( localA );
- free( localB );
+ free(localA);
+ free(localB);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
diff --git a/test/mpi/coll/alltoallw2.c b/test/mpi/coll/alltoallw2.c
index 7d40236..379cdae 100644
--- a/test/mpi/coll/alltoallw2.c
+++ b/test/mpi/coll/alltoallw2.c
@@ -16,133 +16,133 @@
Because there are separate send and receive types to alltoallw,
there need to be tests to rearrange data on the fly. Not done yet.
-
+
The first test sends i items to processor i from all processors.
Currently, the test uses only MPI_INT; this is adequate for testing systems
that use point-to-point operations
*/
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
MPI_Comm comm;
- int *sbuf, *rbuf;
- int rank, size;
- int *sendcounts, *recvcounts, *rdispls, *sdispls;
- int i, j, *p, err;
+ int *sbuf, *rbuf;
+ int rank, size;
+ int *sendcounts, *recvcounts, *rdispls, *sdispls;
+ int i, j, *p, err;
MPI_Datatype *sendtypes, *recvtypes;
-
- MTest_Init( &argc, &argv );
+
+ MTest_Init(&argc, &argv);
err = 0;
-
- while (MTestGetIntracommGeneral( &comm, 2, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
-
- /* Create the buffer */
- MPI_Comm_size( comm, &size );
- MPI_Comm_rank( comm, &rank );
- sbuf = (int *)malloc( size * size * sizeof(int) );
- rbuf = (int *)malloc( size * size * sizeof(int) );
- if (!sbuf || !rbuf) {
- fprintf( stderr, "Could not allocated buffers!\n" );
- MPI_Abort( comm, 1 );
- }
-
- /* Load up the buffers */
- for (i=0; i<size*size; i++) {
- sbuf[i] = i + 100*rank;
- rbuf[i] = -i;
- }
-
- /* Create and load the arguments to alltoallv */
- sendcounts = (int *)malloc( size * sizeof(int) );
- recvcounts = (int *)malloc( size * sizeof(int) );
- rdispls = (int *)malloc( size * sizeof(int) );
- sdispls = (int *)malloc( size * sizeof(int) );
- sendtypes = (MPI_Datatype *)malloc( size * sizeof(MPI_Datatype) );
- recvtypes = (MPI_Datatype *)malloc( size * sizeof(MPI_Datatype) );
- if (!sendcounts || !recvcounts || !rdispls || !sdispls || !sendtypes || !recvtypes) {
- fprintf( stderr, "Could not allocate arg items!\n" );
- MPI_Abort( comm, 1 );
- }
- /* Note that process 0 sends no data (sendcounts[0] = 0) */
- for (i=0; i<size; i++) {
- sendcounts[i] = i;
- recvcounts[i] = rank;
- rdispls[i] = i * rank * sizeof(int);
- sdispls[i] = (((i+1) * (i))/2) * sizeof(int);
- sendtypes[i] = recvtypes[i] = MPI_INT;
- }
- MPI_Alltoallw( sbuf, sendcounts, sdispls, sendtypes,
- rbuf, recvcounts, rdispls, recvtypes, comm );
-
- /* Check rbuf */
- for (i=0; i<size; i++) {
- p = rbuf + rdispls[i]/sizeof(int);
- for (j=0; j<rank; j++) {
- if (p[j] != i * 100 + (rank*(rank+1))/2 + j) {
- fprintf( stderr, "[%d] got %d expected %d for %dth\n",
- rank, p[j],(i*(i+1))/2 + j, j );
- err++;
- }
- }
- }
-
- free(sendtypes);
- free(sdispls);
- free(sendcounts);
- free(sbuf);
+
+ while (MTestGetIntracommGeneral(&comm, 2, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+
+ /* Create the buffer */
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
+ sbuf = (int *) malloc(size * size * sizeof(int));
+ rbuf = (int *) malloc(size * size * sizeof(int));
+ if (!sbuf || !rbuf) {
+ fprintf(stderr, "Could not allocated buffers!\n");
+ MPI_Abort(comm, 1);
+ }
+
+ /* Load up the buffers */
+ for (i = 0; i < size * size; i++) {
+ sbuf[i] = i + 100 * rank;
+ rbuf[i] = -i;
+ }
+
+ /* Create and load the arguments to alltoallv */
+ sendcounts = (int *) malloc(size * sizeof(int));
+ recvcounts = (int *) malloc(size * sizeof(int));
+ rdispls = (int *) malloc(size * sizeof(int));
+ sdispls = (int *) malloc(size * sizeof(int));
+ sendtypes = (MPI_Datatype *) malloc(size * sizeof(MPI_Datatype));
+ recvtypes = (MPI_Datatype *) malloc(size * sizeof(MPI_Datatype));
+ if (!sendcounts || !recvcounts || !rdispls || !sdispls || !sendtypes || !recvtypes) {
+ fprintf(stderr, "Could not allocate arg items!\n");
+ MPI_Abort(comm, 1);
+ }
+ /* Note that process 0 sends no data (sendcounts[0] = 0) */
+ for (i = 0; i < size; i++) {
+ sendcounts[i] = i;
+ recvcounts[i] = rank;
+ rdispls[i] = i * rank * sizeof(int);
+ sdispls[i] = (((i + 1) * (i)) / 2) * sizeof(int);
+ sendtypes[i] = recvtypes[i] = MPI_INT;
+ }
+ MPI_Alltoallw(sbuf, sendcounts, sdispls, sendtypes,
+ rbuf, recvcounts, rdispls, recvtypes, comm);
+
+ /* Check rbuf */
+ for (i = 0; i < size; i++) {
+ p = rbuf + rdispls[i] / sizeof(int);
+ for (j = 0; j < rank; j++) {
+ if (p[j] != i * 100 + (rank * (rank + 1)) / 2 + j) {
+ fprintf(stderr, "[%d] got %d expected %d for %dth\n",
+ rank, p[j], (i * (i + 1)) / 2 + j, j);
+ err++;
+ }
+ }
+ }
+
+ free(sendtypes);
+ free(sdispls);
+ free(sendcounts);
+ free(sbuf);
#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
- /* check MPI_IN_PLACE, added in MPI-2.2 */
- free( rbuf );
- rbuf = (int *)malloc( size * (2 * size) * sizeof(int) );
- if (!rbuf) {
- fprintf( stderr, "Could not reallocate rbuf!\n" );
- MPI_Abort( comm, 1 );
- }
-
- /* Load up the buffers */
- for (i = 0; i < size; i++) {
- /* alltoallw displs are in bytes, not in type extents */
- rdispls[i] = i * (2 * size) * sizeof(int);
- recvtypes[i] = MPI_INT;
- recvcounts[i] = i + rank;
- }
- memset(rbuf, -1, size * (2 * size) * sizeof(int));
- for (i=0; i < size; i++) {
- p = rbuf + (rdispls[i] / sizeof(int));
- for (j = 0; j < recvcounts[i]; ++j) {
- p[j] = 100 * rank + 10 * i + j;
+ /* check MPI_IN_PLACE, added in MPI-2.2 */
+ free(rbuf);
+ rbuf = (int *) malloc(size * (2 * size) * sizeof(int));
+ if (!rbuf) {
+ fprintf(stderr, "Could not reallocate rbuf!\n");
+ MPI_Abort(comm, 1);
}
- }
-
- MPI_Alltoallw( MPI_IN_PLACE, NULL, NULL, NULL,
- rbuf, recvcounts, rdispls, recvtypes, comm );
-
- /* Check rbuf */
- for (i=0; i<size; i++) {
- p = rbuf + (rdispls[i] / sizeof(int));
- for (j=0; j<recvcounts[i]; j++) {
- int expected = 100 * i + 10 * rank + j;
- if (p[j] != expected) {
- fprintf(stderr, "[%d] got %d expected %d for block=%d, element=%dth\n",
- rank, p[j], expected, i, j);
- ++err;
- }
+
+ /* Load up the buffers */
+ for (i = 0; i < size; i++) {
+ /* alltoallw displs are in bytes, not in type extents */
+ rdispls[i] = i * (2 * size) * sizeof(int);
+ recvtypes[i] = MPI_INT;
+ recvcounts[i] = i + rank;
+ }
+ memset(rbuf, -1, size * (2 * size) * sizeof(int));
+ for (i = 0; i < size; i++) {
+ p = rbuf + (rdispls[i] / sizeof(int));
+ for (j = 0; j < recvcounts[i]; ++j) {
+ p[j] = 100 * rank + 10 * i + j;
+ }
+ }
+
+ MPI_Alltoallw(MPI_IN_PLACE, NULL, NULL, NULL, rbuf, recvcounts, rdispls, recvtypes, comm);
+
+ /* Check rbuf */
+ for (i = 0; i < size; i++) {
+ p = rbuf + (rdispls[i] / sizeof(int));
+ for (j = 0; j < recvcounts[i]; j++) {
+ int expected = 100 * i + 10 * rank + j;
+ if (p[j] != expected) {
+ fprintf(stderr, "[%d] got %d expected %d for block=%d, element=%dth\n",
+ rank, p[j], expected, i, j);
+ ++err;
+ }
+ }
}
- }
#endif
- free(recvtypes);
- free(rdispls);
- free(recvcounts);
- free(rbuf);
- MTestFreeComm( &comm );
+ free(recvtypes);
+ free(rdispls);
+ free(recvcounts);
+ free(rbuf);
+ MTestFreeComm(&comm);
}
- MTest_Finalize( err );
+ MTest_Finalize(err);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/alltoallw_zeros.c b/test/mpi/coll/alltoallw_zeros.c
index 65e5c9d..632b053 100644
--- a/test/mpi/coll/alltoallw_zeros.c
+++ b/test/mpi/coll/alltoallw_zeros.c
@@ -46,10 +46,7 @@ int main(int argc, char *argv[])
recvcounts = malloc(size * sizeof(int));
sdispls = malloc(size * sizeof(int));
rdispls = malloc(size * sizeof(int));
- if (!sendtypes || !recvtypes ||
- !sendcounts || !recvcounts ||
- !sdispls || !rdispls)
- {
+ if (!sendtypes || !recvtypes || !sendcounts || !recvcounts || !sdispls || !rdispls) {
printf("error, unable to allocate memory\n");
goto fn_exit;
}
@@ -69,26 +66,34 @@ int main(int argc, char *argv[])
/* try zero-counts on both the send and recv side in case only one direction is broken for some reason */
- MPI_Alltoallw(&sendbuf, sendcounts, sdispls, sendtypes, &recvbuf, recvcounts, rdispls, recvtypes, MPI_COMM_WORLD);
- MPI_Alltoallw(&sendbuf, recvcounts, rdispls, recvtypes, &recvbuf, sendcounts, sdispls, sendtypes, MPI_COMM_WORLD);
+ MPI_Alltoallw(&sendbuf, sendcounts, sdispls, sendtypes, &recvbuf, recvcounts, rdispls,
+ recvtypes, MPI_COMM_WORLD);
+ MPI_Alltoallw(&sendbuf, recvcounts, rdispls, recvtypes, &recvbuf, sendcounts, sdispls,
+ sendtypes, MPI_COMM_WORLD);
#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
/* pass MPI_IN_PLACE and different but compatible types rank is even/odd */
if (rank % 2)
- MPI_Alltoallw(MPI_IN_PLACE, NULL, NULL, NULL, &recvbuf, recvcounts, rdispls, recvtypes, MPI_COMM_WORLD);
+ MPI_Alltoallw(MPI_IN_PLACE, NULL, NULL, NULL, &recvbuf, recvcounts, rdispls, recvtypes,
+ MPI_COMM_WORLD);
else
- MPI_Alltoallw(MPI_IN_PLACE, NULL, NULL, NULL, &recvbuf, sendcounts, sdispls, sendtypes, MPI_COMM_WORLD);
+ MPI_Alltoallw(MPI_IN_PLACE, NULL, NULL, NULL, &recvbuf, sendcounts, sdispls, sendtypes,
+ MPI_COMM_WORLD);
#endif
/* now the same for Alltoallv instead of Alltoallw */
- MPI_Alltoallv(&sendbuf, sendcounts, sdispls, sendtypes[0], &recvbuf, recvcounts, rdispls, recvtypes[0], MPI_COMM_WORLD);
- MPI_Alltoallv(&sendbuf, recvcounts, rdispls, recvtypes[0], &recvbuf, sendcounts, sdispls, sendtypes[0], MPI_COMM_WORLD);
+ MPI_Alltoallv(&sendbuf, sendcounts, sdispls, sendtypes[0], &recvbuf, recvcounts, rdispls,
+ recvtypes[0], MPI_COMM_WORLD);
+ MPI_Alltoallv(&sendbuf, recvcounts, rdispls, recvtypes[0], &recvbuf, sendcounts, sdispls,
+ sendtypes[0], MPI_COMM_WORLD);
#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
if (rank % 2)
- MPI_Alltoallv(MPI_IN_PLACE, NULL, NULL, MPI_DATATYPE_NULL, &recvbuf, recvcounts, rdispls, recvtypes[0], MPI_COMM_WORLD);
+ MPI_Alltoallv(MPI_IN_PLACE, NULL, NULL, MPI_DATATYPE_NULL, &recvbuf, recvcounts, rdispls,
+ recvtypes[0], MPI_COMM_WORLD);
else
- MPI_Alltoallv(MPI_IN_PLACE, NULL, NULL, MPI_DATATYPE_NULL, &recvbuf, sendcounts, sdispls, sendtypes[0], MPI_COMM_WORLD);
+ MPI_Alltoallv(MPI_IN_PLACE, NULL, NULL, MPI_DATATYPE_NULL, &recvbuf, sendcounts, sdispls,
+ sendtypes[0], MPI_COMM_WORLD);
#endif
MPI_Type_free(&sendtype);
@@ -96,16 +101,21 @@ int main(int argc, char *argv[])
if (rank == 0)
printf(" No Errors\n");
-fn_exit:
- if (rdispls) free(rdispls);
- if (sdispls) free(sdispls);
- if (recvcounts) free(recvcounts);
- if (sendcounts) free(sendcounts);
- if (recvtypes) free(recvtypes);
- if (sendtypes) free(sendtypes);
+ fn_exit:
+ if (rdispls)
+ free(rdispls);
+ if (sdispls)
+ free(sdispls);
+ if (recvcounts)
+ free(recvcounts);
+ if (sendcounts)
+ free(sendcounts);
+ if (recvtypes)
+ free(recvtypes);
+ if (sendtypes)
+ free(sendtypes);
MPI_Finalize();
return 0;
}
-
diff --git a/test/mpi/coll/bcasttest.c b/test/mpi/coll/bcasttest.c
index d7d9cda..c3d080a 100644
--- a/test/mpi/coll/bcasttest.c
+++ b/test/mpi/coll/bcasttest.c
@@ -13,91 +13,77 @@
#define NUM_REPS 5
#define NUM_SIZES 4
-int main( int argc, char **argv)
+int main(int argc, char **argv)
{
int *buf;
int i, rank, reps, n;
int bVerify = 1;
- int sizes[NUM_SIZES] = { 100, 64*1024, 128*1024, 1024*1024 };
- int num_errors=0;
-
- MTest_Init( &argc, &argv );
+ int sizes[NUM_SIZES] = { 100, 64 * 1024, 128 * 1024, 1024 * 1024 };
+ int num_errors = 0;
+
+ MTest_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- if (argc > 1)
- {
- if (strcmp(argv[1], "-novalidate") == 0 || strcmp(argv[1], "-noverify") == 0)
- bVerify = 0;
+ if (argc > 1) {
+ if (strcmp(argv[1], "-novalidate") == 0 || strcmp(argv[1], "-noverify") == 0)
+ bVerify = 0;
}
- buf = (int *) malloc(sizes[NUM_SIZES-1]*sizeof(int));
- memset(buf, 0, sizes[NUM_SIZES-1]*sizeof(int));
+ buf = (int *) malloc(sizes[NUM_SIZES - 1] * sizeof(int));
+ memset(buf, 0, sizes[NUM_SIZES - 1] * sizeof(int));
- for (n=0; n<NUM_SIZES; n++)
- {
+ for (n = 0; n < NUM_SIZES; n++) {
#ifdef DEBUG
- if (rank == ROOT)
- {
- printf("bcasting %d MPI_INTs %d times\n", sizes[n], NUM_REPS);
- fflush(stdout);
- }
+ if (rank == ROOT) {
+ printf("bcasting %d MPI_INTs %d times\n", sizes[n], NUM_REPS);
+ fflush(stdout);
+ }
#endif
- for (reps=0; reps < NUM_REPS; reps++)
- {
- if (bVerify)
- {
- if (rank == ROOT)
- {
- for (i=0; i<sizes[n]; i++)
- {
- buf[i] = 1000000 * (n * NUM_REPS + reps) + i;
- }
- }
- else
- {
- for (i=0; i<sizes[n]; i++)
- {
+ for (reps = 0; reps < NUM_REPS; reps++) {
+ if (bVerify) {
+ if (rank == ROOT) {
+ for (i = 0; i < sizes[n]; i++) {
+ buf[i] = 1000000 * (n * NUM_REPS + reps) + i;
+ }
+ }
+ else {
+ for (i = 0; i < sizes[n]; i++) {
buf[i] = -1 - (n * NUM_REPS + reps);
- }
- }
- }
+ }
+ }
+ }
# ifdef DEBUG
- {
- printf("rank=%d, n=%d, reps=%d\n", rank, n, reps);
- }
+ {
+ printf("rank=%d, n=%d, reps=%d\n", rank, n, reps);
+ }
# endif
-
- MPI_Bcast(buf, sizes[n], MPI_INT, ROOT, MPI_COMM_WORLD);
- if (bVerify)
- {
- num_errors = 0;
- for (i=0; i<sizes[n]; i++)
- {
- if (buf[i] != 1000000 * (n * NUM_REPS + reps) + i)
- {
- num_errors++;
- if (num_errors < 10)
- {
- printf("Error: Rank=%d, n=%d, reps=%d, i=%d, buf[i]=%d expected=%d\n", rank, n, reps, i, buf[i],
- 1000000 * (n * NUM_REPS + reps) +i);
- fflush(stdout);
- }
- }
- }
- if (num_errors >= 10)
- {
- printf("Error: Rank=%d, num_errors = %d\n", rank, num_errors);
- fflush(stdout);
- }
- }
- }
+ MPI_Bcast(buf, sizes[n], MPI_INT, ROOT, MPI_COMM_WORLD);
+
+ if (bVerify) {
+ num_errors = 0;
+ for (i = 0; i < sizes[n]; i++) {
+ if (buf[i] != 1000000 * (n * NUM_REPS + reps) + i) {
+ num_errors++;
+ if (num_errors < 10) {
+ printf("Error: Rank=%d, n=%d, reps=%d, i=%d, buf[i]=%d expected=%d\n",
+ rank, n, reps, i, buf[i], 1000000 * (n * NUM_REPS + reps) + i);
+ fflush(stdout);
+ }
+ }
+ }
+ if (num_errors >= 10) {
+ printf("Error: Rank=%d, num_errors = %d\n", rank, num_errors);
+ fflush(stdout);
+ }
+ }
+ }
}
-
+
free(buf);
- MTest_Finalize( num_errors );
+ MTest_Finalize(num_errors);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/bcastzerotype.c b/test/mpi/coll/bcastzerotype.c
index 59f2a5b..9ea8fc4 100644
--- a/test/mpi/coll/bcastzerotype.c
+++ b/test/mpi/coll/bcastzerotype.c
@@ -26,7 +26,7 @@ int main(int argc, char *argv[])
/* a random non-zero sized buffer */
#define NELEM (10)
- buf = malloc(NELEM*sizeof(int));
+ buf = malloc(NELEM * sizeof(int));
assert(buf);
for (i = 0; i < NELEM; i++) {
diff --git a/test/mpi/coll/coll10.c b/test/mpi/coll/coll10.c
index e93abed..e2a424a 100644
--- a/test/mpi/coll/coll10.c
+++ b/test/mpi/coll/coll10.c
@@ -9,53 +9,53 @@
#define BAD_ANSWER 100000
-int assoc ( int *, int *, int *, MPI_Datatype * );
+int assoc(int *, int *, int *, MPI_Datatype *);
/*
- The operation is inoutvec[i] = invec[i] op inoutvec[i]
+ The operation is inoutvec[i] = invec[i] op inoutvec[i]
(see 4.9.4). The order is important.
Note that the computation is in process rank (in the communicator)
order, independant of the root.
*/
-int assoc(int *invec, int *inoutvec, int *len, MPI_Datatype *dtype)
+int assoc(int *invec, int *inoutvec, int *len, MPI_Datatype * dtype)
{
- int i;
- for ( i=0; i<*len; i++ ) {
- if (inoutvec[i] <= invec[i] ) {
- int rank;
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- fprintf( stderr, "[%d] inout[0] = %d, in[0] = %d\n",
- rank, inoutvec[0], invec[0] );
- inoutvec[i] = BAD_ANSWER;
- }
- else
- inoutvec[i] = invec[i];
- }
- return (1);
+ int i;
+ for (i = 0; i < *len; i++) {
+ if (inoutvec[i] <= invec[i]) {
+ int rank;
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ fprintf(stderr, "[%d] inout[0] = %d, in[0] = %d\n", rank, inoutvec[0], invec[0]);
+ inoutvec[i] = BAD_ANSWER;
+ }
+ else
+ inoutvec[i] = invec[i];
+ }
+ return (1);
}
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- int rank, size;
- int data;
- int errors=0;
- int result = -100;
- MPI_Op op;
+ int rank, size;
+ int data;
+ int errors = 0;
+ int result = -100;
+ MPI_Op op;
- MTest_Init( &argc, &argv );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ MTest_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
data = rank;
- MPI_Op_create( (MPI_User_function*)assoc, 0, &op );
- MPI_Reduce ( &data, &result, 1, MPI_INT, op, size-1, MPI_COMM_WORLD );
- MPI_Bcast ( &result, 1, MPI_INT, size-1, MPI_COMM_WORLD );
- MPI_Op_free( &op );
- if (result == BAD_ANSWER) errors++;
+ MPI_Op_create((MPI_User_function *) assoc, 0, &op);
+ MPI_Reduce(&data, &result, 1, MPI_INT, op, size - 1, MPI_COMM_WORLD);
+ MPI_Bcast(&result, 1, MPI_INT, size - 1, MPI_COMM_WORLD);
+ MPI_Op_free(&op);
+ if (result == BAD_ANSWER)
+ errors++;
- MTest_Finalize( errors );
+ MTest_Finalize(errors);
MPI_Finalize();
- return MTestReturnValue( errors );
+ return MTestReturnValue(errors);
}
diff --git a/test/mpi/coll/coll11.c b/test/mpi/coll/coll11.c
index 9b5ddda..b79482e 100644
--- a/test/mpi/coll/coll11.c
+++ b/test/mpi/coll/coll11.c
@@ -7,102 +7,98 @@
#include <stdio.h>
#include "mpitest.h"
-void addem ( int *, int *, int *, MPI_Datatype * );
-void assoc ( int *, int *, int *, MPI_Datatype * );
+void addem(int *, int *, int *, MPI_Datatype *);
+void assoc(int *, int *, int *, MPI_Datatype *);
-void addem(int *invec, int *inoutvec, int *len, MPI_Datatype *dtype)
+void addem(int *invec, int *inoutvec, int *len, MPI_Datatype * dtype)
{
- int i;
- for ( i=0; i<*len; i++ )
- inoutvec[i] += invec[i];
+ int i;
+ for (i = 0; i < *len; i++)
+ inoutvec[i] += invec[i];
}
#define BAD_ANSWER 100000
/*
- The operation is inoutvec[i] = invec[i] op inoutvec[i]
+ The operation is inoutvec[i] = invec[i] op inoutvec[i]
(see 4.9.4). The order is important.
Note that the computation is in process rank (in the communicator)
order, independant of the root.
*/
-void assoc(int *invec, int *inoutvec, int *len, MPI_Datatype *dtype)
+void assoc(int *invec, int *inoutvec, int *len, MPI_Datatype * dtype)
{
- int i;
- for ( i=0; i<*len; i++ ) {
- if (inoutvec[i] <= invec[i] ) {
- int rank;
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- fprintf( stderr, "[%d] inout[0] = %d, in[0] = %d\n",
- rank, inoutvec[0], invec[0] );
- inoutvec[i] = BAD_ANSWER;
- }
- else
- inoutvec[i] = invec[i];
- }
+ int i;
+ for (i = 0; i < *len; i++) {
+ if (inoutvec[i] <= invec[i]) {
+ int rank;
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ fprintf(stderr, "[%d] inout[0] = %d, in[0] = %d\n", rank, inoutvec[0], invec[0]);
+ inoutvec[i] = BAD_ANSWER;
+ }
+ else
+ inoutvec[i] = invec[i];
+ }
}
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- int rank, size, i;
- int data;
- int errors=0;
- int result = -100;
- int correct_result;
- MPI_Op op_assoc, op_addem;
+ int rank, size, i;
+ int data;
+ int errors = 0;
+ int result = -100;
+ int correct_result;
+ MPI_Op op_assoc, op_addem;
- MTest_Init( &argc, &argv );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ MTest_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
data = rank;
correct_result = 0;
- for (i=0;i<=rank;i++)
- correct_result += i;
+ for (i = 0; i <= rank; i++)
+ correct_result += i;
- MPI_Scan ( &data, &result, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
+ MPI_Scan(&data, &result, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
if (result != correct_result) {
- fprintf( stderr, "[%d] Error suming ints with scan\n", rank );
- errors++;
- }
+ fprintf(stderr, "[%d] Error suming ints with scan\n", rank);
+ errors++;
+ }
- MPI_Scan ( &data, &result, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
+ MPI_Scan(&data, &result, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
if (result != correct_result) {
- fprintf( stderr, "[%d] Error summing ints with scan (2)\n", rank );
- errors++;
- }
+ fprintf(stderr, "[%d] Error summing ints with scan (2)\n", rank);
+ errors++;
+ }
data = rank;
result = -100;
- MPI_Op_create( (MPI_User_function *)assoc, 0, &op_assoc );
- MPI_Op_create( (MPI_User_function *)addem, 1, &op_addem );
- MPI_Scan ( &data, &result, 1, MPI_INT, op_addem, MPI_COMM_WORLD );
+ MPI_Op_create((MPI_User_function *) assoc, 0, &op_assoc);
+ MPI_Op_create((MPI_User_function *) addem, 1, &op_addem);
+ MPI_Scan(&data, &result, 1, MPI_INT, op_addem, MPI_COMM_WORLD);
if (result != correct_result) {
- fprintf( stderr, "[%d] Error summing ints with scan (userop)\n",
- rank );
- errors++;
- }
+ fprintf(stderr, "[%d] Error summing ints with scan (userop)\n", rank);
+ errors++;
+ }
- MPI_Scan ( &data, &result, 1, MPI_INT, op_addem, MPI_COMM_WORLD );
+ MPI_Scan(&data, &result, 1, MPI_INT, op_addem, MPI_COMM_WORLD);
if (result != correct_result) {
- fprintf( stderr, "[%d] Error summing ints with scan (userop2)\n",
- rank );
- errors++;
- }
+ fprintf(stderr, "[%d] Error summing ints with scan (userop2)\n", rank);
+ errors++;
+ }
result = -100;
data = rank;
- MPI_Scan ( &data, &result, 1, MPI_INT, op_assoc, MPI_COMM_WORLD );
+ MPI_Scan(&data, &result, 1, MPI_INT, op_assoc, MPI_COMM_WORLD);
if (result == BAD_ANSWER) {
- fprintf( stderr, "[%d] Error scanning with non-commutative op\n",
- rank );
- errors++;
- }
+ fprintf(stderr, "[%d] Error scanning with non-commutative op\n", rank);
+ errors++;
+ }
- MPI_Op_free( &op_assoc );
- MPI_Op_free( &op_addem );
+ MPI_Op_free(&op_assoc);
+ MPI_Op_free(&op_addem);
- MTest_Finalize( errors );
+ MTest_Finalize(errors);
MPI_Finalize();
- return MTestReturnValue( errors );
+ return MTestReturnValue(errors);
}
diff --git a/test/mpi/coll/coll12.c b/test/mpi/coll/coll12.c
index 283fedb..63bd989 100644
--- a/test/mpi/coll/coll12.c
+++ b/test/mpi/coll/coll12.c
@@ -10,64 +10,71 @@
#define TABLE_SIZE 2
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- int rank, size;
- double a[TABLE_SIZE];
- struct { double a; int b; } in[TABLE_SIZE], out[TABLE_SIZE];
- int i;
- int errors = 0, toterrors;
+ int rank, size;
+ double a[TABLE_SIZE];
+ struct {
+ double a;
+ int b;
+ } in[TABLE_SIZE], out[TABLE_SIZE];
+ int i;
+ int errors = 0, toterrors;
- /* Initialize the environment and some variables */
- MTest_Init( &argc, &argv );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ /* Initialize the environment and some variables */
+ MTest_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
- /* Initialize the maxloc data */
- for ( i=0; i<TABLE_SIZE; i++ ) a[i] = 0;
- for ( i=rank; i<TABLE_SIZE; i++ ) a[i] = (double)rank + 1.0;
+ /* Initialize the maxloc data */
+ for (i = 0; i < TABLE_SIZE; i++)
+ a[i] = 0;
+ for (i = rank; i < TABLE_SIZE; i++)
+ a[i] = (double) rank + 1.0;
- /* Copy data to the "in" buffer */
- for (i=0; i<TABLE_SIZE; i++) {
- in[i].a = a[i];
- in[i].b = rank;
- }
+ /* Copy data to the "in" buffer */
+ for (i = 0; i < TABLE_SIZE; i++) {
+ in[i].a = a[i];
+ in[i].b = rank;
+ }
- /* Reduce it! */
- MPI_Reduce( in, out, TABLE_SIZE, MPI_DOUBLE_INT, MPI_MAXLOC, 0, MPI_COMM_WORLD );
- MPI_Bcast ( out, TABLE_SIZE, MPI_DOUBLE_INT, 0, MPI_COMM_WORLD );
+ /* Reduce it! */
+ MPI_Reduce(in, out, TABLE_SIZE, MPI_DOUBLE_INT, MPI_MAXLOC, 0, MPI_COMM_WORLD);
+ MPI_Bcast(out, TABLE_SIZE, MPI_DOUBLE_INT, 0, MPI_COMM_WORLD);
- /* Check to see that we got the right answers */
- for (i=0; i<TABLE_SIZE; i++)
- if (i % size == rank)
- if (out[i].b != rank) {
- printf("MAX (ranks[%d] = %d != %d\n", i, out[i].b, rank );
- errors++;
- }
+ /* Check to see that we got the right answers */
+ for (i = 0; i < TABLE_SIZE; i++)
+ if (i % size == rank)
+ if (out[i].b != rank) {
+ printf("MAX (ranks[%d] = %d != %d\n", i, out[i].b, rank);
+ errors++;
+ }
- /* Initialize the minloc data */
- for ( i=0; i<TABLE_SIZE; i++ ) a[i] = 0;
- for ( i=rank; i<TABLE_SIZE; i++ ) a[i] = -(double)rank - 1.0;
+ /* Initialize the minloc data */
+ for (i = 0; i < TABLE_SIZE; i++)
+ a[i] = 0;
+ for (i = rank; i < TABLE_SIZE; i++)
+ a[i] = -(double) rank - 1.0;
- /* Copy data to the "in" buffer */
- for (i=0; i<TABLE_SIZE; i++) {
- in[i].a = a[i];
- in[i].b = rank;
- }
+ /* Copy data to the "in" buffer */
+ for (i = 0; i < TABLE_SIZE; i++) {
+ in[i].a = a[i];
+ in[i].b = rank;
+ }
- /* Reduce it! */
- MPI_Allreduce( in, out, TABLE_SIZE, MPI_DOUBLE_INT, MPI_MINLOC, MPI_COMM_WORLD );
+ /* Reduce it! */
+ MPI_Allreduce(in, out, TABLE_SIZE, MPI_DOUBLE_INT, MPI_MINLOC, MPI_COMM_WORLD);
- /* Check to see that we got the right answers */
- for (i=0; i<TABLE_SIZE; i++)
- if (i % size == rank)
- if (out[i].b != rank) {
- printf("MIN (ranks[%d] = %d != %d\n", i, out[i].b, rank );
- errors++;
- }
+ /* Check to see that we got the right answers */
+ for (i = 0; i < TABLE_SIZE; i++)
+ if (i % size == rank)
+ if (out[i].b != rank) {
+ printf("MIN (ranks[%d] = %d != %d\n", i, out[i].b, rank);
+ errors++;
+ }
- /* Finish up! */
- MTest_Finalize( errors );
- MPI_Finalize();
- return MTestReturnValue( errors );
+ /* Finish up! */
+ MTest_Finalize(errors);
+ MPI_Finalize();
+ return MTestReturnValue(errors);
}
diff --git a/test/mpi/coll/coll13.c b/test/mpi/coll/coll13.c
index c1b8c2d..80c9bfa 100644
--- a/test/mpi/coll/coll13.c
+++ b/test/mpi/coll/coll13.c
@@ -6,7 +6,7 @@
*/
#include "mpi.h"
-/*
+/*
From: hook at nas.nasa.gov (Edward C. Hook)
*/
@@ -21,7 +21,7 @@ From: hook at nas.nasa.gov (Edward C. Hook)
#define EXIT_FAILURE 1
#endif
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int rank, size;
int chunk = 128;
@@ -30,56 +30,53 @@ int main( int argc, char *argv[] )
int *rb;
int status, gstatus;
- MTest_Init(&argc,&argv);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
- MPI_Comm_size(MPI_COMM_WORLD,&size);
+ MTest_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
- for ( i=1 ; i < argc ; ++i ) {
- if ( argv[i][0] != '-' )
- continue;
- switch(argv[i][1]) {
- case 'm':
- chunk = atoi(argv[++i]);
- break;
- default:
- fprintf(stderr,"Unrecognized argument %s\n",
- argv[i]);
- MPI_Abort(MPI_COMM_WORLD,EXIT_FAILURE);
- }
+ for (i = 1; i < argc; ++i) {
+ if (argv[i][0] != '-')
+ continue;
+ switch (argv[i][1]) {
+ case 'm':
+ chunk = atoi(argv[++i]);
+ break;
+ default:
+ fprintf(stderr, "Unrecognized argument %s\n", argv[i]);
+ MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
+ }
}
- sb = (int *)malloc(size*chunk*sizeof(int));
- if ( !sb ) {
- perror( "can't allocate send buffer" );
- MPI_Abort(MPI_COMM_WORLD,EXIT_FAILURE);
+ sb = (int *) malloc(size * chunk * sizeof(int));
+ if (!sb) {
+ perror("can't allocate send buffer");
+ MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
}
- rb = (int *)malloc(size*chunk*sizeof(int));
- if ( !rb ) {
- perror( "can't allocate recv buffer");
- free(sb);
- MPI_Abort(MPI_COMM_WORLD,EXIT_FAILURE);
+ rb = (int *) malloc(size * chunk * sizeof(int));
+ if (!rb) {
+ perror("can't allocate recv buffer");
+ free(sb);
+ MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
}
- for ( i=0 ; i < size*chunk ; ++i ) {
- sb[i] = rank + 1;
- rb[i] = 0;
+ for (i = 0; i < size * chunk; ++i) {
+ sb[i] = rank + 1;
+ rb[i] = 0;
}
/* fputs("Before MPI_Alltoall\n",stdout); */
/* This should really send MPI_CHAR, but since sb and rb were allocated
- as chunk*size*sizeof(int), the buffers are large enough */
- status = MPI_Alltoall(sb,chunk,MPI_INT,rb,chunk,MPI_INT,
- MPI_COMM_WORLD);
+ * as chunk*size*sizeof(int), the buffers are large enough */
+ status = MPI_Alltoall(sb, chunk, MPI_INT, rb, chunk, MPI_INT, MPI_COMM_WORLD);
/* fputs("Before MPI_Allreduce\n",stdout); */
- MTest_Finalize( status );
+ MTest_Finalize(status);
free(sb);
free(rb);
MPI_Finalize();
- return MTestReturnValue( status );
+ return MTestReturnValue(status);
}
-
diff --git a/test/mpi/coll/coll2.c b/test/mpi/coll/coll2.c
index e89828b..1cd4ba1 100644
--- a/test/mpi/coll/coll2.c
+++ b/test/mpi/coll/coll2.c
@@ -10,59 +10,59 @@
#define MAX_PROCESSES 10
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- int rank, size, i,j;
- int table[MAX_PROCESSES][MAX_PROCESSES];
- int errors=0;
- int participants;
+ int rank, size, i, j;
+ int table[MAX_PROCESSES][MAX_PROCESSES];
+ int errors = 0;
+ int participants;
- MTest_Init( &argc, &argv );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ MTest_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
/* A maximum of MAX_PROCESSES processes can participate */
- if ( size > MAX_PROCESSES ) participants = MAX_PROCESSES;
- else participants = size;
+ if (size > MAX_PROCESSES)
+ participants = MAX_PROCESSES;
+ else
+ participants = size;
if (MAX_PROCESSES % participants) {
- fprintf( stderr, "Number of processors must divide %d\n",
- MAX_PROCESSES );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- if ( (rank < participants) ) {
+ fprintf(stderr, "Number of processors must divide %d\n", MAX_PROCESSES);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ if ((rank < participants)) {
- /* Determine what rows are my responsibility */
- int block_size = MAX_PROCESSES / participants;
- int begin_row = rank * block_size;
- int end_row = (rank+1) * block_size;
- int send_count = block_size * MAX_PROCESSES;
- int recv_count = send_count;
+ /* Determine what rows are my responsibility */
+ int block_size = MAX_PROCESSES / participants;
+ int begin_row = rank * block_size;
+ int end_row = (rank + 1) * block_size;
+ int send_count = block_size * MAX_PROCESSES;
+ int recv_count = send_count;
- /* Paint my rows my color */
- for (i=begin_row; i<end_row ;i++)
- for (j=0; j<MAX_PROCESSES; j++)
- table[i][j] = rank + 10;
+ /* Paint my rows my color */
+ for (i = begin_row; i < end_row; i++)
+ for (j = 0; j < MAX_PROCESSES; j++)
+ table[i][j] = rank + 10;
- /* Gather everybody's result together - sort of like an */
- /* inefficient allgather */
- for (i=0; i<participants; i++) {
- void *sendbuf = (i == rank ? MPI_IN_PLACE : &table[begin_row][0]);
- MTest_Gather(sendbuf, send_count, MPI_INT,
- &table[0][0], recv_count, MPI_INT, i,
- MPI_COMM_WORLD );
- }
+ /* Gather everybody's result together - sort of like an */
+ /* inefficient allgather */
+ for (i = 0; i < participants; i++) {
+ void *sendbuf = (i == rank ? MPI_IN_PLACE : &table[begin_row][0]);
+ MTest_Gather(sendbuf, send_count, MPI_INT,
+ &table[0][0], recv_count, MPI_INT, i, MPI_COMM_WORLD);
+ }
- /* Everybody should have the same table now, */
- /* This test does not in any way guarantee there are no errors */
- /* Print out a table or devise a smart test to make sure it's correct */
- for (i=0; i<MAX_PROCESSES;i++) {
- if ( (table[i][0] - table[i][MAX_PROCESSES-1] !=0) )
- errors++;
- }
- }
+ /* Everybody should have the same table now, */
+ /* This test does not in any way guarantee there are no errors */
+ /* Print out a table or devise a smart test to make sure it's correct */
+ for (i = 0; i < MAX_PROCESSES; i++) {
+ if ((table[i][0] - table[i][MAX_PROCESSES - 1] != 0))
+ errors++;
+ }
+ }
- MTest_Finalize( errors );
+ MTest_Finalize(errors);
MPI_Finalize();
- return MTestReturnValue( errors );
+ return MTestReturnValue(errors);
}
diff --git a/test/mpi/coll/coll3.c b/test/mpi/coll/coll3.c
index 84260d1..e1a1fbe 100644
--- a/test/mpi/coll/coll3.c
+++ b/test/mpi/coll/coll3.c
@@ -9,82 +9,83 @@
#define MAX_PROCESSES 10
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- int rank, size, i,j;
- int table[MAX_PROCESSES][MAX_PROCESSES];
- int errors=0;
- int participants;
- int displs[MAX_PROCESSES];
- int recv_counts[MAX_PROCESSES];
+ int rank, size, i, j;
+ int table[MAX_PROCESSES][MAX_PROCESSES];
+ int errors = 0;
+ int participants;
+ int displs[MAX_PROCESSES];
+ int recv_counts[MAX_PROCESSES];
- MTest_Init( &argc, &argv );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ MTest_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
/* A maximum of MAX_PROCESSES processes can participate */
- if ( size > MAX_PROCESSES ) participants = MAX_PROCESSES;
- else participants = size;
+ if (size > MAX_PROCESSES)
+ participants = MAX_PROCESSES;
+ else
+ participants = size;
/* while (MAX_PROCESSES % participants) participants--; */
if (MAX_PROCESSES % participants) {
- fprintf( stderr, "Number of processors must divide %d\n",
- MAX_PROCESSES );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- if ( (rank < participants) ) {
+ fprintf(stderr, "Number of processors must divide %d\n", MAX_PROCESSES);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ if ((rank < participants)) {
- /* Determine what rows are my responsibility */
- int block_size = MAX_PROCESSES / participants;
- int begin_row = rank * block_size;
- int end_row = (rank+1) * block_size;
- int send_count = block_size * MAX_PROCESSES;
-
- /* Fill in the displacements and recv_counts */
- for (i=0; i<participants; i++) {
- displs[i] = i * block_size * MAX_PROCESSES;
- recv_counts[i] = send_count;
- }
+ /* Determine what rows are my responsibility */
+ int block_size = MAX_PROCESSES / participants;
+ int begin_row = rank * block_size;
+ int end_row = (rank + 1) * block_size;
+ int send_count = block_size * MAX_PROCESSES;
- /* Paint my rows my color */
- for (i=begin_row; i<end_row ;i++)
- for (j=0; j<MAX_PROCESSES; j++)
- table[i][j] = rank + 10;
-
- /* Gather everybody's result together - sort of like an */
- /* inefficient allgather */
- for (i=0; i<participants; i++) {
- void *sendbuf = (i == rank ? MPI_IN_PLACE : &table[begin_row][0]);
- MPI_Gatherv(sendbuf, send_count, MPI_INT,
- &table[0][0], recv_counts, displs, MPI_INT,
- i, MPI_COMM_WORLD);
- }
+ /* Fill in the displacements and recv_counts */
+ for (i = 0; i < participants; i++) {
+ displs[i] = i * block_size * MAX_PROCESSES;
+ recv_counts[i] = send_count;
+ }
+ /* Paint my rows my color */
+ for (i = begin_row; i < end_row; i++)
+ for (j = 0; j < MAX_PROCESSES; j++)
+ table[i][j] = rank + 10;
- /* Everybody should have the same table now.
+ /* Gather everybody's result together - sort of like an */
+ /* inefficient allgather */
+ for (i = 0; i < participants; i++) {
+ void *sendbuf = (i == rank ? MPI_IN_PLACE : &table[begin_row][0]);
+ MPI_Gatherv(sendbuf, send_count, MPI_INT,
+ &table[0][0], recv_counts, displs, MPI_INT, i, MPI_COMM_WORLD);
+ }
- The entries are:
- Table[i][j] = (i/block_size) + 10;
- */
- for (i=0; i<MAX_PROCESSES;i++)
- if ( (table[i][0] - table[i][MAX_PROCESSES-1] !=0) )
- errors++;
- for (i=0; i<MAX_PROCESSES;i++) {
- for (j=0; j<MAX_PROCESSES;j++) {
- if (table[i][j] != (i/block_size) + 10) errors++;
- }
- }
- if (errors) {
- /* Print out table if there are any errors */
- for (i=0; i<MAX_PROCESSES;i++) {
- printf("\n");
- for (j=0; j<MAX_PROCESSES; j++)
- printf(" %d",table[i][j]);
- }
- printf("\n");
- }
- }
- MTest_Finalize( errors );
+ /* Everybody should have the same table now.
+ *
+ * The entries are:
+ * Table[i][j] = (i/block_size) + 10;
+ */
+ for (i = 0; i < MAX_PROCESSES; i++)
+ if ((table[i][0] - table[i][MAX_PROCESSES - 1] != 0))
+ errors++;
+ for (i = 0; i < MAX_PROCESSES; i++) {
+ for (j = 0; j < MAX_PROCESSES; j++) {
+ if (table[i][j] != (i / block_size) + 10)
+ errors++;
+ }
+ }
+ if (errors) {
+ /* Print out table if there are any errors */
+ for (i = 0; i < MAX_PROCESSES; i++) {
+ printf("\n");
+ for (j = 0; j < MAX_PROCESSES; j++)
+ printf(" %d", table[i][j]);
+ }
+ printf("\n");
+ }
+ }
+
+ MTest_Finalize(errors);
MPI_Finalize();
- return MTestReturnValue( errors );
+ return MTestReturnValue(errors);
}
diff --git a/test/mpi/coll/coll4.c b/test/mpi/coll/coll4.c
index cd39065..42afb47 100644
--- a/test/mpi/coll/coll4.c
+++ b/test/mpi/coll/coll4.c
@@ -9,52 +9,52 @@
#define MAX_PROCESSES 10
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- int rank, size, i,j;
- int table[MAX_PROCESSES][MAX_PROCESSES];
- int row[MAX_PROCESSES];
- int errors=0;
- int participants;
- MPI_Comm comm;
+ int rank, size, i, j;
+ int table[MAX_PROCESSES][MAX_PROCESSES];
+ int row[MAX_PROCESSES];
+ int errors = 0;
+ int participants;
+ MPI_Comm comm;
- MTest_Init( &argc, &argv );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ MTest_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
comm = MPI_COMM_WORLD;
/* A maximum of MAX_PROCESSES processes can participate */
- if ( size > MAX_PROCESSES ) {
- participants = MAX_PROCESSES;
- MPI_Comm_split( MPI_COMM_WORLD, rank < MAX_PROCESSES, rank, &comm );
+ if (size > MAX_PROCESSES) {
+ participants = MAX_PROCESSES;
+ MPI_Comm_split(MPI_COMM_WORLD, rank < MAX_PROCESSES, rank, &comm);
}
- else {
- participants = size;
- MPI_Comm_dup( MPI_COMM_WORLD, &comm );
+ else {
+ participants = size;
+ MPI_Comm_dup(MPI_COMM_WORLD, &comm);
}
- if ( (rank < participants) ) {
- int send_count = MAX_PROCESSES;
- int recv_count = MAX_PROCESSES;
-
- /* If I'm the root (process 0), then fill out the big table */
- if (rank == 0)
- for ( i=0; i<participants; i++)
- for ( j=0; j<MAX_PROCESSES; j++ )
- table[i][j] = i+j;
-
- /* Scatter the big table to everybody's little table */
- MPI_Scatter(&table[0][0], send_count, MPI_INT,
- &row[0] , recv_count, MPI_INT, 0, comm );
-
- /* Now see if our row looks right */
- for (i=0; i<MAX_PROCESSES; i++)
- if ( row[i] != i+rank ) errors++;
- }
-
- MPI_Comm_free( &comm );
-
- MTest_Finalize( errors );
+ if ((rank < participants)) {
+ int send_count = MAX_PROCESSES;
+ int recv_count = MAX_PROCESSES;
+
+ /* If I'm the root (process 0), then fill out the big table */
+ if (rank == 0)
+ for (i = 0; i < participants; i++)
+ for (j = 0; j < MAX_PROCESSES; j++)
+ table[i][j] = i + j;
+
+ /* Scatter the big table to everybody's little table */
+ MPI_Scatter(&table[0][0], send_count, MPI_INT, &row[0], recv_count, MPI_INT, 0, comm);
+
+ /* Now see if our row looks right */
+ for (i = 0; i < MAX_PROCESSES; i++)
+ if (row[i] != i + rank)
+ errors++;
+ }
+
+ MPI_Comm_free(&comm);
+
+ MTest_Finalize(errors);
MPI_Finalize();
- return MTestReturnValue( errors );
+ return MTestReturnValue(errors);
}
diff --git a/test/mpi/coll/coll5.c b/test/mpi/coll/coll5.c
index 980650f..95729ac 100644
--- a/test/mpi/coll/coll5.c
+++ b/test/mpi/coll/coll5.c
@@ -9,46 +9,49 @@
#define MAX_PROCESSES 10
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- int rank, size, i,j;
- int table[MAX_PROCESSES][MAX_PROCESSES];
- int row[MAX_PROCESSES];
- int errors=0;
- int participants;
- int displs[MAX_PROCESSES];
- int send_counts[MAX_PROCESSES];
-
- MTest_Init( &argc, &argv );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ int rank, size, i, j;
+ int table[MAX_PROCESSES][MAX_PROCESSES];
+ int row[MAX_PROCESSES];
+ int errors = 0;
+ int participants;
+ int displs[MAX_PROCESSES];
+ int send_counts[MAX_PROCESSES];
+
+ MTest_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
/* A maximum of MAX_PROCESSES processes can participate */
- if ( size > MAX_PROCESSES ) participants = MAX_PROCESSES;
- else participants = size;
- if ( (rank < participants) ) {
- int recv_count = MAX_PROCESSES;
-
- /* If I'm the root (process 0), then fill out the big table */
- /* and setup send_counts and displs arrays */
- if (rank == 0)
- for ( i=0; i<participants; i++) {
- send_counts[i] = recv_count;
- displs[i] = i * MAX_PROCESSES;
- for ( j=0; j<MAX_PROCESSES; j++ )
- table[i][j] = i+j;
- }
-
- /* Scatter the big table to everybody's little table */
- MPI_Scatterv(&table[0][0], send_counts, displs, MPI_INT,
- &row[0] , recv_count, MPI_INT, 0, MPI_COMM_WORLD);
-
- /* Now see if our row looks right */
- for (i=0; i<MAX_PROCESSES; i++)
- if ( row[i] != i+rank ) errors++;
- }
-
- MTest_Finalize( errors );
+ if (size > MAX_PROCESSES)
+ participants = MAX_PROCESSES;
+ else
+ participants = size;
+ if ((rank < participants)) {
+ int recv_count = MAX_PROCESSES;
+
+ /* If I'm the root (process 0), then fill out the big table */
+ /* and setup send_counts and displs arrays */
+ if (rank == 0)
+ for (i = 0; i < participants; i++) {
+ send_counts[i] = recv_count;
+ displs[i] = i * MAX_PROCESSES;
+ for (j = 0; j < MAX_PROCESSES; j++)
+ table[i][j] = i + j;
+ }
+
+ /* Scatter the big table to everybody's little table */
+ MPI_Scatterv(&table[0][0], send_counts, displs, MPI_INT,
+ &row[0], recv_count, MPI_INT, 0, MPI_COMM_WORLD);
+
+ /* Now see if our row looks right */
+ for (i = 0; i < MAX_PROCESSES; i++)
+ if (row[i] != i + rank)
+ errors++;
+ }
+
+ MTest_Finalize(errors);
MPI_Finalize();
- return MTestReturnValue( errors );
+ return MTestReturnValue(errors);
}
diff --git a/test/mpi/coll/coll6.c b/test/mpi/coll/coll6.c
index 666b2ee..077cdcd 100644
--- a/test/mpi/coll/coll6.c
+++ b/test/mpi/coll/coll6.c
@@ -9,86 +9,84 @@
#define MAX_PROCESSES 10
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- int rank, size, i,j;
- int table[MAX_PROCESSES][MAX_PROCESSES];
- int errors=0;
- int participants;
- int displs[MAX_PROCESSES];
- int recv_counts[MAX_PROCESSES];
- MPI_Comm test_comm;
+ int rank, size, i, j;
+ int table[MAX_PROCESSES][MAX_PROCESSES];
+ int errors = 0;
+ int participants;
+ int displs[MAX_PROCESSES];
+ int recv_counts[MAX_PROCESSES];
+ MPI_Comm test_comm;
- MTest_Init( &argc, &argv );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ MTest_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
/* A maximum of MAX_PROCESSES processes can participate */
- participants = ( size > MAX_PROCESSES ) ? MAX_PROCESSES : size;
+ participants = (size > MAX_PROCESSES) ? MAX_PROCESSES : size;
if (MAX_PROCESSES % participants) {
- fprintf( stderr, "Number of processors must divide %d\n",
- MAX_PROCESSES );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- MPI_Comm_split(MPI_COMM_WORLD, rank<participants, rank, &test_comm);
+ fprintf(stderr, "Number of processors must divide %d\n", MAX_PROCESSES);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ MPI_Comm_split(MPI_COMM_WORLD, rank < participants, rank, &test_comm);
- if ( rank < participants ) {
+ if (rank < participants) {
- /* Determine what rows are my responsibility */
- int block_size = MAX_PROCESSES / participants;
- int begin_row = rank * block_size;
- int end_row = (rank+1) * block_size;
- int send_count = block_size * MAX_PROCESSES;
-
- /* Fill in the displacements and recv_counts */
- for (i=0; i<participants; i++) {
- displs[i] = i * block_size * MAX_PROCESSES;
- recv_counts[i] = send_count;
- }
+ /* Determine what rows are my responsibility */
+ int block_size = MAX_PROCESSES / participants;
+ int begin_row = rank * block_size;
+ int end_row = (rank + 1) * block_size;
+ int send_count = block_size * MAX_PROCESSES;
- /* Paint my rows my color */
- for (i=begin_row; i<end_row ;i++)
- for (j=0; j<MAX_PROCESSES; j++)
- table[i][j] = rank + 10;
-
- /* Everybody gets the gathered data */
- if ((char *) &table[begin_row][0] != (char *) table + displs[rank]*sizeof(int))
- MPI_Allgatherv(&table[begin_row][0], send_count, MPI_INT,
- &table[0][0], recv_counts, displs,
- MPI_INT, test_comm);
- else
- MPI_Allgatherv(MPI_IN_PLACE, send_count, MPI_INT,
- &table[0][0], recv_counts, displs,
- MPI_INT, test_comm);
+ /* Fill in the displacements and recv_counts */
+ for (i = 0; i < participants; i++) {
+ displs[i] = i * block_size * MAX_PROCESSES;
+ recv_counts[i] = send_count;
+ }
- /* Everybody should have the same table now.
+ /* Paint my rows my color */
+ for (i = begin_row; i < end_row; i++)
+ for (j = 0; j < MAX_PROCESSES; j++)
+ table[i][j] = rank + 10;
- The entries are:
- Table[i][j] = (i/block_size) + 10;
- */
- for (i=0; i<MAX_PROCESSES;i++)
- if ( (table[i][0] - table[i][MAX_PROCESSES-1] !=0) )
- errors++;
- for (i=0; i<MAX_PROCESSES;i++) {
- for (j=0; j<MAX_PROCESSES;j++) {
- if (table[i][j] != (i/block_size) + 10) errors++;
- }
- }
- if (errors) {
- /* Print out table if there are any errors */
- for (i=0; i<MAX_PROCESSES;i++) {
- printf("\n");
- for (j=0; j<MAX_PROCESSES; j++)
- printf(" %d",table[i][j]);
- }
- printf("\n");
- }
- }
+ /* Everybody gets the gathered data */
+ if ((char *) &table[begin_row][0] != (char *) table + displs[rank] * sizeof(int))
+ MPI_Allgatherv(&table[begin_row][0], send_count, MPI_INT,
+ &table[0][0], recv_counts, displs, MPI_INT, test_comm);
+ else
+ MPI_Allgatherv(MPI_IN_PLACE, send_count, MPI_INT,
+ &table[0][0], recv_counts, displs, MPI_INT, test_comm);
- MTest_Finalize( errors );
+ /* Everybody should have the same table now.
+ *
+ * The entries are:
+ * Table[i][j] = (i/block_size) + 10;
+ */
+ for (i = 0; i < MAX_PROCESSES; i++)
+ if ((table[i][0] - table[i][MAX_PROCESSES - 1] != 0))
+ errors++;
+ for (i = 0; i < MAX_PROCESSES; i++) {
+ for (j = 0; j < MAX_PROCESSES; j++) {
+ if (table[i][j] != (i / block_size) + 10)
+ errors++;
+ }
+ }
+ if (errors) {
+ /* Print out table if there are any errors */
+ for (i = 0; i < MAX_PROCESSES; i++) {
+ printf("\n");
+ for (j = 0; j < MAX_PROCESSES; j++)
+ printf(" %d", table[i][j]);
+ }
+ printf("\n");
+ }
+ }
+
+ MTest_Finalize(errors);
MPI_Comm_free(&test_comm);
MPI_Finalize();
- return MTestReturnValue( errors );
+ return MTestReturnValue(errors);
}
diff --git a/test/mpi/coll/coll7.c b/test/mpi/coll/coll7.c
index 3d352ef..8aef915 100644
--- a/test/mpi/coll/coll7.c
+++ b/test/mpi/coll/coll7.c
@@ -9,54 +9,55 @@
#define MAX_PROCESSES 10
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- int rank, size, i,j;
- int table[MAX_PROCESSES][MAX_PROCESSES];
- int errors=0;
- int participants;
+ int rank, size, i, j;
+ int table[MAX_PROCESSES][MAX_PROCESSES];
+ int errors = 0;
+ int participants;
- MTest_Init( &argc, &argv );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ MTest_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
/* A maximum of MAX_PROCESSES processes can participate */
- if ( size > MAX_PROCESSES ) participants = MAX_PROCESSES;
- else participants = size;
+ if (size > MAX_PROCESSES)
+ participants = MAX_PROCESSES;
+ else
+ participants = size;
if (MAX_PROCESSES % participants) {
- fprintf( stderr, "Number of processors must divide %d\n",
- MAX_PROCESSES );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
+ fprintf(stderr, "Number of processors must divide %d\n", MAX_PROCESSES);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
/* while (MAX_PROCESSES % participants) participants--; */
- if ( (rank < participants) ) {
-
- /* Determine what rows are my responsibility */
- int block_size = MAX_PROCESSES / participants;
- int begin_row = rank * block_size;
- int end_row = (rank+1) * block_size;
- int send_count = block_size * MAX_PROCESSES;
- int recv_count = send_count;
-
- /* Paint my rows my color */
- for (i=begin_row; i<end_row ;i++)
- for (j=0; j<MAX_PROCESSES; j++)
- table[i][j] = rank + 10;
-
- /* Everybody gets the gathered table */
- MPI_Allgather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL,
- &table[0][0], recv_count, MPI_INT, MPI_COMM_WORLD);
-
- /* Everybody should have the same table now, */
- /* This test does not in any way guarantee there are no errors */
- /* Print out a table or devise a smart test to make sure it's correct */
- for (i=0; i<MAX_PROCESSES;i++) {
- if ( (table[i][0] - table[i][MAX_PROCESSES-1] !=0) )
- errors++;
- }
- }
-
- MTest_Finalize( errors );
+ if ((rank < participants)) {
+
+ /* Determine what rows are my responsibility */
+ int block_size = MAX_PROCESSES / participants;
+ int begin_row = rank * block_size;
+ int end_row = (rank + 1) * block_size;
+ int send_count = block_size * MAX_PROCESSES;
+ int recv_count = send_count;
+
+ /* Paint my rows my color */
+ for (i = begin_row; i < end_row; i++)
+ for (j = 0; j < MAX_PROCESSES; j++)
+ table[i][j] = rank + 10;
+
+ /* Everybody gets the gathered table */
+ MPI_Allgather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL,
+ &table[0][0], recv_count, MPI_INT, MPI_COMM_WORLD);
+
+ /* Everybody should have the same table now, */
+ /* This test does not in any way guarantee there are no errors */
+ /* Print out a table or devise a smart test to make sure it's correct */
+ for (i = 0; i < MAX_PROCESSES; i++) {
+ if ((table[i][0] - table[i][MAX_PROCESSES - 1] != 0))
+ errors++;
+ }
+ }
+
+ MTest_Finalize(errors);
MPI_Finalize();
- return MTestReturnValue( errors );
+ return MTestReturnValue(errors);
}
diff --git a/test/mpi/coll/coll8.c b/test/mpi/coll/coll8.c
index b05fb18..940cdf1 100644
--- a/test/mpi/coll/coll8.c
+++ b/test/mpi/coll/coll8.c
@@ -7,36 +7,39 @@
#include <stdio.h>
#include "mpitest.h"
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- int rank, size, i;
- int data;
- int errors=0;
- int result = -100;
- int correct_result;
+ int rank, size, i;
+ int data;
+ int errors = 0;
+ int result = -100;
+ int correct_result;
- MTest_Init( &argc, &argv );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ MTest_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
data = rank;
- MPI_Reduce ( &data, &result, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD );
- MPI_Bcast ( &result, 1, MPI_INT, 0, MPI_COMM_WORLD );
+ MPI_Reduce(&data, &result, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
+ MPI_Bcast(&result, 1, MPI_INT, 0, MPI_COMM_WORLD);
correct_result = 0;
- for(i=0;i<size;i++)
- correct_result += i;
- if (result != correct_result) errors++;
+ for (i = 0; i < size; i++)
+ correct_result += i;
+ if (result != correct_result)
+ errors++;
- MPI_Reduce ( &data, &result, 1, MPI_INT, MPI_MIN, 0, MPI_COMM_WORLD );
- MPI_Bcast ( &result, 1, MPI_INT, 0, MPI_COMM_WORLD );
- if (result != 0) errors++;
+ MPI_Reduce(&data, &result, 1, MPI_INT, MPI_MIN, 0, MPI_COMM_WORLD);
+ MPI_Bcast(&result, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ if (result != 0)
+ errors++;
- MPI_Reduce ( &data, &result, 1, MPI_INT, MPI_MAX, 0, MPI_COMM_WORLD );
- MPI_Bcast ( &result, 1, MPI_INT, 0, MPI_COMM_WORLD );
- if (result != (size-1)) errors++;
+ MPI_Reduce(&data, &result, 1, MPI_INT, MPI_MAX, 0, MPI_COMM_WORLD);
+ MPI_Bcast(&result, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ if (result != (size - 1))
+ errors++;
- MTest_Finalize( errors );
+ MTest_Finalize(errors);
MPI_Finalize();
- return MTestReturnValue( errors );
+ return MTestReturnValue(errors);
}
diff --git a/test/mpi/coll/coll9.c b/test/mpi/coll/coll9.c
index 5fd33c8..7086746 100644
--- a/test/mpi/coll/coll9.c
+++ b/test/mpi/coll/coll9.c
@@ -7,39 +7,40 @@
#include <stdio.h>
#include "mpitest.h"
-void addem ( int *, int *, int *, MPI_Datatype * );
+void addem(int *, int *, int *, MPI_Datatype *);
-void addem(int *invec, int *inoutvec, int *len, MPI_Datatype *dtype)
+void addem(int *invec, int *inoutvec, int *len, MPI_Datatype * dtype)
{
- int i;
- for ( i=0; i<*len; i++ )
- inoutvec[i] += invec[i];
+ int i;
+ for (i = 0; i < *len; i++)
+ inoutvec[i] += invec[i];
}
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- int rank, size, i;
- int data;
- int errors=0;
- int result = -100;
- int correct_result;
- MPI_Op op;
+ int rank, size, i;
+ int data;
+ int errors = 0;
+ int result = -100;
+ int correct_result;
+ MPI_Op op;
- MTest_Init( &argc, &argv );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ MTest_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
data = rank;
- MPI_Op_create( (MPI_User_function *)addem, 1, &op );
- MPI_Reduce ( &data, &result, 1, MPI_INT, op, 0, MPI_COMM_WORLD );
- MPI_Bcast ( &result, 1, MPI_INT, 0, MPI_COMM_WORLD );
- MPI_Op_free( &op );
+ MPI_Op_create((MPI_User_function *) addem, 1, &op);
+ MPI_Reduce(&data, &result, 1, MPI_INT, op, 0, MPI_COMM_WORLD);
+ MPI_Bcast(&result, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ MPI_Op_free(&op);
correct_result = 0;
- for(i=0;i<size;i++)
- correct_result += i;
- if (result != correct_result) errors++;
+ for (i = 0; i < size; i++)
+ correct_result += i;
+ if (result != correct_result)
+ errors++;
- MTest_Finalize( errors );
+ MTest_Finalize(errors);
MPI_Finalize();
- return MTestReturnValue( errors );
+ return MTestReturnValue(errors);
}
diff --git a/test/mpi/coll/exscan.c b/test/mpi/coll/exscan.c
index 70f4c53..4667a70 100644
--- a/test/mpi/coll/exscan.c
+++ b/test/mpi/coll/exscan.c
@@ -13,86 +13,87 @@
static char MTEST_Descrip[] = "Test MPI_Exscan";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size;
- int minsize = 2, count;
+ int minsize = 2, count;
int *sendbuf, *recvbuf, i;
- MPI_Comm comm;
+ MPI_Comm comm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- /* The following illustrates the use of the routines to
- run through a selection of communicators and datatypes.
- Use subsets of these for tests that do not involve combinations
- of communicators, datatypes, and counts of datatypes */
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
+ /* The following illustrates the use of the routines to
+ * run through a selection of communicators and datatypes.
+ * Use subsets of these for tests that do not involve combinations
+ * of communicators, datatypes, and counts of datatypes */
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
-
- for (count = 1; count < 65000; count = count * 2) {
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
- sendbuf = (int *)malloc( count * sizeof(int) );
- recvbuf = (int *)malloc( count * sizeof(int) );
+ for (count = 1; count < 65000; count = count * 2) {
- for (i=0; i<count; i++) {
- sendbuf[i] = rank + i * size;
- recvbuf[i] = -1;
- }
-
- MPI_Exscan( sendbuf, recvbuf, count, MPI_INT, MPI_SUM, comm );
+ sendbuf = (int *) malloc(count * sizeof(int));
+ recvbuf = (int *) malloc(count * sizeof(int));
- /* Check the results. rank 0 has no data */
- if (rank > 0) {
- int result;
- for (i=0; i<count; i++) {
- result = rank * i * size + ((rank) * (rank-1))/2;
- if (recvbuf[i] != result) {
- errs++;
- if (errs < 10) {
- fprintf( stderr, "Error in recvbuf[%d] = %d on %d, expected %d\n",
- i, recvbuf[i], rank, result );
- }
- }
- }
- }
+ for (i = 0; i < count; i++) {
+ sendbuf[i] = rank + i * size;
+ recvbuf[i] = -1;
+ }
+
+ MPI_Exscan(sendbuf, recvbuf, count, MPI_INT, MPI_SUM, comm);
+
+ /* Check the results. rank 0 has no data */
+ if (rank > 0) {
+ int result;
+ for (i = 0; i < count; i++) {
+ result = rank * i * size + ((rank) * (rank - 1)) / 2;
+ if (recvbuf[i] != result) {
+ errs++;
+ if (errs < 10) {
+ fprintf(stderr, "Error in recvbuf[%d] = %d on %d, expected %d\n",
+ i, recvbuf[i], rank, result);
+ }
+ }
+ }
+ }
#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
/* now try the MPI_IN_PLACE flavor */
- for (i=0; i<count; i++) {
- sendbuf[i] = -1; /* unused */
+ for (i = 0; i < count; i++) {
+ sendbuf[i] = -1; /* unused */
recvbuf[i] = rank + i * size;
}
- MPI_Exscan( MPI_IN_PLACE, recvbuf, count, MPI_INT, MPI_SUM, comm );
+ MPI_Exscan(MPI_IN_PLACE, recvbuf, count, MPI_INT, MPI_SUM, comm);
/* Check the results. rank 0's data must remain unchanged */
- for (i=0; i<count; i++) {
+ for (i = 0; i < count; i++) {
int result;
if (rank == 0)
result = rank + i * size;
else
- result = rank * i * size + ((rank) * (rank-1))/2;
+ result = rank * i * size + ((rank) * (rank - 1)) / 2;
if (recvbuf[i] != result) {
errs++;
if (errs < 10) {
- fprintf( stderr, "Error in recvbuf[%d] = %d on %d, expected %d\n",
- i, recvbuf[i], rank, result );
+ fprintf(stderr, "Error in recvbuf[%d] = %d on %d, expected %d\n",
+ i, recvbuf[i], rank, result);
}
}
}
#endif
- free( sendbuf );
- free( recvbuf );
- }
- MTestFreeComm( &comm );
+ free(sendbuf);
+ free(recvbuf);
+ }
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/exscan2.c b/test/mpi/coll/exscan2.c
index 50c898d..0084996 100644
--- a/test/mpi/coll/exscan2.c
+++ b/test/mpi/coll/exscan2.c
@@ -13,45 +13,44 @@
static char MTEST_Descrip[] = "Test MPI_Exscan (simple test)";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size;
int sendbuf[1], recvbuf[1];
- MPI_Comm comm;
+ MPI_Comm comm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
-
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+
sendbuf[0] = rank;
recvbuf[0] = -2;
-
- MPI_Exscan( sendbuf, recvbuf, 1, MPI_INT, MPI_SUM, comm );
+
+ MPI_Exscan(sendbuf, recvbuf, 1, MPI_INT, MPI_SUM, comm);
/* Check the results. rank 0 has no data. Input is
- 0 1 2 3 4 5 6 7 8 ...
- Output is
- - 0 1 3 6 10 15 21 28 36
- (scan, not counting the contribution from the calling process)
- */
+ * 0 1 2 3 4 5 6 7 8 ...
+ * Output is
+ * - 0 1 3 6 10 15 21 28 36
+ * (scan, not counting the contribution from the calling process)
+ */
if (rank > 0) {
- int result = (((rank) * (rank-1))/2);
- /* printf( "%d: %d\n", rank, result ); */
- if (recvbuf[0] != result) {
- errs++;
- fprintf( stderr, "Error in recvbuf = %d on %d, expected %d\n",
- recvbuf[0], rank, result );
- }
+ int result = (((rank) * (rank - 1)) / 2);
+ /* printf("%d: %d\n", rank, result); */
+ if (recvbuf[0] != result) {
+ errs++;
+ fprintf(stderr, "Error in recvbuf = %d on %d, expected %d\n", recvbuf[0], rank, result);
+ }
}
else if (recvbuf[0] != -2) {
- errs++;
- fprintf( stderr, "Error in recvbuf on zero, is %d\n", recvbuf[0] );
+ errs++;
+ fprintf(stderr, "Error in recvbuf on zero, is %d\n", recvbuf[0]);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/gather.c b/test/mpi/coll/gather.c
index 7433caa..b7152c1 100644
--- a/test/mpi/coll/gather.c
+++ b/test/mpi/coll/gather.c
@@ -12,63 +12,63 @@
/* Gather data from a vector to contiguous */
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
MPI_Datatype vec;
- MPI_Comm comm;
+ MPI_Comm comm;
double *vecin, *vecout;
- int minsize = 2, count;
- int root, i, n, stride, errs = 0;
- int rank, size;
+ int minsize = 2, count;
+ int root, i, n, stride, errs = 0;
+ int rank, size;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
- /* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
-
- for (root=0; root<size; root++) {
- for (count = 1; count < 65000; count = count * 2) {
- n = 12;
- stride = 10;
- vecin = (double *)malloc( n * stride * size * sizeof(double) );
- vecout = (double *)malloc( size * n * sizeof(double) );
-
- MPI_Type_vector( n, 1, stride, MPI_DOUBLE, &vec );
- MPI_Type_commit( &vec );
-
- for (i=0; i<n*stride; i++) vecin[i] =-2;
- for (i=0; i<n; i++) vecin[i*stride] = rank * n + i;
-
- MPI_Gather( vecin, 1, vec, vecout, n, MPI_DOUBLE, root, comm );
-
- if (rank == root) {
- for (i=0; i<n*size; i++) {
- if (vecout[i] != i) {
- errs++;
- if (errs < 10) {
- fprintf( stderr, "vecout[%d]=%d\n",
- i, (int)vecout[i] );
- }
- }
- }
- }
- MPI_Type_free( &vec );
- free( vecin );
- free( vecout );
- }
- }
- MTestFreeComm( &comm );
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ /* Determine the sender and receiver */
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+
+ for (root = 0; root < size; root++) {
+ for (count = 1; count < 65000; count = count * 2) {
+ n = 12;
+ stride = 10;
+ vecin = (double *) malloc(n * stride * size * sizeof(double));
+ vecout = (double *) malloc(size * n * sizeof(double));
+
+ MPI_Type_vector(n, 1, stride, MPI_DOUBLE, &vec);
+ MPI_Type_commit(&vec);
+
+ for (i = 0; i < n * stride; i++)
+ vecin[i] = -2;
+ for (i = 0; i < n; i++)
+ vecin[i * stride] = rank * n + i;
+
+ MPI_Gather(vecin, 1, vec, vecout, n, MPI_DOUBLE, root, comm);
+
+ if (rank == root) {
+ for (i = 0; i < n * size; i++) {
+ if (vecout[i] != i) {
+ errs++;
+ if (errs < 10) {
+ fprintf(stderr, "vecout[%d]=%d\n", i, (int) vecout[i]);
+ }
+ }
+ }
+ }
+ MPI_Type_free(&vec);
+ free(vecin);
+ free(vecout);
+ }
+ }
+ MTestFreeComm(&comm);
}
/* do a zero length gather */
- MPI_Gather( NULL, 0, MPI_BYTE, NULL, 0, MPI_BYTE, 0, MPI_COMM_WORLD );
+ MPI_Gather(NULL, 0, MPI_BYTE, NULL, 0, MPI_BYTE, 0, MPI_COMM_WORLD);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
-
-
diff --git a/test/mpi/coll/gather2.c b/test/mpi/coll/gather2.c
index 391c413..f8836f4 100644
--- a/test/mpi/coll/gather2.c
+++ b/test/mpi/coll/gather2.c
@@ -12,78 +12,77 @@
/* Gather data from a vector to contiguous. Use IN_PLACE */
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
MPI_Datatype vec;
double *vecin, *vecout;
MPI_Comm comm;
- int count, minsize = 2;
- int root, i, n, stride, errs = 0;
- int rank, size;
+ int count, minsize = 2;
+ int root, i, n, stride, errs = 0;
+ int rank, size;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
- /* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
-
- for (root=0; root<size; root++) {
- for (count = 1; count < 65000; count = count * 2) {
- n = 12;
- stride = 10;
- vecin = (double *)malloc( n * stride * size * sizeof(double) );
- vecout = (double *)malloc( size * n * sizeof(double) );
-
- MPI_Type_vector( n, 1, stride, MPI_DOUBLE, &vec );
- MPI_Type_commit( &vec );
-
- for (i=0; i<n*stride; i++) vecin[i] =-2;
- for (i=0; i<n; i++) vecin[i*stride] = rank * n + i;
-
- if (rank == root) {
- for (i=0; i<n; i++) {
- vecout[rank*n+i] = rank*n+i;
- }
- MPI_Gather( MPI_IN_PLACE, -1, MPI_DATATYPE_NULL,
- vecout, n, MPI_DOUBLE, root, comm );
- }
- else {
- MPI_Gather( vecin, 1, vec, NULL, -1, MPI_DATATYPE_NULL,
- root, comm );
- }
- if (rank == root) {
- for (i=0; i<n*size; i++) {
- if (vecout[i] != i) {
- errs++;
- if (errs < 10) {
- fprintf( stderr, "vecout[%d]=%d\n",
- i, (int)vecout[i] );
- }
- }
- }
- }
- MPI_Type_free( &vec );
- free( vecin );
- free( vecout );
- }
- }
- MTestFreeComm( &comm );
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ /* Determine the sender and receiver */
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+
+ for (root = 0; root < size; root++) {
+ for (count = 1; count < 65000; count = count * 2) {
+ n = 12;
+ stride = 10;
+ vecin = (double *) malloc(n * stride * size * sizeof(double));
+ vecout = (double *) malloc(size * n * sizeof(double));
+
+ MPI_Type_vector(n, 1, stride, MPI_DOUBLE, &vec);
+ MPI_Type_commit(&vec);
+
+ for (i = 0; i < n * stride; i++)
+ vecin[i] = -2;
+ for (i = 0; i < n; i++)
+ vecin[i * stride] = rank * n + i;
+
+ if (rank == root) {
+ for (i = 0; i < n; i++) {
+ vecout[rank * n + i] = rank * n + i;
+ }
+ MPI_Gather(MPI_IN_PLACE, -1, MPI_DATATYPE_NULL,
+ vecout, n, MPI_DOUBLE, root, comm);
+ }
+ else {
+ MPI_Gather(vecin, 1, vec, NULL, -1, MPI_DATATYPE_NULL, root, comm);
+ }
+ if (rank == root) {
+ for (i = 0; i < n * size; i++) {
+ if (vecout[i] != i) {
+ errs++;
+ if (errs < 10) {
+ fprintf(stderr, "vecout[%d]=%d\n", i, (int) vecout[i]);
+ }
+ }
+ }
+ }
+ MPI_Type_free(&vec);
+ free(vecin);
+ free(vecout);
+ }
+ }
+ MTestFreeComm(&comm);
}
/* do a zero length gather */
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- if ( rank == 0 ) {
- MPI_Gather( MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, NULL, 0, MPI_BYTE, 0,
- MPI_COMM_WORLD );
- } else {
- MPI_Gather( NULL, 0, MPI_BYTE, NULL, 0, MPI_BYTE, 0, MPI_COMM_WORLD );
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ if (rank == 0) {
+ MPI_Gather(MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, NULL, 0, MPI_BYTE, 0, MPI_COMM_WORLD);
+ }
+ else {
+ MPI_Gather(NULL, 0, MPI_BYTE, NULL, 0, MPI_BYTE, 0, MPI_COMM_WORLD);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
-
-
diff --git a/test/mpi/coll/gather_big.c b/test/mpi/coll/gather_big.c
index 7e6ccce..e649192 100644
--- a/test/mpi/coll/gather_big.c
+++ b/test/mpi/coll/gather_big.c
@@ -20,13 +20,12 @@
#endif
#define VERIFY_CONST 100000000L
-int
-main(int argc, char *argv[])
+int main(int argc, char *argv[])
{
int rank, size;
int i, j;
- long *sendbuf=NULL;
- long *recvbuf=NULL;
+ long *sendbuf = NULL;
+ long *recvbuf = NULL;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
@@ -37,7 +36,7 @@ main(int argc, char *argv[])
fprintf(stderr, "PE %d:ERROR: malloc of sendbuf failed\n", rank);
}
for (i = 0; i < COUNT; i++) {
- sendbuf[i] = (long) i + (long) rank * VERIFY_CONST;
+ sendbuf[i] = (long) i + (long) rank *VERIFY_CONST;
}
if (rank == ROOT) {
@@ -50,8 +49,7 @@ main(int argc, char *argv[])
}
}
- MPI_Gather(sendbuf, COUNT, MPI_LONG, recvbuf, COUNT, MPI_LONG,
- ROOT, MPI_COMM_WORLD);
+ MPI_Gather(sendbuf, COUNT, MPI_LONG, recvbuf, COUNT, MPI_LONG, ROOT, MPI_COMM_WORLD);
int lerr = 0;
if (rank == ROOT) {
@@ -65,14 +63,15 @@ main(int argc, char *argv[])
lerr++;
if (lerr > 10) {
j = COUNT;
- }
+ }
}
}
}
- MTest_Finalize(lerr);
- free(recvbuf);
- } else {
- MTest_Finalize(lerr);
+ MTest_Finalize(lerr);
+ free(recvbuf);
+ }
+ else {
+ MTest_Finalize(lerr);
}
MPI_Barrier(MPI_COMM_WORLD);
@@ -81,4 +80,3 @@ main(int argc, char *argv[])
free(sendbuf);
return 0;
}
-
diff --git a/test/mpi/coll/iallred.c b/test/mpi/coll/iallred.c
index d83841c..455c22d 100644
--- a/test/mpi/coll/iallred.c
+++ b/test/mpi/coll/iallred.c
@@ -16,13 +16,13 @@ int main(int argc, char *argv[])
int size, rank;
int one = 1, two = 2, isum, sum;
- MPI_Init(&argc,&argv);
+ MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
assert(size == 2);
- MPI_Iallreduce(&one,&isum,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD,&request);
- MPI_Allreduce(&two,&sum,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
- MPI_Wait(&request,MPI_STATUS_IGNORE);
+ MPI_Iallreduce(&one, &isum, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &request);
+ MPI_Allreduce(&two, &sum, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
+ MPI_Wait(&request, MPI_STATUS_IGNORE);
assert(isum == 2);
assert(sum == 4);
@@ -32,4 +32,3 @@ int main(int argc, char *argv[])
MPI_Finalize();
return 0;
}
-
diff --git a/test/mpi/coll/ibarrier.c b/test/mpi/coll/ibarrier.c
index affde1f..a672da0 100644
--- a/test/mpi/coll/ibarrier.c
+++ b/test/mpi/coll/ibarrier.c
@@ -14,15 +14,15 @@
int main(int argc, char *argv[])
{
MPI_Request barrier;
- int rank,i,done;
+ int rank, i, done;
- MPI_Init(&argc,&argv);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
- MPI_Ibarrier(MPI_COMM_WORLD,&barrier);
- for (i=0,done=0; !done; i++) {
+ MPI_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Ibarrier(MPI_COMM_WORLD, &barrier);
+ for (i = 0, done = 0; !done; i++) {
usleep(1000);
- /*printf("[%d] MPI_Test: %d\n",rank,i);*/
- MPI_Test(&barrier,&done,MPI_STATUS_IGNORE);
+ /*printf("[%d] MPI_Test: %d\n",rank,i); */
+ MPI_Test(&barrier, &done, MPI_STATUS_IGNORE);
}
if (rank == 0)
diff --git a/test/mpi/coll/icallgather.c b/test/mpi/coll/icallgather.c
index 04bef4b..3418167 100644
--- a/test/mpi/coll/icallgather.c
+++ b/test/mpi/coll/icallgather.c
@@ -14,7 +14,7 @@
static char MTEST_Descrip[] = "Simple intercomm allgather test";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int *rbuf = 0, *sbuf = 0;
@@ -22,87 +22,89 @@ int main( int argc, char *argv[] )
MPI_Comm comm;
MPI_Datatype datatype;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
datatype = MPI_INT;
/* Get an intercommunicator */
- while (MTestGetIntercomm( &comm, &leftGroup, 4 )) {
- if (comm == MPI_COMM_NULL) continue;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_remote_size( comm, &rsize );
+ while (MTestGetIntercomm(&comm, &leftGroup, 4)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_remote_size(comm, &rsize);
- /* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Errhandler_set( comm, MPI_ERRORS_RETURN );
+ /* To improve reporting of problems about operations, we
+ * change the error handler to errors return */
+ MPI_Errhandler_set(comm, MPI_ERRORS_RETURN);
- for (count = 1; count < 65000; count = 2 * count) {
- /* The left group will send rank to the right group;
- The right group will send -rank to the left group */
- rbuf = (int *)malloc( count * rsize * sizeof(int) );
- sbuf = (int *)malloc( count * sizeof(int) );
- for (i=0; i<count*rsize; i++) rbuf[i] = -1;
- if (leftGroup) {
- for (i=0; i<count; i++) sbuf[i] = i + rank*count;
- }
- else {
- for (i=0; i<count; i++) sbuf[i] = -(i + rank*count);
- }
- err = MTest_Allgather(sbuf, count, datatype,
- rbuf, count, datatype, comm);
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- if (leftGroup) {
- for (i=0; i<count*rsize; i++) {
- if (rbuf[i] != -i) {
- errs++;
- }
- }
- }
- else {
- for (i=0; i<count*rsize; i++) {
- if (rbuf[i] != i) {
- errs++;
- }
- }
- }
+ for (count = 1; count < 65000; count = 2 * count) {
+ /* The left group will send rank to the right group;
+ * The right group will send -rank to the left group */
+ rbuf = (int *) malloc(count * rsize * sizeof(int));
+ sbuf = (int *) malloc(count * sizeof(int));
+ for (i = 0; i < count * rsize; i++)
+ rbuf[i] = -1;
+ if (leftGroup) {
+ for (i = 0; i < count; i++)
+ sbuf[i] = i + rank * count;
+ }
+ else {
+ for (i = 0; i < count; i++)
+ sbuf[i] = -(i + rank * count);
+ }
+ err = MTest_Allgather(sbuf, count, datatype, rbuf, count, datatype, comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ if (leftGroup) {
+ for (i = 0; i < count * rsize; i++) {
+ if (rbuf[i] != -i) {
+ errs++;
+ }
+ }
+ }
+ else {
+ for (i = 0; i < count * rsize; i++) {
+ if (rbuf[i] != i) {
+ errs++;
+ }
+ }
+ }
- /* Use Allgather in a unidirectional way */
- for (i=0; i<count*rsize; i++) rbuf[i] = -1;
- if (leftGroup) {
- err = MTest_Allgather(sbuf, 0, datatype,
- rbuf, count, datatype, comm);
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- for (i=0; i<count*rsize; i++) {
- if (rbuf[i] != -i) {
- errs++;
- }
- }
- }
- else {
- err = MTest_Allgather(sbuf, count, datatype,
- rbuf, 0, datatype, comm);
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- for (i=0; i<count*rsize; i++) {
- if (rbuf[i] != -1) {
- errs++;
- }
- }
- }
- free( rbuf );
- free( sbuf );
- }
- MTestFreeComm( &comm );
+ /* Use Allgather in a unidirectional way */
+ for (i = 0; i < count * rsize; i++)
+ rbuf[i] = -1;
+ if (leftGroup) {
+ err = MTest_Allgather(sbuf, 0, datatype, rbuf, count, datatype, comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ for (i = 0; i < count * rsize; i++) {
+ if (rbuf[i] != -i) {
+ errs++;
+ }
+ }
+ }
+ else {
+ err = MTest_Allgather(sbuf, count, datatype, rbuf, 0, datatype, comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ for (i = 0; i < count * rsize; i++) {
+ if (rbuf[i] != -1) {
+ errs++;
+ }
+ }
+ }
+ free(rbuf);
+ free(sbuf);
+ }
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/icallgatherv.c b/test/mpi/coll/icallgatherv.c
index 8d17f32..a88cbf7 100644
--- a/test/mpi/coll/icallgatherv.c
+++ b/test/mpi/coll/icallgatherv.c
@@ -14,7 +14,7 @@
static char MTEST_Descrip[] = "Simple intercomm allgatherv test";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int *rbuf = 0, *sbuf = 0;
@@ -23,101 +23,104 @@ int main( int argc, char *argv[] )
MPI_Comm comm;
MPI_Datatype datatype;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
datatype = MPI_INT;
- /* Get an intercommunicator */
- while (MTestGetIntercomm( &comm, &leftGroup, 4 )) {
- if (comm == MPI_COMM_NULL) continue;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_remote_size( comm, &rsize );
+ /* Get an intercommunicator */
+ while (MTestGetIntercomm(&comm, &leftGroup, 4)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_remote_size(comm, &rsize);
- /* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Errhandler_set( comm, MPI_ERRORS_RETURN );
+ /* To improve reporting of problems about operations, we
+ * change the error handler to errors return */
+ MPI_Errhandler_set(comm, MPI_ERRORS_RETURN);
- for (count = 1; count < 65000; count = 2 * count) {
- /* The left group will send rank to the right group;
- The right group will send -rank to the left group */
- rbuf = (int *)malloc( count * rsize * sizeof(int) );
- sbuf = (int *)malloc( count * sizeof(int) );
- recvcounts = (int *) malloc( rsize * sizeof(int) );
- recvdispls = (int *) malloc( rsize * sizeof(int) );
- for (i=0; i<count*rsize; i++) rbuf[i] = -1;
- for (i=0; i<rsize; i++) {
- recvcounts[i] = count;
- recvdispls[i] = i * count;
- }
- if (leftGroup) {
- for (i=0; i<count; i++) sbuf[i] = i + rank*count;
- }
- else {
- for (i=0; i<count; i++) sbuf[i] = -(i + rank*count);
- }
- err = MTest_Allgatherv(sbuf, count, datatype,
- rbuf, recvcounts, recvdispls, datatype,
- comm);
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- if (leftGroup) {
- for (i=0; i<count*rsize; i++) {
- if (rbuf[i] != -i) {
- errs++;
- }
- }
- }
- else {
- for (i=0; i<count*rsize; i++) {
- if (rbuf[i] != i) {
- errs++;
- }
- }
- }
+ for (count = 1; count < 65000; count = 2 * count) {
+ /* The left group will send rank to the right group;
+ * The right group will send -rank to the left group */
+ rbuf = (int *) malloc(count * rsize * sizeof(int));
+ sbuf = (int *) malloc(count * sizeof(int));
+ recvcounts = (int *) malloc(rsize * sizeof(int));
+ recvdispls = (int *) malloc(rsize * sizeof(int));
+ for (i = 0; i < count * rsize; i++)
+ rbuf[i] = -1;
+ for (i = 0; i < rsize; i++) {
+ recvcounts[i] = count;
+ recvdispls[i] = i * count;
+ }
+ if (leftGroup) {
+ for (i = 0; i < count; i++)
+ sbuf[i] = i + rank * count;
+ }
+ else {
+ for (i = 0; i < count; i++)
+ sbuf[i] = -(i + rank * count);
+ }
+ err = MTest_Allgatherv(sbuf, count, datatype,
+ rbuf, recvcounts, recvdispls, datatype, comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ if (leftGroup) {
+ for (i = 0; i < count * rsize; i++) {
+ if (rbuf[i] != -i) {
+ errs++;
+ }
+ }
+ }
+ else {
+ for (i = 0; i < count * rsize; i++) {
+ if (rbuf[i] != i) {
+ errs++;
+ }
+ }
+ }
- /* Use Allgather in a unidirectional way */
- for (i=0; i<count*rsize; i++) rbuf[i] = -1;
- if (leftGroup) {
- err = MTest_Allgatherv(sbuf, 0, datatype,
- rbuf, recvcounts, recvdispls, datatype,
- comm);
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- for (i=0; i<count*rsize; i++) {
- if (rbuf[i] != -i) {
- errs++;
- }
- }
- }
- else {
- for (i=0; i<rsize; i++) {
+ /* Use Allgather in a unidirectional way */
+ for (i = 0; i < count * rsize; i++)
+ rbuf[i] = -1;
+ if (leftGroup) {
+ err = MTest_Allgatherv(sbuf, 0, datatype,
+ rbuf, recvcounts, recvdispls, datatype, comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ for (i = 0; i < count * rsize; i++) {
+ if (rbuf[i] != -i) {
+ errs++;
+ }
+ }
+ }
+ else {
+ for (i = 0; i < rsize; i++) {
recvcounts[i] = 0;
recvdispls[i] = 0;
}
- err = MTest_Allgatherv(sbuf, count, datatype,
- rbuf, recvcounts, recvdispls, datatype, comm);
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- for (i=0; i<count*rsize; i++) {
- if (rbuf[i] != -1) {
- errs++;
- }
- }
- }
- free( rbuf );
- free( sbuf );
- free( recvcounts );
- free( recvdispls );
+ err = MTest_Allgatherv(sbuf, count, datatype,
+ rbuf, recvcounts, recvdispls, datatype, comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ for (i = 0; i < count * rsize; i++) {
+ if (rbuf[i] != -1) {
+ errs++;
+ }
+ }
+ }
+ free(rbuf);
+ free(sbuf);
+ free(recvcounts);
+ free(recvdispls);
}
- MTestFreeComm( &comm );
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/icallreduce.c b/test/mpi/coll/icallreduce.c
index 164a3bb..4014412 100644
--- a/test/mpi/coll/icallreduce.c
+++ b/test/mpi/coll/icallreduce.c
@@ -14,7 +14,7 @@
static char MTEST_Descrip[] = "Simple intercomm allreduce test";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int *sendbuf = 0, *recvbuf = 0;
@@ -22,65 +22,68 @@ int main( int argc, char *argv[] )
MPI_Comm comm;
MPI_Datatype datatype;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
datatype = MPI_INT;
/* Get an intercommunicator */
- while (MTestGetIntercomm( &comm, &leftGroup, 4 )) {
- if (comm == MPI_COMM_NULL) continue;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_remote_size( comm, &rsize );
+ while (MTestGetIntercomm(&comm, &leftGroup, 4)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_remote_size(comm, &rsize);
- /* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Errhandler_set( comm, MPI_ERRORS_RETURN );
+ /* To improve reporting of problems about operations, we
+ * change the error handler to errors return */
+ MPI_Errhandler_set(comm, MPI_ERRORS_RETURN);
- for (count = 1; count < 65000; count = 2 * count) {
- /* printf( "rank = %d(%d)\n", rank, leftGroup ); fflush(stdout); */
- sendbuf = (int *)malloc( count * sizeof(int) );
- recvbuf = (int *)malloc( count * sizeof(int) );
- if (leftGroup) {
- for (i=0; i<count; i++) sendbuf[i] = i;
- }
- else {
- for (i=0; i<count; i++) sendbuf[i] = -i;
- }
- for (i=0; i<count; i++) recvbuf[i] = 0;
- err = MTest_Allreduce(sendbuf, recvbuf, count, datatype,
- MPI_SUM, comm);
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- /* In each process should be the sum of the values from the
- other process */
- if (leftGroup) {
- for (i=0; i<count; i++) {
- if (recvbuf[i] != -i * rsize) {
- errs++;
- if (errs < 10) {
- fprintf( stderr, "recvbuf[%d] = %d\n", i, recvbuf[i] );
- }
- }
- }
- }
- else {
- for (i=0; i<count; i++) {
- if (recvbuf[i] != i * rsize) {
- errs++;
- if (errs < 10) {
- fprintf( stderr, "recvbuf[%d] = %d\n", i, recvbuf[i] );
- }
- }
- }
- }
- free( sendbuf );
- free( recvbuf );
- }
- MTestFreeComm( &comm );
+ for (count = 1; count < 65000; count = 2 * count) {
+ /* printf("rank = %d(%d)\n", rank, leftGroup); fflush(stdout); */
+ sendbuf = (int *) malloc(count * sizeof(int));
+ recvbuf = (int *) malloc(count * sizeof(int));
+ if (leftGroup) {
+ for (i = 0; i < count; i++)
+ sendbuf[i] = i;
+ }
+ else {
+ for (i = 0; i < count; i++)
+ sendbuf[i] = -i;
+ }
+ for (i = 0; i < count; i++)
+ recvbuf[i] = 0;
+ err = MTest_Allreduce(sendbuf, recvbuf, count, datatype, MPI_SUM, comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ /* In each process should be the sum of the values from the
+ * other process */
+ if (leftGroup) {
+ for (i = 0; i < count; i++) {
+ if (recvbuf[i] != -i * rsize) {
+ errs++;
+ if (errs < 10) {
+ fprintf(stderr, "recvbuf[%d] = %d\n", i, recvbuf[i]);
+ }
+ }
+ }
+ }
+ else {
+ for (i = 0; i < count; i++) {
+ if (recvbuf[i] != i * rsize) {
+ errs++;
+ if (errs < 10) {
+ fprintf(stderr, "recvbuf[%d] = %d\n", i, recvbuf[i]);
+ }
+ }
+ }
+ }
+ free(sendbuf);
+ free(recvbuf);
+ }
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/icalltoall.c b/test/mpi/coll/icalltoall.c
index 9d6b8f8..d8ef959 100644
--- a/test/mpi/coll/icalltoall.c
+++ b/test/mpi/coll/icalltoall.c
@@ -14,7 +14,7 @@
static char MTEST_Descrip[] = "Simple intercomm alltoall test";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int *sendbuf = 0, *recvbuf = 0;
@@ -22,65 +22,64 @@ int main( int argc, char *argv[] )
MPI_Comm comm;
MPI_Datatype datatype;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
datatype = MPI_INT;
- while (MTestGetIntercomm( &comm, &leftGroup, 4 )) {
- if (comm == MPI_COMM_NULL) continue;
- for (count = 1; count < 66000; count = 2 * count) {
- /* Get an intercommunicator */
- MPI_Comm_remote_size( comm, &rsize );
- MPI_Comm_rank( comm, &rrank );
- sendbuf = (int *)malloc( rsize * count * sizeof(int) );
- recvbuf = (int *)malloc( rsize * count * sizeof(int) );
- for (i=0; i<rsize*count; i++) recvbuf[i] = -1;
- if (leftGroup) {
- idx = 0;
- for (j=0; j<rsize; j++) {
- for (i=0; i<count; i++) {
- sendbuf[idx++] = i + rrank;
- }
- }
- err = MTest_Alltoall(sendbuf, count, datatype,
- NULL, 0, datatype, comm);
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- }
- else {
- int rank, size;
+ while (MTestGetIntercomm(&comm, &leftGroup, 4)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ for (count = 1; count < 66000; count = 2 * count) {
+ /* Get an intercommunicator */
+ MPI_Comm_remote_size(comm, &rsize);
+ MPI_Comm_rank(comm, &rrank);
+ sendbuf = (int *) malloc(rsize * count * sizeof(int));
+ recvbuf = (int *) malloc(rsize * count * sizeof(int));
+ for (i = 0; i < rsize * count; i++)
+ recvbuf[i] = -1;
+ if (leftGroup) {
+ idx = 0;
+ for (j = 0; j < rsize; j++) {
+ for (i = 0; i < count; i++) {
+ sendbuf[idx++] = i + rrank;
+ }
+ }
+ err = MTest_Alltoall(sendbuf, count, datatype, NULL, 0, datatype, comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ }
+ else {
+ int rank, size;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
- /* In the right group */
- err = MTest_Alltoall(NULL, 0, datatype,
- recvbuf, count, datatype, comm);
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- /* Check that we have received the correct data */
- idx = 0;
- for (j=0; j<rsize; j++) {
- for (i=0; i<count; i++) {
- if (recvbuf[idx++] != i + j) {
- errs++;
- if (errs < 10)
- fprintf( stderr, "buf[%d] = %d on %d\n",
- i, recvbuf[i], rank );
- }
- }
- }
- }
- free( recvbuf );
- free( sendbuf );
- }
- MTestFreeComm( &comm );
+ /* In the right group */
+ err = MTest_Alltoall(NULL, 0, datatype, recvbuf, count, datatype, comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ /* Check that we have received the correct data */
+ idx = 0;
+ for (j = 0; j < rsize; j++) {
+ for (i = 0; i < count; i++) {
+ if (recvbuf[idx++] != i + j) {
+ errs++;
+ if (errs < 10)
+ fprintf(stderr, "buf[%d] = %d on %d\n", i, recvbuf[i], rank);
+ }
+ }
+ }
+ }
+ free(recvbuf);
+ free(sendbuf);
+ }
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/icalltoallv.c b/test/mpi/coll/icalltoallv.c
index 7a81805..90cf06a 100644
--- a/test/mpi/coll/icalltoallv.c
+++ b/test/mpi/coll/icalltoallv.c
@@ -15,86 +15,87 @@
Because there are separate send and receive types to alltoallv,
there need to be tests to rearrange data on the fly. Not done yet.
-
+
The first test sends i items to processor i from all processors.
Currently, the test uses only MPI_INT; this is adequate for testing systems
that use point-to-point operations
*/
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
MPI_Comm comm;
- int *sbuf, *rbuf;
- int rank, size, lsize, asize;
- int *sendcounts, *recvcounts, *rdispls, *sdispls;
- int i, j, *p, err;
- int leftGroup;
+ int *sbuf, *rbuf;
+ int rank, size, lsize, asize;
+ int *sendcounts, *recvcounts, *rdispls, *sdispls;
+ int i, j, *p, err;
+ int leftGroup;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
err = 0;
- while (MTestGetIntercomm( &comm, &leftGroup, 4 )) {
- if (comm == MPI_COMM_NULL) continue;
+ while (MTestGetIntercomm(&comm, &leftGroup, 4)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
- /* Create the buffer */
- MPI_Comm_size( comm, &lsize );
- MPI_Comm_remote_size( comm, &size );
- asize = (lsize > size) ? lsize : size;
- MPI_Comm_rank( comm, &rank );
- sbuf = (int *)malloc( size * size * sizeof(int) );
- rbuf = (int *)malloc( asize * asize * sizeof(int) );
- if (!sbuf || !rbuf) {
- fprintf( stderr, "Could not allocated buffers!\n" );
- MPI_Abort( comm, 1 );
- }
+ /* Create the buffer */
+ MPI_Comm_size(comm, &lsize);
+ MPI_Comm_remote_size(comm, &size);
+ asize = (lsize > size) ? lsize : size;
+ MPI_Comm_rank(comm, &rank);
+ sbuf = (int *) malloc(size * size * sizeof(int));
+ rbuf = (int *) malloc(asize * asize * sizeof(int));
+ if (!sbuf || !rbuf) {
+ fprintf(stderr, "Could not allocated buffers!\n");
+ MPI_Abort(comm, 1);
+ }
- /* Load up the buffers */
- for (i=0; i<size*size; i++) {
- sbuf[i] = i + 100*rank;
- rbuf[i] = -i;
- }
+ /* Load up the buffers */
+ for (i = 0; i < size * size; i++) {
+ sbuf[i] = i + 100 * rank;
+ rbuf[i] = -i;
+ }
- /* Create and load the arguments to alltoallv */
- sendcounts = (int *)malloc( size * sizeof(int) );
- recvcounts = (int *)malloc( size * sizeof(int) );
- rdispls = (int *)malloc( size * sizeof(int) );
- sdispls = (int *)malloc( size * sizeof(int) );
- if (!sendcounts || !recvcounts || !rdispls || !sdispls) {
- fprintf( stderr, "Could not allocate arg items!\n" );
- MPI_Abort( comm, 1 );
- }
- for (i=0; i<size; i++) {
- sendcounts[i] = i;
- sdispls[i] = (i * (i+1))/2;
- recvcounts[i] = rank;
- rdispls[i] = i * rank;
- }
- MTest_Alltoallv(sbuf, sendcounts, sdispls, MPI_INT,
- rbuf, recvcounts, rdispls, MPI_INT, comm);
+ /* Create and load the arguments to alltoallv */
+ sendcounts = (int *) malloc(size * sizeof(int));
+ recvcounts = (int *) malloc(size * sizeof(int));
+ rdispls = (int *) malloc(size * sizeof(int));
+ sdispls = (int *) malloc(size * sizeof(int));
+ if (!sendcounts || !recvcounts || !rdispls || !sdispls) {
+ fprintf(stderr, "Could not allocate arg items!\n");
+ MPI_Abort(comm, 1);
+ }
+ for (i = 0; i < size; i++) {
+ sendcounts[i] = i;
+ sdispls[i] = (i * (i + 1)) / 2;
+ recvcounts[i] = rank;
+ rdispls[i] = i * rank;
+ }
+ MTest_Alltoallv(sbuf, sendcounts, sdispls, MPI_INT,
+ rbuf, recvcounts, rdispls, MPI_INT, comm);
- /* Check rbuf */
- for (i=0; i<size; i++) {
- p = rbuf + rdispls[i];
- for (j=0; j<rank; j++) {
- if (p[j] != i * 100 + (rank*(rank+1))/2 + j) {
- fprintf( stderr, "[%d] got %d expected %d for %dth\n",
- rank, p[j],(i*(i+1))/2 + j, j );
- err++;
- }
- }
- }
+ /* Check rbuf */
+ for (i = 0; i < size; i++) {
+ p = rbuf + rdispls[i];
+ for (j = 0; j < rank; j++) {
+ if (p[j] != i * 100 + (rank * (rank + 1)) / 2 + j) {
+ fprintf(stderr, "[%d] got %d expected %d for %dth\n",
+ rank, p[j], (i * (i + 1)) / 2 + j, j);
+ err++;
+ }
+ }
+ }
- free( sdispls );
- free( rdispls );
- free( recvcounts );
- free( sendcounts );
- free( rbuf );
- free( sbuf );
- MTestFreeComm( &comm );
+ free(sdispls);
+ free(rdispls);
+ free(recvcounts);
+ free(sendcounts);
+ free(rbuf);
+ free(sbuf);
+ MTestFreeComm(&comm);
}
- MTest_Finalize( err );
+ MTest_Finalize(err);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/icalltoallw.c b/test/mpi/coll/icalltoallw.c
index aeb1370..7bf1544 100644
--- a/test/mpi/coll/icalltoallw.c
+++ b/test/mpi/coll/icalltoallw.c
@@ -16,95 +16,96 @@
Because there are separate send and receive types to alltoallw,
there need to be tests to rearrange data on the fly. Not done yet.
-
+
The first test sends i items to processor i from all processors.
Currently, the test uses only MPI_INT; this is adequate for testing systems
that use point-to-point operations
*/
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
MPI_Comm comm;
- int *sbuf, *rbuf;
- int rank, size, lsize, asize;
- int *sendcounts, *recvcounts, *rdispls, *sdispls;
- int i, j, *p, err;
+ int *sbuf, *rbuf;
+ int rank, size, lsize, asize;
+ int *sendcounts, *recvcounts, *rdispls, *sdispls;
+ int i, j, *p, err;
MPI_Datatype *sendtypes, *recvtypes;
- int leftGroup;
+ int leftGroup;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
err = 0;
- while (MTestGetIntercomm( &comm, &leftGroup, 4 )) {
- if (comm == MPI_COMM_NULL) continue;
+ while (MTestGetIntercomm(&comm, &leftGroup, 4)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+
+ /* Create the buffer */
+ MPI_Comm_size(comm, &lsize);
+ MPI_Comm_remote_size(comm, &size);
+ asize = (lsize > size) ? lsize : size;
+ MPI_Comm_rank(comm, &rank);
+ sbuf = (int *) malloc(size * size * sizeof(int));
+ rbuf = (int *) malloc(asize * asize * sizeof(int));
+ if (!sbuf || !rbuf) {
+ fprintf(stderr, "Could not allocated buffers!\n");
+ MPI_Abort(comm, 1);
+ }
+
+ /* Load up the buffers */
+ for (i = 0; i < size * size; i++) {
+ sbuf[i] = i + 100 * rank;
+ rbuf[i] = -i;
+ }
- /* Create the buffer */
- MPI_Comm_size( comm, &lsize );
- MPI_Comm_remote_size( comm, &size );
- asize = (lsize > size) ? lsize : size;
- MPI_Comm_rank( comm, &rank );
- sbuf = (int *)malloc( size * size * sizeof(int) );
- rbuf = (int *)malloc( asize * asize * sizeof(int) );
- if (!sbuf || !rbuf) {
- fprintf( stderr, "Could not allocated buffers!\n" );
- MPI_Abort( comm, 1 );
- }
-
- /* Load up the buffers */
- for (i=0; i<size*size; i++) {
- sbuf[i] = i + 100*rank;
- rbuf[i] = -i;
- }
+ /* Create and load the arguments to alltoallv */
+ sendcounts = (int *) malloc(size * sizeof(int));
+ recvcounts = (int *) malloc(size * sizeof(int));
+ rdispls = (int *) malloc(size * sizeof(int));
+ sdispls = (int *) malloc(size * sizeof(int));
+ sendtypes = (MPI_Datatype *) malloc(size * sizeof(MPI_Datatype));
+ recvtypes = (MPI_Datatype *) malloc(size * sizeof(MPI_Datatype));
+ if (!sendcounts || !recvcounts || !rdispls || !sdispls || !sendtypes || !recvtypes) {
+ fprintf(stderr, "Could not allocate arg items!\n");
+ MPI_Abort(comm, 1);
+ }
+ /* Note that process 0 sends no data (sendcounts[0] = 0) */
+ for (i = 0; i < size; i++) {
+ sendcounts[i] = i;
+ sdispls[i] = (((i + 1) * (i)) / 2) * sizeof(int);
+ sendtypes[i] = MPI_INT;
+ recvcounts[i] = rank;
+ rdispls[i] = i * rank * sizeof(int);
+ recvtypes[i] = MPI_INT;
+ }
+ MTest_Alltoallw(sbuf, sendcounts, sdispls, sendtypes,
+ rbuf, recvcounts, rdispls, recvtypes, comm);
- /* Create and load the arguments to alltoallv */
- sendcounts = (int *)malloc( size * sizeof(int) );
- recvcounts = (int *)malloc( size * sizeof(int) );
- rdispls = (int *)malloc( size * sizeof(int) );
- sdispls = (int *)malloc( size * sizeof(int) );
- sendtypes = (MPI_Datatype *)malloc( size * sizeof(MPI_Datatype) );
- recvtypes = (MPI_Datatype *)malloc( size * sizeof(MPI_Datatype) );
- if (!sendcounts || !recvcounts || !rdispls || !sdispls || !sendtypes || !recvtypes) {
- fprintf( stderr, "Could not allocate arg items!\n" );
- MPI_Abort( comm, 1 );
- }
- /* Note that process 0 sends no data (sendcounts[0] = 0) */
- for (i=0; i<size; i++) {
- sendcounts[i] = i;
- sdispls[i] = (((i+1) * (i))/2) * sizeof(int);
- sendtypes[i] = MPI_INT;
- recvcounts[i] = rank;
- rdispls[i] = i * rank * sizeof(int);
- recvtypes[i] = MPI_INT;
- }
- MTest_Alltoallw(sbuf, sendcounts, sdispls, sendtypes,
- rbuf, recvcounts, rdispls, recvtypes, comm);
-
- /* Check rbuf */
- for (i=0; i<size; i++) {
- p = rbuf + rdispls[i]/sizeof(int);
- for (j=0; j<rank; j++) {
- if (p[j] != i * 100 + (rank*(rank+1))/2 + j) {
- fprintf( stderr, "[%d] got %d expected %d for %dth\n",
- rank, p[j],(i*(i+1))/2 + j, j );
- err++;
- }
- }
- }
+ /* Check rbuf */
+ for (i = 0; i < size; i++) {
+ p = rbuf + rdispls[i] / sizeof(int);
+ for (j = 0; j < rank; j++) {
+ if (p[j] != i * 100 + (rank * (rank + 1)) / 2 + j) {
+ fprintf(stderr, "[%d] got %d expected %d for %dth\n",
+ rank, p[j], (i * (i + 1)) / 2 + j, j);
+ err++;
+ }
+ }
+ }
- free(sendtypes);
- free(recvtypes);
- free( sdispls );
- free( rdispls );
- free( recvcounts );
- free( sendcounts );
- free( rbuf );
- free( sbuf );
- MTestFreeComm( &comm );
+ free(sendtypes);
+ free(recvtypes);
+ free(sdispls);
+ free(rdispls);
+ free(recvcounts);
+ free(sendcounts);
+ free(rbuf);
+ free(sbuf);
+ MTestFreeComm(&comm);
}
- MTest_Finalize( err );
+ MTest_Finalize(err);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/icbarrier.c b/test/mpi/coll/icbarrier.c
index 6551603..43e48c0 100644
--- a/test/mpi/coll/icbarrier.c
+++ b/test/mpi/coll/icbarrier.c
@@ -16,45 +16,45 @@ static char MTEST_Descrip[] = "Simple intercomm barrier test";
/* This only checks that the Barrier operation accepts intercommunicators.
It does not check for the semantics of a intercomm barrier (all processes
- in the local group can exit when (but not before) all processes in the
+ in the local group can exit when (but not before) all processes in the
remote group enter the barrier */
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int leftGroup;
MPI_Comm comm;
MPI_Datatype datatype;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
datatype = MPI_INT;
/* Get an intercommunicator */
- while (MTestGetIntercomm( &comm, &leftGroup, 4 )) {
+ while (MTestGetIntercomm(&comm, &leftGroup, 4)) {
if (comm == MPI_COMM_NULL)
continue;
- /* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN );
- if (leftGroup) {
- err = MTest_Barrier(comm);
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- }
- else {
- /* In the right group */
- err = MTest_Barrier(comm);
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- }
- MTestFreeComm( &comm );
+ /* To improve reporting of problems about operations, we
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN);
+ if (leftGroup) {
+ err = MTest_Barrier(comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ }
+ else {
+ /* In the right group */
+ err = MTest_Barrier(comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ }
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/icbcast.c b/test/mpi/coll/icbcast.c
index c289c3c..39d0cda 100644
--- a/test/mpi/coll/icbcast.c
+++ b/test/mpi/coll/icbcast.c
@@ -14,7 +14,7 @@
static char MTEST_Descrip[] = "Simple intercomm broadcast test";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int *buf = 0;
@@ -22,67 +22,69 @@ int main( int argc, char *argv[] )
MPI_Comm comm;
MPI_Datatype datatype;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
datatype = MPI_INT;
/* Get an intercommunicator */
- while (MTestGetIntercomm( &comm, &leftGroup, 4 )) {
+ while (MTestGetIntercomm(&comm, &leftGroup, 4)) {
if (comm == MPI_COMM_NULL)
continue;
- MPI_Comm_rank( comm, &rank );
+ MPI_Comm_rank(comm, &rank);
- /* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN );
+ /* To improve reporting of problems about operations, we
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN);
- for (count = 1; count < 65000; count = 2 * count) {
- buf = (int *)malloc( count * sizeof(int) );
- if (leftGroup) {
- if (rank == 0) {
- for (i=0; i<count; i++) buf[i] = i;
- }
- else {
- for (i=0; i<count; i++) buf[i] = -1;
- }
- err = MTest_Bcast(buf, count, datatype,
- (rank == 0) ? MPI_ROOT : MPI_PROC_NULL,
- comm);
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- /* Test that no other process in this group received the
- broadcast */
- if (rank != 0) {
- for (i=0; i<count; i++) {
- if (buf[i] != -1) {
- errs++;
- }
- }
- }
- }
- else {
- /* In the right group */
- for (i=0; i<count; i++) buf[i] = -1;
- err = MTest_Bcast(buf, count, datatype, 0, comm);
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- /* Check that we have received the correct data */
- for (i=0; i<count; i++) {
- if (buf[i] != i) {
- errs++;
- }
- }
- }
- free( buf );
- }
- MTestFreeComm( &comm );
+ for (count = 1; count < 65000; count = 2 * count) {
+ buf = (int *) malloc(count * sizeof(int));
+ if (leftGroup) {
+ if (rank == 0) {
+ for (i = 0; i < count; i++)
+ buf[i] = i;
+ }
+ else {
+ for (i = 0; i < count; i++)
+ buf[i] = -1;
+ }
+ err = MTest_Bcast(buf, count, datatype,
+ (rank == 0) ? MPI_ROOT : MPI_PROC_NULL, comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ /* Test that no other process in this group received the
+ * broadcast */
+ if (rank != 0) {
+ for (i = 0; i < count; i++) {
+ if (buf[i] != -1) {
+ errs++;
+ }
+ }
+ }
+ }
+ else {
+ /* In the right group */
+ for (i = 0; i < count; i++)
+ buf[i] = -1;
+ err = MTest_Bcast(buf, count, datatype, 0, comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ /* Check that we have received the correct data */
+ for (i = 0; i < count; i++) {
+ if (buf[i] != i) {
+ errs++;
+ }
+ }
+ }
+ free(buf);
+ }
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/icgather.c b/test/mpi/coll/icgather.c
index 54bb7e4..b4ec3f3 100644
--- a/test/mpi/coll/icgather.c
+++ b/test/mpi/coll/icgather.c
@@ -14,7 +14,7 @@
static char MTEST_Descrip[] = "Simple intercomm gather test";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int *buf = 0;
@@ -22,66 +22,67 @@ int main( int argc, char *argv[] )
MPI_Comm comm;
MPI_Datatype datatype;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
datatype = MPI_INT;
/* Get an intercommunicator */
- while (MTestGetIntercomm( &comm, &leftGroup, 4 )) {
- if (comm == MPI_COMM_NULL) continue;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_remote_size( comm, &rsize );
- MPI_Comm_size( comm, &size );
- /* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN );
- for (count = 1; count < 65000; count = 2 * count) {
- if (leftGroup) {
- buf = (int *)malloc( count * rsize * sizeof(int) );
- for (i=0; i<count*rsize; i++) buf[i] = -1;
+ while (MTestGetIntercomm(&comm, &leftGroup, 4)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_remote_size(comm, &rsize);
+ MPI_Comm_size(comm, &size);
+ /* To improve reporting of problems about operations, we
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN);
+ for (count = 1; count < 65000; count = 2 * count) {
+ if (leftGroup) {
+ buf = (int *) malloc(count * rsize * sizeof(int));
+ for (i = 0; i < count * rsize; i++)
+ buf[i] = -1;
- err = MTest_Gather(NULL, 0, datatype,
- buf, count, datatype,
- (rank == 0) ? MPI_ROOT : MPI_PROC_NULL,
- comm);
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- /* Test that no other process in this group received the
- broadcast */
- if (rank != 0) {
- for (i=0; i<count; i++) {
- if (buf[i] != -1) {
- errs++;
- }
- }
- }
- else {
- /* Check for the correct data */
- for (i=0; i<count*rsize; i++) {
- if (buf[i] != i) {
- errs++;
- }
- }
- }
- }
- else {
- /* In the right group */
- buf = (int *)malloc( count * sizeof(int) );
- for (i=0; i<count; i++) buf[i] = rank * count + i;
- err = MTest_Gather(buf, count, datatype,
- NULL, 0, datatype, 0, comm);
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- }
- free( buf );
- }
- MTestFreeComm( &comm );
+ err = MTest_Gather(NULL, 0, datatype,
+ buf, count, datatype,
+ (rank == 0) ? MPI_ROOT : MPI_PROC_NULL, comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ /* Test that no other process in this group received the
+ * broadcast */
+ if (rank != 0) {
+ for (i = 0; i < count; i++) {
+ if (buf[i] != -1) {
+ errs++;
+ }
+ }
+ }
+ else {
+ /* Check for the correct data */
+ for (i = 0; i < count * rsize; i++) {
+ if (buf[i] != i) {
+ errs++;
+ }
+ }
+ }
+ }
+ else {
+ /* In the right group */
+ buf = (int *) malloc(count * sizeof(int));
+ for (i = 0; i < count; i++)
+ buf[i] = rank * count + i;
+ err = MTest_Gather(buf, count, datatype, NULL, 0, datatype, 0, comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ }
+ free(buf);
+ }
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/icgatherv.c b/test/mpi/coll/icgatherv.c
index b726dcc..f053fe7 100644
--- a/test/mpi/coll/icgatherv.c
+++ b/test/mpi/coll/icgatherv.c
@@ -14,7 +14,7 @@
static char MTEST_Descrip[] = "Simple intercomm gatherv test";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int *buf = 0;
@@ -24,78 +24,79 @@ int main( int argc, char *argv[] )
MPI_Comm comm;
MPI_Datatype datatype;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
datatype = MPI_INT;
- while (MTestGetIntercomm( &comm, &leftGroup, 4 )) {
- if (comm == MPI_COMM_NULL) continue;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_remote_size( comm, &rsize );
- MPI_Comm_size( comm, &size );
-
- /* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN );
+ while (MTestGetIntercomm(&comm, &leftGroup, 4)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_remote_size(comm, &rsize);
+ MPI_Comm_size(comm, &size);
- for (count = 1; count < 65000; count = 2 * count) {
- /* Get an intercommunicator */
- recvcounts = (int *)malloc( rsize * sizeof(int) );
- recvdispls = (int *)malloc( rsize * sizeof(int) );
- /* This simple test duplicates the Gather test,
- using the same lengths for all messages */
- for (i=0; i<rsize; i++) {
- recvcounts[i] = count;
- recvdispls[i] = count * i;
- }
- if (leftGroup) {
- buf = (int *)malloc( count * rsize * sizeof(int) );
- for (i=0; i<count*rsize; i++) buf[i] = -1;
+ /* To improve reporting of problems about operations, we
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN);
- err = MTest_Gatherv(NULL, 0, datatype,
+ for (count = 1; count < 65000; count = 2 * count) {
+ /* Get an intercommunicator */
+ recvcounts = (int *) malloc(rsize * sizeof(int));
+ recvdispls = (int *) malloc(rsize * sizeof(int));
+ /* This simple test duplicates the Gather test,
+ * using the same lengths for all messages */
+ for (i = 0; i < rsize; i++) {
+ recvcounts[i] = count;
+ recvdispls[i] = count * i;
+ }
+ if (leftGroup) {
+ buf = (int *) malloc(count * rsize * sizeof(int));
+ for (i = 0; i < count * rsize; i++)
+ buf[i] = -1;
+
+ err = MTest_Gatherv(NULL, 0, datatype,
buf, recvcounts, recvdispls, datatype,
- (rank == 0) ? MPI_ROOT : MPI_PROC_NULL,
- comm);
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- /* Test that no other process in this group received the
- broadcast */
- if (rank != 0) {
- for (i=0; i<count; i++) {
- if (buf[i] != -1) {
- errs++;
- }
- }
- }
- else {
- /* Check for the correct data */
- for (i=0; i<count*rsize; i++) {
- if (buf[i] != i) {
- errs++;
- }
- }
- }
- }
- else {
- /* In the right group */
- buf = (int *)malloc( count * sizeof(int) );
- for (i=0; i<count; i++) buf[i] = rank * count + i;
- err = MTest_Gatherv(buf, count, datatype,
- NULL, 0, 0, datatype, 0, comm);
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- }
- free( buf );
- free( recvcounts );
- free( recvdispls );
- }
- MTestFreeComm( &comm );
+ (rank == 0) ? MPI_ROOT : MPI_PROC_NULL, comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ /* Test that no other process in this group received the
+ * broadcast */
+ if (rank != 0) {
+ for (i = 0; i < count; i++) {
+ if (buf[i] != -1) {
+ errs++;
+ }
+ }
+ }
+ else {
+ /* Check for the correct data */
+ for (i = 0; i < count * rsize; i++) {
+ if (buf[i] != i) {
+ errs++;
+ }
+ }
+ }
+ }
+ else {
+ /* In the right group */
+ buf = (int *) malloc(count * sizeof(int));
+ for (i = 0; i < count; i++)
+ buf[i] = rank * count + i;
+ err = MTest_Gatherv(buf, count, datatype, NULL, 0, 0, datatype, 0, comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ }
+ free(buf);
+ free(recvcounts);
+ free(recvdispls);
+ }
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/icreduce.c b/test/mpi/coll/icreduce.c
index 7d6ba94..a71ac6f 100644
--- a/test/mpi/coll/icreduce.c
+++ b/test/mpi/coll/icreduce.c
@@ -14,84 +14,83 @@
static char MTEST_Descrip[] = "Simple intercomm reduce test";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
- int *sendbuf = 0, *recvbuf=0;
+ int *sendbuf = 0, *recvbuf = 0;
int leftGroup, i, count, rank, rsize;
MPI_Comm comm;
MPI_Datatype datatype;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
datatype = MPI_INT;
/* Get an intercommunicator */
- while (MTestGetIntercomm( &comm, &leftGroup, 4 )) {
+ while (MTestGetIntercomm(&comm, &leftGroup, 4)) {
if (comm == MPI_COMM_NULL)
continue;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_remote_size( comm, &rsize );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_remote_size(comm, &rsize);
- /* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN );
+ /* To improve reporting of problems about operations, we
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN);
- for (count = 1; count < 65000; count = 2 * count) {
- sendbuf = (int *)malloc( count * sizeof(int) );
- recvbuf = (int *)malloc( count * sizeof(int) );
- for (i=0; i<count; i++) {
- sendbuf[i] = -1;
- recvbuf[i] = -1;
- }
- if (leftGroup) {
- err = MTest_Reduce(sendbuf, recvbuf, count, datatype, MPI_SUM,
- (rank == 0) ? MPI_ROOT : MPI_PROC_NULL,
- comm);
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- /* Test that no other process in this group received the
- broadcast, and that we got the right answers */
- if (rank == 0) {
- for (i=0; i<count; i++) {
- if (recvbuf[i] != i * rsize) {
- errs++;
- }
- }
- }
- else {
- for (i=0; i<count; i++) {
- if (recvbuf[i] != -1) {
- errs++;
- }
- }
- }
- }
- else {
- /* In the right group */
- for (i=0; i<count; i++) sendbuf[i] = i;
- err = MTest_Reduce(sendbuf, recvbuf, count, datatype, MPI_SUM,
- 0, comm);
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- /* Check that we have received no data */
- for (i=0; i<count; i++) {
- if (recvbuf[i] != -1) {
- errs++;
- }
- }
- }
- free( sendbuf );
- free( recvbuf );
- }
- MTestFreeComm( &comm );
+ for (count = 1; count < 65000; count = 2 * count) {
+ sendbuf = (int *) malloc(count * sizeof(int));
+ recvbuf = (int *) malloc(count * sizeof(int));
+ for (i = 0; i < count; i++) {
+ sendbuf[i] = -1;
+ recvbuf[i] = -1;
+ }
+ if (leftGroup) {
+ err = MTest_Reduce(sendbuf, recvbuf, count, datatype, MPI_SUM,
+ (rank == 0) ? MPI_ROOT : MPI_PROC_NULL, comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ /* Test that no other process in this group received the
+ * broadcast, and that we got the right answers */
+ if (rank == 0) {
+ for (i = 0; i < count; i++) {
+ if (recvbuf[i] != i * rsize) {
+ errs++;
+ }
+ }
+ }
+ else {
+ for (i = 0; i < count; i++) {
+ if (recvbuf[i] != -1) {
+ errs++;
+ }
+ }
+ }
+ }
+ else {
+ /* In the right group */
+ for (i = 0; i < count; i++)
+ sendbuf[i] = i;
+ err = MTest_Reduce(sendbuf, recvbuf, count, datatype, MPI_SUM, 0, comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ /* Check that we have received no data */
+ for (i = 0; i < count; i++) {
+ if (recvbuf[i] != -1) {
+ errs++;
+ }
+ }
+ }
+ free(sendbuf);
+ free(recvbuf);
+ }
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/icscatter.c b/test/mpi/coll/icscatter.c
index 2f5b28f..6ac8e41 100644
--- a/test/mpi/coll/icscatter.c
+++ b/test/mpi/coll/icscatter.c
@@ -14,7 +14,7 @@
static char MTEST_Descrip[] = "Simple intercomm scatter test";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int *buf = 0;
@@ -22,77 +22,78 @@ int main( int argc, char *argv[] )
MPI_Comm comm;
MPI_Datatype datatype;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
datatype = MPI_INT;
/* Get an intercommunicator */
- while (MTestGetIntercomm( &comm, &leftGroup, 4 )) {
- if (comm == MPI_COMM_NULL) continue;
- MPI_Comm_remote_size( comm, &rsize );
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ while (MTestGetIntercomm(&comm, &leftGroup, 4)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ MPI_Comm_remote_size(comm, &rsize);
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
- /* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN );
+ /* To improve reporting of problems about operations, we
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN);
- for (count = 1; count < 65000; count = 2 * count) {
- buf = 0;
- if (leftGroup) {
- buf = (int *)malloc( count * rsize * sizeof(int) );
- if (rank == 0) {
- for (i=0; i<count*rsize; i++) buf[i] = i;
- }
- else {
- for (i=0; i<count*rsize; i++) buf[i] = -1;
- }
- err = MTest_Scatter(buf, count, datatype,
+ for (count = 1; count < 65000; count = 2 * count) {
+ buf = 0;
+ if (leftGroup) {
+ buf = (int *) malloc(count * rsize * sizeof(int));
+ if (rank == 0) {
+ for (i = 0; i < count * rsize; i++)
+ buf[i] = i;
+ }
+ else {
+ for (i = 0; i < count * rsize; i++)
+ buf[i] = -1;
+ }
+ err = MTest_Scatter(buf, count, datatype,
NULL, 0, datatype,
- (rank == 0) ? MPI_ROOT : MPI_PROC_NULL,
- comm);
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- /* Test that no other process in this group received the
- scatter */
- if (rank != 0) {
- for (i=0; i<count*rsize; i++) {
- if (buf[i] != -1) {
- if (errs < 10) {
- fprintf( stderr, "Received data on root group!\n" );
- }
- errs++;
- }
- }
- }
- }
- else {
- buf = (int *)malloc( count * sizeof(int) );
- /* In the right group */
- for (i=0; i<count; i++) buf[i] = -1;
- err = MTest_Scatter(NULL, 0, datatype,
- buf, count, datatype, 0, comm);
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- /* Check that we have received the correct data */
- for (i=0; i<count; i++) {
- if (buf[i] != i + rank * count) {
- if (errs < 10)
- fprintf( stderr, "buf[%d] = %d on %d\n",
- i, buf[i], rank );
- errs++;
- }
- }
- }
- free( buf );
- }
- MTestFreeComm( &comm );
+ (rank == 0) ? MPI_ROOT : MPI_PROC_NULL, comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ /* Test that no other process in this group received the
+ * scatter */
+ if (rank != 0) {
+ for (i = 0; i < count * rsize; i++) {
+ if (buf[i] != -1) {
+ if (errs < 10) {
+ fprintf(stderr, "Received data on root group!\n");
+ }
+ errs++;
+ }
+ }
+ }
+ }
+ else {
+ buf = (int *) malloc(count * sizeof(int));
+ /* In the right group */
+ for (i = 0; i < count; i++)
+ buf[i] = -1;
+ err = MTest_Scatter(NULL, 0, datatype, buf, count, datatype, 0, comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ /* Check that we have received the correct data */
+ for (i = 0; i < count; i++) {
+ if (buf[i] != i + rank * count) {
+ if (errs < 10)
+ fprintf(stderr, "buf[%d] = %d on %d\n", i, buf[i], rank);
+ errs++;
+ }
+ }
+ }
+ free(buf);
+ }
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/icscatterv.c b/test/mpi/coll/icscatterv.c
index 2e64afc..98b7f84 100644
--- a/test/mpi/coll/icscatterv.c
+++ b/test/mpi/coll/icscatterv.c
@@ -14,7 +14,7 @@
static char MTEST_Descrip[] = "Simple intercomm scatterv test";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int *buf = 0;
@@ -24,85 +24,86 @@ int main( int argc, char *argv[] )
MPI_Comm comm;
MPI_Datatype datatype;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
datatype = MPI_INT;
/* Get an intercommunicator */
- while (MTestGetIntercomm( &comm, &leftGroup, 4 )) {
- if (comm == MPI_COMM_NULL) continue;
- MPI_Comm_remote_size( comm, &rsize );
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ while (MTestGetIntercomm(&comm, &leftGroup, 4)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ MPI_Comm_remote_size(comm, &rsize);
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
- /* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN );
+ /* To improve reporting of problems about operations, we
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN);
- for (count = 1; count < 65000; count = 2 * count) {
- buf = 0;
- sendcounts = (int *)malloc( rsize * sizeof(int) );
- senddispls = (int *)malloc( rsize * sizeof(int) );
- for (i=0; i<rsize; i++) {
- sendcounts[i] = count;
- senddispls[i] = count * i;
- }
- if (leftGroup) {
- buf = (int *)malloc( count * rsize * sizeof(int) );
- if (rank == 0) {
- for (i=0; i<count*rsize; i++) buf[i] = i;
- }
- else {
- for (i=0; i<count*rsize; i++) buf[i] = -1;
- }
- err = MTest_Scatterv(buf, sendcounts, senddispls, datatype,
+ for (count = 1; count < 65000; count = 2 * count) {
+ buf = 0;
+ sendcounts = (int *) malloc(rsize * sizeof(int));
+ senddispls = (int *) malloc(rsize * sizeof(int));
+ for (i = 0; i < rsize; i++) {
+ sendcounts[i] = count;
+ senddispls[i] = count * i;
+ }
+ if (leftGroup) {
+ buf = (int *) malloc(count * rsize * sizeof(int));
+ if (rank == 0) {
+ for (i = 0; i < count * rsize; i++)
+ buf[i] = i;
+ }
+ else {
+ for (i = 0; i < count * rsize; i++)
+ buf[i] = -1;
+ }
+ err = MTest_Scatterv(buf, sendcounts, senddispls, datatype,
NULL, 0, datatype,
- (rank == 0) ? MPI_ROOT : MPI_PROC_NULL,
- comm);
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- /* Test that no other process in this group received the
- scatter */
- if (rank != 0) {
- for (i=0; i<count*rsize; i++) {
- if (buf[i] != -1) {
- if (errs < 10) {
- fprintf( stderr, "Received data on root group!\n" );
- }
- errs++;
- }
- }
- }
- }
- else {
- buf = (int *)malloc( count * sizeof(int) );
- /* In the right group */
- for (i=0; i<count; i++) buf[i] = -1;
- err = MTest_Scatterv(NULL, 0, 0, datatype,
- buf, count, datatype, 0, comm);
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- /* Check that we have received the correct data */
- for (i=0; i<count; i++) {
- if (buf[i] != i + rank * count) {
- if (errs < 10)
- fprintf( stderr, "buf[%d] = %d on %d\n",
- i, buf[i], rank );
- errs++;
- }
- }
- }
- free( sendcounts );
- free( senddispls );
- free( buf );
- }
- MTestFreeComm( &comm );
+ (rank == 0) ? MPI_ROOT : MPI_PROC_NULL, comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ /* Test that no other process in this group received the
+ * scatter */
+ if (rank != 0) {
+ for (i = 0; i < count * rsize; i++) {
+ if (buf[i] != -1) {
+ if (errs < 10) {
+ fprintf(stderr, "Received data on root group!\n");
+ }
+ errs++;
+ }
+ }
+ }
+ }
+ else {
+ buf = (int *) malloc(count * sizeof(int));
+ /* In the right group */
+ for (i = 0; i < count; i++)
+ buf[i] = -1;
+ err = MTest_Scatterv(NULL, 0, 0, datatype, buf, count, datatype, 0, comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ /* Check that we have received the correct data */
+ for (i = 0; i < count; i++) {
+ if (buf[i] != i + rank * count) {
+ if (errs < 10)
+ fprintf(stderr, "buf[%d] = %d on %d\n", i, buf[i], rank);
+ errs++;
+ }
+ }
+ }
+ free(sendcounts);
+ free(senddispls);
+ free(buf);
+ }
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/longuser.c b/test/mpi/coll/longuser.c
index fd5ac85..aa6b9c6 100644
--- a/test/mpi/coll/longuser.c
+++ b/test/mpi/coll/longuser.c
@@ -7,76 +7,72 @@
#include <stdio.h>
#include <stdlib.h>
-int add ( double *, double *, int *, MPI_Datatype * );
+int add(double *, double *, int *, MPI_Datatype *);
/*
* User-defined operation on a long value (tests proper handling of
* possible pipelining in the implementation of reductions with user-defined
* operations).
*/
-int add( double *invec, double *inoutvec, int *len, MPI_Datatype *dtype )
+int add(double *invec, double *inoutvec, int *len, MPI_Datatype * dtype)
{
int i, n = *len;
- for (i=0; i<n; i++) {
- inoutvec[i] = invec[i] + inoutvec[i];
+ for (i = 0; i < n; i++) {
+ inoutvec[i] = invec[i] + inoutvec[i];
}
return 0;
}
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
MPI_Op op;
- int i, rank, size, bufsize, errcnt = 0, toterr;
+ int i, rank, size, bufsize, errcnt = 0, toterr;
double *inbuf, *outbuf, value;
-
- MPI_Init( &argc, &argv );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
- MPI_Op_create( (MPI_User_function *)add, 1, &op );
-
+
+ MPI_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ MPI_Op_create((MPI_User_function *) add, 1, &op);
+
bufsize = 1;
while (bufsize < 100000) {
- inbuf = (double *)malloc( bufsize * sizeof(double) );
- outbuf = (double *)malloc( bufsize * sizeof(double) );
- if (! inbuf || ! outbuf) {
- fprintf( stderr, "Could not allocate buffers for size %d\n",
- bufsize );
- errcnt++;
- break;
- }
+ inbuf = (double *) malloc(bufsize * sizeof(double));
+ outbuf = (double *) malloc(bufsize * sizeof(double));
+ if (!inbuf || !outbuf) {
+ fprintf(stderr, "Could not allocate buffers for size %d\n", bufsize);
+ errcnt++;
+ break;
+ }
- value = (rank & 0x1) ? 1.0 : -1.0;
- for (i=0; i<bufsize; i++) {
- inbuf[i] = value;
- outbuf[i] = 100.0;
- }
- MPI_Allreduce( inbuf, outbuf, bufsize, MPI_DOUBLE, op,
- MPI_COMM_WORLD );
- /* Check values */
- value = (size & 0x1) ? -1.0 : 0.0;
- for (i=0; i<bufsize; i++) {
- if (outbuf[i] != value) {
- if (errcnt < 10)
- printf( "outbuf[%d] = %f, should = %f\n", i, outbuf[i],
- value );
- errcnt ++;
- }
- }
- free( inbuf );
- free( outbuf );
- bufsize *= 2;
+ value = (rank & 0x1) ? 1.0 : -1.0;
+ for (i = 0; i < bufsize; i++) {
+ inbuf[i] = value;
+ outbuf[i] = 100.0;
+ }
+ MPI_Allreduce(inbuf, outbuf, bufsize, MPI_DOUBLE, op, MPI_COMM_WORLD);
+ /* Check values */
+ value = (size & 0x1) ? -1.0 : 0.0;
+ for (i = 0; i < bufsize; i++) {
+ if (outbuf[i] != value) {
+ if (errcnt < 10)
+ printf("outbuf[%d] = %f, should = %f\n", i, outbuf[i], value);
+ errcnt++;
+ }
+ }
+ free(inbuf);
+ free(outbuf);
+ bufsize *= 2;
}
-
- MPI_Allreduce( &errcnt, &toterr, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+
+ MPI_Allreduce(&errcnt, &toterr, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank == 0) {
- if (toterr == 0)
- printf( " No Errors\n" );
- else
- printf( "*! %d errors!\n", toterr );
+ if (toterr == 0)
+ printf(" No Errors\n");
+ else
+ printf("*! %d errors!\n", toterr);
}
- MPI_Op_free( &op );
- MPI_Finalize( );
+ MPI_Op_free(&op);
+ MPI_Finalize();
return 0;
}
-
diff --git a/test/mpi/coll/nonblocking.c b/test/mpi/coll/nonblocking.c
index b9f4f5b..9942b2b 100644
--- a/test/mpi/coll/nonblocking.c
+++ b/test/mpi/coll/nonblocking.c
@@ -50,31 +50,31 @@ int main(int argc, char **argv)
/* enough space for every process to contribute at least NUM_INTS ints to any
* collective operation */
- sbuf = malloc(NUM_INTS*size*sizeof(int));
+ sbuf = malloc(NUM_INTS * size * sizeof(int));
my_assert(sbuf);
- rbuf = malloc(NUM_INTS*size*sizeof(int));
+ rbuf = malloc(NUM_INTS * size * sizeof(int));
my_assert(rbuf);
- scounts = malloc(size*sizeof(int));
+ scounts = malloc(size * sizeof(int));
my_assert(scounts);
- rcounts = malloc(size*sizeof(int));
+ rcounts = malloc(size * sizeof(int));
my_assert(rcounts);
- sdispls = malloc(size*sizeof(int));
+ sdispls = malloc(size * sizeof(int));
my_assert(sdispls);
- rdispls = malloc(size*sizeof(int));
+ rdispls = malloc(size * sizeof(int));
my_assert(rdispls);
- types = malloc(size*sizeof(int));
+ types = malloc(size * sizeof(int));
my_assert(types);
for (i = 0; i < size; ++i) {
- sbuf[2*i] = i;
- sbuf[2*i+1] = i;
- rbuf[2*i] = i;
- rbuf[2*i+1] = i;
- scounts[i] = NUM_INTS;
- rcounts[i] = NUM_INTS;
- sdispls[i] = i * NUM_INTS;
- rdispls[i] = i * NUM_INTS;
- types[i] = MPI_INT;
+ sbuf[2 * i] = i;
+ sbuf[2 * i + 1] = i;
+ rbuf[2 * i] = i;
+ rbuf[2 * i + 1] = i;
+ scounts[i] = NUM_INTS;
+ rcounts[i] = NUM_INTS;
+ sdispls[i] = i * NUM_INTS;
+ rdispls[i] = i * NUM_INTS;
+ types[i] = MPI_INT;
}
MPI_Ibarrier(comm, &req);
@@ -96,7 +96,8 @@ int main(int argc, char **argv)
MPI_Wait(&req, MPI_STATUS_IGNORE);
if (0 == rank)
- MPI_Igatherv(MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, rbuf, rcounts, rdispls, MPI_INT, 0, comm, &req);
+ MPI_Igatherv(MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, rbuf, rcounts, rdispls, MPI_INT, 0, comm,
+ &req);
else
MPI_Igatherv(sbuf, NUM_INTS, MPI_INT, rbuf, rcounts, rdispls, MPI_INT, 0, comm, &req);
MPI_Wait(&req, MPI_STATUS_IGNORE);
@@ -114,7 +115,8 @@ int main(int argc, char **argv)
MPI_Wait(&req, MPI_STATUS_IGNORE);
if (0 == rank)
- MPI_Iscatterv(sbuf, scounts, sdispls, MPI_INT, MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, 0, comm, &req);
+ MPI_Iscatterv(sbuf, scounts, sdispls, MPI_INT, MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, 0, comm,
+ &req);
else
MPI_Iscatterv(sbuf, scounts, sdispls, MPI_INT, rbuf, NUM_INTS, MPI_INT, 0, comm, &req);
MPI_Wait(&req, MPI_STATUS_IGNORE);
@@ -128,7 +130,8 @@ int main(int argc, char **argv)
MPI_Iallgatherv(sbuf, NUM_INTS, MPI_INT, rbuf, rcounts, rdispls, MPI_INT, comm, &req);
MPI_Wait(&req, MPI_STATUS_IGNORE);
- MPI_Iallgatherv(MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, rbuf, rcounts, rdispls, MPI_INT, comm, &req);
+ MPI_Iallgatherv(MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, rbuf, rcounts, rdispls, MPI_INT, comm,
+ &req);
MPI_Wait(&req, MPI_STATUS_IGNORE);
MPI_Ialltoall(sbuf, NUM_INTS, MPI_INT, rbuf, NUM_INTS, MPI_INT, comm, &req);
@@ -140,7 +143,8 @@ int main(int argc, char **argv)
MPI_Ialltoallv(sbuf, scounts, sdispls, MPI_INT, rbuf, rcounts, rdispls, MPI_INT, comm, &req);
MPI_Wait(&req, MPI_STATUS_IGNORE);
- MPI_Ialltoallv(MPI_IN_PLACE, NULL, NULL, MPI_DATATYPE_NULL, rbuf, rcounts, rdispls, MPI_INT, comm, &req);
+ MPI_Ialltoallv(MPI_IN_PLACE, NULL, NULL, MPI_DATATYPE_NULL, rbuf, rcounts, rdispls, MPI_INT,
+ comm, &req);
MPI_Wait(&req, MPI_STATUS_IGNORE);
MPI_Ialltoallw(sbuf, scounts, sdispls, types, rbuf, rcounts, rdispls, types, comm, &req);
@@ -188,12 +192,18 @@ int main(int argc, char **argv)
MPI_Iexscan(MPI_IN_PLACE, rbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req);
MPI_Wait(&req, MPI_STATUS_IGNORE);
- if (sbuf) free(sbuf);
- if (rbuf) free(rbuf);
- if (scounts) free(scounts);
- if (rcounts) free(rcounts);
- if (sdispls) free(sdispls);
- if (rdispls) free(rdispls);
+ if (sbuf)
+ free(sbuf);
+ if (rbuf)
+ free(rbuf);
+ if (scounts)
+ free(scounts);
+ if (rcounts)
+ free(rcounts);
+ if (sdispls)
+ free(sdispls);
+ if (rdispls)
+ free(rdispls);
if (rank == 0) {
if (errs)
@@ -204,4 +214,3 @@ int main(int argc, char **argv)
MPI_Finalize();
return 0;
}
-
diff --git a/test/mpi/coll/nonblocking2.c b/test/mpi/coll/nonblocking2.c
index 3de5d12..634077b 100644
--- a/test/mpi/coll/nonblocking2.c
+++ b/test/mpi/coll/nonblocking2.c
@@ -26,7 +26,7 @@
} \
} while (0)
-static void sum_fn(void *invec, void *inoutvec, int *len, MPI_Datatype *datatype)
+static void sum_fn(void *invec, void *inoutvec, int *len, MPI_Datatype * datatype)
{
int i;
int *in = invec;
@@ -56,14 +56,14 @@ int main(int argc, char **argv)
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
- buf = malloc(COUNT*size*sizeof(int));
- recvbuf = malloc(COUNT*size*sizeof(int));
- sendcounts = malloc(size*sizeof(int));
- recvcounts = malloc(size*sizeof(int));
- sdispls = malloc(size*sizeof(int));
- rdispls = malloc(size*sizeof(int));
- sendtypes = malloc(size*sizeof(MPI_Datatype));
- recvtypes = malloc(size*sizeof(MPI_Datatype));
+ buf = malloc(COUNT * size * sizeof(int));
+ recvbuf = malloc(COUNT * size * sizeof(int));
+ sendcounts = malloc(size * sizeof(int));
+ recvcounts = malloc(size * sizeof(int));
+ sdispls = malloc(size * sizeof(int));
+ rdispls = malloc(size * sizeof(int));
+ sendtypes = malloc(size * sizeof(MPI_Datatype));
+ recvtypes = malloc(size * sizeof(MPI_Datatype));
/* MPI_Ibcast */
for (i = 0; i < COUNT; ++i) {
@@ -84,8 +84,8 @@ int main(int argc, char **argv)
}
/* MPI_Ibcast (again, but designed to stress scatter/allgather impls) */
- buf_alias = (signed char *)buf;
- my_assert(COUNT*size*sizeof(int) > PRIME); /* sanity */
+ buf_alias = (signed char *) buf;
+ my_assert(COUNT * size * sizeof(int) > PRIME); /* sanity */
for (i = 0; i < PRIME; ++i) {
if (rank == 0)
buf_alias[i] = i;
@@ -116,16 +116,17 @@ int main(int argc, char **argv)
MPI_Wait(&req, MPI_STATUS_IGNORE);
if (rank == 0) {
for (i = 0; i < COUNT; ++i) {
- if (recvbuf[i] != ((size * (size-1) / 2) + (i * size)))
- printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i], ((size * (size-1) / 2) + (i * size)));
- my_assert(recvbuf[i] == ((size * (size-1) / 2) + (i * size)));
+ if (recvbuf[i] != ((size * (size - 1) / 2) + (i * size)))
+ printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i],
+ ((size * (size - 1) / 2) + (i * size)));
+ my_assert(recvbuf[i] == ((size * (size - 1) / 2) + (i * size)));
}
}
/* same again, use a user op and free it before the wait */
{
MPI_Op op = MPI_OP_NULL;
- MPI_Op_create(sum_fn, /*commute=*/1, &op);
+ MPI_Op_create(sum_fn, /*commute= */ 1, &op);
for (i = 0; i < COUNT; ++i) {
buf[i] = rank + i;
@@ -136,9 +137,10 @@ int main(int argc, char **argv)
MPI_Wait(&req, MPI_STATUS_IGNORE);
if (rank == 0) {
for (i = 0; i < COUNT; ++i) {
- if (recvbuf[i] != ((size * (size-1) / 2) + (i * size)))
- printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i], ((size * (size-1) / 2) + (i * size)));
- my_assert(recvbuf[i] == ((size * (size-1) / 2) + (i * size)));
+ if (recvbuf[i] != ((size * (size - 1) / 2) + (i * size)))
+ printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i],
+ ((size * (size - 1) / 2) + (i * size)));
+ my_assert(recvbuf[i] == ((size * (size - 1) / 2) + (i * size)));
}
}
}
@@ -151,9 +153,10 @@ int main(int argc, char **argv)
MPI_Iallreduce(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &req);
MPI_Wait(&req, MPI_STATUS_IGNORE);
for (i = 0; i < COUNT; ++i) {
- if (recvbuf[i] != ((size * (size-1) / 2) + (i * size)))
- printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i], ((size * (size-1) / 2) + (i * size)));
- my_assert(recvbuf[i] == ((size * (size-1) / 2) + (i * size)));
+ if (recvbuf[i] != ((size * (size - 1) / 2) + (i * size)))
+ printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i],
+ ((size * (size - 1) / 2) + (i * size)));
+ my_assert(recvbuf[i] == ((size * (size - 1) / 2) + (i * size)));
}
/* MPI_Ialltoallv (a weak test, neither irregular nor sparse) */
@@ -163,21 +166,22 @@ int main(int argc, char **argv)
sdispls[i] = COUNT * i;
rdispls[i] = COUNT * i;
for (j = 0; j < COUNT; ++j) {
- buf[i*COUNT+j] = rank + (i * j);
- recvbuf[i*COUNT+j] = 0xdeadbeef;
+ buf[i * COUNT + j] = rank + (i * j);
+ recvbuf[i * COUNT + j] = 0xdeadbeef;
}
}
- MPI_Ialltoallv(buf, sendcounts, sdispls, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT, MPI_COMM_WORLD, &req);
+ MPI_Ialltoallv(buf, sendcounts, sdispls, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT,
+ MPI_COMM_WORLD, &req);
MPI_Wait(&req, MPI_STATUS_IGNORE);
for (i = 0; i < size; ++i) {
for (j = 0; j < COUNT; ++j) {
- /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (rank * j)));*/
- my_assert(recvbuf[i*COUNT+j] == (i + (rank * j)));
+ /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (rank * j))); */
+ my_assert(recvbuf[i * COUNT + j] == (i + (rank * j)));
}
}
/* MPI_Igather */
- for (i = 0; i < size*COUNT; ++i) {
+ for (i = 0; i < size * COUNT; ++i) {
buf[i] = rank + i;
recvbuf[i] = 0xdeadbeef;
}
@@ -186,12 +190,12 @@ int main(int argc, char **argv)
if (rank == 0) {
for (i = 0; i < size; ++i) {
for (j = 0; j < COUNT; ++j) {
- my_assert(recvbuf[i*COUNT+j] == i + j);
+ my_assert(recvbuf[i * COUNT + j] == i + j);
}
}
}
else {
- for (i = 0; i < size*COUNT; ++i) {
+ for (i = 0; i < size * COUNT; ++i) {
my_assert(recvbuf[i] == 0xdeadbeef);
}
}
@@ -201,23 +205,23 @@ int main(int argc, char **argv)
MPI_Datatype type = MPI_DATATYPE_NULL;
MPI_Type_dup(MPI_INT, &type);
- for (i = 0; i < size*COUNT; ++i) {
+ for (i = 0; i < size * COUNT; ++i) {
buf[i] = rank + i;
recvbuf[i] = 0xdeadbeef;
}
MPI_Igather(buf, COUNT, MPI_INT, recvbuf, COUNT, type, 0, MPI_COMM_WORLD, &req);
- MPI_Type_free(&type); /* should cause implementations that don't refcount
- correctly to blow up or hang in the wait */
+ MPI_Type_free(&type); /* should cause implementations that don't refcount
+ * correctly to blow up or hang in the wait */
MPI_Wait(&req, MPI_STATUS_IGNORE);
if (rank == 0) {
for (i = 0; i < size; ++i) {
for (j = 0; j < COUNT; ++j) {
- my_assert(recvbuf[i*COUNT+j] == i + j);
+ my_assert(recvbuf[i * COUNT + j] == i + j);
}
}
}
else {
- for (i = 0; i < size*COUNT; ++i) {
+ for (i = 0; i < size * COUNT; ++i) {
my_assert(recvbuf[i] == 0xdeadbeef);
}
}
@@ -227,10 +231,10 @@ int main(int argc, char **argv)
for (i = 0; i < size; ++i) {
for (j = 0; j < COUNT; ++j) {
if (rank == 0)
- buf[i*COUNT+j] = i + j;
+ buf[i * COUNT + j] = i + j;
else
- buf[i*COUNT+j] = 0xdeadbeef;
- recvbuf[i*COUNT+j] = 0xdeadbeef;
+ buf[i * COUNT + j] = 0xdeadbeef;
+ recvbuf[i * COUNT + j] = 0xdeadbeef;
}
}
MPI_Iscatter(buf, COUNT, MPI_INT, recvbuf, COUNT, MPI_INT, 0, MPI_COMM_WORLD, &req);
@@ -239,7 +243,7 @@ int main(int argc, char **argv)
my_assert(recvbuf[j] == rank + j);
}
if (rank != 0) {
- for (i = 0; i < size*COUNT; ++i) {
+ for (i = 0; i < size * COUNT; ++i) {
/* check we didn't corrupt the sendbuf somehow */
my_assert(buf[i] == 0xdeadbeef);
}
@@ -252,19 +256,20 @@ int main(int argc, char **argv)
sdispls[i] = i * COUNT;
for (j = 0; j < COUNT; ++j) {
if (rank == 0)
- buf[i*COUNT+j] = i + j;
+ buf[i * COUNT + j] = i + j;
else
- buf[i*COUNT+j] = 0xdeadbeef;
- recvbuf[i*COUNT+j] = 0xdeadbeef;
+ buf[i * COUNT + j] = 0xdeadbeef;
+ recvbuf[i * COUNT + j] = 0xdeadbeef;
}
}
- MPI_Iscatterv(buf, sendcounts, sdispls, MPI_INT, recvbuf, COUNT, MPI_INT, 0, MPI_COMM_WORLD, &req);
+ MPI_Iscatterv(buf, sendcounts, sdispls, MPI_INT, recvbuf, COUNT, MPI_INT, 0, MPI_COMM_WORLD,
+ &req);
MPI_Wait(&req, MPI_STATUS_IGNORE);
for (j = 0; j < COUNT; ++j) {
my_assert(recvbuf[j] == rank + j);
}
if (rank != 0) {
- for (i = 0; i < size*COUNT; ++i) {
+ for (i = 0; i < size * COUNT; ++i) {
/* check we didn't corrupt the sendbuf somehow */
my_assert(buf[i] == 0xdeadbeef);
}
@@ -272,7 +277,7 @@ int main(int argc, char **argv)
for (i = 1; i < size; ++i) {
for (j = 0; j < COUNT; ++j) {
/* check we didn't corrupt the rest of the recvbuf */
- my_assert(recvbuf[i*COUNT+j] == 0xdeadbeef);
+ my_assert(recvbuf[i * COUNT + j] == 0xdeadbeef);
}
}
@@ -280,8 +285,8 @@ int main(int argc, char **argv)
for (i = 0; i < size; ++i) {
recvcounts[i] = COUNT;
for (j = 0; j < COUNT; ++j) {
- buf[i*COUNT+j] = rank + i;
- recvbuf[i*COUNT+j] = 0xdeadbeef;
+ buf[i * COUNT + j] = rank + i;
+ recvbuf[i * COUNT + j] = 0xdeadbeef;
}
}
MPI_Ireduce_scatter(buf, recvbuf, recvcounts, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &req);
@@ -292,15 +297,15 @@ int main(int argc, char **argv)
for (i = 1; i < size; ++i) {
for (j = 0; j < COUNT; ++j) {
/* check we didn't corrupt the rest of the recvbuf */
- my_assert(recvbuf[i*COUNT+j] == 0xdeadbeef);
+ my_assert(recvbuf[i * COUNT + j] == 0xdeadbeef);
}
}
/* MPI_Ireduce_scatter_block */
for (i = 0; i < size; ++i) {
for (j = 0; j < COUNT; ++j) {
- buf[i*COUNT+j] = rank + i;
- recvbuf[i*COUNT+j] = 0xdeadbeef;
+ buf[i * COUNT + j] = rank + i;
+ recvbuf[i * COUNT + j] = 0xdeadbeef;
}
}
MPI_Ireduce_scatter_block(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &req);
@@ -311,12 +316,12 @@ int main(int argc, char **argv)
for (i = 1; i < size; ++i) {
for (j = 0; j < COUNT; ++j) {
/* check we didn't corrupt the rest of the recvbuf */
- my_assert(recvbuf[i*COUNT+j] == 0xdeadbeef);
+ my_assert(recvbuf[i * COUNT + j] == 0xdeadbeef);
}
}
/* MPI_Igatherv */
- for (i = 0; i < size*COUNT; ++i) {
+ for (i = 0; i < size * COUNT; ++i) {
buf[i] = 0xdeadbeef;
recvbuf[i] = 0xdeadbeef;
}
@@ -327,17 +332,18 @@ int main(int argc, char **argv)
recvcounts[i] = COUNT;
rdispls[i] = i * COUNT;
}
- MPI_Igatherv(buf, COUNT, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT, 0, MPI_COMM_WORLD, &req);
+ MPI_Igatherv(buf, COUNT, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT, 0, MPI_COMM_WORLD,
+ &req);
MPI_Wait(&req, MPI_STATUS_IGNORE);
if (rank == 0) {
for (i = 0; i < size; ++i) {
for (j = 0; j < COUNT; ++j) {
- my_assert(recvbuf[i*COUNT+j] == i + j);
+ my_assert(recvbuf[i * COUNT + j] == i + j);
}
}
}
else {
- for (i = 0; i < size*COUNT; ++i) {
+ for (i = 0; i < size * COUNT; ++i) {
my_assert(recvbuf[i] == 0xdeadbeef);
}
}
@@ -345,21 +351,21 @@ int main(int argc, char **argv)
/* MPI_Ialltoall */
for (i = 0; i < size; ++i) {
for (j = 0; j < COUNT; ++j) {
- buf[i*COUNT+j] = rank + (i * j);
- recvbuf[i*COUNT+j] = 0xdeadbeef;
+ buf[i * COUNT + j] = rank + (i * j);
+ recvbuf[i * COUNT + j] = 0xdeadbeef;
}
}
MPI_Ialltoall(buf, COUNT, MPI_INT, recvbuf, COUNT, MPI_INT, MPI_COMM_WORLD, &req);
MPI_Wait(&req, MPI_STATUS_IGNORE);
for (i = 0; i < size; ++i) {
for (j = 0; j < COUNT; ++j) {
- /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (i * j)));*/
- my_assert(recvbuf[i*COUNT+j] == (i + (rank * j)));
+ /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (i * j))); */
+ my_assert(recvbuf[i * COUNT + j] == (i + (rank * j)));
}
}
/* MPI_Iallgather */
- for (i = 0; i < size*COUNT; ++i) {
+ for (i = 0; i < size * COUNT; ++i) {
buf[i] = rank + i;
recvbuf[i] = 0xdeadbeef;
}
@@ -367,25 +373,26 @@ int main(int argc, char **argv)
MPI_Wait(&req, MPI_STATUS_IGNORE);
for (i = 0; i < size; ++i) {
for (j = 0; j < COUNT; ++j) {
- my_assert(recvbuf[i*COUNT+j] == i + j);
+ my_assert(recvbuf[i * COUNT + j] == i + j);
}
}
/* MPI_Iallgatherv */
for (i = 0; i < size; ++i) {
for (j = 0; j < COUNT; ++j) {
- recvbuf[i*COUNT+j] = 0xdeadbeef;
+ recvbuf[i * COUNT + j] = 0xdeadbeef;
}
recvcounts[i] = COUNT;
rdispls[i] = i * COUNT;
}
for (i = 0; i < COUNT; ++i)
buf[i] = rank + i;
- MPI_Iallgatherv(buf, COUNT, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT, MPI_COMM_WORLD, &req);
+ MPI_Iallgatherv(buf, COUNT, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT, MPI_COMM_WORLD,
+ &req);
MPI_Wait(&req, MPI_STATUS_IGNORE);
for (i = 0; i < size; ++i) {
for (j = 0; j < COUNT; ++j) {
- my_assert(recvbuf[i*COUNT+j] == i + j);
+ my_assert(recvbuf[i * COUNT + j] == i + j);
}
}
@@ -397,7 +404,7 @@ int main(int argc, char **argv)
MPI_Iscan(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &req);
MPI_Wait(&req, MPI_STATUS_IGNORE);
for (i = 0; i < COUNT; ++i) {
- my_assert(recvbuf[i] == ((rank * (rank+1) / 2) + (i * (rank + 1))));
+ my_assert(recvbuf[i] == ((rank * (rank + 1) / 2) + (i * (rank + 1))));
}
/* MPI_Iexscan */
@@ -411,7 +418,7 @@ int main(int argc, char **argv)
if (rank == 0)
my_assert(recvbuf[i] == 0xdeadbeef);
else
- my_assert(recvbuf[i] == ((rank * (rank+1) / 2) + (i * (rank + 1)) - (rank + i)));
+ my_assert(recvbuf[i] == ((rank * (rank + 1) / 2) + (i * (rank + 1)) - (rank + i)));
}
/* MPI_Ialltoallw (a weak test, neither irregular nor sparse) */
@@ -423,16 +430,17 @@ int main(int argc, char **argv)
sendtypes[i] = MPI_INT;
recvtypes[i] = MPI_INT;
for (j = 0; j < COUNT; ++j) {
- buf[i*COUNT+j] = rank + (i * j);
- recvbuf[i*COUNT+j] = 0xdeadbeef;
+ buf[i * COUNT + j] = rank + (i * j);
+ recvbuf[i * COUNT + j] = 0xdeadbeef;
}
}
- MPI_Ialltoallw(buf, sendcounts, sdispls, sendtypes, recvbuf, recvcounts, rdispls, recvtypes, MPI_COMM_WORLD, &req);
+ MPI_Ialltoallw(buf, sendcounts, sdispls, sendtypes, recvbuf, recvcounts, rdispls, recvtypes,
+ MPI_COMM_WORLD, &req);
MPI_Wait(&req, MPI_STATUS_IGNORE);
for (i = 0; i < size; ++i) {
for (j = 0; j < COUNT; ++j) {
- /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (rank * j)));*/
- my_assert(recvbuf[i*COUNT+j] == (i + (rank * j)));
+ /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (rank * j))); */
+ my_assert(recvbuf[i * COUNT + j] == (i + (rank * j)));
}
}
@@ -451,4 +459,3 @@ int main(int argc, char **argv)
free(sendtypes);
return 0;
}
-
diff --git a/test/mpi/coll/nonblocking3.c b/test/mpi/coll/nonblocking3.c
index 7708456..35cc428 100644
--- a/test/mpi/coll/nonblocking3.c
+++ b/test/mpi/coll/nonblocking3.c
@@ -33,7 +33,7 @@ static int errs = 0;
/* we sleep with probability 1/CHANCE_OF_SLEEP */
#define CHANCE_OF_SLEEP (1000)
/* JITTER_DELAY is denominated in microseconds (us) */
-#define JITTER_DELAY (50000) /* 0.05 seconds */
+#define JITTER_DELAY (50000) /* 0.05 seconds */
/* NUM_COMMS is the number of communicators on which ops will be posted */
#define NUM_COMMS (4)
@@ -65,7 +65,7 @@ static unsigned int gen_prn(unsigned int x)
* a=279470273, good primitive root of m from "TABLES OF LINEAR
* CONGRUENTIAL GENERATORS OF DIFFERENT SIZES AND GOOD
* LATTICE STRUCTURE", by Pierre L’Ecuyer */
- return (279470273UL * (unsigned long)x) % 4294967291UL;
+ return (279470273UL * (unsigned long) x) % 4294967291UL;
}
/* given a random unsigned int value "rndval_" from gen_prn, this evaluates to a
@@ -74,7 +74,7 @@ static unsigned int gen_prn(unsigned int x)
((unsigned int)((min_) + ((rndval_) * (1.0 / (GEN_PRN_MAX+1.0)) * ((max_) - (min_)))))
-static void sum_fn(void *invec, void *inoutvec, int *len, MPI_Datatype *datatype)
+static void sum_fn(void *invec, void *inoutvec, int *len, MPI_Datatype * datatype)
{
int i;
int *in = invec;
@@ -87,7 +87,7 @@ static void sum_fn(void *invec, void *inoutvec, int *len, MPI_Datatype *datatype
/* used to keep track of buffers that should be freed after the corresponding
* operation has completed */
struct laundry {
- int case_num; /* which test case initiated this req/laundry */
+ int case_num; /* which test case initiated this req/laundry */
MPI_Comm comm;
int *buf;
int *recvbuf;
@@ -103,21 +103,30 @@ static void cleanup_laundry(struct laundry *l)
{
l->case_num = -1;
l->comm = MPI_COMM_NULL;
- if (l->buf) free(l->buf);
- if (l->recvbuf) free(l->recvbuf);
- if (l->sendcounts) free(l->sendcounts);
- if (l->recvcounts) free(l->recvcounts);
- if (l->sdispls) free(l->sdispls);
- if (l->rdispls) free(l->rdispls);
- if (l->sendtypes) free(l->sendtypes);
- if (l->recvtypes) free(l->recvtypes);
+ if (l->buf)
+ free(l->buf);
+ if (l->recvbuf)
+ free(l->recvbuf);
+ if (l->sendcounts)
+ free(l->sendcounts);
+ if (l->recvcounts)
+ free(l->recvcounts);
+ if (l->sdispls)
+ free(l->sdispls);
+ if (l->rdispls)
+ free(l->rdispls);
+ if (l->sendtypes)
+ free(l->sendtypes);
+ if (l->recvtypes)
+ free(l->recvtypes);
}
/* Starts a "random" operation on "comm" corresponding to "rndnum" and returns
* in (*req) a request handle corresonding to that operation. This call should
* be considered collective over comm (with a consistent value for "rndnum"),
* even though the operation may only be a point-to-point request. */
-static void start_random_nonblocking(MPI_Comm comm, unsigned int rndnum, MPI_Request *req, struct laundry *l)
+static void start_random_nonblocking(MPI_Comm comm, unsigned int rndnum, MPI_Request * req,
+ struct laundry *l)
{
int i, j;
int rank, size;
@@ -139,261 +148,263 @@ static void start_random_nonblocking(MPI_Comm comm, unsigned int rndnum, MPI_Req
l->case_num = -1;
l->comm = comm;
- l->buf = buf = malloc(COUNT*size*sizeof(int));
- l->recvbuf = recvbuf = malloc(COUNT*size*sizeof(int));
- l->sendcounts = sendcounts = malloc(size*sizeof(int));
- l->recvcounts = recvcounts = malloc(size*sizeof(int));
- l->sdispls = sdispls = malloc(size*sizeof(int));
- l->rdispls = rdispls = malloc(size*sizeof(int));
- l->sendtypes = sendtypes = malloc(size*sizeof(MPI_Datatype));
- l->recvtypes = recvtypes = malloc(size*sizeof(MPI_Datatype));
+ l->buf = buf = malloc(COUNT * size * sizeof(int));
+ l->recvbuf = recvbuf = malloc(COUNT * size * sizeof(int));
+ l->sendcounts = sendcounts = malloc(size * sizeof(int));
+ l->recvcounts = recvcounts = malloc(size * sizeof(int));
+ l->sdispls = sdispls = malloc(size * sizeof(int));
+ l->rdispls = rdispls = malloc(size * sizeof(int));
+ l->sendtypes = sendtypes = malloc(size * sizeof(MPI_Datatype));
+ l->recvtypes = recvtypes = malloc(size * sizeof(MPI_Datatype));
#define NUM_CASES (21)
l->case_num = rand_range(rndnum, 0, NUM_CASES);
switch (l->case_num) {
- case 0: /* MPI_Ibcast */
- for (i = 0; i < COUNT; ++i) {
- if (rank == 0) {
- buf[i] = i;
- }
- else {
- buf[i] = 0xdeadbeef;
- }
- }
- MPI_Ibcast(buf, COUNT, MPI_INT, 0, comm, req);
- break;
-
- case 1: /* MPI_Ibcast (again, but designed to stress scatter/allgather impls) */
- /* FIXME fiddle with PRIME and buffer allocation s.t. PRIME is much larger (1021?) */
- buf_alias = (signed char *)buf;
- my_assert(COUNT*size*sizeof(int) > PRIME); /* sanity */
- for (i = 0; i < PRIME; ++i) {
- if (rank == 0)
- buf_alias[i] = i;
- else
- buf_alias[i] = 0xdb;
+ case 0: /* MPI_Ibcast */
+ for (i = 0; i < COUNT; ++i) {
+ if (rank == 0) {
+ buf[i] = i;
}
- for (i = PRIME; i < COUNT * size * sizeof(int); ++i) {
- buf_alias[i] = 0xbf;
+ else {
+ buf[i] = 0xdeadbeef;
}
- MPI_Ibcast(buf_alias, PRIME, MPI_SIGNED_CHAR, 0, comm, req);
- break;
-
- case 2: /* MPI_Ibarrier */
- MPI_Ibarrier(comm, req);
- break;
+ }
+ MPI_Ibcast(buf, COUNT, MPI_INT, 0, comm, req);
+ break;
+
+ case 1: /* MPI_Ibcast (again, but designed to stress scatter/allgather impls) */
+ /* FIXME fiddle with PRIME and buffer allocation s.t. PRIME is much larger (1021?) */
+ buf_alias = (signed char *) buf;
+ my_assert(COUNT * size * sizeof(int) > PRIME); /* sanity */
+ for (i = 0; i < PRIME; ++i) {
+ if (rank == 0)
+ buf_alias[i] = i;
+ else
+ buf_alias[i] = 0xdb;
+ }
+ for (i = PRIME; i < COUNT * size * sizeof(int); ++i) {
+ buf_alias[i] = 0xbf;
+ }
+ MPI_Ibcast(buf_alias, PRIME, MPI_SIGNED_CHAR, 0, comm, req);
+ break;
- case 3: /* MPI_Ireduce */
- for (i = 0; i < COUNT; ++i) {
- buf[i] = rank + i;
- recvbuf[i] = 0xdeadbeef;
- }
- MPI_Ireduce(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, 0, comm, req);
- break;
+ case 2: /* MPI_Ibarrier */
+ MPI_Ibarrier(comm, req);
+ break;
- case 4: /* same again, use a user op and free it before the wait */
- {
- MPI_Op op = MPI_OP_NULL;
- MPI_Op_create(sum_fn, /*commute=*/1, &op);
- for (i = 0; i < COUNT; ++i) {
- buf[i] = rank + i;
- recvbuf[i] = 0xdeadbeef;
- }
- MPI_Ireduce(buf, recvbuf, COUNT, MPI_INT, op, 0, comm, req);
- MPI_Op_free(&op);
- }
- break;
+ case 3: /* MPI_Ireduce */
+ for (i = 0; i < COUNT; ++i) {
+ buf[i] = rank + i;
+ recvbuf[i] = 0xdeadbeef;
+ }
+ MPI_Ireduce(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, 0, comm, req);
+ break;
- case 5: /* MPI_Iallreduce */
+ case 4: /* same again, use a user op and free it before the wait */
+ {
+ MPI_Op op = MPI_OP_NULL;
+ MPI_Op_create(sum_fn, /*commute= */ 1, &op);
for (i = 0; i < COUNT; ++i) {
buf[i] = rank + i;
recvbuf[i] = 0xdeadbeef;
}
- MPI_Iallreduce(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, comm, req);
- break;
+ MPI_Ireduce(buf, recvbuf, COUNT, MPI_INT, op, 0, comm, req);
+ MPI_Op_free(&op);
+ }
+ break;
- case 6: /* MPI_Ialltoallv (a weak test, neither irregular nor sparse) */
- for (i = 0; i < size; ++i) {
- sendcounts[i] = COUNT;
- recvcounts[i] = COUNT;
- sdispls[i] = COUNT * i;
- rdispls[i] = COUNT * i;
- for (j = 0; j < COUNT; ++j) {
- buf[i*COUNT+j] = rank + (i * j);
- recvbuf[i*COUNT+j] = 0xdeadbeef;
- }
+ case 5: /* MPI_Iallreduce */
+ for (i = 0; i < COUNT; ++i) {
+ buf[i] = rank + i;
+ recvbuf[i] = 0xdeadbeef;
+ }
+ MPI_Iallreduce(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, comm, req);
+ break;
+
+ case 6: /* MPI_Ialltoallv (a weak test, neither irregular nor sparse) */
+ for (i = 0; i < size; ++i) {
+ sendcounts[i] = COUNT;
+ recvcounts[i] = COUNT;
+ sdispls[i] = COUNT * i;
+ rdispls[i] = COUNT * i;
+ for (j = 0; j < COUNT; ++j) {
+ buf[i * COUNT + j] = rank + (i * j);
+ recvbuf[i * COUNT + j] = 0xdeadbeef;
}
- MPI_Ialltoallv(buf, sendcounts, sdispls, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT, comm, req);
- break;
-
- case 7: /* MPI_Igather */
- for (i = 0; i < size*COUNT; ++i) {
+ }
+ MPI_Ialltoallv(buf, sendcounts, sdispls, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT,
+ comm, req);
+ break;
+
+ case 7: /* MPI_Igather */
+ for (i = 0; i < size * COUNT; ++i) {
+ buf[i] = rank + i;
+ recvbuf[i] = 0xdeadbeef;
+ }
+ MPI_Igather(buf, COUNT, MPI_INT, recvbuf, COUNT, MPI_INT, 0, comm, req);
+ break;
+
+ case 8: /* same test again, just use a dup'ed datatype and free it before the wait */
+ {
+ MPI_Datatype type = MPI_DATATYPE_NULL;
+ MPI_Type_dup(MPI_INT, &type);
+ for (i = 0; i < size * COUNT; ++i) {
buf[i] = rank + i;
recvbuf[i] = 0xdeadbeef;
}
- MPI_Igather(buf, COUNT, MPI_INT, recvbuf, COUNT, MPI_INT, 0, comm, req);
- break;
-
- case 8: /* same test again, just use a dup'ed datatype and free it before the wait */
- {
- MPI_Datatype type = MPI_DATATYPE_NULL;
- MPI_Type_dup(MPI_INT, &type);
- for (i = 0; i < size*COUNT; ++i) {
- buf[i] = rank + i;
- recvbuf[i] = 0xdeadbeef;
- }
- MPI_Igather(buf, COUNT, MPI_INT, recvbuf, COUNT, type, 0, comm, req);
- MPI_Type_free(&type); /* should cause implementations that don't refcount
- correctly to blow up or hang in the wait */
- }
- break;
-
- case 9: /* MPI_Iscatter */
- for (i = 0; i < size; ++i) {
- for (j = 0; j < COUNT; ++j) {
- if (rank == 0)
- buf[i*COUNT+j] = i + j;
- else
- buf[i*COUNT+j] = 0xdeadbeef;
- recvbuf[i*COUNT+j] = 0xdeadbeef;
- }
- }
- MPI_Iscatter(buf, COUNT, MPI_INT, recvbuf, COUNT, MPI_INT, 0, comm, req);
- break;
-
- case 10: /* MPI_Iscatterv */
- for (i = 0; i < size; ++i) {
- /* weak test, just test the regular case where all counts are equal */
- sendcounts[i] = COUNT;
- sdispls[i] = i * COUNT;
- for (j = 0; j < COUNT; ++j) {
- if (rank == 0)
- buf[i*COUNT+j] = i + j;
- else
- buf[i*COUNT+j] = 0xdeadbeef;
- recvbuf[i*COUNT+j] = 0xdeadbeef;
- }
- }
- MPI_Iscatterv(buf, sendcounts, sdispls, MPI_INT, recvbuf, COUNT, MPI_INT, 0, comm, req);
- break;
+ MPI_Igather(buf, COUNT, MPI_INT, recvbuf, COUNT, type, 0, comm, req);
+ MPI_Type_free(&type); /* should cause implementations that don't refcount
+ * correctly to blow up or hang in the wait */
+ }
+ break;
- case 11: /* MPI_Ireduce_scatter */
- for (i = 0; i < size; ++i) {
- recvcounts[i] = COUNT;
- for (j = 0; j < COUNT; ++j) {
- buf[i*COUNT+j] = rank + i;
- recvbuf[i*COUNT+j] = 0xdeadbeef;
- }
+ case 9: /* MPI_Iscatter */
+ for (i = 0; i < size; ++i) {
+ for (j = 0; j < COUNT; ++j) {
+ if (rank == 0)
+ buf[i * COUNT + j] = i + j;
+ else
+ buf[i * COUNT + j] = 0xdeadbeef;
+ recvbuf[i * COUNT + j] = 0xdeadbeef;
}
- MPI_Ireduce_scatter(buf, recvbuf, recvcounts, MPI_INT, MPI_SUM, comm, req);
- break;
-
- case 12: /* MPI_Ireduce_scatter_block */
- for (i = 0; i < size; ++i) {
- for (j = 0; j < COUNT; ++j) {
- buf[i*COUNT+j] = rank + i;
- recvbuf[i*COUNT+j] = 0xdeadbeef;
- }
+ }
+ MPI_Iscatter(buf, COUNT, MPI_INT, recvbuf, COUNT, MPI_INT, 0, comm, req);
+ break;
+
+ case 10: /* MPI_Iscatterv */
+ for (i = 0; i < size; ++i) {
+ /* weak test, just test the regular case where all counts are equal */
+ sendcounts[i] = COUNT;
+ sdispls[i] = i * COUNT;
+ for (j = 0; j < COUNT; ++j) {
+ if (rank == 0)
+ buf[i * COUNT + j] = i + j;
+ else
+ buf[i * COUNT + j] = 0xdeadbeef;
+ recvbuf[i * COUNT + j] = 0xdeadbeef;
}
- MPI_Ireduce_scatter_block(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, comm, req);
- break;
+ }
+ MPI_Iscatterv(buf, sendcounts, sdispls, MPI_INT, recvbuf, COUNT, MPI_INT, 0, comm, req);
+ break;
- case 13: /* MPI_Igatherv */
- for (i = 0; i < size*COUNT; ++i) {
- buf[i] = 0xdeadbeef;
- recvbuf[i] = 0xdeadbeef;
- }
- for (i = 0; i < COUNT; ++i) {
- buf[i] = rank + i;
- }
- for (i = 0; i < size; ++i) {
- recvcounts[i] = COUNT;
- rdispls[i] = i * COUNT;
+ case 11: /* MPI_Ireduce_scatter */
+ for (i = 0; i < size; ++i) {
+ recvcounts[i] = COUNT;
+ for (j = 0; j < COUNT; ++j) {
+ buf[i * COUNT + j] = rank + i;
+ recvbuf[i * COUNT + j] = 0xdeadbeef;
}
- MPI_Igatherv(buf, COUNT, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT, 0, comm, req);
- break;
+ }
+ MPI_Ireduce_scatter(buf, recvbuf, recvcounts, MPI_INT, MPI_SUM, comm, req);
+ break;
- case 14: /* MPI_Ialltoall */
- for (i = 0; i < size; ++i) {
- for (j = 0; j < COUNT; ++j) {
- buf[i*COUNT+j] = rank + (i * j);
- recvbuf[i*COUNT+j] = 0xdeadbeef;
- }
+ case 12: /* MPI_Ireduce_scatter_block */
+ for (i = 0; i < size; ++i) {
+ for (j = 0; j < COUNT; ++j) {
+ buf[i * COUNT + j] = rank + i;
+ recvbuf[i * COUNT + j] = 0xdeadbeef;
}
- MPI_Ialltoall(buf, COUNT, MPI_INT, recvbuf, COUNT, MPI_INT, comm, req);
- break;
+ }
+ MPI_Ireduce_scatter_block(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, comm, req);
+ break;
- case 15: /* MPI_Iallgather */
- for (i = 0; i < size*COUNT; ++i) {
- buf[i] = rank + i;
- recvbuf[i] = 0xdeadbeef;
- }
- MPI_Iallgather(buf, COUNT, MPI_INT, recvbuf, COUNT, MPI_INT, comm, req);
- break;
+ case 13: /* MPI_Igatherv */
+ for (i = 0; i < size * COUNT; ++i) {
+ buf[i] = 0xdeadbeef;
+ recvbuf[i] = 0xdeadbeef;
+ }
+ for (i = 0; i < COUNT; ++i) {
+ buf[i] = rank + i;
+ }
+ for (i = 0; i < size; ++i) {
+ recvcounts[i] = COUNT;
+ rdispls[i] = i * COUNT;
+ }
+ MPI_Igatherv(buf, COUNT, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT, 0, comm, req);
+ break;
- case 16: /* MPI_Iallgatherv */
- for (i = 0; i < size; ++i) {
- for (j = 0; j < COUNT; ++j) {
- recvbuf[i*COUNT+j] = 0xdeadbeef;
- }
- recvcounts[i] = COUNT;
- rdispls[i] = i * COUNT;
+ case 14: /* MPI_Ialltoall */
+ for (i = 0; i < size; ++i) {
+ for (j = 0; j < COUNT; ++j) {
+ buf[i * COUNT + j] = rank + (i * j);
+ recvbuf[i * COUNT + j] = 0xdeadbeef;
}
- for (i = 0; i < COUNT; ++i)
- buf[i] = rank + i;
- MPI_Iallgatherv(buf, COUNT, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT, comm, req);
- break;
+ }
+ MPI_Ialltoall(buf, COUNT, MPI_INT, recvbuf, COUNT, MPI_INT, comm, req);
+ break;
- case 17: /* MPI_Iscan */
- for (i = 0; i < COUNT; ++i) {
- buf[i] = rank + i;
- recvbuf[i] = 0xdeadbeef;
- }
- MPI_Iscan(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, comm, req);
- break;
+ case 15: /* MPI_Iallgather */
+ for (i = 0; i < size * COUNT; ++i) {
+ buf[i] = rank + i;
+ recvbuf[i] = 0xdeadbeef;
+ }
+ MPI_Iallgather(buf, COUNT, MPI_INT, recvbuf, COUNT, MPI_INT, comm, req);
+ break;
- case 18: /* MPI_Iexscan */
- for (i = 0; i < COUNT; ++i) {
- buf[i] = rank + i;
- recvbuf[i] = 0xdeadbeef;
+ case 16: /* MPI_Iallgatherv */
+ for (i = 0; i < size; ++i) {
+ for (j = 0; j < COUNT; ++j) {
+ recvbuf[i * COUNT + j] = 0xdeadbeef;
}
- MPI_Iexscan(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, comm, req);
- break;
+ recvcounts[i] = COUNT;
+ rdispls[i] = i * COUNT;
+ }
+ for (i = 0; i < COUNT; ++i)
+ buf[i] = rank + i;
+ MPI_Iallgatherv(buf, COUNT, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT, comm, req);
+ break;
+
+ case 17: /* MPI_Iscan */
+ for (i = 0; i < COUNT; ++i) {
+ buf[i] = rank + i;
+ recvbuf[i] = 0xdeadbeef;
+ }
+ MPI_Iscan(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, comm, req);
+ break;
- case 19: /* MPI_Ialltoallw (a weak test, neither irregular nor sparse) */
- for (i = 0; i < size; ++i) {
- sendcounts[i] = COUNT;
- recvcounts[i] = COUNT;
- sdispls[i] = COUNT * i * sizeof(int);
- rdispls[i] = COUNT * i * sizeof(int);
- sendtypes[i] = MPI_INT;
- recvtypes[i] = MPI_INT;
- for (j = 0; j < COUNT; ++j) {
- buf[i*COUNT+j] = rank + (i * j);
- recvbuf[i*COUNT+j] = 0xdeadbeef;
- }
+ case 18: /* MPI_Iexscan */
+ for (i = 0; i < COUNT; ++i) {
+ buf[i] = rank + i;
+ recvbuf[i] = 0xdeadbeef;
+ }
+ MPI_Iexscan(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, comm, req);
+ break;
+
+ case 19: /* MPI_Ialltoallw (a weak test, neither irregular nor sparse) */
+ for (i = 0; i < size; ++i) {
+ sendcounts[i] = COUNT;
+ recvcounts[i] = COUNT;
+ sdispls[i] = COUNT * i * sizeof(int);
+ rdispls[i] = COUNT * i * sizeof(int);
+ sendtypes[i] = MPI_INT;
+ recvtypes[i] = MPI_INT;
+ for (j = 0; j < COUNT; ++j) {
+ buf[i * COUNT + j] = rank + (i * j);
+ recvbuf[i * COUNT + j] = 0xdeadbeef;
}
- MPI_Ialltoallw(buf, sendcounts, sdispls, sendtypes, recvbuf, recvcounts, rdispls, recvtypes, comm, req);
- break;
+ }
+ MPI_Ialltoallw(buf, sendcounts, sdispls, sendtypes, recvbuf, recvcounts, rdispls, recvtypes,
+ comm, req);
+ break;
- case 20: /* basic pt2pt MPI_Isend/MPI_Irecv pairing */
- /* even ranks send to odd ranks, but only if we have a full pair */
- if ((rank % 2 != 0) || (rank != size-1)) {
- for (j = 0; j < COUNT; ++j) {
- buf[j] = j;
- recvbuf[j] = 0xdeadbeef;
- }
- if (rank % 2 == 0)
- MPI_Isend(buf, COUNT, MPI_INT, rank+1, 5, comm, req);
- else
- MPI_Irecv(recvbuf, COUNT, MPI_INT, rank-1, 5, comm, req);
+ case 20: /* basic pt2pt MPI_Isend/MPI_Irecv pairing */
+ /* even ranks send to odd ranks, but only if we have a full pair */
+ if ((rank % 2 != 0) || (rank != size - 1)) {
+ for (j = 0; j < COUNT; ++j) {
+ buf[j] = j;
+ recvbuf[j] = 0xdeadbeef;
}
- break;
+ if (rank % 2 == 0)
+ MPI_Isend(buf, COUNT, MPI_INT, rank + 1, 5, comm, req);
+ else
+ MPI_Irecv(recvbuf, COUNT, MPI_INT, rank - 1, 5, comm, req);
+ }
+ break;
- default:
- fprintf(stderr, "unexpected value for l->case_num=%d)\n", (l->case_num));
- MPI_Abort(comm, 1);
- break;
+ default:
+ fprintf(stderr, "unexpected value for l->case_num=%d)\n", (l->case_num));
+ MPI_Abort(comm, 1);
+ break;
}
}
@@ -401,335 +412,341 @@ static void check_after_completion(struct laundry *l)
{
int i, j;
int rank, size;
- MPI_Comm comm = l->comm;
- int *buf = l->buf;
- int *recvbuf = l->recvbuf;
+ MPI_Comm comm = l->comm;
+ int *buf = l->buf;
+ int *recvbuf = l->recvbuf;
int *sendcounts = l->sendcounts;
int *recvcounts = l->recvcounts;
- int *sdispls = l->sdispls;
- int *rdispls = l->rdispls;
- int *sendtypes = l->sendtypes;
- int *recvtypes = l->recvtypes;
- char *buf_alias = (char *)buf;
+ int *sdispls = l->sdispls;
+ int *rdispls = l->rdispls;
+ int *sendtypes = l->sendtypes;
+ int *recvtypes = l->recvtypes;
+ char *buf_alias = (char *) buf;
MPI_Comm_rank(comm, &rank);
MPI_Comm_size(comm, &size);
/* these cases all correspond to cases in start_random_nonblocking */
switch (l->case_num) {
- case 0: /* MPI_Ibcast */
- for (i = 0; i < COUNT; ++i) {
- if (buf[i] != i)
- printf("buf[%d]=%d i=%d\n", i, buf[i], i);
- my_assert(buf[i] == i);
- }
- break;
+ case 0: /* MPI_Ibcast */
+ for (i = 0; i < COUNT; ++i) {
+ if (buf[i] != i)
+ printf("buf[%d]=%d i=%d\n", i, buf[i], i);
+ my_assert(buf[i] == i);
+ }
+ break;
- case 1: /* MPI_Ibcast (again, but designed to stress scatter/allgather impls) */
- for (i = 0; i < PRIME; ++i) {
- if (buf_alias[i] != i)
- printf("buf_alias[%d]=%d i=%d\n", i, buf_alias[i], i);
- my_assert(buf_alias[i] == i);
- }
- break;
+ case 1: /* MPI_Ibcast (again, but designed to stress scatter/allgather impls) */
+ for (i = 0; i < PRIME; ++i) {
+ if (buf_alias[i] != i)
+ printf("buf_alias[%d]=%d i=%d\n", i, buf_alias[i], i);
+ my_assert(buf_alias[i] == i);
+ }
+ break;
- case 2: /* MPI_Ibarrier */
- /* nothing to check */
- break;
+ case 2: /* MPI_Ibarrier */
+ /* nothing to check */
+ break;
- case 3: /* MPI_Ireduce */
- if (rank == 0) {
- for (i = 0; i < COUNT; ++i) {
- if (recvbuf[i] != ((size * (size-1) / 2) + (i * size)))
- printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i], ((size * (size-1) / 2) + (i * size)));
- my_assert(recvbuf[i] == ((size * (size-1) / 2) + (i * size)));
- }
+ case 3: /* MPI_Ireduce */
+ if (rank == 0) {
+ for (i = 0; i < COUNT; ++i) {
+ if (recvbuf[i] != ((size * (size - 1) / 2) + (i * size)))
+ printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i],
+ ((size * (size - 1) / 2) + (i * size)));
+ my_assert(recvbuf[i] == ((size * (size - 1) / 2) + (i * size)));
}
- break;
+ }
+ break;
- case 4: /* same again, use a user op and free it before the wait */
- if (rank == 0) {
- for (i = 0; i < COUNT; ++i) {
- if (recvbuf[i] != ((size * (size-1) / 2) + (i * size)))
- printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i], ((size * (size-1) / 2) + (i * size)));
- my_assert(recvbuf[i] == ((size * (size-1) / 2) + (i * size)));
- }
+ case 4: /* same again, use a user op and free it before the wait */
+ if (rank == 0) {
+ for (i = 0; i < COUNT; ++i) {
+ if (recvbuf[i] != ((size * (size - 1) / 2) + (i * size)))
+ printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i],
+ ((size * (size - 1) / 2) + (i * size)));
+ my_assert(recvbuf[i] == ((size * (size - 1) / 2) + (i * size)));
}
- break;
+ }
+ break;
+
+ case 5: /* MPI_Iallreduce */
+ for (i = 0; i < COUNT; ++i) {
+ if (recvbuf[i] != ((size * (size - 1) / 2) + (i * size)))
+ printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i],
+ ((size * (size - 1) / 2) + (i * size)));
+ my_assert(recvbuf[i] == ((size * (size - 1) / 2) + (i * size)));
+ }
+ break;
- case 5: /* MPI_Iallreduce */
- for (i = 0; i < COUNT; ++i) {
- if (recvbuf[i] != ((size * (size-1) / 2) + (i * size)))
- printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i], ((size * (size-1) / 2) + (i * size)));
- my_assert(recvbuf[i] == ((size * (size-1) / 2) + (i * size)));
+ case 6: /* MPI_Ialltoallv (a weak test, neither irregular nor sparse) */
+ for (i = 0; i < size; ++i) {
+ for (j = 0; j < COUNT; ++j) {
+ /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (rank * j))); */
+ my_assert(recvbuf[i * COUNT + j] == (i + (rank * j)));
}
- break;
+ }
+ break;
- case 6: /* MPI_Ialltoallv (a weak test, neither irregular nor sparse) */
+ case 7: /* MPI_Igather */
+ if (rank == 0) {
for (i = 0; i < size; ++i) {
for (j = 0; j < COUNT; ++j) {
- /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (rank * j)));*/
- my_assert(recvbuf[i*COUNT+j] == (i + (rank * j)));
+ my_assert(recvbuf[i * COUNT + j] == i + j);
}
}
- break;
-
- case 7: /* MPI_Igather */
- if (rank == 0) {
- for (i = 0; i < size; ++i) {
- for (j = 0; j < COUNT; ++j) {
- my_assert(recvbuf[i*COUNT+j] == i + j);
- }
- }
- }
- else {
- for (i = 0; i < size*COUNT; ++i) {
- my_assert(recvbuf[i] == 0xdeadbeef);
- }
+ }
+ else {
+ for (i = 0; i < size * COUNT; ++i) {
+ my_assert(recvbuf[i] == 0xdeadbeef);
}
- break;
+ }
+ break;
- case 8: /* same test again, just use a dup'ed datatype and free it before the wait */
- if (rank == 0) {
- for (i = 0; i < size; ++i) {
- for (j = 0; j < COUNT; ++j) {
- my_assert(recvbuf[i*COUNT+j] == i + j);
- }
+ case 8: /* same test again, just use a dup'ed datatype and free it before the wait */
+ if (rank == 0) {
+ for (i = 0; i < size; ++i) {
+ for (j = 0; j < COUNT; ++j) {
+ my_assert(recvbuf[i * COUNT + j] == i + j);
}
}
- else {
- for (i = 0; i < size*COUNT; ++i) {
- my_assert(recvbuf[i] == 0xdeadbeef);
- }
+ }
+ else {
+ for (i = 0; i < size * COUNT; ++i) {
+ my_assert(recvbuf[i] == 0xdeadbeef);
}
- break;
+ }
+ break;
- case 9: /* MPI_Iscatter */
- for (j = 0; j < COUNT; ++j) {
- my_assert(recvbuf[j] == rank + j);
- }
- if (rank != 0) {
- for (i = 0; i < size*COUNT; ++i) {
- /* check we didn't corrupt the sendbuf somehow */
- my_assert(buf[i] == 0xdeadbeef);
- }
+ case 9: /* MPI_Iscatter */
+ for (j = 0; j < COUNT; ++j) {
+ my_assert(recvbuf[j] == rank + j);
+ }
+ if (rank != 0) {
+ for (i = 0; i < size * COUNT; ++i) {
+ /* check we didn't corrupt the sendbuf somehow */
+ my_assert(buf[i] == 0xdeadbeef);
}
- break;
+ }
+ break;
- case 10: /* MPI_Iscatterv */
- for (j = 0; j < COUNT; ++j) {
- my_assert(recvbuf[j] == rank + j);
- }
- if (rank != 0) {
- for (i = 0; i < size*COUNT; ++i) {
- /* check we didn't corrupt the sendbuf somehow */
- my_assert(buf[i] == 0xdeadbeef);
- }
- }
- for (i = 1; i < size; ++i) {
- for (j = 0; j < COUNT; ++j) {
- /* check we didn't corrupt the rest of the recvbuf */
- my_assert(recvbuf[i*COUNT+j] == 0xdeadbeef);
- }
+ case 10: /* MPI_Iscatterv */
+ for (j = 0; j < COUNT; ++j) {
+ my_assert(recvbuf[j] == rank + j);
+ }
+ if (rank != 0) {
+ for (i = 0; i < size * COUNT; ++i) {
+ /* check we didn't corrupt the sendbuf somehow */
+ my_assert(buf[i] == 0xdeadbeef);
}
- break;
-
- case 11: /* MPI_Ireduce_scatter */
+ }
+ for (i = 1; i < size; ++i) {
for (j = 0; j < COUNT; ++j) {
- my_assert(recvbuf[j] == (size * rank + ((size - 1) * size) / 2));
+ /* check we didn't corrupt the rest of the recvbuf */
+ my_assert(recvbuf[i * COUNT + j] == 0xdeadbeef);
}
- for (i = 1; i < size; ++i) {
- for (j = 0; j < COUNT; ++j) {
- /* check we didn't corrupt the rest of the recvbuf */
- my_assert(recvbuf[i*COUNT+j] == 0xdeadbeef);
- }
- }
- break;
+ }
+ break;
- case 12: /* MPI_Ireduce_scatter_block */
+ case 11: /* MPI_Ireduce_scatter */
+ for (j = 0; j < COUNT; ++j) {
+ my_assert(recvbuf[j] == (size * rank + ((size - 1) * size) / 2));
+ }
+ for (i = 1; i < size; ++i) {
for (j = 0; j < COUNT; ++j) {
- my_assert(recvbuf[j] == (size * rank + ((size - 1) * size) / 2));
- }
- for (i = 1; i < size; ++i) {
- for (j = 0; j < COUNT; ++j) {
- /* check we didn't corrupt the rest of the recvbuf */
- my_assert(recvbuf[i*COUNT+j] == 0xdeadbeef);
- }
+ /* check we didn't corrupt the rest of the recvbuf */
+ my_assert(recvbuf[i * COUNT + j] == 0xdeadbeef);
}
- break;
+ }
+ break;
- case 13: /* MPI_Igatherv */
- if (rank == 0) {
- for (i = 0; i < size; ++i) {
- for (j = 0; j < COUNT; ++j) {
- my_assert(recvbuf[i*COUNT+j] == i + j);
- }
- }
- }
- else {
- for (i = 0; i < size*COUNT; ++i) {
- my_assert(recvbuf[i] == 0xdeadbeef);
- }
+ case 12: /* MPI_Ireduce_scatter_block */
+ for (j = 0; j < COUNT; ++j) {
+ my_assert(recvbuf[j] == (size * rank + ((size - 1) * size) / 2));
+ }
+ for (i = 1; i < size; ++i) {
+ for (j = 0; j < COUNT; ++j) {
+ /* check we didn't corrupt the rest of the recvbuf */
+ my_assert(recvbuf[i * COUNT + j] == 0xdeadbeef);
}
- break;
+ }
+ break;
- case 14: /* MPI_Ialltoall */
+ case 13: /* MPI_Igatherv */
+ if (rank == 0) {
for (i = 0; i < size; ++i) {
for (j = 0; j < COUNT; ++j) {
- /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (i * j)));*/
- my_assert(recvbuf[i*COUNT+j] == (i + (rank * j)));
+ my_assert(recvbuf[i * COUNT + j] == i + j);
}
}
- break;
-
- case 15: /* MPI_Iallgather */
- for (i = 0; i < size; ++i) {
- for (j = 0; j < COUNT; ++j) {
- my_assert(recvbuf[i*COUNT+j] == i + j);
- }
+ }
+ else {
+ for (i = 0; i < size * COUNT; ++i) {
+ my_assert(recvbuf[i] == 0xdeadbeef);
}
- break;
+ }
+ break;
- case 16: /* MPI_Iallgatherv */
- for (i = 0; i < size; ++i) {
- for (j = 0; j < COUNT; ++j) {
- my_assert(recvbuf[i*COUNT+j] == i + j);
- }
+ case 14: /* MPI_Ialltoall */
+ for (i = 0; i < size; ++i) {
+ for (j = 0; j < COUNT; ++j) {
+ /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (i * j))); */
+ my_assert(recvbuf[i * COUNT + j] == (i + (rank * j)));
}
- break;
+ }
+ break;
- case 17: /* MPI_Iscan */
- for (i = 0; i < COUNT; ++i) {
- my_assert(recvbuf[i] == ((rank * (rank+1) / 2) + (i * (rank + 1))));
+ case 15: /* MPI_Iallgather */
+ for (i = 0; i < size; ++i) {
+ for (j = 0; j < COUNT; ++j) {
+ my_assert(recvbuf[i * COUNT + j] == i + j);
}
- break;
+ }
+ break;
- case 18: /* MPI_Iexscan */
- for (i = 0; i < COUNT; ++i) {
- if (rank == 0)
- my_assert(recvbuf[i] == 0xdeadbeef);
- else
- my_assert(recvbuf[i] == ((rank * (rank+1) / 2) + (i * (rank + 1)) - (rank + i)));
+ case 16: /* MPI_Iallgatherv */
+ for (i = 0; i < size; ++i) {
+ for (j = 0; j < COUNT; ++j) {
+ my_assert(recvbuf[i * COUNT + j] == i + j);
}
- break;
+ }
+ break;
- case 19: /* MPI_Ialltoallw (a weak test, neither irregular nor sparse) */
- for (i = 0; i < size; ++i) {
- for (j = 0; j < COUNT; ++j) {
- /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (rank * j)));*/
- my_assert(recvbuf[i*COUNT+j] == (i + (rank * j)));
- }
+ case 17: /* MPI_Iscan */
+ for (i = 0; i < COUNT; ++i) {
+ my_assert(recvbuf[i] == ((rank * (rank + 1) / 2) + (i * (rank + 1))));
+ }
+ break;
+
+ case 18: /* MPI_Iexscan */
+ for (i = 0; i < COUNT; ++i) {
+ if (rank == 0)
+ my_assert(recvbuf[i] == 0xdeadbeef);
+ else
+ my_assert(recvbuf[i] == ((rank * (rank + 1) / 2) + (i * (rank + 1)) - (rank + i)));
+ }
+ break;
+
+ case 19: /* MPI_Ialltoallw (a weak test, neither irregular nor sparse) */
+ for (i = 0; i < size; ++i) {
+ for (j = 0; j < COUNT; ++j) {
+ /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (rank * j))); */
+ my_assert(recvbuf[i * COUNT + j] == (i + (rank * j)));
}
- break;
+ }
+ break;
- case 20: /* basic pt2pt MPI_Isend/MPI_Irecv pairing */
- /* even ranks send to odd ranks, but only if we have a full pair */
- if ((rank % 2 != 0) || (rank != size-1)) {
- for (j = 0; j < COUNT; ++j) {
- /* only odd procs did a recv */
- if (rank % 2 == 0) {
- my_assert(recvbuf[j] == 0xdeadbeef);
- }
- else {
- if (recvbuf[j] != j) printf("recvbuf[%d]=%d j=%d\n", j, recvbuf[j], j);
- my_assert(recvbuf[j] == j);
- }
+ case 20: /* basic pt2pt MPI_Isend/MPI_Irecv pairing */
+ /* even ranks send to odd ranks, but only if we have a full pair */
+ if ((rank % 2 != 0) || (rank != size - 1)) {
+ for (j = 0; j < COUNT; ++j) {
+ /* only odd procs did a recv */
+ if (rank % 2 == 0) {
+ my_assert(recvbuf[j] == 0xdeadbeef);
+ }
+ else {
+ if (recvbuf[j] != j)
+ printf("recvbuf[%d]=%d j=%d\n", j, recvbuf[j], j);
+ my_assert(recvbuf[j] == j);
}
}
- break;
+ }
+ break;
- default:
- printf("invalid case_num (%d) detected\n", l->case_num);
- assert(0);
- break;
+ default:
+ printf("invalid case_num (%d) detected\n", l->case_num);
+ assert(0);
+ break;
}
}
+
#undef NUM_CASES
-static void complete_something_somehow(unsigned int rndnum, int numreqs, MPI_Request reqs[], int *outcount, int indices[])
+static void complete_something_somehow(unsigned int rndnum, int numreqs, MPI_Request reqs[],
+ int *outcount, int indices[])
{
int i, idx, flag;
#define COMPLETION_CASES (8)
switch (rand_range(rndnum, 0, COMPLETION_CASES)) {
- case 0:
- MPI_Waitall(numreqs, reqs, MPI_STATUSES_IGNORE);
- *outcount = numreqs;
- for (i = 0; i < numreqs; ++i) {
- indices[i] = i;
- }
- break;
-
- case 1:
- MPI_Testsome(numreqs, reqs, outcount, indices, MPI_STATUS_IGNORE);
- if (*outcount == MPI_UNDEFINED) {
- *outcount = 0;
- }
- break;
-
- case 2:
- MPI_Waitsome(numreqs, reqs, outcount, indices, MPI_STATUS_IGNORE);
- if (*outcount == MPI_UNDEFINED) {
- *outcount = 0;
- }
- break;
-
- case 3:
- MPI_Waitany(numreqs, reqs, &idx, MPI_STATUS_IGNORE);
- if (idx == MPI_UNDEFINED) {
- *outcount = 0;
- }
- else {
- *outcount = 1;
- indices[0] = idx;
- }
- break;
+ case 0:
+ MPI_Waitall(numreqs, reqs, MPI_STATUSES_IGNORE);
+ *outcount = numreqs;
+ for (i = 0; i < numreqs; ++i) {
+ indices[i] = i;
+ }
+ break;
- case 4:
- MPI_Testany(numreqs, reqs, &idx, &flag, MPI_STATUS_IGNORE);
- if (idx == MPI_UNDEFINED) {
- *outcount = 0;
- }
- else {
- *outcount = 1;
- indices[0] = idx;
- }
- break;
+ case 1:
+ MPI_Testsome(numreqs, reqs, outcount, indices, MPI_STATUS_IGNORE);
+ if (*outcount == MPI_UNDEFINED) {
+ *outcount = 0;
+ }
+ break;
- case 5:
- MPI_Testall(numreqs, reqs, &flag, MPI_STATUSES_IGNORE);
- if (flag) {
- *outcount = numreqs;
- for (i = 0; i < numreqs; ++i) {
- indices[i] = i;
- }
- }
- else {
- *outcount = 0;
- }
- break;
+ case 2:
+ MPI_Waitsome(numreqs, reqs, outcount, indices, MPI_STATUS_IGNORE);
+ if (*outcount == MPI_UNDEFINED) {
+ *outcount = 0;
+ }
+ break;
- case 6:
- /* select a new random index and wait on it */
- rndnum = gen_prn(rndnum);
- idx = rand_range(rndnum, 0, numreqs);
- MPI_Wait(&reqs[idx], MPI_STATUS_IGNORE);
+ case 3:
+ MPI_Waitany(numreqs, reqs, &idx, MPI_STATUS_IGNORE);
+ if (idx == MPI_UNDEFINED) {
+ *outcount = 0;
+ }
+ else {
*outcount = 1;
indices[0] = idx;
- break;
-
- case 7:
- /* select a new random index and wait on it */
- rndnum = gen_prn(rndnum);
- idx = rand_range(rndnum, 0, numreqs);
- MPI_Test(&reqs[idx], &flag, MPI_STATUS_IGNORE);
- *outcount = (flag ? 1 : 0);
+ }
+ break;
+
+ case 4:
+ MPI_Testany(numreqs, reqs, &idx, &flag, MPI_STATUS_IGNORE);
+ if (idx == MPI_UNDEFINED) {
+ *outcount = 0;
+ }
+ else {
+ *outcount = 1;
indices[0] = idx;
- break;
+ }
+ break;
- default:
- assert(0);
- break;
+ case 5:
+ MPI_Testall(numreqs, reqs, &flag, MPI_STATUSES_IGNORE);
+ if (flag) {
+ *outcount = numreqs;
+ for (i = 0; i < numreqs; ++i) {
+ indices[i] = i;
+ }
+ }
+ else {
+ *outcount = 0;
+ }
+ break;
+
+ case 6:
+ /* select a new random index and wait on it */
+ rndnum = gen_prn(rndnum);
+ idx = rand_range(rndnum, 0, numreqs);
+ MPI_Wait(&reqs[idx], MPI_STATUS_IGNORE);
+ *outcount = 1;
+ indices[0] = idx;
+ break;
+
+ case 7:
+ /* select a new random index and wait on it */
+ rndnum = gen_prn(rndnum);
+ idx = rand_range(rndnum, 0, numreqs);
+ MPI_Test(&reqs[idx], &flag, MPI_STATUS_IGNORE);
+ *outcount = (flag ? 1 : 0);
+ indices[0] = idx;
+ break;
+
+ default:
+ assert(0);
+ break;
}
#undef COMPLETION_CASES
}
@@ -801,7 +818,7 @@ int main(int argc, char **argv)
/* "randomly" and infrequently introduce some jitter into the system */
if (0 == rand_range(gen_prn(complete_seq + wrank), 0, CHANCE_OF_SLEEP)) {
- usleep(JITTER_DELAY); /* take a short nap */
+ usleep(JITTER_DELAY); /* take a short nap */
}
}
@@ -820,4 +837,3 @@ int main(int argc, char **argv)
return 0;
}
-
diff --git a/test/mpi/coll/op_commutative.c b/test/mpi/coll/op_commutative.c
index cc2b80a..5b004fa 100644
--- a/test/mpi/coll/op_commutative.c
+++ b/test/mpi/coll/op_commutative.c
@@ -29,11 +29,11 @@ static void noncomm_user_op(void *invec, void *inoutvec, int *len, MPI_Datatype
}
*/
-static void user_op(void *invec, void *inoutvec, int *len, MPI_Datatype *datatype)
+static void user_op(void *invec, void *inoutvec, int *len, MPI_Datatype * datatype)
{
int i;
- int *invec_int = (int *)invec;
- int *inoutvec_int = (int *)inoutvec;
+ int *invec_int = (int *) invec;
+ int *inoutvec_int = (int *) inoutvec;
if (*datatype != MPI_INT) {
++errs;
@@ -47,7 +47,7 @@ static void user_op(void *invec, void *inoutvec, int *len, MPI_Datatype *datatyp
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Op c_uop = MPI_OP_NULL;
MPI_Op nc_uop = MPI_OP_NULL;
@@ -56,8 +56,8 @@ int main( int argc, char *argv[] )
MTest_Init(&argc, &argv);
/* make sure that user-define ops work too */
- MPI_Op_create(&user_op, 1/*commute*/, &c_uop);
- MPI_Op_create(&user_op, 0/*!commute*/, &nc_uop);
+ MPI_Op_create(&user_op, 1 /*commute */ , &c_uop);
+ MPI_Op_create(&user_op, 0 /*!commute */ , &nc_uop);
#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
/* this function was added in MPI-2.2 */
@@ -104,4 +104,3 @@ int main( int argc, char *argv[] )
MPI_Finalize();
return 0;
}
-
diff --git a/test/mpi/coll/opband.c b/test/mpi/coll/opband.c
index b8ac9d0..19a3704 100644
--- a/test/mpi/coll/opband.c
+++ b/test/mpi/coll/opband.c
@@ -14,16 +14,16 @@ static char MTEST_Descrip[] = "Test MPI_BAND operations on optional datatypes du
*/
/*
- * This test looks at the handling of logical and for types that are not
+ * This test looks at the handling of logical and for types that are not
* integers or are not required integers (e.g., long long). MPICH allows
* these as well. A strict MPI test should not include this test.
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rc;
int rank, size;
- MPI_Comm comm;
+ MPI_Comm comm;
char cinbuf[3], coutbuf[3];
signed char scinbuf[3], scoutbuf[3];
unsigned char ucinbuf[3], ucoutbuf[3];
@@ -32,21 +32,21 @@ int main( int argc, char *argv[] )
long linbuf[3], loutbuf[3];
unsigned long ulinbuf[3], uloutbuf[3];
unsigned uinbuf[3], uoutbuf[3];
-
- MTest_Init( &argc, &argv );
+
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- /* Set errors return so that we can provide better information
- should a routine reject one of the operand/datatype pairs */
- MPI_Errhandler_set( comm, MPI_ERRORS_RETURN );
+ /* Set errors return so that we can provide better information
+ * should a routine reject one of the operand/datatype pairs */
+ MPI_Errhandler_set(comm, MPI_ERRORS_RETURN);
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
#ifndef USE_STRICT_MPI
/* char */
- MTestPrintfMsg( 10, "Reduce of MPI_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_CHAR\n");
cinbuf[0] = 0xff;
cinbuf[1] = 0;
cinbuf[2] = (rank > 0) ? 0xff : 0xf0;
@@ -54,31 +54,31 @@ int main( int argc, char *argv[] )
coutbuf[0] = 0;
coutbuf[1] = 1;
coutbuf[2] = 1;
- rc = MPI_Reduce( cinbuf, coutbuf, 3, MPI_CHAR, MPI_BAND, 0, comm );
+ rc = MPI_Reduce(cinbuf, coutbuf, 3, MPI_CHAR, MPI_BAND, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BAND and MPI_CHAR", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BAND and MPI_CHAR", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (coutbuf[0] != (char)0xff) {
- errs++;
- fprintf( stderr, "char BAND(1) test failed\n" );
- }
- if (coutbuf[1]) {
- errs++;
- fprintf( stderr, "char BAND(0) test failed\n" );
- }
- if (coutbuf[2] != (char)0xf0 && size > 1) {
- errs++;
- fprintf( stderr, "char BAND(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (coutbuf[0] != (char) 0xff) {
+ errs++;
+ fprintf(stderr, "char BAND(1) test failed\n");
+ }
+ if (coutbuf[1]) {
+ errs++;
+ fprintf(stderr, "char BAND(0) test failed\n");
+ }
+ if (coutbuf[2] != (char) 0xf0 && size > 1) {
+ errs++;
+ fprintf(stderr, "char BAND(>) test failed\n");
+ }
+ }
}
#endif /* USE_STRICT_MPI */
/* signed char */
- MTestPrintfMsg( 10, "Reduce of MPI_SIGNED_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_SIGNED_CHAR\n");
scinbuf[0] = 0xff;
scinbuf[1] = 0;
scinbuf[2] = (rank > 0) ? 0xff : 0xf0;
@@ -86,30 +86,30 @@ int main( int argc, char *argv[] )
scoutbuf[0] = 0;
scoutbuf[1] = 1;
scoutbuf[2] = 1;
- rc = MPI_Reduce( scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_BAND, 0, comm );
+ rc = MPI_Reduce(scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_BAND, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BAND and MPI_SIGNED_CHAR", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BAND and MPI_SIGNED_CHAR", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (scoutbuf[0] != (signed char)0xff) {
- errs++;
- fprintf( stderr, "signed char BAND(1) test failed\n" );
- }
- if (scoutbuf[1]) {
- errs++;
- fprintf( stderr, "signed char BAND(0) test failed\n" );
- }
- if (scoutbuf[2] != (signed char)0xf0 && size > 1) {
- errs++;
- fprintf( stderr, "signed char BAND(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (scoutbuf[0] != (signed char) 0xff) {
+ errs++;
+ fprintf(stderr, "signed char BAND(1) test failed\n");
+ }
+ if (scoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "signed char BAND(0) test failed\n");
+ }
+ if (scoutbuf[2] != (signed char) 0xf0 && size > 1) {
+ errs++;
+ fprintf(stderr, "signed char BAND(>) test failed\n");
+ }
+ }
}
/* unsigned char */
- MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_CHAR\n");
ucinbuf[0] = 0xff;
ucinbuf[1] = 0;
ucinbuf[2] = (rank > 0) ? 0xff : 0xf0;
@@ -117,30 +117,30 @@ int main( int argc, char *argv[] )
ucoutbuf[0] = 0;
ucoutbuf[1] = 1;
ucoutbuf[2] = 1;
- rc = MPI_Reduce( ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_BAND, 0, comm );
+ rc = MPI_Reduce(ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_BAND, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BAND and MPI_UNSIGNED_CHAR", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BAND and MPI_UNSIGNED_CHAR", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (ucoutbuf[0] != 0xff) {
- errs++;
- fprintf( stderr, "unsigned char BAND(1) test failed\n" );
- }
- if (ucoutbuf[1]) {
- errs++;
- fprintf( stderr, "unsigned char BAND(0) test failed\n" );
- }
- if (ucoutbuf[2] != 0xf0 && size > 1) {
- errs++;
- fprintf( stderr, "unsigned char BAND(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (ucoutbuf[0] != 0xff) {
+ errs++;
+ fprintf(stderr, "unsigned char BAND(1) test failed\n");
+ }
+ if (ucoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "unsigned char BAND(0) test failed\n");
+ }
+ if (ucoutbuf[2] != 0xf0 && size > 1) {
+ errs++;
+ fprintf(stderr, "unsigned char BAND(>) test failed\n");
+ }
+ }
}
/* bytes */
- MTestPrintfMsg( 10, "Reduce of MPI_BYTE\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_BYTE\n");
cinbuf[0] = 0xff;
cinbuf[1] = 0;
cinbuf[2] = (rank > 0) ? 0xff : 0xf0;
@@ -148,30 +148,30 @@ int main( int argc, char *argv[] )
coutbuf[0] = 0;
coutbuf[1] = 1;
coutbuf[2] = 1;
- rc = MPI_Reduce( cinbuf, coutbuf, 3, MPI_BYTE, MPI_BAND, 0, comm );
+ rc = MPI_Reduce(cinbuf, coutbuf, 3, MPI_BYTE, MPI_BAND, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BAND and MPI_BYTE", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BAND and MPI_BYTE", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (coutbuf[0] != (char)0xff) {
- errs++;
- fprintf( stderr, "byte BAND(1) test failed\n" );
- }
- if (coutbuf[1]) {
- errs++;
- fprintf( stderr, "byte BAND(0) test failed\n" );
- }
- if (coutbuf[2] != (char)0xf0 && size > 1) {
- errs++;
- fprintf( stderr, "byte BAND(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (coutbuf[0] != (char) 0xff) {
+ errs++;
+ fprintf(stderr, "byte BAND(1) test failed\n");
+ }
+ if (coutbuf[1]) {
+ errs++;
+ fprintf(stderr, "byte BAND(0) test failed\n");
+ }
+ if (coutbuf[2] != (char) 0xf0 && size > 1) {
+ errs++;
+ fprintf(stderr, "byte BAND(>) test failed\n");
+ }
+ }
}
/* short */
- MTestPrintfMsg( 10, "Reduce of MPI_SHORT\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_SHORT\n");
sinbuf[0] = 0xffff;
sinbuf[1] = 0;
sinbuf[2] = (rank > 0) ? 0xffff : 0xf0f0;
@@ -179,29 +179,29 @@ int main( int argc, char *argv[] )
soutbuf[0] = 0;
soutbuf[1] = 1;
soutbuf[2] = 1;
- rc = MPI_Reduce( sinbuf, soutbuf, 3, MPI_SHORT, MPI_BAND, 0, comm );
+ rc = MPI_Reduce(sinbuf, soutbuf, 3, MPI_SHORT, MPI_BAND, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BAND and MPI_SHORT", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BAND and MPI_SHORT", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (soutbuf[0] != (short)0xffff) {
- errs++;
- fprintf( stderr, "short BAND(1) test failed\n" );
- }
- if (soutbuf[1]) {
- errs++;
- fprintf( stderr, "short BAND(0) test failed\n" );
- }
- if (soutbuf[2] != (short)0xf0f0 && size > 1) {
- errs++;
- fprintf( stderr, "short BAND(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (soutbuf[0] != (short) 0xffff) {
+ errs++;
+ fprintf(stderr, "short BAND(1) test failed\n");
+ }
+ if (soutbuf[1]) {
+ errs++;
+ fprintf(stderr, "short BAND(0) test failed\n");
+ }
+ if (soutbuf[2] != (short) 0xf0f0 && size > 1) {
+ errs++;
+ fprintf(stderr, "short BAND(>) test failed\n");
+ }
+ }
}
- MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_SHORT\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_SHORT\n");
/* unsigned short */
usinbuf[0] = 0xffff;
usinbuf[1] = 0;
@@ -210,30 +210,30 @@ int main( int argc, char *argv[] )
usoutbuf[0] = 0;
usoutbuf[1] = 1;
usoutbuf[2] = 1;
- rc = MPI_Reduce( usinbuf, usoutbuf, 3, MPI_UNSIGNED_SHORT, MPI_BAND, 0, comm );
+ rc = MPI_Reduce(usinbuf, usoutbuf, 3, MPI_UNSIGNED_SHORT, MPI_BAND, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BAND and MPI_UNSIGNED_SHORT", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BAND and MPI_UNSIGNED_SHORT", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (usoutbuf[0] != 0xffff) {
- errs++;
- fprintf( stderr, "short BAND(1) test failed\n" );
- }
- if (usoutbuf[1]) {
- errs++;
- fprintf( stderr, "short BAND(0) test failed\n" );
- }
- if (usoutbuf[2] != 0xf0f0 && size > 1) {
- errs++;
- fprintf( stderr, "short BAND(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (usoutbuf[0] != 0xffff) {
+ errs++;
+ fprintf(stderr, "short BAND(1) test failed\n");
+ }
+ if (usoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "short BAND(0) test failed\n");
+ }
+ if (usoutbuf[2] != 0xf0f0 && size > 1) {
+ errs++;
+ fprintf(stderr, "short BAND(>) test failed\n");
+ }
+ }
}
/* unsigned */
- MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED\n");
uinbuf[0] = 0xffffffff;
uinbuf[1] = 0;
uinbuf[2] = (rank > 0) ? 0xffffffff : 0xf0f0f0f0;
@@ -241,30 +241,30 @@ int main( int argc, char *argv[] )
uoutbuf[0] = 0;
uoutbuf[1] = 1;
uoutbuf[2] = 1;
- rc = MPI_Reduce( uinbuf, uoutbuf, 3, MPI_UNSIGNED, MPI_BAND, 0, comm );
+ rc = MPI_Reduce(uinbuf, uoutbuf, 3, MPI_UNSIGNED, MPI_BAND, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BAND and MPI_UNSIGNED", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BAND and MPI_UNSIGNED", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (uoutbuf[0] != 0xffffffff) {
- errs++;
- fprintf( stderr, "unsigned BAND(1) test failed\n" );
- }
- if (uoutbuf[1]) {
- errs++;
- fprintf( stderr, "unsigned BAND(0) test failed\n" );
- }
- if (uoutbuf[2] != 0xf0f0f0f0 && size > 1) {
- errs++;
- fprintf( stderr, "unsigned BAND(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (uoutbuf[0] != 0xffffffff) {
+ errs++;
+ fprintf(stderr, "unsigned BAND(1) test failed\n");
+ }
+ if (uoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "unsigned BAND(0) test failed\n");
+ }
+ if (uoutbuf[2] != 0xf0f0f0f0 && size > 1) {
+ errs++;
+ fprintf(stderr, "unsigned BAND(>) test failed\n");
+ }
+ }
}
/* long */
- MTestPrintfMsg( 10, "Reduce of MPI_LONG\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_LONG\n");
linbuf[0] = 0xffffffff;
linbuf[1] = 0;
linbuf[2] = (rank > 0) ? 0xffffffff : 0xf0f0f0f0;
@@ -272,29 +272,29 @@ int main( int argc, char *argv[] )
loutbuf[0] = 0;
loutbuf[1] = 1;
loutbuf[2] = 1;
- rc = MPI_Reduce( linbuf, loutbuf, 3, MPI_LONG, MPI_BAND, 0, comm );
+ rc = MPI_Reduce(linbuf, loutbuf, 3, MPI_LONG, MPI_BAND, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BAND and MPI_LONG", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BAND and MPI_LONG", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (loutbuf[0] != 0xffffffff) {
- errs++;
- fprintf( stderr, "long BAND(1) test failed\n" );
- }
- if (loutbuf[1]) {
- errs++;
- fprintf( stderr, "long BAND(0) test failed\n" );
- }
- if (loutbuf[2] != 0xf0f0f0f0 && size > 1) {
- errs++;
- fprintf( stderr, "long BAND(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (loutbuf[0] != 0xffffffff) {
+ errs++;
+ fprintf(stderr, "long BAND(1) test failed\n");
+ }
+ if (loutbuf[1]) {
+ errs++;
+ fprintf(stderr, "long BAND(0) test failed\n");
+ }
+ if (loutbuf[2] != 0xf0f0f0f0 && size > 1) {
+ errs++;
+ fprintf(stderr, "long BAND(>) test failed\n");
+ }
+ }
}
- MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_LONG\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_LONG\n");
/* unsigned long */
ulinbuf[0] = 0xffffffff;
ulinbuf[1] = 0;
@@ -303,68 +303,68 @@ int main( int argc, char *argv[] )
uloutbuf[0] = 0;
uloutbuf[1] = 1;
uloutbuf[2] = 1;
- rc = MPI_Reduce( ulinbuf, uloutbuf, 3, MPI_UNSIGNED_LONG, MPI_BAND, 0, comm );
+ rc = MPI_Reduce(ulinbuf, uloutbuf, 3, MPI_UNSIGNED_LONG, MPI_BAND, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BAND and MPI_UNSIGNED_LONG", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BAND and MPI_UNSIGNED_LONG", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (uloutbuf[0] != 0xffffffff) {
- errs++;
- fprintf( stderr, "unsigned long BAND(1) test failed\n" );
- }
- if (uloutbuf[1]) {
- errs++;
- fprintf( stderr, "unsigned long BAND(0) test failed\n" );
- }
- if (uloutbuf[2] != 0xf0f0f0f0 && size > 1) {
- errs++;
- fprintf( stderr, "unsigned long BAND(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (uloutbuf[0] != 0xffffffff) {
+ errs++;
+ fprintf(stderr, "unsigned long BAND(1) test failed\n");
+ }
+ if (uloutbuf[1]) {
+ errs++;
+ fprintf(stderr, "unsigned long BAND(0) test failed\n");
+ }
+ if (uloutbuf[2] != 0xf0f0f0f0 && size > 1) {
+ errs++;
+ fprintf(stderr, "unsigned long BAND(>) test failed\n");
+ }
+ }
}
#ifdef HAVE_LONG_LONG
{
- long long llinbuf[3], lloutbuf[3];
- /* long long */
- llinbuf[0] = 0xffffffff;
- llinbuf[1] = 0;
- llinbuf[2] = (rank > 0) ? 0xffffffff : 0xf0f0f0f0;
+ long long llinbuf[3], lloutbuf[3];
+ /* long long */
+ llinbuf[0] = 0xffffffff;
+ llinbuf[1] = 0;
+ llinbuf[2] = (rank > 0) ? 0xffffffff : 0xf0f0f0f0;
- lloutbuf[0] = 0;
- lloutbuf[1] = 1;
- lloutbuf[2] = 1;
- if (MPI_LONG_LONG != MPI_DATATYPE_NULL) {
- MTestPrintfMsg( 10, "Reduce of MPI_LONG_LONG\n" );
- rc = MPI_Reduce( llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_BAND, 0, comm );
- if (rc) {
- MTestPrintErrorMsg( "MPI_BAND and MPI_LONG_LONG", rc );
- errs++;
- }
- else {
- if (rank == 0) {
- if (lloutbuf[0] != 0xffffffff) {
- errs++;
- fprintf( stderr, "long long BAND(1) test failed\n" );
- }
- if (lloutbuf[1]) {
- errs++;
- fprintf( stderr, "long long BAND(0) test failed\n" );
- }
- if (lloutbuf[2] != 0xf0f0f0f0 && size > 1) {
- errs++;
- fprintf( stderr, "long long BAND(>) test failed\n" );
- }
- }
- }
- }
+ lloutbuf[0] = 0;
+ lloutbuf[1] = 1;
+ lloutbuf[2] = 1;
+ if (MPI_LONG_LONG != MPI_DATATYPE_NULL) {
+ MTestPrintfMsg(10, "Reduce of MPI_LONG_LONG\n");
+ rc = MPI_Reduce(llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_BAND, 0, comm);
+ if (rc) {
+ MTestPrintErrorMsg("MPI_BAND and MPI_LONG_LONG", rc);
+ errs++;
+ }
+ else {
+ if (rank == 0) {
+ if (lloutbuf[0] != 0xffffffff) {
+ errs++;
+ fprintf(stderr, "long long BAND(1) test failed\n");
+ }
+ if (lloutbuf[1]) {
+ errs++;
+ fprintf(stderr, "long long BAND(0) test failed\n");
+ }
+ if (lloutbuf[2] != 0xf0f0f0f0 && size > 1) {
+ errs++;
+ fprintf(stderr, "long long BAND(>) test failed\n");
+ }
+ }
+ }
+ }
}
#endif
- MPI_Errhandler_set( comm, MPI_ERRORS_ARE_FATAL );
- MTest_Finalize( errs );
+ MPI_Errhandler_set(comm, MPI_ERRORS_ARE_FATAL);
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/opbor.c b/test/mpi/coll/opbor.c
index 7c4e5d6..1841607 100644
--- a/test/mpi/coll/opbor.c
+++ b/test/mpi/coll/opbor.c
@@ -14,16 +14,16 @@ static char MTEST_Descrip[] = "Test MPI_BOR operations on optional datatypes dup
*/
/*
- * This test looks at the handling of logical and for types that are not
+ * This test looks at the handling of logical and for types that are not
* integers or are not required integers (e.g., long long). MPICH allows
* these as well. A strict MPI test should not include this test.
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rc;
int rank, size;
- MPI_Comm comm;
+ MPI_Comm comm;
char cinbuf[3], coutbuf[3];
signed char scinbuf[3], scoutbuf[3];
unsigned char ucinbuf[3], ucoutbuf[3];
@@ -33,21 +33,21 @@ int main( int argc, char *argv[] )
unsigned long ulinbuf[3], uloutbuf[3];
unsigned uinbuf[3], uoutbuf[3];
int iinbuf[3], ioutbuf[3];
-
- MTest_Init( &argc, &argv );
+
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- /* Set errors return so that we can provide better information
- should a routine reject one of the operand/datatype pairs */
- MPI_Errhandler_set( comm, MPI_ERRORS_RETURN );
+ /* Set errors return so that we can provide better information
+ * should a routine reject one of the operand/datatype pairs */
+ MPI_Errhandler_set(comm, MPI_ERRORS_RETURN);
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
#ifndef USE_STRICT_MPI
/* char */
- MTestPrintfMsg( 10, "Reduce of MPI_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_CHAR\n");
cinbuf[0] = 0xff;
cinbuf[1] = 0;
cinbuf[2] = (rank > 0) ? 0x3c : 0xc3;
@@ -55,31 +55,31 @@ int main( int argc, char *argv[] )
coutbuf[0] = 0;
coutbuf[1] = 1;
coutbuf[2] = 1;
- rc = MPI_Reduce( cinbuf, coutbuf, 3, MPI_CHAR, MPI_BOR, 0, comm );
+ rc = MPI_Reduce(cinbuf, coutbuf, 3, MPI_CHAR, MPI_BOR, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BOR and MPI_CHAR", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BOR and MPI_CHAR", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (coutbuf[0] != (char)0xff) {
- errs++;
- fprintf( stderr, "char BOR(1) test failed\n" );
- }
- if (coutbuf[1]) {
- errs++;
- fprintf( stderr, "char BOR(0) test failed\n" );
- }
- if (coutbuf[2] != (char)0xff && size > 1) {
- errs++;
- fprintf( stderr, "char BOR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (coutbuf[0] != (char) 0xff) {
+ errs++;
+ fprintf(stderr, "char BOR(1) test failed\n");
+ }
+ if (coutbuf[1]) {
+ errs++;
+ fprintf(stderr, "char BOR(0) test failed\n");
+ }
+ if (coutbuf[2] != (char) 0xff && size > 1) {
+ errs++;
+ fprintf(stderr, "char BOR(>) test failed\n");
+ }
+ }
}
#endif /* USE_STRICT_MPI */
/* signed char */
- MTestPrintfMsg( 10, "Reduce of MPI_SIGNED_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_SIGNED_CHAR\n");
scinbuf[0] = 0xff;
scinbuf[1] = 0;
scinbuf[2] = (rank > 0) ? 0x3c : 0xc3;
@@ -87,30 +87,30 @@ int main( int argc, char *argv[] )
scoutbuf[0] = 0;
scoutbuf[1] = 1;
scoutbuf[2] = 1;
- rc = MPI_Reduce( scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_BOR, 0, comm );
+ rc = MPI_Reduce(scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_BOR, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BOR and MPI_SIGNED_CHAR", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BOR and MPI_SIGNED_CHAR", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (scoutbuf[0] != (signed char)0xff) {
- errs++;
- fprintf( stderr, "signed char BOR(1) test failed\n" );
- }
- if (scoutbuf[1]) {
- errs++;
- fprintf( stderr, "signed char BOR(0) test failed\n" );
- }
- if (scoutbuf[2] != (signed char)0xff && size > 1) {
- errs++;
- fprintf( stderr, "signed char BOR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (scoutbuf[0] != (signed char) 0xff) {
+ errs++;
+ fprintf(stderr, "signed char BOR(1) test failed\n");
+ }
+ if (scoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "signed char BOR(0) test failed\n");
+ }
+ if (scoutbuf[2] != (signed char) 0xff && size > 1) {
+ errs++;
+ fprintf(stderr, "signed char BOR(>) test failed\n");
+ }
+ }
}
/* unsigned char */
- MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_CHAR\n");
ucinbuf[0] = 0xff;
ucinbuf[1] = 0;
ucinbuf[2] = (rank > 0) ? 0x3c : 0xc3;
@@ -118,30 +118,30 @@ int main( int argc, char *argv[] )
ucoutbuf[0] = 0;
ucoutbuf[1] = 1;
ucoutbuf[2] = 1;
- rc = MPI_Reduce( ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_BOR, 0, comm );
+ rc = MPI_Reduce(ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_BOR, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BOR and MPI_UNSIGNED_CHAR", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BOR and MPI_UNSIGNED_CHAR", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (ucoutbuf[0] != 0xff) {
- errs++;
- fprintf( stderr, "unsigned char BOR(1) test failed\n" );
- }
- if (ucoutbuf[1]) {
- errs++;
- fprintf( stderr, "unsigned char BOR(0) test failed\n" );
- }
- if (ucoutbuf[2] != 0xff && size > 1) {
- errs++;
- fprintf( stderr, "unsigned char BOR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (ucoutbuf[0] != 0xff) {
+ errs++;
+ fprintf(stderr, "unsigned char BOR(1) test failed\n");
+ }
+ if (ucoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "unsigned char BOR(0) test failed\n");
+ }
+ if (ucoutbuf[2] != 0xff && size > 1) {
+ errs++;
+ fprintf(stderr, "unsigned char BOR(>) test failed\n");
+ }
+ }
}
/* bytes */
- MTestPrintfMsg( 10, "Reduce of MPI_BYTE\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_BYTE\n");
cinbuf[0] = 0xff;
cinbuf[1] = 0;
cinbuf[2] = (rank > 0) ? 0x3c : 0xc3;
@@ -149,30 +149,30 @@ int main( int argc, char *argv[] )
coutbuf[0] = 0;
coutbuf[1] = 1;
coutbuf[2] = 1;
- rc = MPI_Reduce( cinbuf, coutbuf, 3, MPI_BYTE, MPI_BOR, 0, comm );
+ rc = MPI_Reduce(cinbuf, coutbuf, 3, MPI_BYTE, MPI_BOR, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BOR and MPI_BYTE", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BOR and MPI_BYTE", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (coutbuf[0] != (char)0xff) {
- errs++;
- fprintf( stderr, "byte BOR(1) test failed\n" );
- }
- if (coutbuf[1]) {
- errs++;
- fprintf( stderr, "byte BOR(0) test failed\n" );
- }
- if (coutbuf[2] != (char)0xff && size > 1) {
- errs++;
- fprintf( stderr, "byte BOR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (coutbuf[0] != (char) 0xff) {
+ errs++;
+ fprintf(stderr, "byte BOR(1) test failed\n");
+ }
+ if (coutbuf[1]) {
+ errs++;
+ fprintf(stderr, "byte BOR(0) test failed\n");
+ }
+ if (coutbuf[2] != (char) 0xff && size > 1) {
+ errs++;
+ fprintf(stderr, "byte BOR(>) test failed\n");
+ }
+ }
}
/* short */
- MTestPrintfMsg( 10, "Reduce of MPI_SHORT\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_SHORT\n");
sinbuf[0] = 0xffff;
sinbuf[1] = 0;
sinbuf[2] = (rank > 0) ? 0x3c3c : 0xc3c3;
@@ -180,30 +180,30 @@ int main( int argc, char *argv[] )
soutbuf[0] = 0;
soutbuf[1] = 1;
soutbuf[2] = 1;
- rc = MPI_Reduce( sinbuf, soutbuf, 3, MPI_SHORT, MPI_BOR, 0, comm );
+ rc = MPI_Reduce(sinbuf, soutbuf, 3, MPI_SHORT, MPI_BOR, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BOR and MPI_SHORT", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BOR and MPI_SHORT", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (soutbuf[0] != (short)0xffff) {
- errs++;
- fprintf( stderr, "short BOR(1) test failed\n" );
- }
- if (soutbuf[1]) {
- errs++;
- fprintf( stderr, "short BOR(0) test failed\n" );
- }
- if (soutbuf[2] != (short)0xffff && size > 1) {
- errs++;
- fprintf( stderr, "short BOR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (soutbuf[0] != (short) 0xffff) {
+ errs++;
+ fprintf(stderr, "short BOR(1) test failed\n");
+ }
+ if (soutbuf[1]) {
+ errs++;
+ fprintf(stderr, "short BOR(0) test failed\n");
+ }
+ if (soutbuf[2] != (short) 0xffff && size > 1) {
+ errs++;
+ fprintf(stderr, "short BOR(>) test failed\n");
+ }
+ }
}
/* unsigned short */
- MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_SHORT\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_SHORT\n");
usinbuf[0] = 0xffff;
usinbuf[1] = 0;
usinbuf[2] = (rank > 0) ? 0x3c3c : 0xc3c3;
@@ -211,30 +211,30 @@ int main( int argc, char *argv[] )
usoutbuf[0] = 0;
usoutbuf[1] = 1;
usoutbuf[2] = 1;
- rc = MPI_Reduce( usinbuf, usoutbuf, 3, MPI_UNSIGNED_SHORT, MPI_BOR, 0, comm );
+ rc = MPI_Reduce(usinbuf, usoutbuf, 3, MPI_UNSIGNED_SHORT, MPI_BOR, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BOR and MPI_UNSIGNED_SHORT", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BOR and MPI_UNSIGNED_SHORT", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (usoutbuf[0] != 0xffff) {
- errs++;
- fprintf( stderr, "short BOR(1) test failed\n" );
- }
- if (usoutbuf[1]) {
- errs++;
- fprintf( stderr, "short BOR(0) test failed\n" );
- }
- if (usoutbuf[2] != 0xffff && size > 1) {
- errs++;
- fprintf( stderr, "short BOR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (usoutbuf[0] != 0xffff) {
+ errs++;
+ fprintf(stderr, "short BOR(1) test failed\n");
+ }
+ if (usoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "short BOR(0) test failed\n");
+ }
+ if (usoutbuf[2] != 0xffff && size > 1) {
+ errs++;
+ fprintf(stderr, "short BOR(>) test failed\n");
+ }
+ }
}
/* unsigned */
- MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED\n");
uinbuf[0] = 0xffffffff;
uinbuf[1] = 0;
uinbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3;
@@ -242,30 +242,30 @@ int main( int argc, char *argv[] )
uoutbuf[0] = 0;
uoutbuf[1] = 1;
uoutbuf[2] = 1;
- rc = MPI_Reduce( uinbuf, uoutbuf, 3, MPI_UNSIGNED, MPI_BOR, 0, comm );
+ rc = MPI_Reduce(uinbuf, uoutbuf, 3, MPI_UNSIGNED, MPI_BOR, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BOR and MPI_UNSIGNED", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BOR and MPI_UNSIGNED", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (uoutbuf[0] != 0xffffffff) {
- errs++;
- fprintf( stderr, "unsigned BOR(1) test failed\n" );
- }
- if (uoutbuf[1]) {
- errs++;
- fprintf( stderr, "unsigned BOR(0) test failed\n" );
- }
- if (uoutbuf[2] != 0xffffffff && size > 1) {
- errs++;
- fprintf( stderr, "unsigned BOR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (uoutbuf[0] != 0xffffffff) {
+ errs++;
+ fprintf(stderr, "unsigned BOR(1) test failed\n");
+ }
+ if (uoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "unsigned BOR(0) test failed\n");
+ }
+ if (uoutbuf[2] != 0xffffffff && size > 1) {
+ errs++;
+ fprintf(stderr, "unsigned BOR(>) test failed\n");
+ }
+ }
}
/* int */
- MTestPrintfMsg( 10, "Reduce of MPI_INT\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_INT\n");
iinbuf[0] = 0xffffffff;
iinbuf[1] = 0;
iinbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3;
@@ -273,30 +273,30 @@ int main( int argc, char *argv[] )
ioutbuf[0] = 0;
ioutbuf[1] = 1;
ioutbuf[2] = 1;
- rc = MPI_Reduce( iinbuf, ioutbuf, 3, MPI_INT, MPI_BOR, 0, comm );
+ rc = MPI_Reduce(iinbuf, ioutbuf, 3, MPI_INT, MPI_BOR, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BOR and MPI_INT", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BOR and MPI_INT", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (ioutbuf[0] != 0xffffffff) {
- errs++;
- fprintf( stderr, "int BOR(1) test failed\n" );
- }
- if (ioutbuf[1]) {
- errs++;
- fprintf( stderr, "int BOR(0) test failed\n" );
- }
- if (ioutbuf[2] != 0xffffffff && size > 1) {
- errs++;
- fprintf( stderr, "int BOR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (ioutbuf[0] != 0xffffffff) {
+ errs++;
+ fprintf(stderr, "int BOR(1) test failed\n");
+ }
+ if (ioutbuf[1]) {
+ errs++;
+ fprintf(stderr, "int BOR(0) test failed\n");
+ }
+ if (ioutbuf[2] != 0xffffffff && size > 1) {
+ errs++;
+ fprintf(stderr, "int BOR(>) test failed\n");
+ }
+ }
}
/* long */
- MTestPrintfMsg( 10, "Reduce of MPI_LONG\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_LONG\n");
linbuf[0] = 0xffffffff;
linbuf[1] = 0;
linbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3;
@@ -304,30 +304,30 @@ int main( int argc, char *argv[] )
loutbuf[0] = 0;
loutbuf[1] = 1;
loutbuf[2] = 1;
- rc = MPI_Reduce( linbuf, loutbuf, 3, MPI_LONG, MPI_BOR, 0, comm );
+ rc = MPI_Reduce(linbuf, loutbuf, 3, MPI_LONG, MPI_BOR, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BOR and MPI_LONG", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BOR and MPI_LONG", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (loutbuf[0] != 0xffffffff) {
- errs++;
- fprintf( stderr, "long BOR(1) test failed\n" );
- }
- if (loutbuf[1]) {
- errs++;
- fprintf( stderr, "long BOR(0) test failed\n" );
- }
- if (loutbuf[2] != 0xffffffff && size > 1) {
- errs++;
- fprintf( stderr, "long BOR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (loutbuf[0] != 0xffffffff) {
+ errs++;
+ fprintf(stderr, "long BOR(1) test failed\n");
+ }
+ if (loutbuf[1]) {
+ errs++;
+ fprintf(stderr, "long BOR(0) test failed\n");
+ }
+ if (loutbuf[2] != 0xffffffff && size > 1) {
+ errs++;
+ fprintf(stderr, "long BOR(>) test failed\n");
+ }
+ }
}
/* unsigned long */
- MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_LONG\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_LONG\n");
ulinbuf[0] = 0xffffffff;
ulinbuf[1] = 0;
ulinbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3;
@@ -335,68 +335,68 @@ int main( int argc, char *argv[] )
uloutbuf[0] = 0;
uloutbuf[1] = 1;
uloutbuf[2] = 1;
- rc = MPI_Reduce( ulinbuf, uloutbuf, 3, MPI_UNSIGNED_LONG, MPI_BOR, 0, comm );
+ rc = MPI_Reduce(ulinbuf, uloutbuf, 3, MPI_UNSIGNED_LONG, MPI_BOR, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BOR and MPI_UNSIGNED_LONG", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BOR and MPI_UNSIGNED_LONG", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (uloutbuf[0] != 0xffffffff) {
- errs++;
- fprintf( stderr, "unsigned long BOR(1) test failed\n" );
- }
- if (uloutbuf[1]) {
- errs++;
- fprintf( stderr, "unsigned long BOR(0) test failed\n" );
- }
- if (uloutbuf[2] != 0xffffffff && size > 1) {
- errs++;
- fprintf( stderr, "unsigned long BOR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (uloutbuf[0] != 0xffffffff) {
+ errs++;
+ fprintf(stderr, "unsigned long BOR(1) test failed\n");
+ }
+ if (uloutbuf[1]) {
+ errs++;
+ fprintf(stderr, "unsigned long BOR(0) test failed\n");
+ }
+ if (uloutbuf[2] != 0xffffffff && size > 1) {
+ errs++;
+ fprintf(stderr, "unsigned long BOR(>) test failed\n");
+ }
+ }
}
#ifdef HAVE_LONG_LONG
{
- long long llinbuf[3], lloutbuf[3];
- /* long long */
- llinbuf[0] = 0xffffffff;
- llinbuf[1] = 0;
- llinbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3;
+ long long llinbuf[3], lloutbuf[3];
+ /* long long */
+ llinbuf[0] = 0xffffffff;
+ llinbuf[1] = 0;
+ llinbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3;
- lloutbuf[0] = 0;
- lloutbuf[1] = 1;
- lloutbuf[2] = 1;
- if (MPI_LONG_LONG != MPI_DATATYPE_NULL) {
- MTestPrintfMsg( 10, "Reduce of MPI_LONG_LONG\n" );
- rc = MPI_Reduce( llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_BOR, 0, comm );
- if (rc) {
- MTestPrintErrorMsg( "MPI_BOR and MPI_LONG_LONG", rc );
- errs++;
- }
- else {
- if (rank == 0) {
- if (lloutbuf[0] != 0xffffffff) {
- errs++;
- fprintf( stderr, "long long BOR(1) test failed\n" );
- }
- if (lloutbuf[1]) {
- errs++;
- fprintf( stderr, "long long BOR(0) test failed\n" );
- }
- if (lloutbuf[2] != 0xffffffff && size > 1) {
- errs++;
- fprintf( stderr, "long long BOR(>) test failed\n" );
- }
- }
- }
- }
+ lloutbuf[0] = 0;
+ lloutbuf[1] = 1;
+ lloutbuf[2] = 1;
+ if (MPI_LONG_LONG != MPI_DATATYPE_NULL) {
+ MTestPrintfMsg(10, "Reduce of MPI_LONG_LONG\n");
+ rc = MPI_Reduce(llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_BOR, 0, comm);
+ if (rc) {
+ MTestPrintErrorMsg("MPI_BOR and MPI_LONG_LONG", rc);
+ errs++;
+ }
+ else {
+ if (rank == 0) {
+ if (lloutbuf[0] != 0xffffffff) {
+ errs++;
+ fprintf(stderr, "long long BOR(1) test failed\n");
+ }
+ if (lloutbuf[1]) {
+ errs++;
+ fprintf(stderr, "long long BOR(0) test failed\n");
+ }
+ if (lloutbuf[2] != 0xffffffff && size > 1) {
+ errs++;
+ fprintf(stderr, "long long BOR(>) test failed\n");
+ }
+ }
+ }
+ }
}
#endif
- MPI_Errhandler_set( comm, MPI_ERRORS_ARE_FATAL );
- MTest_Finalize( errs );
+ MPI_Errhandler_set(comm, MPI_ERRORS_ARE_FATAL);
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/opbxor.c b/test/mpi/coll/opbxor.c
index 6673561..d5b64db 100644
--- a/test/mpi/coll/opbxor.c
+++ b/test/mpi/coll/opbxor.c
@@ -14,16 +14,16 @@ static char MTEST_Descrip[] = "Test MPI_BXOR operations on optional datatypes du
*/
/*
- * This test looks at the handling of logical and for types that are not
+ * This test looks at the handling of logical and for types that are not
* integers or are not required integers (e.g., long long). MPICH allows
* these as well. A strict MPI test should not include this test.
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rc;
int rank, size;
- MPI_Comm comm;
+ MPI_Comm comm;
char cinbuf[3], coutbuf[3];
signed char scinbuf[3], scoutbuf[3];
unsigned char ucinbuf[3], ucoutbuf[3];
@@ -33,21 +33,21 @@ int main( int argc, char *argv[] )
unsigned long ulinbuf[3], uloutbuf[3];
unsigned uinbuf[3], uoutbuf[3];
int iinbuf[3], ioutbuf[3];
-
- MTest_Init( &argc, &argv );
+
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- /* Set errors return so that we can provide better information
- should a routine reject one of the operand/datatype pairs */
- MPI_Errhandler_set( comm, MPI_ERRORS_RETURN );
+ /* Set errors return so that we can provide better information
+ * should a routine reject one of the operand/datatype pairs */
+ MPI_Errhandler_set(comm, MPI_ERRORS_RETURN);
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
#ifndef USE_STRICT_MPI
/* char */
- MTestPrintfMsg( 10, "Reduce of MPI_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_CHAR\n");
cinbuf[0] = 0xff;
cinbuf[1] = 0;
cinbuf[2] = (rank > 0) ? 0x3c : 0xc3;
@@ -55,31 +55,31 @@ int main( int argc, char *argv[] )
coutbuf[0] = 0xf;
coutbuf[1] = 1;
coutbuf[2] = 1;
- rc = MPI_Reduce( cinbuf, coutbuf, 3, MPI_CHAR, MPI_BXOR, 0, comm );
+ rc = MPI_Reduce(cinbuf, coutbuf, 3, MPI_CHAR, MPI_BXOR, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BXOR and MPI_CHAR", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BXOR and MPI_CHAR", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (coutbuf[0] != ((size % 2) ? (char)0xff : (char)0) ) {
- errs++;
- fprintf( stderr, "char BXOR(1) test failed\n" );
- }
- if (coutbuf[1]) {
- errs++;
- fprintf( stderr, "char BXOR(0) test failed\n" );
- }
- if (coutbuf[2] != ((size % 2) ? (char)0xc3 : (char)0xff)) {
- errs++;
- fprintf( stderr, "char BXOR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (coutbuf[0] != ((size % 2) ? (char) 0xff : (char) 0)) {
+ errs++;
+ fprintf(stderr, "char BXOR(1) test failed\n");
+ }
+ if (coutbuf[1]) {
+ errs++;
+ fprintf(stderr, "char BXOR(0) test failed\n");
+ }
+ if (coutbuf[2] != ((size % 2) ? (char) 0xc3 : (char) 0xff)) {
+ errs++;
+ fprintf(stderr, "char BXOR(>) test failed\n");
+ }
+ }
}
#endif /* USE_STRICT_MPI */
/* signed char */
- MTestPrintfMsg( 10, "Reduce of MPI_SIGNED_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_SIGNED_CHAR\n");
scinbuf[0] = 0xff;
scinbuf[1] = 0;
scinbuf[2] = (rank > 0) ? 0x3c : 0xc3;
@@ -87,30 +87,30 @@ int main( int argc, char *argv[] )
scoutbuf[0] = 0xf;
scoutbuf[1] = 1;
scoutbuf[2] = 1;
- rc = MPI_Reduce( scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_BXOR, 0, comm );
+ rc = MPI_Reduce(scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_BXOR, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BXOR and MPI_SIGNED_CHAR", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BXOR and MPI_SIGNED_CHAR", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (scoutbuf[0] != ((size % 2) ? (signed char)0xff : (signed char)0) ) {
- errs++;
- fprintf( stderr, "signed char BXOR(1) test failed\n" );
- }
- if (scoutbuf[1]) {
- errs++;
- fprintf( stderr, "signed char BXOR(0) test failed\n" );
- }
- if (scoutbuf[2] != ((size % 2) ? (signed char)0xc3 : (signed char)0xff)) {
- errs++;
- fprintf( stderr, "signed char BXOR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (scoutbuf[0] != ((size % 2) ? (signed char) 0xff : (signed char) 0)) {
+ errs++;
+ fprintf(stderr, "signed char BXOR(1) test failed\n");
+ }
+ if (scoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "signed char BXOR(0) test failed\n");
+ }
+ if (scoutbuf[2] != ((size % 2) ? (signed char) 0xc3 : (signed char) 0xff)) {
+ errs++;
+ fprintf(stderr, "signed char BXOR(>) test failed\n");
+ }
+ }
}
/* unsigned char */
- MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_CHAR\n");
ucinbuf[0] = 0xff;
ucinbuf[1] = 0;
ucinbuf[2] = (rank > 0) ? 0x3c : 0xc3;
@@ -118,30 +118,30 @@ int main( int argc, char *argv[] )
ucoutbuf[0] = 0;
ucoutbuf[1] = 1;
ucoutbuf[2] = 1;
- rc = MPI_Reduce( ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_BXOR, 0, comm );
+ rc = MPI_Reduce(ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_BXOR, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BXOR and MPI_UNSIGNED_CHAR", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BXOR and MPI_UNSIGNED_CHAR", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (ucoutbuf[0] != ((size % 2) ? 0xff : 0)) {
- errs++;
- fprintf( stderr, "unsigned char BXOR(1) test failed\n" );
- }
- if (ucoutbuf[1]) {
- errs++;
- fprintf( stderr, "unsigned char BXOR(0) test failed\n" );
- }
- if (ucoutbuf[2] != ((size % 2) ? (unsigned char)0xc3 : (unsigned char)0xff)) {
- errs++;
- fprintf( stderr, "unsigned char BXOR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (ucoutbuf[0] != ((size % 2) ? 0xff : 0)) {
+ errs++;
+ fprintf(stderr, "unsigned char BXOR(1) test failed\n");
+ }
+ if (ucoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "unsigned char BXOR(0) test failed\n");
+ }
+ if (ucoutbuf[2] != ((size % 2) ? (unsigned char) 0xc3 : (unsigned char) 0xff)) {
+ errs++;
+ fprintf(stderr, "unsigned char BXOR(>) test failed\n");
+ }
+ }
}
/* bytes */
- MTestPrintfMsg( 10, "Reduce of MPI_BYTE\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_BYTE\n");
cinbuf[0] = 0xff;
cinbuf[1] = 0;
cinbuf[2] = (rank > 0) ? 0x3c : 0xc3;
@@ -149,30 +149,30 @@ int main( int argc, char *argv[] )
coutbuf[0] = 0;
coutbuf[1] = 1;
coutbuf[2] = 1;
- rc = MPI_Reduce( cinbuf, coutbuf, 3, MPI_BYTE, MPI_BXOR, 0, comm );
+ rc = MPI_Reduce(cinbuf, coutbuf, 3, MPI_BYTE, MPI_BXOR, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BXOR and MPI_BYTE", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BXOR and MPI_BYTE", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (coutbuf[0] != ((size % 2) ? (char)0xff : 0)) {
- errs++;
- fprintf( stderr, "byte BXOR(1) test failed\n" );
- }
- if (coutbuf[1]) {
- errs++;
- fprintf( stderr, "byte BXOR(0) test failed\n" );
- }
- if (coutbuf[2] != ((size % 2) ? (char)0xc3 : (char)0xff)) {
- errs++;
- fprintf( stderr, "byte BXOR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (coutbuf[0] != ((size % 2) ? (char) 0xff : 0)) {
+ errs++;
+ fprintf(stderr, "byte BXOR(1) test failed\n");
+ }
+ if (coutbuf[1]) {
+ errs++;
+ fprintf(stderr, "byte BXOR(0) test failed\n");
+ }
+ if (coutbuf[2] != ((size % 2) ? (char) 0xc3 : (char) 0xff)) {
+ errs++;
+ fprintf(stderr, "byte BXOR(>) test failed\n");
+ }
+ }
}
/* short */
- MTestPrintfMsg( 10, "Reduce of MPI_SHORT\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_SHORT\n");
sinbuf[0] = 0xffff;
sinbuf[1] = 0;
sinbuf[2] = (rank > 0) ? 0x3c3c : 0xc3c3;
@@ -180,30 +180,30 @@ int main( int argc, char *argv[] )
soutbuf[0] = 0;
soutbuf[1] = 1;
soutbuf[2] = 1;
- rc = MPI_Reduce( sinbuf, soutbuf, 3, MPI_SHORT, MPI_BXOR, 0, comm );
+ rc = MPI_Reduce(sinbuf, soutbuf, 3, MPI_SHORT, MPI_BXOR, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BXOR and MPI_SHORT", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BXOR and MPI_SHORT", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (soutbuf[0] != ((size % 2) ? (short)0xffff : 0)) {
- errs++;
- fprintf( stderr, "short BXOR(1) test failed\n" );
- }
- if (soutbuf[1]) {
- errs++;
- fprintf( stderr, "short BXOR(0) test failed\n" );
- }
- if (soutbuf[2] != ((size % 2) ? (short)0xc3c3 : (short)0xffff)) {
- errs++;
- fprintf( stderr, "short BXOR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (soutbuf[0] != ((size % 2) ? (short) 0xffff : 0)) {
+ errs++;
+ fprintf(stderr, "short BXOR(1) test failed\n");
+ }
+ if (soutbuf[1]) {
+ errs++;
+ fprintf(stderr, "short BXOR(0) test failed\n");
+ }
+ if (soutbuf[2] != ((size % 2) ? (short) 0xc3c3 : (short) 0xffff)) {
+ errs++;
+ fprintf(stderr, "short BXOR(>) test failed\n");
+ }
+ }
}
/* unsigned short */
- MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_SHORT\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_SHORT\n");
usinbuf[0] = 0xffff;
usinbuf[1] = 0;
usinbuf[2] = (rank > 0) ? 0x3c3c : 0xc3c3;
@@ -211,30 +211,30 @@ int main( int argc, char *argv[] )
usoutbuf[0] = 0;
usoutbuf[1] = 1;
usoutbuf[2] = 1;
- rc = MPI_Reduce( usinbuf, usoutbuf, 3, MPI_UNSIGNED_SHORT, MPI_BXOR, 0, comm );
+ rc = MPI_Reduce(usinbuf, usoutbuf, 3, MPI_UNSIGNED_SHORT, MPI_BXOR, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BXOR and MPI_UNSIGNED_SHORT", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BXOR and MPI_UNSIGNED_SHORT", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (usoutbuf[0] != ((size % 2) ? 0xffff : 0)) {
- errs++;
- fprintf( stderr, "short BXOR(1) test failed\n" );
- }
- if (usoutbuf[1]) {
- errs++;
- fprintf( stderr, "short BXOR(0) test failed\n" );
- }
- if (usoutbuf[2] != ((size % 2) ? 0xc3c3 : 0xffff)) {
- errs++;
- fprintf( stderr, "short BXOR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (usoutbuf[0] != ((size % 2) ? 0xffff : 0)) {
+ errs++;
+ fprintf(stderr, "short BXOR(1) test failed\n");
+ }
+ if (usoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "short BXOR(0) test failed\n");
+ }
+ if (usoutbuf[2] != ((size % 2) ? 0xc3c3 : 0xffff)) {
+ errs++;
+ fprintf(stderr, "short BXOR(>) test failed\n");
+ }
+ }
}
/* unsigned */
- MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED\n");
uinbuf[0] = 0xffffffff;
uinbuf[1] = 0;
uinbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3;
@@ -242,30 +242,30 @@ int main( int argc, char *argv[] )
uoutbuf[0] = 0;
uoutbuf[1] = 1;
uoutbuf[2] = 1;
- rc = MPI_Reduce( uinbuf, uoutbuf, 3, MPI_UNSIGNED, MPI_BXOR, 0, comm );
+ rc = MPI_Reduce(uinbuf, uoutbuf, 3, MPI_UNSIGNED, MPI_BXOR, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BXOR and MPI_UNSIGNED", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BXOR and MPI_UNSIGNED", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (uoutbuf[0] != ((size % 2) ? 0xffffffff : 0)) {
- errs++;
- fprintf( stderr, "unsigned BXOR(1) test failed\n" );
- }
- if (uoutbuf[1]) {
- errs++;
- fprintf( stderr, "unsigned BXOR(0) test failed\n" );
- }
- if (uoutbuf[2] != ((size % 2) ? 0xc3c3c3c3 : 0xffffffff)) {
- errs++;
- fprintf( stderr, "unsigned BXOR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (uoutbuf[0] != ((size % 2) ? 0xffffffff : 0)) {
+ errs++;
+ fprintf(stderr, "unsigned BXOR(1) test failed\n");
+ }
+ if (uoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "unsigned BXOR(0) test failed\n");
+ }
+ if (uoutbuf[2] != ((size % 2) ? 0xc3c3c3c3 : 0xffffffff)) {
+ errs++;
+ fprintf(stderr, "unsigned BXOR(>) test failed\n");
+ }
+ }
}
/* int */
- MTestPrintfMsg( 10, "Reduce of MPI_INT\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_INT\n");
iinbuf[0] = 0xffffffff;
iinbuf[1] = 0;
iinbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3;
@@ -273,30 +273,30 @@ int main( int argc, char *argv[] )
ioutbuf[0] = 0;
ioutbuf[1] = 1;
ioutbuf[2] = 1;
- rc = MPI_Reduce( iinbuf, ioutbuf, 3, MPI_INT, MPI_BXOR, 0, comm );
+ rc = MPI_Reduce(iinbuf, ioutbuf, 3, MPI_INT, MPI_BXOR, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BXOR and MPI_INT", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BXOR and MPI_INT", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (ioutbuf[0] != ((size % 2) ? 0xffffffff : 0)) {
- errs++;
- fprintf( stderr, "int BXOR(1) test failed\n" );
- }
- if (ioutbuf[1]) {
- errs++;
- fprintf( stderr, "int BXOR(0) test failed\n" );
- }
- if (ioutbuf[2] != ((size % 2) ? 0xc3c3c3c3 : 0xffffffff)) {
- errs++;
- fprintf( stderr, "int BXOR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (ioutbuf[0] != ((size % 2) ? 0xffffffff : 0)) {
+ errs++;
+ fprintf(stderr, "int BXOR(1) test failed\n");
+ }
+ if (ioutbuf[1]) {
+ errs++;
+ fprintf(stderr, "int BXOR(0) test failed\n");
+ }
+ if (ioutbuf[2] != ((size % 2) ? 0xc3c3c3c3 : 0xffffffff)) {
+ errs++;
+ fprintf(stderr, "int BXOR(>) test failed\n");
+ }
+ }
}
/* long */
- MTestPrintfMsg( 10, "Reduce of MPI_LONG\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_LONG\n");
linbuf[0] = 0xffffffff;
linbuf[1] = 0;
linbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3;
@@ -304,30 +304,30 @@ int main( int argc, char *argv[] )
loutbuf[0] = 0;
loutbuf[1] = 1;
loutbuf[2] = 1;
- rc = MPI_Reduce( linbuf, loutbuf, 3, MPI_LONG, MPI_BXOR, 0, comm );
+ rc = MPI_Reduce(linbuf, loutbuf, 3, MPI_LONG, MPI_BXOR, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BXOR and MPI_LONG", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BXOR and MPI_LONG", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (loutbuf[0] != ((size % 2) ? 0xffffffff : 0)) {
- errs++;
- fprintf( stderr, "long BXOR(1) test failed\n" );
- }
- if (loutbuf[1]) {
- errs++;
- fprintf( stderr, "long BXOR(0) test failed\n" );
- }
- if (loutbuf[2] != ((size % 2) ? 0xc3c3c3c3 : 0xffffffff)) {
- errs++;
- fprintf( stderr, "long BXOR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (loutbuf[0] != ((size % 2) ? 0xffffffff : 0)) {
+ errs++;
+ fprintf(stderr, "long BXOR(1) test failed\n");
+ }
+ if (loutbuf[1]) {
+ errs++;
+ fprintf(stderr, "long BXOR(0) test failed\n");
+ }
+ if (loutbuf[2] != ((size % 2) ? 0xc3c3c3c3 : 0xffffffff)) {
+ errs++;
+ fprintf(stderr, "long BXOR(>) test failed\n");
+ }
+ }
}
/* unsigned long */
- MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_LONG\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_LONG\n");
ulinbuf[0] = 0xffffffff;
ulinbuf[1] = 0;
ulinbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3;
@@ -335,68 +335,68 @@ int main( int argc, char *argv[] )
uloutbuf[0] = 0;
uloutbuf[1] = 1;
uloutbuf[2] = 1;
- rc = MPI_Reduce( ulinbuf, uloutbuf, 3, MPI_UNSIGNED_LONG, MPI_BXOR, 0, comm );
+ rc = MPI_Reduce(ulinbuf, uloutbuf, 3, MPI_UNSIGNED_LONG, MPI_BXOR, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_BXOR and MPI_UNSIGNED_LONG", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_BXOR and MPI_UNSIGNED_LONG", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (uloutbuf[0] != ((size % 2) ? 0xffffffff : 0)) {
- errs++;
- fprintf( stderr, "unsigned long BXOR(1) test failed\n" );
- }
- if (uloutbuf[1]) {
- errs++;
- fprintf( stderr, "unsigned long BXOR(0) test failed\n" );
- }
- if (uloutbuf[2] != ((size % 2) ? 0xc3c3c3c3 : 0xffffffff)) {
- errs++;
- fprintf( stderr, "unsigned long BXOR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (uloutbuf[0] != ((size % 2) ? 0xffffffff : 0)) {
+ errs++;
+ fprintf(stderr, "unsigned long BXOR(1) test failed\n");
+ }
+ if (uloutbuf[1]) {
+ errs++;
+ fprintf(stderr, "unsigned long BXOR(0) test failed\n");
+ }
+ if (uloutbuf[2] != ((size % 2) ? 0xc3c3c3c3 : 0xffffffff)) {
+ errs++;
+ fprintf(stderr, "unsigned long BXOR(>) test failed\n");
+ }
+ }
}
#ifdef HAVE_LONG_LONG
{
- long long llinbuf[3], lloutbuf[3];
- /* long long */
- llinbuf[0] = 0xffffffff;
- llinbuf[1] = 0;
- llinbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3;
+ long long llinbuf[3], lloutbuf[3];
+ /* long long */
+ llinbuf[0] = 0xffffffff;
+ llinbuf[1] = 0;
+ llinbuf[2] = (rank > 0) ? 0x3c3c3c3c : 0xc3c3c3c3;
- lloutbuf[0] = 0;
- lloutbuf[1] = 1;
- lloutbuf[2] = 1;
- if (MPI_LONG_LONG != MPI_DATATYPE_NULL) {
- MTestPrintfMsg( 10, "Reduce of MPI_LONG_LONG\n" );
- rc = MPI_Reduce( llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_BXOR, 0, comm );
- if (rc) {
- MTestPrintErrorMsg( "MPI_BXOR and MPI_LONG_LONG", rc );
- errs++;
- }
- else {
- if (rank == 0) {
- if (lloutbuf[0] != ((size % 2) ? 0xffffffff : 0)) {
- errs++;
- fprintf( stderr, "long long BXOR(1) test failed\n" );
- }
- if (lloutbuf[1]) {
- errs++;
- fprintf( stderr, "long long BXOR(0) test failed\n" );
- }
- if (lloutbuf[2] != ((size % 2) ? 0xc3c3c3c3 : 0xffffffff)) {
- errs++;
- fprintf( stderr, "long long BXOR(>) test failed\n" );
- }
- }
- }
- }
+ lloutbuf[0] = 0;
+ lloutbuf[1] = 1;
+ lloutbuf[2] = 1;
+ if (MPI_LONG_LONG != MPI_DATATYPE_NULL) {
+ MTestPrintfMsg(10, "Reduce of MPI_LONG_LONG\n");
+ rc = MPI_Reduce(llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_BXOR, 0, comm);
+ if (rc) {
+ MTestPrintErrorMsg("MPI_BXOR and MPI_LONG_LONG", rc);
+ errs++;
+ }
+ else {
+ if (rank == 0) {
+ if (lloutbuf[0] != ((size % 2) ? 0xffffffff : 0)) {
+ errs++;
+ fprintf(stderr, "long long BXOR(1) test failed\n");
+ }
+ if (lloutbuf[1]) {
+ errs++;
+ fprintf(stderr, "long long BXOR(0) test failed\n");
+ }
+ if (lloutbuf[2] != ((size % 2) ? 0xc3c3c3c3 : 0xffffffff)) {
+ errs++;
+ fprintf(stderr, "long long BXOR(>) test failed\n");
+ }
+ }
+ }
+ }
}
#endif
- MPI_Errhandler_set( comm, MPI_ERRORS_ARE_FATAL );
- MTest_Finalize( errs );
+ MPI_Errhandler_set(comm, MPI_ERRORS_ARE_FATAL);
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/opland.c b/test/mpi/coll/opland.c
index ad32a75..52970df 100644
--- a/test/mpi/coll/opland.c
+++ b/test/mpi/coll/opland.c
@@ -14,35 +14,35 @@ static char MTEST_Descrip[] = "Test MPI_LAND operations on optional datatypes du
*/
/*
- * This test looks at the handling of logical and for types that are not
+ * This test looks at the handling of logical and for types that are not
* integers or are not required integers (e.g., long long). MPICH allows
* these as well. A strict MPI test should not include this test.
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rc;
int rank, size;
- MPI_Comm comm;
+ MPI_Comm comm;
char cinbuf[3], coutbuf[3];
signed char scinbuf[3], scoutbuf[3];
unsigned char ucinbuf[3], ucoutbuf[3];
float finbuf[3], foutbuf[3];
double dinbuf[3], doutbuf[3];
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- /* Set errors return so that we can provide better information
- should a routine reject one of the operand/datatype pairs */
- MPI_Errhandler_set( comm, MPI_ERRORS_RETURN );
+ /* Set errors return so that we can provide better information
+ * should a routine reject one of the operand/datatype pairs */
+ MPI_Errhandler_set(comm, MPI_ERRORS_RETURN);
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
#ifndef USE_STRICT_MPI
/* char */
- MTestPrintfMsg( 10, "Reduce of MPI_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_CHAR\n");
cinbuf[0] = 1;
cinbuf[1] = 0;
cinbuf[2] = (rank > 0);
@@ -50,31 +50,31 @@ int main( int argc, char *argv[] )
coutbuf[0] = 0;
coutbuf[1] = 1;
coutbuf[2] = 1;
- rc = MPI_Reduce( cinbuf, coutbuf, 3, MPI_CHAR, MPI_LAND, 0, comm );
+ rc = MPI_Reduce(cinbuf, coutbuf, 3, MPI_CHAR, MPI_LAND, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_LAND and MPI_CHAR", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_LAND and MPI_CHAR", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (!coutbuf[0]) {
- errs++;
- fprintf( stderr, "char AND(1) test failed\n" );
- }
- if (coutbuf[1]) {
- errs++;
- fprintf( stderr, "char AND(0) test failed\n" );
- }
- if (coutbuf[2] && size > 1) {
- errs++;
- fprintf( stderr, "char AND(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (!coutbuf[0]) {
+ errs++;
+ fprintf(stderr, "char AND(1) test failed\n");
+ }
+ if (coutbuf[1]) {
+ errs++;
+ fprintf(stderr, "char AND(0) test failed\n");
+ }
+ if (coutbuf[2] && size > 1) {
+ errs++;
+ fprintf(stderr, "char AND(>) test failed\n");
+ }
+ }
}
#endif /* USE_STRICT_MPI */
/* signed char */
- MTestPrintfMsg( 10, "Reduce of MPI_SIGNED_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_SIGNED_CHAR\n");
scinbuf[0] = 1;
scinbuf[1] = 0;
scinbuf[2] = (rank > 0);
@@ -82,30 +82,30 @@ int main( int argc, char *argv[] )
scoutbuf[0] = 0;
scoutbuf[1] = 1;
scoutbuf[2] = 1;
- rc = MPI_Reduce( scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_LAND, 0, comm );
+ rc = MPI_Reduce(scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_LAND, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_LAND and MPI_SIGNED_CHAR", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_LAND and MPI_SIGNED_CHAR", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (!scoutbuf[0]) {
- errs++;
- fprintf( stderr, "signed char AND(1) test failed\n" );
- }
- if (scoutbuf[1]) {
- errs++;
- fprintf( stderr, "signed char AND(0) test failed\n" );
- }
- if (scoutbuf[2] && size > 1) {
- errs++;
- fprintf( stderr, "signed char AND(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (!scoutbuf[0]) {
+ errs++;
+ fprintf(stderr, "signed char AND(1) test failed\n");
+ }
+ if (scoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "signed char AND(0) test failed\n");
+ }
+ if (scoutbuf[2] && size > 1) {
+ errs++;
+ fprintf(stderr, "signed char AND(>) test failed\n");
+ }
+ }
}
/* unsigned char */
- MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_CHAR\n");
ucinbuf[0] = 1;
ucinbuf[1] = 0;
ucinbuf[2] = (rank > 0);
@@ -113,31 +113,31 @@ int main( int argc, char *argv[] )
ucoutbuf[0] = 0;
ucoutbuf[1] = 1;
ucoutbuf[2] = 1;
- rc = MPI_Reduce( ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_LAND, 0, comm );
+ rc = MPI_Reduce(ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_LAND, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_LAND and MPI_UNSIGNED_CHAR", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_LAND and MPI_UNSIGNED_CHAR", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (!ucoutbuf[0]) {
- errs++;
- fprintf( stderr, "unsigned char AND(1) test failed\n" );
- }
- if (ucoutbuf[1]) {
- errs++;
- fprintf( stderr, "unsigned char AND(0) test failed\n" );
- }
- if (ucoutbuf[2] && size > 1) {
- errs++;
- fprintf( stderr, "unsigned char AND(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (!ucoutbuf[0]) {
+ errs++;
+ fprintf(stderr, "unsigned char AND(1) test failed\n");
+ }
+ if (ucoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "unsigned char AND(0) test failed\n");
+ }
+ if (ucoutbuf[2] && size > 1) {
+ errs++;
+ fprintf(stderr, "unsigned char AND(>) test failed\n");
+ }
+ }
}
#ifndef USE_STRICT_MPI
/* float */
- MTestPrintfMsg( 10, "Reduce of MPI_FLOAT\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_FLOAT\n");
finbuf[0] = 1;
finbuf[1] = 0;
finbuf[2] = (rank > 0);
@@ -145,29 +145,29 @@ int main( int argc, char *argv[] )
foutbuf[0] = 0;
foutbuf[1] = 1;
foutbuf[2] = 1;
- rc = MPI_Reduce( finbuf, foutbuf, 3, MPI_FLOAT, MPI_LAND, 0, comm );
+ rc = MPI_Reduce(finbuf, foutbuf, 3, MPI_FLOAT, MPI_LAND, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_LAND and MPI_FLOAT", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_LAND and MPI_FLOAT", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (!foutbuf[0]) {
- errs++;
- fprintf( stderr, "float AND(1) test failed\n" );
- }
- if (foutbuf[1]) {
- errs++;
- fprintf( stderr, "float AND(0) test failed\n" );
- }
- if (foutbuf[2] && size > 1) {
- errs++;
- fprintf( stderr, "float AND(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (!foutbuf[0]) {
+ errs++;
+ fprintf(stderr, "float AND(1) test failed\n");
+ }
+ if (foutbuf[1]) {
+ errs++;
+ fprintf(stderr, "float AND(0) test failed\n");
+ }
+ if (foutbuf[2] && size > 1) {
+ errs++;
+ fprintf(stderr, "float AND(>) test failed\n");
+ }
+ }
}
- MTestPrintfMsg( 10, "Reduce of MPI_DOUBLE\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_DOUBLE\n");
/* double */
dinbuf[0] = 1;
dinbuf[1] = 0;
@@ -176,62 +176,63 @@ int main( int argc, char *argv[] )
doutbuf[0] = 0;
doutbuf[1] = 1;
doutbuf[2] = 1;
- rc = MPI_Reduce( dinbuf, doutbuf, 3, MPI_DOUBLE, MPI_LAND, 0, comm );
+ rc = MPI_Reduce(dinbuf, doutbuf, 3, MPI_DOUBLE, MPI_LAND, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_LAND and MPI_DOUBLE", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_LAND and MPI_DOUBLE", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (!doutbuf[0]) {
- errs++;
- fprintf( stderr, "double AND(1) test failed\n" );
- }
- if (doutbuf[1]) {
- errs++;
- fprintf( stderr, "double AND(0) test failed\n" );
- }
- if (doutbuf[2] && size > 1) {
- errs++;
- fprintf( stderr, "double AND(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (!doutbuf[0]) {
+ errs++;
+ fprintf(stderr, "double AND(1) test failed\n");
+ }
+ if (doutbuf[1]) {
+ errs++;
+ fprintf(stderr, "double AND(0) test failed\n");
+ }
+ if (doutbuf[2] && size > 1) {
+ errs++;
+ fprintf(stderr, "double AND(>) test failed\n");
+ }
+ }
}
#ifdef HAVE_LONG_DOUBLE
- { long double ldinbuf[3], ldoutbuf[3];
- /* long double */
- ldinbuf[0] = 1;
- ldinbuf[1] = 0;
- ldinbuf[2] = (rank > 0);
+ {
+ long double ldinbuf[3], ldoutbuf[3];
+ /* long double */
+ ldinbuf[0] = 1;
+ ldinbuf[1] = 0;
+ ldinbuf[2] = (rank > 0);
- ldoutbuf[0] = 0;
- ldoutbuf[1] = 1;
- ldoutbuf[2] = 1;
- if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
- MTestPrintfMsg( 10, "Reduce of MPI_LONG_DOUBLE\n" );
- rc = MPI_Reduce( ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_LAND, 0, comm );
- if (rc) {
- MTestPrintErrorMsg( "MPI_LAND and MPI_LONG_DOUBLE", rc );
- errs++;
- }
- else {
- if (rank == 0) {
- if (!ldoutbuf[0]) {
- errs++;
- fprintf( stderr, "long double AND(1) test failed\n" );
- }
- if (ldoutbuf[1]) {
- errs++;
- fprintf( stderr, "long double AND(0) test failed\n" );
- }
- if (ldoutbuf[2] && size > 1) {
- errs++;
- fprintf( stderr, "long double AND(>) test failed\n" );
- }
- }
- }
- }
+ ldoutbuf[0] = 0;
+ ldoutbuf[1] = 1;
+ ldoutbuf[2] = 1;
+ if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
+ MTestPrintfMsg(10, "Reduce of MPI_LONG_DOUBLE\n");
+ rc = MPI_Reduce(ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_LAND, 0, comm);
+ if (rc) {
+ MTestPrintErrorMsg("MPI_LAND and MPI_LONG_DOUBLE", rc);
+ errs++;
+ }
+ else {
+ if (rank == 0) {
+ if (!ldoutbuf[0]) {
+ errs++;
+ fprintf(stderr, "long double AND(1) test failed\n");
+ }
+ if (ldoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "long double AND(0) test failed\n");
+ }
+ if (ldoutbuf[2] && size > 1) {
+ errs++;
+ fprintf(stderr, "long double AND(>) test failed\n");
+ }
+ }
+ }
+ }
}
#endif /* HAVE_LONG_DOUBLE */
#endif /* USE_STRICT_MPI */
@@ -239,45 +240,44 @@ int main( int argc, char *argv[] )
#ifdef HAVE_LONG_LONG
{
- long long llinbuf[3], lloutbuf[3];
- /* long long */
- llinbuf[0] = 1;
- llinbuf[1] = 0;
- llinbuf[2] = (rank > 0);
+ long long llinbuf[3], lloutbuf[3];
+ /* long long */
+ llinbuf[0] = 1;
+ llinbuf[1] = 0;
+ llinbuf[2] = (rank > 0);
- lloutbuf[0] = 0;
- lloutbuf[1] = 1;
- lloutbuf[2] = 1;
- if (MPI_LONG_LONG != MPI_DATATYPE_NULL) {
- MTestPrintfMsg( 10, "Reduce of MPI_LONG_LONG\n" );
- rc = MPI_Reduce( llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_LAND, 0, comm );
- if (rc) {
- MTestPrintErrorMsg( "MPI_LAND and MPI_LONG_LONG", rc );
- errs++;
- }
- else {
- if (rank == 0) {
- if (!lloutbuf[0]) {
- errs++;
- fprintf( stderr, "long long AND(1) test failed\n" );
- }
- if (lloutbuf[1]) {
- errs++;
- fprintf( stderr, "long long AND(0) test failed\n" );
- }
- if (lloutbuf[2] && size > 1) {
- errs++;
- fprintf( stderr, "long long AND(>) test failed\n" );
- }
- }
- }
- }
+ lloutbuf[0] = 0;
+ lloutbuf[1] = 1;
+ lloutbuf[2] = 1;
+ if (MPI_LONG_LONG != MPI_DATATYPE_NULL) {
+ MTestPrintfMsg(10, "Reduce of MPI_LONG_LONG\n");
+ rc = MPI_Reduce(llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_LAND, 0, comm);
+ if (rc) {
+ MTestPrintErrorMsg("MPI_LAND and MPI_LONG_LONG", rc);
+ errs++;
+ }
+ else {
+ if (rank == 0) {
+ if (!lloutbuf[0]) {
+ errs++;
+ fprintf(stderr, "long long AND(1) test failed\n");
+ }
+ if (lloutbuf[1]) {
+ errs++;
+ fprintf(stderr, "long long AND(0) test failed\n");
+ }
+ if (lloutbuf[2] && size > 1) {
+ errs++;
+ fprintf(stderr, "long long AND(>) test failed\n");
+ }
+ }
+ }
+ }
}
#endif
- MPI_Errhandler_set( comm, MPI_ERRORS_ARE_FATAL );
- MTest_Finalize( errs );
+ MPI_Errhandler_set(comm, MPI_ERRORS_ARE_FATAL);
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
-
diff --git a/test/mpi/coll/oplor.c b/test/mpi/coll/oplor.c
index a168d35..c53c5c6 100644
--- a/test/mpi/coll/oplor.c
+++ b/test/mpi/coll/oplor.c
@@ -14,38 +14,38 @@ static char MTEST_Descrip[] = "Test MPI_LOR operations on optional datatypes dup
*/
/*
- * This test looks at the handling of logical and for types that are not
+ * This test looks at the handling of logical and for types that are not
* integers or are not required integers (e.g., long long). MPICH allows
* these as well. A strict MPI test should not include this test.
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int rank, size;
- MPI_Comm comm;
+ MPI_Comm comm;
char cinbuf[3], coutbuf[3];
signed char scinbuf[3], scoutbuf[3];
unsigned char ucinbuf[3], ucoutbuf[3];
float finbuf[3], foutbuf[3];
double dinbuf[3], doutbuf[3];
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
/* Some MPI implementations do not implement all of the required
- (datatype,operations) combinations, and further, they do not
- always provide clear and specific error messages. By catching
- the error, we can provide a higher quality, more specific message.
- */
- MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN );
+ * (datatype,operations) combinations, and further, they do not
+ * always provide clear and specific error messages. By catching
+ * the error, we can provide a higher quality, more specific message.
+ */
+ MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN);
#ifndef USE_STRICT_MPI
/* char */
- MTestPrintfMsg( 10, "Reduce of MPI_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_CHAR\n");
cinbuf[0] = 1;
cinbuf[1] = 0;
cinbuf[2] = (rank > 0);
@@ -53,31 +53,31 @@ int main( int argc, char *argv[] )
coutbuf[0] = 0;
coutbuf[1] = 1;
coutbuf[2] = 1;
- err = MPI_Reduce( cinbuf, coutbuf, 3, MPI_CHAR, MPI_LOR, 0, comm );
+ err = MPI_Reduce(cinbuf, coutbuf, 3, MPI_CHAR, MPI_LOR, 0, comm);
if (err) {
- errs++;
- MTestPrintErrorMsg( "MPI_LOR and MPI_CHAR", err );
+ errs++;
+ MTestPrintErrorMsg("MPI_LOR and MPI_CHAR", err);
}
else {
- if (rank == 0) {
- if (!coutbuf[0]) {
- errs++;
- fprintf( stderr, "char OR(1) test failed\n" );
- }
- if (coutbuf[1]) {
- errs++;
- fprintf( stderr, "char OR(0) test failed\n" );
- }
- if (!coutbuf[2] && size > 1) {
- errs++;
- fprintf( stderr, "char OR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (!coutbuf[0]) {
+ errs++;
+ fprintf(stderr, "char OR(1) test failed\n");
+ }
+ if (coutbuf[1]) {
+ errs++;
+ fprintf(stderr, "char OR(0) test failed\n");
+ }
+ if (!coutbuf[2] && size > 1) {
+ errs++;
+ fprintf(stderr, "char OR(>) test failed\n");
+ }
+ }
}
#endif /* USE_STRICT_MPI */
/* signed char */
- MTestPrintfMsg( 10, "Reduce of MPI_SIGNED_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_SIGNED_CHAR\n");
scinbuf[0] = 1;
scinbuf[1] = 0;
scinbuf[2] = (rank > 0);
@@ -85,30 +85,30 @@ int main( int argc, char *argv[] )
scoutbuf[0] = 0;
scoutbuf[1] = 1;
scoutbuf[2] = 1;
- err = MPI_Reduce( scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_LOR, 0, comm );
+ err = MPI_Reduce(scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_LOR, 0, comm);
if (err) {
- errs++;
- MTestPrintErrorMsg( "MPI_LOR and MPI_SIGNED_CHAR", err );
+ errs++;
+ MTestPrintErrorMsg("MPI_LOR and MPI_SIGNED_CHAR", err);
}
else {
- if (rank == 0) {
- if (!scoutbuf[0]) {
- errs++;
- fprintf( stderr, "signed char OR(1) test failed\n" );
- }
- if (scoutbuf[1]) {
- errs++;
- fprintf( stderr, "signed char OR(0) test failed\n" );
- }
- if (!scoutbuf[2] && size > 1) {
- errs++;
- fprintf( stderr, "signed char OR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (!scoutbuf[0]) {
+ errs++;
+ fprintf(stderr, "signed char OR(1) test failed\n");
+ }
+ if (scoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "signed char OR(0) test failed\n");
+ }
+ if (!scoutbuf[2] && size > 1) {
+ errs++;
+ fprintf(stderr, "signed char OR(>) test failed\n");
+ }
+ }
}
/* unsigned char */
- MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_CHAR\n");
ucinbuf[0] = 1;
ucinbuf[1] = 0;
ucinbuf[2] = (rank > 0);
@@ -116,31 +116,31 @@ int main( int argc, char *argv[] )
ucoutbuf[0] = 0;
ucoutbuf[1] = 1;
ucoutbuf[2] = 1;
- err = MPI_Reduce( ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_LOR, 0, comm );
+ err = MPI_Reduce(ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_LOR, 0, comm);
if (err) {
- errs++;
- MTestPrintErrorMsg( "MPI_LOR and MPI_UNSIGNED_CHAR", err );
+ errs++;
+ MTestPrintErrorMsg("MPI_LOR and MPI_UNSIGNED_CHAR", err);
}
else {
- if (rank == 0) {
- if (!ucoutbuf[0]) {
- errs++;
- fprintf( stderr, "unsigned char OR(1) test failed\n" );
- }
- if (ucoutbuf[1]) {
- errs++;
- fprintf( stderr, "unsigned char OR(0) test failed\n" );
- }
- if (!ucoutbuf[2] && size > 1) {
- errs++;
- fprintf( stderr, "unsigned char OR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (!ucoutbuf[0]) {
+ errs++;
+ fprintf(stderr, "unsigned char OR(1) test failed\n");
+ }
+ if (ucoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "unsigned char OR(0) test failed\n");
+ }
+ if (!ucoutbuf[2] && size > 1) {
+ errs++;
+ fprintf(stderr, "unsigned char OR(>) test failed\n");
+ }
+ }
}
#ifndef USE_STRICT_MPI
/* float */
- MTestPrintfMsg( 10, "Reduce of MPI_FLOAT\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_FLOAT\n");
finbuf[0] = 1;
finbuf[1] = 0;
finbuf[2] = (rank > 0);
@@ -148,30 +148,30 @@ int main( int argc, char *argv[] )
foutbuf[0] = 0;
foutbuf[1] = 1;
foutbuf[2] = 1;
- err = MPI_Reduce( finbuf, foutbuf, 3, MPI_FLOAT, MPI_LOR, 0, comm );
+ err = MPI_Reduce(finbuf, foutbuf, 3, MPI_FLOAT, MPI_LOR, 0, comm);
if (err) {
- errs++;
- MTestPrintErrorMsg( "MPI_LOR and MPI_FLOAT", err );
+ errs++;
+ MTestPrintErrorMsg("MPI_LOR and MPI_FLOAT", err);
}
else {
- if (rank == 0) {
- if (!foutbuf[0]) {
- errs++;
- fprintf( stderr, "float OR(1) test failed\n" );
- }
- if (foutbuf[1]) {
- errs++;
- fprintf( stderr, "float OR(0) test failed\n" );
- }
- if (!foutbuf[2] && size > 1) {
- errs++;
- fprintf( stderr, "float OR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (!foutbuf[0]) {
+ errs++;
+ fprintf(stderr, "float OR(1) test failed\n");
+ }
+ if (foutbuf[1]) {
+ errs++;
+ fprintf(stderr, "float OR(0) test failed\n");
+ }
+ if (!foutbuf[2] && size > 1) {
+ errs++;
+ fprintf(stderr, "float OR(>) test failed\n");
+ }
+ }
}
/* double */
- MTestPrintfMsg( 10, "Reduce of MPI_DOUBLE\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_DOUBLE\n");
dinbuf[0] = 1;
dinbuf[1] = 0;
dinbuf[2] = (rank > 0);
@@ -179,106 +179,107 @@ int main( int argc, char *argv[] )
doutbuf[0] = 0;
doutbuf[1] = 1;
doutbuf[2] = 1;
- err = MPI_Reduce( dinbuf, doutbuf, 3, MPI_DOUBLE, MPI_LOR, 0, comm );
+ err = MPI_Reduce(dinbuf, doutbuf, 3, MPI_DOUBLE, MPI_LOR, 0, comm);
if (err) {
- errs++;
- MTestPrintErrorMsg( "MPI_LOR and MPI_DOUBLE", err );
+ errs++;
+ MTestPrintErrorMsg("MPI_LOR and MPI_DOUBLE", err);
}
else {
- if (rank == 0) {
- if (!doutbuf[0]) {
- errs++;
- fprintf( stderr, "double OR(1) test failed\n" );
- }
- if (doutbuf[1]) {
- errs++;
- fprintf( stderr, "double OR(0) test failed\n" );
- }
- if (!doutbuf[2] && size > 1) {
- errs++;
- fprintf( stderr, "double OR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (!doutbuf[0]) {
+ errs++;
+ fprintf(stderr, "double OR(1) test failed\n");
+ }
+ if (doutbuf[1]) {
+ errs++;
+ fprintf(stderr, "double OR(0) test failed\n");
+ }
+ if (!doutbuf[2] && size > 1) {
+ errs++;
+ fprintf(stderr, "double OR(>) test failed\n");
+ }
+ }
}
#ifdef HAVE_LONG_DOUBLE
- { long double ldinbuf[3], ldoutbuf[3];
- /* long double */
- ldinbuf[0] = 1;
- ldinbuf[1] = 0;
- ldinbuf[2] = (rank > 0);
+ {
+ long double ldinbuf[3], ldoutbuf[3];
+ /* long double */
+ ldinbuf[0] = 1;
+ ldinbuf[1] = 0;
+ ldinbuf[2] = (rank > 0);
- ldoutbuf[0] = 0;
- ldoutbuf[1] = 1;
- ldoutbuf[2] = 1;
- if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
- MTestPrintfMsg( 10, "Reduce of MPI_LONG_DOUBLE\n" );
- err = MPI_Reduce( ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_LOR, 0, comm );
- if (err) {
- errs++;
- MTestPrintErrorMsg( "MPI_LOR and MPI_LONG_DOUBLE", err );
- }
- else {
- if (rank == 0) {
- if (!ldoutbuf[0]) {
- errs++;
- fprintf( stderr, "long double OR(1) test failed\n" );
- }
- if (ldoutbuf[1]) {
- errs++;
- fprintf( stderr, "long double OR(0) test failed\n" );
- }
- if (!ldoutbuf[2] && size > 1) {
- errs++;
- fprintf( stderr, "long double OR(>) test failed\n" );
- }
- }
- }
- }
+ ldoutbuf[0] = 0;
+ ldoutbuf[1] = 1;
+ ldoutbuf[2] = 1;
+ if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
+ MTestPrintfMsg(10, "Reduce of MPI_LONG_DOUBLE\n");
+ err = MPI_Reduce(ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_LOR, 0, comm);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("MPI_LOR and MPI_LONG_DOUBLE", err);
+ }
+ else {
+ if (rank == 0) {
+ if (!ldoutbuf[0]) {
+ errs++;
+ fprintf(stderr, "long double OR(1) test failed\n");
+ }
+ if (ldoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "long double OR(0) test failed\n");
+ }
+ if (!ldoutbuf[2] && size > 1) {
+ errs++;
+ fprintf(stderr, "long double OR(>) test failed\n");
+ }
+ }
+ }
+ }
}
#endif /* HAVE_LONG_DOUBLE */
#endif /* USE_STRICT_MPI */
#ifdef HAVE_LONG_LONG
{
- long long llinbuf[3], lloutbuf[3];
- /* long long */
- llinbuf[0] = 1;
- llinbuf[1] = 0;
- llinbuf[2] = (rank > 0);
+ long long llinbuf[3], lloutbuf[3];
+ /* long long */
+ llinbuf[0] = 1;
+ llinbuf[1] = 0;
+ llinbuf[2] = (rank > 0);
- lloutbuf[0] = 0;
- lloutbuf[1] = 1;
- lloutbuf[2] = 1;
- if (MPI_LONG_LONG != MPI_DATATYPE_NULL) {
- MTestPrintfMsg( 10, "Reduce of MPI_LONG_LONG\n" );
- err = MPI_Reduce( llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_LOR, 0, comm );
- if (err) {
- errs++;
- MTestPrintErrorMsg( "MPI_LOR and MPI_LONG_LONG", err );
- }
- else {
- if (rank == 0) {
- if (!lloutbuf[0]) {
- errs++;
- fprintf( stderr, "long long OR(1) test failed\n" );
- }
- if (lloutbuf[1]) {
- errs++;
- fprintf( stderr, "long long OR(0) test failed\n" );
- }
- if (!lloutbuf[2] && size > 1) {
- errs++;
- fprintf( stderr, "long long OR(>) test failed\n" );
- }
- }
- }
- }
+ lloutbuf[0] = 0;
+ lloutbuf[1] = 1;
+ lloutbuf[2] = 1;
+ if (MPI_LONG_LONG != MPI_DATATYPE_NULL) {
+ MTestPrintfMsg(10, "Reduce of MPI_LONG_LONG\n");
+ err = MPI_Reduce(llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_LOR, 0, comm);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("MPI_LOR and MPI_LONG_LONG", err);
+ }
+ else {
+ if (rank == 0) {
+ if (!lloutbuf[0]) {
+ errs++;
+ fprintf(stderr, "long long OR(1) test failed\n");
+ }
+ if (lloutbuf[1]) {
+ errs++;
+ fprintf(stderr, "long long OR(0) test failed\n");
+ }
+ if (!lloutbuf[2] && size > 1) {
+ errs++;
+ fprintf(stderr, "long long OR(>) test failed\n");
+ }
+ }
+ }
+ }
}
#endif
- MPI_Errhandler_set( comm, MPI_ERRORS_ARE_FATAL );
- MTest_Finalize( errs );
+ MPI_Errhandler_set(comm, MPI_ERRORS_ARE_FATAL);
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/oplxor.c b/test/mpi/coll/oplxor.c
index e55970d..03de2c4 100644
--- a/test/mpi/coll/oplxor.c
+++ b/test/mpi/coll/oplxor.c
@@ -14,35 +14,35 @@ static char MTEST_Descrip[] = "Test MPI_LXOR operations on optional datatypes du
*/
/*
- * This test looks at the handling of logical and for types that are not
+ * This test looks at the handling of logical and for types that are not
* integers or are not required integers (e.g., long long). MPICH allows
* these as well. A strict MPI test should not include this test.
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rc;
int rank, size;
- MPI_Comm comm;
+ MPI_Comm comm;
char cinbuf[3], coutbuf[3];
signed char scinbuf[3], scoutbuf[3];
unsigned char ucinbuf[3], ucoutbuf[3];
float finbuf[3], foutbuf[3];
double dinbuf[3], doutbuf[3];
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- /* Set errors return so that we can provide better information
- should a routine reject one of the operand/datatype pairs */
- MPI_Errhandler_set( comm, MPI_ERRORS_RETURN );
+ /* Set errors return so that we can provide better information
+ * should a routine reject one of the operand/datatype pairs */
+ MPI_Errhandler_set(comm, MPI_ERRORS_RETURN);
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
#ifndef USE_STRICT_MPI
/* char */
- MTestPrintfMsg( 10, "Reduce of MPI_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_CHAR\n");
cinbuf[0] = 1;
cinbuf[1] = 0;
cinbuf[2] = (rank > 0);
@@ -50,31 +50,31 @@ int main( int argc, char *argv[] )
coutbuf[0] = 0;
coutbuf[1] = 1;
coutbuf[2] = 1;
- rc = MPI_Reduce( cinbuf, coutbuf, 3, MPI_CHAR, MPI_LXOR, 0, comm );
+ rc = MPI_Reduce(cinbuf, coutbuf, 3, MPI_CHAR, MPI_LXOR, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_LXOR and MPI_CHAR", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_LXOR and MPI_CHAR", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (coutbuf[0] != (size % 2)) {
- errs++;
- fprintf( stderr, "char XOR(1) test failed\n" );
- }
- if (coutbuf[1]) {
- errs++;
- fprintf( stderr, "char XOR(0) test failed\n" );
- }
- if (coutbuf[2] == (size % 2) && size > 1) {
- errs++;
- fprintf( stderr, "char XOR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (coutbuf[0] != (size % 2)) {
+ errs++;
+ fprintf(stderr, "char XOR(1) test failed\n");
+ }
+ if (coutbuf[1]) {
+ errs++;
+ fprintf(stderr, "char XOR(0) test failed\n");
+ }
+ if (coutbuf[2] == (size % 2) && size > 1) {
+ errs++;
+ fprintf(stderr, "char XOR(>) test failed\n");
+ }
+ }
}
#endif /* USE_STRICT_MPI */
/* signed char */
- MTestPrintfMsg( 10, "Reduce of MPI_SIGNED_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_SIGNED_CHAR\n");
scinbuf[0] = 1;
scinbuf[1] = 0;
scinbuf[2] = (rank > 0);
@@ -82,30 +82,30 @@ int main( int argc, char *argv[] )
scoutbuf[0] = 0;
scoutbuf[1] = 1;
scoutbuf[2] = 1;
- rc = MPI_Reduce( scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_LXOR, 0, comm );
+ rc = MPI_Reduce(scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_LXOR, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_LXOR and MPI_SIGNED_CHAR", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_LXOR and MPI_SIGNED_CHAR", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (scoutbuf[0] != (size % 2)) {
- errs++;
- fprintf( stderr, "signed char XOR(1) test failed\n" );
- }
- if (scoutbuf[1]) {
- errs++;
- fprintf( stderr, "signed char XOR(0) test failed\n" );
- }
- if (scoutbuf[2] == (size % 2) && size > 1) {
- errs++;
- fprintf( stderr, "signed char XOR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (scoutbuf[0] != (size % 2)) {
+ errs++;
+ fprintf(stderr, "signed char XOR(1) test failed\n");
+ }
+ if (scoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "signed char XOR(0) test failed\n");
+ }
+ if (scoutbuf[2] == (size % 2) && size > 1) {
+ errs++;
+ fprintf(stderr, "signed char XOR(>) test failed\n");
+ }
+ }
}
/* unsigned char */
- MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_CHAR\n");
ucinbuf[0] = 1;
ucinbuf[1] = 0;
ucinbuf[2] = (rank > 0);
@@ -113,31 +113,31 @@ int main( int argc, char *argv[] )
ucoutbuf[0] = 0;
ucoutbuf[1] = 1;
ucoutbuf[2] = 1;
- rc = MPI_Reduce( ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_LXOR, 0, comm );
+ rc = MPI_Reduce(ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_LXOR, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_LXOR and MPI_UNSIGNED_CHAR", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_LXOR and MPI_UNSIGNED_CHAR", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (ucoutbuf[0] != (size % 2)) {
- errs++;
- fprintf( stderr, "unsigned char XOR(1) test failed\n" );
- }
- if (ucoutbuf[1]) {
- errs++;
- fprintf( stderr, "unsigned char XOR(0) test failed\n" );
- }
- if (ucoutbuf[2] == (size % 2) && size > 1) {
- errs++;
- fprintf( stderr, "unsigned char XOR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (ucoutbuf[0] != (size % 2)) {
+ errs++;
+ fprintf(stderr, "unsigned char XOR(1) test failed\n");
+ }
+ if (ucoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "unsigned char XOR(0) test failed\n");
+ }
+ if (ucoutbuf[2] == (size % 2) && size > 1) {
+ errs++;
+ fprintf(stderr, "unsigned char XOR(>) test failed\n");
+ }
+ }
}
#ifndef USE_STRICT_MPI
/* float */
- MTestPrintfMsg( 10, "Reduce of MPI_FLOAT\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_FLOAT\n");
finbuf[0] = 1;
finbuf[1] = 0;
finbuf[2] = (rank > 0);
@@ -145,30 +145,30 @@ int main( int argc, char *argv[] )
foutbuf[0] = 0;
foutbuf[1] = 1;
foutbuf[2] = 1;
- rc = MPI_Reduce( finbuf, foutbuf, 3, MPI_FLOAT, MPI_LXOR, 0, comm );
+ rc = MPI_Reduce(finbuf, foutbuf, 3, MPI_FLOAT, MPI_LXOR, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_LXOR and MPI_FLOAT", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_LXOR and MPI_FLOAT", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (foutbuf[0] != (size % 2)) {
- errs++;
- fprintf( stderr, "float XOR(1) test failed\n" );
- }
- if (foutbuf[1]) {
- errs++;
- fprintf( stderr, "float XOR(0) test failed\n" );
- }
- if (foutbuf[2] == (size % 2) && size > 1) {
- errs++;
- fprintf( stderr, "float XOR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (foutbuf[0] != (size % 2)) {
+ errs++;
+ fprintf(stderr, "float XOR(1) test failed\n");
+ }
+ if (foutbuf[1]) {
+ errs++;
+ fprintf(stderr, "float XOR(0) test failed\n");
+ }
+ if (foutbuf[2] == (size % 2) && size > 1) {
+ errs++;
+ fprintf(stderr, "float XOR(>) test failed\n");
+ }
+ }
}
/* double */
- MTestPrintfMsg( 10, "Reduce of MPI_DOUBLE\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_DOUBLE\n");
dinbuf[0] = 1;
dinbuf[1] = 0;
dinbuf[2] = (rank > 0);
@@ -176,106 +176,107 @@ int main( int argc, char *argv[] )
doutbuf[0] = 0;
doutbuf[1] = 1;
doutbuf[2] = 1;
- rc = MPI_Reduce( dinbuf, doutbuf, 3, MPI_DOUBLE, MPI_LXOR, 0, comm );
+ rc = MPI_Reduce(dinbuf, doutbuf, 3, MPI_DOUBLE, MPI_LXOR, 0, comm);
if (rc) {
- MTestPrintErrorMsg( "MPI_LXOR and MPI_DOUBLE", rc );
- errs++;
+ MTestPrintErrorMsg("MPI_LXOR and MPI_DOUBLE", rc);
+ errs++;
}
else {
- if (rank == 0) {
- if (doutbuf[0] != (size % 2)) {
- errs++;
- fprintf( stderr, "double XOR(1) test failed\n" );
- }
- if (doutbuf[1]) {
- errs++;
- fprintf( stderr, "double XOR(0) test failed\n" );
- }
- if (doutbuf[2] == (size % 2) && size > 1) {
- errs++;
- fprintf( stderr, "double XOR(>) test failed\n" );
- }
- }
+ if (rank == 0) {
+ if (doutbuf[0] != (size % 2)) {
+ errs++;
+ fprintf(stderr, "double XOR(1) test failed\n");
+ }
+ if (doutbuf[1]) {
+ errs++;
+ fprintf(stderr, "double XOR(0) test failed\n");
+ }
+ if (doutbuf[2] == (size % 2) && size > 1) {
+ errs++;
+ fprintf(stderr, "double XOR(>) test failed\n");
+ }
+ }
}
#ifdef HAVE_LONG_DOUBLE
- { long double ldinbuf[3], ldoutbuf[3];
- /* long double */
- ldinbuf[0] = 1;
- ldinbuf[1] = 0;
- ldinbuf[2] = (rank > 0);
+ {
+ long double ldinbuf[3], ldoutbuf[3];
+ /* long double */
+ ldinbuf[0] = 1;
+ ldinbuf[1] = 0;
+ ldinbuf[2] = (rank > 0);
- ldoutbuf[0] = 0;
- ldoutbuf[1] = 1;
- ldoutbuf[2] = 1;
- if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
- MTestPrintfMsg( 10, "Reduce of MPI_LONG_DOUBLE\n" );
- rc = MPI_Reduce( ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_LXOR, 0, comm );
- if (rc) {
- MTestPrintErrorMsg( "MPI_LXOR and MPI_LONG_DOUBLE", rc );
- errs++;
- }
- else {
- if (rank == 0) {
- if (ldoutbuf[0] != (size % 2)) {
- errs++;
- fprintf( stderr, "long double XOR(1) test failed\n" );
- }
- if (ldoutbuf[1]) {
- errs++;
- fprintf( stderr, "long double XOR(0) test failed\n" );
- }
- if (ldoutbuf[2] == (size % 2) && size > 1) {
- errs++;
- fprintf( stderr, "long double XOR(>) test failed\n" );
- }
- }
- }
- }
+ ldoutbuf[0] = 0;
+ ldoutbuf[1] = 1;
+ ldoutbuf[2] = 1;
+ if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
+ MTestPrintfMsg(10, "Reduce of MPI_LONG_DOUBLE\n");
+ rc = MPI_Reduce(ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_LXOR, 0, comm);
+ if (rc) {
+ MTestPrintErrorMsg("MPI_LXOR and MPI_LONG_DOUBLE", rc);
+ errs++;
+ }
+ else {
+ if (rank == 0) {
+ if (ldoutbuf[0] != (size % 2)) {
+ errs++;
+ fprintf(stderr, "long double XOR(1) test failed\n");
+ }
+ if (ldoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "long double XOR(0) test failed\n");
+ }
+ if (ldoutbuf[2] == (size % 2) && size > 1) {
+ errs++;
+ fprintf(stderr, "long double XOR(>) test failed\n");
+ }
+ }
+ }
+ }
}
#endif /* HAVE_LONG_DOUBLE */
#endif /* USE_STRICT_MPI */
#ifdef HAVE_LONG_LONG
{
- long long llinbuf[3], lloutbuf[3];
- /* long long */
- llinbuf[0] = 1;
- llinbuf[1] = 0;
- llinbuf[2] = (rank > 0);
+ long long llinbuf[3], lloutbuf[3];
+ /* long long */
+ llinbuf[0] = 1;
+ llinbuf[1] = 0;
+ llinbuf[2] = (rank > 0);
- lloutbuf[0] = 0;
- lloutbuf[1] = 1;
- lloutbuf[2] = 1;
- if (MPI_LONG_LONG != MPI_DATATYPE_NULL) {
- MTestPrintfMsg( 10, "Reduce of MPI_LONG_LONG\n" );
- rc = MPI_Reduce( llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_LXOR, 0, comm );
- if (rc) {
- MTestPrintErrorMsg( "MPI_LXOR and MPI_LONG_LONG", rc );
- errs++;
- }
- else {
- if (rank == 0) {
- if (lloutbuf[0] != (size % 2)) {
- errs++;
- fprintf( stderr, "long long XOR(1) test failed\n" );
- }
- if (lloutbuf[1]) {
- errs++;
- fprintf( stderr, "long long XOR(0) test failed\n" );
- }
- if (lloutbuf[2] == (size % 2) && size > 1) {
- errs++;
- fprintf( stderr, "long long XOR(>) test failed\n" );
- }
- }
- }
- }
+ lloutbuf[0] = 0;
+ lloutbuf[1] = 1;
+ lloutbuf[2] = 1;
+ if (MPI_LONG_LONG != MPI_DATATYPE_NULL) {
+ MTestPrintfMsg(10, "Reduce of MPI_LONG_LONG\n");
+ rc = MPI_Reduce(llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_LXOR, 0, comm);
+ if (rc) {
+ MTestPrintErrorMsg("MPI_LXOR and MPI_LONG_LONG", rc);
+ errs++;
+ }
+ else {
+ if (rank == 0) {
+ if (lloutbuf[0] != (size % 2)) {
+ errs++;
+ fprintf(stderr, "long long XOR(1) test failed\n");
+ }
+ if (lloutbuf[1]) {
+ errs++;
+ fprintf(stderr, "long long XOR(0) test failed\n");
+ }
+ if (lloutbuf[2] == (size % 2) && size > 1) {
+ errs++;
+ fprintf(stderr, "long long XOR(>) test failed\n");
+ }
+ }
+ }
+ }
}
#endif
- MPI_Errhandler_set( comm, MPI_ERRORS_ARE_FATAL );
- MTest_Finalize( errs );
+ MPI_Errhandler_set(comm, MPI_ERRORS_ARE_FATAL);
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/opmax.c b/test/mpi/coll/opmax.c
index 1c9c1ff..0a52ed3 100644
--- a/test/mpi/coll/opmax.c
+++ b/test/mpi/coll/opmax.c
@@ -14,29 +14,29 @@ static char MTEST_Descrip[] = "Test MPI_MAX operations on optional datatypes dup
*/
/*
- * This test looks at the handling of char and types that are not required
+ * This test looks at the handling of char and types that are not required
* integers (e.g., long long). MPICH allows
* these as well. A strict MPI test should not include this test.
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size;
- MPI_Comm comm;
+ MPI_Comm comm;
char cinbuf[3], coutbuf[3];
signed char scinbuf[3], scoutbuf[3];
unsigned char ucinbuf[3], ucoutbuf[3];
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
#ifndef USE_STRICT_MPI
/* char */
- MTestPrintfMsg( 10, "Reduce of MPI_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_CHAR\n");
cinbuf[0] = 1;
cinbuf[1] = 0;
cinbuf[2] = rank;
@@ -44,25 +44,25 @@ int main( int argc, char *argv[] )
coutbuf[0] = 0;
coutbuf[1] = 1;
coutbuf[2] = 1;
- MPI_Reduce( cinbuf, coutbuf, 3, MPI_CHAR, MPI_MAX, 0, comm );
+ MPI_Reduce(cinbuf, coutbuf, 3, MPI_CHAR, MPI_MAX, 0, comm);
if (rank == 0) {
- if (coutbuf[0] != 1) {
- errs++;
- fprintf( stderr, "char MAX(1) test failed\n" );
- }
- if (coutbuf[1] != 0) {
- errs++;
- fprintf( stderr, "char MAX(0) test failed\n" );
- }
- if (size < 128 && coutbuf[2] != size - 1) {
- errs++;
- fprintf( stderr, "char MAX(>) test failed\n" );
- }
+ if (coutbuf[0] != 1) {
+ errs++;
+ fprintf(stderr, "char MAX(1) test failed\n");
+ }
+ if (coutbuf[1] != 0) {
+ errs++;
+ fprintf(stderr, "char MAX(0) test failed\n");
+ }
+ if (size < 128 && coutbuf[2] != size - 1) {
+ errs++;
+ fprintf(stderr, "char MAX(>) test failed\n");
+ }
}
#endif /* USE_STRICT_MPI */
/* signed char */
- MTestPrintfMsg( 10, "Reduce of MPI_SIGNED_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_SIGNED_CHAR\n");
scinbuf[0] = 1;
scinbuf[1] = 0;
scinbuf[2] = rank;
@@ -70,24 +70,24 @@ int main( int argc, char *argv[] )
scoutbuf[0] = 0;
scoutbuf[1] = 1;
scoutbuf[2] = 1;
- MPI_Reduce( scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_MAX, 0, comm );
+ MPI_Reduce(scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_MAX, 0, comm);
if (rank == 0) {
- if (scoutbuf[0] != 1) {
- errs++;
- fprintf( stderr, "signed char MAX(1) test failed\n" );
- }
- if (scoutbuf[1] != 0) {
- errs++;
- fprintf( stderr, "signed char MAX(0) test failed\n" );
- }
- if (size < 128 && scoutbuf[2] != size - 1) {
- errs++;
- fprintf( stderr, "signed char MAX(>) test failed\n" );
- }
+ if (scoutbuf[0] != 1) {
+ errs++;
+ fprintf(stderr, "signed char MAX(1) test failed\n");
+ }
+ if (scoutbuf[1] != 0) {
+ errs++;
+ fprintf(stderr, "signed char MAX(0) test failed\n");
+ }
+ if (size < 128 && scoutbuf[2] != size - 1) {
+ errs++;
+ fprintf(stderr, "signed char MAX(>) test failed\n");
+ }
}
/* unsigned char */
- MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_CHAR\n");
ucinbuf[0] = 1;
ucinbuf[1] = 0;
ucinbuf[2] = rank;
@@ -95,86 +95,87 @@ int main( int argc, char *argv[] )
ucoutbuf[0] = 0;
ucoutbuf[1] = 1;
ucoutbuf[2] = 1;
- MPI_Reduce( ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_MAX, 0, comm );
+ MPI_Reduce(ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_MAX, 0, comm);
if (rank == 0) {
- if (ucoutbuf[0] != 1) {
- errs++;
- fprintf( stderr, "unsigned char MAX(1) test failed\n" );
- }
- if (ucoutbuf[1]) {
- errs++;
- fprintf( stderr, "unsigned char MAX(0) test failed\n" );
- }
- if (size < 256 && ucoutbuf[2] != size - 1) {
- errs++;
- fprintf( stderr, "unsigned char MAX(>) test failed\n" );
- }
+ if (ucoutbuf[0] != 1) {
+ errs++;
+ fprintf(stderr, "unsigned char MAX(1) test failed\n");
+ }
+ if (ucoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "unsigned char MAX(0) test failed\n");
+ }
+ if (size < 256 && ucoutbuf[2] != size - 1) {
+ errs++;
+ fprintf(stderr, "unsigned char MAX(>) test failed\n");
+ }
}
#ifdef HAVE_LONG_DOUBLE
- { long double ldinbuf[3], ldoutbuf[3];
- /* long double */
- ldinbuf[0] = 1;
- ldinbuf[1] = 0;
- ldinbuf[2] = rank;
-
- ldoutbuf[0] = 0;
- ldoutbuf[1] = 1;
- ldoutbuf[2] = 1;
- if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
- MTestPrintfMsg( 10, "Reduce of MPI_LONG_DOUBLE\n" );
- MPI_Reduce( ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_MAX, 0, comm );
- if (rank == 0) {
- if (ldoutbuf[0] != 1) {
- errs++;
- fprintf( stderr, "long double MAX(1) test failed\n" );
- }
- if (ldoutbuf[1] != 0.0) {
- errs++;
- fprintf( stderr, "long double MAX(0) test failed\n" );
- }
- if (ldoutbuf[2] != size - 1) {
- errs++;
- fprintf( stderr, "long double MAX(>) test failed\n" );
- }
- }
- }
+ {
+ long double ldinbuf[3], ldoutbuf[3];
+ /* long double */
+ ldinbuf[0] = 1;
+ ldinbuf[1] = 0;
+ ldinbuf[2] = rank;
+
+ ldoutbuf[0] = 0;
+ ldoutbuf[1] = 1;
+ ldoutbuf[2] = 1;
+ if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
+ MTestPrintfMsg(10, "Reduce of MPI_LONG_DOUBLE\n");
+ MPI_Reduce(ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_MAX, 0, comm);
+ if (rank == 0) {
+ if (ldoutbuf[0] != 1) {
+ errs++;
+ fprintf(stderr, "long double MAX(1) test failed\n");
+ }
+ if (ldoutbuf[1] != 0.0) {
+ errs++;
+ fprintf(stderr, "long double MAX(0) test failed\n");
+ }
+ if (ldoutbuf[2] != size - 1) {
+ errs++;
+ fprintf(stderr, "long double MAX(>) test failed\n");
+ }
+ }
+ }
}
#endif /* HAVE_LONG_DOUBLE */
#ifdef HAVE_LONG_LONG
{
- long long llinbuf[3], lloutbuf[3];
- /* long long */
- llinbuf[0] = 1;
- llinbuf[1] = 0;
- llinbuf[2] = rank;
-
- lloutbuf[0] = 0;
- lloutbuf[1] = 1;
- lloutbuf[2] = 1;
- if (MPI_LONG_LONG != MPI_DATATYPE_NULL) {
- MTestPrintfMsg( 10, "Reduce of MPI_LONG_LONG\n" );
- MPI_Reduce( llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_MAX, 0, comm );
- if (rank == 0) {
- if (lloutbuf[0] != 1) {
- errs++;
- fprintf( stderr, "long long MAX(1) test failed\n" );
- }
- if (lloutbuf[1] != 0) {
- errs++;
- fprintf( stderr, "long long MAX(0) test failed\n" );
- }
- if (lloutbuf[2] != size - 1) {
- errs++;
- fprintf( stderr, "long long MAX(>) test failed\n" );
- }
- }
- }
+ long long llinbuf[3], lloutbuf[3];
+ /* long long */
+ llinbuf[0] = 1;
+ llinbuf[1] = 0;
+ llinbuf[2] = rank;
+
+ lloutbuf[0] = 0;
+ lloutbuf[1] = 1;
+ lloutbuf[2] = 1;
+ if (MPI_LONG_LONG != MPI_DATATYPE_NULL) {
+ MTestPrintfMsg(10, "Reduce of MPI_LONG_LONG\n");
+ MPI_Reduce(llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_MAX, 0, comm);
+ if (rank == 0) {
+ if (lloutbuf[0] != 1) {
+ errs++;
+ fprintf(stderr, "long long MAX(1) test failed\n");
+ }
+ if (lloutbuf[1] != 0) {
+ errs++;
+ fprintf(stderr, "long long MAX(0) test failed\n");
+ }
+ if (lloutbuf[2] != size - 1) {
+ errs++;
+ fprintf(stderr, "long long MAX(>) test failed\n");
+ }
+ }
+ }
}
#endif /* HAVE_LONG_LONG */
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/opmaxloc.c b/test/mpi/coll/opmaxloc.c
index 0c64ee0..9a187b8 100644
--- a/test/mpi/coll/opmaxloc.c
+++ b/test/mpi/coll/opmaxloc.c
@@ -15,272 +15,315 @@ static char MTEST_Descrip[] = "Test MPI_MAXLOC operations on datatypes dupported
*/
/*
- * This test looks at the handling of char and types that are not required
+ * This test looks at the handling of char and types that are not required
* integers (e.g., long long). MPICH allows
* these as well. A strict MPI test should not include this test.
*
* The rule on max loc is that if there is a tie in the value, the minimum
* rank is used (see 4.9.3 in the MPI-1 standard)
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size;
- MPI_Comm comm;
+ MPI_Comm comm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
/* 2 int */
{
- struct twoint { int val; int loc; } cinbuf[3], coutbuf[3];
-
- cinbuf[0].val = 1;
- cinbuf[0].loc = rank;
- cinbuf[1].val = 0;
- cinbuf[1].loc = rank;
- cinbuf[2].val = rank;
- cinbuf[2].loc = rank;
-
- coutbuf[0].val = 0;
- coutbuf[0].loc = -1;
- coutbuf[1].val = 1;
- coutbuf[1].loc = -1;
- coutbuf[2].val = 1;
- coutbuf[2].loc = -1;
- MPI_Reduce( cinbuf, coutbuf, 3, MPI_2INT, MPI_MAXLOC, 0, comm );
- if (rank == 0) {
- if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) {
- errs++;
- fprintf( stderr, "2int MAXLOC(1) test failed\n" );
- }
- if (coutbuf[1].val != 0) {
- errs++;
- fprintf( stderr, "2int MAXLOC(0) test failed, value = %d, should be zero\n", coutbuf[1].val );
- }
- if (coutbuf[1].loc != 0) {
- errs++;
- fprintf( stderr, "2int MAXLOC(0) test failed, location of max = %d, should be zero\n", coutbuf[1].loc );
- }
- if (coutbuf[2].val != size-1 || coutbuf[2].loc != size-1) {
- errs++;
- fprintf( stderr, "2int MAXLOC(>) test failed\n" );
- }
- }
+ struct twoint {
+ int val;
+ int loc;
+ } cinbuf[3], coutbuf[3];
+
+ cinbuf[0].val = 1;
+ cinbuf[0].loc = rank;
+ cinbuf[1].val = 0;
+ cinbuf[1].loc = rank;
+ cinbuf[2].val = rank;
+ cinbuf[2].loc = rank;
+
+ coutbuf[0].val = 0;
+ coutbuf[0].loc = -1;
+ coutbuf[1].val = 1;
+ coutbuf[1].loc = -1;
+ coutbuf[2].val = 1;
+ coutbuf[2].loc = -1;
+ MPI_Reduce(cinbuf, coutbuf, 3, MPI_2INT, MPI_MAXLOC, 0, comm);
+ if (rank == 0) {
+ if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) {
+ errs++;
+ fprintf(stderr, "2int MAXLOC(1) test failed\n");
+ }
+ if (coutbuf[1].val != 0) {
+ errs++;
+ fprintf(stderr, "2int MAXLOC(0) test failed, value = %d, should be zero\n",
+ coutbuf[1].val);
+ }
+ if (coutbuf[1].loc != 0) {
+ errs++;
+ fprintf(stderr,
+ "2int MAXLOC(0) test failed, location of max = %d, should be zero\n",
+ coutbuf[1].loc);
+ }
+ if (coutbuf[2].val != size - 1 || coutbuf[2].loc != size - 1) {
+ errs++;
+ fprintf(stderr, "2int MAXLOC(>) test failed\n");
+ }
+ }
}
/* float int */
{
- struct floatint { float val; int loc; } cinbuf[3], coutbuf[3];
-
- cinbuf[0].val = 1;
- cinbuf[0].loc = rank;
- cinbuf[1].val = 0;
- cinbuf[1].loc = rank;
- cinbuf[2].val = (float)rank;
- cinbuf[2].loc = rank;
-
- coutbuf[0].val = 0;
- coutbuf[0].loc = -1;
- coutbuf[1].val = 1;
- coutbuf[1].loc = -1;
- coutbuf[2].val = 1;
- coutbuf[2].loc = -1;
- MPI_Reduce( cinbuf, coutbuf, 3, MPI_FLOAT_INT, MPI_MAXLOC, 0, comm );
- if (rank == 0) {
- if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) {
- errs++;
- fprintf( stderr, "float-int MAXLOC(1) test failed\n" );
- }
- if (coutbuf[1].val != 0) {
- errs++;
- fprintf( stderr, "float-int MAXLOC(0) test failed, value = %f, should be zero\n", coutbuf[1].val );
- }
- if (coutbuf[1].loc != 0) {
- errs++;
- fprintf( stderr, "float-int MAXLOC(0) test failed, location of max = %d, should be zero\n", coutbuf[1].loc );
- }
- if (coutbuf[2].val != size-1 || coutbuf[2].loc != size-1) {
- errs++;
- fprintf( stderr, "float-int MAXLOC(>) test failed\n" );
- }
- }
+ struct floatint {
+ float val;
+ int loc;
+ } cinbuf[3], coutbuf[3];
+
+ cinbuf[0].val = 1;
+ cinbuf[0].loc = rank;
+ cinbuf[1].val = 0;
+ cinbuf[1].loc = rank;
+ cinbuf[2].val = (float) rank;
+ cinbuf[2].loc = rank;
+
+ coutbuf[0].val = 0;
+ coutbuf[0].loc = -1;
+ coutbuf[1].val = 1;
+ coutbuf[1].loc = -1;
+ coutbuf[2].val = 1;
+ coutbuf[2].loc = -1;
+ MPI_Reduce(cinbuf, coutbuf, 3, MPI_FLOAT_INT, MPI_MAXLOC, 0, comm);
+ if (rank == 0) {
+ if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) {
+ errs++;
+ fprintf(stderr, "float-int MAXLOC(1) test failed\n");
+ }
+ if (coutbuf[1].val != 0) {
+ errs++;
+ fprintf(stderr, "float-int MAXLOC(0) test failed, value = %f, should be zero\n",
+ coutbuf[1].val);
+ }
+ if (coutbuf[1].loc != 0) {
+ errs++;
+ fprintf(stderr,
+ "float-int MAXLOC(0) test failed, location of max = %d, should be zero\n",
+ coutbuf[1].loc);
+ }
+ if (coutbuf[2].val != size - 1 || coutbuf[2].loc != size - 1) {
+ errs++;
+ fprintf(stderr, "float-int MAXLOC(>) test failed\n");
+ }
+ }
}
-
+
/* long int */
{
- struct longint { long val; int loc; } cinbuf[3], coutbuf[3];
-
- cinbuf[0].val = 1;
- cinbuf[0].loc = rank;
- cinbuf[1].val = 0;
- cinbuf[1].loc = rank;
- cinbuf[2].val = rank;
- cinbuf[2].loc = rank;
-
- coutbuf[0].val = 0;
- coutbuf[0].loc = -1;
- coutbuf[1].val = 1;
- coutbuf[1].loc = -1;
- coutbuf[2].val = 1;
- coutbuf[2].loc = -1;
- MPI_Reduce( cinbuf, coutbuf, 3, MPI_LONG_INT, MPI_MAXLOC, 0, comm );
- if (rank == 0) {
- if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) {
- errs++;
- fprintf( stderr, "long-int MAXLOC(1) test failed\n" );
- }
- if (coutbuf[1].val != 0) {
- errs++;
- fprintf( stderr, "long-int MAXLOC(0) test failed, value = %ld, should be zero\n", coutbuf[1].val );
- }
- if (coutbuf[1].loc != 0) {
- errs++;
- fprintf( stderr, "long-int MAXLOC(0) test failed, location of max = %d, should be zero\n", coutbuf[1].loc );
- }
- if (coutbuf[2].val != size-1 || coutbuf[2].loc != size-1) {
- errs++;
- fprintf( stderr, "long-int MAXLOC(>) test failed\n" );
- }
- }
+ struct longint {
+ long val;
+ int loc;
+ } cinbuf[3], coutbuf[3];
+
+ cinbuf[0].val = 1;
+ cinbuf[0].loc = rank;
+ cinbuf[1].val = 0;
+ cinbuf[1].loc = rank;
+ cinbuf[2].val = rank;
+ cinbuf[2].loc = rank;
+
+ coutbuf[0].val = 0;
+ coutbuf[0].loc = -1;
+ coutbuf[1].val = 1;
+ coutbuf[1].loc = -1;
+ coutbuf[2].val = 1;
+ coutbuf[2].loc = -1;
+ MPI_Reduce(cinbuf, coutbuf, 3, MPI_LONG_INT, MPI_MAXLOC, 0, comm);
+ if (rank == 0) {
+ if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) {
+ errs++;
+ fprintf(stderr, "long-int MAXLOC(1) test failed\n");
+ }
+ if (coutbuf[1].val != 0) {
+ errs++;
+ fprintf(stderr, "long-int MAXLOC(0) test failed, value = %ld, should be zero\n",
+ coutbuf[1].val);
+ }
+ if (coutbuf[1].loc != 0) {
+ errs++;
+ fprintf(stderr,
+ "long-int MAXLOC(0) test failed, location of max = %d, should be zero\n",
+ coutbuf[1].loc);
+ }
+ if (coutbuf[2].val != size - 1 || coutbuf[2].loc != size - 1) {
+ errs++;
+ fprintf(stderr, "long-int MAXLOC(>) test failed\n");
+ }
+ }
}
/* short int */
{
- struct shortint { short val; int loc; } cinbuf[3], coutbuf[3];
-
- cinbuf[0].val = 1;
- cinbuf[0].loc = rank;
- cinbuf[1].val = 0;
- cinbuf[1].loc = rank;
- cinbuf[2].val = rank;
- cinbuf[2].loc = rank;
-
- coutbuf[0].val = 0;
- coutbuf[0].loc = -1;
- coutbuf[1].val = 1;
- coutbuf[1].loc = -1;
- coutbuf[2].val = 1;
- coutbuf[2].loc = -1;
- MPI_Reduce( cinbuf, coutbuf, 3, MPI_SHORT_INT, MPI_MAXLOC, 0, comm );
- if (rank == 0) {
- if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) {
- errs++;
- fprintf( stderr, "short-int MAXLOC(1) test failed\n" );
- }
- if (coutbuf[1].val != 0) {
- errs++;
- fprintf( stderr, "short-int MAXLOC(0) test failed, value = %d, should be zero\n", coutbuf[1].val );
- }
- if (coutbuf[1].loc != 0) {
- errs++;
- fprintf( stderr, "short-int MAXLOC(0) test failed, location of max = %d, should be zero\n", coutbuf[1].loc );
- }
- if (coutbuf[2].val != size-1) {
- errs++;
- fprintf( stderr, "short-int MAXLOC(>) test failed, value = %d, should be %d\n", coutbuf[2].val, size-1 );
- }
- if (coutbuf[2].loc != size -1) {
- errs++;
- fprintf( stderr, "short-int MAXLOC(>) test failed, location of max = %d, should be %d\n", coutbuf[2].loc, size-1 );
- }
- }
+ struct shortint {
+ short val;
+ int loc;
+ } cinbuf[3], coutbuf[3];
+
+ cinbuf[0].val = 1;
+ cinbuf[0].loc = rank;
+ cinbuf[1].val = 0;
+ cinbuf[1].loc = rank;
+ cinbuf[2].val = rank;
+ cinbuf[2].loc = rank;
+
+ coutbuf[0].val = 0;
+ coutbuf[0].loc = -1;
+ coutbuf[1].val = 1;
+ coutbuf[1].loc = -1;
+ coutbuf[2].val = 1;
+ coutbuf[2].loc = -1;
+ MPI_Reduce(cinbuf, coutbuf, 3, MPI_SHORT_INT, MPI_MAXLOC, 0, comm);
+ if (rank == 0) {
+ if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) {
+ errs++;
+ fprintf(stderr, "short-int MAXLOC(1) test failed\n");
+ }
+ if (coutbuf[1].val != 0) {
+ errs++;
+ fprintf(stderr, "short-int MAXLOC(0) test failed, value = %d, should be zero\n",
+ coutbuf[1].val);
+ }
+ if (coutbuf[1].loc != 0) {
+ errs++;
+ fprintf(stderr,
+ "short-int MAXLOC(0) test failed, location of max = %d, should be zero\n",
+ coutbuf[1].loc);
+ }
+ if (coutbuf[2].val != size - 1) {
+ errs++;
+ fprintf(stderr, "short-int MAXLOC(>) test failed, value = %d, should be %d\n",
+ coutbuf[2].val, size - 1);
+ }
+ if (coutbuf[2].loc != size - 1) {
+ errs++;
+ fprintf(stderr,
+ "short-int MAXLOC(>) test failed, location of max = %d, should be %d\n",
+ coutbuf[2].loc, size - 1);
+ }
+ }
}
-
+
/* double int */
{
- struct doubleint { double val; int loc; } cinbuf[3], coutbuf[3];
-
- cinbuf[0].val = 1;
- cinbuf[0].loc = rank;
- cinbuf[1].val = 0;
- cinbuf[1].loc = rank;
- cinbuf[2].val = rank;
- cinbuf[2].loc = rank;
-
- coutbuf[0].val = 0;
- coutbuf[0].loc = -1;
- coutbuf[1].val = 1;
- coutbuf[1].loc = -1;
- coutbuf[2].val = 1;
- coutbuf[2].loc = -1;
- MPI_Reduce( cinbuf, coutbuf, 3, MPI_DOUBLE_INT, MPI_MAXLOC, 0, comm );
- if (rank == 0) {
- if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) {
- errs++;
- fprintf( stderr, "double-int MAXLOC(1) test failed\n" );
- }
- if (coutbuf[1].val != 0) {
- errs++;
- fprintf( stderr, "double-int MAXLOC(0) test failed, value = %lf, should be zero\n", coutbuf[1].val );
- }
- if (coutbuf[1].loc != 0) {
- errs++;
- fprintf( stderr, "double-int MAXLOC(0) test failed, location of max = %d, should be zero\n", coutbuf[1].loc );
- }
- if (coutbuf[2].val != size-1 || coutbuf[2].loc != size-1) {
- errs++;
- fprintf( stderr, "double-int MAXLOC(>) test failed\n" );
- }
- }
+ struct doubleint {
+ double val;
+ int loc;
+ } cinbuf[3], coutbuf[3];
+
+ cinbuf[0].val = 1;
+ cinbuf[0].loc = rank;
+ cinbuf[1].val = 0;
+ cinbuf[1].loc = rank;
+ cinbuf[2].val = rank;
+ cinbuf[2].loc = rank;
+
+ coutbuf[0].val = 0;
+ coutbuf[0].loc = -1;
+ coutbuf[1].val = 1;
+ coutbuf[1].loc = -1;
+ coutbuf[2].val = 1;
+ coutbuf[2].loc = -1;
+ MPI_Reduce(cinbuf, coutbuf, 3, MPI_DOUBLE_INT, MPI_MAXLOC, 0, comm);
+ if (rank == 0) {
+ if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) {
+ errs++;
+ fprintf(stderr, "double-int MAXLOC(1) test failed\n");
+ }
+ if (coutbuf[1].val != 0) {
+ errs++;
+ fprintf(stderr, "double-int MAXLOC(0) test failed, value = %lf, should be zero\n",
+ coutbuf[1].val);
+ }
+ if (coutbuf[1].loc != 0) {
+ errs++;
+ fprintf(stderr,
+ "double-int MAXLOC(0) test failed, location of max = %d, should be zero\n",
+ coutbuf[1].loc);
+ }
+ if (coutbuf[2].val != size - 1 || coutbuf[2].loc != size - 1) {
+ errs++;
+ fprintf(stderr, "double-int MAXLOC(>) test failed\n");
+ }
+ }
}
-
+
#ifdef HAVE_LONG_DOUBLE
/* long double int */
{
- struct longdoubleint { long double val; int loc; } cinbuf[3], coutbuf[3];
+ struct longdoubleint {
+ long double val;
+ int loc;
+ } cinbuf[3], coutbuf[3];
/* avoid valgrind warnings about padding bytes in the long double */
memset(&cinbuf[0], 0, sizeof(cinbuf));
memset(&coutbuf[0], 0, sizeof(coutbuf));
- cinbuf[0].val = 1;
- cinbuf[0].loc = rank;
- cinbuf[1].val = 0;
- cinbuf[1].loc = rank;
- cinbuf[2].val = rank;
- cinbuf[2].loc = rank;
-
- coutbuf[0].val = 0;
- coutbuf[0].loc = -1;
- coutbuf[1].val = 1;
- coutbuf[1].loc = -1;
- coutbuf[2].val = 1;
- coutbuf[2].loc = -1;
- if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
- MPI_Reduce( cinbuf, coutbuf, 3, MPI_LONG_DOUBLE_INT, MPI_MAXLOC,
- 0, comm );
- if (rank == 0) {
- if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) {
- errs++;
- fprintf( stderr, "long double-int MAXLOC(1) test failed\n" );
- }
- if (coutbuf[1].val != 0) {
- errs++;
- fprintf( stderr, "long double-int MAXLOC(0) test failed, value = %lf, should be zero\n", (double)coutbuf[1].val );
- }
- if (coutbuf[1].loc != 0) {
- errs++;
- fprintf( stderr, "long double-int MAXLOC(0) test failed, location of max = %d, should be zero\n", coutbuf[1].loc );
- }
- if (coutbuf[2].val != size-1) {
- errs++;
- fprintf( stderr, "long double-int MAXLOC(>) test failed, value = %lf, should be %d\n", (double)coutbuf[2].val, size-1 );
- }
- if (coutbuf[2].loc != size-1) {
- errs++;
- fprintf( stderr, "long double-int MAXLOC(>) test failed, location of max = %d, should be %d\n", coutbuf[2].loc, size-1 );
- }
- }
- }
+ cinbuf[0].val = 1;
+ cinbuf[0].loc = rank;
+ cinbuf[1].val = 0;
+ cinbuf[1].loc = rank;
+ cinbuf[2].val = rank;
+ cinbuf[2].loc = rank;
+
+ coutbuf[0].val = 0;
+ coutbuf[0].loc = -1;
+ coutbuf[1].val = 1;
+ coutbuf[1].loc = -1;
+ coutbuf[2].val = 1;
+ coutbuf[2].loc = -1;
+ if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
+ MPI_Reduce(cinbuf, coutbuf, 3, MPI_LONG_DOUBLE_INT, MPI_MAXLOC, 0, comm);
+ if (rank == 0) {
+ if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) {
+ errs++;
+ fprintf(stderr, "long double-int MAXLOC(1) test failed\n");
+ }
+ if (coutbuf[1].val != 0) {
+ errs++;
+ fprintf(stderr,
+ "long double-int MAXLOC(0) test failed, value = %lf, should be zero\n",
+ (double) coutbuf[1].val);
+ }
+ if (coutbuf[1].loc != 0) {
+ errs++;
+ fprintf(stderr,
+ "long double-int MAXLOC(0) test failed, location of max = %d, should be zero\n",
+ coutbuf[1].loc);
+ }
+ if (coutbuf[2].val != size - 1) {
+ errs++;
+ fprintf(stderr,
+ "long double-int MAXLOC(>) test failed, value = %lf, should be %d\n",
+ (double) coutbuf[2].val, size - 1);
+ }
+ if (coutbuf[2].loc != size - 1) {
+ errs++;
+ fprintf(stderr,
+ "long double-int MAXLOC(>) test failed, location of max = %d, should be %d\n",
+ coutbuf[2].loc, size - 1);
+ }
+ }
+ }
}
#endif
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/opmin.c b/test/mpi/coll/opmin.c
index 59202da..9f80256 100644
--- a/test/mpi/coll/opmin.c
+++ b/test/mpi/coll/opmin.c
@@ -14,29 +14,29 @@ static char MTEST_Descrip[] = "Test MPI_MIN operations on optional datatypes dup
*/
/*
- * This test looks at the handling of char and types that are not required
+ * This test looks at the handling of char and types that are not required
* integers (e.g., long long). MPICH allows
* these as well. A strict MPI test should not include this test.
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size;
- MPI_Comm comm;
+ MPI_Comm comm;
char cinbuf[3], coutbuf[3];
signed char scinbuf[3], scoutbuf[3];
unsigned char ucinbuf[3], ucoutbuf[3];
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
#ifndef USE_STRICT_MPI
/* char */
- MTestPrintfMsg( 10, "Reduce of MPI_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_CHAR\n");
cinbuf[0] = 1;
cinbuf[1] = 0;
cinbuf[2] = (rank & 0x7f);
@@ -44,25 +44,25 @@ int main( int argc, char *argv[] )
coutbuf[0] = 0;
coutbuf[1] = 1;
coutbuf[2] = 1;
- MPI_Reduce( cinbuf, coutbuf, 3, MPI_CHAR, MPI_MIN, 0, comm );
+ MPI_Reduce(cinbuf, coutbuf, 3, MPI_CHAR, MPI_MIN, 0, comm);
if (rank == 0) {
- if (coutbuf[0] != 1) {
- errs++;
- fprintf( stderr, "char MIN(1) test failed\n" );
- }
- if (coutbuf[1] != 0) {
- errs++;
- fprintf( stderr, "char MIN(0) test failed\n" );
- }
- if (coutbuf[2] != 0) {
- errs++;
- fprintf( stderr, "char MIN(>) test failed\n" );
- }
+ if (coutbuf[0] != 1) {
+ errs++;
+ fprintf(stderr, "char MIN(1) test failed\n");
+ }
+ if (coutbuf[1] != 0) {
+ errs++;
+ fprintf(stderr, "char MIN(0) test failed\n");
+ }
+ if (coutbuf[2] != 0) {
+ errs++;
+ fprintf(stderr, "char MIN(>) test failed\n");
+ }
}
#endif /* USE_STRICT_MPI */
/* signed char */
- MTestPrintfMsg( 10, "Reduce of MPI_SIGNED_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_SIGNED_CHAR\n");
scinbuf[0] = 1;
scinbuf[1] = 0;
scinbuf[2] = (rank & 0x7f);
@@ -70,24 +70,24 @@ int main( int argc, char *argv[] )
scoutbuf[0] = 0;
scoutbuf[1] = 1;
scoutbuf[2] = 1;
- MPI_Reduce( scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_MIN, 0, comm );
+ MPI_Reduce(scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_MIN, 0, comm);
if (rank == 0) {
- if (scoutbuf[0] != 1) {
- errs++;
- fprintf( stderr, "signed char MIN(1) test failed\n" );
- }
- if (scoutbuf[1] != 0) {
- errs++;
- fprintf( stderr, "signed char MIN(0) test failed\n" );
- }
- if (scoutbuf[2] != 0) {
- errs++;
- fprintf( stderr, "signed char MIN(>) test failed\n" );
- }
+ if (scoutbuf[0] != 1) {
+ errs++;
+ fprintf(stderr, "signed char MIN(1) test failed\n");
+ }
+ if (scoutbuf[1] != 0) {
+ errs++;
+ fprintf(stderr, "signed char MIN(0) test failed\n");
+ }
+ if (scoutbuf[2] != 0) {
+ errs++;
+ fprintf(stderr, "signed char MIN(>) test failed\n");
+ }
}
/* unsigned char */
- MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_CHAR\n");
ucinbuf[0] = 1;
ucinbuf[1] = 0;
ucinbuf[2] = (rank & 0x7f);
@@ -95,86 +95,87 @@ int main( int argc, char *argv[] )
ucoutbuf[0] = 0;
ucoutbuf[1] = 1;
ucoutbuf[2] = 1;
- MPI_Reduce( ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_MIN, 0, comm );
+ MPI_Reduce(ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_MIN, 0, comm);
if (rank == 0) {
- if (ucoutbuf[0] != 1) {
- errs++;
- fprintf( stderr, "unsigned char MIN(1) test failed\n" );
- }
- if (ucoutbuf[1]) {
- errs++;
- fprintf( stderr, "unsigned char MIN(0) test failed\n" );
- }
- if (ucoutbuf[2] != 0) {
- errs++;
- fprintf( stderr, "unsigned char MIN(>) test failed\n" );
- }
+ if (ucoutbuf[0] != 1) {
+ errs++;
+ fprintf(stderr, "unsigned char MIN(1) test failed\n");
+ }
+ if (ucoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "unsigned char MIN(0) test failed\n");
+ }
+ if (ucoutbuf[2] != 0) {
+ errs++;
+ fprintf(stderr, "unsigned char MIN(>) test failed\n");
+ }
}
#ifdef HAVE_LONG_DOUBLE
- { long double ldinbuf[3], ldoutbuf[3];
- /* long double */
- ldinbuf[0] = 1;
- ldinbuf[1] = 0;
- ldinbuf[2] = rank;
-
- ldoutbuf[0] = 0;
- ldoutbuf[1] = 1;
- ldoutbuf[2] = 1;
- if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
- MTestPrintfMsg( 10, "Reduce of MPI_LONG_DOUBLE\n" );
- MPI_Reduce( ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_MIN, 0, comm );
- if (rank == 0) {
- if (ldoutbuf[0] != 1) {
- errs++;
- fprintf( stderr, "long double MIN(1) test failed\n" );
- }
- if (ldoutbuf[1] != 0.0) {
- errs++;
- fprintf( stderr, "long double MIN(0) test failed\n" );
- }
- if (ldoutbuf[2] != 0.0) {
- errs++;
- fprintf( stderr, "long double MIN(>) test failed\n" );
- }
- }
- }
+ {
+ long double ldinbuf[3], ldoutbuf[3];
+ /* long double */
+ ldinbuf[0] = 1;
+ ldinbuf[1] = 0;
+ ldinbuf[2] = rank;
+
+ ldoutbuf[0] = 0;
+ ldoutbuf[1] = 1;
+ ldoutbuf[2] = 1;
+ if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
+ MTestPrintfMsg(10, "Reduce of MPI_LONG_DOUBLE\n");
+ MPI_Reduce(ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_MIN, 0, comm);
+ if (rank == 0) {
+ if (ldoutbuf[0] != 1) {
+ errs++;
+ fprintf(stderr, "long double MIN(1) test failed\n");
+ }
+ if (ldoutbuf[1] != 0.0) {
+ errs++;
+ fprintf(stderr, "long double MIN(0) test failed\n");
+ }
+ if (ldoutbuf[2] != 0.0) {
+ errs++;
+ fprintf(stderr, "long double MIN(>) test failed\n");
+ }
+ }
+ }
}
#endif /* HAVE_LONG_DOUBLE */
#ifdef HAVE_LONG_LONG
{
- long long llinbuf[3], lloutbuf[3];
- /* long long */
- llinbuf[0] = 1;
- llinbuf[1] = 0;
- llinbuf[2] = rank;
-
- lloutbuf[0] = 0;
- lloutbuf[1] = 1;
- lloutbuf[2] = 1;
- if (MPI_LONG_LONG != MPI_DATATYPE_NULL) {
- MTestPrintfMsg( 10, "Reduce of MPI_LONG_LONG\n" );
- MPI_Reduce( llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_MIN, 0, comm );
- if (rank == 0) {
- if (lloutbuf[0] != 1) {
- errs++;
- fprintf( stderr, "long long MIN(1) test failed\n" );
- }
- if (lloutbuf[1] != 0) {
- errs++;
- fprintf( stderr, "long long MIN(0) test failed\n" );
- }
- if (lloutbuf[2] != 0) {
- errs++;
- fprintf( stderr, "long long MIN(>) test failed\n" );
- }
- }
- }
+ long long llinbuf[3], lloutbuf[3];
+ /* long long */
+ llinbuf[0] = 1;
+ llinbuf[1] = 0;
+ llinbuf[2] = rank;
+
+ lloutbuf[0] = 0;
+ lloutbuf[1] = 1;
+ lloutbuf[2] = 1;
+ if (MPI_LONG_LONG != MPI_DATATYPE_NULL) {
+ MTestPrintfMsg(10, "Reduce of MPI_LONG_LONG\n");
+ MPI_Reduce(llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_MIN, 0, comm);
+ if (rank == 0) {
+ if (lloutbuf[0] != 1) {
+ errs++;
+ fprintf(stderr, "long long MIN(1) test failed\n");
+ }
+ if (lloutbuf[1] != 0) {
+ errs++;
+ fprintf(stderr, "long long MIN(0) test failed\n");
+ }
+ if (lloutbuf[2] != 0) {
+ errs++;
+ fprintf(stderr, "long long MIN(>) test failed\n");
+ }
+ }
+ }
}
#endif /* HAVE_LONG_LONG */
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/opminloc.c b/test/mpi/coll/opminloc.c
index 9eb84ee..29ced04 100644
--- a/test/mpi/coll/opminloc.c
+++ b/test/mpi/coll/opminloc.c
@@ -14,236 +14,253 @@ static char MTEST_Descrip[] = "Test MPI_MINLOC operations on datatypes dupported
*/
/*
- * This test looks at the handling of char and types that are not required
+ * This test looks at the handling of char and types that are not required
* integers (e.g., long long). MPICH allows
* these as well. A strict MPI test should not include this test.
*
* The rule on min loc is that if there is a tie in the value, the minimum
* rank is used (see 4.9.3 in the MPI-1 standard)
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size;
- MPI_Comm comm;
+ MPI_Comm comm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
/* 2 int */
{
- struct twoint { int val; int loc; } cinbuf[3], coutbuf[3];
-
- cinbuf[0].val = 1;
- cinbuf[0].loc = rank;
- cinbuf[1].val = 0;
- cinbuf[1].loc = rank;
- cinbuf[2].val = (rank & 0x7f);
- cinbuf[2].loc = rank;
-
- coutbuf[0].val = 0;
- coutbuf[0].loc = -1;
- coutbuf[1].val = 1;
- coutbuf[1].loc = -1;
- coutbuf[2].val = 1;
- coutbuf[2].loc = -1;
- MPI_Reduce( cinbuf, coutbuf, 3, MPI_2INT, MPI_MINLOC, 0, comm );
- if (rank == 0) {
- if (coutbuf[0].val != 1 && coutbuf[0].loc != -1) {
- errs++;
- fprintf( stderr, "2int MINLOC(1) test failed\n" );
- }
- if (coutbuf[1].val != 0 && coutbuf[1].loc != -1) {
- errs++;
- fprintf( stderr, "2int MINLOC(0) test failed\n" );
- }
- if (coutbuf[2].val != 0 && coutbuf[2].loc != 0) {
- errs++;
- fprintf( stderr, "2int MINLOC(>) test failed\n" );
- }
- }
+ struct twoint {
+ int val;
+ int loc;
+ } cinbuf[3], coutbuf[3];
+
+ cinbuf[0].val = 1;
+ cinbuf[0].loc = rank;
+ cinbuf[1].val = 0;
+ cinbuf[1].loc = rank;
+ cinbuf[2].val = (rank & 0x7f);
+ cinbuf[2].loc = rank;
+
+ coutbuf[0].val = 0;
+ coutbuf[0].loc = -1;
+ coutbuf[1].val = 1;
+ coutbuf[1].loc = -1;
+ coutbuf[2].val = 1;
+ coutbuf[2].loc = -1;
+ MPI_Reduce(cinbuf, coutbuf, 3, MPI_2INT, MPI_MINLOC, 0, comm);
+ if (rank == 0) {
+ if (coutbuf[0].val != 1 && coutbuf[0].loc != -1) {
+ errs++;
+ fprintf(stderr, "2int MINLOC(1) test failed\n");
+ }
+ if (coutbuf[1].val != 0 && coutbuf[1].loc != -1) {
+ errs++;
+ fprintf(stderr, "2int MINLOC(0) test failed\n");
+ }
+ if (coutbuf[2].val != 0 && coutbuf[2].loc != 0) {
+ errs++;
+ fprintf(stderr, "2int MINLOC(>) test failed\n");
+ }
+ }
}
-
+
/* float int */
{
- struct floatint { float val; int loc; } cinbuf[3], coutbuf[3];
-
- cinbuf[0].val = 1;
- cinbuf[0].loc = rank;
- cinbuf[1].val = 0;
- cinbuf[1].loc = rank;
- cinbuf[2].val = (float)rank;
- cinbuf[2].loc = rank;
-
- coutbuf[0].val = 0;
- coutbuf[0].loc = -1;
- coutbuf[1].val = 1;
- coutbuf[1].loc = -1;
- coutbuf[2].val = 1;
- coutbuf[2].loc = -1;
- MPI_Reduce( cinbuf, coutbuf, 3, MPI_FLOAT_INT, MPI_MINLOC, 0, comm );
- if (rank == 0) {
- if (coutbuf[0].val != 1 && coutbuf[0].loc != -1) {
- errs++;
- fprintf( stderr, "float-int MINLOC(1) test failed\n" );
- }
- if (coutbuf[1].val != 0 && coutbuf[1].loc != -1) {
- errs++;
- fprintf( stderr, "float-int MINLOC(0) test failed\n" );
- }
- if (coutbuf[2].val != 0 && coutbuf[2].loc != 0) {
- errs++;
- fprintf( stderr, "float-int MINLOC(>) test failed\n" );
- }
- }
+ struct floatint {
+ float val;
+ int loc;
+ } cinbuf[3], coutbuf[3];
+
+ cinbuf[0].val = 1;
+ cinbuf[0].loc = rank;
+ cinbuf[1].val = 0;
+ cinbuf[1].loc = rank;
+ cinbuf[2].val = (float) rank;
+ cinbuf[2].loc = rank;
+
+ coutbuf[0].val = 0;
+ coutbuf[0].loc = -1;
+ coutbuf[1].val = 1;
+ coutbuf[1].loc = -1;
+ coutbuf[2].val = 1;
+ coutbuf[2].loc = -1;
+ MPI_Reduce(cinbuf, coutbuf, 3, MPI_FLOAT_INT, MPI_MINLOC, 0, comm);
+ if (rank == 0) {
+ if (coutbuf[0].val != 1 && coutbuf[0].loc != -1) {
+ errs++;
+ fprintf(stderr, "float-int MINLOC(1) test failed\n");
+ }
+ if (coutbuf[1].val != 0 && coutbuf[1].loc != -1) {
+ errs++;
+ fprintf(stderr, "float-int MINLOC(0) test failed\n");
+ }
+ if (coutbuf[2].val != 0 && coutbuf[2].loc != 0) {
+ errs++;
+ fprintf(stderr, "float-int MINLOC(>) test failed\n");
+ }
+ }
}
-
+
/* long int */
{
- struct longint { long val; int loc; } cinbuf[3], coutbuf[3];
-
- cinbuf[0].val = 1;
- cinbuf[0].loc = rank;
- cinbuf[1].val = 0;
- cinbuf[1].loc = rank;
- cinbuf[2].val = rank;
- cinbuf[2].loc = rank;
-
- coutbuf[0].val = 0;
- coutbuf[0].loc = -1;
- coutbuf[1].val = 1;
- coutbuf[1].loc = -1;
- coutbuf[2].val = 1;
- coutbuf[2].loc = -1;
- MPI_Reduce( cinbuf, coutbuf, 3, MPI_LONG_INT, MPI_MINLOC, 0, comm );
- if (rank == 0) {
- if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) {
- errs++;
- fprintf( stderr, "long-int MINLOC(1) test failed\n" );
- }
- if (coutbuf[1].val != 0 || coutbuf[1].loc != 0) {
- errs++;
- fprintf( stderr, "long-int MINLOC(0) test failed\n" );
- }
- if (coutbuf[2].val != 0 || coutbuf[2].loc != 0) {
- errs++;
- fprintf( stderr, "long-int MINLOC(>) test failed\n" );
- }
- }
+ struct longint {
+ long val;
+ int loc;
+ } cinbuf[3], coutbuf[3];
+
+ cinbuf[0].val = 1;
+ cinbuf[0].loc = rank;
+ cinbuf[1].val = 0;
+ cinbuf[1].loc = rank;
+ cinbuf[2].val = rank;
+ cinbuf[2].loc = rank;
+
+ coutbuf[0].val = 0;
+ coutbuf[0].loc = -1;
+ coutbuf[1].val = 1;
+ coutbuf[1].loc = -1;
+ coutbuf[2].val = 1;
+ coutbuf[2].loc = -1;
+ MPI_Reduce(cinbuf, coutbuf, 3, MPI_LONG_INT, MPI_MINLOC, 0, comm);
+ if (rank == 0) {
+ if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) {
+ errs++;
+ fprintf(stderr, "long-int MINLOC(1) test failed\n");
+ }
+ if (coutbuf[1].val != 0 || coutbuf[1].loc != 0) {
+ errs++;
+ fprintf(stderr, "long-int MINLOC(0) test failed\n");
+ }
+ if (coutbuf[2].val != 0 || coutbuf[2].loc != 0) {
+ errs++;
+ fprintf(stderr, "long-int MINLOC(>) test failed\n");
+ }
+ }
}
/* short int */
{
- struct shortint { short val; int loc; } cinbuf[3], coutbuf[3];
-
- cinbuf[0].val = 1;
- cinbuf[0].loc = rank;
- cinbuf[1].val = 0;
- cinbuf[1].loc = rank;
- cinbuf[2].val = rank;
- cinbuf[2].loc = rank;
-
- coutbuf[0].val = 0;
- coutbuf[0].loc = -1;
- coutbuf[1].val = 1;
- coutbuf[1].loc = -1;
- coutbuf[2].val = 1;
- coutbuf[2].loc = -1;
- MPI_Reduce( cinbuf, coutbuf, 3, MPI_SHORT_INT, MPI_MINLOC, 0, comm );
- if (rank == 0) {
- if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) {
- errs++;
- fprintf( stderr, "short-int MINLOC(1) test failed\n" );
- }
- if (coutbuf[1].val != 0 || coutbuf[1].loc != 0) {
- errs++;
- fprintf( stderr, "short-int MINLOC(0) test failed\n" );
- }
- if (coutbuf[2].val != 0 || coutbuf[2].loc != 0) {
- errs++;
- fprintf( stderr, "short-int MINLOC(>) test failed\n" );
- }
- }
+ struct shortint {
+ short val;
+ int loc;
+ } cinbuf[3], coutbuf[3];
+
+ cinbuf[0].val = 1;
+ cinbuf[0].loc = rank;
+ cinbuf[1].val = 0;
+ cinbuf[1].loc = rank;
+ cinbuf[2].val = rank;
+ cinbuf[2].loc = rank;
+
+ coutbuf[0].val = 0;
+ coutbuf[0].loc = -1;
+ coutbuf[1].val = 1;
+ coutbuf[1].loc = -1;
+ coutbuf[2].val = 1;
+ coutbuf[2].loc = -1;
+ MPI_Reduce(cinbuf, coutbuf, 3, MPI_SHORT_INT, MPI_MINLOC, 0, comm);
+ if (rank == 0) {
+ if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) {
+ errs++;
+ fprintf(stderr, "short-int MINLOC(1) test failed\n");
+ }
+ if (coutbuf[1].val != 0 || coutbuf[1].loc != 0) {
+ errs++;
+ fprintf(stderr, "short-int MINLOC(0) test failed\n");
+ }
+ if (coutbuf[2].val != 0 || coutbuf[2].loc != 0) {
+ errs++;
+ fprintf(stderr, "short-int MINLOC(>) test failed\n");
+ }
+ }
}
-
+
/* double int */
{
- struct doubleint { double val; int loc; } cinbuf[3], coutbuf[3];
-
- cinbuf[0].val = 1;
- cinbuf[0].loc = rank;
- cinbuf[1].val = 0;
- cinbuf[1].loc = rank;
- cinbuf[2].val = rank;
- cinbuf[2].loc = rank;
-
- coutbuf[0].val = 0;
- coutbuf[0].loc = -1;
- coutbuf[1].val = 1;
- coutbuf[1].loc = -1;
- coutbuf[2].val = 1;
- coutbuf[2].loc = -1;
- MPI_Reduce( cinbuf, coutbuf, 3, MPI_DOUBLE_INT, MPI_MINLOC, 0, comm );
- if (rank == 0) {
- if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) {
- errs++;
- fprintf( stderr, "double-int MINLOC(1) test failed\n" );
- }
- if (coutbuf[1].val != 0 || coutbuf[1].loc != 0) {
- errs++;
- fprintf( stderr, "double-int MINLOC(0) test failed\n" );
- }
- if (coutbuf[2].val != 0 || coutbuf[2].loc != 0) {
- errs++;
- fprintf( stderr, "double-int MINLOC(>) test failed\n" );
- }
- }
+ struct doubleint {
+ double val;
+ int loc;
+ } cinbuf[3], coutbuf[3];
+
+ cinbuf[0].val = 1;
+ cinbuf[0].loc = rank;
+ cinbuf[1].val = 0;
+ cinbuf[1].loc = rank;
+ cinbuf[2].val = rank;
+ cinbuf[2].loc = rank;
+
+ coutbuf[0].val = 0;
+ coutbuf[0].loc = -1;
+ coutbuf[1].val = 1;
+ coutbuf[1].loc = -1;
+ coutbuf[2].val = 1;
+ coutbuf[2].loc = -1;
+ MPI_Reduce(cinbuf, coutbuf, 3, MPI_DOUBLE_INT, MPI_MINLOC, 0, comm);
+ if (rank == 0) {
+ if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) {
+ errs++;
+ fprintf(stderr, "double-int MINLOC(1) test failed\n");
+ }
+ if (coutbuf[1].val != 0 || coutbuf[1].loc != 0) {
+ errs++;
+ fprintf(stderr, "double-int MINLOC(0) test failed\n");
+ }
+ if (coutbuf[2].val != 0 || coutbuf[2].loc != 0) {
+ errs++;
+ fprintf(stderr, "double-int MINLOC(>) test failed\n");
+ }
+ }
}
-
+
#ifdef HAVE_LONG_DOUBLE
/* long double int */
{
- struct longdoubleint { long double val; int loc; } cinbuf[3], coutbuf[3];
-
- cinbuf[0].val = 1;
- cinbuf[0].loc = rank;
- cinbuf[1].val = 0;
- cinbuf[1].loc = rank;
- cinbuf[2].val = rank;
- cinbuf[2].loc = rank;
-
- coutbuf[0].val = 0;
- coutbuf[0].loc = -1;
- coutbuf[1].val = 1;
- coutbuf[1].loc = -1;
- coutbuf[2].val = 1;
- coutbuf[2].loc = -1;
- if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
- MPI_Reduce( cinbuf, coutbuf, 3, MPI_LONG_DOUBLE_INT, MPI_MINLOC,
- 0, comm );
- if (rank == 0) {
- if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) {
- errs++;
- fprintf( stderr, "long double-int MINLOC(1) test failed\n" );
- }
- if (coutbuf[1].val != 0 || coutbuf[1].loc != 0) {
- errs++;
- fprintf( stderr, "long double-int MINLOC(0) test failed\n" );
- }
- if (coutbuf[2].val != 0 || coutbuf[2].loc != 0) {
- errs++;
- fprintf( stderr, "long double-int MINLOC(>) test failed\n" );
- }
- }
- }
+ struct longdoubleint {
+ long double val;
+ int loc;
+ } cinbuf[3], coutbuf[3];
+
+ cinbuf[0].val = 1;
+ cinbuf[0].loc = rank;
+ cinbuf[1].val = 0;
+ cinbuf[1].loc = rank;
+ cinbuf[2].val = rank;
+ cinbuf[2].loc = rank;
+
+ coutbuf[0].val = 0;
+ coutbuf[0].loc = -1;
+ coutbuf[1].val = 1;
+ coutbuf[1].loc = -1;
+ coutbuf[2].val = 1;
+ coutbuf[2].loc = -1;
+ if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
+ MPI_Reduce(cinbuf, coutbuf, 3, MPI_LONG_DOUBLE_INT, MPI_MINLOC, 0, comm);
+ if (rank == 0) {
+ if (coutbuf[0].val != 1 || coutbuf[0].loc != 0) {
+ errs++;
+ fprintf(stderr, "long double-int MINLOC(1) test failed\n");
+ }
+ if (coutbuf[1].val != 0 || coutbuf[1].loc != 0) {
+ errs++;
+ fprintf(stderr, "long double-int MINLOC(0) test failed\n");
+ }
+ if (coutbuf[2].val != 0 || coutbuf[2].loc != 0) {
+ errs++;
+ fprintf(stderr, "long double-int MINLOC(>) test failed\n");
+ }
+ }
+ }
}
#endif
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/opprod.c b/test/mpi/coll/opprod.c
index e96aae2..0d25f3a 100644
--- a/test/mpi/coll/opprod.c
+++ b/test/mpi/coll/opprod.c
@@ -13,43 +13,49 @@
static char MTEST_Descrip[] = "Test MPI_PROD operations on optional datatypes dupported by MPICH";
*/
-typedef struct { double r, i; } d_complex;
+typedef struct {
+ double r, i;
+} d_complex;
#ifdef HAVE_LONG_DOUBLE
-typedef struct { long double r, i; } ld_complex;
+typedef struct {
+ long double r, i;
+} ld_complex;
#endif
/*
- * This test looks at the handling of logical and for types that are not
+ * This test looks at the handling of logical and for types that are not
* integers or are not required integers (e.g., long long). MPICH allows
* these as well. A strict MPI test should not include this test.
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size, maxsize, result[6] = { 1, 1, 2, 6, 24, 120 };
- MPI_Comm comm;
+ MPI_Comm comm;
char cinbuf[3], coutbuf[3];
signed char scinbuf[3], scoutbuf[3];
unsigned char ucinbuf[3], ucoutbuf[3];
d_complex dinbuf[3], doutbuf[3];
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
- if (size > 5) maxsize = 5;
- else maxsize = size;
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+ if (size > 5)
+ maxsize = 5;
+ else
+ maxsize = size;
- /* General forumula: If we multiple the values from 1 to n, the
- product is n!. This grows very fast, so we'll only use the first
- five (1! = 1, 2! = 2, 3! = 6, 4! = 24, 5! = 120), with n!
- stored in the array result[n] */
+ /* General forumula: If we multiple the values from 1 to n, the
+ * product is n!. This grows very fast, so we'll only use the first
+ * five (1! = 1, 2! = 2, 3! = 6, 4! = 24, 5! = 120), with n!
+ * stored in the array result[n] */
#ifndef USE_STRICT_MPI
/* char */
- MTestPrintfMsg( 10, "Reduce of MPI_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_CHAR\n");
cinbuf[0] = (rank < maxsize && rank > 0) ? rank : 1;
cinbuf[1] = 0;
cinbuf[2] = (rank > 1);
@@ -57,26 +63,26 @@ int main( int argc, char *argv[] )
coutbuf[0] = 0;
coutbuf[1] = 1;
coutbuf[2] = 1;
- MPI_Reduce( cinbuf, coutbuf, 3, MPI_CHAR, MPI_PROD, 0, comm );
+ MPI_Reduce(cinbuf, coutbuf, 3, MPI_CHAR, MPI_PROD, 0, comm);
if (rank == 0) {
- if (coutbuf[0] != (char)result[maxsize-1]) {
- errs++;
- fprintf( stderr, "char PROD(rank) test failed (%d!=%d)\n",
- (int)coutbuf[0], (int)result[maxsize]);
- }
- if (coutbuf[1]) {
- errs++;
- fprintf( stderr, "char PROD(0) test failed\n" );
- }
- if (size > 1 && coutbuf[2]) {
- errs++;
- fprintf( stderr, "char PROD(>) test failed\n" );
- }
+ if (coutbuf[0] != (char) result[maxsize - 1]) {
+ errs++;
+ fprintf(stderr, "char PROD(rank) test failed (%d!=%d)\n",
+ (int) coutbuf[0], (int) result[maxsize]);
+ }
+ if (coutbuf[1]) {
+ errs++;
+ fprintf(stderr, "char PROD(0) test failed\n");
+ }
+ if (size > 1 && coutbuf[2]) {
+ errs++;
+ fprintf(stderr, "char PROD(>) test failed\n");
+ }
}
#endif /* USE_STRICT_MPI */
/* signed char */
- MTestPrintfMsg( 10, "Reduce of MPI_SIGNED_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_SIGNED_CHAR\n");
scinbuf[0] = (rank < maxsize && rank > 0) ? rank : 1;
scinbuf[1] = 0;
scinbuf[2] = (rank > 1);
@@ -84,25 +90,25 @@ int main( int argc, char *argv[] )
scoutbuf[0] = 0;
scoutbuf[1] = 1;
scoutbuf[2] = 1;
- MPI_Reduce( scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_PROD, 0, comm );
+ MPI_Reduce(scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_PROD, 0, comm);
if (rank == 0) {
- if (scoutbuf[0] != (signed char)result[maxsize-1]) {
- errs++;
- fprintf( stderr, "signed char PROD(rank) test failed (%d!=%d)\n",
- (int)scoutbuf[0], (int)result[maxsize]);
- }
- if (scoutbuf[1]) {
- errs++;
- fprintf( stderr, "signed char PROD(0) test failed\n" );
- }
- if (size > 1 && scoutbuf[2]) {
- errs++;
- fprintf( stderr, "signed char PROD(>) test failed\n" );
- }
+ if (scoutbuf[0] != (signed char) result[maxsize - 1]) {
+ errs++;
+ fprintf(stderr, "signed char PROD(rank) test failed (%d!=%d)\n",
+ (int) scoutbuf[0], (int) result[maxsize]);
+ }
+ if (scoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "signed char PROD(0) test failed\n");
+ }
+ if (size > 1 && scoutbuf[2]) {
+ errs++;
+ fprintf(stderr, "signed char PROD(>) test failed\n");
+ }
}
/* unsigned char */
- MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_CHAR\n");
ucinbuf[0] = (rank < maxsize && rank > 0) ? rank : 1;
ucinbuf[1] = 0;
ucinbuf[2] = (rank > 0);
@@ -110,180 +116,207 @@ int main( int argc, char *argv[] )
ucoutbuf[0] = 0;
ucoutbuf[1] = 1;
ucoutbuf[2] = 1;
- MPI_Reduce( ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_PROD, 0, comm );
+ MPI_Reduce(ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_PROD, 0, comm);
if (rank == 0) {
- if (ucoutbuf[0] != (unsigned char)result[maxsize-1]) {
- errs++;
- fprintf( stderr, "unsigned char PROD(rank) test failed\n" );
- }
- if (ucoutbuf[1]) {
- errs++;
- fprintf( stderr, "unsigned char PROD(0) test failed\n" );
- }
- if (size > 1 && ucoutbuf[2]) {
- errs++;
- fprintf( stderr, "unsigned char PROD(>) test failed\n" );
- }
+ if (ucoutbuf[0] != (unsigned char) result[maxsize - 1]) {
+ errs++;
+ fprintf(stderr, "unsigned char PROD(rank) test failed\n");
+ }
+ if (ucoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "unsigned char PROD(0) test failed\n");
+ }
+ if (size > 1 && ucoutbuf[2]) {
+ errs++;
+ fprintf(stderr, "unsigned char PROD(>) test failed\n");
+ }
}
#ifndef USE_STRICT_MPI
/* For some reason, complex is not allowed for sum and prod */
if (MPI_DOUBLE_COMPLEX != MPI_DATATYPE_NULL) {
- int dc;
-#ifdef HAVE_LONG_DOUBLE
- ld_complex ldinbuf[3], ldoutbuf[3];
-#endif
- /* Must determine which C type matches this Fortran type */
- MPI_Type_size( MPI_DOUBLE_COMPLEX, &dc );
- if (dc == sizeof(d_complex)) {
- /* double complex; may be null if we do not have Fortran support */
- dinbuf[0].r = (rank < maxsize && rank > 0) ? rank : 1;
- dinbuf[1].r = 0;
- dinbuf[2].r = (rank > 0);
- dinbuf[0].i = 0;
- dinbuf[1].i = 1;
- dinbuf[2].i = -(rank > 0);
-
- doutbuf[0].r = 0;
- doutbuf[1].r = 1;
- doutbuf[2].r = 1;
- doutbuf[0].i = 0;
- doutbuf[1].i = 1;
- doutbuf[2].i = 1;
- MPI_Reduce( dinbuf, doutbuf, 3, MPI_DOUBLE_COMPLEX, MPI_PROD, 0, comm );
- if (rank == 0) {
- double imag, real;
- if (doutbuf[0].r != (double)result[maxsize-1] || doutbuf[0].i != 0) {
- errs++;
- fprintf( stderr, "double complex PROD(rank) test failed\n" );
- }
- /* Multiplying the imaginary part depends on size mod 4 */
- imag = 1.0; real = 0.0; /* Make compiler happy */
- switch (size % 4) {
- case 1: imag = 1.0; real = 0.0; break;
- case 2: imag = 0.0; real = -1.0; break;
- case 3: imag =-1.0; real = 0.0; break;
- case 0: imag = 0.0; real = 1.0; break;
- }
- if (doutbuf[1].r != real || doutbuf[1].i != imag) {
- errs++;
- fprintf( stderr, "double complex PROD(i) test failed (%f,%f)!=(%f,%f)\n",
- doutbuf[1].r,doutbuf[1].i,real,imag);
- }
- if (doutbuf[2].r != 0 || doutbuf[2].i != 0) {
- errs++;
- fprintf( stderr, "double complex PROD(>) test failed\n" );
- }
- }
- }
+ int dc;
#ifdef HAVE_LONG_DOUBLE
- else if (dc == sizeof(ld_complex)) {
- /* double complex; may be null if we do not have Fortran support */
- ldinbuf[0].r = (rank < maxsize && rank > 0) ? rank : 1;
- ldinbuf[1].r = 0;
- ldinbuf[2].r = (rank > 0);
- ldinbuf[0].i = 0;
- ldinbuf[1].i = 1;
- ldinbuf[2].i = -(rank > 0);
-
- ldoutbuf[0].r = 0;
- ldoutbuf[1].r = 1;
- ldoutbuf[2].r = 1;
- ldoutbuf[0].i = 0;
- ldoutbuf[1].i = 1;
- ldoutbuf[2].i = 1;
- MPI_Reduce( ldinbuf, ldoutbuf, 3, MPI_DOUBLE_COMPLEX, MPI_PROD, 0, comm );
- if (rank == 0) {
- long double imag, real;
- if (ldoutbuf[0].r != (double)result[maxsize-1] || ldoutbuf[0].i != 0) {
- errs++;
- fprintf( stderr, "double complex PROD(rank) test failed\n" );
- }
- /* Multiplying the imaginary part depends on size mod 4 */
- imag = 1.0; real = 0.0; /* Make compiler happy */
- switch (size % 4) {
- case 1: imag = 1.0; real = 0.0; break;
- case 2: imag = 0.0; real = -1.0; break;
- case 3: imag =-1.0; real = 0.0; break;
- case 0: imag = 0.0; real = 1.0; break;
- }
- if (ldoutbuf[1].r != real || ldoutbuf[1].i != imag) {
- errs++;
- fprintf( stderr, "double complex PROD(i) test failed (%Lf,%Lf)!=(%Lf,%Lf)\n",
- ldoutbuf[1].r,ldoutbuf[1].i,real,imag);
- }
- if (ldoutbuf[2].r != 0 || ldoutbuf[2].i != 0) {
- errs++;
- fprintf( stderr, "double complex PROD(>) test failed\n" );
- }
- }
- }
+ ld_complex ldinbuf[3], ldoutbuf[3];
+#endif
+ /* Must determine which C type matches this Fortran type */
+ MPI_Type_size(MPI_DOUBLE_COMPLEX, &dc);
+ if (dc == sizeof(d_complex)) {
+ /* double complex; may be null if we do not have Fortran support */
+ dinbuf[0].r = (rank < maxsize && rank > 0) ? rank : 1;
+ dinbuf[1].r = 0;
+ dinbuf[2].r = (rank > 0);
+ dinbuf[0].i = 0;
+ dinbuf[1].i = 1;
+ dinbuf[2].i = -(rank > 0);
+
+ doutbuf[0].r = 0;
+ doutbuf[1].r = 1;
+ doutbuf[2].r = 1;
+ doutbuf[0].i = 0;
+ doutbuf[1].i = 1;
+ doutbuf[2].i = 1;
+ MPI_Reduce(dinbuf, doutbuf, 3, MPI_DOUBLE_COMPLEX, MPI_PROD, 0, comm);
+ if (rank == 0) {
+ double imag, real;
+ if (doutbuf[0].r != (double) result[maxsize - 1] || doutbuf[0].i != 0) {
+ errs++;
+ fprintf(stderr, "double complex PROD(rank) test failed\n");
+ }
+ /* Multiplying the imaginary part depends on size mod 4 */
+ imag = 1.0;
+ real = 0.0; /* Make compiler happy */
+ switch (size % 4) {
+ case 1:
+ imag = 1.0;
+ real = 0.0;
+ break;
+ case 2:
+ imag = 0.0;
+ real = -1.0;
+ break;
+ case 3:
+ imag = -1.0;
+ real = 0.0;
+ break;
+ case 0:
+ imag = 0.0;
+ real = 1.0;
+ break;
+ }
+ if (doutbuf[1].r != real || doutbuf[1].i != imag) {
+ errs++;
+ fprintf(stderr, "double complex PROD(i) test failed (%f,%f)!=(%f,%f)\n",
+ doutbuf[1].r, doutbuf[1].i, real, imag);
+ }
+ if (doutbuf[2].r != 0 || doutbuf[2].i != 0) {
+ errs++;
+ fprintf(stderr, "double complex PROD(>) test failed\n");
+ }
+ }
+ }
+#ifdef HAVE_LONG_DOUBLE
+ else if (dc == sizeof(ld_complex)) {
+ /* double complex; may be null if we do not have Fortran support */
+ ldinbuf[0].r = (rank < maxsize && rank > 0) ? rank : 1;
+ ldinbuf[1].r = 0;
+ ldinbuf[2].r = (rank > 0);
+ ldinbuf[0].i = 0;
+ ldinbuf[1].i = 1;
+ ldinbuf[2].i = -(rank > 0);
+
+ ldoutbuf[0].r = 0;
+ ldoutbuf[1].r = 1;
+ ldoutbuf[2].r = 1;
+ ldoutbuf[0].i = 0;
+ ldoutbuf[1].i = 1;
+ ldoutbuf[2].i = 1;
+ MPI_Reduce(ldinbuf, ldoutbuf, 3, MPI_DOUBLE_COMPLEX, MPI_PROD, 0, comm);
+ if (rank == 0) {
+ long double imag, real;
+ if (ldoutbuf[0].r != (double) result[maxsize - 1] || ldoutbuf[0].i != 0) {
+ errs++;
+ fprintf(stderr, "double complex PROD(rank) test failed\n");
+ }
+ /* Multiplying the imaginary part depends on size mod 4 */
+ imag = 1.0;
+ real = 0.0; /* Make compiler happy */
+ switch (size % 4) {
+ case 1:
+ imag = 1.0;
+ real = 0.0;
+ break;
+ case 2:
+ imag = 0.0;
+ real = -1.0;
+ break;
+ case 3:
+ imag = -1.0;
+ real = 0.0;
+ break;
+ case 0:
+ imag = 0.0;
+ real = 1.0;
+ break;
+ }
+ if (ldoutbuf[1].r != real || ldoutbuf[1].i != imag) {
+ errs++;
+ fprintf(stderr, "double complex PROD(i) test failed (%Lf,%Lf)!=(%Lf,%Lf)\n",
+ ldoutbuf[1].r, ldoutbuf[1].i, real, imag);
+ }
+ if (ldoutbuf[2].r != 0 || ldoutbuf[2].i != 0) {
+ errs++;
+ fprintf(stderr, "double complex PROD(>) test failed\n");
+ }
+ }
+ }
#endif /* HAVE_LONG_DOUBLE */
}
#endif /* USE_STRICT_MPI */
#ifdef HAVE_LONG_DOUBLE
- { long double ldinbuf[3], ldoutbuf[3];
- /* long double */
- ldinbuf[0] = (rank < maxsize && rank > 0) ? rank : 1;
- ldinbuf[1] = 0;
- ldinbuf[2] = (rank > 0);
+ {
+ long double ldinbuf[3], ldoutbuf[3];
+ /* long double */
+ ldinbuf[0] = (rank < maxsize && rank > 0) ? rank : 1;
+ ldinbuf[1] = 0;
+ ldinbuf[2] = (rank > 0);
- ldoutbuf[0] = 0;
- ldoutbuf[1] = 1;
- ldoutbuf[2] = 1;
- if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
- MPI_Reduce( ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_PROD, 0, comm );
- if (rank == 0) {
- if (ldoutbuf[0] != (long double)result[maxsize-1]) {
- errs++;
- fprintf( stderr, "long double PROD(rank) test failed\n" );
- }
- if (ldoutbuf[1]) {
- errs++;
- fprintf( stderr, "long double PROD(0) test failed\n" );
- }
- if (size > 1 && ldoutbuf[2] != 0) {
- errs++;
- fprintf( stderr, "long double PROD(>) test failed\n" );
- }
- }
- }
+ ldoutbuf[0] = 0;
+ ldoutbuf[1] = 1;
+ ldoutbuf[2] = 1;
+ if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
+ MPI_Reduce(ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_PROD, 0, comm);
+ if (rank == 0) {
+ if (ldoutbuf[0] != (long double) result[maxsize - 1]) {
+ errs++;
+ fprintf(stderr, "long double PROD(rank) test failed\n");
+ }
+ if (ldoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "long double PROD(0) test failed\n");
+ }
+ if (size > 1 && ldoutbuf[2] != 0) {
+ errs++;
+ fprintf(stderr, "long double PROD(>) test failed\n");
+ }
+ }
+ }
}
#endif /* HAVE_LONG_DOUBLE */
#ifdef HAVE_LONG_LONG
{
- long long llinbuf[3], lloutbuf[3];
- /* long long */
- llinbuf[0] = (rank < maxsize && rank > 0) ? rank : 1;
- llinbuf[1] = 0;
- llinbuf[2] = (rank > 0);
+ long long llinbuf[3], lloutbuf[3];
+ /* long long */
+ llinbuf[0] = (rank < maxsize && rank > 0) ? rank : 1;
+ llinbuf[1] = 0;
+ llinbuf[2] = (rank > 0);
- lloutbuf[0] = 0;
- lloutbuf[1] = 1;
- lloutbuf[2] = 1;
- if (MPI_LONG_LONG != MPI_DATATYPE_NULL) {
- MPI_Reduce( llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_PROD, 0, comm );
- if (rank == 0) {
- if (lloutbuf[0] != (long long)result[maxsize-1]) {
- errs++;
- fprintf( stderr, "long long PROD(rank) test failed\n" );
- }
- if (lloutbuf[1]) {
- errs++;
- fprintf( stderr, "long long PROD(0) test failed\n" );
- }
- if (size > 1 && lloutbuf[2]) {
- errs++;
- fprintf( stderr, "long long PROD(>) test failed\n" );
- }
- }
- }
+ lloutbuf[0] = 0;
+ lloutbuf[1] = 1;
+ lloutbuf[2] = 1;
+ if (MPI_LONG_LONG != MPI_DATATYPE_NULL) {
+ MPI_Reduce(llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_PROD, 0, comm);
+ if (rank == 0) {
+ if (lloutbuf[0] != (long long) result[maxsize - 1]) {
+ errs++;
+ fprintf(stderr, "long long PROD(rank) test failed\n");
+ }
+ if (lloutbuf[1]) {
+ errs++;
+ fprintf(stderr, "long long PROD(0) test failed\n");
+ }
+ if (size > 1 && lloutbuf[2]) {
+ errs++;
+ fprintf(stderr, "long long PROD(>) test failed\n");
+ }
+ }
+ }
}
#endif /* HAVE_LONG_LONG */
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/opsum.c b/test/mpi/coll/opsum.c
index c9bd5f8..636c001 100644
--- a/test/mpi/coll/opsum.c
+++ b/test/mpi/coll/opsum.c
@@ -13,36 +13,40 @@
static char MTEST_Descrip[] = "Test MPI_SUM operations on optional datatypes dupported by MPICH";
*/
-typedef struct { double r, i; } d_complex;
+typedef struct {
+ double r, i;
+} d_complex;
#ifdef HAVE_LONG_DOUBLE
-typedef struct { long double r, i; } ld_complex;
+typedef struct {
+ long double r, i;
+} ld_complex;
#endif
/*
- * This test looks at the handling of logical and for types that are not
+ * This test looks at the handling of logical and for types that are not
* integers or are not required integers (e.g., long long). MPICH allows
* these as well. A strict MPI test should not include this test.
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size;
- MPI_Comm comm;
+ MPI_Comm comm;
char cinbuf[3], coutbuf[3];
signed char scinbuf[3], scoutbuf[3];
unsigned char ucinbuf[3], ucoutbuf[3];
d_complex dinbuf[3], doutbuf[3];
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
#ifndef USE_STRICT_MPI
/* char */
- MTestPrintfMsg( 10, "Reduce of MPI_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_CHAR\n");
cinbuf[0] = 1;
cinbuf[1] = 0;
cinbuf[2] = (rank > 0);
@@ -50,25 +54,25 @@ int main( int argc, char *argv[] )
coutbuf[0] = 0;
coutbuf[1] = 1;
coutbuf[2] = 1;
- MPI_Reduce( cinbuf, coutbuf, 3, MPI_CHAR, MPI_SUM, 0, comm );
+ MPI_Reduce(cinbuf, coutbuf, 3, MPI_CHAR, MPI_SUM, 0, comm);
if (rank == 0) {
- if (size < 128 && coutbuf[0] != size) {
- errs++;
- fprintf( stderr, "char SUM(1) test failed\n" );
- }
- if (size < 128 && coutbuf[1] != 0) {
- errs++;
- fprintf( stderr, "char SUM(0) test failed\n" );
- }
- if (size < 128 && coutbuf[2] != size - 1) {
- errs++;
- fprintf( stderr, "char SUM(>) test failed\n" );
- }
+ if (size < 128 && coutbuf[0] != size) {
+ errs++;
+ fprintf(stderr, "char SUM(1) test failed\n");
+ }
+ if (size < 128 && coutbuf[1] != 0) {
+ errs++;
+ fprintf(stderr, "char SUM(0) test failed\n");
+ }
+ if (size < 128 && coutbuf[2] != size - 1) {
+ errs++;
+ fprintf(stderr, "char SUM(>) test failed\n");
+ }
}
#endif /* USE_MPI_STRICT */
/* signed char */
- MTestPrintfMsg( 10, "Reduce of MPI_SIGNED_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_SIGNED_CHAR\n");
scinbuf[0] = 1;
scinbuf[1] = 0;
scinbuf[2] = (rank > 0);
@@ -76,24 +80,24 @@ int main( int argc, char *argv[] )
scoutbuf[0] = 0;
scoutbuf[1] = 1;
scoutbuf[2] = 1;
- MPI_Reduce( scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_SUM, 0, comm );
+ MPI_Reduce(scinbuf, scoutbuf, 3, MPI_SIGNED_CHAR, MPI_SUM, 0, comm);
if (rank == 0) {
- if (size < 128 && scoutbuf[0] != size) {
- errs++;
- fprintf( stderr, "signed char SUM(1) test failed\n" );
- }
- if (size < 128 && scoutbuf[1] != 0) {
- errs++;
- fprintf( stderr, "signed char SUM(0) test failed\n" );
- }
- if (size < 128 && scoutbuf[2] != size - 1) {
- errs++;
- fprintf( stderr, "signed char SUM(>) test failed\n" );
- }
+ if (size < 128 && scoutbuf[0] != size) {
+ errs++;
+ fprintf(stderr, "signed char SUM(1) test failed\n");
+ }
+ if (size < 128 && scoutbuf[1] != 0) {
+ errs++;
+ fprintf(stderr, "signed char SUM(0) test failed\n");
+ }
+ if (size < 128 && scoutbuf[2] != size - 1) {
+ errs++;
+ fprintf(stderr, "signed char SUM(>) test failed\n");
+ }
}
/* unsigned char */
- MTestPrintfMsg( 10, "Reduce of MPI_UNSIGNED_CHAR\n" );
+ MTestPrintfMsg(10, "Reduce of MPI_UNSIGNED_CHAR\n");
ucinbuf[0] = 1;
ucinbuf[1] = 0;
ucinbuf[2] = (rank > 0);
@@ -101,166 +105,166 @@ int main( int argc, char *argv[] )
ucoutbuf[0] = 0;
ucoutbuf[1] = 1;
ucoutbuf[2] = 1;
- MPI_Reduce( ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_SUM, 0, comm );
+ MPI_Reduce(ucinbuf, ucoutbuf, 3, MPI_UNSIGNED_CHAR, MPI_SUM, 0, comm);
if (rank == 0) {
- if (size < 128 && ucoutbuf[0] != size) {
- errs++;
- fprintf( stderr, "unsigned char SUM(1) test failed\n" );
- }
- if (size < 128 && ucoutbuf[1]) {
- errs++;
- fprintf( stderr, "unsigned char SUM(0) test failed\n" );
- }
- if (size < 128 && ucoutbuf[2] != size - 1) {
- errs++;
- fprintf( stderr, "unsigned char SUM(>) test failed\n" );
- }
+ if (size < 128 && ucoutbuf[0] != size) {
+ errs++;
+ fprintf(stderr, "unsigned char SUM(1) test failed\n");
+ }
+ if (size < 128 && ucoutbuf[1]) {
+ errs++;
+ fprintf(stderr, "unsigned char SUM(0) test failed\n");
+ }
+ if (size < 128 && ucoutbuf[2] != size - 1) {
+ errs++;
+ fprintf(stderr, "unsigned char SUM(>) test failed\n");
+ }
}
#ifndef USE_STRICT_MPI
/* For some reason, complex is not allowed for sum and prod */
if (MPI_DOUBLE_COMPLEX != MPI_DATATYPE_NULL) {
- int dc;
-#ifdef HAVE_LONG_DOUBLE
- ld_complex ldinbuf[3], ldoutbuf[3];
-#endif
- /* Must determine which C type matches this Fortran type */
- MPI_Type_size( MPI_DOUBLE_COMPLEX, &dc );
- if (dc == sizeof(d_complex)) {
- MTestPrintfMsg( 10, "Reduce of MPI_DOUBLE_COMPLEX\n" );
- /* double complex; may be null if we do not have Fortran support */
- dinbuf[0].r = 1;
- dinbuf[1].r = 0;
- dinbuf[2].r = (rank > 0);
- dinbuf[0].i = -1;
- dinbuf[1].i = 0;
- dinbuf[2].i = -(rank > 0);
-
- doutbuf[0].r = 0;
- doutbuf[1].r = 1;
- doutbuf[2].r = 1;
- doutbuf[0].i = 0;
- doutbuf[1].i = 1;
- doutbuf[2].i = 1;
- MPI_Reduce( dinbuf, doutbuf, 3, MPI_DOUBLE_COMPLEX, MPI_SUM, 0, comm );
- if (rank == 0) {
- if (doutbuf[0].r != size || doutbuf[0].i != -size) {
- errs++;
- fprintf( stderr, "double complex SUM(1) test failed\n" );
- }
- if (doutbuf[1].r != 0 || doutbuf[1].i != 0) {
- errs++;
- fprintf( stderr, "double complex SUM(0) test failed\n" );
- }
- if (doutbuf[2].r != size - 1 || doutbuf[2].i != 1 - size) {
- errs++;
- fprintf( stderr, "double complex SUM(>) test failed\n" );
- }
- }
- }
+ int dc;
#ifdef HAVE_LONG_DOUBLE
- else if (dc == sizeof(ld_complex)) {
- MTestPrintfMsg( 10, "Reduce of MPI_DOUBLE_COMPLEX\n" );
- /* double complex; may be null if we do not have Fortran support */
- ldinbuf[0].r = 1;
- ldinbuf[1].r = 0;
- ldinbuf[2].r = (rank > 0);
- ldinbuf[0].i = -1;
- ldinbuf[1].i = 0;
- ldinbuf[2].i = -(rank > 0);
-
- ldoutbuf[0].r = 0;
- ldoutbuf[1].r = 1;
- ldoutbuf[2].r = 1;
- ldoutbuf[0].i = 0;
- ldoutbuf[1].i = 1;
- ldoutbuf[2].i = 1;
- MPI_Reduce( ldinbuf, ldoutbuf, 3, MPI_DOUBLE_COMPLEX,
- MPI_SUM, 0, comm );
- if (rank == 0) {
- if (ldoutbuf[0].r != size || ldoutbuf[0].i != -size) {
- errs++;
- fprintf( stderr, "double complex SUM(1) test failed\n" );
- }
- if (ldoutbuf[1].r != 0 || ldoutbuf[1].i != 0) {
- errs++;
- fprintf( stderr, "double complex SUM(0) test failed\n" );
- }
- if (ldoutbuf[2].r != size - 1 || ldoutbuf[2].i != 1 - size) {
- errs++;
- fprintf( stderr, "double complex SUM(>) test failed\n" );
- }
- }
- }
+ ld_complex ldinbuf[3], ldoutbuf[3];
#endif
- /* Implicitly ignore if there is no matching C type */
+ /* Must determine which C type matches this Fortran type */
+ MPI_Type_size(MPI_DOUBLE_COMPLEX, &dc);
+ if (dc == sizeof(d_complex)) {
+ MTestPrintfMsg(10, "Reduce of MPI_DOUBLE_COMPLEX\n");
+ /* double complex; may be null if we do not have Fortran support */
+ dinbuf[0].r = 1;
+ dinbuf[1].r = 0;
+ dinbuf[2].r = (rank > 0);
+ dinbuf[0].i = -1;
+ dinbuf[1].i = 0;
+ dinbuf[2].i = -(rank > 0);
+
+ doutbuf[0].r = 0;
+ doutbuf[1].r = 1;
+ doutbuf[2].r = 1;
+ doutbuf[0].i = 0;
+ doutbuf[1].i = 1;
+ doutbuf[2].i = 1;
+ MPI_Reduce(dinbuf, doutbuf, 3, MPI_DOUBLE_COMPLEX, MPI_SUM, 0, comm);
+ if (rank == 0) {
+ if (doutbuf[0].r != size || doutbuf[0].i != -size) {
+ errs++;
+ fprintf(stderr, "double complex SUM(1) test failed\n");
+ }
+ if (doutbuf[1].r != 0 || doutbuf[1].i != 0) {
+ errs++;
+ fprintf(stderr, "double complex SUM(0) test failed\n");
+ }
+ if (doutbuf[2].r != size - 1 || doutbuf[2].i != 1 - size) {
+ errs++;
+ fprintf(stderr, "double complex SUM(>) test failed\n");
+ }
+ }
+ }
+#ifdef HAVE_LONG_DOUBLE
+ else if (dc == sizeof(ld_complex)) {
+ MTestPrintfMsg(10, "Reduce of MPI_DOUBLE_COMPLEX\n");
+ /* double complex; may be null if we do not have Fortran support */
+ ldinbuf[0].r = 1;
+ ldinbuf[1].r = 0;
+ ldinbuf[2].r = (rank > 0);
+ ldinbuf[0].i = -1;
+ ldinbuf[1].i = 0;
+ ldinbuf[2].i = -(rank > 0);
+
+ ldoutbuf[0].r = 0;
+ ldoutbuf[1].r = 1;
+ ldoutbuf[2].r = 1;
+ ldoutbuf[0].i = 0;
+ ldoutbuf[1].i = 1;
+ ldoutbuf[2].i = 1;
+ MPI_Reduce(ldinbuf, ldoutbuf, 3, MPI_DOUBLE_COMPLEX, MPI_SUM, 0, comm);
+ if (rank == 0) {
+ if (ldoutbuf[0].r != size || ldoutbuf[0].i != -size) {
+ errs++;
+ fprintf(stderr, "double complex SUM(1) test failed\n");
+ }
+ if (ldoutbuf[1].r != 0 || ldoutbuf[1].i != 0) {
+ errs++;
+ fprintf(stderr, "double complex SUM(0) test failed\n");
+ }
+ if (ldoutbuf[2].r != size - 1 || ldoutbuf[2].i != 1 - size) {
+ errs++;
+ fprintf(stderr, "double complex SUM(>) test failed\n");
+ }
+ }
+ }
+#endif
+ /* Implicitly ignore if there is no matching C type */
}
#endif /* USE_STRICT_MPI */
#ifdef HAVE_LONG_DOUBLE
- { long double ldinbuf[3], ldoutbuf[3];
- /* long double */
- ldinbuf[0] = 1;
- ldinbuf[1] = 0;
- ldinbuf[2] = (rank > 0);
+ {
+ long double ldinbuf[3], ldoutbuf[3];
+ /* long double */
+ ldinbuf[0] = 1;
+ ldinbuf[1] = 0;
+ ldinbuf[2] = (rank > 0);
- ldoutbuf[0] = 0;
- ldoutbuf[1] = 1;
- ldoutbuf[2] = 1;
- if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
- MTestPrintfMsg( 10, "Reduce of MPI_LONG_DOUBLE\n" );
- MPI_Reduce( ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_SUM, 0, comm );
- if (rank == 0) {
- if (ldoutbuf[0] != size) {
- errs++;
- fprintf( stderr, "long double SUM(1) test failed\n" );
- }
- if (ldoutbuf[1] != 0.0) {
- errs++;
- fprintf( stderr, "long double SUM(0) test failed\n" );
- }
- if (ldoutbuf[2] != size - 1) {
- errs++;
- fprintf( stderr, "long double SUM(>) test failed\n" );
- }
- }
- }
+ ldoutbuf[0] = 0;
+ ldoutbuf[1] = 1;
+ ldoutbuf[2] = 1;
+ if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
+ MTestPrintfMsg(10, "Reduce of MPI_LONG_DOUBLE\n");
+ MPI_Reduce(ldinbuf, ldoutbuf, 3, MPI_LONG_DOUBLE, MPI_SUM, 0, comm);
+ if (rank == 0) {
+ if (ldoutbuf[0] != size) {
+ errs++;
+ fprintf(stderr, "long double SUM(1) test failed\n");
+ }
+ if (ldoutbuf[1] != 0.0) {
+ errs++;
+ fprintf(stderr, "long double SUM(0) test failed\n");
+ }
+ if (ldoutbuf[2] != size - 1) {
+ errs++;
+ fprintf(stderr, "long double SUM(>) test failed\n");
+ }
+ }
+ }
}
#endif
#ifdef HAVE_LONG_LONG
{
- long long llinbuf[3], lloutbuf[3];
- /* long long */
- llinbuf[0] = 1;
- llinbuf[1] = 0;
- llinbuf[2] = (rank > 0);
+ long long llinbuf[3], lloutbuf[3];
+ /* long long */
+ llinbuf[0] = 1;
+ llinbuf[1] = 0;
+ llinbuf[2] = (rank > 0);
- lloutbuf[0] = 0;
- lloutbuf[1] = 1;
- lloutbuf[2] = 1;
- if (MPI_LONG_LONG != MPI_DATATYPE_NULL) {
- MTestPrintfMsg( 10, "Reduce of MPI_LONG_LONG\n" );
- MPI_Reduce( llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_SUM, 0, comm );
- if (rank == 0) {
- if (lloutbuf[0] != size) {
- errs++;
- fprintf( stderr, "long long SUM(1) test failed\n" );
- }
- if (lloutbuf[1] != 0) {
- errs++;
- fprintf( stderr, "long long SUM(0) test failed\n" );
- }
- if (lloutbuf[2] != size - 1) {
- errs++;
- fprintf( stderr, "long long SUM(>) test failed\n" );
- }
- }
- }
+ lloutbuf[0] = 0;
+ lloutbuf[1] = 1;
+ lloutbuf[2] = 1;
+ if (MPI_LONG_LONG != MPI_DATATYPE_NULL) {
+ MTestPrintfMsg(10, "Reduce of MPI_LONG_LONG\n");
+ MPI_Reduce(llinbuf, lloutbuf, 3, MPI_LONG_LONG, MPI_SUM, 0, comm);
+ if (rank == 0) {
+ if (lloutbuf[0] != size) {
+ errs++;
+ fprintf(stderr, "long long SUM(1) test failed\n");
+ }
+ if (lloutbuf[1] != 0) {
+ errs++;
+ fprintf(stderr, "long long SUM(0) test failed\n");
+ }
+ if (lloutbuf[2] != size - 1) {
+ errs++;
+ fprintf(stderr, "long long SUM(>) test failed\n");
+ }
+ }
+ }
}
#endif
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/red3.c b/test/mpi/coll/red3.c
index 32358d9..599d0a3 100644
--- a/test/mpi/coll/red3.c
+++ b/test/mpi/coll/red3.c
@@ -14,9 +14,9 @@ static char MTEST_Descrip[] = "Test MPI_Reduce with non-commutative user-define
*/
/*
* This tests that the reduce operation respects the noncommutative flag.
- * See red4.c for a version that can distinguish between P_{root} P_{root+1}
+ * See red4.c for a version that can distinguish between P_{root} P_{root+1}
* ... P_{root-1} and P_0 ... P_{size-1} . The MPI standard clearly
- * specifies that the result is P_0 ... P_{size-1}, independent of the root
+ * specifies that the result is P_0 ... P_{size-1}, independent of the root
* (see 4.9.4 in MPI-1)
*/
@@ -27,174 +27,181 @@ static char MTEST_Descrip[] = "Test MPI_Reduce with non-commutative user-define
c(i,j) is cin[j+i*matSize]
*/
#define MAXCOL 256
-static int matSize = 0; /* Must be < MAXCOL */
-void uop( void *cinPtr, void *coutPtr, int *count, MPI_Datatype *dtype );
-void uop( void *cinPtr, void *coutPtr, int *count, MPI_Datatype *dtype )
+static int matSize = 0; /* Must be < MAXCOL */
+void uop(void *cinPtr, void *coutPtr, int *count, MPI_Datatype * dtype);
+void uop(void *cinPtr, void *coutPtr, int *count, MPI_Datatype * dtype)
{
- const int *cin = (const int *)cinPtr;
- int *cout = (int *)coutPtr;
+ const int *cin = (const int *) cinPtr;
+ int *cout = (int *) coutPtr;
int i, j, k, nmat;
int tempCol[MAXCOL];
for (nmat = 0; nmat < *count; nmat++) {
- for (j=0; j<matSize; j++) {
- for (i=0; i<matSize; i++) {
- tempCol[i] = 0;
- for (k=0; k<matSize; k++) {
- /* col[i] += cin(i,k) * cout(k,j) */
- tempCol[i] += cin[k+i*matSize] * cout[j+k*matSize];
- }
- }
- for (i=0; i<matSize; i++) {
- cout[j+i*matSize] = tempCol[i];
- }
- }
+ for (j = 0; j < matSize; j++) {
+ for (i = 0; i < matSize; i++) {
+ tempCol[i] = 0;
+ for (k = 0; k < matSize; k++) {
+ /* col[i] += cin(i,k) * cout(k,j) */
+ tempCol[i] += cin[k + i * matSize] * cout[j + k * matSize];
+ }
+ }
+ for (i = 0; i < matSize; i++) {
+ cout[j + i * matSize] = tempCol[i];
+ }
+ }
}
}
/* Initialize the integer matrix as a permutation of rank with rank+1.
If we call this matrix P_r, we know that product of P_0 P_1 ... P_{size-2}
is a left shift by 1.
-*/
+*/
-static void initMat( MPI_Comm comm, int mat[] )
+static void initMat(MPI_Comm comm, int mat[])
{
int i, size, rank;
-
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
- for (i=0; i<size*size; i++) mat[i] = 0;
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+
+ for (i = 0; i < size * size; i++)
+ mat[i] = 0;
/* For each row */
- for (i=0; i<size; i++) {
- if (rank != size - 1) {
- if (i == rank) mat[((i+1)%size) + i * size] = 1;
- else if (i == ((rank + 1)%size)) mat[((i+size-1)%size) + i * size] = 1;
- else mat[i+i*size] = 1;
- }
- else {
- mat[i+i*size] = 1;
- }
+ for (i = 0; i < size; i++) {
+ if (rank != size - 1) {
+ if (i == rank)
+ mat[((i + 1) % size) + i * size] = 1;
+ else if (i == ((rank + 1) % size))
+ mat[((i + size - 1) % size) + i * size] = 1;
+ else
+ mat[i + i * size] = 1;
+ }
+ else {
+ mat[i + i * size] = 1;
+ }
}
}
#ifdef FOO
/* Compare a matrix with the identity matrix */
-static int isIdentity( MPI_Comm comm, int mat[] )
+static int isIdentity(MPI_Comm comm, int mat[])
{
int i, j, size, rank, errs = 0;
-
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
-
- for (i=0; i<size; i++) {
- for (j=0; j<size; j++) {
- if (i == j) {
- if (mat[j+i*size] != 1) {
- errs++;
- }
- }
- else {
- if (mat[j+i*size] != 0) {
- errs++;
- }
- }
- }
+
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+
+ for (i = 0; i < size; i++) {
+ for (j = 0; j < size; j++) {
+ if (i == j) {
+ if (mat[j + i * size] != 1) {
+ errs++;
+ }
+ }
+ else {
+ if (mat[j + i * size] != 0) {
+ errs++;
+ }
+ }
+ }
}
return errs;
}
#endif
/* Compare a matrix with the identity matrix */
-static int isShiftLeft( MPI_Comm comm, int mat[] )
+static int isShiftLeft(MPI_Comm comm, int mat[])
{
int i, j, size, rank, errs = 0;
-
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
-
- for (i=0; i<size; i++) {
- for (j=0; j<size; j++) {
- if (i == ((j + 1) % size)) {
- if (mat[j+i*size] != 1) {
- errs++;
- }
- }
- else {
- if (mat[j+i*size] != 0) {
- errs++;
- }
- }
- }
+
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+
+ for (i = 0; i < size; i++) {
+ for (j = 0; j < size; j++) {
+ if (i == ((j + 1) % size)) {
+ if (mat[j + i * size] != 1) {
+ errs++;
+ }
+ }
+ else {
+ if (mat[j + i * size] != 0) {
+ errs++;
+ }
+ }
+ }
}
return errs;
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size, root;
- int minsize = 2, count;
- MPI_Comm comm;
+ int minsize = 2, count;
+ MPI_Comm comm;
int *buf, *bufout;
MPI_Op op;
MPI_Datatype mattype;
- MTest_Init( &argc, &argv );
-
- MPI_Op_create( uop, 0, &op );
-
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
-
- MPI_Comm_size( comm, &size );
- MPI_Comm_rank( comm, &rank );
-
- matSize = size; /* used by the user-defined operation */
- /* Only one matrix for now */
- count = 1;
-
- /* A single matrix, the size of the communicator */
- MPI_Type_contiguous( size*size, MPI_INT, &mattype );
- MPI_Type_commit( &mattype );
-
- buf = (int *)malloc( count * size * size * sizeof(int) );
- if (!buf) MPI_Abort( MPI_COMM_WORLD, 1 );
- bufout = (int *)malloc( count * size * size * sizeof(int) );
- if (!bufout) MPI_Abort( MPI_COMM_WORLD, 1 );
-
- for (root = 0; root < size; root ++) {
- initMat( comm, buf );
- MPI_Reduce( buf, bufout, count, mattype, op, root, comm );
- if (rank == root) {
- errs += isShiftLeft( comm, bufout );
- }
-
- /* Try the same test, but using MPI_IN_PLACE */
- initMat( comm, bufout );
- if (rank == root) {
- MPI_Reduce( MPI_IN_PLACE, bufout, count, mattype, op, root, comm );
- }
- else {
- MPI_Reduce( bufout, NULL, count, mattype, op, root, comm );
- }
- if (rank == root) {
- errs += isShiftLeft( comm, bufout );
- }
- }
-
- free( buf );
- free( bufout );
-
- MPI_Type_free( &mattype );
-
- MTestFreeComm( &comm );
+ MTest_Init(&argc, &argv);
+
+ MPI_Op_create(uop, 0, &op);
+
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
+
+ matSize = size; /* used by the user-defined operation */
+ /* Only one matrix for now */
+ count = 1;
+
+ /* A single matrix, the size of the communicator */
+ MPI_Type_contiguous(size * size, MPI_INT, &mattype);
+ MPI_Type_commit(&mattype);
+
+ buf = (int *) malloc(count * size * size * sizeof(int));
+ if (!buf)
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ bufout = (int *) malloc(count * size * size * sizeof(int));
+ if (!bufout)
+ MPI_Abort(MPI_COMM_WORLD, 1);
+
+ for (root = 0; root < size; root++) {
+ initMat(comm, buf);
+ MPI_Reduce(buf, bufout, count, mattype, op, root, comm);
+ if (rank == root) {
+ errs += isShiftLeft(comm, bufout);
+ }
+
+ /* Try the same test, but using MPI_IN_PLACE */
+ initMat(comm, bufout);
+ if (rank == root) {
+ MPI_Reduce(MPI_IN_PLACE, bufout, count, mattype, op, root, comm);
+ }
+ else {
+ MPI_Reduce(bufout, NULL, count, mattype, op, root, comm);
+ }
+ if (rank == root) {
+ errs += isShiftLeft(comm, bufout);
+ }
+ }
+
+ free(buf);
+ free(bufout);
+
+ MPI_Type_free(&mattype);
+
+ MTestFreeComm(&comm);
}
- MPI_Op_free( &op );
+ MPI_Op_free(&op);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/red4.c b/test/mpi/coll/red4.c
index a3e9183..f69668d 100644
--- a/test/mpi/coll/red4.c
+++ b/test/mpi/coll/red4.c
@@ -15,9 +15,9 @@ static char MTEST_Descrip[] = "Test MPI_Reduce with non-commutative user-define
/*
* This tests that the reduce operation respects the noncommutative flag.
- * and that can distinguish between P_{root} P_{root+1}
+ * and that can distinguish between P_{root} P_{root+1}
* ... P_{root-1} and P_0 ... P_{size-1} . The MPI standard clearly
- * specifies that the result is P_0 ... P_{size-1}, independent of the root
+ * specifies that the result is P_0 ... P_{size-1}, independent of the root
* (see 4.9.4 in MPI-1)
*/
@@ -28,34 +28,35 @@ static char MTEST_Descrip[] = "Test MPI_Reduce with non-commutative user-define
c(i,j) is cin[j+i*matSize]
*/
#define MAXCOL 256
-static int matSize = 0; /* Must be < MAXCOL */
+static int matSize = 0; /* Must be < MAXCOL */
-void uop( void *cinPtr, void *coutPtr, int *count, MPI_Datatype *dtype );
-void uop( void *cinPtr, void *coutPtr, int *count, MPI_Datatype *dtype )
+void uop(void *cinPtr, void *coutPtr, int *count, MPI_Datatype * dtype);
+void uop(void *cinPtr, void *coutPtr, int *count, MPI_Datatype * dtype)
{
const int *cin;
- int *cout;
- int i, j, k, nmat;
- int tempCol[MAXCOL];
+ int *cout;
+ int i, j, k, nmat;
+ int tempCol[MAXCOL];
- if (*count != 1) printf( "Panic!\n" );
+ if (*count != 1)
+ printf("Panic!\n");
for (nmat = 0; nmat < *count; nmat++) {
- cin = (const int *)cinPtr;
- cout = (int *)coutPtr;
- for (j=0; j<matSize; j++) {
- for (i=0; i<matSize; i++) {
- tempCol[i] = 0;
- for (k=0; k<matSize; k++) {
- /* col[i] += cin(i,k) * cout(k,j) */
- tempCol[i] += cin[k+i*matSize] * cout[j+k*matSize];
- }
- }
- for (i=0; i<matSize; i++) {
- cout[j+i*matSize] = tempCol[i];
- }
- }
- cinPtr = (int *)cinPtr + matSize*matSize;
- coutPtr = (int *)coutPtr + matSize*matSize;
+ cin = (const int *) cinPtr;
+ cout = (int *) coutPtr;
+ for (j = 0; j < matSize; j++) {
+ for (i = 0; i < matSize; i++) {
+ tempCol[i] = 0;
+ for (k = 0; k < matSize; k++) {
+ /* col[i] += cin(i,k) * cout(k,j) */
+ tempCol[i] += cin[k + i * matSize] * cout[j + k * matSize];
+ }
+ }
+ for (i = 0; i < matSize; i++) {
+ cout[j + i * matSize] = tempCol[i];
+ }
+ }
+ cinPtr = (int *) cinPtr + matSize * matSize;
+ coutPtr = (int *) coutPtr + matSize * matSize;
}
}
@@ -63,55 +64,56 @@ void uop( void *cinPtr, void *coutPtr, int *count, MPI_Datatype *dtype )
If we call this matrix P_r, we know that product of P_0 P_1 ... P_{size-1}
is the matrix with rows ordered as
1,size,2,3,4,...,size-1
- (The matrix is basically a circular shift right,
+ (The matrix is basically a circular shift right,
shifting right n-1 steps for an n x n dimensional matrix, with the last
step swapping rows 1 and size)
-*/
+*/
-static void initMat( MPI_Comm comm, int mat[] )
+static void initMat(MPI_Comm comm, int mat[])
{
int i, size, rank;
-
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
/* Remember the matrix size */
matSize = size;
- for (i=0; i<matSize*matSize; i++) mat[i] = 0;
+ for (i = 0; i < matSize * matSize; i++)
+ mat[i] = 0;
- for (i=0; i<matSize; i++) {
- if (i == rank)
- mat[((i+1)%matSize) + i * matSize] = 1;
- else if (i == ((rank + 1)%matSize))
- mat[((i+matSize-1)%matSize) + i * matSize] = 1;
- else
- mat[i+i*matSize] = 1;
+ for (i = 0; i < matSize; i++) {
+ if (i == rank)
+ mat[((i + 1) % matSize) + i * matSize] = 1;
+ else if (i == ((rank + 1) % matSize))
+ mat[((i + matSize - 1) % matSize) + i * matSize] = 1;
+ else
+ mat[i + i * matSize] = 1;
}
}
/* Compare a matrix with the identity matrix */
/*
-static int isIdentity( MPI_Comm comm, int mat[] )
+static int isIdentity(MPI_Comm comm, int mat[])
{
int i, j, size, rank, errs = 0;
-
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
for (i=0; i<size; i++) {
for (j=0; j<size; j++) {
if (j == i) {
if (mat[j+i*size] != 1) {
- printf( "mat(%d,%d) = %d, should = 1\n",
- i, j, mat[j+i*size] );
+ printf("mat(%d,%d) = %d, should = 1\n",
+ i, j, mat[j+i*size]);
errs++;
}
}
else {
if (mat[j+i*size] != 0) {
- printf( "mat(%d,%d) = %d, should = 0\n",
- i, j, mat[j+i*size] );
+ printf("mat(%d,%d) = %d, should = 0\n",
+ i, j, mat[j+i*size]);
errs++;
}
}
@@ -123,137 +125,134 @@ static int isIdentity( MPI_Comm comm, int mat[] )
/* Compare a matrix with the identity matrix with rows permuted to as rows
1,size,2,3,4,5,...,size-1 */
-static int isPermutedIdentity( MPI_Comm comm, int mat[] )
+static int isPermutedIdentity(MPI_Comm comm, int mat[])
{
int i, j, size, rank, errs = 0;
-
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
/* Check the first two last rows */
i = 0;
- for (j=0; j<size; j++) {
- if (j==0) {
- if (mat[j] != 1) {
- printf( "mat(%d,%d) = %d, should = 1\n",
- i, j, mat[j] );
- errs++;
- }
- }
- else {
- if (mat[j] != 0) {
- printf( "mat(%d,%d) = %d, should = 0\n",
- i, j, mat[j] );
- errs++;
- }
- }
+ for (j = 0; j < size; j++) {
+ if (j == 0) {
+ if (mat[j] != 1) {
+ printf("mat(%d,%d) = %d, should = 1\n", i, j, mat[j]);
+ errs++;
+ }
+ }
+ else {
+ if (mat[j] != 0) {
+ printf("mat(%d,%d) = %d, should = 0\n", i, j, mat[j]);
+ errs++;
+ }
+ }
}
i = 1;
- for (j=0; j<size; j++) {
- if (j==size-1) {
- if (mat[j+i*size] != 1) {
- printf( "mat(%d,%d) = %d, should = 1\n",
- i, j, mat[j+i*size] );
- errs++;
- }
- }
- else {
- if (mat[j+i*size] != 0) {
- printf( "mat(%d,%d) = %d, should = 0\n",
- i, j, mat[j+i*size] );
- errs++;
- }
- }
+ for (j = 0; j < size; j++) {
+ if (j == size - 1) {
+ if (mat[j + i * size] != 1) {
+ printf("mat(%d,%d) = %d, should = 1\n", i, j, mat[j + i * size]);
+ errs++;
+ }
+ }
+ else {
+ if (mat[j + i * size] != 0) {
+ printf("mat(%d,%d) = %d, should = 0\n", i, j, mat[j + i * size]);
+ errs++;
+ }
+ }
}
/* The remaint rows are shifted down by one */
- for (i=2; i<size; i++) {
- for (j=0; j<size; j++) {
- if (j == i-1) {
- if (mat[j+i*size] != 1) {
- printf( "mat(%d,%d) = %d, should = 1\n",
- i, j, mat[j+i*size] );
- errs++;
- }
- }
- else {
- if (mat[j+i*size] != 0) {
- printf( "mat(%d,%d) = %d, should = 0\n",
- i, j, mat[j+i*size] );
- errs++;
- }
- }
- }
+ for (i = 2; i < size; i++) {
+ for (j = 0; j < size; j++) {
+ if (j == i - 1) {
+ if (mat[j + i * size] != 1) {
+ printf("mat(%d,%d) = %d, should = 1\n", i, j, mat[j + i * size]);
+ errs++;
+ }
+ }
+ else {
+ if (mat[j + i * size] != 0) {
+ printf("mat(%d,%d) = %d, should = 0\n", i, j, mat[j + i * size]);
+ errs++;
+ }
+ }
+ }
}
return errs;
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size, root;
- int minsize = 2, count;
- MPI_Comm comm;
+ int minsize = 2, count;
+ MPI_Comm comm;
int *buf, *bufout;
MPI_Op op;
MPI_Datatype mattype;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Op_create( uop, 0, &op );
-
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
- MPI_Comm_size( comm, &size );
- MPI_Comm_rank( comm, &rank );
+ MPI_Op_create(uop, 0, &op);
- if (size > MAXCOL) {
- /* Skip because there are too many processes */
- MTestFreeComm( &comm );
- continue;
- }
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
- /* Only one matrix for now */
- count = 1;
+ if (size > MAXCOL) {
+ /* Skip because there are too many processes */
+ MTestFreeComm(&comm);
+ continue;
+ }
- /* A single matrix, the size of the communicator */
- MPI_Type_contiguous( size*size, MPI_INT, &mattype );
- MPI_Type_commit( &mattype );
-
- buf = (int *)malloc( count * size * size * sizeof(int) );
- if (!buf) MPI_Abort( MPI_COMM_WORLD, 1 );
- bufout = (int *)malloc( count * size * size * sizeof(int) );
- if (!bufout) MPI_Abort( MPI_COMM_WORLD, 1 );
+ /* Only one matrix for now */
+ count = 1;
- for (root = 0; root < size; root ++) {
- initMat( comm, buf );
- MPI_Reduce( buf, bufout, count, mattype, op, root, comm );
- if (rank == root) {
- errs += isPermutedIdentity( comm, bufout );
- }
+ /* A single matrix, the size of the communicator */
+ MPI_Type_contiguous(size * size, MPI_INT, &mattype);
+ MPI_Type_commit(&mattype);
- /* Try the same test, but using MPI_IN_PLACE */
- initMat( comm, bufout );
- if (rank == root) {
- MPI_Reduce( MPI_IN_PLACE, bufout, count, mattype, op, root, comm );
- }
- else {
- MPI_Reduce( bufout, NULL, count, mattype, op, root, comm );
- }
- if (rank == root) {
- errs += isPermutedIdentity( comm, bufout );
- }
- }
- MPI_Type_free( &mattype );
+ buf = (int *) malloc(count * size * size * sizeof(int));
+ if (!buf)
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ bufout = (int *) malloc(count * size * size * sizeof(int));
+ if (!bufout)
+ MPI_Abort(MPI_COMM_WORLD, 1);
+
+ for (root = 0; root < size; root++) {
+ initMat(comm, buf);
+ MPI_Reduce(buf, bufout, count, mattype, op, root, comm);
+ if (rank == root) {
+ errs += isPermutedIdentity(comm, bufout);
+ }
+
+ /* Try the same test, but using MPI_IN_PLACE */
+ initMat(comm, bufout);
+ if (rank == root) {
+ MPI_Reduce(MPI_IN_PLACE, bufout, count, mattype, op, root, comm);
+ }
+ else {
+ MPI_Reduce(bufout, NULL, count, mattype, op, root, comm);
+ }
+ if (rank == root) {
+ errs += isPermutedIdentity(comm, bufout);
+ }
+ }
+ MPI_Type_free(&mattype);
- free( buf );
- free( bufout );
+ free(buf);
+ free(bufout);
- MTestFreeComm( &comm );
+ MTestFreeComm(&comm);
}
- MPI_Op_free( &op );
+ MPI_Op_free(&op);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/red_scat_block.c b/test/mpi/coll/red_scat_block.c
index 3092c8d..2884708 100644
--- a/test/mpi/coll/red_scat_block.c
+++ b/test/mpi/coll/red_scat_block.c
@@ -40,12 +40,12 @@ int main(int argc, char **argv)
fprintf(stderr, "unable to allocate send/recv buffers, aborting");
MPI_Abort(MPI_COMM_WORLD, 1);
}
- for (i=0; i<size; i++)
+ for (i = 0; i < size; i++)
sendbuf[i] = rank + i;
MPI_Reduce_scatter_block(sendbuf, recvbuf, 1, MPI_INT, MPI_SUM, comm);
- sumval = size * rank + ((size - 1) * size)/2;
+ sumval = size * rank + ((size - 1) * size) / 2;
if (recvbuf[0] != sumval) {
err++;
fprintf(stdout, "Did not get expected value for reduce scatter block\n");
@@ -55,12 +55,12 @@ int main(int argc, char **argv)
free(sendbuf);
/* let's try it again with MPI_IN_PLACE this time */
- for (i=0; i<size; i++)
+ for (i = 0; i < size; i++)
recvbuf[i] = rank + i;
MPI_Reduce_scatter_block(MPI_IN_PLACE, recvbuf, 1, MPI_INT, MPI_SUM, comm);
- sumval = size * rank + ((size - 1) * size)/2;
+ sumval = size * rank + ((size - 1) * size) / 2;
if (recvbuf[0] != sumval) {
err++;
fprintf(stdout, "Did not get expected value for reduce scatter block\n");
diff --git a/test/mpi/coll/red_scat_block2.c b/test/mpi/coll/red_scat_block2.c
index 4451b88..aa0817c 100644
--- a/test/mpi/coll/red_scat_block2.c
+++ b/test/mpi/coll/red_scat_block2.c
@@ -3,7 +3,7 @@
* (C) 2009 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-/*
+/*
* Test of reduce_scatter_block.
*
* Checks that non-commutative operations are not commuted and that
@@ -20,15 +20,14 @@
int err = 0;
/* left(x,y) ==> x */
-void left(void *a, void *b, int *count, MPI_Datatype *type);
-void left(void *a, void *b, int *count, MPI_Datatype *type)
+void left(void *a, void *b, int *count, MPI_Datatype * type);
+void left(void *a, void *b, int *count, MPI_Datatype * type)
{
int *in = a;
int *inout = b;
int i;
- for (i = 0; i < *count; ++i)
- {
+ for (i = 0; i < *count; ++i) {
if (in[i] > inout[i])
++err;
inout[i] = in[i];
@@ -36,15 +35,14 @@ void left(void *a, void *b, int *count, MPI_Datatype *type)
}
/* right(x,y) ==> y */
-void right(void *a, void *b, int *count, MPI_Datatype *type);
-void right(void *a, void *b, int *count, MPI_Datatype *type)
+void right(void *a, void *b, int *count, MPI_Datatype * type);
+void right(void *a, void *b, int *count, MPI_Datatype * type)
{
int *in = a;
int *inout = b;
int i;
- for (i = 0; i < *count; ++i)
- {
+ for (i = 0; i < *count; ++i) {
if (in[i] > inout[i])
++err;
inout[i] = inout[i];
@@ -53,64 +51,66 @@ void right(void *a, void *b, int *count, MPI_Datatype *type)
/* Just performs a simple sum but can be marked as non-commutative to
potentially tigger different logic in the implementation. */
-void nc_sum(void *a, void *b, int *count, MPI_Datatype *type);
-void nc_sum(void *a, void *b, int *count, MPI_Datatype *type)
+void nc_sum(void *a, void *b, int *count, MPI_Datatype * type);
+void nc_sum(void *a, void *b, int *count, MPI_Datatype * type)
{
int *in = a;
int *inout = b;
int i;
- for (i = 0; i < *count; ++i)
- {
+ for (i = 0; i < *count; ++i) {
inout[i] = in[i] + inout[i];
}
}
#define MAX_BLOCK_SIZE 256
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- int *sendbuf;
- int block_size;
- int *recvbuf;
- int size, rank, i;
+ int *sendbuf;
+ int block_size;
+ int *recvbuf;
+ int size, rank, i;
MPI_Comm comm;
MPI_Op left_op, right_op, nc_sum_op;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_size( comm, &size );
- MPI_Comm_rank( comm, &rank );
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
/* MPI_Reduce_scatter block was added in MPI-2.2 */
- MPI_Op_create(&left, 0/*non-commutative*/, &left_op);
- MPI_Op_create(&right, 0/*non-commutative*/, &right_op);
- MPI_Op_create(&nc_sum, 0/*non-commutative*/, &nc_sum_op);
+ MPI_Op_create(&left, 0 /*non-commutative */ , &left_op);
+ MPI_Op_create(&right, 0 /*non-commutative */ , &right_op);
+ MPI_Op_create(&nc_sum, 0 /*non-commutative */ , &nc_sum_op);
for (block_size = 1; block_size < MAX_BLOCK_SIZE; block_size *= 2) {
- sendbuf = (int *) malloc( block_size * size * sizeof(int) );
- recvbuf = malloc( block_size * sizeof(int) );
+ sendbuf = (int *) malloc(block_size * size * sizeof(int));
+ recvbuf = malloc(block_size * sizeof(int));
- for (i=0; i<(size*block_size); i++)
+ for (i = 0; i < (size * block_size); i++)
sendbuf[i] = rank + i;
- for (i=0; i<block_size; i++)
+ for (i = 0; i < block_size; i++)
recvbuf[i] = 0xdeadbeef;
- MPI_Reduce_scatter_block( sendbuf, recvbuf, block_size, MPI_INT, left_op, comm );
+ MPI_Reduce_scatter_block(sendbuf, recvbuf, block_size, MPI_INT, left_op, comm);
for (i = 0; i < block_size; ++i)
- if (recvbuf[i] != (rank * block_size + i)) ++err;
+ if (recvbuf[i] != (rank * block_size + i))
+ ++err;
- MPI_Reduce_scatter_block( sendbuf, recvbuf, block_size, MPI_INT, right_op, comm );
+ MPI_Reduce_scatter_block(sendbuf, recvbuf, block_size, MPI_INT, right_op, comm);
for (i = 0; i < block_size; ++i)
- if (recvbuf[i] != ((size - 1) + (rank * block_size) + i)) ++err;
+ if (recvbuf[i] != ((size - 1) + (rank * block_size) + i))
+ ++err;
- MPI_Reduce_scatter_block( sendbuf, recvbuf, block_size, MPI_INT, nc_sum_op, comm );
+ MPI_Reduce_scatter_block(sendbuf, recvbuf, block_size, MPI_INT, nc_sum_op, comm);
for (i = 0; i < block_size; ++i) {
int x = rank * block_size + i;
- if (recvbuf[i] != (size*x + (size-1)*size/2)) ++err;
+ if (recvbuf[i] != (size * x + (size - 1) * size / 2))
+ ++err;
}
free(recvbuf);
@@ -120,10 +120,10 @@ int main( int argc, char **argv )
MPI_Op_free(&left_op);
MPI_Op_free(&right_op);
MPI_Op_free(&nc_sum_op);
-#endif
+#endif
- MTest_Finalize( err );
- MPI_Finalize( );
+ MTest_Finalize(err);
+ MPI_Finalize();
return err;
}
diff --git a/test/mpi/coll/redscat.c b/test/mpi/coll/redscat.c
index 46d59ba..75bb5a4 100644
--- a/test/mpi/coll/redscat.c
+++ b/test/mpi/coll/redscat.c
@@ -3,10 +3,10 @@
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-/*
+/*
* Test of reduce scatter.
*
- * Each processor contributes its rank + the index to the reduction,
+ * Each processor contributes its rank + the index to the reduction,
* then receives the ith sum
*
* Can be called with any number of processors.
@@ -17,41 +17,41 @@
#include <stdlib.h>
#include "mpicolltest.h"
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- int err = 0, toterr;
- int *sendbuf, recvbuf, *recvcounts;
- int size, rank, i, sumval;
+ int err = 0, toterr;
+ int *sendbuf, recvbuf, *recvcounts;
+ int size, rank, i, sumval;
MPI_Comm comm;
- MPI_Init( &argc, &argv );
+ MPI_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_size( comm, &size );
- MPI_Comm_rank( comm, &rank );
- sendbuf = (int *) malloc( size * sizeof(int) );
- for (i=0; i<size; i++)
- sendbuf[i] = rank + i;
- recvcounts = (int *)malloc( size * sizeof(int) );
- for (i=0; i<size; i++)
- recvcounts[i] = 1;
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
+ sendbuf = (int *) malloc(size * sizeof(int));
+ for (i = 0; i < size; i++)
+ sendbuf[i] = rank + i;
+ recvcounts = (int *) malloc(size * sizeof(int));
+ for (i = 0; i < size; i++)
+ recvcounts[i] = 1;
- MTest_Reduce_scatter( sendbuf, &recvbuf, recvcounts, MPI_INT, MPI_SUM, comm );
+ MTest_Reduce_scatter(sendbuf, &recvbuf, recvcounts, MPI_INT, MPI_SUM, comm);
- sumval = size * rank + ((size - 1) * size)/2;
+ sumval = size * rank + ((size - 1) * size) / 2;
/* recvbuf should be size * (rank + i) */
if (recvbuf != sumval) {
- err++;
- fprintf( stdout, "Did not get expected value for reduce scatter\n" );
- fprintf( stdout, "[%d] Got %d expected %d\n", rank, recvbuf, sumval );
+ err++;
+ fprintf(stdout, "Did not get expected value for reduce scatter\n");
+ fprintf(stdout, "[%d] Got %d expected %d\n", rank, recvbuf, sumval);
}
- MPI_Allreduce( &err, &toterr, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
+ MPI_Allreduce(&err, &toterr, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
if (rank == 0 && toterr == 0) {
- printf( " No Errors\n" );
+ printf(" No Errors\n");
}
- MPI_Finalize( );
+ MPI_Finalize();
return toterr;
}
diff --git a/test/mpi/coll/redscat2.c b/test/mpi/coll/redscat2.c
index f77bad8..2c01ba7 100644
--- a/test/mpi/coll/redscat2.c
+++ b/test/mpi/coll/redscat2.c
@@ -3,7 +3,7 @@
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-/*
+/*
* Test of reduce scatter.
*
* Checks that non-commutative operations are not commuted and that
@@ -20,15 +20,14 @@
int err = 0;
/* left(x,y) ==> x */
-void left(void *a, void *b, int *count, MPI_Datatype *type);
-void left(void *a, void *b, int *count, MPI_Datatype *type)
+void left(void *a, void *b, int *count, MPI_Datatype * type);
+void left(void *a, void *b, int *count, MPI_Datatype * type)
{
int *in = a;
int *inout = b;
int i;
- for (i = 0; i < *count; ++i)
- {
+ for (i = 0; i < *count; ++i) {
if (in[i] > inout[i])
++err;
inout[i] = in[i];
@@ -36,15 +35,14 @@ void left(void *a, void *b, int *count, MPI_Datatype *type)
}
/* right(x,y) ==> y */
-void right(void *a, void *b, int *count, MPI_Datatype *type);
-void right(void *a, void *b, int *count, MPI_Datatype *type)
+void right(void *a, void *b, int *count, MPI_Datatype * type);
+void right(void *a, void *b, int *count, MPI_Datatype * type)
{
int *in = a;
int *inout = b;
int i;
- for (i = 0; i < *count; ++i)
- {
+ for (i = 0; i < *count; ++i) {
if (in[i] > inout[i])
++err;
inout[i] = inout[i];
@@ -53,64 +51,66 @@ void right(void *a, void *b, int *count, MPI_Datatype *type)
/* Just performs a simple sum but can be marked as non-commutative to
potentially tigger different logic in the implementation. */
-void nc_sum(void *a, void *b, int *count, MPI_Datatype *type);
-void nc_sum(void *a, void *b, int *count, MPI_Datatype *type)
+void nc_sum(void *a, void *b, int *count, MPI_Datatype * type);
+void nc_sum(void *a, void *b, int *count, MPI_Datatype * type)
{
int *in = a;
int *inout = b;
int i;
- for (i = 0; i < *count; ++i)
- {
+ for (i = 0; i < *count; ++i) {
inout[i] = in[i] + inout[i];
}
}
#define MAX_BLOCK_SIZE 256
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- int *sendbuf, *recvcounts;
- int block_size;
- int *recvbuf;
- int size, rank, i;
+ int *sendbuf, *recvcounts;
+ int block_size;
+ int *recvbuf;
+ int size, rank, i;
MPI_Comm comm;
MPI_Op left_op, right_op, nc_sum_op;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_size( comm, &size );
- MPI_Comm_rank( comm, &rank );
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
- MPI_Op_create(&left, 0/*non-commutative*/, &left_op);
- MPI_Op_create(&right, 0/*non-commutative*/, &right_op);
- MPI_Op_create(&nc_sum, 0/*non-commutative*/, &nc_sum_op);
+ MPI_Op_create(&left, 0 /*non-commutative */ , &left_op);
+ MPI_Op_create(&right, 0 /*non-commutative */ , &right_op);
+ MPI_Op_create(&nc_sum, 0 /*non-commutative */ , &nc_sum_op);
for (block_size = 1; block_size < MAX_BLOCK_SIZE; block_size *= 2) {
- sendbuf = (int *) malloc( block_size * size * sizeof(int) );
- recvbuf = malloc( block_size * sizeof(int) );
+ sendbuf = (int *) malloc(block_size * size * sizeof(int));
+ recvbuf = malloc(block_size * sizeof(int));
- for (i=0; i<(size*block_size); i++)
+ for (i = 0; i < (size * block_size); i++)
sendbuf[i] = rank + i;
- for (i=0; i<block_size; i++)
+ for (i = 0; i < block_size; i++)
recvbuf[i] = 0xdeadbeef;
- recvcounts = (int *)malloc( size * sizeof(int) );
- for (i=0; i<size; i++)
+ recvcounts = (int *) malloc(size * sizeof(int));
+ for (i = 0; i < size; i++)
recvcounts[i] = block_size;
- MPI_Reduce_scatter( sendbuf, recvbuf, recvcounts, MPI_INT, left_op, comm );
+ MPI_Reduce_scatter(sendbuf, recvbuf, recvcounts, MPI_INT, left_op, comm);
for (i = 0; i < block_size; ++i)
- if (recvbuf[i] != (rank * block_size + i)) ++err;
+ if (recvbuf[i] != (rank * block_size + i))
+ ++err;
- MPI_Reduce_scatter( sendbuf, recvbuf, recvcounts, MPI_INT, right_op, comm );
+ MPI_Reduce_scatter(sendbuf, recvbuf, recvcounts, MPI_INT, right_op, comm);
for (i = 0; i < block_size; ++i)
- if (recvbuf[i] != ((size - 1) + (rank * block_size) + i)) ++err;
+ if (recvbuf[i] != ((size - 1) + (rank * block_size) + i))
+ ++err;
- MPI_Reduce_scatter( sendbuf, recvbuf, recvcounts, MPI_INT, nc_sum_op, comm );
+ MPI_Reduce_scatter(sendbuf, recvbuf, recvcounts, MPI_INT, nc_sum_op, comm);
for (i = 0; i < block_size; ++i) {
int x = rank * block_size + i;
- if (recvbuf[i] != (size*x + (size-1)*size/2)) ++err;
+ if (recvbuf[i] != (size * x + (size - 1) * size / 2))
+ ++err;
}
free(recvbuf);
@@ -121,8 +121,8 @@ int main( int argc, char **argv )
MPI_Op_free(&right_op);
MPI_Op_free(&nc_sum_op);
- MTest_Finalize( err );
- MPI_Finalize( );
+ MTest_Finalize(err);
+ MPI_Finalize();
return err;
}
diff --git a/test/mpi/coll/redscat3.c b/test/mpi/coll/redscat3.c
index b76774d..42474d3 100644
--- a/test/mpi/coll/redscat3.c
+++ b/test/mpi/coll/redscat3.c
@@ -3,11 +3,11 @@
* (C) 2010 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-/*
+/*
* Test of reduce scatter with large data (needed in MPICH to trigger the
* long-data algorithm)
*
- * Each processor contributes its rank + the index to the reduction,
+ * Each processor contributes its rank + the index to the reduction,
* then receives the ith sum
*
* Can be called with any number of processors.
@@ -22,78 +22,73 @@
/* Limit the number of error reports */
#define MAX_ERRORS 10
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- int err = 0;
- int *sendbuf, *recvbuf, *recvcounts;
- int size, rank, i, j, idx, mycount, sumval;
+ int err = 0;
+ int *sendbuf, *recvbuf, *recvcounts;
+ int size, rank, i, j, idx, mycount, sumval;
MPI_Comm comm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_size( comm, &size );
- MPI_Comm_rank( comm, &rank );
- recvcounts = (int *)malloc( size * sizeof(int) );
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
+ recvcounts = (int *) malloc(size * sizeof(int));
if (!recvcounts) {
- fprintf( stderr, "Could not allocate %d ints for recvcounts\n",
- size );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Could not allocate %d ints for recvcounts\n", size);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
mycount = (1024 * 1024) / size;
- for (i=0; i<size; i++)
- recvcounts[i] = mycount;
- sendbuf = (int *) malloc( mycount * size * sizeof(int) );
+ for (i = 0; i < size; i++)
+ recvcounts[i] = mycount;
+ sendbuf = (int *) malloc(mycount * size * sizeof(int));
if (!sendbuf) {
- fprintf( stderr, "Could not allocate %d ints for sendbuf\n",
- mycount * size );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Could not allocate %d ints for sendbuf\n", mycount * size);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
idx = 0;
- for (i=0; i<size; i++) {
- for (j=0; j<mycount; j++) {
- sendbuf[idx++] = rank + i;
- }
+ for (i = 0; i < size; i++) {
+ for (j = 0; j < mycount; j++) {
+ sendbuf[idx++] = rank + i;
+ }
}
- recvbuf = (int *)malloc( mycount * sizeof(int) );
+ recvbuf = (int *) malloc(mycount * sizeof(int));
if (!recvbuf) {
- fprintf( stderr, "Could not allocate %d ints for recvbuf\n",
- mycount );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Could not allocate %d ints for recvbuf\n", mycount);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- for (i=0; i<mycount; i++) {
- recvbuf[i] = -1;
+ for (i = 0; i < mycount; i++) {
+ recvbuf[i] = -1;
}
- MTest_Reduce_scatter( sendbuf, recvbuf, recvcounts, MPI_INT, MPI_SUM, comm );
+ MTest_Reduce_scatter(sendbuf, recvbuf, recvcounts, MPI_INT, MPI_SUM, comm);
- sumval = size * rank + ((size - 1) * size)/2;
+ sumval = size * rank + ((size - 1) * size) / 2;
/* recvbuf should be size * (rank + i) */
- for (i=0; i<mycount; i++) {
- if (recvbuf[i] != sumval) {
- err++;
- if (err < MAX_ERRORS) {
- fprintf( stdout, "Did not get expected value for reduce scatter\n" );
- fprintf( stdout, "[%d] Got recvbuf[%d] = %d expected %d\n",
- rank, i, recvbuf[i], sumval );
- }
- }
+ for (i = 0; i < mycount; i++) {
+ if (recvbuf[i] != sumval) {
+ err++;
+ if (err < MAX_ERRORS) {
+ fprintf(stdout, "Did not get expected value for reduce scatter\n");
+ fprintf(stdout, "[%d] Got recvbuf[%d] = %d expected %d\n",
+ rank, i, recvbuf[i], sumval);
+ }
+ }
}
#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
- MTest_Reduce_scatter( MPI_IN_PLACE, sendbuf, recvcounts, MPI_INT, MPI_SUM,
- comm );
+ MTest_Reduce_scatter(MPI_IN_PLACE, sendbuf, recvcounts, MPI_INT, MPI_SUM, comm);
- sumval = size * rank + ((size - 1) * size)/2;
+ sumval = size * rank + ((size - 1) * size) / 2;
/* recv'ed values for my process should be size * (rank + i) */
- for (i=0; i<mycount; i++) {
+ for (i = 0; i < mycount; i++) {
if (sendbuf[i] != sumval) {
err++;
if (err < MAX_ERRORS) {
- fprintf( stdout, "Did not get expected value for reduce scatter (in place)\n" );
- fprintf( stdout, "[%d] Got buf[%d] = %d expected %d\n",
- rank, i, sendbuf[i], sumval );
+ fprintf(stdout, "Did not get expected value for reduce scatter (in place)\n");
+ fprintf(stdout, "[%d] Got buf[%d] = %d expected %d\n", rank, i, sendbuf[i], sumval);
}
}
}
@@ -102,10 +97,10 @@ int main( int argc, char **argv )
free(sendbuf);
free(recvbuf);
free(recvcounts);
-
- MTest_Finalize( err );
- MPI_Finalize( );
+ MTest_Finalize(err);
+
+ MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/redscatbkinter.c b/test/mpi/coll/redscatbkinter.c
index bf5f65f..31645c0 100644
--- a/test/mpi/coll/redscatbkinter.c
+++ b/test/mpi/coll/redscatbkinter.c
@@ -3,11 +3,11 @@
* (C) 2011 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-/*
+/*
* Test of reduce scatter block with large data on an intercommunicator
* (needed in MPICH to trigger the long-data algorithm)
*
- * Each processor contributes its rank + the index to the reduction,
+ * Each processor contributes its rank + the index to the reduction,
* then receives the ith sum
*
* Can be called with any number of processors.
@@ -18,89 +18,83 @@
#include <stdlib.h>
#include "mpitest.h"
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- int err = 0;
- int size, rsize, rank, i;
- int recvcount, /* Each process receives this much data */
- sendcount, /* Each process contributes this much data */
- basecount; /* Unit of elements - basecount *rsize is recvcount,
- etc. */
- int isLeftGroup;
+ int err = 0;
+ int size, rsize, rank, i;
+ int recvcount, /* Each process receives this much data */
+ sendcount, /* Each process contributes this much data */
+ basecount; /* Unit of elements - basecount *rsize is recvcount,
+ * etc. */
+ int isLeftGroup;
long long *sendbuf, *recvbuf;
long long sumval;
MPI_Comm comm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
basecount = 1024;
- while (MTestGetIntercomm( &comm, &isLeftGroup, 2 )) {
- if (comm == MPI_COMM_NULL) continue;
-
- MPI_Comm_remote_size( comm, &rsize );
- MPI_Comm_size( comm, &size );
- MPI_Comm_rank( comm, &rank );
-
- if (0) {
- printf( "[%d] %s (%d,%d) remote %d\n", rank,
- isLeftGroup ? "L" : "R",
- rank, size, rsize );
- }
-
- recvcount = basecount * rsize;
- sendcount = basecount * rsize * size;
-
- sendbuf = (long long *) malloc( sendcount * sizeof(long long) );
- if (!sendbuf) {
- fprintf( stderr, "Could not allocate %d ints for sendbuf\n",
- sendcount );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
-
- for (i=0; i<sendcount; i++) {
- sendbuf[i] = (long long)(rank*sendcount + i);
- }
- recvbuf = (long long *)malloc( recvcount * sizeof(long long) );
- if (!recvbuf) {
- fprintf( stderr, "Could not allocate %d ints for recvbuf\n",
- recvcount );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- for (i=0; i<recvcount; i++) {
- recvbuf[i] = (long long)(-i);
- }
-
- MPI_Reduce_scatter_block( sendbuf, recvbuf, recvcount, MPI_LONG_LONG,
- MPI_SUM, comm );
-
- /* Check received data */
- for (i=0; i<recvcount; i++) {
- sumval = (long long)(sendcount) * (long long)((rsize * (rsize-1))/2) +
- (long long)(i + rank * rsize * basecount) * (long long)rsize;
- if (recvbuf[i] != sumval) {
- err++;
- if (err < 4) {
- fprintf( stdout, "Did not get expected value for reduce scatter\n" );
- fprintf( stdout, "[%d] %s recvbuf[%d] = %lld, expected %lld\n",
- rank,
- isLeftGroup ? "L" : "R",
- i, recvbuf[i], sumval );
- }
- }
- }
-
- free(sendbuf);
- free(recvbuf);
-
- MTestFreeComm( &comm );
+ while (MTestGetIntercomm(&comm, &isLeftGroup, 2)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+
+ MPI_Comm_remote_size(comm, &rsize);
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
+
+ if (0) {
+ printf("[%d] %s (%d,%d) remote %d\n", rank, isLeftGroup ? "L" : "R", rank, size, rsize);
+ }
+
+ recvcount = basecount * rsize;
+ sendcount = basecount * rsize * size;
+
+ sendbuf = (long long *) malloc(sendcount * sizeof(long long));
+ if (!sendbuf) {
+ fprintf(stderr, "Could not allocate %d ints for sendbuf\n", sendcount);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+
+ for (i = 0; i < sendcount; i++) {
+ sendbuf[i] = (long long) (rank * sendcount + i);
+ }
+ recvbuf = (long long *) malloc(recvcount * sizeof(long long));
+ if (!recvbuf) {
+ fprintf(stderr, "Could not allocate %d ints for recvbuf\n", recvcount);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ for (i = 0; i < recvcount; i++) {
+ recvbuf[i] = (long long) (-i);
+ }
+
+ MPI_Reduce_scatter_block(sendbuf, recvbuf, recvcount, MPI_LONG_LONG, MPI_SUM, comm);
+
+ /* Check received data */
+ for (i = 0; i < recvcount; i++) {
+ sumval = (long long) (sendcount) * (long long) ((rsize * (rsize - 1)) / 2) +
+ (long long) (i + rank * rsize * basecount) * (long long) rsize;
+ if (recvbuf[i] != sumval) {
+ err++;
+ if (err < 4) {
+ fprintf(stdout, "Did not get expected value for reduce scatter\n");
+ fprintf(stdout, "[%d] %s recvbuf[%d] = %lld, expected %lld\n",
+ rank, isLeftGroup ? "L" : "R", i, recvbuf[i], sumval);
+ }
+ }
+ }
+
+ free(sendbuf);
+ free(recvbuf);
+
+ MTestFreeComm(&comm);
}
- MTest_Finalize( err );
+ MTest_Finalize(err);
- MPI_Finalize( );
+ MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/redscatblk3.c b/test/mpi/coll/redscatblk3.c
index efb6d1e..8bfbbc6 100644
--- a/test/mpi/coll/redscatblk3.c
+++ b/test/mpi/coll/redscatblk3.c
@@ -3,11 +3,11 @@
* (C) 2010 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-/*
+/*
* Test of reduce scatter with large data (needed in MPICH to trigger the
* long-data algorithm)
*
- * Each processor contributes its rank + the index to the reduction,
+ * Each processor contributes its rank + the index to the reduction,
* then receives the ith sum
*
* Can be called with any number of processors.
@@ -18,72 +18,68 @@
#include <stdlib.h>
#include "mpitest.h"
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- int err = 0;
- int *sendbuf, *recvbuf;
- int size, rank, i, j, idx, mycount, sumval;
+ int err = 0;
+ int *sendbuf, *recvbuf;
+ int size, rank, i, j, idx, mycount, sumval;
MPI_Comm comm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_size( comm, &size );
- MPI_Comm_rank( comm, &rank );
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
mycount = (1024 * 1024) / size;
- sendbuf = (int *) malloc( mycount * size * sizeof(int) );
+ sendbuf = (int *) malloc(mycount * size * sizeof(int));
if (!sendbuf) {
- fprintf( stderr, "Could not allocate %d ints for sendbuf\n",
- mycount * size );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Could not allocate %d ints for sendbuf\n", mycount * size);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
idx = 0;
- for (i=0; i<size; i++) {
- for (j=0; j<mycount; j++) {
- sendbuf[idx++] = rank + i;
- }
+ for (i = 0; i < size; i++) {
+ for (j = 0; j < mycount; j++) {
+ sendbuf[idx++] = rank + i;
+ }
}
- recvbuf = (int *)malloc( mycount * sizeof(int) );
+ recvbuf = (int *) malloc(mycount * sizeof(int));
if (!recvbuf) {
- fprintf( stderr, "Could not allocate %d ints for recvbuf\n",
- mycount );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Could not allocate %d ints for recvbuf\n", mycount);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- MPI_Reduce_scatter_block( sendbuf, recvbuf, mycount, MPI_INT, MPI_SUM,
- comm );
+ MPI_Reduce_scatter_block(sendbuf, recvbuf, mycount, MPI_INT, MPI_SUM, comm);
- sumval = size * rank + ((size - 1) * size)/2;
+ sumval = size * rank + ((size - 1) * size) / 2;
/* recvbuf should be size * (rank + i) */
- for (i=0; i<mycount; i++) {
- if (recvbuf[i] != sumval) {
- err++;
- fprintf( stdout, "Did not get expected value for reduce scatter\n" );
- fprintf( stdout, "[%d] Got %d expected %d\n", rank, recvbuf[i], sumval );
- }
+ for (i = 0; i < mycount; i++) {
+ if (recvbuf[i] != sumval) {
+ err++;
+ fprintf(stdout, "Did not get expected value for reduce scatter\n");
+ fprintf(stdout, "[%d] Got %d expected %d\n", rank, recvbuf[i], sumval);
+ }
}
- MPI_Reduce_scatter_block( MPI_IN_PLACE, sendbuf, mycount, MPI_INT, MPI_SUM,
- comm );
+ MPI_Reduce_scatter_block(MPI_IN_PLACE, sendbuf, mycount, MPI_INT, MPI_SUM, comm);
- sumval = size * rank + ((size - 1) * size)/2;
+ sumval = size * rank + ((size - 1) * size) / 2;
/* recv'ed values for my process should be size * (rank + i) */
- for (i=0; i<mycount; i++) {
+ for (i = 0; i < mycount; i++) {
if (sendbuf[i] != sumval) {
err++;
- fprintf( stdout, "Did not get expected value for reduce scatter (in place)\n" );
- fprintf( stdout, "[%d] Got %d expected %d\n", rank, sendbuf[i], sumval );
+ fprintf(stdout, "Did not get expected value for reduce scatter (in place)\n");
+ fprintf(stdout, "[%d] Got %d expected %d\n", rank, sendbuf[i], sumval);
}
}
free(sendbuf);
free(recvbuf);
-
- MTest_Finalize( err );
- MPI_Finalize( );
+ MTest_Finalize(err);
+
+ MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/redscatinter.c b/test/mpi/coll/redscatinter.c
index 38d7e8c..b1415cc 100644
--- a/test/mpi/coll/redscatinter.c
+++ b/test/mpi/coll/redscatinter.c
@@ -3,11 +3,11 @@
* (C) 2011 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-/*
+/*
* Test of reduce scatter with large data on an intercommunicator
* (needed in MPICH to trigger the long-data algorithm)
*
- * Each processor contributes its rank + the index to the reduction,
+ * Each processor contributes its rank + the index to the reduction,
* then receives the ith sum
*
* Can be called with any number of processors.
@@ -19,100 +19,93 @@
#include "mpitest.h"
#include "mpicolltest.h"
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- int err = 0;
- int *recvcounts;
- int size, rsize, rank, i;
- int recvcount, /* Each process receives this much data */
- sendcount, /* Each process contributes this much data */
- basecount; /* Unit of elements - basecount *rsize is recvcount,
- etc. */
- int isLeftGroup;
+ int err = 0;
+ int *recvcounts;
+ int size, rsize, rank, i;
+ int recvcount, /* Each process receives this much data */
+ sendcount, /* Each process contributes this much data */
+ basecount; /* Unit of elements - basecount *rsize is recvcount,
+ * etc. */
+ int isLeftGroup;
long long *sendbuf, *recvbuf;
long long sumval;
MPI_Comm comm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
basecount = 1024;
- while (MTestGetIntercomm( &comm, &isLeftGroup, 2 )) {
- if (comm == MPI_COMM_NULL) continue;
-
- MPI_Comm_remote_size( comm, &rsize );
- MPI_Comm_size( comm, &size );
- MPI_Comm_rank( comm, &rank );
-
- if (0) {
- printf( "[%d] %s (%d,%d) remote %d\n", rank,
- isLeftGroup ? "L" : "R",
- rank, size, rsize );
- }
-
- recvcount = basecount * rsize;
- sendcount = basecount * rsize * size;
-
- recvcounts = (int *)malloc( size * sizeof(int) );
- if (!recvcounts) {
- fprintf( stderr, "Could not allocate %d int for recvcounts\n",
- size );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- for (i=0; i<size; i++)
- recvcounts[i] = recvcount;
-
- sendbuf = (long long *) malloc( sendcount * sizeof(long long) );
- if (!sendbuf) {
- fprintf( stderr, "Could not allocate %d ints for sendbuf\n",
- sendcount );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
-
- for (i=0; i<sendcount; i++) {
- sendbuf[i] = (long long)(rank*sendcount + i);
- }
- recvbuf = (long long *)malloc( recvcount * sizeof(long long) );
- if (!recvbuf) {
- fprintf( stderr, "Could not allocate %d ints for recvbuf\n",
- recvcount );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- for (i=0; i<recvcount; i++) {
- recvbuf[i] = (long long)(-i);
- }
-
- MTest_Reduce_scatter( sendbuf, recvbuf, recvcounts, MPI_LONG_LONG, MPI_SUM,
- comm );
-
- /* Check received data */
- for (i=0; i<recvcount; i++) {
- sumval = (long long)(sendcount) * (long long)((rsize * (rsize-1))/2) +
- (long long)(i + rank * rsize * basecount) * (long long)rsize;
- if (recvbuf[i] != sumval) {
- err++;
- if (err < 4) {
- fprintf( stdout, "Did not get expected value for reduce scatter\n" );
- fprintf( stdout, "[%d] %s recvbuf[%d] = %lld, expected %lld\n",
- rank,
- isLeftGroup ? "L" : "R",
- i, recvbuf[i], sumval );
- }
- }
- }
-
- free(sendbuf);
- free(recvbuf);
- free(recvcounts);
-
- MTestFreeComm( &comm );
+ while (MTestGetIntercomm(&comm, &isLeftGroup, 2)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+
+ MPI_Comm_remote_size(comm, &rsize);
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
+
+ if (0) {
+ printf("[%d] %s (%d,%d) remote %d\n", rank, isLeftGroup ? "L" : "R", rank, size, rsize);
+ }
+
+ recvcount = basecount * rsize;
+ sendcount = basecount * rsize * size;
+
+ recvcounts = (int *) malloc(size * sizeof(int));
+ if (!recvcounts) {
+ fprintf(stderr, "Could not allocate %d int for recvcounts\n", size);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ for (i = 0; i < size; i++)
+ recvcounts[i] = recvcount;
+
+ sendbuf = (long long *) malloc(sendcount * sizeof(long long));
+ if (!sendbuf) {
+ fprintf(stderr, "Could not allocate %d ints for sendbuf\n", sendcount);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+
+ for (i = 0; i < sendcount; i++) {
+ sendbuf[i] = (long long) (rank * sendcount + i);
+ }
+ recvbuf = (long long *) malloc(recvcount * sizeof(long long));
+ if (!recvbuf) {
+ fprintf(stderr, "Could not allocate %d ints for recvbuf\n", recvcount);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ for (i = 0; i < recvcount; i++) {
+ recvbuf[i] = (long long) (-i);
+ }
+
+ MTest_Reduce_scatter(sendbuf, recvbuf, recvcounts, MPI_LONG_LONG, MPI_SUM, comm);
+
+ /* Check received data */
+ for (i = 0; i < recvcount; i++) {
+ sumval = (long long) (sendcount) * (long long) ((rsize * (rsize - 1)) / 2) +
+ (long long) (i + rank * rsize * basecount) * (long long) rsize;
+ if (recvbuf[i] != sumval) {
+ err++;
+ if (err < 4) {
+ fprintf(stdout, "Did not get expected value for reduce scatter\n");
+ fprintf(stdout, "[%d] %s recvbuf[%d] = %lld, expected %lld\n",
+ rank, isLeftGroup ? "L" : "R", i, recvbuf[i], sumval);
+ }
+ }
+ }
+
+ free(sendbuf);
+ free(recvbuf);
+ free(recvcounts);
+
+ MTestFreeComm(&comm);
}
- MTest_Finalize( err );
+ MTest_Finalize(err);
- MPI_Finalize( );
+ MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/reduce.c b/test/mpi/coll/reduce.c
index 6106782..d86503e 100644
--- a/test/mpi/coll/reduce.c
+++ b/test/mpi/coll/reduce.c
@@ -13,45 +13,47 @@
static char MTEST_Descrip[] = "A simple test of Reduce with all choices of root process";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size, root;
int *sendbuf, *recvbuf, i;
- int minsize = 2, count;
- MPI_Comm comm;
+ int minsize = 2, count;
+ MPI_Comm comm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
- /* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
-
- for (count = 1; count < 130000; count = count * 2) {
- sendbuf = (int *)malloc( count * sizeof(int) );
- recvbuf = (int *)malloc( count * sizeof(int) );
- for (root = 0; root < size; root ++) {
- for (i=0; i<count; i++) sendbuf[i] = i;
- for (i=0; i<count; i++) recvbuf[i] = -1;
- MPI_Reduce( sendbuf, recvbuf, count, MPI_INT, MPI_SUM,
- root, comm );
- if (rank == root) {
- for (i=0; i<count; i++) {
- if (recvbuf[i] != i * size) {
- errs++;
- }
- }
- }
- }
- free( sendbuf );
- free( recvbuf );
- }
- MTestFreeComm( &comm );
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ /* Determine the sender and receiver */
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+
+ for (count = 1; count < 130000; count = count * 2) {
+ sendbuf = (int *) malloc(count * sizeof(int));
+ recvbuf = (int *) malloc(count * sizeof(int));
+ for (root = 0; root < size; root++) {
+ for (i = 0; i < count; i++)
+ sendbuf[i] = i;
+ for (i = 0; i < count; i++)
+ recvbuf[i] = -1;
+ MPI_Reduce(sendbuf, recvbuf, count, MPI_INT, MPI_SUM, root, comm);
+ if (rank == root) {
+ for (i = 0; i < count; i++) {
+ if (recvbuf[i] != i * size) {
+ errs++;
+ }
+ }
+ }
+ }
+ free(sendbuf);
+ free(recvbuf);
+ }
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/coll/reduce_local.c b/test/mpi/coll/reduce_local.c
index 9bf6820..3c6ffb1 100644
--- a/test/mpi/coll/reduce_local.c
+++ b/test/mpi/coll/reduce_local.c
@@ -18,13 +18,13 @@ static char MTEST_Descrip[] = "A simple test of MPI_Reduce_local";
static int uop_errs = 0;
/* prototype to keep the compiler happy */
-static void user_op(void *invec, void *inoutvec, int *len, MPI_Datatype *datatype);
+static void user_op(void *invec, void *inoutvec, int *len, MPI_Datatype * datatype);
-static void user_op(void *invec, void *inoutvec, int *len, MPI_Datatype *datatype)
+static void user_op(void *invec, void *inoutvec, int *len, MPI_Datatype * datatype)
{
int i;
- int *invec_int = (int *)invec;
- int *inoutvec_int = (int *)inoutvec;
+ int *invec_int = (int *) invec;
+ int *inoutvec_int = (int *) inoutvec;
if (*datatype != MPI_INT) {
++uop_errs;
@@ -37,7 +37,7 @@ static void user_op(void *invec, void *inoutvec, int *len, MPI_Datatype *datatyp
}
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int i;
@@ -53,7 +53,7 @@ int main( int argc, char *argv[] )
inbuf = malloc(sizeof(int) * MAX_BUF_ELEMENTS);
inoutbuf = malloc(sizeof(int) * MAX_BUF_ELEMENTS);
- for (count = 0; count < MAX_BUF_ELEMENTS; count > 0 ? count*=2 : count++) {
+ for (count = 0; count < MAX_BUF_ELEMENTS; count > 0 ? count *= 2 : count++) {
for (i = 0; i < count; ++i) {
inbuf[i] = i;
inoutbuf[i] = i;
@@ -62,14 +62,14 @@ int main( int argc, char *argv[] )
for (i = 0; i < count; ++i)
if (inbuf[i] != i) {
++errs;
- if (inoutbuf[i] != (2*i))
- ++errs;
- }
+ if (inoutbuf[i] != (2 * i))
+ ++errs;
+ }
}
/* make sure that user-define ops work too */
- MPI_Op_create(&user_op, 0/*!commute*/, &uop);
- for (count = 0; count < MAX_BUF_ELEMENTS; count > 0 ? count*=2 : count++) {
+ MPI_Op_create(&user_op, 0 /*!commute */ , &uop);
+ for (count = 0; count < MAX_BUF_ELEMENTS; count > 0 ? count *= 2 : count++) {
for (i = 0; i < count; ++i) {
inbuf[i] = i;
inoutbuf[i] = i;
@@ -79,9 +79,9 @@ int main( int argc, char *argv[] )
for (i = 0; i < count; ++i)
if (inbuf[i] != i) {
++errs;
- if (inoutbuf[i] != (3*i))
- ++errs;
- }
+ if (inoutbuf[i] != (3 * i))
+ ++errs;
+ }
}
MPI_Op_free(&uop);
@@ -93,4 +93,3 @@ int main( int argc, char *argv[] )
MPI_Finalize();
return 0;
}
-
diff --git a/test/mpi/coll/scantst.c b/test/mpi/coll/scantst.c
index 97802ad..12ddcad 100644
--- a/test/mpi/coll/scantst.c
+++ b/test/mpi/coll/scantst.c
@@ -7,111 +7,107 @@
#include <stdio.h>
#include "mpitest.h"
-void addem ( int *, int *, int *, MPI_Datatype * );
-void assoc ( int *, int *, int *, MPI_Datatype * );
+void addem(int *, int *, int *, MPI_Datatype *);
+void assoc(int *, int *, int *, MPI_Datatype *);
-void addem( int *invec, int *inoutvec, int *len, MPI_Datatype *dtype)
+void addem(int *invec, int *inoutvec, int *len, MPI_Datatype * dtype)
{
- int i;
- for ( i=0; i<*len; i++ )
- inoutvec[i] += invec[i];
+ int i;
+ for (i = 0; i < *len; i++)
+ inoutvec[i] += invec[i];
}
#define BAD_ANSWER 100000
/*
- The operation is inoutvec[i] = invec[i] op inoutvec[i]
+ The operation is inoutvec[i] = invec[i] op inoutvec[i]
(see 4.9.4). The order is important.
Note that the computation is in process rank (in the communicator)
order, independant of the root.
*/
-void assoc( int *invec, int *inoutvec, int *len, MPI_Datatype *dtype)
+void assoc(int *invec, int *inoutvec, int *len, MPI_Datatype * dtype)
{
- int i;
- for ( i=0; i<*len; i++ ) {
- if (inoutvec[i] <= invec[i] ) {
- int rank;
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- fprintf( stderr, "[%d] inout[0] = %d, in[0] = %d\n",
- rank, inoutvec[0], invec[0] );
- inoutvec[i] = BAD_ANSWER;
- }
- else
- inoutvec[i] = invec[i];
- }
+ int i;
+ for (i = 0; i < *len; i++) {
+ if (inoutvec[i] <= invec[i]) {
+ int rank;
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ fprintf(stderr, "[%d] inout[0] = %d, in[0] = %d\n", rank, inoutvec[0], invec[0]);
+ inoutvec[i] = BAD_ANSWER;
+ }
+ else
+ inoutvec[i] = invec[i];
+ }
}
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- int rank, size, i;
- int data;
- int errors=0;
- int result = -100;
- int correct_result;
- MPI_Op op_assoc, op_addem;
- MPI_Comm comm=MPI_COMM_WORLD;
-
- MPI_Init( &argc, &argv );
- MPI_Op_create( (MPI_User_function *)assoc, 0, &op_assoc );
- MPI_Op_create( (MPI_User_function *)addem, 1, &op_addem );
+ int rank, size, i;
+ int data;
+ int errors = 0;
+ int result = -100;
+ int correct_result;
+ MPI_Op op_assoc, op_addem;
+ MPI_Comm comm = MPI_COMM_WORLD;
+
+ MPI_Init(&argc, &argv);
+ MPI_Op_create((MPI_User_function *) assoc, 0, &op_assoc);
+ MPI_Op_create((MPI_User_function *) addem, 1, &op_addem);
/* Run this for a variety of communicator sizes */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
data = rank;
-
+
correct_result = 0;
- for (i=0;i<=rank;i++)
+ for (i = 0; i <= rank; i++)
correct_result += i;
-
- MPI_Scan ( &data, &result, 1, MPI_INT, MPI_SUM, comm );
+
+ MPI_Scan(&data, &result, 1, MPI_INT, MPI_SUM, comm);
if (result != correct_result) {
- fprintf( stderr, "[%d] Error suming ints with scan\n", rank );
+ fprintf(stderr, "[%d] Error suming ints with scan\n", rank);
errors++;
}
- MPI_Scan ( &data, &result, 1, MPI_INT, MPI_SUM, comm );
+ MPI_Scan(&data, &result, 1, MPI_INT, MPI_SUM, comm);
if (result != correct_result) {
- fprintf( stderr, "[%d] Error summing ints with scan (2)\n", rank );
+ fprintf(stderr, "[%d] Error summing ints with scan (2)\n", rank);
errors++;
}
-
+
data = rank;
result = -100;
- MPI_Scan ( &data, &result, 1, MPI_INT, op_addem, comm );
+ MPI_Scan(&data, &result, 1, MPI_INT, op_addem, comm);
if (result != correct_result) {
- fprintf( stderr, "[%d] Error summing ints with scan (userop)\n",
- rank );
+ fprintf(stderr, "[%d] Error summing ints with scan (userop)\n", rank);
errors++;
}
-
- MPI_Scan ( &data, &result, 1, MPI_INT, op_addem, comm );
+
+ MPI_Scan(&data, &result, 1, MPI_INT, op_addem, comm);
if (result != correct_result) {
- fprintf( stderr, "[%d] Error summing ints with scan (userop2)\n",
- rank );
+ fprintf(stderr, "[%d] Error summing ints with scan (userop2)\n", rank);
errors++;
}
result = -100;
data = rank;
- MPI_Scan ( &data, &result, 1, MPI_INT, op_assoc, comm );
+ MPI_Scan(&data, &result, 1, MPI_INT, op_assoc, comm);
if (result == BAD_ANSWER) {
- fprintf( stderr, "[%d] Error scanning with non-commutative op\n",
- rank );
+ fprintf(stderr, "[%d] Error scanning with non-commutative op\n", rank);
errors++;
}
- MPI_Op_free( &op_assoc );
- MPI_Op_free( &op_addem );
-
+ MPI_Op_free(&op_assoc);
+ MPI_Op_free(&op_addem);
+
MPI_Finalize();
if (errors)
- printf( "[%d] done with ERRORS(%d)!\n", rank, errors );
+ printf("[%d] done with ERRORS(%d)!\n", rank, errors);
else {
- if (rank == 0)
- printf(" No Errors\n");
+ if (rank == 0)
+ printf(" No Errors\n");
}
return errors;
diff --git a/test/mpi/coll/scatter2.c b/test/mpi/coll/scatter2.c
index f11e204..96a55b0 100644
--- a/test/mpi/coll/scatter2.c
+++ b/test/mpi/coll/scatter2.c
@@ -13,63 +13,62 @@
/* This example sends a vector and receives individual elements, but the
root process does not receive any data */
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
MPI_Datatype vec;
double *vecin, *vecout, ivalue;
- int root, i, n, stride, err = 0;
- int rank, size;
+ int root, i, n, stride, err = 0;
+ int rank, size;
MPI_Aint vextent;
- MTest_Init( &argc, &argv );
-
- MPI_Comm_size( MPI_COMM_WORLD, &size );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+ MTest_Init(&argc, &argv);
+
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
n = 12;
stride = 10;
- vecin = (double *)malloc( n * stride * size * sizeof(double) );
- vecout = (double *)malloc( n * sizeof(double) );
-
- MPI_Type_vector( n, 1, stride, MPI_DOUBLE, &vec );
- MPI_Type_commit( &vec );
- MPI_Type_extent( vec, &vextent );
- if (vextent != ((n-1)*(MPI_Aint)stride + 1) * sizeof(double) ) {
- err++;
- printf( "Vector extent is %ld, should be %ld\n",
- (long) vextent, (long)(((n-1)*stride+1)*sizeof(double)) );
+ vecin = (double *) malloc(n * stride * size * sizeof(double));
+ vecout = (double *) malloc(n * sizeof(double));
+
+ MPI_Type_vector(n, 1, stride, MPI_DOUBLE, &vec);
+ MPI_Type_commit(&vec);
+ MPI_Type_extent(vec, &vextent);
+ if (vextent != ((n - 1) * (MPI_Aint) stride + 1) * sizeof(double)) {
+ err++;
+ printf("Vector extent is %ld, should be %ld\n",
+ (long) vextent, (long) (((n - 1) * stride + 1) * sizeof(double)));
}
/* Note that the exted of type vector is from the first to the
- last element, not n*stride.
- E.g., with n=1, the extent is a single double */
+ * last element, not n*stride.
+ * E.g., with n=1, the extent is a single double */
- for (i=0; i<n*stride*size; i++) vecin[i] = (double)i;
- for (root=0; root<size; root++) {
- for (i=0; i<n; i++) vecout[i] = -1.0;
- if (rank == root) {
- MPI_Scatter( vecin, 1, vec, MPI_IN_PLACE, -1, MPI_DATATYPE_NULL,
- root, MPI_COMM_WORLD );
- }
- else {
- MPI_Scatter( NULL, -1, MPI_DATATYPE_NULL, vecout, n, MPI_DOUBLE,
- root, MPI_COMM_WORLD );
- ivalue = rank * ((n-1) * stride + 1);
- for (i=0; i<n; i++) {
- if (vecout[i] != ivalue) {
- printf( "[%d] Expected %f but found %f for vecout[%d]\n",
- rank, ivalue, vecout[i], i );
- err++;
- }
- ivalue += stride;
- }
- }
+ for (i = 0; i < n * stride * size; i++)
+ vecin[i] = (double) i;
+ for (root = 0; root < size; root++) {
+ for (i = 0; i < n; i++)
+ vecout[i] = -1.0;
+ if (rank == root) {
+ MPI_Scatter(vecin, 1, vec, MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, root, MPI_COMM_WORLD);
+ }
+ else {
+ MPI_Scatter(NULL, -1, MPI_DATATYPE_NULL, vecout, n, MPI_DOUBLE, root, MPI_COMM_WORLD);
+ ivalue = rank * ((n - 1) * stride + 1);
+ for (i = 0; i < n; i++) {
+ if (vecout[i] != ivalue) {
+ printf("[%d] Expected %f but found %f for vecout[%d]\n",
+ rank, ivalue, vecout[i], i);
+ err++;
+ }
+ ivalue += stride;
+ }
+ }
}
-
+
free(vecin);
free(vecout);
- MTest_Finalize( err );
- MPI_Type_free( &vec );
+ MTest_Finalize(err);
+ MPI_Type_free(&vec);
MPI_Finalize();
return 0;
}
-
diff --git a/test/mpi/coll/scatter3.c b/test/mpi/coll/scatter3.c
index a95748d..c83e413 100644
--- a/test/mpi/coll/scatter3.c
+++ b/test/mpi/coll/scatter3.c
@@ -13,75 +13,74 @@
/* This example sends contiguous data and receives a vector on some nodes
and contiguous data on others. There is some evidence that some
MPI implementations do not check recvcount on the root process; this
- test checks for that case
+ test checks for that case
*/
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
MPI_Datatype vec;
double *vecin, *vecout, ivalue;
- int root, i, n, stride, errs = 0;
- int rank, size;
+ int root, i, n, stride, errs = 0;
+ int rank, size;
MPI_Aint vextent;
- MTest_Init( &argc, &argv );
-
- MPI_Comm_size( MPI_COMM_WORLD, &size );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+ MTest_Init(&argc, &argv);
+
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
n = 12;
stride = 10;
/* Note that vecout really needs to be only (n-1)*stride+1 doubles, but
- this is easier and allows a little extra room if there is a bug */
- vecout = (double *)malloc( n * stride * sizeof(double) );
- vecin = (double *)malloc( n * size * sizeof(double) );
-
- MPI_Type_vector( n, 1, stride, MPI_DOUBLE, &vec );
- MPI_Type_commit( &vec );
- MPI_Type_extent( vec, &vextent );
- if (vextent != ((n-1)*(MPI_Aint)stride + 1) * sizeof(double) ) {
- errs++;
- printf( "Vector extent is %ld, should be %ld\n",
- (long) vextent, (long)(((n-1)*stride+1)*sizeof(double)) );
+ * this is easier and allows a little extra room if there is a bug */
+ vecout = (double *) malloc(n * stride * sizeof(double));
+ vecin = (double *) malloc(n * size * sizeof(double));
+
+ MPI_Type_vector(n, 1, stride, MPI_DOUBLE, &vec);
+ MPI_Type_commit(&vec);
+ MPI_Type_extent(vec, &vextent);
+ if (vextent != ((n - 1) * (MPI_Aint) stride + 1) * sizeof(double)) {
+ errs++;
+ printf("Vector extent is %ld, should be %ld\n",
+ (long) vextent, (long) (((n - 1) * stride + 1) * sizeof(double)));
}
/* Note that the exted of type vector is from the first to the
- last element, not n*stride.
- E.g., with n=1, the extent is a single double */
+ * last element, not n*stride.
+ * E.g., with n=1, the extent is a single double */
- for (i=0; i<n*size; i++) vecin[i] = (double)i;
- for (root=0; root<size; root++) {
- for (i=0; i<n*stride; i++) vecout[i] = -1.0;
- if (rank == root) {
- /* Receive into a vector */
- MPI_Scatter( vecin, n, MPI_DOUBLE, vecout, 1, vec,
- root, MPI_COMM_WORLD );
- for (i=0; i<n; i++) {
- ivalue = n*root + i;
- if (vecout[i*stride] != ivalue) {
- errs++;
- printf( "[%d] Expected %f but found %f for vecout[%d] on root\n",
- rank, ivalue, vecout[i*stride], i *stride );
- }
- }
- }
- else {
- /* Receive into contiguous data */
- MPI_Scatter( NULL, -1, MPI_DATATYPE_NULL, vecout, n, MPI_DOUBLE,
- root, MPI_COMM_WORLD );
- for (i=0; i<n; i++) {
- ivalue = rank * n + i;
- if (vecout[i] != ivalue) {
- printf( "[%d] Expected %f but found %f for vecout[%d]\n",
- rank, ivalue, vecout[i], i );
- errs++;
- }
- }
- }
+ for (i = 0; i < n * size; i++)
+ vecin[i] = (double) i;
+ for (root = 0; root < size; root++) {
+ for (i = 0; i < n * stride; i++)
+ vecout[i] = -1.0;
+ if (rank == root) {
+ /* Receive into a vector */
+ MPI_Scatter(vecin, n, MPI_DOUBLE, vecout, 1, vec, root, MPI_COMM_WORLD);
+ for (i = 0; i < n; i++) {
+ ivalue = n * root + i;
+ if (vecout[i * stride] != ivalue) {
+ errs++;
+ printf("[%d] Expected %f but found %f for vecout[%d] on root\n",
+ rank, ivalue, vecout[i * stride], i * stride);
+ }
+ }
+ }
+ else {
+ /* Receive into contiguous data */
+ MPI_Scatter(NULL, -1, MPI_DATATYPE_NULL, vecout, n, MPI_DOUBLE, root, MPI_COMM_WORLD);
+ for (i = 0; i < n; i++) {
+ ivalue = rank * n + i;
+ if (vecout[i] != ivalue) {
+ printf("[%d] Expected %f but found %f for vecout[%d]\n",
+ rank, ivalue, vecout[i], i);
+ errs++;
+ }
+ }
+ }
}
-
- MTest_Finalize( errs );
- MPI_Type_free( &vec );
+
+ MTest_Finalize(errs);
+ MPI_Type_free(&vec);
MPI_Finalize();
return 0;
}
-
diff --git a/test/mpi/coll/scattern.c b/test/mpi/coll/scattern.c
index 0c2a096..5bc2fc4 100644
--- a/test/mpi/coll/scattern.c
+++ b/test/mpi/coll/scattern.c
@@ -9,50 +9,51 @@
/* This example sends a vector and receives individual elements */
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
MPI_Datatype vec;
double *vecin, *vecout, ivalue;
- int root, i, n, stride, err = 0;
- int rank, size;
+ int root, i, n, stride, err = 0;
+ int rank, size;
- MPI_Init( &argc, &argv );
-
- MPI_Comm_size( MPI_COMM_WORLD, &size );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+ MPI_Init(&argc, &argv);
+
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
n = 12;
stride = 10;
- vecin = (double *)malloc( n * stride * size * sizeof(double) );
- vecout = (double *)malloc( n * sizeof(double) );
-
- MPI_Type_vector( n, 1, stride, MPI_DOUBLE, &vec );
- MPI_Type_commit( &vec );
-
- for (i=0; i<n*stride*size; i++) vecin[i] = (double)i;
- for (root=0; root<size; root++) {
- for (i=0; i<n; i++) vecout[i] = -1.0;
- MPI_Scatter( vecin, 1, vec, vecout, n, MPI_DOUBLE, root,
- MPI_COMM_WORLD );
- ivalue = rank * ((n-1) * stride + 1);
- for (i=0; i<n; i++) {
- if (vecout[i] != ivalue) {
- printf( "Expected %f but found %f\n",
- ivalue, vecout[i] );
- err++;
- }
- ivalue += stride;
- }
+ vecin = (double *) malloc(n * stride * size * sizeof(double));
+ vecout = (double *) malloc(n * sizeof(double));
+
+ MPI_Type_vector(n, 1, stride, MPI_DOUBLE, &vec);
+ MPI_Type_commit(&vec);
+
+ for (i = 0; i < n * stride * size; i++)
+ vecin[i] = (double) i;
+ for (root = 0; root < size; root++) {
+ for (i = 0; i < n; i++)
+ vecout[i] = -1.0;
+ MPI_Scatter(vecin, 1, vec, vecout, n, MPI_DOUBLE, root, MPI_COMM_WORLD);
+ ivalue = rank * ((n - 1) * stride + 1);
+ for (i = 0; i < n; i++) {
+ if (vecout[i] != ivalue) {
+ printf("Expected %f but found %f\n", ivalue, vecout[i]);
+ err++;
+ }
+ ivalue += stride;
+ }
}
i = err;
- MPI_Allreduce( &i, &err, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
+ MPI_Allreduce(&i, &err, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
if (rank == 0) {
- if (err > 0) printf( "Found %d errors!\n", err );
- else printf( " No Errors\n" );
+ if (err > 0)
+ printf("Found %d errors!\n", err);
+ else
+ printf(" No Errors\n");
}
- MPI_Type_free( &vec );
+ MPI_Type_free(&vec);
MPI_Finalize();
return 0;
-
-}
+}
diff --git a/test/mpi/coll/scatterv.c b/test/mpi/coll/scatterv.c
index 6d8aa94..3115bfc 100644
--- a/test/mpi/coll/scatterv.c
+++ b/test/mpi/coll/scatterv.c
@@ -8,8 +8,8 @@
#include <stdio.h>
/* Prototypes for picky compilers */
-void SetData ( double *, double *, int, int, int, int, int, int );
-int CheckData ( double *, int, int, int, int, int, int );
+void SetData(double *, double *, int, int, int, int, int, int);
+int CheckData(double *, int, int, int, int, int, int);
/*
This is an example of using scatterv to send a matrix from one
process to all others, with the matrix stored in Fortran order.
@@ -21,19 +21,19 @@ int CheckData ( double *, int, int, int, int, int, int );
*/
-void SetData( double *sendbuf, double *recvbuf, int nx, int ny,
- int myrow, int mycol, int nrow, int ncol )
+void SetData(double *sendbuf, double *recvbuf, int nx, int ny,
+ int myrow, int mycol, int nrow, int ncol)
{
int coldim, i, j, m, k;
double *p;
if (myrow == 0 && mycol == 0) {
coldim = nx * nrow;
- for (j=0; j<ncol; j++) {
- for (i=0; i<nrow; i++) {
+ for (j = 0; j < ncol; j++) {
+ for (i = 0; i < nrow; i++) {
p = sendbuf + i * nx + j * (ny * coldim);
- for (m=0; m<ny; m++) {
- for (k=0; k<nx; k++) {
+ for (m = 0; m < ny; m++) {
+ for (k = 0; k < nx; k++) {
p[k] = 1000 * j + 100 * i + m * nx + k;
}
p += coldim;
@@ -41,22 +41,20 @@ void SetData( double *sendbuf, double *recvbuf, int nx, int ny,
}
}
}
- for (i=0; i<nx*ny; i++)
+ for (i = 0; i < nx * ny; i++)
recvbuf[i] = -1.0;
}
-int CheckData( double *recvbuf,
- int nx, int ny, int myrow, int mycol, int nrow,
- int expect_no_value )
+int CheckData(double *recvbuf, int nx, int ny, int myrow, int mycol, int nrow, int expect_no_value)
{
int coldim, m, k;
double *p, val;
int errs = 0;
coldim = nx;
- p = recvbuf;
- for (m=0; m<ny; m++) {
- for (k=0; k<nx; k++) {
+ p = recvbuf;
+ for (m = 0; m < ny; m++) {
+ for (k = 0; k < nx; k++) {
/* If expect_no_value is true then we assume that the pre-scatterv
* value should remain in the recvbuf for our portion of the array.
* This is the case for the root process when using MPI_IN_PLACE. */
@@ -69,10 +67,10 @@ int CheckData( double *recvbuf,
errs++;
if (errs < 10) {
printf("Error in (%d,%d) [%d,%d] location, got %f expected %f\n",
- m, k, myrow, mycol, p[k], val );
+ m, k, myrow, mycol, p[k], val);
}
else if (errs == 10) {
- printf( "Too many errors; suppressing printing\n" );
+ printf("Too many errors; suppressing printing\n");
}
}
}
@@ -81,34 +79,36 @@ int CheckData( double *recvbuf,
return errs;
}
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
int rank, size, myrow, mycol, nx, ny, stride, cnt, i, j, errs, errs_in_place, tot_errs;
- double *sendbuf, *recvbuf;
+ double *sendbuf, *recvbuf;
MPI_Datatype vec, block, types[2];
MPI_Aint displs[2];
- int *scdispls;
- int blens[2];
+ int *scdispls;
+ int blens[2];
MPI_Comm comm2d;
int dims[2], periods[2], coords[2], lcoords[2];
int *sendcounts;
- MPI_Init( &argc, &argv );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ MPI_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
/* Get a 2-d decomposition of the processes */
- dims[0] = 0; dims[1] = 0;
- MPI_Dims_create( size, 2, dims );
- periods[0] = 0; periods[1] = 0;
- MPI_Cart_create( MPI_COMM_WORLD, 2, dims, periods, 0, &comm2d );
- MPI_Cart_get( comm2d, 2, dims, periods, coords );
+ dims[0] = 0;
+ dims[1] = 0;
+ MPI_Dims_create(size, 2, dims);
+ periods[0] = 0;
+ periods[1] = 0;
+ MPI_Cart_create(MPI_COMM_WORLD, 2, dims, periods, 0, &comm2d);
+ MPI_Cart_get(comm2d, 2, dims, periods, coords);
myrow = coords[0];
mycol = coords[1];
/*
if (rank == 0)
- printf( "Decomposition is [%d x %d]\n", dims[0], dims[1] );
+ printf("Decomposition is [%d x %d]\n", dims[0], dims[1]);
*/
/* Get the size of the matrix */
@@ -116,75 +116,76 @@ int main( int argc, char **argv )
ny = 8;
stride = nx * dims[0];
- recvbuf = (double *)malloc( nx * ny * sizeof(double) );
+ recvbuf = (double *) malloc(nx * ny * sizeof(double));
if (!recvbuf) {
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
sendbuf = 0;
if (myrow == 0 && mycol == 0) {
- sendbuf = (double *)malloc( nx * ny * size * sizeof(double) );
+ sendbuf = (double *) malloc(nx * ny * size * sizeof(double));
if (!sendbuf) {
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
}
- sendcounts = (int *) malloc( size * sizeof(int) );
- scdispls = (int *)malloc( size * sizeof(int) );
+ sendcounts = (int *) malloc(size * sizeof(int));
+ scdispls = (int *) malloc(size * sizeof(int));
- MPI_Type_vector( ny, nx, stride, MPI_DOUBLE, &vec );
- blens[0] = 1; blens[1] = 1;
- types[0] = vec; types[1] = MPI_UB;
- displs[0] = 0; displs[1] = nx * sizeof(double);
+ MPI_Type_vector(ny, nx, stride, MPI_DOUBLE, &vec);
+ blens[0] = 1;
+ blens[1] = 1;
+ types[0] = vec;
+ types[1] = MPI_UB;
+ displs[0] = 0;
+ displs[1] = nx * sizeof(double);
- MPI_Type_struct( 2, blens, displs, types, &block );
- MPI_Type_free( &vec );
- MPI_Type_commit( &block );
+ MPI_Type_struct(2, blens, displs, types, &block);
+ MPI_Type_free(&vec);
+ MPI_Type_commit(&block);
/* Set up the transfer */
- cnt = 0;
- for (i=0; i<dims[1]; i++) {
- for (j=0; j<dims[0]; j++) {
+ cnt = 0;
+ for (i = 0; i < dims[1]; i++) {
+ for (j = 0; j < dims[0]; j++) {
sendcounts[cnt] = 1;
/* Using Cart_coords makes sure that ranks (used by
- sendrecv) matches the cartesian coordinates (used to
- set data in the matrix) */
- MPI_Cart_coords( comm2d, cnt, 2, lcoords );
+ * sendrecv) matches the cartesian coordinates (used to
+ * set data in the matrix) */
+ MPI_Cart_coords(comm2d, cnt, 2, lcoords);
scdispls[cnt++] = lcoords[0] + lcoords[1] * (dims[0] * ny);
}
}
- SetData( sendbuf, recvbuf, nx, ny, myrow, mycol, dims[0], dims[1] );
- MPI_Scatterv( sendbuf, sendcounts, scdispls, block,
- recvbuf, nx * ny, MPI_DOUBLE, 0, comm2d );
- if((errs = CheckData( recvbuf, nx, ny, myrow, mycol, dims[0], 0 ))) {
- fprintf( stdout, "Failed to transfer data\n" );
+ SetData(sendbuf, recvbuf, nx, ny, myrow, mycol, dims[0], dims[1]);
+ MPI_Scatterv(sendbuf, sendcounts, scdispls, block, recvbuf, nx * ny, MPI_DOUBLE, 0, comm2d);
+ if ((errs = CheckData(recvbuf, nx, ny, myrow, mycol, dims[0], 0))) {
+ fprintf(stdout, "Failed to transfer data\n");
}
/* once more, but this time passing MPI_IN_PLACE for the root */
- SetData( sendbuf, recvbuf, nx, ny, myrow, mycol, dims[0], dims[1] );
- MPI_Scatterv( sendbuf, sendcounts, scdispls, block,
- (rank == 0 ? MPI_IN_PLACE : recvbuf), nx * ny, MPI_DOUBLE, 0, comm2d );
- errs_in_place = CheckData( recvbuf, nx, ny, myrow, mycol, dims[0], (rank == 0) );
- if(errs_in_place) {
- fprintf( stdout, "Failed to transfer data (MPI_IN_PLACE)\n" );
+ SetData(sendbuf, recvbuf, nx, ny, myrow, mycol, dims[0], dims[1]);
+ MPI_Scatterv(sendbuf, sendcounts, scdispls, block,
+ (rank == 0 ? MPI_IN_PLACE : recvbuf), nx * ny, MPI_DOUBLE, 0, comm2d);
+ errs_in_place = CheckData(recvbuf, nx, ny, myrow, mycol, dims[0], (rank == 0));
+ if (errs_in_place) {
+ fprintf(stdout, "Failed to transfer data (MPI_IN_PLACE)\n");
}
errs += errs_in_place;
- MPI_Allreduce( &errs, &tot_errs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
+ MPI_Allreduce(&errs, &tot_errs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
if (rank == 0) {
if (tot_errs == 0)
- printf( " No Errors\n" );
+ printf(" No Errors\n");
else
- printf( "%d errors in use of MPI_SCATTERV\n", tot_errs );
+ printf("%d errors in use of MPI_SCATTERV\n", tot_errs);
}
- if (sendbuf) free( sendbuf );
- free( recvbuf );
- free( sendcounts );
- free( scdispls );
- MPI_Type_free( &block );
- MPI_Comm_free( &comm2d );
+ if (sendbuf)
+ free(sendbuf);
+ free(recvbuf);
+ free(sendcounts);
+ free(scdispls);
+ MPI_Type_free(&block);
+ MPI_Comm_free(&comm2d);
MPI_Finalize();
return errs;
}
-
-
diff --git a/test/mpi/coll/uoplong.c b/test/mpi/coll/uoplong.c
index 39f857d..280a8a7 100644
--- a/test/mpi/coll/uoplong.c
+++ b/test/mpi/coll/uoplong.c
@@ -9,8 +9,8 @@
#include <stdio.h>
#include <stdlib.h>
-/*
- * Test user-defined operations with a large number of elements.
+/*
+ * Test user-defined operations with a large number of elements.
* Added because a talk at EuroMPI'12 claimed that these failed with
* more than 64k elements
*/
@@ -18,28 +18,28 @@
#define MAX_ERRS 10
#define MAX_COUNT 1200000
-void myop( void *cinPtr, void *coutPtr, int *count, MPI_Datatype *dtype );
+void myop(void *cinPtr, void *coutPtr, int *count, MPI_Datatype * dtype);
-/*
+/*
* myop takes a datatype that is a triple of doubles, and computes
* the sum, max, min of the respective elements of the triple.
*/
-void myop( void *cinPtr, void *coutPtr, int *count, MPI_Datatype *dtype )
+void myop(void *cinPtr, void *coutPtr, int *count, MPI_Datatype * dtype)
{
int i, n = *count;
- double const *cin = (double *)cinPtr;
- double *cout = (double *)coutPtr;
-
- for (i=0; i<n; i++) {
- cout[0] += cin[0];
- cout[1] = (cout[1] > cin[1]) ? cout[1] : cin[1];
- cout[2] = (cout[2] < cin[2]) ? cout[2] : cin[2];
- cin += 3;
- cout += 3;
+ double const *cin = (double *) cinPtr;
+ double *cout = (double *) coutPtr;
+
+ for (i = 0; i < n; i++) {
+ cout[0] += cin[0];
+ cout[1] = (cout[1] > cin[1]) ? cout[1] : cin[1];
+ cout[2] = (cout[2] < cin[2]) ? cout[2] : cin[2];
+ cin += 3;
+ cout += 3;
}
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int wsize, wrank, i, count;
@@ -48,62 +48,61 @@ int main( int argc, char *argv[] )
double maxval, sumval;
MPI_Op op;
- MTest_Init( &argc, &argv );
- MPI_Op_create( myop, 0, &op );
- MPI_Type_contiguous( 3, MPI_DOUBLE, &tripleType );
- MPI_Type_commit( &tripleType );
+ MTest_Init(&argc, &argv);
+ MPI_Op_create(myop, 0, &op);
+ MPI_Type_contiguous(3, MPI_DOUBLE, &tripleType);
+ MPI_Type_commit(&tripleType);
- MPI_Comm_size( MPI_COMM_WORLD, &wsize );
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
+ MPI_Comm_size(MPI_COMM_WORLD, &wsize);
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
- for (count=1; count<MAX_COUNT; count += count) {
- if (wrank == 0)
- MTestPrintfMsg( 1, "Count = %d\n", count );
- inVal = (double *)malloc( 3 * count * sizeof(double) );
- outVal = (double *)malloc( 3 * count * sizeof(double) );
- if (!inVal || !outVal) {
- fprintf( stderr, "Unable to allocated %d words for data\n",
- 3 * count );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- for (i=0; i<count*3; i++) {
- outVal[i] = -1;
- inVal[i] = 1 + (i & 0x3);
- }
- MPI_Reduce( inVal, outVal, count, tripleType, op, 0, MPI_COMM_WORLD );
- /* Check Result values */
- if (wrank == 0) {
- for (i=0; i<3*count; i+=3) {
- sumval = wsize * (1 + (i & 0x3));
- maxval = 1 + ((i+1) & 0x3);
- if (outVal[i] != sumval) {
- if (errs < MAX_ERRS)
- fprintf( stderr, "%d: outval[%d] = %f, expected %f (sum)\n",
- count, i, outVal[i], sumval );
- errs++;
- }
- if (outVal[i+1] != maxval) {
- if (errs < MAX_ERRS)
- fprintf( stderr, "%d: outval[%d] = %f, expected %f (max)\n",
- count, i+1, outVal[i+1], maxval );
- errs++;
- }
- if (outVal[i+2] != 1 + ((i+2)&0x3)) {
- if (errs < MAX_ERRS)
- fprintf( stderr, "%d: outval[%d] = %f, expected %f (min)\n",
- count, i+2, outVal[i+2], (double)(1 + ((i+2)^0x3)) );
- errs++;
- }
- }
- }
+ for (count = 1; count < MAX_COUNT; count += count) {
+ if (wrank == 0)
+ MTestPrintfMsg(1, "Count = %d\n", count);
+ inVal = (double *) malloc(3 * count * sizeof(double));
+ outVal = (double *) malloc(3 * count * sizeof(double));
+ if (!inVal || !outVal) {
+ fprintf(stderr, "Unable to allocated %d words for data\n", 3 * count);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ for (i = 0; i < count * 3; i++) {
+ outVal[i] = -1;
+ inVal[i] = 1 + (i & 0x3);
+ }
+ MPI_Reduce(inVal, outVal, count, tripleType, op, 0, MPI_COMM_WORLD);
+ /* Check Result values */
+ if (wrank == 0) {
+ for (i = 0; i < 3 * count; i += 3) {
+ sumval = wsize * (1 + (i & 0x3));
+ maxval = 1 + ((i + 1) & 0x3);
+ if (outVal[i] != sumval) {
+ if (errs < MAX_ERRS)
+ fprintf(stderr, "%d: outval[%d] = %f, expected %f (sum)\n",
+ count, i, outVal[i], sumval);
+ errs++;
+ }
+ if (outVal[i + 1] != maxval) {
+ if (errs < MAX_ERRS)
+ fprintf(stderr, "%d: outval[%d] = %f, expected %f (max)\n",
+ count, i + 1, outVal[i + 1], maxval);
+ errs++;
+ }
+ if (outVal[i + 2] != 1 + ((i + 2) & 0x3)) {
+ if (errs < MAX_ERRS)
+ fprintf(stderr, "%d: outval[%d] = %f, expected %f (min)\n",
+ count, i + 2, outVal[i + 2], (double) (1 + ((i + 2) ^ 0x3)));
+ errs++;
+ }
+ }
+ }
- free( inVal );
- free( outVal );
+ free(inVal);
+ free(outVal);
}
-
- MPI_Op_free( &op );
- MPI_Type_free( &tripleType );
- MTest_Finalize( errs );
- MPI_Finalize( );
+
+ MPI_Op_free(&op);
+ MPI_Type_free(&tripleType);
+ MTest_Finalize(errs);
+ MPI_Finalize();
return 0;
}
diff --git a/test/mpi/comm/cmfree.c b/test/mpi/comm/cmfree.c
index 771a12a..3044019 100644
--- a/test/mpi/comm/cmfree.c
+++ b/test/mpi/comm/cmfree.c
@@ -16,103 +16,104 @@ static char MTEST_Descrip[] = "Test that communicators have reference count sema
#define NELM 128
#define NCOMM 1020
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size, source, dest, i;
- MPI_Comm comm;
- MPI_Comm tmpComm[NCOMM];
- MPI_Status status;
- MPI_Request req;
- int *buf=0;
+ MPI_Comm comm;
+ MPI_Comm tmpComm[NCOMM];
+ MPI_Status status;
+ MPI_Request req;
+ int *buf = 0;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Comm_dup( MPI_COMM_WORLD, &comm );
+ MPI_Comm_dup(MPI_COMM_WORLD, &comm);
/* This is similar to the datatype test, except that we post
- an irecv on a simple data buffer but use a rank-reordered communicator.
- In this case, an error in handling the reference count will most
- likely cause the program to hang, so this should be run only
- if (a) you are confident that the code is correct or (b)
- a timeout is set for mpiexec
- */
+ * an irecv on a simple data buffer but use a rank-reordered communicator.
+ * In this case, an error in handling the reference count will most
+ * likely cause the program to hang, so this should be run only
+ * if (a) you are confident that the code is correct or (b)
+ * a timeout is set for mpiexec
+ */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
if (size < 2) {
- fprintf( stderr, "This test requires at least two processes." );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "This test requires at least two processes.");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- source = 0;
- dest = size - 1;
+ source = 0;
+ dest = size - 1;
if (rank == dest) {
- buf = (int *)malloc( NELM * sizeof(int) );
- for (i=0; i<NELM; i++) buf[i] = -i;
- MPI_Irecv( buf, NELM, MPI_INT, source, 0, comm, &req );
- MPI_Comm_free( &comm );
-
- if (comm != MPI_COMM_NULL) {
- errs++;
- printf( "Freed comm was not set to COMM_NULL\n" );
- }
-
- for (i=0; i<NCOMM; i++) {
- MPI_Comm_split( MPI_COMM_WORLD, 0, size - rank, &tmpComm[i] );
- }
-
- MPI_Sendrecv( NULL, 0, MPI_INT, source, 1,
- NULL, 0, MPI_INT, source, 1, MPI_COMM_WORLD, &status );
-
- MPI_Wait( &req, &status );
- for (i=0; i<NELM; i++) {
- if (buf[i] != i) {
- errs++;
- if (errs < 10) {
- printf( "buf[%d] = %d, expected %d\n", i, buf[i], i );
- }
- }
- }
- for (i=0; i<NCOMM; i++) {
- MPI_Comm_free( &tmpComm[i] );
- }
- free( buf );
+ buf = (int *) malloc(NELM * sizeof(int));
+ for (i = 0; i < NELM; i++)
+ buf[i] = -i;
+ MPI_Irecv(buf, NELM, MPI_INT, source, 0, comm, &req);
+ MPI_Comm_free(&comm);
+
+ if (comm != MPI_COMM_NULL) {
+ errs++;
+ printf("Freed comm was not set to COMM_NULL\n");
+ }
+
+ for (i = 0; i < NCOMM; i++) {
+ MPI_Comm_split(MPI_COMM_WORLD, 0, size - rank, &tmpComm[i]);
+ }
+
+ MPI_Sendrecv(NULL, 0, MPI_INT, source, 1,
+ NULL, 0, MPI_INT, source, 1, MPI_COMM_WORLD, &status);
+
+ MPI_Wait(&req, &status);
+ for (i = 0; i < NELM; i++) {
+ if (buf[i] != i) {
+ errs++;
+ if (errs < 10) {
+ printf("buf[%d] = %d, expected %d\n", i, buf[i], i);
+ }
+ }
+ }
+ for (i = 0; i < NCOMM; i++) {
+ MPI_Comm_free(&tmpComm[i]);
+ }
+ free(buf);
}
else if (rank == source) {
- buf = (int *)malloc( NELM * sizeof(int) );
- for (i=0; i<NELM; i++) buf[i] = i;
-
- for (i=0; i<NCOMM; i++) {
- MPI_Comm_split( MPI_COMM_WORLD, 0, size - rank, &tmpComm[i] );
- }
- /* Synchronize with the receiver */
- MPI_Sendrecv( NULL, 0, MPI_INT, dest, 1,
- NULL, 0, MPI_INT, dest, 1, MPI_COMM_WORLD, &status );
- MPI_Send( buf, NELM, MPI_INT, dest, 0, comm );
- free( buf );
+ buf = (int *) malloc(NELM * sizeof(int));
+ for (i = 0; i < NELM; i++)
+ buf[i] = i;
+
+ for (i = 0; i < NCOMM; i++) {
+ MPI_Comm_split(MPI_COMM_WORLD, 0, size - rank, &tmpComm[i]);
+ }
+ /* Synchronize with the receiver */
+ MPI_Sendrecv(NULL, 0, MPI_INT, dest, 1, NULL, 0, MPI_INT, dest, 1, MPI_COMM_WORLD, &status);
+ MPI_Send(buf, NELM, MPI_INT, dest, 0, comm);
+ free(buf);
}
else {
- for (i=0; i<NCOMM; i++) {
- MPI_Comm_split( MPI_COMM_WORLD, 0, size - rank, &tmpComm[i] );
- }
+ for (i = 0; i < NCOMM; i++) {
+ MPI_Comm_split(MPI_COMM_WORLD, 0, size - rank, &tmpComm[i]);
+ }
}
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
if (rank != dest) {
- /* Clean up the communicators */
- for (i=0; i<NCOMM; i++) {
- MPI_Comm_free( &tmpComm[i] );
- }
+ /* Clean up the communicators */
+ for (i = 0; i < NCOMM; i++) {
+ MPI_Comm_free(&tmpComm[i]);
+ }
}
if (comm != MPI_COMM_NULL) {
- MPI_Comm_free( &comm );
+ MPI_Comm_free(&comm);
}
-
- MTest_Finalize( errs );
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/comm/cmsplit.c b/test/mpi/comm/cmsplit.c
index c5f103e..216d890 100644
--- a/test/mpi/comm/cmsplit.c
+++ b/test/mpi/comm/cmsplit.c
@@ -13,43 +13,44 @@
static char MTEST_Descrip[] = "Test comm split";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size, color, srank;
- MPI_Comm comm, scomm;
+ MPI_Comm comm, scomm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Comm_dup( MPI_COMM_WORLD, &comm );
+ MPI_Comm_dup(MPI_COMM_WORLD, &comm);
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
if (size < 4) {
- fprintf( stderr, "This test requires at least four processes." );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "This test requires at least four processes.");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
color = MPI_UNDEFINED;
- if (rank < 2) color = 1;
- MPI_Comm_split( comm, color, size - rank, &scomm );
-
+ if (rank < 2)
+ color = 1;
+ MPI_Comm_split(comm, color, size - rank, &scomm);
+
if (rank < 2) {
- /* Check that the ranks are ordered correctly */
- MPI_Comm_rank( scomm, &srank );
- if (srank != 1 - rank) {
- errs++;
- }
- MPI_Comm_free( &scomm );
+ /* Check that the ranks are ordered correctly */
+ MPI_Comm_rank(scomm, &srank);
+ if (srank != 1 - rank) {
+ errs++;
+ }
+ MPI_Comm_free(&scomm);
}
else {
- if (scomm != MPI_COMM_NULL) {
- errs++;
- }
+ if (scomm != MPI_COMM_NULL) {
+ errs++;
+ }
}
- MPI_Comm_free( &comm );
- MTest_Finalize( errs );
+ MPI_Comm_free(&comm);
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/comm/cmsplit2.c b/test/mpi/comm/cmsplit2.c
index e711d29..985b5c9 100644
--- a/test/mpi/comm/cmsplit2.c
+++ b/test/mpi/comm/cmsplit2.c
@@ -105,11 +105,12 @@ int main(int argc, char **argv)
/* there's probably a better way to write these loop bounds and
* indices, but this is the first (correct) way that occurred to me */
for (j = 0; j < (size / modulus + (i < size % modulus ? 1 : 0)); ++j) {
- if (errs < ERRLIMIT && oldranks[pos] != i+modulus*j) {
- printf("size=%d i=%d j=%d modulus=%d pos=%d i+modulus*j=%d oldranks[pos]=%d\n",
- size, i, j, modulus, pos, i+modulus*j, oldranks[pos]);
+ if (errs < ERRLIMIT && oldranks[pos] != i + modulus * j) {
+ printf
+ ("size=%d i=%d j=%d modulus=%d pos=%d i+modulus*j=%d oldranks[pos]=%d\n",
+ size, i, j, modulus, pos, i + modulus * j, oldranks[pos]);
}
- my_assert(oldranks[pos] == i+modulus*j);
+ my_assert(oldranks[pos] == i + modulus * j);
++pos;
}
}
@@ -134,4 +135,3 @@ int main(int argc, char **argv)
MPI_Finalize();
return 0;
}
-
diff --git a/test/mpi/comm/cmsplit_type.c b/test/mpi/comm/cmsplit_type.c
index 75d3e4b..5385fac 100644
--- a/test/mpi/comm/cmsplit_type.c
+++ b/test/mpi/comm/cmsplit_type.c
@@ -14,7 +14,7 @@
int main(int argc, char *argv[])
{
- int rank, size, verbose=0;
+ int rank, size, verbose = 0;
int wrank;
MPI_Comm comm;
@@ -23,7 +23,7 @@ int main(int argc, char *argv[])
if (getenv("MPITEST_VERBOSE"))
verbose = 1;
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
/* Check to see if MPI_COMM_TYPE_SHARED works correctly */
MPI_Comm_split_type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL, &comm);
@@ -55,9 +55,9 @@ int main(int argc, char *argv[])
}
/* Use wrank because Comm_split_type may return more than one communicator
- across the job, and if so, each will have a rank 0 entry. Test
- output rules are for a single process to write the successful
- test (No Errors) output. */
+ * across the job, and if so, each will have a rank 0 entry. Test
+ * output rules are for a single process to write the successful
+ * test (No Errors) output. */
if (wrank == 0)
printf(" No errors\n");
diff --git a/test/mpi/comm/comm_group_rand.c b/test/mpi/comm/comm_group_rand.c
index a736043..681242d 100644
--- a/test/mpi/comm/comm_group_rand.c
+++ b/test/mpi/comm/comm_group_rand.c
@@ -28,11 +28,11 @@ int main(int argc, char **argv)
MPI_Comm_group(MPI_COMM_WORLD, &full_group);
for (j = 0; j < LOOPS; j++) {
- srand(j); /* Deterministic seed */
+ srand(j); /* Deterministic seed */
count = 0;
for (i = 0; i < size; i++) {
- if (rand() % 2) { /* randomly include a rank */
+ if (rand() % 2) { /* randomly include a rank */
included[i] = 1;
ranks[count++] = i;
}
diff --git a/test/mpi/comm/comm_idup.c b/test/mpi/comm/comm_idup.c
index 0823943..fc41ae1 100644
--- a/test/mpi/comm/comm_idup.c
+++ b/test/mpi/comm/comm_idup.c
@@ -75,7 +75,7 @@ int main(int argc, char **argv)
buf[0] = rank;
buf[1] = 0xfeedface;
MPI_Allreduce(&buf[0], &buf[1], 1, MPI_INT, MPI_SUM, newcomm);
- check(buf[1] == (size * (size-1) / 2));
+ check(buf[1] == (size * (size - 1) / 2));
MPI_Comm_free(&newcomm);
@@ -118,7 +118,7 @@ int main(int argc, char **argv)
buf[0] = lrank;
buf[1] = 0xfeedface;
MPI_Allreduce(&buf[0], &buf[1], 1, MPI_INT, MPI_SUM, newcomm);
- check(buf[1] == (rsize * (rsize-1) / 2));
+ check(buf[1] == (rsize * (rsize - 1) / 2));
/* free this down here, not before idup, otherwise it will undo our
* stagger_comm work */
@@ -146,4 +146,3 @@ int main(int argc, char **argv)
return 0;
}
-
diff --git a/test/mpi/comm/comm_idup_comm.c b/test/mpi/comm/comm_idup_comm.c
index c11dfed..0ac260e 100644
--- a/test/mpi/comm/comm_idup_comm.c
+++ b/test/mpi/comm/comm_idup_comm.c
@@ -27,7 +27,7 @@ int main(int argc, char **argv)
MPI_Comm idupcomms[NUM_IDUPS];
MPI_Request reqs[NUM_IDUPS];
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_group(MPI_COMM_WORLD, &world_group);
@@ -37,7 +37,7 @@ int main(int argc, char **argv)
MPI_Abort(MPI_COMM_WORLD, 1);
}
- /* Idup MPI_COMM_WORLD multiple times */
+ /* Idup MPI_COMM_WORLD multiple times */
for (i = 0; i < NUM_IDUPS; i++) {
MPI_Comm_idup(MPI_COMM_WORLD, &idupcomms[i], &reqs[i]);
}
@@ -50,13 +50,13 @@ int main(int argc, char **argv)
MTestFreeComm(&outcomm);
/* Comm_split */
- MPI_Comm_split(MPI_COMM_WORLD, rank%2, size-rank, &outcomm);
+ MPI_Comm_split(MPI_COMM_WORLD, rank % 2, size - rank, &outcomm);
errs += MTestTestComm(outcomm);
MTestFreeComm(&outcomm);
- /* Comm_create, high half of MPI_COMM_WORLD */
- ranges[0][0] = size/2;
- ranges[0][1] = size-1;
+ /* Comm_create, high half of MPI_COMM_WORLD */
+ ranges[0][0] = size / 2;
+ ranges[0][1] = size - 1;
ranges[0][2] = 1;
MPI_Group_range_incl(world_group, 1, ranges, &high_group);
MPI_Comm_create(MPI_COMM_WORLD, high_group, &outcomm);
@@ -66,16 +66,18 @@ int main(int argc, char **argv)
/* Comm_create_group, even ranks of MPI_COMM_WORLD */
/* exclude the odd ranks */
- excl = malloc((size/2) * sizeof(int));
- for (i = 0; i < size / 2; i++) excl[i] = (2 * i) + 1;
+ excl = malloc((size / 2) * sizeof(int));
+ for (i = 0; i < size / 2; i++)
+ excl[i] = (2 * i) + 1;
MPI_Group_excl(world_group, size / 2, excl, &even_group);
free(excl);
if (rank % 2 == 0) {
MPI_Comm_create_group(MPI_COMM_WORLD, even_group, 0, &outcomm);
- } else {
- outcomm = MPI_COMM_NULL;
+ }
+ else {
+ outcomm = MPI_COMM_NULL;
}
MPI_Group_free(&even_group);
@@ -83,12 +85,18 @@ int main(int argc, char **argv)
MTestFreeComm(&outcomm);
/* Intercomm_create & Intercomm_merge */
- MPI_Comm_split(MPI_COMM_WORLD, (rank < size/2), rank, &local_comm);
+ MPI_Comm_split(MPI_COMM_WORLD, (rank < size / 2), rank, &local_comm);
- if (rank == 0) { rleader = size/2; }
- else if (rank == size/2) { rleader = 0; }
- else { rleader = -1; }
- isLeft = rank < size/2;
+ if (rank == 0) {
+ rleader = size / 2;
+ }
+ else if (rank == size / 2) {
+ rleader = 0;
+ }
+ else {
+ rleader = -1;
+ }
+ isLeft = rank < size / 2;
MPI_Intercomm_create(local_comm, 0, MPI_COMM_WORLD, rleader, 99, &inter_comm);
MPI_Intercomm_merge(inter_comm, isLeft, &outcomm);
diff --git a/test/mpi/comm/comm_idup_iallreduce.c b/test/mpi/comm/comm_idup_iallreduce.c
index 8aedd51..670c23f 100644
--- a/test/mpi/comm/comm_idup_iallreduce.c
+++ b/test/mpi/comm/comm_idup_iallreduce.c
@@ -40,9 +40,9 @@ int main(int argc, char **argv)
int in, out, sol;
MPI_Comm newcomm, newcomm_v[ITERS], dup_comm, split, ic, merge;
- MPI_Request sreq[ITERS*2];
+ MPI_Request sreq[ITERS * 2];
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
@@ -59,19 +59,19 @@ int main(int argc, char **argv)
MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
/* Test results of overlapping allreduce */
- if(sol != out)
+ if (sol != out)
errs++;
/*Test new communicator */
errs += MTestTestComm(newcomm);
MPI_Comm_free(&newcomm);
- for(i = 0; i < ITERS; i++){
- MPI_Comm_idup(MPI_COMM_WORLD, &newcomm_v[i], &sreq[i]);
- MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &sreq[i+ITERS]);
+ for (i = 0; i < ITERS; i++) {
+ MPI_Comm_idup(MPI_COMM_WORLD, &newcomm_v[i], &sreq[i]);
+ MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &sreq[i + ITERS]);
}
- MPI_Waitall(ITERS*2,sreq, MPI_STATUS_IGNORE);
+ MPI_Waitall(ITERS * 2, sreq, MPI_STATUS_IGNORE);
- for( i = 0; i<ITERS ; i++) {
+ for (i = 0; i < ITERS; i++) {
errs += MTestTestComm(newcomm_v[i]);
MPI_Comm_free(&newcomm_v[i]);
}
@@ -80,63 +80,66 @@ int main(int argc, char **argv)
MPI_Comm_dup(MPI_COMM_WORLD, &dup_comm);
- if(rank == 0) {
- MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &sreq[0]);
- MPI_Comm_idup(dup_comm, &newcomm, &sreq[1]);
- MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
+ if (rank == 0) {
+ MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &sreq[0]);
+ MPI_Comm_idup(dup_comm, &newcomm, &sreq[1]);
+ MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
}
else {
- MPI_Comm_idup(dup_comm, &newcomm, &sreq[1]);
- MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &sreq[0]);
- MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
- }
+ MPI_Comm_idup(dup_comm, &newcomm, &sreq[1]);
+ MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &sreq[0]);
+ MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
+ }
/* Test Iallreduce */
- if(sol != out) errs++;
+ if (sol != out)
+ errs++;
/*Test new communicator */
errs += MTestTestComm(newcomm);
- MPI_Comm_free(&newcomm);
- MPI_Comm_free(&dup_comm);
+ MPI_Comm_free(&newcomm);
+ MPI_Comm_free(&dup_comm);
- MPI_Comm_split(MPI_COMM_WORLD, rank % 2, rank, &split);
- MPI_Comm_rank(split, &lrank);
- MPI_Comm_size(split, &lsize);
+ MPI_Comm_split(MPI_COMM_WORLD, rank % 2, rank, &split);
+ MPI_Comm_rank(split, &lrank);
+ MPI_Comm_size(split, &lsize);
- sol = lsize;
- if(lrank == 0) {
- MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, split, &sreq[0]);
- MPI_Comm_idup(MPI_COMM_WORLD, &newcomm, &sreq[1]);
- MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
+ sol = lsize;
+ if (lrank == 0) {
+ MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, split, &sreq[0]);
+ MPI_Comm_idup(MPI_COMM_WORLD, &newcomm, &sreq[1]);
+ MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
}
else {
- MPI_Comm_idup(MPI_COMM_WORLD, &newcomm, &sreq[1]);
- MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, split, &sreq[0]);
- MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
- }
+ MPI_Comm_idup(MPI_COMM_WORLD, &newcomm, &sreq[1]);
+ MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, split, &sreq[0]);
+ MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
+ }
/* Test Iallreduce */
- if(sol != out) errs++;;
+ if (sol != out)
+ errs++;;
/* Test new communicator */
errs += MTestTestComm(newcomm);
MPI_Comm_free(&newcomm);
sol = size;
- if(lrank == 0) {
- MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &sreq[0]);
- MPI_Comm_idup(split, &newcomm, &sreq[1]);
- MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
+ if (lrank == 0) {
+ MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &sreq[0]);
+ MPI_Comm_idup(split, &newcomm, &sreq[1]);
+ MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
}
else {
- MPI_Comm_idup(split, &newcomm, &sreq[1]);
- MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &sreq[0]);
- MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
+ MPI_Comm_idup(split, &newcomm, &sreq[1]);
+ MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &sreq[0]);
+ MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
}
/* Test Iallreduce */
- if(sol != out) errs++;;
+ if (sol != out)
+ errs++;;
/* Test new communicator */
errs += MTestTestComm(newcomm);
@@ -152,69 +155,72 @@ int main(int argc, char **argv)
MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
- if(sol != out) errs++;;
+ if (sol != out)
+ errs++;;
/* Test new inter communicator */
errs += MTestTestComm(newcomm);
MPI_Comm_free(&newcomm);
- sol = lsize;
- if(lrank == 0) {
- MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, split, &sreq[0]);
- MPI_Comm_idup(ic, &newcomm, &sreq[1]);
- MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
+ sol = lsize;
+ if (lrank == 0) {
+ MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, split, &sreq[0]);
+ MPI_Comm_idup(ic, &newcomm, &sreq[1]);
+ MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
}
else {
- MPI_Comm_idup(ic, &newcomm, &sreq[1]);
- MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, split, &sreq[0]);
- MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
- }
- /* Test Iallreduce resutls for split-communicator*/
- if(sol != out) errs++;;
+ MPI_Comm_idup(ic, &newcomm, &sreq[1]);
+ MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, split, &sreq[0]);
+ MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
+ }
+ /* Test Iallreduce resutls for split-communicator */
+ if (sol != out)
+ errs++;;
/* Test new inter-communicator */
- errs += MTestTestComm(newcomm);
- MPI_Comm_free(&newcomm);
+ errs += MTestTestComm(newcomm);
+ MPI_Comm_free(&newcomm);
- MPI_Intercomm_merge( ic, rank%2, &merge );
- MPI_Comm_size(merge, &isize);
+ MPI_Intercomm_merge(ic, rank % 2, &merge);
+ MPI_Comm_size(merge, &isize);
- sol = size;
- if(rank == 0) {
- MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &sreq[0]);
- MPI_Comm_idup(merge, &newcomm, &sreq[1]);
- MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
+ sol = size;
+ if (rank == 0) {
+ MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &sreq[0]);
+ MPI_Comm_idup(merge, &newcomm, &sreq[1]);
+ MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
}
else {
- MPI_Comm_idup(merge, &newcomm, &sreq[1]);
- MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &sreq[0]);
- MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
- }
-
-
- if(sol != out) errs++;;
- /* Test new communicator */
- errs += MTestTestComm(newcomm);
- MPI_Comm_free(&newcomm);
- sol = isize;
-
- if(rank == 0) {
- MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, merge, &sreq[0]);
- MPI_Comm_idup(MPI_COMM_WORLD, &newcomm, &sreq[1]);
- MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
+ MPI_Comm_idup(merge, &newcomm, &sreq[1]);
+ MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD, &sreq[0]);
+ MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
+ }
+
+
+ if (sol != out)
+ errs++;;
+ /* Test new communicator */
+ errs += MTestTestComm(newcomm);
+ MPI_Comm_free(&newcomm);
+ sol = isize;
+
+ if (rank == 0) {
+ MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, merge, &sreq[0]);
+ MPI_Comm_idup(MPI_COMM_WORLD, &newcomm, &sreq[1]);
+ MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
}
else {
- MPI_Comm_idup(MPI_COMM_WORLD, &newcomm, &sreq[1]);
- MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, merge, &sreq[0]);
- MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
- }
-
- MPI_Comm_free(&merge);
- MPI_Comm_free(&newcomm);
- MPI_Comm_free(&split);
- MPI_Comm_free(&ic);
-
- MTest_Finalize(errs);
- MPI_Finalize();
+ MPI_Comm_idup(MPI_COMM_WORLD, &newcomm, &sreq[1]);
+ MPI_Iallreduce(&in, &out, 1, MPI_INT, MPI_SUM, merge, &sreq[0]);
+ MPI_Waitall(2, sreq, MPI_STATUS_IGNORE);
+ }
+
+ MPI_Comm_free(&merge);
+ MPI_Comm_free(&newcomm);
+ MPI_Comm_free(&split);
+ MPI_Comm_free(&ic);
+
+ MTest_Finalize(errs);
+ MPI_Finalize();
}
diff --git a/test/mpi/comm/comm_idup_isend.c b/test/mpi/comm/comm_idup_isend.c
index 43afd81..1814dae 100644
--- a/test/mpi/comm/comm_idup_isend.c
+++ b/test/mpi/comm/comm_idup_isend.c
@@ -10,14 +10,14 @@
int main(int argc, char **argv)
{
int errs = 0;
- int i,j;
- int rank, size, rsize;
+ int i, j;
+ int rank, size, rsize;
int in[ITERS], out[ITERS], sol[ITERS], cnt;
int isLeft;
MPI_Comm newcomm[ITERS], testcomm;
MPI_Request *sreq;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
if (size < 2) {
@@ -26,75 +26,81 @@ int main(int argc, char **argv)
}
- sreq = (MPI_Request*)malloc(sizeof(MPI_Request)*(size+1)*ITERS);
+ sreq = (MPI_Request *) malloc(sizeof(MPI_Request) * (size + 1) * ITERS);
while (MTestGetIntracommGeneral(&testcomm, 1, 1)) {
- if (testcomm == MPI_COMM_NULL) continue;
+ if (testcomm == MPI_COMM_NULL)
+ continue;
MPI_Comm_rank(testcomm, &rank);
MPI_Comm_size(testcomm, &size);
cnt = 0;
- for(j = 0; j < ITERS; j++) {
- if(rank == 0) {
+ for (j = 0; j < ITERS; j++) {
+ if (rank == 0) {
out[j] = 815;
in[j] = 815;
sol[j] = 815;
- for(i = 1; i<size; i++)
- MPI_Isend(&out[j], 1, MPI_INT, i, 0, testcomm, &sreq[cnt++]);
+ for (i = 1; i < size; i++)
+ MPI_Isend(&out[j], 1, MPI_INT, i, 0, testcomm, &sreq[cnt++]);
MPI_Comm_idup(testcomm, &newcomm[j], &sreq[cnt++]);
- } else {
+ }
+ else {
out[j] = 0;
in[j] = 0;
sol[j] = 815;
MPI_Comm_idup(testcomm, &newcomm[j], &sreq[cnt++]);
MPI_Irecv(&in[j], 1, MPI_INT, 0, 0, testcomm, &sreq[cnt++]);
- }
+ }
- }
+ }
MPI_Waitall(cnt, sreq, MPI_STATUS_IGNORE);
- for(j = 0; j < ITERS; j++) {
- if(sol[j] != in[j]) errs++;
- errs+=MTestTestComm(newcomm[j]);
- MPI_Comm_free(&newcomm[j]);
- }
- MTestFreeComm(&testcomm);
+ for (j = 0; j < ITERS; j++) {
+ if (sol[j] != in[j])
+ errs++;
+ errs += MTestTestComm(newcomm[j]);
+ MPI_Comm_free(&newcomm[j]);
+ }
+ MTestFreeComm(&testcomm);
}
- while (MTestGetIntercomm(&testcomm, &isLeft, 1)) {
- if (testcomm == MPI_COMM_NULL) continue;
+ while (MTestGetIntercomm(&testcomm, &isLeft, 1)) {
+ if (testcomm == MPI_COMM_NULL)
+ continue;
MPI_Comm_rank(testcomm, &rank);
MPI_Comm_size(testcomm, &size);
MPI_Comm_remote_size(testcomm, &rsize);
cnt = 0;
- for(j = 0; j < ITERS; j++) {
- if(rank == 0) {
+ for (j = 0; j < ITERS; j++) {
+ if (rank == 0) {
out[j] = 815;
in[j] = 815;
sol[j] = 815;
- for(i = 1; i<rsize; i++)
- MPI_Isend(&out[j], 1, MPI_INT, i, 0, testcomm, &sreq[cnt++]);
+ for (i = 1; i < rsize; i++)
+ MPI_Isend(&out[j], 1, MPI_INT, i, 0, testcomm, &sreq[cnt++]);
MPI_Comm_idup(testcomm, &newcomm[j], &sreq[cnt++]);
- } else {
+ }
+ else {
out[j] = 0;
in[j] = 0;
sol[j] = 815;
MPI_Comm_idup(testcomm, &newcomm[j], &sreq[cnt++]);
MPI_Irecv(&in[j], 1, MPI_INT, 0, 0, testcomm, &sreq[cnt++]);
- }
+ }
- }
+ }
MPI_Waitall(cnt, sreq, MPI_STATUS_IGNORE);
- for(j = 0; j < ITERS; j++) {
- if(sol[j] != in[j]) errs++;
- errs+=MTestTestComm(newcomm[j]);
- MPI_Comm_free(&newcomm[j]);
- }
- MTestFreeComm(&testcomm);
+ for (j = 0; j < ITERS; j++) {
+ if (sol[j] != in[j])
+ errs++;
+ errs += MTestTestComm(newcomm[j]);
+ MPI_Comm_free(&newcomm[j]);
+ }
+ MTestFreeComm(&testcomm);
}
- MTest_Finalize(errs);
- MPI_Finalize();
+ MTest_Finalize(errs);
+ MPI_Finalize();
}
diff --git a/test/mpi/comm/comm_idup_nb.c b/test/mpi/comm/comm_idup_nb.c
index 67dc07b..2f86571 100644
--- a/test/mpi/comm/comm_idup_nb.c
+++ b/test/mpi/comm/comm_idup_nb.c
@@ -22,9 +22,9 @@ int main(int argc, char **argv)
MPI_Comm test_comm, new_comm[ITERS];
int in[ITERS], out[ITERS], sol;
int rank, size, rsize, rrank;
- MPI_Request sreq[ITERS*2];
+ MPI_Request sreq[ITERS * 2];
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
@@ -34,154 +34,162 @@ int main(int argc, char **argv)
}
while (MTestGetIntracommGeneral(&test_comm, 1, 1)) {
- if (test_comm == MPI_COMM_NULL) continue;
- MPI_Comm_size(test_comm, &size);
- MPI_Comm_rank(test_comm, &rank);
+ if (test_comm == MPI_COMM_NULL)
+ continue;
+ MPI_Comm_size(test_comm, &size);
+ MPI_Comm_rank(test_comm, &rank);
- /* Ibarrier */
- for(i = 0; i< ITERS; i++) {
+ /* Ibarrier */
+ for (i = 0; i < ITERS; i++) {
MPI_Ibarrier(test_comm, &sreq[i]);
- MPI_Comm_idup(test_comm, &new_comm[i], &sreq[i+ITERS]);
+ MPI_Comm_idup(test_comm, &new_comm[i], &sreq[i + ITERS]);
}
- MPI_Waitall(ITERS*2, sreq, MPI_STATUS_IGNORE);
+ MPI_Waitall(ITERS * 2, sreq, MPI_STATUS_IGNORE);
- for(i = 0; i< ITERS; i++) {
+ for (i = 0; i < ITERS; i++) {
errs += MTestTestComm(new_comm[i]);
MPI_Comm_free(&new_comm[i]);
- }
- /*Ibcast */
- for(i = 0; i< ITERS; i++) {
- if(rank == 0)
- in[i] = 815;
+ }
+ /*Ibcast */
+ for (i = 0; i < ITERS; i++) {
+ if (rank == 0)
+ in[i] = 815;
else
- in[i] = 10;
- MPI_Ibcast(&in[i], 1, MPI_INT, 0,test_comm, &sreq[i]);
- MPI_Comm_idup(test_comm, &new_comm[i], &sreq[i+ITERS]);
+ in[i] = 10;
+ MPI_Ibcast(&in[i], 1, MPI_INT, 0, test_comm, &sreq[i]);
+ MPI_Comm_idup(test_comm, &new_comm[i], &sreq[i + ITERS]);
}
sol = 815;
- MPI_Waitall(ITERS*2, sreq, MPI_STATUS_IGNORE);
+ MPI_Waitall(ITERS * 2, sreq, MPI_STATUS_IGNORE);
- for(i = 0; i< ITERS; i++) {
- if(in[i]!= sol) errs++;
+ for (i = 0; i < ITERS; i++) {
+ if (in[i] != sol)
+ errs++;
errs += MTestTestComm(new_comm[i]);
MPI_Comm_free(&new_comm[i]);
- }
+ }
/* Iallreduce */
- for(i = 0; i< ITERS; i++) {
+ for (i = 0; i < ITERS; i++) {
in[i] = 1;
- MPI_Iallreduce(&in[i], &out[i], 1, MPI_INT, MPI_SUM,test_comm, &sreq[i]);
- MPI_Comm_idup(test_comm, &new_comm[i], &sreq[i+ITERS]);
+ MPI_Iallreduce(&in[i], &out[i], 1, MPI_INT, MPI_SUM, test_comm, &sreq[i]);
+ MPI_Comm_idup(test_comm, &new_comm[i], &sreq[i + ITERS]);
}
sol = size;
- MPI_Waitall(ITERS*2, sreq, MPI_STATUS_IGNORE);
+ MPI_Waitall(ITERS * 2, sreq, MPI_STATUS_IGNORE);
- for(i = 0; i< ITERS; i++) {
- if(out[i]!= sol) errs++;
+ for (i = 0; i < ITERS; i++) {
+ if (out[i] != sol)
+ errs++;
errs += MTestTestComm(new_comm[i]);
MPI_Comm_free(&new_comm[i]);
- }
+ }
/* Isann */
- for(i = 0; i< ITERS; i++) {
+ for (i = 0; i < ITERS; i++) {
MPI_Iscan(&rank, &out[i], 1, MPI_INT, MPI_SUM, test_comm, &sreq[i]);
- MPI_Comm_idup(test_comm, &new_comm[i], &sreq[i+ITERS]);
+ MPI_Comm_idup(test_comm, &new_comm[i], &sreq[i + ITERS]);
}
- sol = rank*(rank+1)/2;
- MPI_Waitall(ITERS*2, sreq, MPI_STATUS_IGNORE);
+ sol = rank * (rank + 1) / 2;
+ MPI_Waitall(ITERS * 2, sreq, MPI_STATUS_IGNORE);
- for(i = 0; i< ITERS; i++) {
- if(out[i]!= sol) errs++;
+ for (i = 0; i < ITERS; i++) {
+ if (out[i] != sol)
+ errs++;
errs += MTestTestComm(new_comm[i]);
MPI_Comm_free(&new_comm[i]);
- }
- /*Ibcast */
- for(i = 0; i< ITERS; i++) {
- if(rank == 0)
- in[i] = 815;
+ }
+ /*Ibcast */
+ for (i = 0; i < ITERS; i++) {
+ if (rank == 0)
+ in[i] = 815;
else
- in[i] = 10;
- MPI_Ibcast(&in[i], 1, MPI_INT, 0,test_comm, &sreq[i]);
- MPI_Comm_idup(test_comm, &new_comm[i], &sreq[i+ITERS]);
+ in[i] = 10;
+ MPI_Ibcast(&in[i], 1, MPI_INT, 0, test_comm, &sreq[i]);
+ MPI_Comm_idup(test_comm, &new_comm[i], &sreq[i + ITERS]);
}
- MPI_Waitall(ITERS*2, sreq, MPI_STATUS_IGNORE);
+ MPI_Waitall(ITERS * 2, sreq, MPI_STATUS_IGNORE);
sol = 815;
- for(i = 0; i< ITERS; i++) {
- if(in[i]!= sol) errs++;
+ for (i = 0; i < ITERS; i++) {
+ if (in[i] != sol)
+ errs++;
errs += MTestTestComm(new_comm[i]);
MPI_Comm_free(&new_comm[i]);
- }
+ }
MTestFreeComm(&test_comm);
}
/* Now the test for inter-communicators */
- while (MTestGetIntercomm(&test_comm, &isleft, 1)) {
- if (test_comm == MPI_COMM_NULL) continue;
+ while (MTestGetIntercomm(&test_comm, &isleft, 1)) {
+ if (test_comm == MPI_COMM_NULL)
+ continue;
- MPI_Comm_size(test_comm, &size);
- MPI_Comm_rank(test_comm, &rank);
+ MPI_Comm_size(test_comm, &size);
+ MPI_Comm_rank(test_comm, &rank);
- MPI_Comm_remote_size(test_comm, &rsize);
- /* Ibarrier */
+ MPI_Comm_remote_size(test_comm, &rsize);
+ /* Ibarrier */
- for(i = 0; i< ITERS; i++) {
+ for (i = 0; i < ITERS; i++) {
MPI_Ibarrier(test_comm, &sreq[i]);
- MPI_Comm_idup(test_comm, &new_comm[i], &sreq[i+ITERS]);
+ MPI_Comm_idup(test_comm, &new_comm[i], &sreq[i + ITERS]);
}
- MPI_Waitall(ITERS*2, sreq, MPI_STATUS_IGNORE);
- for(i = 0; i< ITERS; i++) {
+ MPI_Waitall(ITERS * 2, sreq, MPI_STATUS_IGNORE);
+ for (i = 0; i < ITERS; i++) {
errs += MTestTestComm(new_comm[i]);
MPI_Comm_free(&new_comm[i]);
- }
-
- /*Ibcast */
- int root;
- for(i = 0; i< ITERS; i++) {
- if (isleft) {
- if (rank == 0) {
- root = MPI_ROOT;
- in[i] = 815;
- }
- else {
- root = MPI_PROC_NULL;
- in[i]= 815; /* not needed, just to make correctness checking easier */
- }
+ }
+
+ /*Ibcast */
+ int root;
+ for (i = 0; i < ITERS; i++) {
+ if (isleft) {
+ if (rank == 0) {
+ root = MPI_ROOT;
+ in[i] = 815;
+ }
+ else {
+ root = MPI_PROC_NULL;
+ in[i] = 815; /* not needed, just to make correctness checking easier */
+ }
}
else {
- root = 0;
- in[i] = 213; /* garbage value */
+ root = 0;
+ in[i] = 213; /* garbage value */
}
- MPI_Ibcast(&in[i], 1, MPI_INT, root,test_comm, &sreq[i]);
- MPI_Comm_idup(test_comm, &new_comm[i], &sreq[i+ITERS]);
+ MPI_Ibcast(&in[i], 1, MPI_INT, root, test_comm, &sreq[i]);
+ MPI_Comm_idup(test_comm, &new_comm[i], &sreq[i + ITERS]);
}
sol = 815;
- MPI_Waitall(ITERS*2, sreq, MPI_STATUS_IGNORE);
+ MPI_Waitall(ITERS * 2, sreq, MPI_STATUS_IGNORE);
- for(i = 0; i< ITERS; i++) {
- if(in[i]!= sol) errs++;
+ for (i = 0; i < ITERS; i++) {
+ if (in[i] != sol)
+ errs++;
errs += MTestTestComm(new_comm[i]);
MPI_Comm_free(&new_comm[i]);
- }
- /* Iallreduce */
- for(i = 0; i< ITERS; i++) {
- in[i] = 1;
- MPI_Iallreduce(&in[i], &out[i], 1, MPI_INT, MPI_SUM,test_comm, &sreq[i]);
- MPI_Comm_idup(test_comm, &new_comm[i], &sreq[i+ITERS]);
+ }
+ /* Iallreduce */
+ for (i = 0; i < ITERS; i++) {
+ in[i] = 1;
+ MPI_Iallreduce(&in[i], &out[i], 1, MPI_INT, MPI_SUM, test_comm, &sreq[i]);
+ MPI_Comm_idup(test_comm, &new_comm[i], &sreq[i + ITERS]);
}
sol = rsize;
- MPI_Waitall(ITERS*2, sreq, MPI_STATUS_IGNORE);
+ MPI_Waitall(ITERS * 2, sreq, MPI_STATUS_IGNORE);
- for(i = 0; i< ITERS; i++) {
- if(out[i]!= sol) errs++;
+ for (i = 0; i < ITERS; i++) {
+ if (out[i] != sol)
+ errs++;
errs += MTestTestComm(new_comm[i]);
MPI_Comm_free(&new_comm[i]);
- }
+ }
MTestFreeComm(&test_comm);
}
- MTest_Finalize( errs );
- MPI_Finalize();
+ MTest_Finalize(errs);
+ MPI_Finalize();
diff --git a/test/mpi/comm/commcreate1.c b/test/mpi/comm/commcreate1.c
index edb60fd..514dc6d 100644
--- a/test/mpi/comm/commcreate1.c
+++ b/test/mpi/comm/commcreate1.c
@@ -12,128 +12,128 @@
processes in the communicator.
*/
-void abortMsg( const char *, int );
-int BuildComm( MPI_Comm, MPI_Group, const char [] );
+void abortMsg(const char *, int);
+int BuildComm(MPI_Comm, MPI_Group, const char[]);
-void abortMsg( const char *str, int code )
+void abortMsg(const char *str, int code)
{
char msg[MPI_MAX_ERROR_STRING];
int class, resultLen;
- MPI_Error_class( code, &class );
- MPI_Error_string( code, msg, &resultLen );
- fprintf( stderr, "%s: errcode = %d, class = %d, msg = %s\n",
- str, code, class, msg );
- MPI_Abort( MPI_COMM_WORLD, code );
+ MPI_Error_class(code, &class);
+ MPI_Error_string(code, msg, &resultLen);
+ fprintf(stderr, "%s: errcode = %d, class = %d, msg = %s\n", str, code, class, msg);
+ MPI_Abort(MPI_COMM_WORLD, code);
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
- MPI_Comm dupWorld;
- int wrank, wsize, gsize, err, errs = 0;
- int ranges[1][3];
+ MPI_Comm dupWorld;
+ int wrank, wsize, gsize, err, errs = 0;
+ int ranges[1][3];
MPI_Group wGroup, godd, ghigh, geven;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Comm_size( MPI_COMM_WORLD, &wsize );
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
+ MPI_Comm_size(MPI_COMM_WORLD, &wsize);
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
/* Create some groups */
- MPI_Comm_group( MPI_COMM_WORLD, &wGroup );
+ MPI_Comm_group(MPI_COMM_WORLD, &wGroup);
- MTestPrintfMsg( 2, "Creating groups\n" );
- ranges[0][0] = 2*(wsize/2)-1;
+ MTestPrintfMsg(2, "Creating groups\n");
+ ranges[0][0] = 2 * (wsize / 2) - 1;
ranges[0][1] = 1;
ranges[0][2] = -2;
- err = MPI_Group_range_incl( wGroup, 1, ranges, &godd );
- if (err) abortMsg( "Failed to create odd group: ", err );
- err = MPI_Group_size( godd, &gsize );
- if (err) abortMsg( "Failed to get size of odd group: ", err );
- if (gsize != wsize/2) {
- fprintf( stderr, "Group godd size is %d should be %d\n", gsize,
- wsize/2 );
- errs++;
+ err = MPI_Group_range_incl(wGroup, 1, ranges, &godd);
+ if (err)
+ abortMsg("Failed to create odd group: ", err);
+ err = MPI_Group_size(godd, &gsize);
+ if (err)
+ abortMsg("Failed to get size of odd group: ", err);
+ if (gsize != wsize / 2) {
+ fprintf(stderr, "Group godd size is %d should be %d\n", gsize, wsize / 2);
+ errs++;
}
- ranges[0][0] = wsize/2+1;
- ranges[0][1] = wsize-1;
+ ranges[0][0] = wsize / 2 + 1;
+ ranges[0][1] = wsize - 1;
ranges[0][2] = 1;
- err = MPI_Group_range_incl( wGroup, 1, ranges, &ghigh );
- if (err) abortMsg( "Failed to create high group\n", err );
+ err = MPI_Group_range_incl(wGroup, 1, ranges, &ghigh);
+ if (err)
+ abortMsg("Failed to create high group\n", err);
ranges[0][0] = 0;
- ranges[0][1] = wsize-1;
+ ranges[0][1] = wsize - 1;
ranges[0][2] = 2;
- err = MPI_Group_range_incl( wGroup, 1, ranges, &geven );
- if (err) abortMsg( "Failed to create even group:", err );
+ err = MPI_Group_range_incl(wGroup, 1, ranges, &geven);
+ if (err)
+ abortMsg("Failed to create even group:", err);
- MPI_Comm_dup( MPI_COMM_WORLD, &dupWorld );
- MPI_Comm_set_name( dupWorld, (char*)"Dup of world" );
+ MPI_Comm_dup(MPI_COMM_WORLD, &dupWorld);
+ MPI_Comm_set_name(dupWorld, (char *) "Dup of world");
/* First, use the groups to create communicators from world and a dup
- of world */
- errs += BuildComm( MPI_COMM_WORLD, ghigh, "ghigh" );
- errs += BuildComm( MPI_COMM_WORLD, godd, "godd" );
- errs += BuildComm( MPI_COMM_WORLD, geven, "geven" );
- errs += BuildComm( dupWorld, ghigh, "ghigh" );
- errs += BuildComm( dupWorld, godd, "godd" );
- errs += BuildComm( dupWorld, geven, "geven" );
+ * of world */
+ errs += BuildComm(MPI_COMM_WORLD, ghigh, "ghigh");
+ errs += BuildComm(MPI_COMM_WORLD, godd, "godd");
+ errs += BuildComm(MPI_COMM_WORLD, geven, "geven");
+ errs += BuildComm(dupWorld, ghigh, "ghigh");
+ errs += BuildComm(dupWorld, godd, "godd");
+ errs += BuildComm(dupWorld, geven, "geven");
#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
/* check that we can create multiple communicators from a single collective
* call to MPI_Comm_create as long as the groups are all disjoint */
- errs += BuildComm( MPI_COMM_WORLD, (wrank % 2 ? godd : geven), "godd+geven" );
- errs += BuildComm( dupWorld, (wrank % 2 ? godd : geven), "godd+geven" );
- errs += BuildComm( MPI_COMM_WORLD, MPI_GROUP_EMPTY, "MPI_GROUP_EMPTY" );
- errs += BuildComm( dupWorld, MPI_GROUP_EMPTY, "MPI_GROUP_EMPTY" );
+ errs += BuildComm(MPI_COMM_WORLD, (wrank % 2 ? godd : geven), "godd+geven");
+ errs += BuildComm(dupWorld, (wrank % 2 ? godd : geven), "godd+geven");
+ errs += BuildComm(MPI_COMM_WORLD, MPI_GROUP_EMPTY, "MPI_GROUP_EMPTY");
+ errs += BuildComm(dupWorld, MPI_GROUP_EMPTY, "MPI_GROUP_EMPTY");
#endif
- MPI_Comm_free( &dupWorld );
- MPI_Group_free( &ghigh );
- MPI_Group_free( &godd );
- MPI_Group_free( &geven );
- MPI_Group_free( &wGroup );
+ MPI_Comm_free(&dupWorld);
+ MPI_Group_free(&ghigh);
+ MPI_Group_free(&godd);
+ MPI_Group_free(&geven);
+ MPI_Group_free(&wGroup);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
-int BuildComm( MPI_Comm oldcomm, MPI_Group group, const char gname[] )
+int BuildComm(MPI_Comm oldcomm, MPI_Group group, const char gname[])
{
MPI_Comm newcomm;
int grank, gsize, rank, size, errs = 0;
- char cname[MPI_MAX_OBJECT_NAME+1];
- int cnamelen;
-
- MPI_Group_rank( group, &grank );
- MPI_Group_size( group, &gsize );
- MPI_Comm_get_name( oldcomm, cname, &cnamelen );
- MTestPrintfMsg( 2, "Testing comm %s from %s\n", cname, gname );
- MPI_Comm_create( oldcomm, group, &newcomm );
+ char cname[MPI_MAX_OBJECT_NAME + 1];
+ int cnamelen;
+
+ MPI_Group_rank(group, &grank);
+ MPI_Group_size(group, &gsize);
+ MPI_Comm_get_name(oldcomm, cname, &cnamelen);
+ MTestPrintfMsg(2, "Testing comm %s from %s\n", cname, gname);
+ MPI_Comm_create(oldcomm, group, &newcomm);
if (newcomm == MPI_COMM_NULL && grank != MPI_UNDEFINED) {
- errs ++;
- fprintf( stderr, "newcomm is null but process is in group\n" );
+ errs++;
+ fprintf(stderr, "newcomm is null but process is in group\n");
}
if (newcomm != MPI_COMM_NULL && grank == MPI_UNDEFINED) {
- errs ++;
- fprintf( stderr, "newcomm is not null but process is not in group\n" );
+ errs++;
+ fprintf(stderr, "newcomm is not null but process is not in group\n");
}
if (newcomm != MPI_COMM_NULL && grank != MPI_UNDEFINED) {
- MPI_Comm_rank( newcomm, &rank );
- if (rank != grank) {
- errs ++;
- fprintf( stderr, "Rank is %d should be %d in comm from %s\n",
- rank, grank, gname );
- }
- MPI_Comm_size( newcomm, &size );
- if (size != gsize) {
- errs++;
- fprintf( stderr, "Size is %d should be %d in comm from %s\n",
- size, gsize, gname );
- }
- MPI_Comm_free( &newcomm );
- MTestPrintfMsg( 2, "Done testing comm %s from %s\n", cname, gname );
+ MPI_Comm_rank(newcomm, &rank);
+ if (rank != grank) {
+ errs++;
+ fprintf(stderr, "Rank is %d should be %d in comm from %s\n", rank, grank, gname);
+ }
+ MPI_Comm_size(newcomm, &size);
+ if (size != gsize) {
+ errs++;
+ fprintf(stderr, "Size is %d should be %d in comm from %s\n", size, gsize, gname);
+ }
+ MPI_Comm_free(&newcomm);
+ MTestPrintfMsg(2, "Done testing comm %s from %s\n", cname, gname);
}
return errs;
}
diff --git a/test/mpi/comm/commname.c b/test/mpi/comm/commname.c
index 6a7a736..ed52049 100644
--- a/test/mpi/comm/commname.c
+++ b/test/mpi/comm/commname.c
@@ -14,51 +14,49 @@
#include <string.h>
#endif
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
MPI_Comm comm;
int cnt, rlen;
char name[MPI_MAX_OBJECT_NAME], nameout[MPI_MAX_OBJECT_NAME];
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
/* Check world and self firt */
nameout[0] = 0;
- MPI_Comm_get_name( MPI_COMM_WORLD, nameout, &rlen );
- if (strcmp(nameout,"MPI_COMM_WORLD")) {
- errs++;
- printf( "Name of comm world is %s, should be MPI_COMM_WORLD\n",
- nameout );
+ MPI_Comm_get_name(MPI_COMM_WORLD, nameout, &rlen);
+ if (strcmp(nameout, "MPI_COMM_WORLD")) {
+ errs++;
+ printf("Name of comm world is %s, should be MPI_COMM_WORLD\n", nameout);
}
nameout[0] = 0;
- MPI_Comm_get_name( MPI_COMM_SELF, nameout, &rlen );
- if (strcmp(nameout,"MPI_COMM_SELF")) {
- errs++;
- printf( "Name of comm self is %s, should be MPI_COMM_SELF\n",
- nameout );
+ MPI_Comm_get_name(MPI_COMM_SELF, nameout, &rlen);
+ if (strcmp(nameout, "MPI_COMM_SELF")) {
+ errs++;
+ printf("Name of comm self is %s, should be MPI_COMM_SELF\n", nameout);
}
/* Now, handle other communicators, including world/self */
cnt = 0;
- while (MTestGetComm( &comm, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
-
- sprintf( name, "comm-%d", cnt );
- cnt++;
- MPI_Comm_set_name( comm, name );
- nameout[0] = 0;
- MPI_Comm_get_name( comm, nameout, &rlen );
- if (strcmp( name, nameout )) {
- errs++;
- printf( "Unexpected name, was %s but should be %s\n",
- nameout, name );
- }
-
- MTestFreeComm( &comm );
+ while (MTestGetComm(&comm, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+
+ sprintf(name, "comm-%d", cnt);
+ cnt++;
+ MPI_Comm_set_name(comm, name);
+ nameout[0] = 0;
+ MPI_Comm_get_name(comm, nameout, &rlen);
+ if (strcmp(name, nameout)) {
+ errs++;
+ printf("Unexpected name, was %s but should be %s\n", nameout, name);
+ }
+
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/comm/ctxalloc.c b/test/mpi/comm/ctxalloc.c
index ef66be3..97c8466 100644
--- a/test/mpi/comm/ctxalloc.c
+++ b/test/mpi/comm/ctxalloc.c
@@ -10,51 +10,51 @@
/*
* This program tests the allocation (and deallocation) of contexts.
- *
+ *
*/
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
int errs = 0;
int i, j, err;
MPI_Comm newcomm1, newcomm2[200];
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
/* Get a separate communicator to duplicate */
- MPI_Comm_dup( MPI_COMM_WORLD, &newcomm1 );
+ MPI_Comm_dup(MPI_COMM_WORLD, &newcomm1);
- MPI_Errhandler_set( newcomm1, MPI_ERRORS_RETURN );
+ MPI_Errhandler_set(newcomm1, MPI_ERRORS_RETURN);
/* Allocate many communicators in batches, then free them */
- for (i=0; i<1000; i++) {
- for (j=0; j<200; j++) {
- err = MPI_Comm_dup( newcomm1, &newcomm2[j] );
- if (err) {
- errs++;
- if (errs < 10) {
- fprintf( stderr, "Failed to duplicate communicator for (%d,%d)\n", i, j );
- MTestPrintError( err );
- }
- }
- }
- for (j=0; j<200; j++) {
- err = MPI_Comm_free( &newcomm2[j] );
- if (err) {
- errs++;
- if (errs < 10) {
- fprintf( stderr, "Failed to free %d,%d\n", i, j );
- MTestPrintError( err );
- }
- }
- }
+ for (i = 0; i < 1000; i++) {
+ for (j = 0; j < 200; j++) {
+ err = MPI_Comm_dup(newcomm1, &newcomm2[j]);
+ if (err) {
+ errs++;
+ if (errs < 10) {
+ fprintf(stderr, "Failed to duplicate communicator for (%d,%d)\n", i, j);
+ MTestPrintError(err);
+ }
+ }
+ }
+ for (j = 0; j < 200; j++) {
+ err = MPI_Comm_free(&newcomm2[j]);
+ if (err) {
+ errs++;
+ if (errs < 10) {
+ fprintf(stderr, "Failed to free %d,%d\n", i, j);
+ MTestPrintError(err);
+ }
+ }
+ }
}
- err = MPI_Comm_free( &newcomm1 );
+ err = MPI_Comm_free(&newcomm1);
if (err) {
- errs++;
- fprintf( stderr, "Failed to free newcomm1\n" );
- MTestPrintError( err );
+ errs++;
+ fprintf(stderr, "Failed to free newcomm1\n");
+ MTestPrintError(err);
}
-
- MTest_Finalize( errs );
+
+ MTest_Finalize(errs);
MPI_Finalize();
diff --git a/test/mpi/comm/ctxsplit.c b/test/mpi/comm/ctxsplit.c
index 4e73dc5..a235cac 100644
--- a/test/mpi/comm/ctxsplit.c
+++ b/test/mpi/comm/ctxsplit.c
@@ -11,70 +11,71 @@
#include "mpitest.h"
/*
- * This check is intended to fail if there is a leak of context ids.
+ * This check is intended to fail if there is a leak of context ids.
* Because this is trying to exhaust the number of context ids, it needs
- * to run for a longer time than many tests. The for loop uses 100,000
+ * to run for a longer time than many tests. The for loop uses 100,000
* iterations, which is adequate for MPICH (with only about 1k context ids
* available).
*/
-int main(int argc, char** argv) {
+int main(int argc, char **argv)
+{
- int i=0;
- int randval;
- int rank;
- int errs = 0;
- MPI_Comm newcomm;
- double startTime;
- int nLoop = 100000;
-
- MTest_Init(&argc,&argv);
+ int i = 0;
+ int randval;
+ int rank;
+ int errs = 0;
+ MPI_Comm newcomm;
+ double startTime;
+ int nLoop = 100000;
- for (i=1; i<argc; i++) {
- if (strcmp( argv[i], "--loopcount" ) == 0) {
- i++;
- nLoop = atoi( argv[i] );
- }
- else {
- fprintf( stderr, "Unrecognized argument %s\n", argv[i] );
- }
- }
+ MTest_Init(&argc, &argv);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "--loopcount") == 0) {
+ i++;
+ nLoop = atoi(argv[i]);
+ }
+ else {
+ fprintf(stderr, "Unrecognized argument %s\n", argv[i]);
+ }
+ }
- startTime = MPI_Wtime();
- for (i=0; i<nLoop; i++) {
-
- if ( rank == 0 && (i%100 == 0) ) {
- double rate = MPI_Wtime() - startTime;
- if (rate > 0) {
- rate = i / rate;
- MTestPrintfMsg( 10, "After %d (%f)\n", i, rate );
- }
- else {
- MTestPrintfMsg( 10, "After %d\n", i );
- }
- }
-
- /* FIXME: Explain the rationale behind rand in this test */
- randval=rand();
-
- if (randval%(rank+2) == 0) {
- MPI_Comm_split(MPI_COMM_WORLD,1,rank,&newcomm);
- MPI_Comm_free( &newcomm );
- }
- else {
- MPI_Comm_split(MPI_COMM_WORLD,MPI_UNDEFINED,rank,&newcomm);
- if (newcomm != MPI_COMM_NULL) {
- errs++;
- printf( "Created a non-null communicator with MPI_UNDEFINED\n" );
- }
- }
-
- }
-
- MTest_Finalize( errs );
- MPI_Finalize();
-
- return 0;
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+
+ startTime = MPI_Wtime();
+ for (i = 0; i < nLoop; i++) {
+
+ if (rank == 0 && (i % 100 == 0)) {
+ double rate = MPI_Wtime() - startTime;
+ if (rate > 0) {
+ rate = i / rate;
+ MTestPrintfMsg(10, "After %d (%f)\n", i, rate);
+ }
+ else {
+ MTestPrintfMsg(10, "After %d\n", i);
+ }
+ }
+
+ /* FIXME: Explain the rationale behind rand in this test */
+ randval = rand();
+
+ if (randval % (rank + 2) == 0) {
+ MPI_Comm_split(MPI_COMM_WORLD, 1, rank, &newcomm);
+ MPI_Comm_free(&newcomm);
+ }
+ else {
+ MPI_Comm_split(MPI_COMM_WORLD, MPI_UNDEFINED, rank, &newcomm);
+ if (newcomm != MPI_COMM_NULL) {
+ errs++;
+ printf("Created a non-null communicator with MPI_UNDEFINED\n");
+ }
+ }
+
+ }
+
+ MTest_Finalize(errs);
+ MPI_Finalize();
+
+ return 0;
}
diff --git a/test/mpi/comm/dup.c b/test/mpi/comm/dup.c
index a30975f..7129ef6 100644
--- a/test/mpi/comm/dup.c
+++ b/test/mpi/comm/dup.c
@@ -8,72 +8,68 @@
#include <stdio.h>
#include "mpitest.h"
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
int errs = 0;
int rank, size, wrank, wsize, dest, a, b;
MPI_Comm newcomm;
MPI_Status status;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
/* Can we run comm dup at all? */
- MPI_Comm_dup( MPI_COMM_WORLD, &newcomm );
+ MPI_Comm_dup(MPI_COMM_WORLD, &newcomm);
/* Check basic properties */
- MPI_Comm_size( MPI_COMM_WORLD, &wsize );
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
- MPI_Comm_size( newcomm, &size );
- MPI_Comm_rank( newcomm, &rank );
-
+ MPI_Comm_size(MPI_COMM_WORLD, &wsize);
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
+ MPI_Comm_size(newcomm, &size);
+ MPI_Comm_rank(newcomm, &rank);
+
if (size != wsize || rank != wrank) {
- errs++;
- fprintf( stderr, "Size (%d) or rank (%d) wrong\n", size, rank );
- fflush( stderr );
+ errs++;
+ fprintf(stderr, "Size (%d) or rank (%d) wrong\n", size, rank);
+ fflush(stderr);
}
/* Can we communicate with this new communicator? */
dest = MPI_PROC_NULL;
if (rank == 0) {
- dest = size - 1;
- a = rank;
- b = -1;
- MPI_Sendrecv( &a, 1, MPI_INT, dest, 0,
- &b, 1, MPI_INT, dest, 0, newcomm, &status );
- if (b != dest) {
- errs++;
- fprintf( stderr, "Received %d expected %d on %d\n", b, dest, rank );
- fflush( stderr );
- }
- if (status.MPI_SOURCE != dest) {
- errs++;
- fprintf( stderr, "Source not set correctly in status on %d\n",
- rank );
- fflush( stderr );
- }
+ dest = size - 1;
+ a = rank;
+ b = -1;
+ MPI_Sendrecv(&a, 1, MPI_INT, dest, 0, &b, 1, MPI_INT, dest, 0, newcomm, &status);
+ if (b != dest) {
+ errs++;
+ fprintf(stderr, "Received %d expected %d on %d\n", b, dest, rank);
+ fflush(stderr);
+ }
+ if (status.MPI_SOURCE != dest) {
+ errs++;
+ fprintf(stderr, "Source not set correctly in status on %d\n", rank);
+ fflush(stderr);
+ }
}
- else if (rank == size-1) {
- dest = 0;
- a = rank;
- b = -1;
- MPI_Sendrecv( &a, 1, MPI_INT, dest, 0,
- &b, 1, MPI_INT, dest, 0, newcomm, &status );
- if (b != dest) {
- errs++;
- fprintf( stderr, "Received %d expected %d on %d\n", b, dest, rank );
- fflush( stderr );
- }
- if (status.MPI_SOURCE != dest) {
- errs++;
- fprintf( stderr, "Source not set correctly in status on %d\n",
- rank );
- fflush( stderr );
- }
+ else if (rank == size - 1) {
+ dest = 0;
+ a = rank;
+ b = -1;
+ MPI_Sendrecv(&a, 1, MPI_INT, dest, 0, &b, 1, MPI_INT, dest, 0, newcomm, &status);
+ if (b != dest) {
+ errs++;
+ fprintf(stderr, "Received %d expected %d on %d\n", b, dest, rank);
+ fflush(stderr);
+ }
+ if (status.MPI_SOURCE != dest) {
+ errs++;
+ fprintf(stderr, "Source not set correctly in status on %d\n", rank);
+ fflush(stderr);
+ }
}
- MPI_Comm_free( &newcomm );
+ MPI_Comm_free(&newcomm);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
diff --git a/test/mpi/comm/dupic.c b/test/mpi/comm/dupic.c
index 8a79fb5..e371276 100644
--- a/test/mpi/comm/dupic.c
+++ b/test/mpi/comm/dupic.c
@@ -8,7 +8,7 @@
#include <stdio.h>
#include "mpitest.h"
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
MPI_Comm comm, dupcomm, dupcomm2;
@@ -18,78 +18,76 @@ int main( int argc, char *argv[] )
int r1buf, r2buf, s1buf, s2buf;
int rank, isLeft;
- MTest_Init( &argc, &argv );
-
- while (MTestGetIntercomm( &comm, &isLeft, 2 )) {
- if (comm == MPI_COMM_NULL) continue;
+ MTest_Init(&argc, &argv);
- MPI_Comm_dup( comm, &dupcomm );
-
- /* Check that there are separate contexts. We do this by setting
- up nonblocking received on both communicators, and then
- sending to them. If the contexts are different, tests on the
- unsatisfied communicator should indicate no available message */
- MPI_Comm_rank( comm, &rank );
- if (rank == 0) {
- s1buf = 456;
- s2buf = 17;
- r1buf = r2buf = -1;
- /* These are send/receives to the process with rank zero
- in the other group (these are intercommunicators) */
- MPI_Irecv( &r1buf, 1, MPI_INT, 0, 0, dupcomm, &rreq[0] );
- MPI_Irecv( &r2buf, 1, MPI_INT, 0, 0, comm, &rreq[1] );
- MPI_Send( &s2buf, 1, MPI_INT, 0, 0, comm );
- MPI_Waitsome(2, rreq, &count, indicies, MPI_STATUSES_IGNORE);
- if (count != 1 || indicies[0] != 1) {
- /* The only valid return is that exactly one message
- has been received */
- errs++;
- if (count == 1 && indicies[0] != 1) {
- printf( "Error in context values for intercomm\n" );
- }
- else if (count == 2) {
- printf( "Error: two messages received!\n" );
- }
- else {
- int i;
- printf( "Error: count = %d", count );
- for (i=0; i<count; i++) {
- printf( " indicies[%d] = %d", i, indicies[i] );
- }
- printf( "\n" );
- }
- }
-
- /* Make sure that we do not send the next message until
- the other process (rank zero in the other group)
- has also completed the first step */
- MPI_Sendrecv( MPI_BOTTOM, 0, MPI_BYTE, 0, 37,
- MPI_BOTTOM, 0, MPI_BYTE, 0, 37, comm,
- MPI_STATUS_IGNORE );
+ while (MTestGetIntercomm(&comm, &isLeft, 2)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
- /* Complete the receive on dupcomm */
- MPI_Send( &s1buf, 1, MPI_INT, 0, 0, dupcomm );
- MPI_Wait( &rreq[0], MPI_STATUS_IGNORE );
- if (r1buf != s1buf) {
- errs++;
- printf( "Wrong value in communication on dupcomm %d != %d\n",
- r1buf, s1buf );
- }
- if (r2buf != s2buf) {
- errs++;
- printf( "Wrong value in communication on comm %d != %d\n",
- r2buf, s2buf );
- }
- }
- /* Try to duplicate a duplicated intercomm. (This caused problems
- with some MPIs) */
- MPI_Comm_dup( dupcomm, &dupcomm2 );
- MPI_Comm_free( &dupcomm2 );
- MPI_Comm_free( &dupcomm );
- MTestFreeComm( &comm );
+ MPI_Comm_dup(comm, &dupcomm);
+
+ /* Check that there are separate contexts. We do this by setting
+ * up nonblocking received on both communicators, and then
+ * sending to them. If the contexts are different, tests on the
+ * unsatisfied communicator should indicate no available message */
+ MPI_Comm_rank(comm, &rank);
+ if (rank == 0) {
+ s1buf = 456;
+ s2buf = 17;
+ r1buf = r2buf = -1;
+ /* These are send/receives to the process with rank zero
+ * in the other group (these are intercommunicators) */
+ MPI_Irecv(&r1buf, 1, MPI_INT, 0, 0, dupcomm, &rreq[0]);
+ MPI_Irecv(&r2buf, 1, MPI_INT, 0, 0, comm, &rreq[1]);
+ MPI_Send(&s2buf, 1, MPI_INT, 0, 0, comm);
+ MPI_Waitsome(2, rreq, &count, indicies, MPI_STATUSES_IGNORE);
+ if (count != 1 || indicies[0] != 1) {
+ /* The only valid return is that exactly one message
+ * has been received */
+ errs++;
+ if (count == 1 && indicies[0] != 1) {
+ printf("Error in context values for intercomm\n");
+ }
+ else if (count == 2) {
+ printf("Error: two messages received!\n");
+ }
+ else {
+ int i;
+ printf("Error: count = %d", count);
+ for (i = 0; i < count; i++) {
+ printf(" indicies[%d] = %d", i, indicies[i]);
+ }
+ printf("\n");
+ }
+ }
+
+ /* Make sure that we do not send the next message until
+ * the other process (rank zero in the other group)
+ * has also completed the first step */
+ MPI_Sendrecv(MPI_BOTTOM, 0, MPI_BYTE, 0, 37,
+ MPI_BOTTOM, 0, MPI_BYTE, 0, 37, comm, MPI_STATUS_IGNORE);
+
+ /* Complete the receive on dupcomm */
+ MPI_Send(&s1buf, 1, MPI_INT, 0, 0, dupcomm);
+ MPI_Wait(&rreq[0], MPI_STATUS_IGNORE);
+ if (r1buf != s1buf) {
+ errs++;
+ printf("Wrong value in communication on dupcomm %d != %d\n", r1buf, s1buf);
+ }
+ if (r2buf != s2buf) {
+ errs++;
+ printf("Wrong value in communication on comm %d != %d\n", r2buf, s2buf);
+ }
+ }
+ /* Try to duplicate a duplicated intercomm. (This caused problems
+ * with some MPIs) */
+ MPI_Comm_dup(dupcomm, &dupcomm2);
+ MPI_Comm_free(&dupcomm2);
+ MPI_Comm_free(&dupcomm);
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/comm/ic1.c b/test/mpi/comm/ic1.c
index bbe5df1..952016b 100644
--- a/test/mpi/comm/ic1.c
+++ b/test/mpi/comm/ic1.c
@@ -11,53 +11,49 @@
#include <stdio.h>
#include "mpitest.h"
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Comm intercomm;
- int remote_rank, rank, size, errs = 0;
+ int remote_rank, rank, size, errs = 0;
volatile int trigger;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
trigger = 1;
/* while (trigger) ; */
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
if (size < 2) {
- printf( "Size must be at least 2\n" );
- MPI_Abort( MPI_COMM_WORLD, 0 );
+ printf("Size must be at least 2\n");
+ MPI_Abort(MPI_COMM_WORLD, 0);
}
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
/* Make an intercomm of the first two elements of comm_world */
if (rank < 2) {
- int lrank = rank, rrank = -1;
- MPI_Status status;
+ int lrank = rank, rrank = -1;
+ MPI_Status status;
- remote_rank = 1 - rank;
- MPI_Intercomm_create( MPI_COMM_SELF, 0,
- MPI_COMM_WORLD, remote_rank, 27,
- &intercomm );
+ remote_rank = 1 - rank;
+ MPI_Intercomm_create(MPI_COMM_SELF, 0, MPI_COMM_WORLD, remote_rank, 27, &intercomm);
- /* Now, communicate between them */
- MPI_Sendrecv( &lrank, 1, MPI_INT, 0, 13,
- &rrank, 1, MPI_INT, 0, 13, intercomm, &status );
+ /* Now, communicate between them */
+ MPI_Sendrecv(&lrank, 1, MPI_INT, 0, 13, &rrank, 1, MPI_INT, 0, 13, intercomm, &status);
- if (rrank != remote_rank) {
- errs++;
- printf( "%d Expected %d but received %d\n",
- rank, remote_rank, rrank );
- }
+ if (rrank != remote_rank) {
+ errs++;
+ printf("%d Expected %d but received %d\n", rank, remote_rank, rrank);
+ }
- MPI_Comm_free( &intercomm );
+ MPI_Comm_free(&intercomm);
}
-
+
/* The next test should create an intercomm with groups of different
- sizes FIXME */
+ * sizes FIXME */
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
-
+
return 0;
}
diff --git a/test/mpi/comm/ic2.c b/test/mpi/comm/ic2.c
index 8385648..14d8c96 100644
--- a/test/mpi/comm/ic2.c
+++ b/test/mpi/comm/ic2.c
@@ -79,8 +79,7 @@ int main(int argc, char **argv)
MPI_Comm_free(&ic);
- MPI_Reduce((rank == 0 ? MPI_IN_PLACE : &errs), &errs,
- 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
+ MPI_Reduce((rank == 0 ? MPI_IN_PLACE : &errs), &errs, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
if (rank == 0) {
if (errs) {
printf("found %d errors\n", errs);
@@ -93,4 +92,3 @@ int main(int argc, char **argv)
return 0;
}
-
diff --git a/test/mpi/comm/iccreate.c b/test/mpi/comm/iccreate.c
index b2dc85e..64ce1ed 100644
--- a/test/mpi/comm/iccreate.c
+++ b/test/mpi/comm/iccreate.c
@@ -13,96 +13,102 @@
* This program tests that MPI_Comm_create applies to intercommunicators;
* this is an extension added in MPI-2
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int size, isLeft, wrank;
MPI_Comm intercomm, newcomm;
MPI_Group oldgroup, newgroup;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
if (size < 4) {
- printf( "This test requires at least 4 processes\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ printf("This test requires at least 4 processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
-
- while (MTestGetIntercomm( &intercomm, &isLeft, 2 )) {
- int ranks[10], nranks, result;
-
- if (intercomm == MPI_COMM_NULL) continue;
-
- MPI_Comm_group( intercomm, &oldgroup );
- ranks[0] = 0;
- nranks = 1;
- MTestPrintfMsg( 1, "Creating a new intercomm 0-0\n" );
- MPI_Group_incl( oldgroup, nranks, ranks, &newgroup );
- MPI_Comm_create( intercomm, newgroup, &newcomm );
-
- /* Make sure that the new communicator has the appropriate pieces */
- if (newcomm != MPI_COMM_NULL) {
- int new_rsize, new_size, flag, commok = 1;
-
- MPI_Comm_set_name( newcomm, (char*)"Single rank in each group" );
- MPI_Comm_test_inter( intercomm, &flag );
- if (!flag) {
- errs++;
- printf( "[%d] Output communicator is not an intercomm\n",
- wrank );
- commok = 0;
- }
-
- MPI_Comm_remote_size( newcomm, &new_rsize );
- MPI_Comm_size( newcomm, &new_size );
- /* The new communicator has 1 process in each group */
- if (new_rsize != 1) {
- errs++;
- printf( "[%d] Remote size is %d, should be one\n",
- wrank, new_rsize );
- commok = 0;
- }
- if (new_size != 1) {
- errs++;
- printf( "[%d] Local size is %d, should be one\n",
- wrank, new_size );
- commok = 0;
- }
- /* ... more to do */
- if (commok) {
- errs += MTestTestComm(newcomm);
- }
- }
- MPI_Group_free( &newgroup );
- if (newcomm != MPI_COMM_NULL) {
- MPI_Comm_free( &newcomm );
- }
-
- /* Now, do a sort of dup, using the original group */
- MTestPrintfMsg( 1, "Creating a new intercomm (manual dup)\n" );
- MPI_Comm_create( intercomm, oldgroup, &newcomm );
- MPI_Comm_set_name( newcomm, (char*)"Dup of original" );
- MTestPrintfMsg( 1, "Creating a new intercomm (manual dup (done))\n" );
-
- MPI_Comm_compare( intercomm, newcomm, &result );
- MTestPrintfMsg( 1, "Result of comm/intercomm compare is %d\n", result );
- if (result != MPI_CONGRUENT) {
- const char *rname=0;
- errs++;
- switch (result) {
- case MPI_IDENT: rname = "IDENT"; break;
- case MPI_CONGRUENT: rname = "CONGRUENT"; break;
- case MPI_SIMILAR: rname = "SIMILAR"; break;
- case MPI_UNEQUAL: rname = "UNEQUAL"; break;
- printf( "[%d] Expected MPI_CONGRUENT but saw %d (%s)",
- wrank, result, rname ); fflush(stdout);
- }
- }
- else {
- /* Try to communication between each member of intercomm */
- errs += MTestTestComm(newcomm);
- }
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
+
+ while (MTestGetIntercomm(&intercomm, &isLeft, 2)) {
+ int ranks[10], nranks, result;
+
+ if (intercomm == MPI_COMM_NULL)
+ continue;
+
+ MPI_Comm_group(intercomm, &oldgroup);
+ ranks[0] = 0;
+ nranks = 1;
+ MTestPrintfMsg(1, "Creating a new intercomm 0-0\n");
+ MPI_Group_incl(oldgroup, nranks, ranks, &newgroup);
+ MPI_Comm_create(intercomm, newgroup, &newcomm);
+
+ /* Make sure that the new communicator has the appropriate pieces */
+ if (newcomm != MPI_COMM_NULL) {
+ int new_rsize, new_size, flag, commok = 1;
+
+ MPI_Comm_set_name(newcomm, (char *) "Single rank in each group");
+ MPI_Comm_test_inter(intercomm, &flag);
+ if (!flag) {
+ errs++;
+ printf("[%d] Output communicator is not an intercomm\n", wrank);
+ commok = 0;
+ }
+
+ MPI_Comm_remote_size(newcomm, &new_rsize);
+ MPI_Comm_size(newcomm, &new_size);
+ /* The new communicator has 1 process in each group */
+ if (new_rsize != 1) {
+ errs++;
+ printf("[%d] Remote size is %d, should be one\n", wrank, new_rsize);
+ commok = 0;
+ }
+ if (new_size != 1) {
+ errs++;
+ printf("[%d] Local size is %d, should be one\n", wrank, new_size);
+ commok = 0;
+ }
+ /* ... more to do */
+ if (commok) {
+ errs += MTestTestComm(newcomm);
+ }
+ }
+ MPI_Group_free(&newgroup);
+ if (newcomm != MPI_COMM_NULL) {
+ MPI_Comm_free(&newcomm);
+ }
+
+ /* Now, do a sort of dup, using the original group */
+ MTestPrintfMsg(1, "Creating a new intercomm (manual dup)\n");
+ MPI_Comm_create(intercomm, oldgroup, &newcomm);
+ MPI_Comm_set_name(newcomm, (char *) "Dup of original");
+ MTestPrintfMsg(1, "Creating a new intercomm (manual dup (done))\n");
+
+ MPI_Comm_compare(intercomm, newcomm, &result);
+ MTestPrintfMsg(1, "Result of comm/intercomm compare is %d\n", result);
+ if (result != MPI_CONGRUENT) {
+ const char *rname = 0;
+ errs++;
+ switch (result) {
+ case MPI_IDENT:
+ rname = "IDENT";
+ break;
+ case MPI_CONGRUENT:
+ rname = "CONGRUENT";
+ break;
+ case MPI_SIMILAR:
+ rname = "SIMILAR";
+ break;
+ case MPI_UNEQUAL:
+ rname = "UNEQUAL";
+ break;
+ printf("[%d] Expected MPI_CONGRUENT but saw %d (%s)", wrank, result, rname);
+ fflush(stdout);
+ }
+ }
+ else {
+ /* Try to communication between each member of intercomm */
+ errs += MTestTestComm(newcomm);
+ }
if (newcomm != MPI_COMM_NULL) {
MPI_Comm_free(&newcomm);
@@ -118,15 +124,16 @@ int main( int argc, char *argv[] )
MPI_Comm_create(intercomm, MPI_GROUP_EMPTY, &newcomm);
}
if (newcomm != MPI_COMM_NULL) {
- printf("[%d] expected MPI_COMM_NULL, but got a different communicator\n", wrank); fflush(stdout);
+ printf("[%d] expected MPI_COMM_NULL, but got a different communicator\n", wrank);
+ fflush(stdout);
errs++;
}
if (newcomm != MPI_COMM_NULL) {
MPI_Comm_free(&newcomm);
}
- MPI_Group_free( &oldgroup );
- MPI_Comm_free( &intercomm );
+ MPI_Group_free(&oldgroup);
+ MPI_Comm_free(&intercomm);
}
MTest_Finalize(errs);
diff --git a/test/mpi/comm/icgroup.c b/test/mpi/comm/icgroup.c
index f44e1fa..61dfa5d 100644
--- a/test/mpi/comm/icgroup.c
+++ b/test/mpi/comm/icgroup.c
@@ -12,43 +12,42 @@
static char MTEST_Descrip[] = "Get the group of an intercommunicator";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size, grank, gsize;
- int minsize = 2, isleft;
- MPI_Comm comm;
- MPI_Group group;
+ int minsize = 2, isleft;
+ MPI_Comm comm;
+ MPI_Group group;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- /* The following illustrates the use of the routines to
- run through a selection of communicators and datatypes.
- Use subsets of these for tests that do not involve combinations
- of communicators, datatypes, and counts of datatypes */
- while (MTestGetIntercomm( &comm, &isleft, minsize )) {
- if (comm == MPI_COMM_NULL) continue;
- /* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
- MPI_Comm_group( comm, &group );
- MPI_Group_rank( group, &grank );
- MPI_Group_size( group, &gsize );
- if (rank != grank) {
- errs++;
- fprintf( stderr, "Ranks of groups do not match %d != %d\n",
- rank, grank );
- }
- if (size != gsize) {
- errs++;
- fprintf( stderr, "Sizes of groups do not match %d != %d\n",
- size, gsize );
- }
- MPI_Group_free( &group );
- MTestFreeComm( &comm );
+ /* The following illustrates the use of the routines to
+ * run through a selection of communicators and datatypes.
+ * Use subsets of these for tests that do not involve combinations
+ * of communicators, datatypes, and counts of datatypes */
+ while (MTestGetIntercomm(&comm, &isleft, minsize)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ /* Determine the sender and receiver */
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_group(comm, &group);
+ MPI_Group_rank(group, &grank);
+ MPI_Group_size(group, &gsize);
+ if (rank != grank) {
+ errs++;
+ fprintf(stderr, "Ranks of groups do not match %d != %d\n", rank, grank);
+ }
+ if (size != gsize) {
+ errs++;
+ fprintf(stderr, "Sizes of groups do not match %d != %d\n", size, gsize);
+ }
+ MPI_Group_free(&group);
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/comm/icm.c b/test/mpi/comm/icm.c
index 102c738..4fcc395 100644
--- a/test/mpi/comm/icm.c
+++ b/test/mpi/comm/icm.c
@@ -13,95 +13,90 @@
static char MTEST_Descrip[] = "Test intercomm merge, including the choice of the high value";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size, rsize;
int nsize, nrank;
int minsize = 2;
int isLeft;
- MPI_Comm comm, comm1, comm2, comm3, comm4;
+ MPI_Comm comm, comm1, comm2, comm3, comm4;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- /* The following illustrates the use of the routines to
- run through a selection of communicators and datatypes.
- Use subsets of these for tests that do not involve combinations
- of communicators, datatypes, and counts of datatypes */
- while (MTestGetIntercomm( &comm, &isLeft, minsize )) {
- if (comm == MPI_COMM_NULL) continue;
- /* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_remote_size( comm, &rsize );
- MPI_Comm_size( comm, &size );
+ /* The following illustrates the use of the routines to
+ * run through a selection of communicators and datatypes.
+ * Use subsets of these for tests that do not involve combinations
+ * of communicators, datatypes, and counts of datatypes */
+ while (MTestGetIntercomm(&comm, &isLeft, minsize)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ /* Determine the sender and receiver */
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_remote_size(comm, &rsize);
+ MPI_Comm_size(comm, &size);
- /* Try building intercomms */
- MPI_Intercomm_merge( comm, isLeft, &comm1 );
- /* Check the size and ranks */
- MPI_Comm_size( comm1, &nsize );
- MPI_Comm_rank( comm1, &nrank );
- if (nsize != size + rsize) {
- errs++;
- printf( "(1) Comm size is %d but should be %d\n", nsize,
- size + rsize );
- if (isLeft) {
- /* The left processes should be high */
- if (nrank != rsize + rank) {
- errs++;
- printf( "(1) rank for high process is %d should be %d\n",
- nrank, rsize + rank );
- }
- }
- else {
- /* The right processes should be low */
- if (nrank != rank) {
- errs++;
- printf( "(1) rank for low process is %d should be %d\n",
- nrank, rank );
- }
- }
- }
-
- MPI_Intercomm_merge( comm, !isLeft, &comm2 );
- /* Check the size and ranks */
- MPI_Comm_size( comm1, &nsize );
- MPI_Comm_rank( comm1, &nrank );
- if (nsize != size + rsize) {
- errs++;
- printf( "(2) Comm size is %d but should be %d\n", nsize,
- size + rsize );
- if (!isLeft) {
- /* The right processes should be high */
- if (nrank != rsize + rank) {
- errs++;
- printf( "(2) rank for high process is %d should be %d\n",
- nrank, rsize + rank );
- }
- }
- else {
- /* The left processes should be low */
- if (nrank != rank) {
- errs++;
- printf( "(2) rank for low process is %d should be %d\n",
- nrank, rank );
- }
- }
- }
-
+ /* Try building intercomms */
+ MPI_Intercomm_merge(comm, isLeft, &comm1);
+ /* Check the size and ranks */
+ MPI_Comm_size(comm1, &nsize);
+ MPI_Comm_rank(comm1, &nrank);
+ if (nsize != size + rsize) {
+ errs++;
+ printf("(1) Comm size is %d but should be %d\n", nsize, size + rsize);
+ if (isLeft) {
+ /* The left processes should be high */
+ if (nrank != rsize + rank) {
+ errs++;
+ printf("(1) rank for high process is %d should be %d\n", nrank, rsize + rank);
+ }
+ }
+ else {
+ /* The right processes should be low */
+ if (nrank != rank) {
+ errs++;
+ printf("(1) rank for low process is %d should be %d\n", nrank, rank);
+ }
+ }
+ }
- MPI_Intercomm_merge( comm, 0, &comm3 );
+ MPI_Intercomm_merge(comm, !isLeft, &comm2);
+ /* Check the size and ranks */
+ MPI_Comm_size(comm1, &nsize);
+ MPI_Comm_rank(comm1, &nrank);
+ if (nsize != size + rsize) {
+ errs++;
+ printf("(2) Comm size is %d but should be %d\n", nsize, size + rsize);
+ if (!isLeft) {
+ /* The right processes should be high */
+ if (nrank != rsize + rank) {
+ errs++;
+ printf("(2) rank for high process is %d should be %d\n", nrank, rsize + rank);
+ }
+ }
+ else {
+ /* The left processes should be low */
+ if (nrank != rank) {
+ errs++;
+ printf("(2) rank for low process is %d should be %d\n", nrank, rank);
+ }
+ }
+ }
- MPI_Intercomm_merge( comm, 1, &comm4 );
-
- MPI_Comm_free( &comm1 );
- MPI_Comm_free( &comm2 );
- MPI_Comm_free( &comm3 );
- MPI_Comm_free( &comm4 );
-
- MTestFreeComm( &comm );
+
+ MPI_Intercomm_merge(comm, 0, &comm3);
+
+ MPI_Intercomm_merge(comm, 1, &comm4);
+
+ MPI_Comm_free(&comm1);
+ MPI_Comm_free(&comm2);
+ MPI_Comm_free(&comm3);
+ MPI_Comm_free(&comm4);
+
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/comm/icsplit.c b/test/mpi/comm/icsplit.c
index 177c945..f7d43c1 100644
--- a/test/mpi/comm/icsplit.c
+++ b/test/mpi/comm/icsplit.c
@@ -13,101 +13,100 @@
* This program tests that MPI_Comm_split applies to intercommunicators;
* this is an extension added in MPI-2
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int size, isLeft;
MPI_Comm intercomm, newcomm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
if (size < 4) {
- printf( "This test requires at least 4 processes\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ printf("This test requires at least 4 processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- while (MTestGetIntercomm( &intercomm, &isLeft, 2 )) {
- int key, color;
+ while (MTestGetIntercomm(&intercomm, &isLeft, 2)) {
+ int key, color;
- if (intercomm == MPI_COMM_NULL) continue;
+ if (intercomm == MPI_COMM_NULL)
+ continue;
- /* Split this intercomm. The new intercomms contain the
- processes that had odd (resp even) rank in their local group
- in the original intercomm */
- MTestPrintfMsg( 1, "Created intercomm %s\n", MTestGetIntercommName() );
- MPI_Comm_rank( intercomm, &key );
- color = (key % 2);
- MPI_Comm_split( intercomm, color, key, &newcomm );
- /* Make sure that the new communicator has the appropriate pieces */
- if (newcomm != MPI_COMM_NULL) {
- int orig_rsize, orig_size, new_rsize, new_size;
- int predicted_size, flag, commok=1;
+ /* Split this intercomm. The new intercomms contain the
+ * processes that had odd (resp even) rank in their local group
+ * in the original intercomm */
+ MTestPrintfMsg(1, "Created intercomm %s\n", MTestGetIntercommName());
+ MPI_Comm_rank(intercomm, &key);
+ color = (key % 2);
+ MPI_Comm_split(intercomm, color, key, &newcomm);
+ /* Make sure that the new communicator has the appropriate pieces */
+ if (newcomm != MPI_COMM_NULL) {
+ int orig_rsize, orig_size, new_rsize, new_size;
+ int predicted_size, flag, commok = 1;
- MPI_Comm_test_inter( intercomm, &flag );
- if (!flag) {
- errs++;
- printf( "Output communicator is not an intercomm\n" );
- commok = 0;
- }
+ MPI_Comm_test_inter(intercomm, &flag);
+ if (!flag) {
+ errs++;
+ printf("Output communicator is not an intercomm\n");
+ commok = 0;
+ }
- MPI_Comm_remote_size( intercomm, &orig_rsize );
- MPI_Comm_remote_size( newcomm, &new_rsize );
- MPI_Comm_size( intercomm, &orig_size );
- MPI_Comm_size( newcomm, &new_size );
- /* The local size is 1/2 the original size, +1 if the
- size was odd and the color was even. More precisely,
- let n be the orig_size. Then
- color 0 color 1
- orig size even n/2 n/2
- orig size odd (n+1)/2 n/2
-
- However, since these are integer valued, if n is even,
- then (n+1)/2 = n/2, so this table is much simpler:
- color 0 color 1
- orig size even (n+1)/2 n/2
- orig size odd (n+1)/2 n/2
-
- */
- predicted_size = (orig_size + !color) / 2;
- if (predicted_size != new_size) {
- errs++;
- printf( "Predicted size = %d but found %d for %s (%d,%d)\n",
- predicted_size, new_size, MTestGetIntercommName(),
- orig_size, orig_rsize );
- commok = 0;
- }
- predicted_size = (orig_rsize + !color) / 2;
- if (predicted_size != new_rsize) {
- errs++;
- printf( "Predicted remote size = %d but found %d for %s (%d,%d)\n",
- predicted_size, new_rsize, MTestGetIntercommName(),
- orig_size, orig_rsize );
- commok = 0;
- }
- /* ... more to do */
- if (commok) {
- errs += MTestTestComm(newcomm);
- }
- }
- else {
- int orig_rsize;
- /* If the newcomm is null, then this means that remote group
- for this color is of size zero (since all processes in this
- test have been given colors other than MPI_UNDEFINED).
- Confirm that here */
- /* FIXME: ToDo */
- MPI_Comm_remote_size( intercomm, &orig_rsize );
- if (orig_rsize == 1) {
- if (color == 0) {
- errs++;
- printf( "Returned null intercomm when non-null expected\n" );
- }
- }
- }
- if (newcomm != MPI_COMM_NULL)
- MPI_Comm_free( &newcomm );
- MPI_Comm_free( &intercomm );
+ MPI_Comm_remote_size(intercomm, &orig_rsize);
+ MPI_Comm_remote_size(newcomm, &new_rsize);
+ MPI_Comm_size(intercomm, &orig_size);
+ MPI_Comm_size(newcomm, &new_size);
+ /* The local size is 1/2 the original size, +1 if the
+ * size was odd and the color was even. More precisely,
+ * let n be the orig_size. Then
+ * color 0 color 1
+ * orig size even n/2 n/2
+ * orig size odd (n+1)/2 n/2
+ *
+ * However, since these are integer valued, if n is even,
+ * then (n+1)/2 = n/2, so this table is much simpler:
+ * color 0 color 1
+ * orig size even (n+1)/2 n/2
+ * orig size odd (n+1)/2 n/2
+ *
+ */
+ predicted_size = (orig_size + !color) / 2;
+ if (predicted_size != new_size) {
+ errs++;
+ printf("Predicted size = %d but found %d for %s (%d,%d)\n",
+ predicted_size, new_size, MTestGetIntercommName(), orig_size, orig_rsize);
+ commok = 0;
+ }
+ predicted_size = (orig_rsize + !color) / 2;
+ if (predicted_size != new_rsize) {
+ errs++;
+ printf("Predicted remote size = %d but found %d for %s (%d,%d)\n",
+ predicted_size, new_rsize, MTestGetIntercommName(), orig_size, orig_rsize);
+ commok = 0;
+ }
+ /* ... more to do */
+ if (commok) {
+ errs += MTestTestComm(newcomm);
+ }
+ }
+ else {
+ int orig_rsize;
+ /* If the newcomm is null, then this means that remote group
+ * for this color is of size zero (since all processes in this
+ * test have been given colors other than MPI_UNDEFINED).
+ * Confirm that here */
+ /* FIXME: ToDo */
+ MPI_Comm_remote_size(intercomm, &orig_rsize);
+ if (orig_rsize == 1) {
+ if (color == 0) {
+ errs++;
+ printf("Returned null intercomm when non-null expected\n");
+ }
+ }
+ }
+ if (newcomm != MPI_COMM_NULL)
+ MPI_Comm_free(&newcomm);
+ MPI_Comm_free(&intercomm);
}
MTest_Finalize(errs);
diff --git a/test/mpi/comm/probe-intercomm.c b/test/mpi/comm/probe-intercomm.c
index edd56e2..85464ef 100644
--- a/test/mpi/comm/probe-intercomm.c
+++ b/test/mpi/comm/probe-intercomm.c
@@ -15,56 +15,58 @@ static char MTEST_Descrip[] = "Test MPI_Probe() for an intercomm";
*/
#define MAX_DATA_LEN 100
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, recvlen, isLeft;
MPI_Status status;
int rank, size;
- MPI_Comm intercomm;
+ MPI_Comm intercomm;
char buf[MAX_DATA_LEN];
const char *test_str = "test";
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
if (size < 2) {
- fprintf( stderr, "This test requires at least two processes." );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "This test requires at least two processes.");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- while (MTestGetIntercomm( &intercomm, &isLeft, 2 )) {
- if (intercomm == MPI_COMM_NULL) continue;
+ while (MTestGetIntercomm(&intercomm, &isLeft, 2)) {
+ if (intercomm == MPI_COMM_NULL)
+ continue;
MPI_Comm_rank(intercomm, &rank);
/* 0 ranks on each side communicate, everyone else does nothing */
- if(rank == 0) {
+ if (rank == 0) {
if (isLeft) {
recvlen = -1;
MPI_Probe(0, 0, intercomm, &status);
MPI_Get_count(&status, MPI_CHAR, &recvlen);
if (recvlen != (strlen(test_str) + 1)) {
- printf(" Error: recvlen (%d) != strlen(\"%s\")+1 (%d)\n", recvlen, test_str, (int)strlen(test_str) + 1);
+ printf(" Error: recvlen (%d) != strlen(\"%s\")+1 (%d)\n", recvlen, test_str,
+ (int) strlen(test_str) + 1);
++errs;
}
buf[0] = '\0';
MPI_Recv(buf, recvlen, MPI_CHAR, 0, 0, intercomm, &status);
- if (strcmp(test_str,buf)) {
+ if (strcmp(test_str, buf)) {
printf(" Error: strcmp(test_str,buf)!=0\n");
++errs;
}
}
else {
strncpy(buf, test_str, 5);
- MPI_Send(buf, strlen(buf)+1, MPI_CHAR, 0, 0, intercomm);
+ MPI_Send(buf, strlen(buf) + 1, MPI_CHAR, 0, 0, intercomm);
}
}
MTestFreeComm(&intercomm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/datatype/blockindexed-misc.c b/test/mpi/datatype/blockindexed-misc.c
index c3c59dc..d267205 100644
--- a/test/mpi/datatype/blockindexed-misc.c
+++ b/test/mpi/datatype/blockindexed-misc.c
@@ -19,39 +19,36 @@ int blockindexed_vector_test(void);
/* helper functions */
int parse_args(int argc, char **argv);
-static int pack_and_unpack(char *typebuf,
- int count,
- MPI_Datatype datatype,
- int typebufsz);
+static int pack_and_unpack(char *typebuf, int count, MPI_Datatype datatype, int typebufsz);
int main(int argc, char **argv)
{
int err, errs = 0;
- MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
+ MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
/* perform some tests */
err = blockindexed_contig_test();
- if (err && verbose) fprintf(stderr, "%d errors in blockindexed test.\n",
- err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in blockindexed test.\n", err);
errs += err;
err = blockindexed_vector_test();
- if (err && verbose) fprintf(stderr, "%d errors in blockindexed vector test.\n",
- err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in blockindexed vector test.\n", err);
errs += err;
/* print message and exit */
if (errs) {
- fprintf(stderr, "Found %d errors\n", errs);
+ fprintf(stderr, "Found %d errors\n", errs);
}
else {
- printf(" No Errors\n");
+ printf(" No Errors\n");
}
MPI_Finalize();
return 0;
@@ -59,14 +56,14 @@ int main(int argc, char **argv)
/* blockindexed_contig_test()
*
- * Tests behavior with a blockindexed that can be converted to a
+ * Tests behavior with a blockindexed that can be converted to a
* contig easily. This is specifically for coverage.
*
* Returns the number of errors encountered.
*/
int blockindexed_contig_test(void)
{
- int buf[4] = {7, -1, -2, -3};
+ int buf[4] = { 7, -1, -2, -3 };
int err, errs = 0;
int i, count = 1;
@@ -76,85 +73,75 @@ int blockindexed_contig_test(void)
int size, int_size;
MPI_Aint extent;
- err = MPI_Type_create_indexed_block(count,
- 1,
- &disp,
- MPI_INT,
- &newtype);
+ err = MPI_Type_create_indexed_block(count, 1, &disp, MPI_INT, &newtype);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error creating struct type in blockindexed_contig_test()\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "error creating struct type in blockindexed_contig_test()\n");
+ }
+ errs++;
}
MPI_Type_size(MPI_INT, &int_size);
err = MPI_Type_size(newtype, &size);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error obtaining type size in blockindexed_contig_test()\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "error obtaining type size in blockindexed_contig_test()\n");
+ }
+ errs++;
}
-
+
if (size != int_size) {
- if (verbose) {
- fprintf(stderr,
- "error: size != int_size in blockindexed_contig_test()\n");
- }
- errs++;
- }
+ if (verbose) {
+ fprintf(stderr, "error: size != int_size in blockindexed_contig_test()\n");
+ }
+ errs++;
+ }
err = MPI_Type_extent(newtype, &extent);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error obtaining type extent in blockindexed_contig_test()\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "error obtaining type extent in blockindexed_contig_test()\n");
+ }
+ errs++;
}
-
+
if (extent != int_size) {
- if (verbose) {
- fprintf(stderr,
- "error: extent != int_size in blockindexed_contig_test()\n");
- }
- errs++;
- }
+ if (verbose) {
+ fprintf(stderr, "error: extent != int_size in blockindexed_contig_test()\n");
+ }
+ errs++;
+ }
MPI_Type_commit(&newtype);
err = pack_and_unpack((char *) buf, 1, newtype, 4 * sizeof(int));
if (err != 0) {
- if (verbose) {
- fprintf(stderr,
- "error packing/unpacking in blockindexed_contig_test()\n");
- }
- errs += err;
+ if (verbose) {
+ fprintf(stderr, "error packing/unpacking in blockindexed_contig_test()\n");
+ }
+ errs += err;
}
- for (i=0; i < 4; i++) {
- int goodval;
-
- switch(i) {
- case 0:
- goodval = 7;
- break;
- default:
- goodval = 0; /* pack_and_unpack() zeros before unpack */
- break;
- }
- if (buf[i] != goodval) {
- errs++;
- if (verbose) fprintf(stderr, "buf[%d] = %d; should be %d\n",
- i, buf[i], goodval);
- }
+ for (i = 0; i < 4; i++) {
+ int goodval;
+
+ switch (i) {
+ case 0:
+ goodval = 7;
+ break;
+ default:
+ goodval = 0; /* pack_and_unpack() zeros before unpack */
+ break;
+ }
+ if (buf[i] != goodval) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "buf[%d] = %d; should be %d\n", i, buf[i], goodval);
+ }
}
-
- MPI_Type_free( &newtype );
+
+ MPI_Type_free(&newtype);
return errs;
}
@@ -170,22 +157,24 @@ int blockindexed_vector_test(void)
{
#define NELT (18)
int buf[NELT] = { -1, -1, -1,
- 1, -2, 2,
- -3, -3, -3,
- -4, -4, -4,
- 3, -5, 4,
- 5, -6, 6 };
+ 1, -2, 2,
+ -3, -3, -3,
+ -4, -4, -4,
+ 3, -5, 4,
+ 5, -6, 6
+ };
int expected[NELT] = {
- 0, 0, 0,
- 1, 0, 2,
- 0, 0, 0,
- 0, 0, 0,
- 3, 0, 4,
- 5, 0, 6 };
+ 0, 0, 0,
+ 1, 0, 2,
+ 0, 0, 0,
+ 0, 0, 0,
+ 3, 0, 4,
+ 5, 0, 6
+ };
int err, errs = 0;
int i, count = 3;
- int disp[] = {1, 4, 5};
+ int disp[] = { 1, 4, 5 };
MPI_Datatype vectype, newtype;
int size, int_size;
@@ -193,66 +182,57 @@ int blockindexed_vector_test(void)
/* create a vector type of 2 ints, skipping one in between */
err = MPI_Type_vector(2, 1, 2, MPI_INT, &vectype);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error creating vector type in blockindexed_contig_test()\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "error creating vector type in blockindexed_contig_test()\n");
+ }
+ errs++;
}
- err = MPI_Type_create_indexed_block(count,
- 1,
- disp,
- vectype,
- &newtype);
+ err = MPI_Type_create_indexed_block(count, 1, disp, vectype, &newtype);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error creating blockindexed type in blockindexed_contig_test()\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "error creating blockindexed type in blockindexed_contig_test()\n");
+ }
+ errs++;
}
MPI_Type_size(MPI_INT, &int_size);
err = MPI_Type_size(newtype, &size);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error obtaining type size in blockindexed_contig_test()\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "error obtaining type size in blockindexed_contig_test()\n");
+ }
+ errs++;
}
-
+
if (size != 6 * int_size) {
- if (verbose) {
- fprintf(stderr,
- "error: size != 6 * int_size in blockindexed_contig_test()\n");
- }
- errs++;
- }
+ if (verbose) {
+ fprintf(stderr, "error: size != 6 * int_size in blockindexed_contig_test()\n");
+ }
+ errs++;
+ }
MPI_Type_commit(&newtype);
err = pack_and_unpack((char *) buf, 1, newtype, NELT * sizeof(int));
if (err != 0) {
- if (verbose) {
- fprintf(stderr,
- "error packing/unpacking in blockindexed_vector_test()\n");
- }
- errs += err;
+ if (verbose) {
+ fprintf(stderr, "error packing/unpacking in blockindexed_vector_test()\n");
+ }
+ errs += err;
}
- for (i=0; i < NELT; i++) {
- if (buf[i] != expected[i]) {
- errs++;
- if (verbose) fprintf(stderr, "buf[%d] = %d; should be %d\n",
- i, buf[i], expected[i]);
- }
+ for (i = 0; i < NELT; i++) {
+ if (buf[i] != expected[i]) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "buf[%d] = %d; should be %d\n", i, buf[i], expected[i]);
+ }
}
- MPI_Type_free( &vectype );
- MPI_Type_free( &newtype );
+ MPI_Type_free(&vectype);
+ MPI_Type_free(&newtype);
return errs;
}
@@ -272,87 +252,64 @@ int blockindexed_vector_test(void)
* between the pack and unpack steps
*
*/
-static int pack_and_unpack(char *typebuf,
- int count,
- MPI_Datatype datatype,
- int typebufsz)
+static int pack_and_unpack(char *typebuf, int count, MPI_Datatype datatype, int typebufsz)
{
char *packbuf;
int err, errs = 0, pack_size, type_size, position;
err = MPI_Type_size(datatype, &type_size);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in MPI_Type_size call; aborting after %d errors\n",
- errs);
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "error in MPI_Type_size call; aborting after %d errors\n", errs);
+ }
+ return errs;
}
type_size *= count;
err = MPI_Pack_size(count, datatype, MPI_COMM_SELF, &pack_size);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in MPI_Pack_size call; aborting after %d errors\n",
- errs);
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "error in MPI_Pack_size call; aborting after %d errors\n", errs);
+ }
+ return errs;
}
packbuf = (char *) malloc(pack_size);
if (packbuf == NULL) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in malloc call; aborting after %d errors\n",
- errs);
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "error in malloc call; aborting after %d errors\n", errs);
+ }
+ return errs;
}
position = 0;
- err = MPI_Pack(typebuf,
- count,
- datatype,
- packbuf,
- type_size,
- &position,
- MPI_COMM_SELF);
+ err = MPI_Pack(typebuf, count, datatype, packbuf, type_size, &position, MPI_COMM_SELF);
if (position != type_size) {
- errs++;
- if (verbose) fprintf(stderr, "position = %d; should be %d (pack)\n",
- position, type_size);
+ errs++;
+ if (verbose)
+ fprintf(stderr, "position = %d; should be %d (pack)\n", position, type_size);
}
memset(typebuf, 0, typebufsz);
position = 0;
- err = MPI_Unpack(packbuf,
- type_size,
- &position,
- typebuf,
- count,
- datatype,
- MPI_COMM_SELF);
+ err = MPI_Unpack(packbuf, type_size, &position, typebuf, count, datatype, MPI_COMM_SELF);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in MPI_Unpack call; aborting after %d errors\n",
- errs);
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "error in MPI_Unpack call; aborting after %d errors\n", errs);
+ }
+ return errs;
}
free(packbuf);
if (position != type_size) {
- errs++;
- if (verbose) fprintf(stderr, "position = %d; should be %d (unpack)\n",
- position, type_size);
+ errs++;
+ if (verbose)
+ fprintf(stderr, "position = %d; should be %d (unpack)\n", position, type_size);
}
return errs;
@@ -361,19 +318,18 @@ static int pack_and_unpack(char *typebuf,
int parse_args(int argc, char **argv)
{
/*
- int ret;
-
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
- }
- */
+ * int ret;
+ *
+ * while ((ret = getopt(argc, argv, "v")) >= 0)
+ * {
+ * switch (ret) {
+ * case 'v':
+ * verbose = 1;
+ * break;
+ * }
+ * }
+ */
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
return 0;
}
-
diff --git a/test/mpi/datatype/blockindexed-zero-count.c b/test/mpi/datatype/blockindexed-zero-count.c
index f7d14b0..88a2d5f 100644
--- a/test/mpi/datatype/blockindexed-zero-count.c
+++ b/test/mpi/datatype/blockindexed-zero-count.c
@@ -23,25 +23,25 @@ int main(int argc, char **argv)
{
int err, errs = 0;
- MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
+ MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
/* perform some tests */
err = blockindexed_test();
- if (err && verbose) fprintf(stderr, "%d errors in blockindexed test.\n",
- err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in blockindexed test.\n", err);
errs += err;
/* print message and exit */
if (errs) {
- fprintf(stderr, "Found %d errors\n", errs);
+ fprintf(stderr, "Found %d errors\n", errs);
}
else {
- printf(" No Errors\n");
+ printf(" No Errors\n");
}
MPI_Finalize();
return 0;
@@ -63,54 +63,45 @@ int blockindexed_test(void)
int size;
MPI_Aint extent;
- err = MPI_Type_create_indexed_block(count,
- 0,
- (int *) 0,
- MPI_INT,
- &newtype);
+ err = MPI_Type_create_indexed_block(count, 0, (int *) 0, MPI_INT, &newtype);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error creating struct type in blockindexed_test()\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "error creating struct type in blockindexed_test()\n");
+ }
+ errs++;
}
err = MPI_Type_size(newtype, &size);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error obtaining type size in blockindexed_test()\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "error obtaining type size in blockindexed_test()\n");
+ }
+ errs++;
}
-
+
if (size != 0) {
- if (verbose) {
- fprintf(stderr,
- "error: size != 0 in blockindexed_test()\n");
- }
- errs++;
- }
+ if (verbose) {
+ fprintf(stderr, "error: size != 0 in blockindexed_test()\n");
+ }
+ errs++;
+ }
err = MPI_Type_extent(newtype, &extent);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error obtaining type extent in blockindexed_test()\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "error obtaining type extent in blockindexed_test()\n");
+ }
+ errs++;
}
-
+
if (extent != 0) {
- if (verbose) {
- fprintf(stderr,
- "error: extent != 0 in blockindexed_test()\n");
- }
- errs++;
- }
+ if (verbose) {
+ fprintf(stderr, "error: extent != 0 in blockindexed_test()\n");
+ }
+ errs++;
+ }
- MPI_Type_free( &newtype );
+ MPI_Type_free(&newtype);
return errs;
}
@@ -119,19 +110,18 @@ int blockindexed_test(void)
int parse_args(int argc, char **argv)
{
/*
- int ret;
-
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
- }
- */
+ * int ret;
+ *
+ * while ((ret = getopt(argc, argv, "v")) >= 0)
+ * {
+ * switch (ret) {
+ * case 'v':
+ * verbose = 1;
+ * break;
+ * }
+ * }
+ */
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
return 0;
}
-
diff --git a/test/mpi/datatype/contents.c b/test/mpi/datatype/contents.c
index fb513c3..53d2a90 100644
--- a/test/mpi/datatype/contents.c
+++ b/test/mpi/datatype/contents.c
@@ -29,42 +29,42 @@ int main(int argc, char **argv)
{
int err, errs = 0;
- MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
+ MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
/* perform some tests */
err = builtin_float_test();
errs += err;
if (err) {
- fprintf(stderr, "Found %d errors in builtin float test.\n", err);
+ fprintf(stderr, "Found %d errors in builtin float test.\n", err);
}
err = vector_of_vectors_test();
errs += err;
if (err) {
- fprintf(stderr, "Found %d errors in vector of vectors test.\n", err);
+ fprintf(stderr, "Found %d errors in vector of vectors test.\n", err);
}
err = optimizable_vector_of_basics_test();
errs += err;
if (err) {
- fprintf(stderr, "Found %d errors in vector of basics test.\n", err);
+ fprintf(stderr, "Found %d errors in vector of basics test.\n", err);
}
err = indexed_of_basics_test();
errs += err;
if (err) {
- fprintf(stderr, "Found %d errors in indexed of basics test.\n", err);
+ fprintf(stderr, "Found %d errors in indexed of basics test.\n", err);
}
err = indexed_of_vectors_test();
errs += err;
if (err) {
- fprintf(stderr, "Found %d errors in indexed of vectors test.\n", err);
+ fprintf(stderr, "Found %d errors in indexed of vectors test.\n", err);
}
#ifdef HAVE_MPI_TYPE_CREATE_STRUCT
@@ -74,10 +74,10 @@ int main(int argc, char **argv)
/* print message and exit */
if (errs) {
- fprintf(stderr, "Found %d errors\n", errs);
+ fprintf(stderr, "Found %d errors\n", errs);
}
else {
- printf(" No Errors\n");
+ printf(" No Errors\n");
}
MPI_Finalize();
return 0;
@@ -95,16 +95,12 @@ int builtin_float_test(void)
int err, errs = 0;
- err = MPI_Type_get_envelope(MPI_FLOAT,
- &nints,
- &nadds,
- &ntypes,
- &combiner);
-
- if (combiner != MPI_COMBINER_NAMED) errs++;
+ err = MPI_Type_get_envelope(MPI_FLOAT, &nints, &nadds, &ntypes, &combiner);
+
+ if (combiner != MPI_COMBINER_NAMED)
+ errs++;
if (verbose && combiner != MPI_COMBINER_NAMED)
- fprintf(stderr, "combiner = %s; should be named\n",
- combiner_to_string(combiner));
+ fprintf(stderr, "combiner = %s; should be named\n", combiner_to_string(combiner));
/* Note: it is erroneous to call MPI_Type_get_contents() on a basic. */
return errs;
@@ -112,8 +108,8 @@ int builtin_float_test(void)
/* vector_of_vectors_test()
*
- * Builds a vector of a vector of ints. Assuming an int array of size 9
- * integers, and treating the array as a 3x3 2D array, this will grab the
+ * Builds a vector of a vector of ints. Assuming an int array of size 9
+ * integers, and treating the array as a 3x3 2D array, this will grab the
* corners.
*
* Returns the number of errors encountered.
@@ -130,180 +126,159 @@ int vector_of_vectors_test(void)
int err, errs = 0;
/* set up type */
- err = MPI_Type_vector(2,
- 1,
- 2,
- MPI_INT,
- &inner_vector);
+ err = MPI_Type_vector(2, 1, 2, MPI_INT, &inner_vector);
if (err != MPI_SUCCESS) {
- if (verbose) fprintf(stderr,
- "error in MPI call; aborting after %d errors\n",
- errs+1);
- return errs+1;
+ if (verbose)
+ fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
+ return errs + 1;
}
- err = MPI_Type_vector(2,
- 1,
- 2,
- inner_vector,
- &outer_vector);
+ err = MPI_Type_vector(2, 1, 2, inner_vector, &outer_vector);
if (err != MPI_SUCCESS) {
- if (verbose) fprintf(stderr,
- "error in MPI call; aborting after %d errors\n",
- errs+1);
- return errs+1;
+ if (verbose)
+ fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
+ return errs + 1;
}
/* decode outer vector (get envelope, then contents) */
- err = MPI_Type_get_envelope(outer_vector,
- &nints,
- &nadds,
- &ntypes,
- &combiner);
+ err = MPI_Type_get_envelope(outer_vector, &nints, &nadds, &ntypes, &combiner);
if (err != MPI_SUCCESS) {
- if (verbose) fprintf(stderr,
- "error in MPI call; aborting after %d errors\n",
- errs+1);
- return errs+1;
+ if (verbose)
+ fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
+ return errs + 1;
}
- if (nints != 3) errs++;
- if (nadds != 0) errs++;
- if (ntypes != 1) errs++;
- if (combiner != MPI_COMBINER_VECTOR) errs++;
+ if (nints != 3)
+ errs++;
+ if (nadds != 0)
+ errs++;
+ if (ntypes != 1)
+ errs++;
+ if (combiner != MPI_COMBINER_VECTOR)
+ errs++;
if (verbose) {
- if (nints != 3) fprintf(stderr,
- "outer vector nints = %d; should be 3\n",
- nints);
- if (nadds != 0) fprintf(stderr,
- "outer vector nadds = %d; should be 0\n",
- nadds);
- if (ntypes != 1) fprintf(stderr,
- "outer vector ntypes = %d; should be 1\n",
- ntypes);
- if (combiner != MPI_COMBINER_VECTOR)
- fprintf(stderr, "outer vector combiner = %s; should be vector\n",
- combiner_to_string(combiner));
+ if (nints != 3)
+ fprintf(stderr, "outer vector nints = %d; should be 3\n", nints);
+ if (nadds != 0)
+ fprintf(stderr, "outer vector nadds = %d; should be 0\n", nadds);
+ if (ntypes != 1)
+ fprintf(stderr, "outer vector ntypes = %d; should be 1\n", ntypes);
+ if (combiner != MPI_COMBINER_VECTOR)
+ fprintf(stderr, "outer vector combiner = %s; should be vector\n",
+ combiner_to_string(combiner));
}
if (errs) {
- if (verbose) fprintf(stderr, "aborting after %d errors\n", errs);
- return errs;
+ if (verbose)
+ fprintf(stderr, "aborting after %d errors\n", errs);
+ return errs;
}
ints = malloc(nints * sizeof(*ints));
- if (nadds) adds = malloc(nadds * sizeof(*adds));
+ if (nadds)
+ adds = malloc(nadds * sizeof(*adds));
types = malloc(ntypes * sizeof(*types));
/* get contents of outer vector */
- err = MPI_Type_get_contents(outer_vector,
- nints,
- nadds,
- ntypes,
- ints,
- adds,
- types);
-
- if (ints[0] != 2) errs++;
- if (ints[1] != 1) errs++;
- if (ints[2] != 2) errs++;
+ err = MPI_Type_get_contents(outer_vector, nints, nadds, ntypes, ints, adds, types);
+
+ if (ints[0] != 2)
+ errs++;
+ if (ints[1] != 1)
+ errs++;
+ if (ints[2] != 2)
+ errs++;
if (verbose) {
- if (ints[0] != 2) fprintf(stderr,
- "outer vector count = %d; should be 2\n",
- ints[0]);
- if (ints[1] != 1) fprintf(stderr,
- "outer vector blocklength = %d; should be 1\n",
- ints[1]);
- if (ints[2] != 2) fprintf(stderr, "outer vector stride = %d; should be 2\n",
- ints[2]);
+ if (ints[0] != 2)
+ fprintf(stderr, "outer vector count = %d; should be 2\n", ints[0]);
+ if (ints[1] != 1)
+ fprintf(stderr, "outer vector blocklength = %d; should be 1\n", ints[1]);
+ if (ints[2] != 2)
+ fprintf(stderr, "outer vector stride = %d; should be 2\n", ints[2]);
}
if (errs) {
- if (verbose) fprintf(stderr, "aborting after %d errors\n", errs);
- return errs;
+ if (verbose)
+ fprintf(stderr, "aborting after %d errors\n", errs);
+ return errs;
}
inner_vector_copy = types[0];
free(ints);
- if (nadds) free(adds);
+ if (nadds)
+ free(adds);
free(types);
/* decode inner vector */
- err = MPI_Type_get_envelope(inner_vector_copy,
- &nints,
- &nadds,
- &ntypes,
- &combiner);
+ err = MPI_Type_get_envelope(inner_vector_copy, &nints, &nadds, &ntypes, &combiner);
if (err != MPI_SUCCESS) {
- if (verbose) fprintf(stderr,
- "error in MPI call; aborting after %d errors\n",
- errs+1);
- return errs+1;
+ if (verbose)
+ fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
+ return errs + 1;
}
- if (nints != 3) errs++;
- if (nadds != 0) errs++;
- if (ntypes != 1) errs++;
- if (combiner != MPI_COMBINER_VECTOR) errs++;
+ if (nints != 3)
+ errs++;
+ if (nadds != 0)
+ errs++;
+ if (ntypes != 1)
+ errs++;
+ if (combiner != MPI_COMBINER_VECTOR)
+ errs++;
if (verbose) {
- if (nints != 3) fprintf(stderr,
- "inner vector nints = %d; should be 3\n",
- nints);
- if (nadds != 0) fprintf(stderr,
- "inner vector nadds = %d; should be 0\n",
- nadds);
- if (ntypes != 1) fprintf(stderr,
- "inner vector ntypes = %d; should be 1\n",
- ntypes);
- if (combiner != MPI_COMBINER_VECTOR)
- fprintf(stderr, "inner vector combiner = %s; should be vector\n",
- combiner_to_string(combiner));
+ if (nints != 3)
+ fprintf(stderr, "inner vector nints = %d; should be 3\n", nints);
+ if (nadds != 0)
+ fprintf(stderr, "inner vector nadds = %d; should be 0\n", nadds);
+ if (ntypes != 1)
+ fprintf(stderr, "inner vector ntypes = %d; should be 1\n", ntypes);
+ if (combiner != MPI_COMBINER_VECTOR)
+ fprintf(stderr, "inner vector combiner = %s; should be vector\n",
+ combiner_to_string(combiner));
}
if (errs) {
- if (verbose) fprintf(stderr, "aborting after %d errors\n", errs);
- return errs;
+ if (verbose)
+ fprintf(stderr, "aborting after %d errors\n", errs);
+ return errs;
}
ints = malloc(nints * sizeof(*ints));
- if (nadds) adds = malloc(nadds * sizeof(*adds));
+ if (nadds)
+ adds = malloc(nadds * sizeof(*adds));
types = malloc(ntypes * sizeof(*types));
- err = MPI_Type_get_contents(inner_vector_copy,
- nints,
- nadds,
- ntypes,
- ints,
- adds,
- types);
+ err = MPI_Type_get_contents(inner_vector_copy, nints, nadds, ntypes, ints, adds, types);
- if (ints[0] != 2) errs++;
- if (ints[1] != 1) errs++;
- if (ints[2] != 2) errs++;
+ if (ints[0] != 2)
+ errs++;
+ if (ints[1] != 1)
+ errs++;
+ if (ints[2] != 2)
+ errs++;
if (verbose) {
- if (ints[0] != 2) fprintf(stderr,
- "inner vector count = %d; should be 2\n",
- ints[0]);
- if (ints[1] != 1) fprintf(stderr,
- "inner vector blocklength = %d; should be 1\n",
- ints[1]);
- if (ints[2] != 2) fprintf(stderr,
- "inner vector stride = %d; should be 2\n",
- ints[2]);
+ if (ints[0] != 2)
+ fprintf(stderr, "inner vector count = %d; should be 2\n", ints[0]);
+ if (ints[1] != 1)
+ fprintf(stderr, "inner vector blocklength = %d; should be 1\n", ints[1]);
+ if (ints[2] != 2)
+ fprintf(stderr, "inner vector stride = %d; should be 2\n", ints[2]);
}
if (errs) {
- if (verbose) fprintf(stderr, "aborting after %d errors\n", errs);
- return errs;
+ if (verbose)
+ fprintf(stderr, "aborting after %d errors\n", errs);
+ return errs;
}
free(ints);
- if (nadds) free(adds);
+ if (nadds)
+ free(adds);
free(types);
- MPI_Type_free( &inner_vector_copy );
- MPI_Type_free( &inner_vector );
- MPI_Type_free( &outer_vector );
+ MPI_Type_free(&inner_vector_copy);
+ MPI_Type_free(&inner_vector);
+ MPI_Type_free(&outer_vector);
return 0;
}
@@ -327,65 +302,64 @@ int optimizable_vector_of_basics_test(void)
int err, errs = 0;
/* set up type */
- err = MPI_Type_vector(10,
- 2,
- 2,
- MPI_INT,
- &parent_type);
+ err = MPI_Type_vector(10, 2, 2, MPI_INT, &parent_type);
/* decode */
- err = MPI_Type_get_envelope(parent_type,
- &nints,
- &nadds,
- &ntypes,
- &combiner);
+ err = MPI_Type_get_envelope(parent_type, &nints, &nadds, &ntypes, &combiner);
- if (nints != 3) errs++;
- if (nadds != 0) errs++;
- if (ntypes != 1) errs++;
- if (combiner != MPI_COMBINER_VECTOR) errs++;
+ if (nints != 3)
+ errs++;
+ if (nadds != 0)
+ errs++;
+ if (ntypes != 1)
+ errs++;
+ if (combiner != MPI_COMBINER_VECTOR)
+ errs++;
if (verbose) {
- if (nints != 3) fprintf(stderr, "nints = %d; should be 3\n", nints);
- if (nadds != 0) fprintf(stderr, "nadds = %d; should be 0\n", nadds);
- if (ntypes != 1) fprintf(stderr, "ntypes = %d; should be 1\n", ntypes);
- if (combiner != MPI_COMBINER_VECTOR)
- fprintf(stderr, "combiner = %s; should be vector\n",
- combiner_to_string(combiner));
+ if (nints != 3)
+ fprintf(stderr, "nints = %d; should be 3\n", nints);
+ if (nadds != 0)
+ fprintf(stderr, "nadds = %d; should be 0\n", nadds);
+ if (ntypes != 1)
+ fprintf(stderr, "ntypes = %d; should be 1\n", ntypes);
+ if (combiner != MPI_COMBINER_VECTOR)
+ fprintf(stderr, "combiner = %s; should be vector\n", combiner_to_string(combiner));
}
ints = malloc(nints * sizeof(*ints));
- if (nadds) adds = malloc(nadds * sizeof(*adds));
- types = malloc(ntypes *sizeof(*types));
-
- err = MPI_Type_get_contents(parent_type,
- nints,
- nadds,
- ntypes,
- ints,
- adds,
- types);
-
- if (ints[0] != 10) errs++;
- if (ints[1] != 2) errs++;
- if (ints[2] != 2) errs++;
- if (types[0] != MPI_INT) errs++;
+ if (nadds)
+ adds = malloc(nadds * sizeof(*adds));
+ types = malloc(ntypes * sizeof(*types));
+
+ err = MPI_Type_get_contents(parent_type, nints, nadds, ntypes, ints, adds, types);
+
+ if (ints[0] != 10)
+ errs++;
+ if (ints[1] != 2)
+ errs++;
+ if (ints[2] != 2)
+ errs++;
+ if (types[0] != MPI_INT)
+ errs++;
if (verbose) {
- if (ints[0] != 10) fprintf(stderr, "count = %d; should be 10\n",
- ints[0]);
- if (ints[1] != 2) fprintf(stderr, "blocklength = %d; should be 2\n",
- ints[1]);
- if (ints[2] != 2) fprintf(stderr, "stride = %d; should be 2\n",
- ints[2]);
- if (types[0] != MPI_INT) fprintf(stderr, "type is not MPI_INT\n");
+ if (ints[0] != 10)
+ fprintf(stderr, "count = %d; should be 10\n", ints[0]);
+ if (ints[1] != 2)
+ fprintf(stderr, "blocklength = %d; should be 2\n", ints[1]);
+ if (ints[2] != 2)
+ fprintf(stderr, "stride = %d; should be 2\n", ints[2]);
+ if (types[0] != MPI_INT)
+ fprintf(stderr, "type is not MPI_INT\n");
}
free(ints);
- if (nadds) free(adds);
+ if (nadds)
+ free(adds);
free(types);
- MPI_Type_free( &parent_type );
+ MPI_Type_free(&parent_type);
return errs;
}
@@ -410,77 +384,80 @@ int indexed_of_basics_test(void)
int err, errs = 0;
/* set up type */
- err = MPI_Type_indexed(s_count,
- s_blocklengths,
- s_displacements,
- MPI_INT,
- &parent_type);
+ err = MPI_Type_indexed(s_count, s_blocklengths, s_displacements, MPI_INT, &parent_type);
/* decode */
- err = MPI_Type_get_envelope(parent_type,
- &nints,
- &nadds,
- &ntypes,
- &combiner);
+ err = MPI_Type_get_envelope(parent_type, &nints, &nadds, &ntypes, &combiner);
- if (nints != 7) errs++;
- if (nadds != 0) errs++;
- if (ntypes != 1) errs++;
- if (combiner != MPI_COMBINER_INDEXED) errs++;
+ if (nints != 7)
+ errs++;
+ if (nadds != 0)
+ errs++;
+ if (ntypes != 1)
+ errs++;
+ if (combiner != MPI_COMBINER_INDEXED)
+ errs++;
if (verbose) {
- if (nints != 7) fprintf(stderr, "nints = %d; should be 7\n", nints);
- if (nadds != 0) fprintf(stderr, "nadds = %d; should be 0\n", nadds);
- if (ntypes != 1) fprintf(stderr, "ntypes = %d; should be 1\n", ntypes);
- if (combiner != MPI_COMBINER_INDEXED)
- fprintf(stderr, "combiner = %s; should be indexed\n",
- combiner_to_string(combiner));
+ if (nints != 7)
+ fprintf(stderr, "nints = %d; should be 7\n", nints);
+ if (nadds != 0)
+ fprintf(stderr, "nadds = %d; should be 0\n", nadds);
+ if (ntypes != 1)
+ fprintf(stderr, "ntypes = %d; should be 1\n", ntypes);
+ if (combiner != MPI_COMBINER_INDEXED)
+ fprintf(stderr, "combiner = %s; should be indexed\n", combiner_to_string(combiner));
}
ints = malloc(nints * sizeof(*ints));
- if (nadds) adds = malloc(nadds * sizeof(*adds));
- types = malloc(ntypes *sizeof(*types));
-
- err = MPI_Type_get_contents(parent_type,
- nints,
- nadds,
- ntypes,
- ints,
- adds,
- types);
-
- if (ints[0] != s_count) errs++;
- if (ints[1] != s_blocklengths[0]) errs++;
- if (ints[2] != s_blocklengths[1]) errs++;
- if (ints[3] != s_blocklengths[2]) errs++;
- if (ints[4] != s_displacements[0]) errs++;
- if (ints[5] != s_displacements[1]) errs++;
- if (ints[6] != s_displacements[2]) errs++;
- if (types[0] != MPI_INT) errs++;
+ if (nadds)
+ adds = malloc(nadds * sizeof(*adds));
+ types = malloc(ntypes * sizeof(*types));
+
+ err = MPI_Type_get_contents(parent_type, nints, nadds, ntypes, ints, adds, types);
+
+ if (ints[0] != s_count)
+ errs++;
+ if (ints[1] != s_blocklengths[0])
+ errs++;
+ if (ints[2] != s_blocklengths[1])
+ errs++;
+ if (ints[3] != s_blocklengths[2])
+ errs++;
+ if (ints[4] != s_displacements[0])
+ errs++;
+ if (ints[5] != s_displacements[1])
+ errs++;
+ if (ints[6] != s_displacements[2])
+ errs++;
+ if (types[0] != MPI_INT)
+ errs++;
if (verbose) {
- if (ints[0] != s_count)
- fprintf(stderr, "count = %d; should be %d\n", ints[0], s_count);
- if (ints[1] != s_blocklengths[0])
- fprintf(stderr, "blocklength[0] = %d; should be %d\n", ints[1], s_blocklengths[0]);
- if (ints[2] != s_blocklengths[1])
- fprintf(stderr, "blocklength[1] = %d; should be %d\n", ints[2], s_blocklengths[1]);
- if (ints[3] != s_blocklengths[2])
- fprintf(stderr, "blocklength[2] = %d; should be %d\n", ints[3], s_blocklengths[2]);
- if (ints[4] != s_displacements[0])
- fprintf(stderr, "displacement[0] = %d; should be %d\n", ints[4], s_displacements[0]);
- if (ints[5] != s_displacements[1])
- fprintf(stderr, "displacement[1] = %d; should be %d\n", ints[5], s_displacements[1]);
- if (ints[6] != s_displacements[2])
- fprintf(stderr, "displacement[2] = %d; should be %d\n", ints[6], s_displacements[2]);
- if (types[0] != MPI_INT) fprintf(stderr, "type[0] does not match\n");
+ if (ints[0] != s_count)
+ fprintf(stderr, "count = %d; should be %d\n", ints[0], s_count);
+ if (ints[1] != s_blocklengths[0])
+ fprintf(stderr, "blocklength[0] = %d; should be %d\n", ints[1], s_blocklengths[0]);
+ if (ints[2] != s_blocklengths[1])
+ fprintf(stderr, "blocklength[1] = %d; should be %d\n", ints[2], s_blocklengths[1]);
+ if (ints[3] != s_blocklengths[2])
+ fprintf(stderr, "blocklength[2] = %d; should be %d\n", ints[3], s_blocklengths[2]);
+ if (ints[4] != s_displacements[0])
+ fprintf(stderr, "displacement[0] = %d; should be %d\n", ints[4], s_displacements[0]);
+ if (ints[5] != s_displacements[1])
+ fprintf(stderr, "displacement[1] = %d; should be %d\n", ints[5], s_displacements[1]);
+ if (ints[6] != s_displacements[2])
+ fprintf(stderr, "displacement[2] = %d; should be %d\n", ints[6], s_displacements[2]);
+ if (types[0] != MPI_INT)
+ fprintf(stderr, "type[0] does not match\n");
}
free(ints);
- if (nadds) free(adds);
+ if (nadds)
+ free(adds);
free(types);
- MPI_Type_free( &parent_type );
+ MPI_Type_free(&parent_type);
return errs;
}
@@ -494,7 +471,7 @@ int indexed_of_vectors_test(void)
{
MPI_Datatype inner_vector, inner_vector_copy;
MPI_Datatype outer_indexed;
-
+
int i_count = 3, i_blocklengths[3] = { 3, 2, 1 };
int i_displacements[3] = { 10, 20, 30 };
@@ -505,186 +482,176 @@ int indexed_of_vectors_test(void)
int err, errs = 0;
/* set up type */
- err = MPI_Type_vector(2,
- 1,
- 2,
- MPI_INT,
- &inner_vector);
+ err = MPI_Type_vector(2, 1, 2, MPI_INT, &inner_vector);
if (err != MPI_SUCCESS) {
- if (verbose) fprintf(stderr,
- "error in MPI call; aborting after %d errors\n",
- errs+1);
- return errs+1;
+ if (verbose)
+ fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
+ return errs + 1;
}
- err = MPI_Type_indexed(i_count,
- i_blocklengths,
- i_displacements,
- inner_vector,
- &outer_indexed);
+ err = MPI_Type_indexed(i_count, i_blocklengths, i_displacements, inner_vector, &outer_indexed);
if (err != MPI_SUCCESS) {
- if (verbose) fprintf(stderr,
- "error in MPI call; aborting after %d errors\n",
- errs+1);
- return errs+1;
+ if (verbose)
+ fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
+ return errs + 1;
}
/* decode outer vector (get envelope, then contents) */
- err = MPI_Type_get_envelope(outer_indexed,
- &nints,
- &nadds,
- &ntypes,
- &combiner);
+ err = MPI_Type_get_envelope(outer_indexed, &nints, &nadds, &ntypes, &combiner);
if (err != MPI_SUCCESS) {
- if (verbose) fprintf(stderr,
- "error in MPI call; aborting after %d errors\n",
- errs+1);
- return errs+1;
+ if (verbose)
+ fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
+ return errs + 1;
}
- if (nints != 7) errs++;
- if (nadds != 0) errs++;
- if (ntypes != 1) errs++;
- if (combiner != MPI_COMBINER_INDEXED) errs++;
+ if (nints != 7)
+ errs++;
+ if (nadds != 0)
+ errs++;
+ if (ntypes != 1)
+ errs++;
+ if (combiner != MPI_COMBINER_INDEXED)
+ errs++;
if (verbose) {
- if (nints != 7) fprintf(stderr, "nints = %d; should be 7\n", nints);
- if (nadds != 0) fprintf(stderr, "nadds = %d; should be 0\n", nadds);
- if (ntypes != 1) fprintf(stderr, "ntypes = %d; should be 1\n", ntypes);
- if (combiner != MPI_COMBINER_INDEXED)
- fprintf(stderr, "combiner = %s; should be indexed\n",
- combiner_to_string(combiner));
+ if (nints != 7)
+ fprintf(stderr, "nints = %d; should be 7\n", nints);
+ if (nadds != 0)
+ fprintf(stderr, "nadds = %d; should be 0\n", nadds);
+ if (ntypes != 1)
+ fprintf(stderr, "ntypes = %d; should be 1\n", ntypes);
+ if (combiner != MPI_COMBINER_INDEXED)
+ fprintf(stderr, "combiner = %s; should be indexed\n", combiner_to_string(combiner));
}
if (errs) {
- if (verbose) fprintf(stderr, "aborting after %d errors\n", errs);
- return errs;
+ if (verbose)
+ fprintf(stderr, "aborting after %d errors\n", errs);
+ return errs;
}
ints = malloc(nints * sizeof(*ints));
- if (nadds) adds = malloc(nadds * sizeof(*adds));
+ if (nadds)
+ adds = malloc(nadds * sizeof(*adds));
types = malloc(ntypes * sizeof(*types));
/* get contents of outer vector */
- err = MPI_Type_get_contents(outer_indexed,
- nints,
- nadds,
- ntypes,
- ints,
- adds,
- types);
-
- if (ints[0] != i_count) errs++;
- if (ints[1] != i_blocklengths[0]) errs++;
- if (ints[2] != i_blocklengths[1]) errs++;
- if (ints[3] != i_blocklengths[2]) errs++;
- if (ints[4] != i_displacements[0]) errs++;
- if (ints[5] != i_displacements[1]) errs++;
- if (ints[6] != i_displacements[2]) errs++;
+ err = MPI_Type_get_contents(outer_indexed, nints, nadds, ntypes, ints, adds, types);
+
+ if (ints[0] != i_count)
+ errs++;
+ if (ints[1] != i_blocklengths[0])
+ errs++;
+ if (ints[2] != i_blocklengths[1])
+ errs++;
+ if (ints[3] != i_blocklengths[2])
+ errs++;
+ if (ints[4] != i_displacements[0])
+ errs++;
+ if (ints[5] != i_displacements[1])
+ errs++;
+ if (ints[6] != i_displacements[2])
+ errs++;
if (verbose) {
- if (ints[0] != i_count)
- fprintf(stderr, "count = %d; should be %d\n", ints[0], i_count);
- if (ints[1] != i_blocklengths[0])
- fprintf(stderr, "blocklength[0] = %d; should be %d\n", ints[1], i_blocklengths[0]);
- if (ints[2] != i_blocklengths[1])
- fprintf(stderr, "blocklength[1] = %d; should be %d\n", ints[2], i_blocklengths[1]);
- if (ints[3] != i_blocklengths[2])
- fprintf(stderr, "blocklength[2] = %d; should be %d\n", ints[3], i_blocklengths[2]);
- if (ints[4] != i_displacements[0])
- fprintf(stderr, "displacement[0] = %d; should be %d\n", ints[4], i_displacements[0]);
- if (ints[5] != i_displacements[1])
- fprintf(stderr, "displacement[1] = %d; should be %d\n", ints[5], i_displacements[1]);
- if (ints[6] != i_displacements[2])
- fprintf(stderr, "displacement[2] = %d; should be %d\n", ints[6], i_displacements[2]);
+ if (ints[0] != i_count)
+ fprintf(stderr, "count = %d; should be %d\n", ints[0], i_count);
+ if (ints[1] != i_blocklengths[0])
+ fprintf(stderr, "blocklength[0] = %d; should be %d\n", ints[1], i_blocklengths[0]);
+ if (ints[2] != i_blocklengths[1])
+ fprintf(stderr, "blocklength[1] = %d; should be %d\n", ints[2], i_blocklengths[1]);
+ if (ints[3] != i_blocklengths[2])
+ fprintf(stderr, "blocklength[2] = %d; should be %d\n", ints[3], i_blocklengths[2]);
+ if (ints[4] != i_displacements[0])
+ fprintf(stderr, "displacement[0] = %d; should be %d\n", ints[4], i_displacements[0]);
+ if (ints[5] != i_displacements[1])
+ fprintf(stderr, "displacement[1] = %d; should be %d\n", ints[5], i_displacements[1]);
+ if (ints[6] != i_displacements[2])
+ fprintf(stderr, "displacement[2] = %d; should be %d\n", ints[6], i_displacements[2]);
}
if (errs) {
- if (verbose) fprintf(stderr, "aborting after %d errors\n", errs);
- return errs;
+ if (verbose)
+ fprintf(stderr, "aborting after %d errors\n", errs);
+ return errs;
}
inner_vector_copy = types[0];
free(ints);
- if (nadds) free(adds);
+ if (nadds)
+ free(adds);
free(types);
/* decode inner vector */
- err = MPI_Type_get_envelope(inner_vector_copy,
- &nints,
- &nadds,
- &ntypes,
- &combiner);
+ err = MPI_Type_get_envelope(inner_vector_copy, &nints, &nadds, &ntypes, &combiner);
if (err != MPI_SUCCESS) {
- if (verbose) fprintf(stderr,
- "error in MPI call; aborting after %d errors\n",
- errs+1);
- return errs+1;
+ if (verbose)
+ fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
+ return errs + 1;
}
- if (nints != 3) errs++;
- if (nadds != 0) errs++;
- if (ntypes != 1) errs++;
- if (combiner != MPI_COMBINER_VECTOR) errs++;
+ if (nints != 3)
+ errs++;
+ if (nadds != 0)
+ errs++;
+ if (ntypes != 1)
+ errs++;
+ if (combiner != MPI_COMBINER_VECTOR)
+ errs++;
if (verbose) {
- if (nints != 3) fprintf(stderr,
- "inner vector nints = %d; should be 3\n",
- nints);
- if (nadds != 0) fprintf(stderr,
- "inner vector nadds = %d; should be 0\n",
- nadds);
- if (ntypes != 1) fprintf(stderr,
- "inner vector ntypes = %d; should be 1\n",
- ntypes);
- if (combiner != MPI_COMBINER_VECTOR)
- fprintf(stderr, "inner vector combiner = %s; should be vector\n",
- combiner_to_string(combiner));
+ if (nints != 3)
+ fprintf(stderr, "inner vector nints = %d; should be 3\n", nints);
+ if (nadds != 0)
+ fprintf(stderr, "inner vector nadds = %d; should be 0\n", nadds);
+ if (ntypes != 1)
+ fprintf(stderr, "inner vector ntypes = %d; should be 1\n", ntypes);
+ if (combiner != MPI_COMBINER_VECTOR)
+ fprintf(stderr, "inner vector combiner = %s; should be vector\n",
+ combiner_to_string(combiner));
}
if (errs) {
- if (verbose) fprintf(stderr, "aborting after %d errors\n", errs);
- return errs;
+ if (verbose)
+ fprintf(stderr, "aborting after %d errors\n", errs);
+ return errs;
}
ints = malloc(nints * sizeof(*ints));
- if (nadds) adds = malloc(nadds * sizeof(*adds));
+ if (nadds)
+ adds = malloc(nadds * sizeof(*adds));
types = malloc(ntypes * sizeof(*types));
- err = MPI_Type_get_contents(inner_vector_copy,
- nints,
- nadds,
- ntypes,
- ints,
- adds,
- types);
+ err = MPI_Type_get_contents(inner_vector_copy, nints, nadds, ntypes, ints, adds, types);
- if (ints[0] != 2) errs++;
- if (ints[1] != 1) errs++;
- if (ints[2] != 2) errs++;
+ if (ints[0] != 2)
+ errs++;
+ if (ints[1] != 1)
+ errs++;
+ if (ints[2] != 2)
+ errs++;
if (verbose) {
- if (ints[0] != 2) fprintf(stderr,
- "inner vector count = %d; should be 2\n",
- ints[0]);
- if (ints[1] != 1) fprintf(stderr,
- "inner vector blocklength = %d; should be 1\n",
- ints[1]);
- if (ints[2] != 2) fprintf(stderr,
- "inner vector stride = %d; should be 2\n",
- ints[2]);
+ if (ints[0] != 2)
+ fprintf(stderr, "inner vector count = %d; should be 2\n", ints[0]);
+ if (ints[1] != 1)
+ fprintf(stderr, "inner vector blocklength = %d; should be 1\n", ints[1]);
+ if (ints[2] != 2)
+ fprintf(stderr, "inner vector stride = %d; should be 2\n", ints[2]);
}
if (errs) {
- if (verbose) fprintf(stderr, "aborting after %d errors\n", errs);
- return errs;
+ if (verbose)
+ fprintf(stderr, "aborting after %d errors\n", errs);
+ return errs;
}
free(ints);
- if (nadds) free(adds);
+ if (nadds)
+ free(adds);
free(types);
- MPI_Type_free( &inner_vector_copy );
- MPI_Type_free( &inner_vector );
- MPI_Type_free( &outer_indexed );
+ MPI_Type_free(&inner_vector_copy);
+ MPI_Type_free(&inner_vector);
+ MPI_Type_free(&outer_indexed);
return 0;
}
@@ -713,84 +680,86 @@ int struct_of_basics_test(void)
int err, errs = 0;
/* set up type */
- err = MPI_Type_create_struct(s_count,
- s_blocklengths,
- s_displacements,
- s_types,
- &parent_type);
+ err = MPI_Type_create_struct(s_count, s_blocklengths, s_displacements, s_types, &parent_type);
/* decode */
- err = MPI_Type_get_envelope(parent_type,
- &nints,
- &nadds,
- &ntypes,
- &combiner);
+ err = MPI_Type_get_envelope(parent_type, &nints, &nadds, &ntypes, &combiner);
- if (nints != 4) errs++;
- if (nadds != 3) errs++;
- if (ntypes != 3) errs++;
- if (combiner != MPI_COMBINER_STRUCT) errs++;
+ if (nints != 4)
+ errs++;
+ if (nadds != 3)
+ errs++;
+ if (ntypes != 3)
+ errs++;
+ if (combiner != MPI_COMBINER_STRUCT)
+ errs++;
if (verbose) {
- if (nints != 4) fprintf(stderr, "nints = %d; should be 3\n", nints);
- if (nadds != 3) fprintf(stderr, "nadds = %d; should be 0\n", nadds);
- if (ntypes != 3) fprintf(stderr, "ntypes = %d; should be 3\n", ntypes);
- if (combiner != MPI_COMBINER_STRUCT)
- fprintf(stderr, "combiner = %s; should be struct\n",
- combiner_to_string(combiner));
+ if (nints != 4)
+ fprintf(stderr, "nints = %d; should be 3\n", nints);
+ if (nadds != 3)
+ fprintf(stderr, "nadds = %d; should be 0\n", nadds);
+ if (ntypes != 3)
+ fprintf(stderr, "ntypes = %d; should be 3\n", ntypes);
+ if (combiner != MPI_COMBINER_STRUCT)
+ fprintf(stderr, "combiner = %s; should be struct\n", combiner_to_string(combiner));
}
ints = malloc(nints * sizeof(*ints));
adds = malloc(nadds * sizeof(*adds));
- types = malloc(ntypes *sizeof(*types));
-
- err = MPI_Type_get_contents(parent_type,
- nints,
- nadds,
- ntypes,
- ints,
- adds,
- types);
-
- if (ints[0] != s_count) errs++;
- if (ints[1] != s_blocklengths[0]) errs++;
- if (ints[2] != s_blocklengths[1]) errs++;
- if (ints[3] != s_blocklengths[2]) errs++;
- if (adds[0] != s_displacements[0]) errs++;
- if (adds[1] != s_displacements[1]) errs++;
- if (adds[2] != s_displacements[2]) errs++;
- if (types[0] != s_types[0]) errs++;
- if (types[1] != s_types[1]) errs++;
- if (types[2] != s_types[2]) errs++;
+ types = malloc(ntypes * sizeof(*types));
+
+ err = MPI_Type_get_contents(parent_type, nints, nadds, ntypes, ints, adds, types);
+
+ if (ints[0] != s_count)
+ errs++;
+ if (ints[1] != s_blocklengths[0])
+ errs++;
+ if (ints[2] != s_blocklengths[1])
+ errs++;
+ if (ints[3] != s_blocklengths[2])
+ errs++;
+ if (adds[0] != s_displacements[0])
+ errs++;
+ if (adds[1] != s_displacements[1])
+ errs++;
+ if (adds[2] != s_displacements[2])
+ errs++;
+ if (types[0] != s_types[0])
+ errs++;
+ if (types[1] != s_types[1])
+ errs++;
+ if (types[2] != s_types[2])
+ errs++;
if (verbose) {
- if (ints[0] != s_count)
- fprintf(stderr, "count = %d; should be %d\n", ints[0], s_count);
- if (ints[1] != s_blocklengths[0])
- fprintf(stderr, "blocklength[0] = %d; should be %d\n", ints[1], s_blocklengths[0]);
- if (ints[2] != s_blocklengths[1])
- fprintf(stderr, "blocklength[1] = %d; should be %d\n", ints[2], s_blocklengths[1]);
- if (ints[3] != s_blocklengths[2])
- fprintf(stderr, "blocklength[2] = %d; should be %d\n", ints[3], s_blocklengths[2]);
- if (adds[0] != s_displacements[0])
- fprintf(stderr, "displacement[0] = %d; should be %d\n", adds[0], s_displacements[0]);
- if (adds[1] != s_displacements[1])
- fprintf(stderr, "displacement[1] = %d; should be %d\n", adds[1], s_displacements[1]);
- if (adds[2] != s_displacements[2])
- fprintf(stderr, "displacement[2] = %d; should be %d\n", adds[2], s_displacements[2]);
- if (types[0] != s_types[0])
- fprintf(stderr, "type[0] does not match\n");
- if (types[1] != s_types[1])
- fprintf(stderr, "type[1] does not match\n");
- if (types[2] != s_types[2])
- fprintf(stderr, "type[2] does not match\n");
+ if (ints[0] != s_count)
+ fprintf(stderr, "count = %d; should be %d\n", ints[0], s_count);
+ if (ints[1] != s_blocklengths[0])
+ fprintf(stderr, "blocklength[0] = %d; should be %d\n", ints[1], s_blocklengths[0]);
+ if (ints[2] != s_blocklengths[1])
+ fprintf(stderr, "blocklength[1] = %d; should be %d\n", ints[2], s_blocklengths[1]);
+ if (ints[3] != s_blocklengths[2])
+ fprintf(stderr, "blocklength[2] = %d; should be %d\n", ints[3], s_blocklengths[2]);
+ if (adds[0] != s_displacements[0])
+ fprintf(stderr, "displacement[0] = %d; should be %d\n", adds[0], s_displacements[0]);
+ if (adds[1] != s_displacements[1])
+ fprintf(stderr, "displacement[1] = %d; should be %d\n", adds[1], s_displacements[1]);
+ if (adds[2] != s_displacements[2])
+ fprintf(stderr, "displacement[2] = %d; should be %d\n", adds[2], s_displacements[2]);
+ if (types[0] != s_types[0])
+ fprintf(stderr, "type[0] does not match\n");
+ if (types[1] != s_types[1])
+ fprintf(stderr, "type[1] does not match\n");
+ if (types[2] != s_types[2])
+ fprintf(stderr, "type[2] does not match\n");
}
free(ints);
free(adds);
free(types);
- MPI_Type_free( &parent_type );
+ MPI_Type_free(&parent_type);
return errs;
}
@@ -802,48 +771,66 @@ int struct_of_basics_test(void)
*/
char *combiner_to_string(int combiner)
{
- static char c_named[] = "named";
- static char c_contig[] = "contig";
- static char c_vector[] = "vector";
- static char c_hvector[] = "hvector";
- static char c_indexed[] = "indexed";
+ static char c_named[] = "named";
+ static char c_contig[] = "contig";
+ static char c_vector[] = "vector";
+ static char c_hvector[] = "hvector";
+ static char c_indexed[] = "indexed";
static char c_hindexed[] = "hindexed";
- static char c_struct[] = "struct";
+ static char c_struct[] = "struct";
#ifdef HAVE_MPI2_COMBINERS
- static char c_dup[] = "dup";
- static char c_hvector_integer[] = "hvector_integer";
+ static char c_dup[] = "dup";
+ static char c_hvector_integer[] = "hvector_integer";
static char c_hindexed_integer[] = "hindexed_integer";
- static char c_indexed_block[] = "indexed_block";
- static char c_struct_integer[] = "struct_integer";
- static char c_subarray[] = "subarray";
- static char c_darray[] = "darray";
- static char c_f90_real[] = "f90_real";
- static char c_f90_complex[] = "f90_complex";
- static char c_f90_integer[] = "f90_integer";
- static char c_resized[] = "resized";
+ static char c_indexed_block[] = "indexed_block";
+ static char c_struct_integer[] = "struct_integer";
+ static char c_subarray[] = "subarray";
+ static char c_darray[] = "darray";
+ static char c_f90_real[] = "f90_real";
+ static char c_f90_complex[] = "f90_complex";
+ static char c_f90_integer[] = "f90_integer";
+ static char c_resized[] = "resized";
#endif
- if (combiner == MPI_COMBINER_NAMED) return c_named;
- if (combiner == MPI_COMBINER_CONTIGUOUS) return c_contig;
- if (combiner == MPI_COMBINER_VECTOR) return c_vector;
- if (combiner == MPI_COMBINER_HVECTOR) return c_hvector;
- if (combiner == MPI_COMBINER_INDEXED) return c_indexed;
- if (combiner == MPI_COMBINER_HINDEXED) return c_hindexed;
- if (combiner == MPI_COMBINER_STRUCT) return c_struct;
+ if (combiner == MPI_COMBINER_NAMED)
+ return c_named;
+ if (combiner == MPI_COMBINER_CONTIGUOUS)
+ return c_contig;
+ if (combiner == MPI_COMBINER_VECTOR)
+ return c_vector;
+ if (combiner == MPI_COMBINER_HVECTOR)
+ return c_hvector;
+ if (combiner == MPI_COMBINER_INDEXED)
+ return c_indexed;
+ if (combiner == MPI_COMBINER_HINDEXED)
+ return c_hindexed;
+ if (combiner == MPI_COMBINER_STRUCT)
+ return c_struct;
#ifdef HAVE_MPI2_COMBINERS
- if (combiner == MPI_COMBINER_DUP) return c_dup;
- if (combiner == MPI_COMBINER_HVECTOR_INTEGER) return c_hvector_integer;
- if (combiner == MPI_COMBINER_HINDEXED_INTEGER) return c_hindexed_integer;
- if (combiner == MPI_COMBINER_INDEXED_BLOCK) return c_indexed_block;
- if (combiner == MPI_COMBINER_STRUCT_INTEGER) return c_struct_integer;
- if (combiner == MPI_COMBINER_SUBARRAY) return c_subarray;
- if (combiner == MPI_COMBINER_DARRAY) return c_darray;
- if (combiner == MPI_COMBINER_F90_REAL) return c_f90_real;
- if (combiner == MPI_COMBINER_F90_COMPLEX) return c_f90_complex;
- if (combiner == MPI_COMBINER_F90_INTEGER) return c_f90_integer;
- if (combiner == MPI_COMBINER_RESIZED) return c_resized;
+ if (combiner == MPI_COMBINER_DUP)
+ return c_dup;
+ if (combiner == MPI_COMBINER_HVECTOR_INTEGER)
+ return c_hvector_integer;
+ if (combiner == MPI_COMBINER_HINDEXED_INTEGER)
+ return c_hindexed_integer;
+ if (combiner == MPI_COMBINER_INDEXED_BLOCK)
+ return c_indexed_block;
+ if (combiner == MPI_COMBINER_STRUCT_INTEGER)
+ return c_struct_integer;
+ if (combiner == MPI_COMBINER_SUBARRAY)
+ return c_subarray;
+ if (combiner == MPI_COMBINER_DARRAY)
+ return c_darray;
+ if (combiner == MPI_COMBINER_F90_REAL)
+ return c_f90_real;
+ if (combiner == MPI_COMBINER_F90_COMPLEX)
+ return c_f90_complex;
+ if (combiner == MPI_COMBINER_F90_INTEGER)
+ return c_f90_integer;
+ if (combiner == MPI_COMBINER_RESIZED)
+ return c_resized;
#endif
-
+
return NULL;
}
@@ -852,16 +839,14 @@ int parse_args(int argc, char **argv)
#ifdef HAVE_GET_OPT
int ret;
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
+ while ((ret = getopt(argc, argv, "v")) >= 0) {
+ switch (ret) {
+ case 'v':
+ verbose = 1;
+ break;
+ }
}
#else
#endif
return 0;
}
-
diff --git a/test/mpi/datatype/contig-zero-count.c b/test/mpi/datatype/contig-zero-count.c
index 6236173..a6b9cd9 100644
--- a/test/mpi/datatype/contig-zero-count.c
+++ b/test/mpi/datatype/contig-zero-count.c
@@ -23,25 +23,25 @@ int main(int argc, char **argv)
{
int err, errs = 0;
- MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
+ MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
/* perform some tests */
err = contig_test();
- if (err && verbose) fprintf(stderr, "%d errors in contig test.\n",
- err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in contig test.\n", err);
errs += err;
/* print message and exit */
if (errs) {
- fprintf(stderr, "Found %d errors\n", errs);
+ fprintf(stderr, "Found %d errors\n", errs);
}
else {
- printf(" No Errors\n");
+ printf(" No Errors\n");
}
MPI_Finalize();
return 0;
@@ -63,52 +63,45 @@ int contig_test(void)
int size;
MPI_Aint extent;
- err = MPI_Type_contiguous(count,
- MPI_INT,
- &newtype);
+ err = MPI_Type_contiguous(count, MPI_INT, &newtype);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error creating type in contig_test()\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "error creating type in contig_test()\n");
+ }
+ errs++;
}
err = MPI_Type_size(newtype, &size);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error obtaining type size in contig_test()\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "error obtaining type size in contig_test()\n");
+ }
+ errs++;
}
-
+
if (size != 0) {
- if (verbose) {
- fprintf(stderr,
- "error: size != 0 in contig_test()\n");
- }
- errs++;
- }
+ if (verbose) {
+ fprintf(stderr, "error: size != 0 in contig_test()\n");
+ }
+ errs++;
+ }
err = MPI_Type_extent(newtype, &extent);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error obtaining type extent in contig_test()\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "error obtaining type extent in contig_test()\n");
+ }
+ errs++;
}
-
+
if (extent != 0) {
- if (verbose) {
- fprintf(stderr,
- "error: extent != 0 in contig_test()\n");
- }
- errs++;
- }
+ if (verbose) {
+ fprintf(stderr, "error: extent != 0 in contig_test()\n");
+ }
+ errs++;
+ }
- MPI_Type_free( &newtype );
+ MPI_Type_free(&newtype);
return errs;
}
@@ -117,19 +110,18 @@ int contig_test(void)
int parse_args(int argc, char **argv)
{
/*
- int ret;
-
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
- }
- */
+ * int ret;
+ *
+ * while ((ret = getopt(argc, argv, "v")) >= 0)
+ * {
+ * switch (ret) {
+ * case 'v':
+ * verbose = 1;
+ * break;
+ * }
+ * }
+ */
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
return 0;
}
-
diff --git a/test/mpi/datatype/contigstruct.c b/test/mpi/datatype/contigstruct.c
index 657c8e0..2081559 100644
--- a/test/mpi/datatype/contigstruct.c
+++ b/test/mpi/datatype/contigstruct.c
@@ -14,34 +14,34 @@
* avoid any struct->contig optimizations.
*/
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- int blocklens[8], psize, i, rank;
- MPI_Aint displs[8];
- MPI_Datatype oldtypes[8];
- MPI_Datatype ntype1, ntype2;
-
- MPI_Init( &argc, &argv );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
-
- for (i=0; i<8; i++) {
- blocklens[i] = 1;
- displs[i] = (7-i) * sizeof(long);
- oldtypes[i] = MPI_LONG;
+ int blocklens[8], psize, i, rank;
+ MPI_Aint displs[8];
+ MPI_Datatype oldtypes[8];
+ MPI_Datatype ntype1, ntype2;
+
+ MPI_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+
+ for (i = 0; i < 8; i++) {
+ blocklens[i] = 1;
+ displs[i] = (7 - i) * sizeof(long);
+ oldtypes[i] = MPI_LONG;
}
- MPI_Type_struct( 8, blocklens, displs, oldtypes, &ntype1 );
- MPI_Type_contiguous( 65536, ntype1, &ntype2 );
- MPI_Type_commit( &ntype2 );
+ MPI_Type_struct(8, blocklens, displs, oldtypes, &ntype1);
+ MPI_Type_contiguous(65536, ntype1, &ntype2);
+ MPI_Type_commit(&ntype2);
- MPI_Pack_size( 2, ntype2, MPI_COMM_WORLD, &psize );
+ MPI_Pack_size(2, ntype2, MPI_COMM_WORLD, &psize);
- MPI_Type_free( &ntype2 );
- MPI_Type_free( &ntype1 );
+ MPI_Type_free(&ntype2);
+ MPI_Type_free(&ntype1);
/* The only failure mode has been SEGV or aborts within the datatype
- routines */
+ * routines */
if (rank == 0) {
- printf( " No Errors\n" );
+ printf(" No Errors\n");
}
MPI_Finalize();
diff --git a/test/mpi/datatype/darray-cyclic.c b/test/mpi/datatype/darray-cyclic.c
index 910cfc4..8e1e1b2 100644
--- a/test/mpi/datatype/darray-cyclic.c
+++ b/test/mpi/datatype/darray-cyclic.c
@@ -8,10 +8,10 @@
#include <stdlib.h>
#include "mpitest.h"
-int AllocateGrid( int nx, int ny, int **srcArray, int **destArray );
-int PackUnpack( MPI_Datatype, const int [], int[], int );
+int AllocateGrid(int nx, int ny, int **srcArray, int **destArray);
+int PackUnpack(MPI_Datatype, const int[], int[], int);
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int wrank, wsize;
@@ -21,232 +21,222 @@ int main( int argc, char *argv[] )
int i, j, ii, jj, loc;
MPI_Datatype darraytype;
- MTest_Init( 0, 0 );
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
- MPI_Comm_size( MPI_COMM_WORLD, &wsize );
+ MTest_Init(0, 0);
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
+ MPI_Comm_size(MPI_COMM_WORLD, &wsize);
/* Test 1: Simple, 1-D cyclic decomposition */
- if (AllocateGrid( 1, 3*wsize, &srcArray, &destArray ) ) {
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ if (AllocateGrid(1, 3 * wsize, &srcArray, &destArray)) {
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
/* Simple cyclic with 1-dim global array */
- gsizes[0] = 3*wsize;
+ gsizes[0] = 3 * wsize;
distribs[0] = MPI_DISTRIBUTE_CYCLIC;
- dargs[0] = 1;
- psizes[0] = wsize;
- MPI_Type_create_darray( wsize, wrank, 1,
- gsizes, distribs, dargs, psizes,
- MPI_ORDER_C, MPI_INT, &darraytype );
+ dargs[0] = 1;
+ psizes[0] = wsize;
+ MPI_Type_create_darray(wsize, wrank, 1,
+ gsizes, distribs, dargs, psizes, MPI_ORDER_C, MPI_INT, &darraytype);
/* Check the created datatype. Because cyclic, should represent
- a strided type */
- if (PackUnpack( darraytype, srcArray, destArray, 3 )) {
- fprintf( stderr, "Error in pack/unpack check\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ * a strided type */
+ if (PackUnpack(darraytype, srcArray, destArray, 3)) {
+ fprintf(stderr, "Error in pack/unpack check\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
/* Now, check for correct data */
- for (i=0; i<3; i++) {
- if (destArray[i] != wrank + i * wsize) {
- fprintf( stderr, "1D: %d: Expected %d but saw %d\n",
- i, wrank + i * wsize, destArray[i] );
- errs++;
- }
+ for (i = 0; i < 3; i++) {
+ if (destArray[i] != wrank + i * wsize) {
+ fprintf(stderr, "1D: %d: Expected %d but saw %d\n", i, wrank + i * wsize, destArray[i]);
+ errs++;
+ }
}
- free( destArray );
- free( srcArray );
- MPI_Type_free( &darraytype );
+ free(destArray);
+ free(srcArray);
+ MPI_Type_free(&darraytype);
/* Test 2: Simple, 1-D cyclic decomposition, with block size=2 */
- if (AllocateGrid( 1, 4*wsize, &srcArray, &destArray ) ) {
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ if (AllocateGrid(1, 4 * wsize, &srcArray, &destArray)) {
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
/* Simple cyclic with 1-dim global array */
- gsizes[0] = 4*wsize;
+ gsizes[0] = 4 * wsize;
distribs[0] = MPI_DISTRIBUTE_CYCLIC;
- dargs[0] = 2;
- psizes[0] = wsize;
- MPI_Type_create_darray( wsize, wrank, 1,
- gsizes, distribs, dargs, psizes,
- MPI_ORDER_C, MPI_INT, &darraytype );
+ dargs[0] = 2;
+ psizes[0] = wsize;
+ MPI_Type_create_darray(wsize, wrank, 1,
+ gsizes, distribs, dargs, psizes, MPI_ORDER_C, MPI_INT, &darraytype);
/* Check the created datatype. Because cyclic, should represent
- a strided type */
- if (PackUnpack( darraytype, srcArray, destArray, 4 )) {
- fprintf( stderr, "Error in pack/unpack check\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ * a strided type */
+ if (PackUnpack(darraytype, srcArray, destArray, 4)) {
+ fprintf(stderr, "Error in pack/unpack check\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
loc = 0;
/* for each cyclic element */
- for (i=0; i<2; i++) {
- /* For each element in block */
- for (j=0; j<2; j++) {
- if (destArray[loc] != 2*wrank + i * 2*wsize + j) {
- fprintf( stderr, "1D(2): %d: Expected %d but saw %d\n",
- i, 2*wrank + i * 2*wsize+j, destArray[loc] );
- errs++;
- }
- loc++;
- }
- }
-
- free( destArray );
- free( srcArray );
- MPI_Type_free( &darraytype );
+ for (i = 0; i < 2; i++) {
+ /* For each element in block */
+ for (j = 0; j < 2; j++) {
+ if (destArray[loc] != 2 * wrank + i * 2 * wsize + j) {
+ fprintf(stderr, "1D(2): %d: Expected %d but saw %d\n",
+ i, 2 * wrank + i * 2 * wsize + j, destArray[loc]);
+ errs++;
+ }
+ loc++;
+ }
+ }
+
+ free(destArray);
+ free(srcArray);
+ MPI_Type_free(&darraytype);
/* 2D: Create some 2-D decompositions */
- px = wsize/2;
+ px = wsize / 2;
py = 2;
rx = wrank % px;
ry = wrank / px;
if (px * py != wsize) {
- fprintf( stderr, "An even number of processes is required\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "An even number of processes is required\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
/* Cyclic/Cyclic */
- if (AllocateGrid( 5*px, 7*py, &srcArray, &destArray )) {
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ if (AllocateGrid(5 * px, 7 * py, &srcArray, &destArray)) {
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- /* Simple cyclic/cyclic. Note in C order, the [1] index varies most
- rapidly */
- gsizes[0] = ny = 7*py;
- gsizes[1] = nx = 5*px;
+ /* Simple cyclic/cyclic. Note in C order, the [1] index varies most
+ * rapidly */
+ gsizes[0] = ny = 7 * py;
+ gsizes[1] = nx = 5 * px;
distribs[0] = MPI_DISTRIBUTE_CYCLIC;
distribs[1] = MPI_DISTRIBUTE_CYCLIC;
- dargs[0] = 1;
- dargs[1] = 1;
- psizes[0] = py;
- psizes[1] = px;
- MPI_Type_create_darray( wsize, wrank, 2,
- gsizes, distribs, dargs, psizes,
- MPI_ORDER_C, MPI_INT, &darraytype );
+ dargs[0] = 1;
+ dargs[1] = 1;
+ psizes[0] = py;
+ psizes[1] = px;
+ MPI_Type_create_darray(wsize, wrank, 2,
+ gsizes, distribs, dargs, psizes, MPI_ORDER_C, MPI_INT, &darraytype);
/* Check the created datatype. Because cyclic, should represent
- a strided type */
- if (PackUnpack( darraytype, srcArray, destArray, 5*7 )) {
- fprintf( stderr, "Error in pack/unpack check\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ * a strided type */
+ if (PackUnpack(darraytype, srcArray, destArray, 5 * 7)) {
+ fprintf(stderr, "Error in pack/unpack check\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
loc = 0;
- for (j=0; j<7; j++) {
- for (i=0; i<5; i++) {
- int expected = rx + ry * nx + i * px + j * nx * py;
- if (destArray[loc] != expected) {
- errs++;
- fprintf( stderr, "2D(cc): [%d,%d] = %d, expected %d\n",
- i, j, destArray[loc], expected );
- }
- loc++;
- }
- }
-
- free( srcArray );
- free( destArray );
- MPI_Type_free( &darraytype );
+ for (j = 0; j < 7; j++) {
+ for (i = 0; i < 5; i++) {
+ int expected = rx + ry * nx + i * px + j * nx * py;
+ if (destArray[loc] != expected) {
+ errs++;
+ fprintf(stderr, "2D(cc): [%d,%d] = %d, expected %d\n",
+ i, j, destArray[loc], expected);
+ }
+ loc++;
+ }
+ }
+
+ free(srcArray);
+ free(destArray);
+ MPI_Type_free(&darraytype);
/* Cyclic(2)/Cyclic(3) */
- if (AllocateGrid( 6*px, 4*py, &srcArray, &destArray )) {
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ if (AllocateGrid(6 * px, 4 * py, &srcArray, &destArray)) {
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- /* Block cyclic/cyclic. Note in C order, the [1] index varies most
- rapidly */
- gsizes[0] = ny = 4*py;
- gsizes[1] = nx = 6*px;
+ /* Block cyclic/cyclic. Note in C order, the [1] index varies most
+ * rapidly */
+ gsizes[0] = ny = 4 * py;
+ gsizes[1] = nx = 6 * px;
distribs[0] = MPI_DISTRIBUTE_CYCLIC;
distribs[1] = MPI_DISTRIBUTE_CYCLIC;
- dargs[0] = by = 2;
- dargs[1] = bx = 3;
- psizes[0] = py;
- psizes[1] = px;
- MPI_Type_create_darray( wsize, wrank, 2,
- gsizes, distribs, dargs, psizes,
- MPI_ORDER_C, MPI_INT, &darraytype );
+ dargs[0] = by = 2;
+ dargs[1] = bx = 3;
+ psizes[0] = py;
+ psizes[1] = px;
+ MPI_Type_create_darray(wsize, wrank, 2,
+ gsizes, distribs, dargs, psizes, MPI_ORDER_C, MPI_INT, &darraytype);
/* Check the created datatype. Because cyclic, should represent
- a strided type */
- if (PackUnpack( darraytype, srcArray, destArray, 4*6 )) {
- fprintf( stderr, "Error in pack/unpack check\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ * a strided type */
+ if (PackUnpack(darraytype, srcArray, destArray, 4 * 6)) {
+ fprintf(stderr, "Error in pack/unpack check\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
loc = 0;
- for (j=0; j<4/by; j++) {
- for (jj=0; jj<by; jj++) {
- for (i=0; i<6/bx; i++) {
- for (ii=0; ii<bx; ii++) {
- int expected = rx * bx + ry * by * nx + i * bx * px + ii +
- (j * by * py + jj) * nx;
- if (destArray[loc] != expected) {
- errs++;
- fprintf( stderr, "2D(c(2)c(3)): [%d,%d] = %d, expected %d\n",
- i*bx+ii, j*by+jj, destArray[loc], expected );
- }
- loc++;
- }
- }
- }
- }
-
- free( srcArray );
- free( destArray );
- MPI_Type_free( &darraytype );
-
- MTest_Finalize( errs );
+ for (j = 0; j < 4 / by; j++) {
+ for (jj = 0; jj < by; jj++) {
+ for (i = 0; i < 6 / bx; i++) {
+ for (ii = 0; ii < bx; ii++) {
+ int expected = rx * bx + ry * by * nx + i * bx * px + ii +
+ (j * by * py + jj) * nx;
+ if (destArray[loc] != expected) {
+ errs++;
+ fprintf(stderr, "2D(c(2)c(3)): [%d,%d] = %d, expected %d\n",
+ i * bx + ii, j * by + jj, destArray[loc], expected);
+ }
+ loc++;
+ }
+ }
+ }
+ }
+
+ free(srcArray);
+ free(destArray);
+ MPI_Type_free(&darraytype);
+
+ MTest_Finalize(errs);
MPI_Finalize();
-
+
return 0;
}
-int AllocateGrid( int nx, int ny, int **srcArray, int **destArray )
+int AllocateGrid(int nx, int ny, int **srcArray, int **destArray)
{
int *src, *dest;
int i, j;
- src = (int *)malloc( nx*ny*sizeof(int) );
- dest = (int *)malloc( nx*ny*sizeof(int) );
+ src = (int *) malloc(nx * ny * sizeof(int));
+ dest = (int *) malloc(nx * ny * sizeof(int));
if (!src || !dest) {
- fprintf( stderr, "Unable to allocate test arrays of size (%d x %d)\n",
- nx, ny );
- return 1;
+ fprintf(stderr, "Unable to allocate test arrays of size (%d x %d)\n", nx, ny);
+ return 1;
}
- for (i=0; i<nx*ny; i++) {
- src[i] = i;
- dest[i] = -i-1;
+ for (i = 0; i < nx * ny; i++) {
+ src[i] = i;
+ dest[i] = -i - 1;
}
- *srcArray = src;
+ *srcArray = src;
*destArray = dest;
return 0;
}
/* Extract the source array into the dest array using the DARRAY datatype.
"count" integers are returned in destArray */
-int PackUnpack( MPI_Datatype darraytype, const int srcArray[], int destArray[],
- int count )
+int PackUnpack(MPI_Datatype darraytype, const int srcArray[], int destArray[], int count)
{
int packsize, position;
int *packArray;
- MPI_Type_commit( &darraytype );
- MPI_Pack_size( 1, darraytype, MPI_COMM_SELF, &packsize );
- packArray = (int *)malloc( packsize );
+ MPI_Type_commit(&darraytype);
+ MPI_Pack_size(1, darraytype, MPI_COMM_SELF, &packsize);
+ packArray = (int *) malloc(packsize);
if (!packArray) {
- fprintf( stderr, "Unable to allocate pack array of size %d\n",
- packsize );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Unable to allocate pack array of size %d\n", packsize);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
position = 0;
- MPI_Pack( (int*)srcArray, 1, darraytype, packArray, packsize, &position,
- MPI_COMM_SELF );
+ MPI_Pack((int *) srcArray, 1, darraytype, packArray, packsize, &position, MPI_COMM_SELF);
packsize = position;
position = 0;
- MPI_Unpack( packArray, packsize, &position, destArray, count, MPI_INT,
- MPI_COMM_SELF );
- free( packArray );
+ MPI_Unpack(packArray, packsize, &position, destArray, count, MPI_INT, MPI_COMM_SELF);
+ free(packArray);
return 0;
}
diff --git a/test/mpi/datatype/darray-pack.c b/test/mpi/datatype/darray-pack.c
index e2104e7..25b37fb 100644
--- a/test/mpi/datatype/darray-pack.c
+++ b/test/mpi/datatype/darray-pack.c
@@ -9,7 +9,7 @@
#include <string.h>
#include "mpitest.h"
-/*
+/*
The default behavior of the test routines should be to briefly indicate
the cause of any errors - in this test, that means that verbose needs
to be set. Verbose should turn on output that is independent of error
@@ -23,39 +23,36 @@ int darray_4d_c_test1(void);
/* helper functions */
static int parse_args(int argc, char **argv);
-static int pack_and_unpack(char *typebuf,
- int count,
- MPI_Datatype datatype,
- int typebufsz);
+static int pack_and_unpack(char *typebuf, int count, MPI_Datatype datatype, int typebufsz);
int main(int argc, char **argv)
{
int err, errs = 0;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
/* perform some tests */
err = darray_2d_c_test1();
- if (err && verbose) fprintf(stderr,
- "%d errors in 2d darray c test 1.\n", err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in 2d darray c test 1.\n", err);
errs += err;
err = darray_4d_c_test1();
- if (err && verbose) fprintf(stderr,
- "%d errors in 4d darray c test 1.\n", err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in 4d darray c test 1.\n", err);
errs += err;
/* print message and exit */
/* Allow the use of more than one process - some MPI implementations
- (including IBM's) check that the number of processes given to
- Type_create_darray is no larger than MPI_COMM_WORLD */
+ * (including IBM's) check that the number of processes given to
+ * Type_create_darray is no larger than MPI_COMM_WORLD */
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
@@ -71,69 +68,65 @@ int main(int argc, char **argv)
int darray_2d_c_test1(void)
{
MPI_Datatype darray;
- int array[9]; /* initialized below */
- int array_size[2] = {3, 3};
- int array_distrib[2] = {MPI_DISTRIBUTE_BLOCK, MPI_DISTRIBUTE_BLOCK};
- int array_dargs[2] = {MPI_DISTRIBUTE_DFLT_DARG, MPI_DISTRIBUTE_DFLT_DARG};
- int array_psizes[2] = {3, 3};
+ int array[9]; /* initialized below */
+ int array_size[2] = { 3, 3 };
+ int array_distrib[2] = { MPI_DISTRIBUTE_BLOCK, MPI_DISTRIBUTE_BLOCK };
+ int array_dargs[2] = { MPI_DISTRIBUTE_DFLT_DARG, MPI_DISTRIBUTE_DFLT_DARG };
+ int array_psizes[2] = { 3, 3 };
int i, rank, err, errs = 0, sizeoftype;
/* pretend we are each rank, one at a time */
- for (rank=0; rank < 9; rank++) {
- /* set up buffer */
- for (i=0; i < 9; i++) {
- array[i] = i;
- }
-
- /* set up type */
- err = MPI_Type_create_darray(9, /* size */
- rank,
- 2, /* dims */
- array_size,
- array_distrib,
- array_dargs,
- array_psizes,
- MPI_ORDER_C,
- MPI_INT,
- &darray);
- if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in MPI_Type_create_darray call; aborting after %d errors\n",
- errs);
- }
- MTestPrintError( err );
- return errs;
- }
-
- MPI_Type_commit(&darray);
-
- MPI_Type_size(darray, &sizeoftype);
- if (sizeoftype != sizeof(int)) {
- errs++;
- if (verbose) fprintf(stderr, "size of type = %d; should be %d\n",
- sizeoftype, (int) sizeof(int));
- return errs;
- }
-
- err = pack_and_unpack((char *) array, 1, darray, 9*sizeof(int));
-
- for (i=0; i < 9; i++) {
-
- if ((i == rank) && (array[i] != rank)) {
- errs++;
- if (verbose) fprintf(stderr, "[2d array rank=%d]:array[%d] = %d; should be %d\n",
- rank, i, array[i], rank);
- }
- else if ((i != rank) && (array[i] != 0)) {
- errs++;
- if (verbose) fprintf(stderr, "[2d array rank=%d]:array[%d] = %d; should be %d\n",
- rank, i, array[i], 0);
- }
- }
- MPI_Type_free(&darray);
+ for (rank = 0; rank < 9; rank++) {
+ /* set up buffer */
+ for (i = 0; i < 9; i++) {
+ array[i] = i;
+ }
+
+ /* set up type */
+ err = MPI_Type_create_darray(9, /* size */
+ rank, 2, /* dims */
+ array_size,
+ array_distrib,
+ array_dargs, array_psizes, MPI_ORDER_C, MPI_INT, &darray);
+ if (err != MPI_SUCCESS) {
+ errs++;
+ if (verbose) {
+ fprintf(stderr,
+ "error in MPI_Type_create_darray call; aborting after %d errors\n", errs);
+ }
+ MTestPrintError(err);
+ return errs;
+ }
+
+ MPI_Type_commit(&darray);
+
+ MPI_Type_size(darray, &sizeoftype);
+ if (sizeoftype != sizeof(int)) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "size of type = %d; should be %d\n", sizeoftype, (int) sizeof(int));
+ return errs;
+ }
+
+ err = pack_and_unpack((char *) array, 1, darray, 9 * sizeof(int));
+
+ for (i = 0; i < 9; i++) {
+
+ if ((i == rank) && (array[i] != rank)) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "[2d array rank=%d]:array[%d] = %d; should be %d\n",
+ rank, i, array[i], rank);
+ }
+ else if ((i != rank) && (array[i] != 0)) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "[2d array rank=%d]:array[%d] = %d; should be %d\n",
+ rank, i, array[i], 0);
+ }
+ }
+ MPI_Type_free(&darray);
}
return errs;
@@ -147,85 +140,85 @@ int darray_4d_c_test1(void)
{
MPI_Datatype darray;
int array[72];
- int array_size[4] = {6, 3, 2, 2};
+ int array_size[4] = { 6, 3, 2, 2 };
int array_distrib[4] = { MPI_DISTRIBUTE_BLOCK,
- MPI_DISTRIBUTE_BLOCK,
- MPI_DISTRIBUTE_NONE,
- MPI_DISTRIBUTE_NONE };
+ MPI_DISTRIBUTE_BLOCK,
+ MPI_DISTRIBUTE_NONE,
+ MPI_DISTRIBUTE_NONE
+ };
int array_dargs[4] = { MPI_DISTRIBUTE_DFLT_DARG,
- MPI_DISTRIBUTE_DFLT_DARG,
- MPI_DISTRIBUTE_DFLT_DARG,
- MPI_DISTRIBUTE_DFLT_DARG };
- int array_psizes[4] = {6, 3, 1, 1};
+ MPI_DISTRIBUTE_DFLT_DARG,
+ MPI_DISTRIBUTE_DFLT_DARG,
+ MPI_DISTRIBUTE_DFLT_DARG
+ };
+ int array_psizes[4] = { 6, 3, 1, 1 };
int i, rank, err, errs = 0, sizeoftype;
- for (rank=0; rank < 18; rank++) {
- /* set up array */
- for (i=0; i < 72; i++) {
- array[i] = i;
- }
-
- /* set up type */
- err = MPI_Type_create_darray(18, /* size */
- rank,
- 4, /* dims */
- array_size,
- array_distrib,
- array_dargs,
- array_psizes,
- MPI_ORDER_C,
- MPI_INT,
- &darray);
- if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in MPI_Type_create_darray call; aborting after %d errors\n",
- errs);
- }
- MTestPrintError( err );
- return errs;
- }
-
- MPI_Type_commit(&darray);
-
- /* verify the size of the type */
- MPI_Type_size(darray, &sizeoftype);
- if (sizeoftype != 4*sizeof(int)) {
- errs++;
- if (verbose) fprintf(stderr, "size of type = %d; should be %d\n",
- sizeoftype, (int) (4*sizeof(int)));
- return errs;
- }
-
- /* pack and unpack the type, zero'ing out all other values */
- err = pack_and_unpack((char *) array, 1, darray, 72*sizeof(int));
-
- for (i=0; i < 4*rank; i++) {
- if (array[i] != 0) {
- errs++;
- if (verbose) fprintf(stderr, "[4d array rank=%d]:array[%d] = %d; should be %d\n",
- rank, i, array[i], 0);
- }
- }
-
- for (i=4*rank; i < 4*rank + 4; i++) {
- if (array[i] != i) {
- errs++;
- if (verbose) fprintf(stderr, "[4d array rank=%d]:array[%d] = %d; should be %d\n",
- rank, i, array[i], i);
- }
- }
- for (i=4*rank+4; i < 72; i++) {
- if (array[i] != 0) {
- errs++;
- if (verbose) fprintf(stderr, "[4d array rank=%d]:array[%d] = %d; should be %d\n",
- rank, i, array[i], 0);
- }
- }
-
- MPI_Type_free(&darray);
+ for (rank = 0; rank < 18; rank++) {
+ /* set up array */
+ for (i = 0; i < 72; i++) {
+ array[i] = i;
+ }
+
+ /* set up type */
+ err = MPI_Type_create_darray(18, /* size */
+ rank, 4, /* dims */
+ array_size,
+ array_distrib,
+ array_dargs, array_psizes, MPI_ORDER_C, MPI_INT, &darray);
+ if (err != MPI_SUCCESS) {
+ errs++;
+ if (verbose) {
+ fprintf(stderr,
+ "error in MPI_Type_create_darray call; aborting after %d errors\n", errs);
+ }
+ MTestPrintError(err);
+ return errs;
+ }
+
+ MPI_Type_commit(&darray);
+
+ /* verify the size of the type */
+ MPI_Type_size(darray, &sizeoftype);
+ if (sizeoftype != 4 * sizeof(int)) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "size of type = %d; should be %d\n",
+ sizeoftype, (int) (4 * sizeof(int)));
+ return errs;
+ }
+
+ /* pack and unpack the type, zero'ing out all other values */
+ err = pack_and_unpack((char *) array, 1, darray, 72 * sizeof(int));
+
+ for (i = 0; i < 4 * rank; i++) {
+ if (array[i] != 0) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "[4d array rank=%d]:array[%d] = %d; should be %d\n",
+ rank, i, array[i], 0);
+ }
+ }
+
+ for (i = 4 * rank; i < 4 * rank + 4; i++) {
+ if (array[i] != i) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "[4d array rank=%d]:array[%d] = %d; should be %d\n",
+ rank, i, array[i], i);
+ }
+ }
+ for (i = 4 * rank + 4; i < 72; i++) {
+ if (array[i] != 0) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "[4d array rank=%d]:array[%d] = %d; should be %d\n",
+ rank, i, array[i], 0);
+ }
+ }
+
+ MPI_Type_free(&darray);
}
return errs;
}
@@ -247,93 +240,70 @@ int darray_4d_c_test1(void)
* between the pack and unpack steps
*
*/
-static int pack_and_unpack(char *typebuf,
- int count,
- MPI_Datatype datatype,
- int typebufsz)
+static int pack_and_unpack(char *typebuf, int count, MPI_Datatype datatype, int typebufsz)
{
char *packbuf;
int err, errs = 0, pack_size, type_size, position;
err = MPI_Type_size(datatype, &type_size);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in MPI_Type_size call; aborting after %d errors\n",
- errs);
- }
- MTestPrintError( err );
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "error in MPI_Type_size call; aborting after %d errors\n", errs);
+ }
+ MTestPrintError(err);
+ return errs;
}
type_size *= count;
err = MPI_Pack_size(count, datatype, MPI_COMM_SELF, &pack_size);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in MPI_Pack_size call; aborting after %d errors\n",
- errs);
- }
- MTestPrintError( err );
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "error in MPI_Pack_size call; aborting after %d errors\n", errs);
+ }
+ MTestPrintError(err);
+ return errs;
}
packbuf = (char *) malloc(pack_size);
if (packbuf == NULL) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in malloc call; aborting after %d errors\n",
- errs);
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "error in malloc call; aborting after %d errors\n", errs);
+ }
+ return errs;
}
/* FIXME: the pack size returned need not be the type_size - this will
- only be true if the pack routine simply moves the bytes but does
- no other transformations of the data */
+ * only be true if the pack routine simply moves the bytes but does
+ * no other transformations of the data */
position = 0;
- err = MPI_Pack(typebuf,
- count,
- datatype,
- packbuf,
- type_size,
- &position,
- MPI_COMM_SELF);
+ err = MPI_Pack(typebuf, count, datatype, packbuf, type_size, &position, MPI_COMM_SELF);
if (position != type_size) {
- errs++;
- if (verbose) fprintf(stderr, "position = %d; should be %d (pack)\n",
- position, type_size);
+ errs++;
+ if (verbose)
+ fprintf(stderr, "position = %d; should be %d (pack)\n", position, type_size);
}
memset(typebuf, 0, typebufsz);
position = 0;
- err = MPI_Unpack(packbuf,
- type_size,
- &position,
- typebuf,
- count,
- datatype,
- MPI_COMM_SELF);
+ err = MPI_Unpack(packbuf, type_size, &position, typebuf, count, datatype, MPI_COMM_SELF);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in MPI_Unpack call; aborting after %d errors\n",
- errs);
- }
- MTestPrintError( err );
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "error in MPI_Unpack call; aborting after %d errors\n", errs);
+ }
+ MTestPrintError(err);
+ return errs;
}
free(packbuf);
if (position != type_size) {
- errs++;
- if (verbose) fprintf(stderr, "position = %d; should be %d (unpack)\n",
- position, type_size);
+ errs++;
+ if (verbose)
+ fprintf(stderr, "position = %d; should be %d (unpack)\n", position, type_size);
}
return errs;
@@ -342,18 +312,18 @@ static int pack_and_unpack(char *typebuf,
static int parse_args(int argc, char **argv)
{
/*
- int ret;
-
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
- }
- */
+ * int ret;
+ *
+ * while ((ret = getopt(argc, argv, "v")) >= 0)
+ * {
+ * switch (ret) {
+ * case 'v':
+ * verbose = 1;
+ * break;
+ * }
+ * }
+ */
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
return 0;
}
diff --git a/test/mpi/datatype/dataalign.c b/test/mpi/datatype/dataalign.c
index b152c80..9539b95 100644
--- a/test/mpi/datatype/dataalign.c
+++ b/test/mpi/datatype/dataalign.c
@@ -9,97 +9,96 @@
#include <ctype.h>
#include "mpitest.h"
-int main( int argc, char *argv[])
+int main(int argc, char *argv[])
{
- struct a { int i;
- char c;
- } s[10], s1[10];
- int j;
- int errs = 0;
- int rank, size, tsize;
- MPI_Aint text;
- int blens[2];
- MPI_Aint disps[2];
- MPI_Datatype bases[2];
- MPI_Datatype str, con;
- MPI_Status status;
+ struct a {
+ int i;
+ char c;
+ } s[10], s1[10];
+ int j;
+ int errs = 0;
+ int rank, size, tsize;
+ MPI_Aint text;
+ int blens[2];
+ MPI_Aint disps[2];
+ MPI_Datatype bases[2];
+ MPI_Datatype str, con;
+ MPI_Status status;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
- for( j = 0; j < 10; j ++ ) {
- s[j].i = j + rank;
- s[j].c = j + rank + 'a';
- }
+ for (j = 0; j < 10; j++) {
+ s[j].i = j + rank;
+ s[j].c = j + rank + 'a';
+ }
- blens[0] = blens[1] = 1;
- disps[0] = 0; disps[1] = sizeof(int);
- bases[0] = MPI_INT; bases[1] = MPI_CHAR;
- MPI_Type_struct( 2, blens, disps, bases, &str );
- MPI_Type_commit( &str );
- MPI_Type_contiguous( 10, str, &con );
- MPI_Type_commit( &con );
- MPI_Type_size( con, &tsize );
- MPI_Type_extent( con, &text );
+ blens[0] = blens[1] = 1;
+ disps[0] = 0;
+ disps[1] = sizeof(int);
+ bases[0] = MPI_INT;
+ bases[1] = MPI_CHAR;
+ MPI_Type_struct(2, blens, disps, bases, &str);
+ MPI_Type_commit(&str);
+ MPI_Type_contiguous(10, str, &con);
+ MPI_Type_commit(&con);
+ MPI_Type_size(con, &tsize);
+ MPI_Type_extent(con, &text);
- MTestPrintfMsg( 0, "Size of MPI array is %d, extent is %d\n",
- tsize, text );
+ MTestPrintfMsg(0, "Size of MPI array is %d, extent is %d\n", tsize, text);
- /* The following block of code is only for verbose-level output */
- {
- void * p1, *p2;
- p1 = s;
- p2 = &(s[10].i); /* This statement may fail on some systems */
- MTestPrintfMsg( 0,
- "C array starts at %p and ends at %p for a length of %d\n",
- s, &(s[9].c), (char *)p2-(char *)p1 );
- }
+ /* The following block of code is only for verbose-level output */
+ {
+ void *p1, *p2;
+ p1 = s;
+ p2 = &(s[10].i); /* This statement may fail on some systems */
+ MTestPrintfMsg(0,
+ "C array starts at %p and ends at %p for a length of %d\n",
+ s, &(s[9].c), (char *) p2 - (char *) p1);
+ }
- MPI_Type_extent( str, &text );
- MPI_Type_size( str, &tsize );
- MTestPrintfMsg( 0, "Size of MPI struct is %d, extent is %d\n",
- tsize, (int)text );
- MTestPrintfMsg( 0, "Size of C struct is %d\n", sizeof(struct a) );
- if (text != sizeof(struct a)) {
- fprintf( stderr,
- "Extent of struct a (%d) does not match sizeof (%d)\n",
- (int)text, (int)sizeof(struct a) );
- errs++;
- }
+ MPI_Type_extent(str, &text);
+ MPI_Type_size(str, &tsize);
+ MTestPrintfMsg(0, "Size of MPI struct is %d, extent is %d\n", tsize, (int) text);
+ MTestPrintfMsg(0, "Size of C struct is %d\n", sizeof(struct a));
+ if (text != sizeof(struct a)) {
+ fprintf(stderr,
+ "Extent of struct a (%d) does not match sizeof (%d)\n",
+ (int) text, (int) sizeof(struct a));
+ errs++;
+ }
- MPI_Send( s, 1, con, rank ^ 1, 0, MPI_COMM_WORLD );
- MPI_Recv( s1, 1, con, rank ^ 1, 0, MPI_COMM_WORLD, &status );
+ MPI_Send(s, 1, con, rank ^ 1, 0, MPI_COMM_WORLD);
+ MPI_Recv(s1, 1, con, rank ^ 1, 0, MPI_COMM_WORLD, &status);
- for( j = 0; j < 10; j++ ) {
- MTestPrintfMsg( 0, "%d Sent: %d %c, Got: %d %c\n", rank,
- s[j].i, s[j].c, s1[j].i, s1[j].c );
- if ( s1[j].i != j + status.MPI_SOURCE ) {
- errs++;
- fprintf( stderr, "Got s[%d].i = %d; expected %d\n", j, s1[j].i,
- j + status.MPI_SOURCE );
- }
- if ( s1[j].c != 'a' + j + status.MPI_SOURCE ) {
- errs++;
- /* If the character is not a printing character,
- this can generate a file that diff, for example,
- believes is a binary file */
- if (isprint( (int)(s1[j].c) )) {
- fprintf( stderr, "Got s[%d].c = %c; expected %c\n",
- j, s1[j].c, j + status.MPI_SOURCE + 'a');
- }
- else {
- fprintf( stderr, "Got s[%d].c = %x; expected %c\n",
- j, (int)s1[j].c, j + status.MPI_SOURCE + 'a');
- }
- }
- }
+ for (j = 0; j < 10; j++) {
+ MTestPrintfMsg(0, "%d Sent: %d %c, Got: %d %c\n", rank, s[j].i, s[j].c, s1[j].i, s1[j].c);
+ if (s1[j].i != j + status.MPI_SOURCE) {
+ errs++;
+ fprintf(stderr, "Got s[%d].i = %d; expected %d\n", j, s1[j].i, j + status.MPI_SOURCE);
+ }
+ if (s1[j].c != 'a' + j + status.MPI_SOURCE) {
+ errs++;
+ /* If the character is not a printing character,
+ * this can generate a file that diff, for example,
+ * believes is a binary file */
+ if (isprint((int) (s1[j].c))) {
+ fprintf(stderr, "Got s[%d].c = %c; expected %c\n",
+ j, s1[j].c, j + status.MPI_SOURCE + 'a');
+ }
+ else {
+ fprintf(stderr, "Got s[%d].c = %x; expected %c\n",
+ j, (int) s1[j].c, j + status.MPI_SOURCE + 'a');
+ }
+ }
+ }
- MPI_Type_free( &str );
- MPI_Type_free( &con );
+ MPI_Type_free(&str);
+ MPI_Type_free(&con);
- MTest_Finalize( errs );
- MPI_Finalize();
- return 0;
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
}
diff --git a/test/mpi/datatype/gaddress.c b/test/mpi/datatype/gaddress.c
index dfd91fc..31edc75 100644
--- a/test/mpi/datatype/gaddress.c
+++ b/test/mpi/datatype/gaddress.c
@@ -12,23 +12,23 @@
static char MTEST_Descrip[] = "";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int buf[10];
MPI_Aint a1, a2;
- MTest_Init( &argc, &argv );
-
- MPI_Get_address( &buf[0], &a1 );
- MPI_Get_address( &buf[1], &a2 );
-
- if ((int)(a2-a1) != sizeof(int)) {
- errs++;
- printf( "Get address of two address did not return values the correct distance apart\n" );
+ MTest_Init(&argc, &argv);
+
+ MPI_Get_address(&buf[0], &a1);
+ MPI_Get_address(&buf[1], &a2);
+
+ if ((int) (a2 - a1) != sizeof(int)) {
+ errs++;
+ printf("Get address of two address did not return values the correct distance apart\n");
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/datatype/get-elements-pairtype.c b/test/mpi/datatype/get-elements-pairtype.c
index d813b2a..5f44fee 100644
--- a/test/mpi/datatype/get-elements-pairtype.c
+++ b/test/mpi/datatype/get-elements-pairtype.c
@@ -20,25 +20,25 @@ int main(int argc, char **argv)
{
int err, errs = 0;
- MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
+ MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
/* perform some tests */
err = double_int_test();
- if (err && verbose) fprintf(stderr, "%d errors in double_int test.\n",
- err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in double_int test.\n", err);
errs += err;
/* print message and exit */
if (errs) {
- fprintf(stderr, "Found %d errors\n", errs);
+ fprintf(stderr, "Found %d errors\n", errs);
}
else {
- printf(" No Errors\n");
+ printf(" No Errors\n");
}
MPI_Finalize();
return 0;
@@ -52,8 +52,17 @@ int double_int_test(void)
{
int err, errs = 0, count;
- struct { double a; int b; double c; } foo;
- struct { double a; int b; double c; int d; } bar;
+ struct {
+ double a;
+ int b;
+ double c;
+ } foo;
+ struct {
+ double a;
+ int b;
+ double c;
+ int d;
+ } bar;
int blks[3] = { 1, 1, 1 };
MPI_Aint disps[3] = { 0, 0, 0 };
@@ -65,35 +74,33 @@ int double_int_test(void)
/* fill in disps[1..2] with appropriate offset */
disps[1] = (MPI_Aint) ((char *) &foo.b - (char *) &foo.a);
disps[2] = (MPI_Aint) ((char *) &foo.c - (char *) &foo.a);
-
+
MPI_Type_create_struct(3, blks, disps, types, &stype);
MPI_Type_commit(&stype);
err = MPI_Sendrecv((const void *) &foo, 1, stype, 0, 0,
- (void *) &bar, 2, MPI_DOUBLE_INT, 0, 0,
- MPI_COMM_SELF, &recvstatus);
+ (void *) &bar, 2, MPI_DOUBLE_INT, 0, 0, MPI_COMM_SELF, &recvstatus);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, "MPI_Sendrecv returned error (%d)\n",
- err);
- return errs;
+ errs++;
+ if (verbose)
+ fprintf(stderr, "MPI_Sendrecv returned error (%d)\n", err);
+ return errs;
}
err = MPI_Get_elements(&recvstatus, MPI_DOUBLE_INT, &count);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, "MPI_Get_elements returned error (%d)\n",
- err);
+ errs++;
+ if (verbose)
+ fprintf(stderr, "MPI_Get_elements returned error (%d)\n", err);
}
if (count != 3) {
- errs++;
- if (verbose) fprintf(stderr,
- "MPI_Get_elements returned count of %d, should be 3\n",
- count);
+ errs++;
+ if (verbose)
+ fprintf(stderr, "MPI_Get_elements returned count of %d, should be 3\n", count);
}
- MPI_Type_free( &stype );
+ MPI_Type_free(&stype);
return errs;
}
@@ -101,6 +108,6 @@ int double_int_test(void)
int parse_args(int argc, char **argv)
{
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
return 0;
}
diff --git a/test/mpi/datatype/get-elements.c b/test/mpi/datatype/get-elements.c
index 2809a3d..add7289 100644
--- a/test/mpi/datatype/get-elements.c
+++ b/test/mpi/datatype/get-elements.c
@@ -36,15 +36,15 @@ int main(int argc, char **argv)
* (B) a type that has an odd number of ints in its "type contents" (1 in
* this case)
* This triggers a specific bug in some versions of MPICH. */
- blens[0] = 1;
+ blens[0] = 1;
displs[0] = offsetof(struct test_struct, a);
- types[0] = MPI_CHAR;
- blens[1] = 1;
+ types[0] = MPI_CHAR;
+ blens[1] = 1;
displs[1] = offsetof(struct test_struct, b);
- types[1] = MPI_SHORT;
- blens[2] = 1;
+ types[1] = MPI_SHORT;
+ blens[2] = 1;
displs[2] = offsetof(struct test_struct, c);
- types[2] = MPI_INT;
+ types[2] = MPI_INT;
MPI_Type_create_struct(3, blens, displs, types, &struct_type);
MPI_Type_contiguous(1, struct_type, &contig);
MPI_Type_commit(&struct_type);
@@ -58,9 +58,7 @@ int main(int argc, char **argv)
recvbuf.c = -1;
/* send to ourself */
- MPI_Sendrecv(&sendbuf, 1, contig, 0, 0,
- &recvbuf, 1, contig, 0, 0,
- MPI_COMM_SELF, &status);
+ MPI_Sendrecv(&sendbuf, 1, contig, 0, 0, &recvbuf, 1, contig, 0, 0, MPI_COMM_SELF, &status);
/* sanity */
assert(sendbuf.a == recvbuf.a);
@@ -86,4 +84,3 @@ int main(int argc, char **argv)
MPI_Finalize();
return 0;
}
-
diff --git a/test/mpi/datatype/getpartelm.c b/test/mpi/datatype/getpartelm.c
index 49ba725..8f7000f 100644
--- a/test/mpi/datatype/getpartelm.c
+++ b/test/mpi/datatype/getpartelm.c
@@ -13,111 +13,108 @@ static char MTest_descrip[] = "Receive partial datatypes and check that\
MPI_Getelements gives the correct version";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
MPI_Datatype outtype, oldtypes[2];
- MPI_Aint offsets[2];
- int blklens[2];
- MPI_Comm comm;
- int size, rank, src, dest, tag;
+ MPI_Aint offsets[2];
+ int blklens[2];
+ MPI_Comm comm;
+ int size, rank, src, dest, tag;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
-
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+
if (size < 2) {
- errs++;
- printf( "This test requires at least 2 processes\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ errs++;
+ printf("This test requires at least 2 processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
-
- src = 0;
+
+ src = 0;
dest = 1;
if (rank == src) {
- int buf[128], position, cnt;
- /* sender */
-
- /* Create a datatype and send it (multiple of sizeof(int)) */
- /* Create a send struct type */
- oldtypes[0] = MPI_INT;
- oldtypes[1] = MPI_CHAR;
- blklens[0] = 1;
- blklens[1] = 4*sizeof(int);
- offsets[0] = 0;
- offsets[1] = sizeof(int);
- MPI_Type_struct( 2, blklens, offsets, oldtypes, &outtype );
- MPI_Type_commit( &outtype );
-
- buf[0] = 4*sizeof(int);
- /* printf( "About to send to %d\n", dest ); */
- MPI_Send( buf, 1, outtype, dest, 0, comm );
- MPI_Type_free( &outtype );
-
- /* Create a datatype and send it (not a multiple of sizeof(int)) */
- /* Create a send struct type */
- oldtypes[0] = MPI_INT;
- oldtypes[1] = MPI_CHAR;
- blklens[0] = 1;
- blklens[1] = 4*sizeof(int)+1;
- offsets[0] = 0;
- offsets[1] = sizeof(int);
- MPI_Type_struct( 2, blklens, offsets, oldtypes, &outtype );
- MPI_Type_commit( &outtype );
-
- buf[0] = 4*sizeof(int) + 1;
- MPI_Send( buf, 1, outtype, dest, 1, comm );
- MPI_Type_free( &outtype );
-
- /* Pack data and send as packed */
- position = 0;
- cnt = 7;
- MPI_Pack( &cnt, 1, MPI_INT,
- buf, 128*sizeof(int), &position, comm );
- MPI_Pack( (void*)"message", 7, MPI_CHAR,
- buf, 128*sizeof(int), &position, comm );
- MPI_Send( buf, position, MPI_PACKED, dest, 2, comm );
+ int buf[128], position, cnt;
+ /* sender */
+
+ /* Create a datatype and send it (multiple of sizeof(int)) */
+ /* Create a send struct type */
+ oldtypes[0] = MPI_INT;
+ oldtypes[1] = MPI_CHAR;
+ blklens[0] = 1;
+ blklens[1] = 4 * sizeof(int);
+ offsets[0] = 0;
+ offsets[1] = sizeof(int);
+ MPI_Type_struct(2, blklens, offsets, oldtypes, &outtype);
+ MPI_Type_commit(&outtype);
+
+ buf[0] = 4 * sizeof(int);
+ /* printf("About to send to %d\n", dest); */
+ MPI_Send(buf, 1, outtype, dest, 0, comm);
+ MPI_Type_free(&outtype);
+
+ /* Create a datatype and send it (not a multiple of sizeof(int)) */
+ /* Create a send struct type */
+ oldtypes[0] = MPI_INT;
+ oldtypes[1] = MPI_CHAR;
+ blklens[0] = 1;
+ blklens[1] = 4 * sizeof(int) + 1;
+ offsets[0] = 0;
+ offsets[1] = sizeof(int);
+ MPI_Type_struct(2, blklens, offsets, oldtypes, &outtype);
+ MPI_Type_commit(&outtype);
+
+ buf[0] = 4 * sizeof(int) + 1;
+ MPI_Send(buf, 1, outtype, dest, 1, comm);
+ MPI_Type_free(&outtype);
+
+ /* Pack data and send as packed */
+ position = 0;
+ cnt = 7;
+ MPI_Pack(&cnt, 1, MPI_INT, buf, 128 * sizeof(int), &position, comm);
+ MPI_Pack((void *) "message", 7, MPI_CHAR, buf, 128 * sizeof(int), &position, comm);
+ MPI_Send(buf, position, MPI_PACKED, dest, 2, comm);
}
else if (rank == dest) {
- MPI_Status status;
- int buf[128], i, elms, count;
-
- /* Receiver */
- /* Create a receive struct type */
- oldtypes[0] = MPI_INT;
- oldtypes[1] = MPI_CHAR;
- blklens[0] = 1;
- blklens[1] = 256;
- offsets[0] = 0;
- offsets[1] = sizeof(int);
- MPI_Type_struct( 2, blklens, offsets, oldtypes, &outtype );
- MPI_Type_commit( &outtype );
-
- for (i=0; i<3; i++) {
- tag = i;
- /* printf( "about to receive tag %d from %d\n", i, src ); */
- MPI_Recv( buf, 1, outtype, src, tag, comm, &status );
- MPI_Get_elements( &status, outtype, &elms );
- if (elms != buf[0] + 1) {
- errs++;
- printf( "For test %d, Get elements gave %d but should be %d\n",
- i, elms, buf[0] + 1 );
- }
- MPI_Get_count( &status, outtype, &count );
- if (count != MPI_UNDEFINED) {
- errs++;
- printf( "For partial send, Get_count did not return MPI_UNDEFINED\n" );
- }
- }
- MPI_Type_free( &outtype );
+ MPI_Status status;
+ int buf[128], i, elms, count;
+
+ /* Receiver */
+ /* Create a receive struct type */
+ oldtypes[0] = MPI_INT;
+ oldtypes[1] = MPI_CHAR;
+ blklens[0] = 1;
+ blklens[1] = 256;
+ offsets[0] = 0;
+ offsets[1] = sizeof(int);
+ MPI_Type_struct(2, blklens, offsets, oldtypes, &outtype);
+ MPI_Type_commit(&outtype);
+
+ for (i = 0; i < 3; i++) {
+ tag = i;
+ /* printf("about to receive tag %d from %d\n", i, src); */
+ MPI_Recv(buf, 1, outtype, src, tag, comm, &status);
+ MPI_Get_elements(&status, outtype, &elms);
+ if (elms != buf[0] + 1) {
+ errs++;
+ printf("For test %d, Get elements gave %d but should be %d\n", i, elms, buf[0] + 1);
+ }
+ MPI_Get_count(&status, outtype, &count);
+ if (count != MPI_UNDEFINED) {
+ errs++;
+ printf("For partial send, Get_count did not return MPI_UNDEFINED\n");
+ }
+ }
+ MPI_Type_free(&outtype);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/datatype/hindexed-zeros.c b/test/mpi/datatype/hindexed-zeros.c
index eac1b2a..90a4cd0 100644
--- a/test/mpi/datatype/hindexed-zeros.c
+++ b/test/mpi/datatype/hindexed-zeros.c
@@ -17,7 +17,7 @@ int hindexed_zerotype_test(void);
int hindexed_sparsetype_test(void);
struct test_struct_1 {
- int a,b,c,d;
+ int a, b, c, d;
};
int main(int argc, char *argv[])
@@ -29,23 +29,25 @@ int main(int argc, char *argv[])
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
err = hindexed_zerotype_test();
- if (verbose && err) fprintf(stderr, "error in hindexed_zerotype_test\n");
+ if (verbose && err)
+ fprintf(stderr, "error in hindexed_zerotype_test\n");
errs += err;
err = hindexed_sparsetype_test();
- if (verbose && err) fprintf(stderr, "error in hindexed_sparsetype_test\n");
+ if (verbose && err)
+ fprintf(stderr, "error in hindexed_sparsetype_test\n");
errs += err;
/* print message and exit */
if (errs) {
- fprintf(stderr, "Found %d errors\n", errs);
+ fprintf(stderr, "Found %d errors\n", errs);
}
else {
- printf(" No Errors\n");
+ printf(" No Errors\n");
}
MPI_Finalize();
return 0;
@@ -60,70 +62,70 @@ int hindexed_zerotype_test(void)
MPI_Request request;
MPI_Status status;
- int blks[] = { 0, 0, 0 };
+ int blks[] = { 0, 0, 0 };
MPI_Aint disps[] = { 0, 4, 16 };
err = MPI_Type_hindexed(3, blks, disps, MPI_INT, &mytype);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Type_hindexed returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Type_hindexed returned error\n");
+ }
}
MPI_Type_commit(&mytype);
err = MPI_Irecv(NULL, 2, mytype, 0, 0, MPI_COMM_SELF, &request);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Irecv returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Irecv returned error\n");
+ }
}
err = MPI_Send(NULL, 1, mytype, 0, 0, MPI_COMM_SELF);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Send returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Send returned error\n");
+ }
}
err = MPI_Wait(&request, &status);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Wait returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Wait returned error\n");
+ }
}
/* verify count and elements */
err = MPI_Get_count(&status, mytype, &count);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Get_count returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Get_count returned error\n");
+ }
}
if (count != 0) {
- errs++;
- if (verbose) {
- fprintf(stderr, "count = %d; should be 0\n", count);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "count = %d; should be 0\n", count);
+ }
}
err = MPI_Get_elements(&status, mytype, &elements);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Get_elements returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Get_elements returned error\n");
+ }
}
if (elements != 0) {
- errs++;
- if (verbose) {
- fprintf(stderr, "elements = %d; should be 0\n", elements);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "elements = %d; should be 0\n", elements);
+ }
}
MPI_Type_free(&mytype);
@@ -143,89 +145,89 @@ int hindexed_sparsetype_test(void)
MPI_Request request;
MPI_Status status;
- int sendbuf[6] = { 1, 2, 3, 4, 5, 6 };
+ int sendbuf[6] = { 1, 2, 3, 4, 5, 6 };
int recvbuf[16];
int correct[16] = { 1, -2, 4, -4, 2, 3, 5, -8, -9, -10, 6,
- -12, -13, -14, -15, -16 };
+ -12, -13, -14, -15, -16
+ };
- int blks[] = { 1, 0, 2, 1 };
- MPI_Aint disps[] = { 0, 1*sizeof(int), 4*sizeof(int), 2*sizeof(int) };
+ int blks[] = { 1, 0, 2, 1 };
+ MPI_Aint disps[] = { 0, 1 * sizeof(int), 4 * sizeof(int), 2 * sizeof(int) };
err = MPI_Type_hindexed(4, blks, disps, MPI_INT, &mytype);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Type_hindexed returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Type_hindexed returned error\n");
+ }
}
MPI_Type_commit(&mytype);
- for (i=0; i < 16; i++) recvbuf[i] = -(i+1);
+ for (i = 0; i < 16; i++)
+ recvbuf[i] = -(i + 1);
err = MPI_Irecv(recvbuf, 2, mytype, 0, 0, MPI_COMM_SELF, &request);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Irecv returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Irecv returned error\n");
+ }
}
err = MPI_Send(sendbuf, 6, MPI_INT, 0, 0, MPI_COMM_SELF);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Send returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Send returned error\n");
+ }
}
err = MPI_Wait(&request, &status);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Wait returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Wait returned error\n");
+ }
}
-
+
/* verify data */
- for (i=0; i < 16; i++) {
- if (recvbuf[i] != correct[i]) {
- errs++;
- if (verbose) {
- fprintf(stderr, "recvbuf[%d] = %d; should be %d\n",
- i, recvbuf[i], correct[i]);
- }
- }
+ for (i = 0; i < 16; i++) {
+ if (recvbuf[i] != correct[i]) {
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "recvbuf[%d] = %d; should be %d\n", i, recvbuf[i], correct[i]);
+ }
+ }
}
/* verify count and elements */
err = MPI_Get_count(&status, mytype, &count);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Get_count returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Get_count returned error\n");
+ }
}
if (count != MPI_UNDEFINED) {
- errs++;
- if (verbose) {
- fprintf(stderr, "count = %d; should be MPI_UNDEFINED (%d)\n",
- count, MPI_UNDEFINED);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "count = %d; should be MPI_UNDEFINED (%d)\n", count, MPI_UNDEFINED);
+ }
}
err = MPI_Get_elements(&status, mytype, &elements);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Get_elements returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Get_elements returned error\n");
+ }
}
if (elements != 6) {
- errs++;
- if (verbose) {
- fprintf(stderr, "elements = %d; should be 6\n", elements);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "elements = %d; should be 6\n", elements);
+ }
}
MPI_Type_free(&mytype);
@@ -237,18 +239,18 @@ int hindexed_sparsetype_test(void)
int parse_args(int argc, char **argv)
{
/*
- int ret;
-
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
- }
- */
+ * int ret;
+ *
+ * while ((ret = getopt(argc, argv, "v")) >= 0)
+ * {
+ * switch (ret) {
+ * case 'v':
+ * verbose = 1;
+ * break;
+ * }
+ * }
+ */
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
return 0;
}
diff --git a/test/mpi/datatype/hindexed_block.c b/test/mpi/datatype/hindexed_block.c
index da3fccd..5f00009 100644
--- a/test/mpi/datatype/hindexed_block.c
+++ b/test/mpi/datatype/hindexed_block.c
@@ -49,7 +49,7 @@ int main(int argc, char **argv)
if (err && verbose)
fprintf(stderr, "%d errors in hindexed_block vector test.\n", err);
errs += err;
-#endif /*defined(TEST_HINDEXED_BLOCK)*/
+#endif /*defined(TEST_HINDEXED_BLOCK) */
/* print message and exit */
if (rank == 0) {
@@ -170,19 +170,19 @@ int hindexed_block_vector_test(void)
#define NELT (18)
int buf[NELT] = {
-1, -1, -1,
- 1, -2, 2,
+ 1, -2, 2,
-3, -3, -3,
-4, -4, -4,
- 3, -5, 4,
- 5, -6, 6
+ 3, -5, 4,
+ 5, -6, 6
};
int expected[NELT] = {
- 0, 0, 0,
- 1, 0, 2,
- 0, 0, 0,
- 0, 0, 0,
- 3, 0, 4,
- 5, 0, 6
+ 0, 0, 0,
+ 1, 0, 2,
+ 0, 0, 0,
+ 0, 0, 0,
+ 3, 0, 4,
+ 5, 0, 6
};
int err, errs = 0;
@@ -211,8 +211,7 @@ int hindexed_block_vector_test(void)
err = MPI_Type_create_hindexed_block(count, 1, disp, vectype, &newtype);
if (err != MPI_SUCCESS) {
if (verbose) {
- fprintf(stderr,
- "error creating hindexed_block type in hindexed_block_contig_test()\n");
+ fprintf(stderr, "error creating hindexed_block type in hindexed_block_contig_test()\n");
}
errs++;
}
@@ -344,4 +343,4 @@ int parse_args(int argc, char **argv)
verbose = 1;
return 0;
}
-#endif /*defined(TEST_HINDEXED_BLOCK)*/
+#endif /*defined(TEST_HINDEXED_BLOCK) */
diff --git a/test/mpi/datatype/hindexed_block_contents.c b/test/mpi/datatype/hindexed_block_contents.c
index e316c70..c5d0483 100644
--- a/test/mpi/datatype/hindexed_block_contents.c
+++ b/test/mpi/datatype/hindexed_block_contents.c
@@ -31,15 +31,13 @@ int main(int argc, char **argv)
MPI_Datatype t;
int count = 4;
int blocklength = 2;
- MPI_Aint displacements[] = {0, 8, 16, 24};
+ MPI_Aint displacements[] = { 0, 8, 16, 24 };
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (!rank) {
- MPI_Type_create_hindexed_block(count, blocklength,
- displacements, MPI_INT,
- &t);
+ MPI_Type_create_hindexed_block(count, blocklength, displacements, MPI_INT, &t);
MPI_Type_commit(&t);
{
int ni, na, nd, combiner;
@@ -55,7 +53,7 @@ int main(int argc, char **argv)
check(i[1] == 2);
check(na == 4);
- for (k=0; k < na; k++)
+ for (k = 0; k < na; k++)
check(a[k] == (k * 8));
check(nd == 1);
diff --git a/test/mpi/datatype/hvecblklen.c b/test/mpi/datatype/hvecblklen.c
index d9a6aa5..2734885 100644
--- a/test/mpi/datatype/hvecblklen.c
+++ b/test/mpi/datatype/hvecblklen.c
@@ -12,79 +12,77 @@
/* Inspired by the Intel MPI_Type_hvector_blklen test.
Added to include a test of a dataloop optimization that failed.
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Datatype ot, ot2, newtype;
int position, psize, insize, outsize;
- signed char *inbuf=0, *outbuf=0, *pbuf=0, *p;
- int i, j, k;
- int errs = 0;
- int veccount=16, stride=16;
+ signed char *inbuf = 0, *outbuf = 0, *pbuf = 0, *p;
+ int i, j, k;
+ int errs = 0;
+ int veccount = 16, stride = 16;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
/*
* Create a type with some padding
*/
- MPI_Type_contiguous( 59, MPI_CHAR, &ot );
- MPI_Type_create_resized( ot, 0, 64, &ot2 );
+ MPI_Type_contiguous(59, MPI_CHAR, &ot);
+ MPI_Type_create_resized(ot, 0, 64, &ot2);
/*
- Use a vector type with a block size equal to the stride - thus
- tiling the target memory with copies of old type. This is not
- a contiguous copy since oldtype has a gap at the end.
- */
- MPI_Type_hvector( veccount, stride, stride*64, ot2, &newtype );
- MPI_Type_commit( &newtype );
+ * Use a vector type with a block size equal to the stride - thus
+ * tiling the target memory with copies of old type. This is not
+ * a contiguous copy since oldtype has a gap at the end.
+ */
+ MPI_Type_hvector(veccount, stride, stride * 64, ot2, &newtype);
+ MPI_Type_commit(&newtype);
insize = veccount * stride * 64;
outsize = insize;
- inbuf = (char *)malloc( insize );
- outbuf = (char *)malloc( outsize );
- for (i=0; i<outsize; i++) {
+ inbuf = (char *) malloc(insize);
+ outbuf = (char *) malloc(outsize);
+ for (i = 0; i < outsize; i++) {
inbuf[i] = i % 64;
outbuf[i] = -1;
}
- MPI_Pack_size( 1, newtype, MPI_COMM_WORLD, &psize );
- pbuf = (char *)malloc( psize );
+ MPI_Pack_size(1, newtype, MPI_COMM_WORLD, &psize);
+ pbuf = (char *) malloc(psize);
position = 0;
- MPI_Pack( inbuf, 1, newtype, pbuf, psize, &position, MPI_COMM_WORLD );
- psize = position;
+ MPI_Pack(inbuf, 1, newtype, pbuf, psize, &position, MPI_COMM_WORLD);
+ psize = position;
position = 0;
- MPI_Unpack( pbuf, psize, &position, outbuf, 1, newtype, MPI_COMM_WORLD );
+ MPI_Unpack(pbuf, psize, &position, outbuf, 1, newtype, MPI_COMM_WORLD);
/* Check the output */
p = outbuf;
- for (i=0; i<veccount; i++) {
- for (j=0; j<stride; j++) {
- for (k=0; k<59; k++) {
+ for (i = 0; i < veccount; i++) {
+ for (j = 0; j < stride; j++) {
+ for (k = 0; k < 59; k++) {
if (*p != k % 64) {
errs++;
- fprintf( stderr, "[%d,%d,%d]expected %d but saw %d\n",
- i, j, k, (k%64), *p );
+ fprintf(stderr, "[%d,%d,%d]expected %d but saw %d\n", i, j, k, (k % 64), *p);
}
p++;
}
- for (k=59; k<64; k++) {
+ for (k = 59; k < 64; k++) {
if (*p != -1) {
errs++;
- fprintf( stderr, "[%d,%d,%d]expected -1 but saw %d\n",
- i, j, k, *p );
+ fprintf(stderr, "[%d,%d,%d]expected -1 but saw %d\n", i, j, k, *p);
}
p++;
}
}
}
- free( pbuf );
- free( inbuf );
- free( outbuf );
+ free(pbuf);
+ free(inbuf);
+ free(outbuf);
- MPI_Type_free( &ot );
- MPI_Type_free( &ot2 );
- MPI_Type_free( &newtype );
- MTest_Finalize( errs );
+ MPI_Type_free(&ot);
+ MPI_Type_free(&ot2);
+ MPI_Type_free(&newtype);
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
diff --git a/test/mpi/datatype/indexed-misc.c b/test/mpi/datatype/indexed-misc.c
index bab12d0..4f8954e 100644
--- a/test/mpi/datatype/indexed-misc.c
+++ b/test/mpi/datatype/indexed-misc.c
@@ -45,65 +45,56 @@ int indexed_same_lengths(void);
/* helper functions */
int parse_args(int argc, char **argv);
-static int pack_and_unpack(char *typebuf,
- int count,
- MPI_Datatype datatype,
- int typebufsz);
+static int pack_and_unpack(char *typebuf, int count, MPI_Datatype datatype, int typebufsz);
int main(int argc, char **argv)
{
int err, errs = 0;
- MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
+ MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
/* perform some tests */
err = indexed_contig_test();
- if (err && verbose) fprintf(stderr,
- "%d errors in indexed_contig_test.\n",
- err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in indexed_contig_test.\n", err);
errs += err;
err = indexed_zeroblock_first_test();
- if (err && verbose) fprintf(stderr,
- "%d errors in indexed_zeroblock_first_test.\n",
- err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in indexed_zeroblock_first_test.\n", err);
errs += err;
err = indexed_zeroblock_middle_test();
- if (err && verbose) fprintf(stderr,
- "%d errors in indexed_zeroblock_middle_test.\n",
- err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in indexed_zeroblock_middle_test.\n", err);
errs += err;
err = indexed_zeroblock_last_test();
- if (err && verbose) fprintf(stderr,
- "%d errors in indexed_zeroblock_last_test.\n",
- err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in indexed_zeroblock_last_test.\n", err);
errs += err;
err = indexed_contig_leading_zero_test();
- if (err && verbose) fprintf(stderr,
- "%d errors in indexed_contig_leading_zero_test.\n",
- err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in indexed_contig_leading_zero_test.\n", err);
errs += err;
err = indexed_same_lengths();
- if (err && verbose) fprintf(stderr,
- "%d errors in indexed_contig_leading_zero_test.\n",
- err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in indexed_contig_leading_zero_test.\n", err);
errs += err;
/* print message and exit */
if (errs) {
- fprintf(stderr, "Found %d errors\n", errs);
+ fprintf(stderr, "Found %d errors\n", errs);
}
else {
- printf(" No Errors\n");
+ printf(" No Errors\n");
}
MPI_Finalize();
return 0;
@@ -114,40 +105,36 @@ int indexed_zeroblock_first_test(void)
int err, errs = 0;
MPI_Datatype type;
- int len[3] = { 0, 1, 1 };
+ int len[3] = { 0, 1, 1 };
int disp[3] = { 0, 1, 4 };
MPI_Aint lb, ub;
err = MPI_Type_indexed(3, len, disp, MPI_INT, &type);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error creating indexed type in indexed_zeroblock_first_test()\n");
- }
- errs += 1;
+ if (verbose) {
+ fprintf(stderr, "error creating indexed type in indexed_zeroblock_first_test()\n");
+ }
+ errs += 1;
}
MPI_Type_lb(type, &lb);
if (lb != sizeof(int)) {
- if (verbose) {
- fprintf(stderr,
- "lb mismatch; is %d, should be %d\n",
- (int) lb, (int) sizeof(int));
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "lb mismatch; is %d, should be %d\n", (int) lb, (int) sizeof(int));
+ }
+ errs++;
}
MPI_Type_ub(type, &ub);
if (ub != 5 * sizeof(int)) {
- if (verbose) {
- fprintf(stderr,
- "ub mismatch; is %d, should be %d\n",
- (int) ub, (int) (5 * sizeof(int)));
- }
- errs++;
- }
-
- MPI_Type_free( &type );
-
+ if (verbose) {
+ fprintf(stderr,
+ "ub mismatch; is %d, should be %d\n", (int) ub, (int) (5 * sizeof(int)));
+ }
+ errs++;
+ }
+
+ MPI_Type_free(&type);
+
return errs;
}
@@ -156,40 +143,36 @@ int indexed_zeroblock_middle_test(void)
int err, errs = 0;
MPI_Datatype type;
- int len[3] = { 1, 0, 1 };
+ int len[3] = { 1, 0, 1 };
int disp[3] = { 1, 2, 4 };
MPI_Aint lb, ub;
err = MPI_Type_indexed(3, len, disp, MPI_INT, &type);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error creating indexed type in indexed_zeroblock_middle_test()\n");
- }
- errs += 1;
+ if (verbose) {
+ fprintf(stderr, "error creating indexed type in indexed_zeroblock_middle_test()\n");
+ }
+ errs += 1;
}
MPI_Type_lb(type, &lb);
if (lb != sizeof(int)) {
- if (verbose) {
- fprintf(stderr,
- "lb mismatch; is %d, should be %d\n",
- (int) lb, (int) sizeof(int));
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "lb mismatch; is %d, should be %d\n", (int) lb, (int) sizeof(int));
+ }
+ errs++;
}
MPI_Type_ub(type, &ub);
if (ub != 5 * sizeof(int)) {
- if (verbose) {
- fprintf(stderr,
- "ub mismatch; is %d, should be %d\n",
- (int) ub, (int) (5 * sizeof(int)));
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr,
+ "ub mismatch; is %d, should be %d\n", (int) ub, (int) (5 * sizeof(int)));
+ }
+ errs++;
}
- MPI_Type_free( &type );
-
+ MPI_Type_free(&type);
+
return errs;
}
@@ -198,40 +181,36 @@ int indexed_zeroblock_last_test(void)
int err, errs = 0;
MPI_Datatype type;
- int len[3] = { 1, 1, 0 };
+ int len[3] = { 1, 1, 0 };
int disp[3] = { 1, 4, 8 };
MPI_Aint lb, ub;
err = MPI_Type_indexed(3, len, disp, MPI_INT, &type);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error creating indexed type in indexed_zeroblock_last_test()\n");
- }
- errs += 1;
+ if (verbose) {
+ fprintf(stderr, "error creating indexed type in indexed_zeroblock_last_test()\n");
+ }
+ errs += 1;
}
MPI_Type_lb(type, &lb);
if (lb != sizeof(int)) {
- if (verbose) {
- fprintf(stderr,
- "lb mismatch; is %d, should be %d\n",
- (int) lb, (int) sizeof(int));
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "lb mismatch; is %d, should be %d\n", (int) lb, (int) sizeof(int));
+ }
+ errs++;
}
MPI_Type_ub(type, &ub);
if (ub != 5 * sizeof(int)) {
- if (verbose) {
- fprintf(stderr,
- "ub mismatch; is %d, should be %d\n",
- (int) ub, (int) (5 * sizeof(int)));
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr,
+ "ub mismatch; is %d, should be %d\n", (int) ub, (int) (5 * sizeof(int)));
+ }
+ errs++;
}
- MPI_Type_free( &type );
-
+ MPI_Type_free(&type);
+
return errs;
}
@@ -244,93 +223,85 @@ int indexed_zeroblock_last_test(void)
*/
int indexed_contig_test(void)
{
- int buf[9] = {-1, 1, 2, 3, -2, 4, 5, -3, 6};
+ int buf[9] = { -1, 1, 2, 3, -2, 4, 5, -3, 6 };
int err, errs = 0;
int i, count = 5;
- int blklen[] = { 1, 2, 1, 1, 1 };
+ int blklen[] = { 1, 2, 1, 1, 1 };
int disp[] = { 1, 2, 5, 6, 8 };
MPI_Datatype newtype;
int size, int_size;
- err = MPI_Type_indexed(count,
- blklen,
- disp,
- MPI_INT,
- &newtype);
+ err = MPI_Type_indexed(count, blklen, disp, MPI_INT, &newtype);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error creating indexed type in indexed_contig_test()\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "error creating indexed type in indexed_contig_test()\n");
+ }
+ errs++;
}
MPI_Type_size(MPI_INT, &int_size);
err = MPI_Type_size(newtype, &size);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error obtaining type size in indexed_contig_test()\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "error obtaining type size in indexed_contig_test()\n");
+ }
+ errs++;
}
-
+
if (size != 6 * int_size) {
- if (verbose) {
- fprintf(stderr,
- "error: size != 6 * int_size in indexed_contig_test()\n");
- }
- errs++;
- }
+ if (verbose) {
+ fprintf(stderr, "error: size != 6 * int_size in indexed_contig_test()\n");
+ }
+ errs++;
+ }
MPI_Type_commit(&newtype);
err = pack_and_unpack((char *) buf, 1, newtype, 9 * sizeof(int));
if (err != 0) {
- if (verbose) {
- fprintf(stderr,
- "error packing/unpacking in indexed_contig_test()\n");
- }
- errs += err;
- }
-
- for (i=0; i < 9; i++) {
- int goodval;
-
- switch(i) {
- case 1:
- goodval = 1;
- break;
- case 2:
- goodval = 2;
- break;
- case 3:
- goodval = 3;
- break;
- case 5:
- goodval = 4;
- break;
- case 6:
- goodval = 5;
- break;
- case 8:
- goodval = 6;
- break;
- default:
- goodval = 0; /* pack_and_unpack() zeros before unpack */
- break;
- }
- if (buf[i] != goodval) {
- errs++;
- if (verbose) fprintf(stderr, "buf[%d] = %d; should be %d\n",
- i, buf[i], goodval);
- }
- }
-
- MPI_Type_free( &newtype );
+ if (verbose) {
+ fprintf(stderr, "error packing/unpacking in indexed_contig_test()\n");
+ }
+ errs += err;
+ }
+
+ for (i = 0; i < 9; i++) {
+ int goodval;
+
+ switch (i) {
+ case 1:
+ goodval = 1;
+ break;
+ case 2:
+ goodval = 2;
+ break;
+ case 3:
+ goodval = 3;
+ break;
+ case 5:
+ goodval = 4;
+ break;
+ case 6:
+ goodval = 5;
+ break;
+ case 8:
+ goodval = 6;
+ break;
+ default:
+ goodval = 0; /* pack_and_unpack() zeros before unpack */
+ break;
+ }
+ if (buf[i] != goodval) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "buf[%d] = %d; should be %d\n", i, buf[i], goodval);
+ }
+ }
+
+ MPI_Type_free(&newtype);
return errs;
}
@@ -346,8 +317,8 @@ int indexed_contig_leading_zero_test(void)
MPI_Datatype type = MPI_DATATYPE_NULL;
MPI_Datatype struct_type = MPI_DATATYPE_NULL;
MPI_Datatype types[2];
- int len[3] = { 0, 4, 0 };
- int disp[3] = { INT_MAX, 2, INT_MAX};
+ int len[3] = { 0, 4, 0 };
+ int disp[3] = { INT_MAX, 2, INT_MAX };
MPI_Aint adisp[3];
MPI_Aint lb, ub;
int *buf = NULL;
@@ -364,7 +335,7 @@ int indexed_contig_leading_zero_test(void)
/* make sure packing/unpacking works (hits a simple "is_contig" case in
* MPICH's pack/unpack routines) */
- buf = malloc(10*sizeof(int));
+ buf = malloc(10 * sizeof(int));
assert(buf != NULL);
for (i = 0; i < 10; ++i) {
buf[i] = i + 1;
@@ -388,7 +359,7 @@ int indexed_contig_leading_zero_test(void)
len[0] = 1;
len[1] = 1;
adisp[0] = 0;
- adisp[1] = 8*sizeof(int);
+ adisp[1] = 8 * sizeof(int);
types[0] = type;
types[1] = MPI_INT;
@@ -399,7 +370,7 @@ int indexed_contig_leading_zero_test(void)
err = MPI_Type_commit(&struct_type);
check_err(err, "committing struct type in indexed_contig_leading_zero_test()");
- buf = malloc(10*sizeof(int));
+ buf = malloc(10 * sizeof(int));
assert(buf != NULL);
for (i = 0; i < 10; ++i) {
buf[i] = i + 1;
@@ -418,7 +389,7 @@ int indexed_contig_leading_zero_test(void)
free(buf);
MPI_Type_free(&struct_type);
- MPI_Type_free( &type );
+ MPI_Type_free(&type);
/* -------------------------------------------------------------------- */
/* now do the same as above, but with hindexed */
@@ -430,16 +401,16 @@ int indexed_contig_leading_zero_test(void)
/* FIXME: This should also look at long, or use a different approach */
#if defined(HAVE_LONG_LONG) && defined(LLONG_MAX)
if (sizeof(MPI_Aint) == sizeof(long long)) {
- adisp[0] = (MPI_Aint)LLONG_MAX;
- adisp[1] = 2*sizeof(int);
- adisp[2] = (MPI_Aint)LLONG_MAX;
+ adisp[0] = (MPI_Aint) LLONG_MAX;
+ adisp[1] = 2 * sizeof(int);
+ adisp[2] = (MPI_Aint) LLONG_MAX;
}
- else
+ else
#endif
{
- adisp[0] = (MPI_Aint)INT_MAX;
- adisp[1] = 2*sizeof(int);
- adisp[2] = (MPI_Aint)INT_MAX;
+ adisp[0] = (MPI_Aint) INT_MAX;
+ adisp[1] = 2 * sizeof(int);
+ adisp[2] = (MPI_Aint) INT_MAX;
}
err = MPI_Type_hindexed(3, len, adisp, MPI_INT, &type);
@@ -453,7 +424,7 @@ int indexed_contig_leading_zero_test(void)
MPI_Type_ub(type, &ub);
check(ub == 6 * sizeof(int));
- buf = malloc(10*sizeof(int));
+ buf = malloc(10 * sizeof(int));
assert(buf != NULL);
for (i = 0; i < 10; ++i) {
buf[i] = i + 1;
@@ -479,7 +450,7 @@ int indexed_contig_leading_zero_test(void)
len[0] = 1;
len[1] = 1;
adisp[0] = 0;
- adisp[1] = 8*sizeof(int);
+ adisp[1] = 8 * sizeof(int);
/* struct layout: xx0123xx4x ('x' indicates a hole), one char is an
* MPI_INT */
@@ -488,7 +459,7 @@ int indexed_contig_leading_zero_test(void)
err = MPI_Type_commit(&struct_type);
check_err(err, "committing struct type in indexed_contig_leading_zero_test()");
- buf = malloc(10*sizeof(int));
+ buf = malloc(10 * sizeof(int));
assert(buf != NULL);
for (i = 0; i < 10; ++i) {
buf[i] = i + 1;
@@ -551,7 +522,7 @@ int indexed_same_lengths(void)
MPI_Type_ub(type, &ub);
check(ub == 9 * sizeof(int));
- buf = malloc(10*sizeof(int));
+ buf = malloc(10 * sizeof(int));
assert(buf != NULL);
for (i = 0; i < 10; ++i) {
buf[i] = i + 1;
@@ -592,7 +563,7 @@ int indexed_same_lengths(void)
MPI_Type_ub(type, &ub);
check(ub == 9 * sizeof(int));
- buf = malloc(10*sizeof(int));
+ buf = malloc(10 * sizeof(int));
assert(buf != NULL);
for (i = 0; i < 10; ++i) {
buf[i] = i + 1;
@@ -629,87 +600,64 @@ int indexed_same_lengths(void)
* between the pack and unpack steps
*
*/
-static int pack_and_unpack(char *typebuf,
- int count,
- MPI_Datatype datatype,
- int typebufsz)
+static int pack_and_unpack(char *typebuf, int count, MPI_Datatype datatype, int typebufsz)
{
char *packbuf;
int err, errs = 0, pack_size, type_size, position;
err = MPI_Type_size(datatype, &type_size);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in MPI_Type_size call; aborting after %d errors\n",
- errs);
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "error in MPI_Type_size call; aborting after %d errors\n", errs);
+ }
+ return errs;
}
type_size *= count;
err = MPI_Pack_size(count, datatype, MPI_COMM_SELF, &pack_size);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in MPI_Pack_size call; aborting after %d errors\n",
- errs);
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "error in MPI_Pack_size call; aborting after %d errors\n", errs);
+ }
+ return errs;
}
packbuf = (char *) malloc(pack_size);
if (packbuf == NULL) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in malloc call; aborting after %d errors\n",
- errs);
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "error in malloc call; aborting after %d errors\n", errs);
+ }
+ return errs;
}
position = 0;
- err = MPI_Pack(typebuf,
- count,
- datatype,
- packbuf,
- type_size,
- &position,
- MPI_COMM_SELF);
+ err = MPI_Pack(typebuf, count, datatype, packbuf, type_size, &position, MPI_COMM_SELF);
if (position != type_size) {
- errs++;
- if (verbose) fprintf(stderr, "position = %d; should be %d (pack)\n",
- position, type_size);
+ errs++;
+ if (verbose)
+ fprintf(stderr, "position = %d; should be %d (pack)\n", position, type_size);
}
memset(typebuf, 0, typebufsz);
position = 0;
- err = MPI_Unpack(packbuf,
- type_size,
- &position,
- typebuf,
- count,
- datatype,
- MPI_COMM_SELF);
+ err = MPI_Unpack(packbuf, type_size, &position, typebuf, count, datatype, MPI_COMM_SELF);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in MPI_Unpack call; aborting after %d errors\n",
- errs);
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "error in MPI_Unpack call; aborting after %d errors\n", errs);
+ }
+ return errs;
}
free(packbuf);
if (position != type_size) {
- errs++;
- if (verbose) fprintf(stderr, "position = %d; should be %d (unpack)\n",
- position, type_size);
+ errs++;
+ if (verbose)
+ fprintf(stderr, "position = %d; should be %d (unpack)\n", position, type_size);
}
return errs;
@@ -718,19 +666,18 @@ static int pack_and_unpack(char *typebuf,
int parse_args(int argc, char **argv)
{
/*
- int ret;
-
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
- }
- */
+ * int ret;
+ *
+ * while ((ret = getopt(argc, argv, "v")) >= 0)
+ * {
+ * switch (ret) {
+ * case 'v':
+ * verbose = 1;
+ * break;
+ * }
+ * }
+ */
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
return 0;
}
-
diff --git a/test/mpi/datatype/large-count.c b/test/mpi/datatype/large-count.c
index fd316d6..da733fc 100644
--- a/test/mpi/datatype/large-count.c
+++ b/test/mpi/datatype/large-count.c
@@ -66,38 +66,38 @@ int main(int argc, char *argv[])
MPI_Type_commit(&four_ints);
/* a type with size>INT_MAX */
- MPI_Type_vector(INT_MAX/2, 1, 3, four_ints, &imx4i);
+ MPI_Type_vector(INT_MAX / 2, 1, 3, four_ints, &imx4i);
MPI_Type_commit(&imx4i);
/* don't forget, ub for dtype w/ stride doesn't include any holes at the end
* of the type, hence the more complicated calculation below */
- imx4i_true_extent = 3LL*4LL*sizeof(int)*((INT_MAX/2)-1) + 4LL*sizeof(int);
+ imx4i_true_extent = 3LL * 4LL * sizeof(int) * ((INT_MAX / 2) - 1) + 4LL * sizeof(int);
/* sanity check that the MPI_COUNT predefined named datatype exists */
MPI_Send(&imx4i_true_extent, 1, MPI_COUNT, MPI_PROC_NULL, 0, MPI_COMM_SELF);
/* the same oversized type but with goofy extents */
- MPI_Type_create_resized(imx4i, /*lb=*/INT_MAX, /*extent=*/-1024, &imx4i_rsz);
+ MPI_Type_create_resized(imx4i, /*lb= */ INT_MAX, /*extent= */ -1024, &imx4i_rsz);
MPI_Type_commit(&imx4i_rsz);
/* MPI_Type_size */
MPI_Type_size(imax_contig, &size);
check(size == INT_MAX);
MPI_Type_size(four_ints, &size);
- check(size == 4*sizeof(int));
+ check(size == 4 * sizeof(int));
MPI_Type_size(imx4i, &size);
- check(size == MPI_UNDEFINED); /* should overflow an int */
+ check(size == MPI_UNDEFINED); /* should overflow an int */
MPI_Type_size(imx4i_rsz, &size);
- check(size == MPI_UNDEFINED); /* should overflow an int */
+ check(size == MPI_UNDEFINED); /* should overflow an int */
/* MPI_Type_size_x */
MPI_Type_size_x(imax_contig, &size_x);
check(size_x == INT_MAX);
MPI_Type_size_x(four_ints, &size_x);
- check(size_x == 4*sizeof(int));
+ check(size_x == 4 * sizeof(int));
MPI_Type_size_x(imx4i, &size_x);
- check(size_x == 4LL*sizeof(int)*(INT_MAX/2)); /* should overflow an int */
+ check(size_x == 4LL * sizeof(int) * (INT_MAX / 2)); /* should overflow an int */
MPI_Type_size_x(imx4i_rsz, &size_x);
- check(size_x == 4LL*sizeof(int)*(INT_MAX/2)); /* should overflow an int */
+ check(size_x == 4LL * sizeof(int) * (INT_MAX / 2)); /* should overflow an int */
/* MPI_Type_get_extent */
MPI_Type_get_extent(imax_contig, &lb, &extent);
@@ -105,7 +105,7 @@ int main(int argc, char *argv[])
check(extent == INT_MAX);
MPI_Type_get_extent(four_ints, &lb, &extent);
check(lb == 0);
- check(extent == 4*sizeof(int));
+ check(extent == 4 * sizeof(int));
MPI_Type_get_extent(imx4i, &lb, &extent);
check(lb == 0);
if (sizeof(MPI_Aint) == sizeof(int))
@@ -123,7 +123,7 @@ int main(int argc, char *argv[])
check(extent_x == INT_MAX);
MPI_Type_get_extent_x(four_ints, &lb_x, &extent_x);
check(lb_x == 0);
- check(extent_x == 4*sizeof(int));
+ check(extent_x == 4 * sizeof(int));
MPI_Type_get_extent_x(imx4i, &lb_x, &extent_x);
check(lb_x == 0);
check(extent_x == imx4i_true_extent);
@@ -137,7 +137,7 @@ int main(int argc, char *argv[])
check(extent == INT_MAX);
MPI_Type_get_true_extent(four_ints, &lb, &extent);
check(lb == 0);
- check(extent == 4*sizeof(int));
+ check(extent == 4 * sizeof(int));
MPI_Type_get_true_extent(imx4i, &lb, &extent);
check(lb == 0);
if (sizeof(MPI_Aint) == sizeof(int))
@@ -157,7 +157,7 @@ int main(int argc, char *argv[])
check(extent_x == INT_MAX);
MPI_Type_get_true_extent_x(four_ints, &lb_x, &extent_x);
check(lb_x == 0);
- check(extent_x == 4*sizeof(int));
+ check(extent_x == 4 * sizeof(int));
MPI_Type_get_true_extent_x(imx4i, &lb_x, &extent_x);
check(lb_x == 0);
check(extent_x == imx4i_true_extent);
@@ -221,14 +221,18 @@ int main(int argc, char *argv[])
check_set_elements(imax_contig, INT_MAX);
check_set_elements(four_ints, 4);
- check_set_elements(imx4i, 4LL*(INT_MAX/2));
- check_set_elements(imx4i_rsz, 4LL*(INT_MAX/2));
-
-epilogue:
- if (imax_contig != MPI_DATATYPE_NULL) MPI_Type_free(&imax_contig);
- if (four_ints != MPI_DATATYPE_NULL) MPI_Type_free(&four_ints);
- if (imx4i != MPI_DATATYPE_NULL) MPI_Type_free(&imx4i);
- if (imx4i_rsz != MPI_DATATYPE_NULL) MPI_Type_free(&imx4i_rsz);
+ check_set_elements(imx4i, 4LL * (INT_MAX / 2));
+ check_set_elements(imx4i_rsz, 4LL * (INT_MAX / 2));
+
+ epilogue:
+ if (imax_contig != MPI_DATATYPE_NULL)
+ MPI_Type_free(&imax_contig);
+ if (four_ints != MPI_DATATYPE_NULL)
+ MPI_Type_free(&four_ints);
+ if (imx4i != MPI_DATATYPE_NULL)
+ MPI_Type_free(&imx4i);
+ if (imx4i_rsz != MPI_DATATYPE_NULL)
+ MPI_Type_free(&imx4i_rsz);
MPI_Reduce((wrank == 0 ? MPI_IN_PLACE : &errs), &errs, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
if (wrank == 0) {
diff --git a/test/mpi/datatype/large_type.c b/test/mpi/datatype/large_type.c
index 4688e1b..687f31b 100644
--- a/test/mpi/datatype/large_type.c
+++ b/test/mpi/datatype/large_type.c
@@ -11,34 +11,35 @@
static MPI_Datatype make_largexfer_type_struct(MPI_Offset nbytes)
{
- int typechunk_size = 1024*1024; /* in bytes: TODO: figure out how big a
- chunk is really needed */
+ int typechunk_size = 1024 * 1024; /* in bytes: TODO: figure out how big a
+ * chunk is really needed */
int chunk_count;
- int remainder=0;
+ int remainder = 0;
MPI_Datatype memtype, chunktype;
/* need to cook up a new datatype to accomodate large datatypes */
/* first pass: chunks of 1 MiB plus an additional remainder. Does require
* 8 byte MPI_Aint, which should have been checked for earlier */
- chunk_count = nbytes/typechunk_size;
+ chunk_count = nbytes / typechunk_size;
remainder = nbytes % typechunk_size;
MPI_Type_contiguous(typechunk_size, MPI_BYTE, &chunktype);
MPI_Type_commit(&chunktype);
/* a zero remainder means we can just count contigs */
if (remainder == 0) {
- MPI_Type_contiguous(chunk_count, chunktype, &memtype);
- MPI_Type_free(&chunktype);
- } else {
- if (sizeof(MPI_Aint) <= sizeof(int)) {
- return MPI_DATATYPE_NULL;
- }
- /* struct type: some number of chunks plus remaining bytes tacked
+ MPI_Type_contiguous(chunk_count, chunktype, &memtype);
+ MPI_Type_free(&chunktype);
+ }
+ else {
+ if (sizeof(MPI_Aint) <= sizeof(int)) {
+ return MPI_DATATYPE_NULL;
+ }
+ /* struct type: some number of chunks plus remaining bytes tacked
* on at end */
- int lens[] = {chunk_count, remainder};
- MPI_Aint disp[] = {0, (MPI_Aint) typechunk_size * (MPI_Aint)chunk_count};
- MPI_Datatype types[] = {chunktype, MPI_BYTE};
+ int lens[] = { chunk_count, remainder };
+ MPI_Aint disp[] = { 0, (MPI_Aint) typechunk_size * (MPI_Aint) chunk_count };
+ MPI_Datatype types[] = { chunktype, MPI_BYTE };
MPI_Type_struct(2, lens, disp, types, &memtype);
MPI_Type_free(&chunktype);
@@ -46,10 +47,11 @@ static MPI_Datatype make_largexfer_type_struct(MPI_Offset nbytes)
MPI_Type_commit(&memtype);
return memtype;
}
+
static MPI_Datatype make_largexfer_type_hindexed(MPI_Offset nbytes)
{
int i, count;
- int chunk_size = 1024*1024;
+ int chunk_size = 1024 * 1024;
int *blocklens;
MPI_Aint *disp;
MPI_Datatype memtype;
@@ -61,20 +63,20 @@ static MPI_Datatype make_largexfer_type_hindexed(MPI_Offset nbytes)
if (sizeof(MPI_Aint) <= sizeof(int)) {
return MPI_DATATYPE_NULL;
}
-
+
/* ceiling division */
- count = 1 + ((nbytes -1) / chunk_size );
+ count = 1 + ((nbytes - 1) / chunk_size);
blocklens = calloc(count, sizeof(int));
disp = calloc(count, sizeof(MPI_Aint));
- for (i=0; i<(count-1); i++) {
- blocklens[i] = chunk_size;
- disp[i] = (MPI_Aint)chunk_size*i;
+ for (i = 0; i < (count - 1); i++) {
+ blocklens[i] = chunk_size;
+ disp[i] = (MPI_Aint) chunk_size *i;
}
- blocklens[count-1] = nbytes-((MPI_Aint)chunk_size*i);
- disp[count-1] = (MPI_Aint)chunk_size*(count-1);
+ blocklens[count - 1] = nbytes - ((MPI_Aint) chunk_size * i);
+ disp[count - 1] = (MPI_Aint) chunk_size *(count - 1);
MPI_Type_create_hindexed(count, blocklens, disp, MPI_BYTE, &memtype);
MPI_Type_commit(&memtype);
@@ -83,31 +85,31 @@ static MPI_Datatype make_largexfer_type_hindexed(MPI_Offset nbytes)
}
-int testtype(MPI_Datatype type, MPI_Offset expected) {
+int testtype(MPI_Datatype type, MPI_Offset expected)
+{
MPI_Count size, lb, extent;
- int nerrors=0;
+ int nerrors = 0;
MPI_Type_size_x(type, &size);
- if (size < 0) {
- printf("ERROR: type size apparently overflowed integer\n");
- nerrors++;
+ if (size < 0) {
+ printf("ERROR: type size apparently overflowed integer\n");
+ nerrors++;
}
if (size != expected) {
- printf("reported type size %lld does not match expected %lld\n",
- size, expected);
- nerrors++;
+ printf("reported type size %lld does not match expected %lld\n", size, expected);
+ nerrors++;
}
MPI_Type_get_true_extent_x(type, &lb, &extent);
if (lb != 0) {
- printf("ERROR: type should have lb of 0, reported %lld\n", lb);
- nerrors ++;
+ printf("ERROR: type should have lb of 0, reported %lld\n", lb);
+ nerrors++;
}
- if (extent != size) {
- printf("ERROR: extent should match size, not %lld\n", extent);
- nerrors ++;
+ if (extent != size) {
+ printf("ERROR: extent should match size, not %lld\n", extent);
+ nerrors++;
}
return nerrors;
}
@@ -116,16 +118,17 @@ int testtype(MPI_Datatype type, MPI_Offset expected) {
int main(int argc, char **argv)
{
- int nerrors=0, i;
+ int nerrors = 0, i;
int rank, size;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
#define NR_TYPES 3
- MPI_Offset expected_sizes[NR_TYPES] = {1024UL*1024UL*2400UL,
- 2346319872,
- 2346319872};
+ MPI_Offset expected_sizes[NR_TYPES] = { 1024UL * 1024UL * 2400UL,
+ 2346319872,
+ 2346319872
+ };
MPI_Datatype types[NR_TYPES];
/* a contig type, itself large, but does not need 8 byte aints */
@@ -135,20 +138,21 @@ int main(int argc, char **argv)
/* similar, but with hindexed type */
types[2] = make_largexfer_type_hindexed(expected_sizes[2]);
- for (i=0; i<NR_TYPES; i++) {
- if (types[i] != MPI_DATATYPE_NULL) {
- nerrors += testtype(types[i], expected_sizes[i]);
- MPI_Type_free(&(types[i]));
- }
+ for (i = 0; i < NR_TYPES; i++) {
+ if (types[i] != MPI_DATATYPE_NULL) {
+ nerrors += testtype(types[i], expected_sizes[i]);
+ MPI_Type_free(&(types[i]));
+ }
}
MPI_Finalize();
if (rank == 0) {
- if (nerrors) {
- printf("found %d errors\n", nerrors);
- } else {
- printf(" No errors\n");
- }
+ if (nerrors) {
+ printf("found %d errors\n", nerrors);
+ }
+ else {
+ printf(" No errors\n");
+ }
}
return 0;
diff --git a/test/mpi/datatype/large_type_sendrec.c b/test/mpi/datatype/large_type_sendrec.c
index 056c4a7..7f3438b 100644
--- a/test/mpi/datatype/large_type_sendrec.c
+++ b/test/mpi/datatype/large_type_sendrec.c
@@ -27,7 +27,7 @@ static void verbose_abort(int errorcode)
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
char errorstring[MPI_MAX_ERROR_STRING];
- memset(errorstring, 0, MPI_MAX_ERROR_STRING); /* optional */
+ memset(errorstring, 0, MPI_MAX_ERROR_STRING); /* optional */
int errorclass;
MPI_Error_class(errorcode, &errorclass);
@@ -36,17 +36,17 @@ static void verbose_abort(int errorcode)
MPI_Error_string(errorcode, errorstring, &resultlen);
fprintf(stderr, "%d: MPI failed (%d: %s) \n", rank, errorclass, errorstring);
- fflush(stderr); /* almost certainly redundant with the following... */
+ fflush(stderr); /* almost certainly redundant with the following... */
MPI_Abort(MPI_COMM_WORLD, errorclass);
return;
}
+
#define MPI_ASSERT(rc) \
do { if ((rc)!=MPI_SUCCESS) verbose_abort(rc); } while (0)
-int Type_contiguous_x(MPI_Count count, MPI_Datatype oldtype,
- MPI_Datatype * newtype);
+int Type_contiguous_x(MPI_Count count, MPI_Datatype oldtype, MPI_Datatype * newtype);
#define BIGMPI_MAX INT_MAX
@@ -56,7 +56,7 @@ int Type_contiguous_x(MPI_Count count, MPI_Datatype oldtype,
* int Type_contiguous_x(MPI_Count count,
* MPI_Datatype oldtype,
* MPI_Datatype * newtype)
- *
+ *
* Input Parameters
*
* count replication count (nonnegative integer)
@@ -69,8 +69,8 @@ int Type_contiguous_x(MPI_Count count, MPI_Datatype oldtype,
*/
int Type_contiguous_x(MPI_Count count, MPI_Datatype oldtype, MPI_Datatype * newtype)
{
- MPI_Count c = count/BIGMPI_MAX;
- MPI_Count r = count%BIGMPI_MAX;
+ MPI_Count c = count / BIGMPI_MAX;
+ MPI_Count r = count % BIGMPI_MAX;
MPI_Datatype chunk;
MPI_ASSERT(MPI_Type_contiguous(BIGMPI_MAX, oldtype, &chunk));
@@ -84,12 +84,13 @@ int Type_contiguous_x(MPI_Count count, MPI_Datatype oldtype, MPI_Datatype * newt
int typesize;
MPI_ASSERT(MPI_Type_size(oldtype, &typesize));
- MPI_Aint remdisp = (MPI_Aint)c*BIGMPI_MAX*typesize; /* must explicit-cast to avoid overflow */
- int array_of_blocklengths[2] = {1,1};
- MPI_Aint array_of_displacements[2] = {0,remdisp};
- MPI_Datatype array_of_types[2] = {chunks,remainder};
+ MPI_Aint remdisp = (MPI_Aint) c * BIGMPI_MAX * typesize; /* must explicit-cast to avoid overflow */
+ int array_of_blocklengths[2] = { 1, 1 };
+ MPI_Aint array_of_displacements[2] = { 0, remdisp };
+ MPI_Datatype array_of_types[2] = { chunks, remainder };
- MPI_ASSERT(MPI_Type_create_struct(2, array_of_blocklengths, array_of_displacements, array_of_types, newtype));
+ MPI_ASSERT(MPI_Type_create_struct
+ (2, array_of_blocklengths, array_of_displacements, array_of_types, newtype));
MPI_ASSERT(MPI_Type_commit(newtype));
MPI_ASSERT(MPI_Type_free(&chunk));
@@ -100,7 +101,7 @@ int Type_contiguous_x(MPI_Count count, MPI_Datatype oldtype, MPI_Datatype * newt
}
-int main(int argc, char * argv[])
+int main(int argc, char *argv[])
{
int provided;
size_t i;
@@ -111,65 +112,71 @@ int main(int argc, char * argv[])
MPI_ASSERT(MPI_Comm_rank(MPI_COMM_WORLD, &rank));
MPI_ASSERT(MPI_Comm_size(MPI_COMM_WORLD, &size));
- int logn = (argc>1) ? atoi(argv[1]) : 32;
- size_t count = (size_t)1<<logn; /* explicit cast required */
+ int logn = (argc > 1) ? atoi(argv[1]) : 32;
+ size_t count = (size_t) 1 << logn; /* explicit cast required */
MPI_Datatype bigtype;
- MPI_ASSERT(Type_contiguous_x( (MPI_Count)count, MPI_CHAR, &bigtype));
+ MPI_ASSERT(Type_contiguous_x((MPI_Count) count, MPI_CHAR, &bigtype));
MPI_ASSERT(MPI_Type_commit(&bigtype));
MPI_Request requests[2];
MPI_Status statuses[2];
- char * rbuf = NULL;
- char * sbuf = NULL;
+ char *rbuf = NULL;
+ char *sbuf = NULL;
- if (rank==(size-1)) {
- rbuf = malloc( count * sizeof(char)); assert(rbuf!=NULL);
- for (i=0; i<count; i++)
+ if (rank == (size - 1)) {
+ rbuf = malloc(count * sizeof(char));
+ assert(rbuf != NULL);
+ for (i = 0; i < count; i++)
rbuf[i] = 'a';
- MPI_ASSERT(MPI_Irecv(rbuf, 1, bigtype, 0, 0, MPI_COMM_WORLD, &(requests[1]) ));
+ MPI_ASSERT(MPI_Irecv(rbuf, 1, bigtype, 0, 0, MPI_COMM_WORLD, &(requests[1])));
}
- if (rank==0) {
- sbuf = malloc( count * sizeof(char)); assert(sbuf!=NULL);
- for (i=0; i<count; i++)
+ if (rank == 0) {
+ sbuf = malloc(count * sizeof(char));
+ assert(sbuf != NULL);
+ for (i = 0; i < count; i++)
sbuf[i] = 'z';
- MPI_ASSERT(MPI_Isend(sbuf, 1, bigtype, size-1, 0, MPI_COMM_WORLD, &(requests[0]) ));
+ MPI_ASSERT(MPI_Isend(sbuf, 1, bigtype, size - 1, 0, MPI_COMM_WORLD, &(requests[0])));
}
MPI_Count ocount[2];
- if (size==1) {
+ if (size == 1) {
MPI_ASSERT(MPI_Waitall(2, requests, statuses));
- MPI_ASSERT(MPI_Get_elements_x( &(statuses[1]), MPI_CHAR, &(ocount[1])));
+ MPI_ASSERT(MPI_Get_elements_x(&(statuses[1]), MPI_CHAR, &(ocount[1])));
}
else {
- if (rank==(size-1)) {
- MPI_ASSERT(MPI_Wait( &(requests[1]), &(statuses[1]) ));
- MPI_ASSERT(MPI_Get_elements_x( &(statuses[1]), MPI_CHAR, &(ocount[1]) ));
- } else if (rank==0) {
- MPI_ASSERT(MPI_Wait( &(requests[0]), &(statuses[0]) ));
- /* No valid fields in status from a send request (MPI-3 p53,
- line 1-5) */
+ if (rank == (size - 1)) {
+ MPI_ASSERT(MPI_Wait(&(requests[1]), &(statuses[1])));
+ MPI_ASSERT(MPI_Get_elements_x(&(statuses[1]), MPI_CHAR, &(ocount[1])));
+ }
+ else if (rank == 0) {
+ MPI_ASSERT(MPI_Wait(&(requests[0]), &(statuses[0])));
+ /* No valid fields in status from a send request (MPI-3 p53,
+ * line 1-5) */
}
}
/* correctness check */
- if (rank==(size-1)) {
+ if (rank == (size - 1)) {
MPI_Count errors = 0;
- for (j=0; j<count; j++)
- errors += ( rbuf[j] != 'z' );
+ for (j = 0; j < count; j++)
+ errors += (rbuf[j] != 'z');
if (errors == 0) {
- printf(" No Errors\n");
- } else {
- printf("errors = %lld \n", errors);
- }
+ printf(" No Errors\n");
+ }
+ else {
+ printf("errors = %lld \n", errors);
+ }
}
- if (rbuf) free(rbuf);
- if (sbuf) free(sbuf);
+ if (rbuf)
+ free(rbuf);
+ if (sbuf)
+ free(sbuf);
MPI_ASSERT(MPI_Type_free(&bigtype));
diff --git a/test/mpi/datatype/lbub.c b/test/mpi/datatype/lbub.c
index 366dd6c..b1c4824 100644
--- a/test/mpi/datatype/lbub.c
+++ b/test/mpi/datatype/lbub.c
@@ -12,7 +12,7 @@
#include <string.h>
#endif
-/*
+/*
The default behavior of the test routines should be to briefly indicate
the cause of any errors - in this test, that means that verbose needs
to be set. Verbose should turn on output that is independent of error
@@ -39,55 +39,65 @@ int main(int argc, char **argv)
{
int err, errs = 0;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
/* perform some tests */
err = int_with_lb_ub_test();
- if (err && verbose) fprintf(stderr, "found %d errors in simple lb/ub test\n", err);
+ if (err && verbose)
+ fprintf(stderr, "found %d errors in simple lb/ub test\n", err);
errs += err;
err = contig_of_int_with_lb_ub_test();
- if (err && verbose) fprintf(stderr, "found %d errors in contig test\n", err);
+ if (err && verbose)
+ fprintf(stderr, "found %d errors in contig test\n", err);
errs += err;
err = contig_negextent_of_int_with_lb_ub_test();
- if (err && verbose) fprintf(stderr, "found %d errors in negextent contig test\n", err);
+ if (err && verbose)
+ fprintf(stderr, "found %d errors in negextent contig test\n", err);
errs += err;
err = vector_of_int_with_lb_ub_test();
- if (err && verbose) fprintf(stderr, "found %d errors in simple vector test\n", err);
+ if (err && verbose)
+ fprintf(stderr, "found %d errors in simple vector test\n", err);
errs += err;
err = vector_blklen_of_int_with_lb_ub_test();
- if (err && verbose) fprintf(stderr, "found %d errors in vector blklen test\n", err);
+ if (err && verbose)
+ fprintf(stderr, "found %d errors in vector blklen test\n", err);
errs += err;
err = vector_blklen_stride_of_int_with_lb_ub_test();
- if (err && verbose) fprintf(stderr, "found %d errors in strided vector test\n", err);
+ if (err && verbose)
+ fprintf(stderr, "found %d errors in strided vector test\n", err);
errs += err;
err = vector_blklen_negstride_of_int_with_lb_ub_test();
- if (err && verbose) fprintf(stderr, "found %d errors in negstrided vector test\n", err);
+ if (err && verbose)
+ fprintf(stderr, "found %d errors in negstrided vector test\n", err);
errs += err;
err = int_with_negextent_test();
- if (err && verbose) fprintf(stderr, "found %d errors in negextent lb/ub test\n", err);
+ if (err && verbose)
+ fprintf(stderr, "found %d errors in negextent lb/ub test\n", err);
errs += err;
err = vector_blklen_stride_negextent_of_int_with_lb_ub_test();
- if (err && verbose) fprintf(stderr, "found %d errors in strided negextent vector test\n", err);
+ if (err && verbose)
+ fprintf(stderr, "found %d errors in strided negextent vector test\n", err);
errs += err;
err = vector_blklen_negstride_negextent_of_int_with_lb_ub_test();
- if (err && verbose) fprintf(stderr, "found %d errors in negstrided negextent vector test\n", err);
+ if (err && verbose)
+ fprintf(stderr, "found %d errors in negstrided negextent vector test\n", err);
errs += err;
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
@@ -95,19 +105,19 @@ int main(int argc, char **argv)
int parse_args(int argc, char **argv)
{
/*
- int ret;
-
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
- }
- */
+ * int ret;
+ *
+ * while ((ret = getopt(argc, argv, "v")) >= 0)
+ * {
+ * switch (ret) {
+ * case 'v':
+ * verbose = 1;
+ * break;
+ * }
+ * }
+ */
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
return 0;
}
@@ -123,95 +133,115 @@ int int_with_lb_ub_test(void)
err = MPI_Type_struct(3, blocks, disps, types, &eviltype);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_struct failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_struct failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
err = MPI_Type_size(eviltype, &val);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_size failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_size failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (val != 4) {
- errs++;
- if (verbose) fprintf(stderr, " size of type = %d; should be %d\n", val, 4);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " size of type = %d; should be %d\n", val, 4);
}
err = MPI_Type_extent(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != 9) {
- errs++;
- if (verbose) fprintf(stderr, " extent of type = %ld; should be %d\n", (long) aval, 9);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " extent of type = %ld; should be %d\n", (long) aval, 9);
}
-
+
err = MPI_Type_lb(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_lb failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_lb failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != -3) {
- errs++;
- if (verbose) fprintf(stderr, " lb of type = %d; should be %d\n", (int) aval, -3);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " lb of type = %d; should be %d\n", (int) aval, -3);
}
err = MPI_Type_get_extent(eviltype, &lb, &extent);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_get_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_get_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (lb != -3) {
- errs++;
- if (verbose) fprintf(stderr, " lb of type = %d; should be %d\n",
- (int) aval, -3);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " lb of type = %d; should be %d\n", (int) aval, -3);
}
if (extent != 9) {
- errs++;
- if (verbose) fprintf(stderr, " extent of type = %d; should be %d\n",
- (int) extent, 9);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " extent of type = %d; should be %d\n", (int) extent, 9);
}
err = MPI_Type_ub(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_ub failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_ub failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != 6) {
- errs++;
- if (verbose) fprintf(stderr, " ub of type = %d; should be %d\n", (int) aval, 6);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " ub of type = %d; should be %d\n", (int) aval, 6);
}
err = MPI_Type_get_true_extent(eviltype, &true_lb, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_get_true_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_get_true_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (true_lb != 0) {
- errs++;
- if (verbose) fprintf(stderr, " true_lb of type = %d; should be %d\n", (int) true_lb, 0);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " true_lb of type = %d; should be %d\n", (int) true_lb, 0);
}
if (aval != 4) {
- errs++;
- if (verbose) fprintf(stderr, " true extent of type = %d; should be %d\n", (int) aval, 4);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " true extent of type = %d; should be %d\n", (int) aval, 4);
}
-
+
MPI_Type_free(&eviltype);
return errs;
@@ -229,117 +259,143 @@ int contig_of_int_with_lb_ub_test(void)
MPI_Datatype inttype, eviltype;
/* build same type as in int_with_lb_ub_test() */
- typemapstring = (char*)"{ (LB,-3),4*(BYTE,0),(UB,6) }";
+ typemapstring = (char *) "{ (LB,-3),4*(BYTE,0),(UB,6) }";
err = MPI_Type_struct(3, blocks, disps, types, &inttype);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_struct of %s failed.\n",
- typemapstring );
- if (verbose) MTestPrintError( err );
- /* no point in continuing */
- return errs;
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_struct of %s failed.\n", typemapstring);
+ if (verbose)
+ MTestPrintError(err);
+ /* no point in continuing */
+ return errs;
}
- typemapstring=(char*)"{ (LB,-3),4*(BYTE,0),(UB,6),(LB,6),4*(BYTE,9),(UB,15),(LB,15),4*(BYTE,18),(UB,24)}";
+ typemapstring = (char *)
+ "{ (LB,-3),4*(BYTE,0),(UB,6),(LB,6),4*(BYTE,9),(UB,15),(LB,15),4*(BYTE,18),(UB,24)}";
err = MPI_Type_contiguous(3, inttype, &eviltype);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_contiguous of %s failed.\n",
- typemapstring );
- if (verbose) MTestPrintError( err );
- /* no point in continuing */
- return errs;
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_contiguous of %s failed.\n", typemapstring);
+ if (verbose)
+ MTestPrintError(err);
+ /* no point in continuing */
+ return errs;
}
err = MPI_Type_size(eviltype, &val);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_size of %s failed.\n",
- typemapstring );
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_size of %s failed.\n", typemapstring);
+ if (verbose)
+ MTestPrintError(err);
}
if (val != 12) {
- errs++;
- if (verbose) fprintf(stderr, " size of type = %d; should be %d\n",
- val, 12);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " size of type = %d; should be %d\n", val, 12);
}
err = MPI_Type_extent(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != 27) {
- errs++;
- if (verbose) fprintf(stderr, " extent of type = %d; should be %d\n", (int) aval, 27);
- if (verbose) fprintf( stderr, " for type %s\n", typemapstring );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " extent of type = %d; should be %d\n", (int) aval, 27);
+ if (verbose)
+ fprintf(stderr, " for type %s\n", typemapstring);
}
-
+
err = MPI_Type_lb(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_lb failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_lb failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != -3) {
- errs++;
- if (verbose) fprintf(stderr, " lb of type = %d from Type_lb; should be %d in %s\n", (int) aval, -3, typemapstring );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " lb of type = %d from Type_lb; should be %d in %s\n", (int) aval, -3,
+ typemapstring);
}
err = MPI_Type_get_extent(eviltype, &lb, &extent);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_get_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_get_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (lb != -3) {
- errs++;
- if (verbose) fprintf(stderr, " lb of type = %d from Type_get_extent; should be %d in %s\n",
- (int) aval, -3, typemapstring );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " lb of type = %d from Type_get_extent; should be %d in %s\n",
+ (int) aval, -3, typemapstring);
}
if (extent != 27) {
- errs++;
- if (verbose) fprintf(stderr, " extent of type = %d from Type_get_extent; should be %d in %s\n",
- (int) extent, 27, typemapstring);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " extent of type = %d from Type_get_extent; should be %d in %s\n",
+ (int) extent, 27, typemapstring);
}
err = MPI_Type_ub(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_ub failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_ub failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != 24) {
- errs++;
- if (verbose) fprintf(stderr, " ub of type = %d in Type_ub; should be %din %s\n", (int) aval, 24, typemapstring);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " ub of type = %d in Type_ub; should be %din %s\n", (int) aval, 24,
+ typemapstring);
}
err = MPI_Type_get_true_extent(eviltype, &true_lb, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_get_true_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_get_true_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (true_lb != 0) {
- errs++;
- if (verbose) fprintf(stderr, " true_lb of type = %d; should be %d in %s\n", (int) true_lb, 0, typemapstring);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " true_lb of type = %d; should be %d in %s\n", (int) true_lb, 0,
+ typemapstring);
}
if (aval != 22) {
- errs++;
- if (verbose) fprintf(stderr, " true extent of type = %d; should be %d in %s\n", (int) aval, 22, typemapstring);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " true extent of type = %d; should be %d in %s\n", (int) aval, 22,
+ typemapstring);
}
- MPI_Type_free( &inttype );
- MPI_Type_free( &eviltype );
+ MPI_Type_free(&inttype);
+ MPI_Type_free(&eviltype);
return errs;
}
@@ -356,116 +412,136 @@ int contig_negextent_of_int_with_lb_ub_test(void)
MPI_Datatype inttype, eviltype;
/* build same type as in int_with_lb_ub_test() */
- typemapstring = (char*)"{ (LB,6),4*(BYTE,0),(UB,-3) }";
+ typemapstring = (char *) "{ (LB,6),4*(BYTE,0),(UB,-3) }";
err = MPI_Type_struct(3, blocks, disps, types, &inttype);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_struct of %s failed.\n",
- typemapstring );
- if (verbose) MTestPrintError( err );
- /* No point in continuing */
- return errs;
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_struct of %s failed.\n", typemapstring);
+ if (verbose)
+ MTestPrintError(err);
+ /* No point in continuing */
+ return errs;
}
- typemapstring = (char*)"{ (LB,6),4*(BYTE,0),(UB,-3),(LB,-3),4*(BYTE,-9),(UB,-12),(LB,-12),4*(BYTE,-18),(UB,-21) }";
+ typemapstring = (char *)
+ "{ (LB,6),4*(BYTE,0),(UB,-3),(LB,-3),4*(BYTE,-9),(UB,-12),(LB,-12),4*(BYTE,-18),(UB,-21) }";
err = MPI_Type_contiguous(3, inttype, &eviltype);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_contiguous of %s failed.\n",
- typemapstring);
- if (verbose) MTestPrintError( err );
- /* No point in continuing */
- return errs;
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_contiguous of %s failed.\n", typemapstring);
+ if (verbose)
+ MTestPrintError(err);
+ /* No point in continuing */
+ return errs;
}
err = MPI_Type_size(eviltype, &val);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_size of %s failed.\n",
- typemapstring);
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_size of %s failed.\n", typemapstring);
+ if (verbose)
+ MTestPrintError(err);
}
if (val != 12) {
- errs++;
- if (verbose) fprintf(stderr, " size of type = %d; should be %d\n", val, 12);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " size of type = %d; should be %d\n", val, 12);
}
err = MPI_Type_extent(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != 9) {
- errs++;
- if (verbose) fprintf(stderr, " extent of type = %d; should be %d\n", (int) aval, 9);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " extent of type = %d; should be %d\n", (int) aval, 9);
}
-
+
err = MPI_Type_lb(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_lb failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_lb failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != -12) {
- errs++;
- if (verbose) fprintf(stderr, " lb of type = %d; should be %d\n", (int) aval, -12);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " lb of type = %d; should be %d\n", (int) aval, -12);
}
err = MPI_Type_get_extent(eviltype, &lb, &extent);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_get_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_get_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (lb != -12) {
- errs++;
- if (verbose) fprintf(stderr, " lb of type = %d; should be %d\n",
- (int) aval, -12);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " lb of type = %d; should be %d\n", (int) aval, -12);
}
if (extent != 9) {
- errs++;
- if (verbose) fprintf(stderr, " extent of type = %d; should be %d\n",
- (int) extent, 9);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " extent of type = %d; should be %d\n", (int) extent, 9);
}
err = MPI_Type_ub(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_ub failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_ub failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != -3) {
- errs++;
- if (verbose) fprintf(stderr, " ub of type = %d; should be %d\n", (int) aval, -3);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " ub of type = %d; should be %d\n", (int) aval, -3);
}
err = MPI_Type_get_true_extent(eviltype, &true_lb, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_get_true_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_get_true_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (true_lb != -18) {
- errs++;
- if (verbose) fprintf(stderr, " true_lb of type = %d; should be %d\n", (int) true_lb, -18);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " true_lb of type = %d; should be %d\n", (int) true_lb, -18);
}
if (aval != 22) {
- errs++;
- if (verbose) fprintf(stderr, " true extent of type = %d; should be %d\n", (int) aval, 22);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " true extent of type = %d; should be %d\n", (int) aval, 22);
}
- MPI_Type_free( &inttype );
- MPI_Type_free( &eviltype );
-
+ MPI_Type_free(&inttype);
+ MPI_Type_free(&eviltype);
+
return errs;
}
@@ -482,108 +558,130 @@ int vector_of_int_with_lb_ub_test(void)
/* build same type as in int_with_lb_ub_test() */
err = MPI_Type_struct(3, blocks, disps, types, &inttype);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_struct failed.\n");
- if (verbose) MTestPrintError( err );
- /* no point in continuing */
- return errs;
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_struct failed.\n");
+ if (verbose)
+ MTestPrintError(err);
+ /* no point in continuing */
+ return errs;
}
err = MPI_Type_vector(3, 1, 1, inttype, &eviltype);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_vector failed.\n");
- if (verbose) MTestPrintError( err );
- /* no point in continuing */
- return errs;
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_vector failed.\n");
+ if (verbose)
+ MTestPrintError(err);
+ /* no point in continuing */
+ return errs;
}
err = MPI_Type_size(eviltype, &val);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_size failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_size failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (val != 12) {
- errs++;
- if (verbose) fprintf(stderr, " size of type = %d; should be %d\n", val, 12);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " size of type = %d; should be %d\n", val, 12);
}
err = MPI_Type_extent(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != 27) {
- errs++;
- if (verbose) fprintf(stderr, " extent of type = %d; should be %d\n", (int) aval, 27);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " extent of type = %d; should be %d\n", (int) aval, 27);
}
-
+
err = MPI_Type_lb(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_lb failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_lb failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != -3) {
- errs++;
- if (verbose) fprintf(stderr, " lb of type = %d; should be %d\n", (int) aval, -3);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " lb of type = %d; should be %d\n", (int) aval, -3);
}
err = MPI_Type_get_extent(eviltype, &lb, &extent);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_get_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_get_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (lb != -3) {
- errs++;
- if (verbose) fprintf(stderr, " lb of type = %d; should be %d\n",
- (int) aval, -3);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " lb of type = %d; should be %d\n", (int) aval, -3);
}
if (extent != 27) {
- errs++;
- if (verbose) fprintf(stderr, " extent of type = %d; should be %d\n",
- (int) extent, 27);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " extent of type = %d; should be %d\n", (int) extent, 27);
}
err = MPI_Type_ub(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_ub failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_ub failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != 24) {
- errs++;
- if (verbose) fprintf(stderr, " ub of type = %d; should be %d\n", (int) aval, 24);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " ub of type = %d; should be %d\n", (int) aval, 24);
}
err = MPI_Type_get_true_extent(eviltype, &true_lb, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_get_true_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_get_true_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (true_lb != 0) {
- errs++;
- if (verbose) fprintf(stderr, " true_lb of type = %d; should be %d\n", (int) true_lb, 0);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " true_lb of type = %d; should be %d\n", (int) true_lb, 0);
}
if (aval != 22) {
- errs++;
- if (verbose) fprintf(stderr, " true extent of type = %d; should be %d\n", (int) aval, 22);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " true extent of type = %d; should be %d\n", (int) aval, 22);
}
- MPI_Type_free( &inttype );
- MPI_Type_free( &eviltype );
+ MPI_Type_free(&inttype);
+ MPI_Type_free(&eviltype);
return errs;
}
@@ -604,109 +702,132 @@ int vector_blklen_of_int_with_lb_ub_test(void)
/* build same type as in int_with_lb_ub_test() */
err = MPI_Type_struct(3, blocks, disps, types, &inttype);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_struct failed.\n");
- if (verbose) MTestPrintError( err );
- /* no point in continuing */
- return errs;
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_struct failed.\n");
+ if (verbose)
+ MTestPrintError(err);
+ /* no point in continuing */
+ return errs;
}
err = MPI_Type_vector(3, 4, 1, inttype, &eviltype);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_vector failed.\n");
- if (verbose) MTestPrintError( err );
- /* no point in continuing */
- return errs;
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_vector failed.\n");
+ if (verbose)
+ MTestPrintError(err);
+ /* no point in continuing */
+ return errs;
}
err = MPI_Type_size(eviltype, &val);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_size failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_size failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (val != 48) {
- errs++;
- if (verbose) fprintf(stderr, " size of type = %d; should be %d\n", val, 48);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " size of type = %d; should be %d\n", val, 48);
}
err = MPI_Type_extent(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != 54) {
- errs++;
- if (verbose) fprintf(stderr, " extent of type = %d; should be %d\n", (int) aval, 54);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " extent of type = %d; should be %d\n", (int) aval, 54);
}
-
+
err = MPI_Type_lb(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_lb failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_lb failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != -3) {
- errs++;
- if (verbose) fprintf(stderr, " lb of type = %d; should be %d\n", (int) aval, -3);
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " lb of type = %d; should be %d\n", (int) aval, -3);
+ if (verbose)
+ MTestPrintError(err);
}
err = MPI_Type_get_extent(eviltype, &lb, &extent);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_get_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_get_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (lb != -3) {
- errs++;
- if (verbose) fprintf(stderr, " lb of type = %d; should be %d\n",
- (int) aval, -3);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " lb of type = %d; should be %d\n", (int) aval, -3);
}
if (extent != 54) {
- errs++;
- if (verbose) fprintf(stderr, " extent of type = %d; should be %d\n",
- (int) extent, 54);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " extent of type = %d; should be %d\n", (int) extent, 54);
}
err = MPI_Type_ub(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_ub failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_ub failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != 51) {
- errs++;
- if (verbose) fprintf(stderr, " ub of type = %d; should be %d\n", (int) aval, 51);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " ub of type = %d; should be %d\n", (int) aval, 51);
}
err = MPI_Type_get_true_extent(eviltype, &true_lb, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_get_true_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_get_true_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (true_lb != 0) {
- errs++;
- if (verbose) fprintf(stderr, " true_lb of type = %d; should be %d\n", (int) true_lb, 0);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " true_lb of type = %d; should be %d\n", (int) true_lb, 0);
}
if (aval != 49) {
- errs++;
- if (verbose) fprintf(stderr, " true extent of type = %d; should be %d\n", (int) aval, 49);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " true extent of type = %d; should be %d\n", (int) aval, 49);
}
- MPI_Type_free( &inttype );
- MPI_Type_free( &eviltype );
+ MPI_Type_free(&inttype);
+ MPI_Type_free(&eviltype);
return errs;
}
@@ -723,112 +844,133 @@ int vector_blklen_stride_of_int_with_lb_ub_test(void)
MPI_Datatype inttype, eviltype;
/* build same type as in int_with_lb_ub_test() */
- typemapstring = (char*)"{ (LB,-3),4*(BYTE,0),(UB,6) }";
+ typemapstring = (char *) "{ (LB,-3),4*(BYTE,0),(UB,6) }";
err = MPI_Type_struct(3, blocks, disps, types, &inttype);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_struct of %s failed.\n",
- typemapstring );
- if (verbose) MTestPrintError( err );
- /* No point in continuing */
- return errs;
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_struct of %s failed.\n", typemapstring);
+ if (verbose)
+ MTestPrintError(err);
+ /* No point in continuing */
+ return errs;
}
err = MPI_Type_vector(3, 4, 5, inttype, &eviltype);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_vector failed.\n");
- if (verbose) MTestPrintError( err );
- /* no point in continuing */
- return errs;
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_vector failed.\n");
+ if (verbose)
+ MTestPrintError(err);
+ /* no point in continuing */
+ return errs;
}
err = MPI_Type_size(eviltype, &val);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_size failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_size failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (val != 48) {
- errs++;
- if (verbose) fprintf(stderr, " size of type = %d; should be %d\n", val, 48);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " size of type = %d; should be %d\n", val, 48);
}
err = MPI_Type_extent(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != 126) {
- errs++;
- if (verbose) fprintf(stderr, " extent of type = %d; should be %d\n", (int) aval, 126);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " extent of type = %d; should be %d\n", (int) aval, 126);
}
-
+
err = MPI_Type_lb(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_lb failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_lb failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != -3) {
- errs++;
- if (verbose) fprintf(stderr, " lb of type = %d; should be %d\n", (int) aval, -3);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " lb of type = %d; should be %d\n", (int) aval, -3);
}
err = MPI_Type_get_extent(eviltype, &lb, &extent);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_get_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_get_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (lb != -3) {
- errs++;
- if (verbose) fprintf(stderr, " lb of type = %d; should be %d\n",
- (int) aval, -3);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " lb of type = %d; should be %d\n", (int) aval, -3);
}
if (extent != 126) {
- errs++;
- if (verbose) fprintf(stderr, " extent of type = %d; should be %d\n",
- (int) extent, 126);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " extent of type = %d; should be %d\n", (int) extent, 126);
}
err = MPI_Type_ub(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_ub failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_ub failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != 123) {
- errs++;
- if (verbose) fprintf(stderr, " ub of type = %d; should be %d\n", (int) aval, 123);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " ub of type = %d; should be %d\n", (int) aval, 123);
}
err = MPI_Type_get_true_extent(eviltype, &true_lb, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_get_true_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_get_true_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (true_lb != 0) {
- errs++;
- if (verbose) fprintf(stderr, " true_lb of type = %d; should be %d\n", (int) true_lb, 0);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " true_lb of type = %d; should be %d\n", (int) true_lb, 0);
}
if (aval != 121) {
- errs++;
- if (verbose) fprintf(stderr, " true extent of type = %d; should be %d\n", (int) aval, 121);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " true extent of type = %d; should be %d\n", (int) aval, 121);
}
- MPI_Type_free( &inttype );
- MPI_Type_free( &eviltype );
+ MPI_Type_free(&inttype);
+ MPI_Type_free(&eviltype);
return errs;
}
@@ -846,108 +988,130 @@ int vector_blklen_negstride_of_int_with_lb_ub_test(void)
/* build same type as in int_with_lb_ub_test() */
err = MPI_Type_struct(3, blocks, disps, types, &inttype);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_struct failed.\n");
- if (verbose) MTestPrintError( err );
- /* no point in continuing */
- return errs;
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_struct failed.\n");
+ if (verbose)
+ MTestPrintError(err);
+ /* no point in continuing */
+ return errs;
}
err = MPI_Type_vector(3, 4, -5, inttype, &eviltype);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_vector failed.\n");
- if (verbose) MTestPrintError( err );
- /* no point in continuing */
- return errs;
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_vector failed.\n");
+ if (verbose)
+ MTestPrintError(err);
+ /* no point in continuing */
+ return errs;
}
err = MPI_Type_size(eviltype, &val);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_size failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_size failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (val != 48) {
- errs++;
- if (verbose) fprintf(stderr, " size of type = %d; should be %d\n", val, 48);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " size of type = %d; should be %d\n", val, 48);
}
err = MPI_Type_extent(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != 126) {
- errs++;
- if (verbose) fprintf(stderr, " extent of type = %d; should be %d\n", (int) aval, 126);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " extent of type = %d; should be %d\n", (int) aval, 126);
}
-
+
err = MPI_Type_lb(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_lb failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_lb failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != -93) {
- errs++;
- if (verbose) fprintf(stderr, " lb of type = %d; should be %d\n", (int) aval, -93);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " lb of type = %d; should be %d\n", (int) aval, -93);
}
err = MPI_Type_get_extent(eviltype, &lb, &extent);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_get_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_get_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (lb != -93) {
- errs++;
- if (verbose) fprintf(stderr, " lb of type = %d; should be %d\n",
- (int) aval, -93);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " lb of type = %d; should be %d\n", (int) aval, -93);
}
if (extent != 126) {
- errs++;
- if (verbose) fprintf(stderr, " extent of type = %d; should be %d\n",
- (int) extent, 126);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " extent of type = %d; should be %d\n", (int) extent, 126);
}
err = MPI_Type_ub(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_ub failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_ub failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != 33) {
- errs++;
- if (verbose) fprintf(stderr, " ub of type = %d; should be %d\n", (int) aval, 33);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " ub of type = %d; should be %d\n", (int) aval, 33);
}
err = MPI_Type_get_true_extent(eviltype, &true_lb, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_get_true_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_get_true_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (true_lb != -90) {
- errs++;
- if (verbose) fprintf(stderr, " true_lb of type = %d; should be %d\n", (int) true_lb, -90);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " true_lb of type = %d; should be %d\n", (int) true_lb, -90);
}
if (aval != 121) {
- errs++;
- if (verbose) fprintf(stderr, " true extent of type = %d; should be %d\n", (int) aval, 121);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " true extent of type = %d; should be %d\n", (int) aval, 121);
}
- MPI_Type_free( &inttype );
- MPI_Type_free( &eviltype );
+ MPI_Type_free(&inttype);
+ MPI_Type_free(&eviltype);
return errs;
}
@@ -959,105 +1123,124 @@ int int_with_negextent_test(void)
int blocks[3] = { 1, 4, 1 };
MPI_Aint disps[3] = { 6, 0, -3 };
MPI_Datatype types[3] = { MPI_LB, MPI_BYTE, MPI_UB };
- char *typemapstring =0;
+ char *typemapstring = 0;
MPI_Datatype eviltype;
- typemapstring = (char*)"{ (LB,6),4*(BYTE,0),(UB,-3) }";
+ typemapstring = (char *) "{ (LB,6),4*(BYTE,0),(UB,-3) }";
err = MPI_Type_struct(3, blocks, disps, types, &eviltype);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_struct of %s failed.\n",
- typemapstring );
- if (verbose) MTestPrintError( err );
- /* No point in contiuing */
- return errs;
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_struct of %s failed.\n", typemapstring);
+ if (verbose)
+ MTestPrintError(err);
+ /* No point in contiuing */
+ return errs;
}
err = MPI_Type_size(eviltype, &val);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_size failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_size failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (val != 4) {
- errs++;
- if (verbose) fprintf(stderr, " size of type = %d; should be %d\n", val, 4);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " size of type = %d; should be %d\n", val, 4);
}
err = MPI_Type_extent(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != -9) {
- errs++;
- if (verbose) fprintf(stderr, " extent of type = %d; should be %d\n", (int) aval, -9);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " extent of type = %d; should be %d\n", (int) aval, -9);
}
-
+
err = MPI_Type_lb(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_lb failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_lb failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != 6) {
- errs++;
- if (verbose) fprintf(stderr, " lb of type = %d; should be %d\n", (int) aval, 6);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " lb of type = %d; should be %d\n", (int) aval, 6);
}
err = MPI_Type_get_extent(eviltype, &lb, &extent);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_get_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_get_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (lb != 6) {
- errs++;
- if (verbose) fprintf(stderr, " lb of type = %d; should be %d\n",
- (int) aval, 6);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " lb of type = %d; should be %d\n", (int) aval, 6);
}
if (extent != -9) {
- errs++;
- if (verbose) fprintf(stderr, " extent of type = %d; should be %d\n",
- (int) extent, -9);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " extent of type = %d; should be %d\n", (int) extent, -9);
}
err = MPI_Type_ub(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_ub failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_ub failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != -3) {
- errs++;
- if (verbose) fprintf(stderr, " ub of type = %d; should be %d\n", (int) aval, -3);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " ub of type = %d; should be %d\n", (int) aval, -3);
}
err = MPI_Type_get_true_extent(eviltype, &true_lb, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_get_true_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_get_true_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (true_lb != 0) {
- errs++;
- if (verbose) fprintf(stderr, " true_lb of type = %d; should be %d\n", (int) true_lb, 0);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " true_lb of type = %d; should be %d\n", (int) true_lb, 0);
}
if (aval != 4) {
- errs++;
- if (verbose) fprintf(stderr, " true extent of type = %d; should be %d\n", (int) aval, 4);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " true extent of type = %d; should be %d\n", (int) aval, 4);
}
-
+
MPI_Type_free(&eviltype);
return errs;
@@ -1074,112 +1257,133 @@ int vector_blklen_stride_negextent_of_int_with_lb_ub_test(void)
char *typemapstring = 0;
/* build same type as in int_with_lb_ub_test() */
- typemapstring = (char*)"{ (LB,6),4*(BYTE,0),(UB,-3) }";
+ typemapstring = (char *) "{ (LB,6),4*(BYTE,0),(UB,-3) }";
err = MPI_Type_struct(3, blocks, disps, types, &inttype);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_struct of %s failed.\n",
- typemapstring );
- if (verbose) MTestPrintError( err );
- /* No point in continuing */
- return errs;
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_struct of %s failed.\n", typemapstring);
+ if (verbose)
+ MTestPrintError(err);
+ /* No point in continuing */
+ return errs;
}
err = MPI_Type_vector(3, 4, 5, inttype, &eviltype);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_vector failed.\n");
- if (verbose) MTestPrintError( err );
- /* no point in continuing */
- return errs;
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_vector failed.\n");
+ if (verbose)
+ MTestPrintError(err);
+ /* no point in continuing */
+ return errs;
}
err = MPI_Type_size(eviltype, &val);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_size failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_size failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (val != 48) {
- errs++;
- if (verbose) fprintf(stderr, " size of type = %d; should be %d\n", val, 48);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " size of type = %d; should be %d\n", val, 48);
}
err = MPI_Type_extent(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != 108) {
- errs++;
- if (verbose) fprintf(stderr, " extent of type = %d; should be %d\n", (int) aval, 108);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " extent of type = %d; should be %d\n", (int) aval, 108);
}
-
+
err = MPI_Type_lb(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_lb failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_lb failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != -111) {
- errs++;
- if (verbose) fprintf(stderr, " lb of type = %d; should be %d\n", (int) aval, -111);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " lb of type = %d; should be %d\n", (int) aval, -111);
}
err = MPI_Type_get_extent(eviltype, &lb, &extent);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_get_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_get_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (lb != -111) {
- errs++;
- if (verbose) fprintf(stderr, " lb of type = %d; should be %d\n",
- (int) aval, -111);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " lb of type = %d; should be %d\n", (int) aval, -111);
}
if (extent != 108) {
- errs++;
- if (verbose) fprintf(stderr, " extent of type = %d; should be %d\n",
- (int) extent, 108);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " extent of type = %d; should be %d\n", (int) extent, 108);
}
err = MPI_Type_ub(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_ub failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_ub failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != -3) {
- errs++;
- if (verbose) fprintf(stderr, " ub of type = %d; should be %d\n", (int) aval, -3);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " ub of type = %d; should be %d\n", (int) aval, -3);
}
err = MPI_Type_get_true_extent(eviltype, &true_lb, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_get_true_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_get_true_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (true_lb != -117) {
- errs++;
- if (verbose) fprintf(stderr, " true_lb of type = %d; should be %d\n", (int) true_lb, -117);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " true_lb of type = %d; should be %d\n", (int) true_lb, -117);
}
if (aval != 121) {
- errs++;
- if (verbose) fprintf(stderr, " true extent of type = %d; should be %d\n", (int) aval, 121);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " true extent of type = %d; should be %d\n", (int) aval, 121);
}
- MPI_Type_free( &inttype );
- MPI_Type_free( &eviltype );
+ MPI_Type_free(&inttype);
+ MPI_Type_free(&eviltype);
return errs;
}
@@ -1197,109 +1401,131 @@ int vector_blklen_negstride_negextent_of_int_with_lb_ub_test(void)
/* build same type as in int_with_lb_ub_test() */
err = MPI_Type_struct(3, blocks, disps, types, &inttype);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_struct failed.\n");
- if (verbose) MTestPrintError( err );
- /* no point in continuing */
- return errs;
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_struct failed.\n");
+ if (verbose)
+ MTestPrintError(err);
+ /* no point in continuing */
+ return errs;
}
err = MPI_Type_vector(3, 4, -5, inttype, &eviltype);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_vector failed.\n");
- if (verbose) MTestPrintError( err );
- /* no point in continuing */
- return errs;
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_vector failed.\n");
+ if (verbose)
+ MTestPrintError(err);
+ /* no point in continuing */
+ return errs;
}
err = MPI_Type_size(eviltype, &val);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_size failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_size failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (val != 48) {
- errs++;
- if (verbose) fprintf(stderr, " size of type = %d; should be %d\n", val, 48);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " size of type = %d; should be %d\n", val, 48);
}
err = MPI_Type_extent(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != 108) {
- errs++;
- if (verbose) fprintf(stderr, " extent of type = %ld; should be %d\n", (long) aval, 108);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " extent of type = %ld; should be %d\n", (long) aval, 108);
}
-
+
err = MPI_Type_lb(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_lb failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_lb failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != -21) {
- errs++;
- if (verbose) fprintf(stderr, " lb of type = %ld; should be %d\n", (long) aval, -21);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " lb of type = %ld; should be %d\n", (long) aval, -21);
}
err = MPI_Type_get_extent(eviltype, &lb, &extent);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_get_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_get_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (lb != -21) {
- errs++;
- if (verbose) fprintf(stderr, " lb of type = %ld; should be %d\n",
- (long) aval, -21);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " lb of type = %ld; should be %d\n", (long) aval, -21);
}
if (extent != 108) {
- errs++;
- if (verbose) fprintf(stderr, " extent of type = %ld; should be %d\n",
- (long) extent, 108);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " extent of type = %ld; should be %d\n", (long) extent, 108);
}
err = MPI_Type_ub(eviltype, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_ub failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_ub failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (aval != 87) {
- errs++;
- if (verbose) fprintf(stderr, " ub of type = %ld; should be %d\n", (long) aval, 87);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " ub of type = %ld; should be %d\n", (long) aval, 87);
}
err = MPI_Type_get_true_extent(eviltype, &true_lb, &aval);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr, " MPI_Type_get_true_extent failed.\n");
- if (verbose) MTestPrintError( err );
+ errs++;
+ if (verbose)
+ fprintf(stderr, " MPI_Type_get_true_extent failed.\n");
+ if (verbose)
+ MTestPrintError(err);
}
if (true_lb != -27) {
- errs++;
- if (verbose) fprintf(stderr, " true_lb of type = %ld; should be %d\n", (long) true_lb, -27);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " true_lb of type = %ld; should be %d\n", (long) true_lb, -27);
}
if (aval != 121) {
- errs++;
- if (verbose) fprintf(stderr, " true extent of type = %ld; should be %d\n", (long) aval, 121);
+ errs++;
+ if (verbose)
+ fprintf(stderr, " true extent of type = %ld; should be %d\n", (long) aval, 121);
}
- MPI_Type_free( &inttype );
- MPI_Type_free( &eviltype );
+ MPI_Type_free(&inttype);
+ MPI_Type_free(&eviltype);
return errs;
}
diff --git a/test/mpi/datatype/localpack.c b/test/mpi/datatype/localpack.c
index 5348d55..54e3d4f 100644
--- a/test/mpi/datatype/localpack.c
+++ b/test/mpi/datatype/localpack.c
@@ -28,51 +28,54 @@ int main(int argc, char *argv[])
int errs = 0;
char buffer[BUF_SIZE];
int n, size;
- double a,b;
+ double a, b;
int pos;
/* Initialize MPI */
MPI_Init(&argc, &argv);
parse_args(argc, argv);
- pos = 0;
- n = 10;
- a = 1.1;
- b = 2.2;
+ pos = 0;
+ n = 10;
+ a = 1.1;
+ b = 2.2;
MPI_Pack(&n, 1, MPI_INT, buffer, BUF_SIZE, &pos, MPI_COMM_WORLD);
MPI_Pack(&a, 1, MPI_DOUBLE, buffer, BUF_SIZE, &pos, MPI_COMM_WORLD);
MPI_Pack(&b, 1, MPI_DOUBLE, buffer, BUF_SIZE, &pos, MPI_COMM_WORLD);
size = pos;
- pos = 0;
- n = 0;
- a = 0;
- b = 0;
+ pos = 0;
+ n = 0;
+ a = 0;
+ b = 0;
MPI_Unpack(buffer, size, &pos, &n, 1, MPI_INT, MPI_COMM_WORLD);
MPI_Unpack(buffer, size, &pos, &a, 1, MPI_DOUBLE, MPI_COMM_WORLD);
MPI_Unpack(buffer, size, &pos, &b, 1, MPI_DOUBLE, MPI_COMM_WORLD);
/* Check results */
- if (n != 10) {
- errs++;
- if (verbose) fprintf(stderr, "Wrong value for n; got %d expected %d\n", n, 10 );
+ if (n != 10) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "Wrong value for n; got %d expected %d\n", n, 10);
}
- if (a != 1.1) {
- errs++;
- if (verbose) fprintf(stderr, "Wrong value for a; got %f expected %f\n", a, 1.1 );
+ if (a != 1.1) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "Wrong value for a; got %f expected %f\n", a, 1.1);
}
- if (b != 2.2) {
- errs++;
- if (verbose) fprintf(stderr, "Wrong value for b; got %f expected %f\n", b, 2.2 );
+ if (b != 2.2) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "Wrong value for b; got %f expected %f\n", b, 2.2);
}
/* print message and exit */
if (errs) {
- fprintf(stderr, "Found %d errors\n", errs);
+ fprintf(stderr, "Found %d errors\n", errs);
}
else {
- printf(" No Errors\n");
+ printf(" No Errors\n");
}
MPI_Finalize();
return 0;
@@ -81,18 +84,18 @@ int main(int argc, char *argv[])
int parse_args(int argc, char **argv)
{
/*
- int ret;
-
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
- }
- */
+ * int ret;
+ *
+ * while ((ret = getopt(argc, argv, "v")) >= 0)
+ * {
+ * switch (ret) {
+ * case 'v':
+ * verbose = 1;
+ * break;
+ * }
+ * }
+ */
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
return 0;
}
diff --git a/test/mpi/datatype/longdouble.c b/test/mpi/datatype/longdouble.c
index 4ebc551..c08e451 100644
--- a/test/mpi/datatype/longdouble.c
+++ b/test/mpi/datatype/longdouble.c
@@ -62,4 +62,3 @@ int main(int argc, char *argv[])
MPI_Finalize();
return 0;
}
-
diff --git a/test/mpi/datatype/lots-of-types.c b/test/mpi/datatype/lots-of-types.c
index 9722167..c3f6e66 100644
--- a/test/mpi/datatype/lots-of-types.c
+++ b/test/mpi/datatype/lots-of-types.c
@@ -10,7 +10,7 @@
#include "mpi.h"
#include "mpitest.h"
-/*
+/*
The default behavior of the test routines should be to briefly indicate
the cause of any errors - in this test, that means that verbose needs
to be set. Verbose should turn on output that is independent of error
@@ -23,7 +23,7 @@ int parse_args(int argc, char **argv);
int lots_of_types_test(void);
struct test_struct_1 {
- int a,b,c,d;
+ int a, b, c, d;
};
int main(int argc, char *argv[])
@@ -35,15 +35,16 @@ int main(int argc, char *argv[])
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
err = lots_of_types_test();
- if (verbose && err) fprintf(stderr, "error in lots_of_types_test\n");
+ if (verbose && err)
+ fprintf(stderr, "error in lots_of_types_test\n");
errs += err;
/* print message and exit */
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
@@ -72,107 +73,104 @@ int lots_of_types_test(void)
int disps[NUM_BLOCKS];
int blks[NUM_BLOCKS];
- for (i=0; i < NUM_DTYPES; i++)
+ for (i = 0; i < NUM_DTYPES; i++)
mytypes[i] = MPI_DATATYPE_NULL;
- for (i=0; i < NUM_DTYPES; i++) {
- int j;
-
- disps[0] = 0;
- blks[0] = 4;
-
- for (j=1; j < NUM_BLOCKS; j++) {
- disps[j] = 4 * j;
- blks[j] = (j % 3) + 1;
- }
-
- err = MPI_Type_indexed(NUM_BLOCKS, blks, disps, MPI_INT, &mytypes[i]);
- if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Type_indexed returned error on type %d\n",
- i);
- }
+ for (i = 0; i < NUM_DTYPES; i++) {
+ int j;
+
+ disps[0] = 0;
+ blks[0] = 4;
+
+ for (j = 1; j < NUM_BLOCKS; j++) {
+ disps[j] = 4 * j;
+ blks[j] = (j % 3) + 1;
+ }
+
+ err = MPI_Type_indexed(NUM_BLOCKS, blks, disps, MPI_INT, &mytypes[i]);
+ if (err != MPI_SUCCESS) {
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Type_indexed returned error on type %d\n", i);
+ }
mytypes[i] = MPI_DATATYPE_NULL;
goto fn_exit;
- }
-
- MPI_Type_commit(&mytypes[i]);
+ }
+
+ MPI_Type_commit(&mytypes[i]);
}
- for (i=0; i < NUM_DTYPES; i++) {
- int j;
- int recvbuf[4] = { -1, -1, -1, -1 };
-
- /* we will only receive 4 ints, so short buffer is ok */
- err = MPI_Irecv(recvbuf, 1, mytypes[i], 0, 0, MPI_COMM_SELF, &request);
- if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Irecv returned error\n");
- }
- }
-
- err = MPI_Send(sendbuf, 4, MPI_INT, 0, 0, MPI_COMM_SELF);
- if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Send returned error\n");
- }
- }
-
- err = MPI_Wait(&request, &status);
- if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Wait returned error\n");
- }
- }
-
- /* verify data */
- for (j=0; j < 4; j++) {
- if (recvbuf[j] != sendbuf[j]) {
- errs++;
- if (verbose) {
- fprintf(stderr, "recvbuf[%d] = %d; should be %d\n",
- j, recvbuf[j], sendbuf[j]);
- }
- }
- }
-
- /* verify count and elements */
- err = MPI_Get_count(&status, mytypes[i], &count);
- if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Get_count returned error\n");
- }
- }
- if (count != MPI_UNDEFINED) {
- errs++;
- if (verbose) {
- fprintf(stderr, "count = %d; should be MPI_UNDEFINED (%d)\n",
- count, MPI_UNDEFINED);
- }
- }
-
- err = MPI_Get_elements(&status, mytypes[i], &elements);
- if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Get_elements returned error\n");
- }
- }
- if (elements != 4) {
- errs++;
- if (verbose) {
- fprintf(stderr, "elements = %d; should be 4\n", elements);
- }
- }
+ for (i = 0; i < NUM_DTYPES; i++) {
+ int j;
+ int recvbuf[4] = { -1, -1, -1, -1 };
+
+ /* we will only receive 4 ints, so short buffer is ok */
+ err = MPI_Irecv(recvbuf, 1, mytypes[i], 0, 0, MPI_COMM_SELF, &request);
+ if (err != MPI_SUCCESS) {
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Irecv returned error\n");
+ }
+ }
+
+ err = MPI_Send(sendbuf, 4, MPI_INT, 0, 0, MPI_COMM_SELF);
+ if (err != MPI_SUCCESS) {
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Send returned error\n");
+ }
+ }
+
+ err = MPI_Wait(&request, &status);
+ if (err != MPI_SUCCESS) {
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Wait returned error\n");
+ }
+ }
+
+ /* verify data */
+ for (j = 0; j < 4; j++) {
+ if (recvbuf[j] != sendbuf[j]) {
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "recvbuf[%d] = %d; should be %d\n", j, recvbuf[j], sendbuf[j]);
+ }
+ }
+ }
+
+ /* verify count and elements */
+ err = MPI_Get_count(&status, mytypes[i], &count);
+ if (err != MPI_SUCCESS) {
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Get_count returned error\n");
+ }
+ }
+ if (count != MPI_UNDEFINED) {
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "count = %d; should be MPI_UNDEFINED (%d)\n", count, MPI_UNDEFINED);
+ }
+ }
+
+ err = MPI_Get_elements(&status, mytypes[i], &elements);
+ if (err != MPI_SUCCESS) {
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Get_elements returned error\n");
+ }
+ }
+ if (elements != 4) {
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "elements = %d; should be 4\n", elements);
+ }
+ }
}
- fn_exit:
- for (i=0; i < NUM_DTYPES; i++) {
+ fn_exit:
+ for (i = 0; i < NUM_DTYPES; i++) {
if (mytypes[i] != MPI_DATATYPE_NULL)
MPI_Type_free(&mytypes[i]);
}
@@ -184,18 +182,18 @@ int lots_of_types_test(void)
int parse_args(int argc, char **argv)
{
/*
- int ret;
-
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
- }
- */
+ * int ret;
+ *
+ * while ((ret = getopt(argc, argv, "v")) >= 0)
+ * {
+ * switch (ret) {
+ * case 'v':
+ * verbose = 1;
+ * break;
+ * }
+ * }
+ */
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
return 0;
}
diff --git a/test/mpi/datatype/pairtype-pack.c b/test/mpi/datatype/pairtype-pack.c
index 8086bd5..04199ab 100644
--- a/test/mpi/datatype/pairtype-pack.c
+++ b/test/mpi/datatype/pairtype-pack.c
@@ -17,31 +17,28 @@ int short_int_pack_test(void);
/* helper functions */
int parse_args(int argc, char **argv);
-static int pack_and_unpack(char *typebuf,
- int count,
- MPI_Datatype datatype,
- int typebufsz);
+static int pack_and_unpack(char *typebuf, int count, MPI_Datatype datatype, int typebufsz);
int main(int argc, char *argv[])
{
int err, errs = 0;
- MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
+ MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
err = short_int_pack_test();
errs += err;
/* print message and exit */
if (errs) {
- fprintf(stderr, "Found %d errors\n", errs);
+ fprintf(stderr, "Found %d errors\n", errs);
}
else {
- printf(" No Errors\n");
+ printf(" No Errors\n");
}
MPI_Finalize();
return 0;
@@ -51,39 +48,41 @@ int short_int_pack_test(void)
{
int i, err, errs = 0;
- struct shortint { short a; int b; } sibuf[16];
+ struct shortint {
+ short a;
+ int b;
+ } sibuf[16];
- for (i=0; i < 16; i++) {
- sibuf[i].a = (short) (i * 2);
- sibuf[i].b = i * 2 + 1;
+ for (i = 0; i < 16; i++) {
+ sibuf[i].a = (short) (i * 2);
+ sibuf[i].b = i * 2 + 1;
}
err = pack_and_unpack((char *) sibuf, 16, MPI_SHORT_INT, sizeof(sibuf));
if (err != 0) {
- if (verbose) {
- fprintf(stderr,
- "error packing/unpacking in short_int_pack_test()\n");
- }
- errs += err;
+ if (verbose) {
+ fprintf(stderr, "error packing/unpacking in short_int_pack_test()\n");
+ }
+ errs += err;
}
- for (i=0; i < 16; i++) {
- if (sibuf[i].a != (short) (i * 2)) {
- err++;
- if (verbose) {
- fprintf(stderr,
- "buf[%d] has invalid short (%d); should be %d\n",
- i, (int) sibuf[i].a, i * 2);
- }
- }
- if (sibuf[i].b != i * 2 + 1) {
- err++;
- if (verbose) {
- fprintf(stderr,
- "buf[%d] has invalid int (%d); should be %d\n",
- i, (int) sibuf[i].b, i * 2 + 1);
- }
- }
+ for (i = 0; i < 16; i++) {
+ if (sibuf[i].a != (short) (i * 2)) {
+ err++;
+ if (verbose) {
+ fprintf(stderr,
+ "buf[%d] has invalid short (%d); should be %d\n",
+ i, (int) sibuf[i].a, i * 2);
+ }
+ }
+ if (sibuf[i].b != i * 2 + 1) {
+ err++;
+ if (verbose) {
+ fprintf(stderr,
+ "buf[%d] has invalid int (%d); should be %d\n",
+ i, (int) sibuf[i].b, i * 2 + 1);
+ }
+ }
}
return errs;
@@ -104,87 +103,64 @@ int short_int_pack_test(void)
* between the pack and unpack steps
*
*/
-static int pack_and_unpack(char *typebuf,
- int count,
- MPI_Datatype datatype,
- int typebufsz)
+static int pack_and_unpack(char *typebuf, int count, MPI_Datatype datatype, int typebufsz)
{
char *packbuf;
int err, errs = 0, pack_size, type_size, position;
err = MPI_Type_size(datatype, &type_size);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in MPI_Type_size call; aborting after %d errors\n",
- errs);
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "error in MPI_Type_size call; aborting after %d errors\n", errs);
+ }
+ return errs;
}
type_size *= count;
err = MPI_Pack_size(count, datatype, MPI_COMM_SELF, &pack_size);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in MPI_Pack_size call; aborting after %d errors\n",
- errs);
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "error in MPI_Pack_size call; aborting after %d errors\n", errs);
+ }
+ return errs;
}
packbuf = (char *) malloc(pack_size);
if (packbuf == NULL) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in malloc call; aborting after %d errors\n",
- errs);
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "error in malloc call; aborting after %d errors\n", errs);
+ }
+ return errs;
}
position = 0;
- err = MPI_Pack(typebuf,
- count,
- datatype,
- packbuf,
- type_size,
- &position,
- MPI_COMM_SELF);
+ err = MPI_Pack(typebuf, count, datatype, packbuf, type_size, &position, MPI_COMM_SELF);
if (position != type_size) {
- errs++;
- if (verbose) fprintf(stderr, "position = %d; should be %d (pack)\n",
- position, type_size);
+ errs++;
+ if (verbose)
+ fprintf(stderr, "position = %d; should be %d (pack)\n", position, type_size);
}
memset(typebuf, 0, typebufsz);
position = 0;
- err = MPI_Unpack(packbuf,
- type_size,
- &position,
- typebuf,
- count,
- datatype,
- MPI_COMM_SELF);
+ err = MPI_Unpack(packbuf, type_size, &position, typebuf, count, datatype, MPI_COMM_SELF);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in MPI_Unpack call; aborting after %d errors\n",
- errs);
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "error in MPI_Unpack call; aborting after %d errors\n", errs);
+ }
+ return errs;
}
free(packbuf);
if (position != type_size) {
- errs++;
- if (verbose) fprintf(stderr, "position = %d; should be %d (unpack)\n",
- position, type_size);
+ errs++;
+ if (verbose)
+ fprintf(stderr, "position = %d; should be %d (unpack)\n", position, type_size);
}
return errs;
@@ -193,18 +169,18 @@ static int pack_and_unpack(char *typebuf,
int parse_args(int argc, char **argv)
{
/*
- int ret;
-
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
- }
- */
+ * int ret;
+ *
+ * while ((ret = getopt(argc, argv, "v")) >= 0)
+ * {
+ * switch (ret) {
+ * case 'v':
+ * verbose = 1;
+ * break;
+ * }
+ * }
+ */
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
return 0;
}
diff --git a/test/mpi/datatype/pairtype-size-extent.c b/test/mpi/datatype/pairtype-size-extent.c
index 37f21fc..441661a 100644
--- a/test/mpi/datatype/pairtype-size-extent.c
+++ b/test/mpi/datatype/pairtype-size-extent.c
@@ -13,15 +13,17 @@
static int verbose = 1;
-static struct { MPI_Datatype atype, ptype; char name[32]; }
-pairtypes[] =
- { {MPI_FLOAT, MPI_FLOAT_INT, "MPI_FLOAT_INT"},
- {MPI_DOUBLE, MPI_DOUBLE_INT, "MPI_DOUBLE_INT"},
- {MPI_LONG, MPI_LONG_INT, "MPI_LONG_INT"},
- {MPI_SHORT, MPI_SHORT_INT, "MPI_SHORT_INT"},
- {MPI_LONG_DOUBLE, MPI_LONG_DOUBLE_INT, "MPI_LONG_DOUBLE_INT"},
- {(MPI_Datatype) -1, (MPI_Datatype) -1, "end"}
- };
+static struct {
+ MPI_Datatype atype, ptype;
+ char name[32];
+} pairtypes[] = { {
+MPI_FLOAT, MPI_FLOAT_INT, "MPI_FLOAT_INT"}, {
+MPI_DOUBLE, MPI_DOUBLE_INT, "MPI_DOUBLE_INT"}, {
+MPI_LONG, MPI_LONG_INT, "MPI_LONG_INT"}, {
+MPI_SHORT, MPI_SHORT_INT, "MPI_SHORT_INT"}, {
+MPI_LONG_DOUBLE, MPI_LONG_DOUBLE_INT, "MPI_LONG_DOUBLE_INT"}, {
+(MPI_Datatype) - 1, (MPI_Datatype) - 1, "end"}
+};
int parse_args(int argc, char **argv);
@@ -31,35 +33,50 @@ MPI_Aint pairtype_displacement(MPI_Datatype type, int *out_size_p)
{
MPI_Aint disp;
- /* Note that a portable test may not use a switch statement for
- datatypes, as they are not required to be compile-time constants */
+ /* Note that a portable test may not use a switch statement for
+ * datatypes, as they are not required to be compile-time constants */
if (type == MPI_FLOAT_INT) {
- struct { float a; int b; } foo;
- disp = (MPI_Aint) ((char *) &foo.b - (char *) &foo.a);
- *out_size_p = sizeof(foo);
+ struct {
+ float a;
+ int b;
+ } foo;
+ disp = (MPI_Aint) ((char *) &foo.b - (char *) &foo.a);
+ *out_size_p = sizeof(foo);
}
else if (type == MPI_DOUBLE_INT) {
- struct { double a; int b; } foo;
- disp = (MPI_Aint) ((char *) &foo.b - (char *) &foo.a);
- *out_size_p = sizeof(foo);
+ struct {
+ double a;
+ int b;
+ } foo;
+ disp = (MPI_Aint) ((char *) &foo.b - (char *) &foo.a);
+ *out_size_p = sizeof(foo);
}
else if (type == MPI_LONG_INT) {
- struct { long a; int b; } foo;
- disp = (MPI_Aint) ((char *) &foo.b - (char *) &foo.a);
- *out_size_p = sizeof(foo);
+ struct {
+ long a;
+ int b;
+ } foo;
+ disp = (MPI_Aint) ((char *) &foo.b - (char *) &foo.a);
+ *out_size_p = sizeof(foo);
}
else if (type == MPI_SHORT_INT) {
- struct { short a; int b; } foo;
- disp = (MPI_Aint) ((char *) &foo.b - (char *) &foo.a);
- *out_size_p = sizeof(foo);
+ struct {
+ short a;
+ int b;
+ } foo;
+ disp = (MPI_Aint) ((char *) &foo.b - (char *) &foo.a);
+ *out_size_p = sizeof(foo);
}
else if (type == MPI_LONG_DOUBLE_INT && type != MPI_DATATYPE_NULL) {
- struct { long double a; int b; } foo;
- disp = (MPI_Aint) ((char *) &foo.b - (char *) &foo.a);
- *out_size_p = sizeof(foo);
+ struct {
+ long double a;
+ int b;
+ } foo;
+ disp = (MPI_Aint) ((char *) &foo.b - (char *) &foo.a);
+ *out_size_p = sizeof(foo);
}
else {
- disp = -1;
+ disp = -1;
}
return disp;
}
@@ -69,62 +86,63 @@ int main(int argc, char *argv[])
int errs = 0;
int i;
- int blks[2] = {1, 1};
- MPI_Aint disps[2] = {0, 0};
- MPI_Datatype types[2] = {MPI_INT, MPI_INT};
+ int blks[2] = { 1, 1 };
+ MPI_Aint disps[2] = { 0, 0 };
+ MPI_Datatype types[2] = { MPI_INT, MPI_INT };
MPI_Datatype stype;
-
+
MPI_Init(&argc, &argv);
parse_args(argc, argv);
- for (i=0; pairtypes[i].atype != (MPI_Datatype) -1; i++) {
- int atype_size, ptype_size, stype_size, handbuilt_extent;
- MPI_Aint ptype_extent, stype_extent, dummy_lb;
-
- types[0] = pairtypes[i].atype;
-
- /* Check for undefined optional types, such as
- LONG_DOUBLE_INT (if, for example, long double or
- long long are not supported) */
- if (types[0] == MPI_DATATYPE_NULL) continue;
-
- MPI_Type_size(types[0], &atype_size);
- disps[1] = pairtype_displacement(pairtypes[i].ptype,
- &handbuilt_extent);
-
- MPI_Type_create_struct(2, blks, disps, types, &stype);
-
- MPI_Type_size(stype, &stype_size);
- MPI_Type_size(pairtypes[i].ptype, &ptype_size);
- if (stype_size != ptype_size) {
- errs++;
-
- if (verbose) fprintf(stderr,
- "size of %s (%d) does not match size of hand-built MPI struct (%d)\n",
- pairtypes[i].name, ptype_size, stype_size);
- }
-
- MPI_Type_get_extent(stype, &dummy_lb, &stype_extent);
- MPI_Type_get_extent(pairtypes[i].ptype, &dummy_lb, &ptype_extent);
- if (stype_extent != ptype_extent || stype_extent != handbuilt_extent) {
- errs++;
-
- if (verbose) fprintf(stderr,
- "extent of %s (%d) does not match extent of either hand-built MPI struct (%d) or equivalent C struct (%d)\n",
- pairtypes[i].name, (int) ptype_extent,
- (int) stype_extent,
- handbuilt_extent);
- }
- MPI_Type_free( &stype );
+ for (i = 0; pairtypes[i].atype != (MPI_Datatype) - 1; i++) {
+ int atype_size, ptype_size, stype_size, handbuilt_extent;
+ MPI_Aint ptype_extent, stype_extent, dummy_lb;
+
+ types[0] = pairtypes[i].atype;
+
+ /* Check for undefined optional types, such as
+ * LONG_DOUBLE_INT (if, for example, long double or
+ * long long are not supported) */
+ if (types[0] == MPI_DATATYPE_NULL)
+ continue;
+
+ MPI_Type_size(types[0], &atype_size);
+ disps[1] = pairtype_displacement(pairtypes[i].ptype, &handbuilt_extent);
+
+ MPI_Type_create_struct(2, blks, disps, types, &stype);
+
+ MPI_Type_size(stype, &stype_size);
+ MPI_Type_size(pairtypes[i].ptype, &ptype_size);
+ if (stype_size != ptype_size) {
+ errs++;
+
+ if (verbose)
+ fprintf(stderr,
+ "size of %s (%d) does not match size of hand-built MPI struct (%d)\n",
+ pairtypes[i].name, ptype_size, stype_size);
+ }
+
+ MPI_Type_get_extent(stype, &dummy_lb, &stype_extent);
+ MPI_Type_get_extent(pairtypes[i].ptype, &dummy_lb, &ptype_extent);
+ if (stype_extent != ptype_extent || stype_extent != handbuilt_extent) {
+ errs++;
+
+ if (verbose)
+ fprintf(stderr,
+ "extent of %s (%d) does not match extent of either hand-built MPI struct (%d) or equivalent C struct (%d)\n",
+ pairtypes[i].name, (int) ptype_extent,
+ (int) stype_extent, handbuilt_extent);
+ }
+ MPI_Type_free(&stype);
}
-
+
/* print message and exit */
if (errs) {
- fprintf(stderr, "Found %d errors\n", errs);
+ fprintf(stderr, "Found %d errors\n", errs);
}
else {
- printf(" No Errors\n");
+ printf(" No Errors\n");
}
MPI_Finalize();
return 0;
@@ -134,8 +152,8 @@ int parse_args(int argc, char **argv)
{
/* We use a simple test because getopt isn't universally available */
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
if (argc > 1 && strcmp(argv[1], "-nov") == 0)
- verbose = 0;
+ verbose = 0;
return 0;
}
diff --git a/test/mpi/datatype/segtest.c b/test/mpi/datatype/segtest.c
index 78ad55a..9148d6f 100644
--- a/test/mpi/datatype/segtest.c
+++ b/test/mpi/datatype/segtest.c
@@ -7,11 +7,11 @@
#include "mpiimpl.h"
#include <stdio.h>
-/*
+/*
* Simple segment test, including timing code
*/
-/*
+/*
* Build datatype structures
*
* Contiguous
@@ -24,12 +24,12 @@
* offsets = i*24 for i = 0 to n, n = 0, 64, 512
* Indexed
* blocksizes = 1, 2, 4, 3, 7, 5, 6
- * offsets = i*24 for i = 0 to n, n = 0, 4, 7, 64, 512
+ * offsets = i*24 for i = 0 to n, n = 0, 4, 7, 64, 512
* (Wrap blocksizes to match offsets)
*
* Also need a few nested datatypes, such as vector of vectors
* Do the versions in Using MPI
- *
+ *
*/
/*
@@ -38,16 +38,16 @@
/*
* Contig
*/
-MPID_Dataloop *MPID_Dataloop_init_contig( int count )
+MPID_Dataloop *MPID_Dataloop_init_contig(int count)
{
MPID_Dataloop *ct;
-
- ct = (MPID_Dataloop *)MPIU_Malloc( sizeof(MPID_Dataloop ) );
- ct->kind = MPID_DTYPE_CONTIG | DATALOOP_FINAL_MASK;
- ct->loop_params.c_t.count = count;
+
+ ct = (MPID_Dataloop *) MPIU_Malloc(sizeof(MPID_Dataloop));
+ ct->kind = MPID_DTYPE_CONTIG | DATALOOP_FINAL_MASK;
+ ct->loop_params.c_t.count = count;
ct->loop_params.c_t.dataloop = 0;
- ct->extent = count;
- ct->handle = 0;
+ ct->extent = count;
+ ct->handle = 0;
return ct;
}
@@ -55,155 +55,149 @@ MPID_Dataloop *MPID_Dataloop_init_contig( int count )
/*
* Vector
*/
-MPID_Dataloop *MPID_Dataloop_init_vector( int count, int blocksize,
- int stride )
+MPID_Dataloop *MPID_Dataloop_init_vector(int count, int blocksize, int stride)
{
MPID_Dataloop *v;
- v = (MPID_Dataloop *)MPIU_Malloc( sizeof(MPID_Dataloop) );
- v->kind = MPID_DTYPE_VECTOR | DATALOOP_FINAL_MASK;
- v->loop_params.v_t.count = count;
+ v = (MPID_Dataloop *) MPIU_Malloc(sizeof(MPID_Dataloop));
+ v->kind = MPID_DTYPE_VECTOR | DATALOOP_FINAL_MASK;
+ v->loop_params.v_t.count = count;
v->loop_params.v_t.blocksize = blocksize;
- v->loop_params.v_t.stride = stride;
- v->loop_params.v_t.dataloop = 0;
- v->extent = (count-1)*stride + blocksize;
- v->handle = 0;
+ v->loop_params.v_t.stride = stride;
+ v->loop_params.v_t.dataloop = 0;
+ v->extent = (count - 1) * stride + blocksize;
+ v->handle = 0;
return v;
}
-/*
+/*
* Block indexed
*/
-MPID_Dataloop *MPID_Dataloop_init_blockindexed( int count, int blocksize,
- MPI_Aint *offset )
+MPID_Dataloop *MPID_Dataloop_init_blockindexed(int count, int blocksize, MPI_Aint * offset)
{
MPID_Dataloop *bi;
- MPI_Aint extent;
- int i;
+ MPI_Aint extent;
+ int i;
- bi = (MPID_Dataloop *)MPIU_Malloc( sizeof(MPID_Dataloop) );
- bi->kind = MPID_DTYPE_BLOCKINDEXED | DATALOOP_FINAL_MASK;
- bi->loop_params.bi_t.count = count;
+ bi = (MPID_Dataloop *) MPIU_Malloc(sizeof(MPID_Dataloop));
+ bi->kind = MPID_DTYPE_BLOCKINDEXED | DATALOOP_FINAL_MASK;
+ bi->loop_params.bi_t.count = count;
bi->loop_params.bi_t.blocksize = blocksize;
- bi->loop_params.bi_t.offset =
- (MPI_Aint *)MPIU_Malloc( sizeof(MPI_Aint) * count );
- for (i=0; i<count; i++) {
- bi->loop_params.bi_t.offset[i] = offset[i];
- if (offset[i] + blocksize > extent)
- extent = offset[i] + blocksize;
+ bi->loop_params.bi_t.offset = (MPI_Aint *) MPIU_Malloc(sizeof(MPI_Aint) * count);
+ for (i = 0; i < count; i++) {
+ bi->loop_params.bi_t.offset[i] = offset[i];
+ if (offset[i] + blocksize > extent)
+ extent = offset[i] + blocksize;
}
- bi->loop_params.bi_t.dataloop = 0;
- bi->extent = extent;
- bi->handle = 0;
+ bi->loop_params.bi_t.dataloop = 0;
+ bi->extent = extent;
+ bi->handle = 0;
return bi;
}
/*
- * Indexed
+ * Indexed
*/
-MPID_Dataloop *MPID_Dataloop_init_indexed( int count, int *blocksize,
- MPI_Aint *offset )
+MPID_Dataloop *MPID_Dataloop_init_indexed(int count, int *blocksize, MPI_Aint * offset)
{
MPID_Dataloop *it;
- MPI_Aint extent = 0;
- int i;
-
- it = (MPID_Dataloop *)MPIU_Malloc( sizeof(MPID_Dataloop) );
- it->kind = MPID_DTYPE_INDEXED | DATALOOP_FINAL_MASK;
- it->loop_params.i_t.count = count;
- it->loop_params.i_t.blocksize = (int *)MPIU_Malloc( sizeof(int) * count );
- it->loop_params.i_t.offset =
- (MPI_Aint *)MPIU_Malloc( sizeof(MPI_Aint) * count );
- for (i=0; i<count; i++) {
- it->loop_params.i_t.offset[i] = offset[i];
- it->loop_params.i_t.blocksize[i] = blocksize[i];
- if (offset[i] + blocksize[i] > extent)
- extent = offset[i] + blocksize[i];
+ MPI_Aint extent = 0;
+ int i;
+
+ it = (MPID_Dataloop *) MPIU_Malloc(sizeof(MPID_Dataloop));
+ it->kind = MPID_DTYPE_INDEXED | DATALOOP_FINAL_MASK;
+ it->loop_params.i_t.count = count;
+ it->loop_params.i_t.blocksize = (int *) MPIU_Malloc(sizeof(int) * count);
+ it->loop_params.i_t.offset = (MPI_Aint *) MPIU_Malloc(sizeof(MPI_Aint) * count);
+ for (i = 0; i < count; i++) {
+ it->loop_params.i_t.offset[i] = offset[i];
+ it->loop_params.i_t.blocksize[i] = blocksize[i];
+ if (offset[i] + blocksize[i] > extent)
+ extent = offset[i] + blocksize[i];
}
- it->loop_params.i_t.dataloop = 0;
- it->extent = extent;
- it->handle = 0;
+ it->loop_params.i_t.dataloop = 0;
+ it->extent = extent;
+ it->handle = 0;
return it;
}
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
/* MPID_Dataloop *vecloop; */
MPI_Datatype vectype;
- int count=200, blocksize=4, stride = 7*4;
+ int count = 200, blocksize = 4, stride = 7 * 4;
char *src_buf, *dest_buf;
- int i,j,k;
+ int i, j, k;
double r1, r2;
- MPI_Init( &argc, &argv );
-
-/* vecloop = MPID_Dataloop_init_vector( count, blocksize, stride ); */
+ MPI_Init(&argc, &argv);
- MPI_Type_vector( count, 1, 7, MPI_INT, &vectype );
+/* vecloop = MPID_Dataloop_init_vector(count, blocksize, stride); */
+
+ MPI_Type_vector(count, 1, 7, MPI_INT, &vectype);
/* Initialize the data */
- src_buf = (char *)MPIU_Malloc( (count - 1) * stride + blocksize );
- for (i=0; i<(count-1)*stride+blocksize; i++)
- src_buf[i] = -i;
- for (i=0; i<count; i++) {
- for (j=0; j<blocksize; j++)
- src_buf[i*stride+j] = i*blocksize + j;
+ src_buf = (char *) MPIU_Malloc((count - 1) * stride + blocksize);
+ for (i = 0; i < (count - 1) * stride + blocksize; i++)
+ src_buf[i] = -i;
+ for (i = 0; i < count; i++) {
+ for (j = 0; j < blocksize; j++)
+ src_buf[i * stride + j] = i * blocksize + j;
}
- dest_buf = (char *)MPIU_Malloc( count*blocksize );
- for (i=0; i<count*blocksize; i++) {
- dest_buf[i] = -i;
+ dest_buf = (char *) MPIU_Malloc(count * blocksize);
+ for (i = 0; i < count * blocksize; i++) {
+ dest_buf[i] = -i;
}
r1 = MPI_Wtime();
- for (i=0; i<100; i++) {
- int position = 0;
- /*MPID_Segment_pack( vecloop, src_buf, dest_buf );*/
- MPI_Pack( src_buf, count, vectype, dest_buf, count*blocksize,
- &position, MPI_COMM_WORLD );
+ for (i = 0; i < 100; i++) {
+ int position = 0;
+ /*MPID_Segment_pack(vecloop, src_buf, dest_buf); */
+ MPI_Pack(src_buf, count, vectype, dest_buf, count * blocksize, &position, MPI_COMM_WORLD);
}
r2 = MPI_Wtime();
- printf( "Timer for vector pack is %e\n", (r2-r1)/100 );
- for (i=0; i<count*blocksize; i++) {
- if (dest_buf[i] != (char)i) {
- printf( "Error at location %d\n", i );
- }
+ printf("Timer for vector pack is %e\n", (r2 - r1) / 100);
+ for (i = 0; i < count * blocksize; i++) {
+ if (dest_buf[i] != (char) i) {
+ printf("Error at location %d\n", i);
+ }
}
r1 = MPI_Wtime();
- for (k=0; k<100; k++) {
- char *dest=dest_buf, *src=src_buf;
- for (i=0; i<count; i++) {
- for (j=0; j<blocksize; j++)
- *dest++ = src[j];
- src+= stride;
- }
+ for (k = 0; k < 100; k++) {
+ char *dest = dest_buf, *src = src_buf;
+ for (i = 0; i < count; i++) {
+ for (j = 0; j < blocksize; j++)
+ *dest++ = src[j];
+ src += stride;
+ }
}
r2 = MPI_Wtime();
- printf( "Timer for hand vector pack is %e\n", (r2-r1)/100 );
+ printf("Timer for hand vector pack is %e\n", (r2 - r1) / 100);
r1 = MPI_Wtime();
- for (k=0; k<100; k++) {
- int *dest=(int*)dest_buf, *src=(int*)src_buf;
- int bsize = blocksize >> 2;
- int istride = stride >> 2;
- if (bsize == 1) {
- for (i=0; i<count; i++) {
- *dest++ = *src;
- src+= istride;
- }
- }
- else {
- for (i=0; i<count; i++) {
- for (j=0; j<bsize; j++)
- *dest++ = src[j];
- src+= istride;
- }
- }
+ for (k = 0; k < 100; k++) {
+ int *dest = (int *) dest_buf, *src = (int *) src_buf;
+ int bsize = blocksize >> 2;
+ int istride = stride >> 2;
+ if (bsize == 1) {
+ for (i = 0; i < count; i++) {
+ *dest++ = *src;
+ src += istride;
+ }
+ }
+ else {
+ for (i = 0; i < count; i++) {
+ for (j = 0; j < bsize; j++)
+ *dest++ = src[j];
+ src += istride;
+ }
+ }
}
r2 = MPI_Wtime();
- printf( "Timer for hand vector pack (int) is %e\n", (r2-r1)/100 );
-
+ printf("Timer for hand vector pack (int) is %e\n", (r2 - r1) / 100);
+
MPI_Finalize();
return 0;
}
@@ -211,7 +205,7 @@ int main( int argc, char **argv )
/*
* Nested vector.
* The y-z subface is
- * Type_vector( ey-sy+1, 1, nx, MPI_DOUBLE, &newx1 );
- * Type_hvector( ez-sz+1, 1, nx*ny_sizeof(double), newx1, &newx );
+ * Type_vector(ey-sy+1, 1, nx, MPI_DOUBLE, &newx1);
+ * Type_hvector(ez-sz+1, 1, nx*ny_sizeof(double), newx1, &newx);
* This gives the a(i,sy:ey,sz:ez) of a(nx,ny,nz) (in Fortran notation)
*/
diff --git a/test/mpi/datatype/sendrecvt2.c b/test/mpi/datatype/sendrecvt2.c
index acb673d..6c2aa40 100644
--- a/test/mpi/datatype/sendrecvt2.c
+++ b/test/mpi/datatype/sendrecvt2.c
@@ -13,98 +13,96 @@
This program is derived from one in the MPICH-1 test suite. It
tests a wide variety of basic and derived datatypes.
*/
-int main( int argc, char **argv)
+int main(int argc, char **argv)
{
MPI_Datatype *types;
- void **inbufs, **outbufs;
- int *counts, *bytesize, ntype;
- MPI_Comm comm;
- int ncomm = 20, rank, np, partner, tag, count;
- int i, j, k, err, toterr, world_rank, errloc;
- MPI_Status status;
- char *obuf;
- char myname[MPI_MAX_OBJECT_NAME];
- int mynamelen;
+ void **inbufs, **outbufs;
+ int *counts, *bytesize, ntype;
+ MPI_Comm comm;
+ int ncomm = 20, rank, np, partner, tag, count;
+ int i, j, k, err, toterr, world_rank, errloc;
+ MPI_Status status;
+ char *obuf;
+ char myname[MPI_MAX_OBJECT_NAME];
+ int mynamelen;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
/*
* Check for -basiconly to select only the simple datatypes
*/
- for (i=1; i<argc; i++) {
- if (!argv[i]) break;
- if (strcmp( argv[i], "-basiconly" ) == 0) {
- MTestDatatype2BasicOnly();
- }
+ for (i = 1; i < argc; i++) {
+ if (!argv[i])
+ break;
+ if (strcmp(argv[i], "-basiconly") == 0) {
+ MTestDatatype2BasicOnly();
+ }
}
- MTestDatatype2Allocate( &types, &inbufs, &outbufs, &counts, &bytesize,
- &ntype );
- MTestDatatype2Generate( types, inbufs, outbufs, counts, bytesize, &ntype );
+ MTestDatatype2Allocate(&types, &inbufs, &outbufs, &counts, &bytesize, &ntype);
+ MTestDatatype2Generate(types, inbufs, outbufs, counts, bytesize, &ntype);
- MPI_Comm_rank( MPI_COMM_WORLD, &world_rank );
+ MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
- /* Test over a wide range of datatypes and communicators */
+ /* Test over a wide range of datatypes and communicators */
err = 0;
tag = 0;
- while (MTestGetIntracomm( &comm, 2 )) {
- if (comm == MPI_COMM_NULL) continue;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &np );
- if (np < 2) continue;
- if (world_rank == 0)
- MTestPrintfMsg( 10, "Testing communicator number %s\n",
- MTestGetIntracommName() );
+ while (MTestGetIntracomm(&comm, 2)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &np);
+ if (np < 2)
+ continue;
+ if (world_rank == 0)
+ MTestPrintfMsg(10, "Testing communicator number %s\n", MTestGetIntracommName());
- tag++;
- for (j=0; j<ntype; j++) {
- MPI_Type_get_name( types[j], myname, &mynamelen );
- if (world_rank == 0)
- MTestPrintfMsg( 10, "Testing type %s\n", myname );
- if (rank == 0) {
- partner = np - 1;
- MPI_Send( inbufs[j], counts[j], types[j], partner, tag, comm );
+ tag++;
+ for (j = 0; j < ntype; j++) {
+ MPI_Type_get_name(types[j], myname, &mynamelen);
+ if (world_rank == 0)
+ MTestPrintfMsg(10, "Testing type %s\n", myname);
+ if (rank == 0) {
+ partner = np - 1;
+ MPI_Send(inbufs[j], counts[j], types[j], partner, tag, comm);
}
- else if (rank == np-1) {
- partner = 0;
- obuf = outbufs[j];
- for (k=0; k<bytesize[j]; k++)
- obuf[k] = 0;
- MPI_Recv( outbufs[j], counts[j], types[j], partner, tag,
- comm, &status );
- /* Test correct */
- MPI_Get_count( &status, types[j], &count );
- if (count != counts[j]) {
- fprintf( stderr,
- "Error in counts (got %d expected %d) with type %s\n",
- count, counts[j], myname );
- err++;
+ else if (rank == np - 1) {
+ partner = 0;
+ obuf = outbufs[j];
+ for (k = 0; k < bytesize[j]; k++)
+ obuf[k] = 0;
+ MPI_Recv(outbufs[j], counts[j], types[j], partner, tag, comm, &status);
+ /* Test correct */
+ MPI_Get_count(&status, types[j], &count);
+ if (count != counts[j]) {
+ fprintf(stderr,
+ "Error in counts (got %d expected %d) with type %s\n",
+ count, counts[j], myname);
+ err++;
}
- if (status.MPI_SOURCE != partner) {
- fprintf( stderr,
- "Error in source (got %d expected %d) with type %s\n",
- status.MPI_SOURCE, partner, myname );
- err++;
+ if (status.MPI_SOURCE != partner) {
+ fprintf(stderr,
+ "Error in source (got %d expected %d) with type %s\n",
+ status.MPI_SOURCE, partner, myname);
+ err++;
}
- if ((errloc = MTestDatatype2Check( inbufs[j], outbufs[j],
- bytesize[j] ))) {
- char *p1, *p2;
- fprintf( stderr,
- "Error in data with type %s (type %d on %d) at byte %d\n",
- myname, j, world_rank, errloc - 1 );
- p1 = (char *)inbufs[j];
- p2 = (char *)outbufs[j];
- fprintf( stderr,
- "Got %x expected %x\n", p1[errloc-1], p2[errloc-1] );
- err++;
+ if ((errloc = MTestDatatype2Check(inbufs[j], outbufs[j], bytesize[j]))) {
+ char *p1, *p2;
+ fprintf(stderr,
+ "Error in data with type %s (type %d on %d) at byte %d\n",
+ myname, j, world_rank, errloc - 1);
+ p1 = (char *) inbufs[j];
+ p2 = (char *) outbufs[j];
+ fprintf(stderr, "Got %x expected %x\n", p1[errloc - 1], p2[errloc - 1]);
+ err++;
}
}
- }
- MTestFreeComm( &comm );
+ }
+ MTestFreeComm(&comm);
}
- MTestDatatype2Free( types, inbufs, outbufs, counts, bytesize, ntype );
- MTest_Finalize( err );
+ MTestDatatype2Free(types, inbufs, outbufs, counts, bytesize, ntype);
+ MTest_Finalize(err);
MPI_Finalize();
- return MTestReturnValue( err );
+ return MTestReturnValue(err);
}
diff --git a/test/mpi/datatype/sendrecvt4.c b/test/mpi/datatype/sendrecvt4.c
index da8edee..fe35d3e 100644
--- a/test/mpi/datatype/sendrecvt4.c
+++ b/test/mpi/datatype/sendrecvt4.c
@@ -15,139 +15,134 @@
This version sends and receives EVERYTHING from MPI_BOTTOM, by putting
the data into a structure.
*/
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
MPI_Datatype *types;
- void **inbufs, **outbufs;
- int *counts, *bytesize, ntype;
- MPI_Comm comm;
- int ncomm = 20, rank, np, partner, tag, count;
- int j, k, err, toterr, world_rank, errloc;
- MPI_Status status;
- char *obuf;
+ void **inbufs, **outbufs;
+ int *counts, *bytesize, ntype;
+ MPI_Comm comm;
+ int ncomm = 20, rank, np, partner, tag, count;
+ int j, k, err, toterr, world_rank, errloc;
+ MPI_Status status;
+ char *obuf;
MPI_Datatype offsettype;
- int blen;
- MPI_Aint displ, extent, natural_extent;
- char myname[MPI_MAX_OBJECT_NAME];
- int mynamelen;
+ int blen;
+ MPI_Aint displ, extent, natural_extent;
+ char myname[MPI_MAX_OBJECT_NAME];
+ int mynamelen;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MTestDatatype2Allocate( &types, &inbufs, &outbufs, &counts, &bytesize,
- &ntype );
- MTestDatatype2Generate( types, inbufs, outbufs, counts, bytesize, &ntype );
+ MTestDatatype2Allocate(&types, &inbufs, &outbufs, &counts, &bytesize, &ntype);
+ MTestDatatype2Generate(types, inbufs, outbufs, counts, bytesize, &ntype);
- MPI_Comm_rank( MPI_COMM_WORLD, &world_rank );
+ MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
/* Test over a wide range of datatypes and communicators */
err = 0;
tag = 0;
- while (MTestGetIntracomm( &comm, 2 )) {
- if (comm == MPI_COMM_NULL) continue;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &np );
- if (np < 2) continue;
- tag++;
- for (j=0; j<ntype; j++) {
- MPI_Type_get_name( types[j], myname, &mynamelen );
- if (world_rank == 0)
- MTestPrintfMsg( 10, "Testing type %s\n", myname );
- if (rank == 0) {
- MPI_Get_address( inbufs[j], &displ );
- blen = 1;
- MPI_Type_create_struct( 1, &blen, &displ, types + j,
- &offsettype );
- MPI_Type_commit( &offsettype );
- /* Warning: if the type has an explicit MPI_UB, then using a
- simple shift of the offset won't work. For now, we skip
- types whose extents are negative; the correct solution is
- to add, where required, an explicit MPI_UB */
- MPI_Type_extent( offsettype, &extent );
- if (extent < 0) {
- if (world_rank == 0)
- MTestPrintfMsg( 10,
- "... skipping (appears to have explicit MPI_UB\n" );
- MPI_Type_free( &offsettype );
- continue;
- }
- MPI_Type_extent( types[j], &natural_extent );
- if (natural_extent != extent) {
- MPI_Type_free( &offsettype );
- continue;
- }
- partner = np - 1;
- MPI_Send( MPI_BOTTOM, counts[j], offsettype, partner, tag,
- comm );
- MPI_Type_free( &offsettype );
+ while (MTestGetIntracomm(&comm, 2)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &np);
+ if (np < 2)
+ continue;
+ tag++;
+ for (j = 0; j < ntype; j++) {
+ MPI_Type_get_name(types[j], myname, &mynamelen);
+ if (world_rank == 0)
+ MTestPrintfMsg(10, "Testing type %s\n", myname);
+ if (rank == 0) {
+ MPI_Get_address(inbufs[j], &displ);
+ blen = 1;
+ MPI_Type_create_struct(1, &blen, &displ, types + j, &offsettype);
+ MPI_Type_commit(&offsettype);
+ /* Warning: if the type has an explicit MPI_UB, then using a
+ * simple shift of the offset won't work. For now, we skip
+ * types whose extents are negative; the correct solution is
+ * to add, where required, an explicit MPI_UB */
+ MPI_Type_extent(offsettype, &extent);
+ if (extent < 0) {
+ if (world_rank == 0)
+ MTestPrintfMsg(10, "... skipping (appears to have explicit MPI_UB\n");
+ MPI_Type_free(&offsettype);
+ continue;
+ }
+ MPI_Type_extent(types[j], &natural_extent);
+ if (natural_extent != extent) {
+ MPI_Type_free(&offsettype);
+ continue;
+ }
+ partner = np - 1;
+ MPI_Send(MPI_BOTTOM, counts[j], offsettype, partner, tag, comm);
+ MPI_Type_free(&offsettype);
}
- else if (rank == np-1) {
- partner = 0;
- obuf = outbufs[j];
- for (k=0; k<bytesize[j]; k++)
- obuf[k] = 0;
- MPI_Get_address( outbufs[j], &displ );
- blen = 1;
- MPI_Type_create_struct( 1, &blen, &displ, types + j,
- &offsettype );
- MPI_Type_commit( &offsettype );
- /* Warning: if the type has an explicit MPI_UB, then using a
- simple shift of the offset won't work. For now, we skip
- types whose extents are negative; the correct solution is
- to add, where required, an explicit MPI_UB */
- MPI_Type_extent( offsettype, &extent );
- if (extent < 0) {
- MPI_Type_free( &offsettype );
- continue;
- }
- MPI_Type_extent( types[j], &natural_extent );
- if (natural_extent != extent) {
- MPI_Type_free( &offsettype );
- continue;
- }
- MPI_Recv( MPI_BOTTOM, counts[j], offsettype,
- partner, tag, comm, &status );
- /* Test for correctness */
- MPI_Get_count( &status, types[j], &count );
- if (count != counts[j]) {
- fprintf( stderr,
- "Error in counts (got %d expected %d) with type %s\n",
- count, counts[j], myname );
- err++;
+ else if (rank == np - 1) {
+ partner = 0;
+ obuf = outbufs[j];
+ for (k = 0; k < bytesize[j]; k++)
+ obuf[k] = 0;
+ MPI_Get_address(outbufs[j], &displ);
+ blen = 1;
+ MPI_Type_create_struct(1, &blen, &displ, types + j, &offsettype);
+ MPI_Type_commit(&offsettype);
+ /* Warning: if the type has an explicit MPI_UB, then using a
+ * simple shift of the offset won't work. For now, we skip
+ * types whose extents are negative; the correct solution is
+ * to add, where required, an explicit MPI_UB */
+ MPI_Type_extent(offsettype, &extent);
+ if (extent < 0) {
+ MPI_Type_free(&offsettype);
+ continue;
+ }
+ MPI_Type_extent(types[j], &natural_extent);
+ if (natural_extent != extent) {
+ MPI_Type_free(&offsettype);
+ continue;
+ }
+ MPI_Recv(MPI_BOTTOM, counts[j], offsettype, partner, tag, comm, &status);
+ /* Test for correctness */
+ MPI_Get_count(&status, types[j], &count);
+ if (count != counts[j]) {
+ fprintf(stderr,
+ "Error in counts (got %d expected %d) with type %s\n",
+ count, counts[j], myname);
+ err++;
}
- if (status.MPI_SOURCE != partner) {
- fprintf( stderr,
- "Error in source (got %d expected %d) with type %s\n",
- status.MPI_SOURCE, partner, myname );
- err++;
+ if (status.MPI_SOURCE != partner) {
+ fprintf(stderr,
+ "Error in source (got %d expected %d) with type %s\n",
+ status.MPI_SOURCE, partner, myname);
+ err++;
}
- if ((errloc = MTestDatatype2Check( inbufs[j], outbufs[j],
- bytesize[j] ))) {
- fprintf( stderr,
- "Error in data with type %s (type %d on %d) at byte %d\n",
- myname, j, world_rank, errloc - 1 );
- if (err < 10) {
- /* Give details on only the first 10 errors */
- unsigned char *in_p = (unsigned char *)inbufs[j],
- *out_p = (unsigned char *)outbufs[j];
- int jj;
- jj = errloc - 1;
- jj &= 0xfffffffc; /* lop off a few bits */
- in_p += jj;
- out_p += jj;
- fprintf( stderr, "%02x%02x%02x%02x should be %02x%02x%02x%02x\n",
- out_p[0], out_p[1], out_p[2], out_p[3],
- in_p[0], in_p[1], in_p[2], in_p[3] );
- }
- err++;
+ if ((errloc = MTestDatatype2Check(inbufs[j], outbufs[j], bytesize[j]))) {
+ fprintf(stderr,
+ "Error in data with type %s (type %d on %d) at byte %d\n",
+ myname, j, world_rank, errloc - 1);
+ if (err < 10) {
+ /* Give details on only the first 10 errors */
+ unsigned char *in_p = (unsigned char *) inbufs[j],
+ *out_p = (unsigned char *) outbufs[j];
+ int jj;
+ jj = errloc - 1;
+ jj &= 0xfffffffc; /* lop off a few bits */
+ in_p += jj;
+ out_p += jj;
+ fprintf(stderr, "%02x%02x%02x%02x should be %02x%02x%02x%02x\n",
+ out_p[0], out_p[1], out_p[2], out_p[3],
+ in_p[0], in_p[1], in_p[2], in_p[3]);
+ }
+ err++;
}
- MPI_Type_free( &offsettype );
+ MPI_Type_free(&offsettype);
}
- }
- MTestFreeComm( &comm );
+ }
+ MTestFreeComm(&comm);
}
- MTestDatatype2Free( types, inbufs, outbufs, counts, bytesize, ntype );
- MTest_Finalize( err );
+ MTestDatatype2Free(types, inbufs, outbufs, counts, bytesize, ntype);
+ MTest_Finalize(err);
MPI_Finalize();
- return MTestReturnValue( err );
+ return MTestReturnValue(err);
}
diff --git a/test/mpi/datatype/simple-commit.c b/test/mpi/datatype/simple-commit.c
index 2caa4e8..af79be3 100644
--- a/test/mpi/datatype/simple-commit.c
+++ b/test/mpi/datatype/simple-commit.c
@@ -26,33 +26,33 @@ int main(int argc, char **argv)
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
type = MPI_INT;
mpi_err = MPI_Type_commit(&type);
if (mpi_err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr, "MPI_Type_commit of MPI_INT failed.\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Type_commit of MPI_INT failed.\n");
+ }
+ errs++;
}
type = MPI_FLOAT_INT;
mpi_err = MPI_Type_commit(&type);
if (mpi_err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr, "MPI_Type_commit of MPI_FLOAT_INT failed.\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Type_commit of MPI_FLOAT_INT failed.\n");
+ }
+ errs++;
}
/* print message and exit */
if (errs) {
- fprintf(stderr, "Found %d errors\n", errs);
+ fprintf(stderr, "Found %d errors\n", errs);
}
else {
- printf(" No Errors\n");
+ printf(" No Errors\n");
}
MPI_Finalize();
return 0;
@@ -61,18 +61,18 @@ int main(int argc, char **argv)
int parse_args(int argc, char **argv)
{
/*
- int ret;
-
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
- }
- */
+ * int ret;
+ *
+ * while ((ret = getopt(argc, argv, "v")) >= 0)
+ * {
+ * switch (ret) {
+ * case 'v':
+ * verbose = 1;
+ * break;
+ * }
+ * }
+ */
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
return 0;
}
diff --git a/test/mpi/datatype/simple-pack-external.c b/test/mpi/datatype/simple-pack-external.c
index 43f421c..ce67a32 100644
--- a/test/mpi/datatype/simple-pack-external.c
+++ b/test/mpi/datatype/simple-pack-external.c
@@ -29,31 +29,31 @@ int main(int argc, char **argv)
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
/* perform some tests */
err = builtin_float_test();
- if (err && verbose) fprintf(stderr, "%d errors in builtin float test.\n",
- err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in builtin float test.\n", err);
errs += err;
err = vector_of_vectors_test();
- if (err && verbose) fprintf(stderr,
- "%d errors in vector of vectors test.\n", err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in vector of vectors test.\n", err);
errs += err;
err = optimizable_vector_of_basics_test();
- if (err && verbose) fprintf(stderr,
- "%d errors in vector of basics test.\n", err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in vector of basics test.\n", err);
errs += err;
err = struct_of_basics_test();
- if (err && verbose) fprintf(stderr,
- "%d errors in struct of basics test.\n", err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in struct of basics test.\n", err);
errs += err;
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
@@ -70,13 +70,10 @@ int builtin_float_test(void)
int err, errs = 0;
- err = MPI_Type_get_envelope(MPI_FLOAT,
- &nints,
- &nadds,
- &ntypes,
- &combiner);
-
- if (combiner != MPI_COMBINER_NAMED) errs++;
+ err = MPI_Type_get_envelope(MPI_FLOAT, &nints, &nadds, &ntypes, &combiner);
+
+ if (combiner != MPI_COMBINER_NAMED)
+ errs++;
/* Note: it is erroneous to call MPI_Type_get_contents() on a basic. */
return errs;
@@ -84,7 +81,7 @@ int builtin_float_test(void)
/* vector_of_vectors_test()
*
- * Builds a vector of a vector of ints. Assuming an int array of size 9
+ * Builds a vector of a vector of ints. Assuming an int array of size 9
* integers, and treating the array as a 3x3 2D array, this will grab the
* corners.
*
@@ -94,108 +91,91 @@ int vector_of_vectors_test(void)
{
MPI_Datatype inner_vector;
MPI_Datatype outer_vector;
- int array[9] = { 1, -1, 2,
- -2, -3, -4,
- 3, -5, 4 };
+ int array[9] = { 1, -1, 2,
+ -2, -3, -4,
+ 3, -5, 4
+ };
char *buf;
int i, err, errs = 0;
MPI_Aint sizeoftype, position;
/* set up type */
- err = MPI_Type_vector(2,
- 1,
- 2,
- MPI_INT,
- &inner_vector);
+ err = MPI_Type_vector(2, 1, 2, MPI_INT, &inner_vector);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr,
- "error in MPI call; aborting after %d errors\n",
- errs+1);
- return errs;
+ errs++;
+ if (verbose)
+ fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
+ return errs;
}
- err = MPI_Type_vector(2,
- 1,
- 2,
- inner_vector,
- &outer_vector);
+ err = MPI_Type_vector(2, 1, 2, inner_vector, &outer_vector);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr,
- "error in MPI call; aborting after %d errors\n",
- errs+1);
- return errs;
+ errs++;
+ if (verbose)
+ fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
+ return errs;
}
MPI_Type_commit(&outer_vector);
- MPI_Pack_external_size((char*)"external32", 1, outer_vector, &sizeoftype);
- if (sizeoftype != 4*4) {
- errs++;
- if (verbose) fprintf(stderr, "size of type = %d; should be %d\n",
- (int) sizeoftype, 4*4);
- return errs;
+ MPI_Pack_external_size((char *) "external32", 1, outer_vector, &sizeoftype);
+ if (sizeoftype != 4 * 4) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "size of type = %d; should be %d\n", (int) sizeoftype, 4 * 4);
+ return errs;
}
buf = (char *) malloc(sizeoftype);
position = 0;
- err = MPI_Pack_external((char*)"external32",
- array,
- 1,
- outer_vector,
- buf,
- sizeoftype,
- &position);
+ err = MPI_Pack_external((char *) "external32",
+ array, 1, outer_vector, buf, sizeoftype, &position);
if (position != sizeoftype) {
- errs++;
- if (verbose) fprintf(stderr, "position = %d; should be %d (pack)\n",
- (int) position, (int) sizeoftype);
+ errs++;
+ if (verbose)
+ fprintf(stderr, "position = %d; should be %d (pack)\n",
+ (int) position, (int) sizeoftype);
}
- memset(array, 0, 9*sizeof(int));
+ memset(array, 0, 9 * sizeof(int));
position = 0;
- err = MPI_Unpack_external((char*)"external32",
- buf,
- sizeoftype,
- &position,
- array,
- 1,
- outer_vector);
+ err = MPI_Unpack_external((char *) "external32",
+ buf, sizeoftype, &position, array, 1, outer_vector);
if (position != sizeoftype) {
- errs++;
- if (verbose) fprintf(stderr, "position = %d; should be %d (unpack)\n",
- (int) position, (int) sizeoftype);
+ errs++;
+ if (verbose)
+ fprintf(stderr, "position = %d; should be %d (unpack)\n",
+ (int) position, (int) sizeoftype);
}
- for (i=0; i < 9; i++) {
- int goodval;
- switch (i) {
- case 0:
- goodval = 1;
- break;
- case 2:
- goodval = 2;
- break;
- case 6:
- goodval = 3;
- break;
- case 8:
- goodval = 4;
- break;
- default:
- goodval = 0;
- break;
- }
- if (array[i] != goodval) {
- errs++;
- if (verbose) fprintf(stderr, "array[%d] = %d; should be %d\n",
- i, array[i], goodval);
- }
+ for (i = 0; i < 9; i++) {
+ int goodval;
+ switch (i) {
+ case 0:
+ goodval = 1;
+ break;
+ case 2:
+ goodval = 2;
+ break;
+ case 6:
+ goodval = 3;
+ break;
+ case 8:
+ goodval = 4;
+ break;
+ default:
+ goodval = 0;
+ break;
+ }
+ if (array[i] != goodval) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "array[%d] = %d; should be %d\n", i, array[i], goodval);
+ }
}
MPI_Type_free(&inner_vector);
@@ -214,80 +194,68 @@ int optimizable_vector_of_basics_test(void)
{
MPI_Datatype parent_type;
int array[20] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19 };
+ 16, 17, 18, 19
+ };
char *buf;
int i;
MPI_Aint sizeofint, sizeoftype, position;
int err, errs = 0;
- MPI_Pack_external_size((char*)"external32", 1, MPI_INT, &sizeofint);
+ MPI_Pack_external_size((char *) "external32", 1, MPI_INT, &sizeofint);
if (sizeofint != 4) {
- errs++;
- if (verbose) fprintf(stderr,
- "size of external32 MPI_INT = %d; should be %d\n",
- (int) sizeofint, 4);
+ errs++;
+ if (verbose)
+ fprintf(stderr, "size of external32 MPI_INT = %d; should be %d\n", (int) sizeofint, 4);
}
/* set up type */
- err = MPI_Type_vector(10,
- 2,
- 2,
- MPI_INT,
- &parent_type);
+ err = MPI_Type_vector(10, 2, 2, MPI_INT, &parent_type);
MPI_Type_commit(&parent_type);
- MPI_Pack_external_size((char*)"external32", 1, parent_type, &sizeoftype);
+ MPI_Pack_external_size((char *) "external32", 1, parent_type, &sizeoftype);
if (sizeoftype != 20 * sizeofint) {
- errs++;
- if (verbose) fprintf(stderr, "size of vector = %d; should be %d\n",
- (int) sizeoftype, (int) (20 * sizeofint));
+ errs++;
+ if (verbose)
+ fprintf(stderr, "size of vector = %d; should be %d\n",
+ (int) sizeoftype, (int) (20 * sizeofint));
}
buf = (char *) malloc(sizeoftype);
position = 0;
- err = MPI_Pack_external((char*)"external32",
- array,
- 1,
- parent_type,
- buf,
- sizeoftype,
- &position);
+ err = MPI_Pack_external((char *) "external32",
+ array, 1, parent_type, buf, sizeoftype, &position);
if (position != sizeoftype) {
- errs++;
- if (verbose) fprintf(stderr, "position = %d; should be %d (pack)\n",
- (int) position, (int) sizeoftype);
+ errs++;
+ if (verbose)
+ fprintf(stderr, "position = %d; should be %d (pack)\n",
+ (int) position, (int) sizeoftype);
}
memset(array, 0, 20 * sizeof(int));
position = 0;
- err = MPI_Unpack_external((char*)"external32",
- buf,
- sizeoftype,
- &position,
- array,
- 1,
- parent_type);
+ err = MPI_Unpack_external((char *) "external32",
+ buf, sizeoftype, &position, array, 1, parent_type);
if (position != sizeoftype) {
- errs++;
- if (verbose) fprintf(stderr,
- "position = %ld; should be %ld (unpack)\n",
- (long) position, (long) sizeoftype);
+ errs++;
+ if (verbose)
+ fprintf(stderr,
+ "position = %ld; should be %ld (unpack)\n", (long) position, (long) sizeoftype);
}
- for (i=0; i < 20; i++) {
- if (array[i] != i) {
- errs++;
- if (verbose) fprintf(stderr, "array[%d] = %d; should be %d\n",
- i, array[i], i);
- }
+ for (i = 0; i < 20; i++) {
+ if (array[i] != i) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "array[%d] = %d; should be %d\n", i, array[i], i);
+ }
}
MPI_Type_free(&parent_type);
@@ -305,7 +273,8 @@ int struct_of_basics_test(void)
{
MPI_Datatype parent_type;
int array[20] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19 };
+ 16, 17, 18, 19
+ };
char *buf;
int i;
MPI_Aint sizeofint, sizeoftype, position;
@@ -315,80 +284,67 @@ int struct_of_basics_test(void)
int err, errs = 0;
- MPI_Pack_external_size((char*)"external32", 1, MPI_INT, &sizeofint);
+ MPI_Pack_external_size((char *) "external32", 1, MPI_INT, &sizeofint);
if (sizeofint != 4) {
- errs++;
- if (verbose) fprintf(stderr,
- "size of external32 MPI_INT = %d; should be %d\n",
- (int) sizeofint, 4);
+ errs++;
+ if (verbose)
+ fprintf(stderr, "size of external32 MPI_INT = %d; should be %d\n", (int) sizeofint, 4);
}
for (i = 0; i < 10; i++) {
- blocks[i] = 2;
- indices[i] = 2 * i * sizeofint;
- /* This will cause MPICH to consider this as a blockindex. We
- * need different types here. */
- types[i] = MPI_INT;
+ blocks[i] = 2;
+ indices[i] = 2 * i * sizeofint;
+ /* This will cause MPICH to consider this as a blockindex. We
+ * need different types here. */
+ types[i] = MPI_INT;
}
/* set up type */
- err = MPI_Type_struct(10,
- blocks,
- indices,
- types,
- &parent_type);
+ err = MPI_Type_struct(10, blocks, indices, types, &parent_type);
MPI_Type_commit(&parent_type);
- MPI_Pack_external_size((char*)"external32", 1, parent_type, &sizeoftype);
+ MPI_Pack_external_size((char *) "external32", 1, parent_type, &sizeoftype);
if (sizeoftype != 20 * sizeofint) {
- errs++;
- if (verbose) fprintf(stderr, "size of vector = %d; should be %d\n",
- (int) sizeoftype, (int) (20 * sizeofint));
+ errs++;
+ if (verbose)
+ fprintf(stderr, "size of vector = %d; should be %d\n",
+ (int) sizeoftype, (int) (20 * sizeofint));
}
buf = (char *) malloc(sizeoftype);
position = 0;
- err = MPI_Pack_external((char*)"external32",
- array,
- 1,
- parent_type,
- buf,
- sizeoftype,
- &position);
+ err = MPI_Pack_external((char *) "external32",
+ array, 1, parent_type, buf, sizeoftype, &position);
if (position != sizeoftype) {
- errs++;
- if (verbose) fprintf(stderr, "position = %d; should be %d (pack)\n",
- (int) position, (int) sizeoftype);
+ errs++;
+ if (verbose)
+ fprintf(stderr, "position = %d; should be %d (pack)\n",
+ (int) position, (int) sizeoftype);
}
memset(array, 0, 20 * sizeof(int));
position = 0;
- err = MPI_Unpack_external((char*)"external32",
- buf,
- sizeoftype,
- &position,
- array,
- 1,
- parent_type);
+ err = MPI_Unpack_external((char *) "external32",
+ buf, sizeoftype, &position, array, 1, parent_type);
if (position != sizeoftype) {
- errs++;
- if (verbose) fprintf(stderr,
- "position = %ld; should be %ld (unpack)\n",
- (long) position, (long) sizeoftype);
+ errs++;
+ if (verbose)
+ fprintf(stderr,
+ "position = %ld; should be %ld (unpack)\n", (long) position, (long) sizeoftype);
}
- for (i=0; i < 20; i++) {
- if (array[i] != i) {
- errs++;
- if (verbose) fprintf(stderr, "array[%d] = %d; should be %d\n",
- i, array[i], i);
- }
+ for (i = 0; i < 20; i++) {
+ if (array[i] != i) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "array[%d] = %d; should be %d\n", i, array[i], i);
+ }
}
MPI_Type_free(&parent_type);
@@ -399,14 +355,12 @@ int parse_args(int argc, char **argv)
{
int ret;
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
+ while ((ret = getopt(argc, argv, "v")) >= 0) {
+ switch (ret) {
+ case 'v':
+ verbose = 1;
+ break;
+ }
}
return 0;
}
-
diff --git a/test/mpi/datatype/simple-pack.c b/test/mpi/datatype/simple-pack.c
index d2119cd..8483d73 100644
--- a/test/mpi/datatype/simple-pack.c
+++ b/test/mpi/datatype/simple-pack.c
@@ -25,35 +25,35 @@ int main(int argc, char **argv)
{
int err, errs = 0;
- MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
+ MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
/* perform some tests */
err = builtin_float_test();
- if (err && verbose) fprintf(stderr, "%d errors in builtin float test.\n",
- err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in builtin float test.\n", err);
errs += err;
err = vector_of_vectors_test();
- if (err && verbose) fprintf(stderr,
- "%d errors in vector of vectors test.\n", err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in vector of vectors test.\n", err);
errs += err;
err = optimizable_vector_of_basics_test();
- if (err && verbose) fprintf(stderr,
- "%d errors in vector of basics test.\n", err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in vector of basics test.\n", err);
errs += err;
/* print message and exit */
if (errs) {
- fprintf(stderr, "Found %d errors\n", errs);
+ fprintf(stderr, "Found %d errors\n", errs);
}
else {
- printf(" No Errors\n");
+ printf(" No Errors\n");
}
MPI_Finalize();
return 0;
@@ -71,13 +71,10 @@ int builtin_float_test(void)
int err, errs = 0;
- err = MPI_Type_get_envelope(MPI_FLOAT,
- &nints,
- &nadds,
- &ntypes,
- &combiner);
-
- if (combiner != MPI_COMBINER_NAMED) errs++;
+ err = MPI_Type_get_envelope(MPI_FLOAT, &nints, &nadds, &ntypes, &combiner);
+
+ if (combiner != MPI_COMBINER_NAMED)
+ errs++;
/* Note: it is erroneous to call MPI_Type_get_contents() on a basic. */
return errs;
@@ -85,8 +82,8 @@ int builtin_float_test(void)
/* vector_of_vectors_test()
*
- * Builds a vector of a vector of ints. Assuming an int array of size 9
- * integers, and treating the array as a 3x3 2D array, this will grab the
+ * Builds a vector of a vector of ints. Assuming an int array of size 9
+ * integers, and treating the array as a 3x3 2D array, this will grab the
* corners.
*
* Returns the number of errors encountered.
@@ -95,106 +92,86 @@ int vector_of_vectors_test(void)
{
MPI_Datatype inner_vector;
MPI_Datatype outer_vector;
- int array[9] = { 1, -1, 2,
- -2, -3, -4,
- 3, -5, 4 };
+ int array[9] = { 1, -1, 2,
+ -2, -3, -4,
+ 3, -5, 4
+ };
char *buf;
int i, err, errs = 0, sizeoftype, position;
/* set up type */
- err = MPI_Type_vector(2,
- 1,
- 2,
- MPI_INT,
- &inner_vector);
+ err = MPI_Type_vector(2, 1, 2, MPI_INT, &inner_vector);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr,
- "error in MPI call; aborting after %d errors\n",
- errs+1);
- return errs;
+ errs++;
+ if (verbose)
+ fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
+ return errs;
}
- err = MPI_Type_vector(2,
- 1,
- 2,
- inner_vector,
- &outer_vector);
+ err = MPI_Type_vector(2, 1, 2, inner_vector, &outer_vector);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) fprintf(stderr,
- "error in MPI call; aborting after %d errors\n",
- errs+1);
- return errs;
+ errs++;
+ if (verbose)
+ fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
+ return errs;
}
MPI_Type_commit(&outer_vector);
MPI_Type_size(outer_vector, &sizeoftype);
- if (sizeoftype != 4*sizeof(int)) {
- errs++;
- if (verbose) fprintf(stderr, "size of type = %d; should be %d\n",
- (int) sizeoftype, (int) (4*sizeof(int)));
- return errs;
+ if (sizeoftype != 4 * sizeof(int)) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "size of type = %d; should be %d\n",
+ (int) sizeoftype, (int) (4 * sizeof(int)));
+ return errs;
}
buf = (char *) malloc(sizeoftype);
position = 0;
- err = MPI_Pack(array,
- 1,
- outer_vector,
- buf,
- sizeoftype,
- &position,
- MPI_COMM_WORLD);
+ err = MPI_Pack(array, 1, outer_vector, buf, sizeoftype, &position, MPI_COMM_WORLD);
if (position != sizeoftype) {
- errs++;
- if (verbose) fprintf(stderr, "position = %d; should be %d (pack)\n",
- position, sizeoftype);
+ errs++;
+ if (verbose)
+ fprintf(stderr, "position = %d; should be %d (pack)\n", position, sizeoftype);
}
- memset(array, 0, 9*sizeof(int));
+ memset(array, 0, 9 * sizeof(int));
position = 0;
- err = MPI_Unpack(buf,
- sizeoftype,
- &position,
- array,
- 1,
- outer_vector,
- MPI_COMM_WORLD);
+ err = MPI_Unpack(buf, sizeoftype, &position, array, 1, outer_vector, MPI_COMM_WORLD);
if (position != sizeoftype) {
- errs++;
- if (verbose) fprintf(stderr, "position = %d; should be %d (unpack)\n",
- position, sizeoftype);
+ errs++;
+ if (verbose)
+ fprintf(stderr, "position = %d; should be %d (unpack)\n", position, sizeoftype);
}
- for (i=0; i < 9; i++) {
- int goodval;
- switch (i) {
- case 0:
- goodval = 1;
- break;
- case 2:
- goodval = 2;
- break;
- case 6:
- goodval = 3;
- break;
- case 8:
- goodval = 4;
- break;
- default:
- goodval = 0;
- break;
- }
- if (array[i] != goodval) {
- errs++;
- if (verbose) fprintf(stderr, "array[%d] = %d; should be %d\n",
- i, array[i], goodval);
- }
+ for (i = 0; i < 9; i++) {
+ int goodval;
+ switch (i) {
+ case 0:
+ goodval = 1;
+ break;
+ case 2:
+ goodval = 2;
+ break;
+ case 6:
+ goodval = 3;
+ break;
+ case 8:
+ goodval = 4;
+ break;
+ default:
+ goodval = 0;
+ break;
+ }
+ if (array[i] != goodval) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "array[%d] = %d; should be %d\n", i, array[i], goodval);
+ }
}
MPI_Type_free(&inner_vector);
@@ -213,7 +190,8 @@ int optimizable_vector_of_basics_test(void)
{
MPI_Datatype parent_type;
int array[20] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19 };
+ 16, 17, 18, 19
+ };
char *buf;
int i, sizeofint, sizeoftype, position;
@@ -222,67 +200,52 @@ int optimizable_vector_of_basics_test(void)
MPI_Type_size(MPI_INT, &sizeofint);
if (sizeofint != sizeof(int)) {
- errs++;
- if (verbose) fprintf(stderr, "size of MPI_Int = %d; should be %d\n",
- sizeofint, (int) sizeof(int));
+ errs++;
+ if (verbose)
+ fprintf(stderr, "size of MPI_Int = %d; should be %d\n", sizeofint, (int) sizeof(int));
}
/* set up type */
- err = MPI_Type_vector(10,
- 2,
- 2,
- MPI_INT,
- &parent_type);
+ err = MPI_Type_vector(10, 2, 2, MPI_INT, &parent_type);
MPI_Type_commit(&parent_type);
MPI_Type_size(parent_type, &sizeoftype);
if (sizeoftype != 20 * sizeof(int)) {
- errs++;
- if (verbose) fprintf(stderr, "size of vector = %d; should be %d\n",
- (int) sizeoftype, (int) (20 * sizeof(int)));
+ errs++;
+ if (verbose)
+ fprintf(stderr, "size of vector = %d; should be %d\n",
+ (int) sizeoftype, (int) (20 * sizeof(int)));
}
buf = (char *) malloc(sizeoftype);
position = 0;
- err = MPI_Pack(array,
- 1,
- parent_type,
- buf,
- sizeoftype,
- &position,
- MPI_COMM_WORLD);
+ err = MPI_Pack(array, 1, parent_type, buf, sizeoftype, &position, MPI_COMM_WORLD);
if (position != sizeoftype) {
- errs++;
- if (verbose) fprintf(stderr, "position = %d; should be %d (pack)\n",
- position, sizeoftype);
+ errs++;
+ if (verbose)
+ fprintf(stderr, "position = %d; should be %d (pack)\n", position, sizeoftype);
}
memset(array, 0, 20 * sizeof(int));
position = 0;
- err = MPI_Unpack(buf,
- sizeoftype,
- &position,
- array,
- 1,
- parent_type,
- MPI_COMM_WORLD);
+ err = MPI_Unpack(buf, sizeoftype, &position, array, 1, parent_type, MPI_COMM_WORLD);
if (position != sizeoftype) {
- errs++;
- if (verbose) fprintf(stderr, "position = %d; should be %d (unpack)\n",
- position, sizeoftype);
+ errs++;
+ if (verbose)
+ fprintf(stderr, "position = %d; should be %d (unpack)\n", position, sizeoftype);
}
- for (i=0; i < 20; i++) {
- if (array[i] != i) {
- errs++;
- if (verbose) fprintf(stderr, "array[%d] = %d; should be %d\n",
- i, array[i], i);
- }
+ for (i = 0; i < 20; i++) {
+ if (array[i] != i) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "array[%d] = %d; should be %d\n", i, array[i], i);
+ }
}
MPI_Type_free(&parent_type);
@@ -293,19 +256,18 @@ int optimizable_vector_of_basics_test(void)
int parse_args(int argc, char **argv)
{
/*
- int ret;
-
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
- }
- */
+ * int ret;
+ *
+ * while ((ret = getopt(argc, argv, "v")) >= 0)
+ * {
+ * switch (ret) {
+ * case 'v':
+ * verbose = 1;
+ * break;
+ * }
+ * }
+ */
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
return 0;
}
-
diff --git a/test/mpi/datatype/simple-resized.c b/test/mpi/datatype/simple-resized.c
index 83aa629..b8700ac 100644
--- a/test/mpi/datatype/simple-resized.c
+++ b/test/mpi/datatype/simple-resized.c
@@ -23,25 +23,25 @@ int main(int argc, char **argv)
{
int err, errs = 0;
- MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
+ MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
/* perform some tests */
err = derived_resized_test();
- if (err && verbose) fprintf(stderr, "%d errors in derived_resized test.\n",
- err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in derived_resized test.\n", err);
errs += err;
/* print message and exit */
if (errs) {
- fprintf(stderr, "Found %d errors\n", errs);
+ fprintf(stderr, "Found %d errors\n", errs);
}
else {
- printf(" No Errors\n");
+ printf(" No Errors\n");
}
MPI_Finalize();
return 0;
@@ -63,60 +63,52 @@ int derived_resized_test(void)
int size;
MPI_Aint extent;
- err = MPI_Type_contiguous(count,
- MPI_INT,
- &newtype);
+ err = MPI_Type_contiguous(count, MPI_INT, &newtype);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error creating type in derived_resized_test()\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "error creating type in derived_resized_test()\n");
+ }
+ errs++;
}
err = MPI_Type_create_resized(newtype,
- (MPI_Aint) 0,
- (MPI_Aint) (2*sizeof(int) + 10),
- &resizedtype);
+ (MPI_Aint) 0, (MPI_Aint) (2 * sizeof(int) + 10), &resizedtype);
err = MPI_Type_size(resizedtype, &size);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error obtaining type size in derived_resized_test()\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "error obtaining type size in derived_resized_test()\n");
+ }
+ errs++;
+ }
+
+ if (size != 2 * sizeof(int)) {
+ if (verbose) {
+ fprintf(stderr,
+ "error: size != %d in derived_resized_test()\n", (int) (2 * sizeof(int)));
+ }
+ errs++;
}
-
- if (size != 2*sizeof(int)) {
- if (verbose) {
- fprintf(stderr,
- "error: size != %d in derived_resized_test()\n", (int) (2*sizeof(int)));
- }
- errs++;
- }
err = MPI_Type_extent(resizedtype, &extent);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error obtaining type extent in derived_resized_test()\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "error obtaining type extent in derived_resized_test()\n");
+ }
+ errs++;
+ }
+
+ if (extent != 2 * sizeof(int) + 10) {
+ if (verbose) {
+ fprintf(stderr,
+ "error: invalid extent (%d) in derived_resized_test(); should be %d\n",
+ (int) extent, (int) (2 * sizeof(int) + 10));
+ }
+ errs++;
}
-
- if (extent != 2*sizeof(int) + 10) {
- if (verbose) {
- fprintf(stderr,
- "error: invalid extent (%d) in derived_resized_test(); should be %d\n",
- (int) extent,
- (int) (2*sizeof(int) + 10));
- }
- errs++;
- }
-
- MPI_Type_free( &newtype );
- MPI_Type_free( &resizedtype );
+
+ MPI_Type_free(&newtype);
+ MPI_Type_free(&resizedtype);
return errs;
}
@@ -125,19 +117,18 @@ int derived_resized_test(void)
int parse_args(int argc, char **argv)
{
/*
- int ret;
-
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
- }
- */
+ * int ret;
+ *
+ * while ((ret = getopt(argc, argv, "v")) >= 0)
+ * {
+ * switch (ret) {
+ * case 'v':
+ * verbose = 1;
+ * break;
+ * }
+ * }
+ */
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
return 0;
}
-
diff --git a/test/mpi/datatype/simple-size-extent.c b/test/mpi/datatype/simple-size-extent.c
index bde5592..3433079 100644
--- a/test/mpi/datatype/simple-size-extent.c
+++ b/test/mpi/datatype/simple-size-extent.c
@@ -23,125 +23,134 @@ int main(int argc, char **argv)
MPI_Aint lb, ub, extent;
MPI_Datatype type;
- struct { float a; int b; } foo;
+ struct {
+ float a;
+ int b;
+ } foo;
MPI_Init(&argc, &argv);
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
type = MPI_INT;
mpi_err = MPI_Type_size(type, &size);
if (mpi_err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr, "MPI_Type_size of MPI_INT failed.\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Type_size of MPI_INT failed.\n");
+ }
+ errs++;
}
if (size != sizeof(int)) {
- if (verbose) {
- fprintf(stderr, "MPI_Type_size of MPI_INT incorrect size (%d); should be %d.\n",
- size, (int) sizeof(int));
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Type_size of MPI_INT incorrect size (%d); should be %d.\n",
+ size, (int) sizeof(int));
+ }
+ errs++;
}
mpi_err = MPI_Type_get_extent(type, &lb, &extent);
if (mpi_err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr, "MPI_Type_get_extent of MPI_INT failed.\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Type_get_extent of MPI_INT failed.\n");
+ }
+ errs++;
}
if (extent != sizeof(int)) {
- if (verbose) {
- fprintf(stderr, "MPI_Type_get_extent of MPI_INT returned incorrect extent (%d); should be %d.\n",
- (int) extent, (int) sizeof(int));
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr,
+ "MPI_Type_get_extent of MPI_INT returned incorrect extent (%d); should be %d.\n",
+ (int) extent, (int) sizeof(int));
+ }
+ errs++;
}
if (lb != 0) {
- if (verbose) {
- fprintf(stderr, "MPI_Type_get_extent of MPI_INT returned incorrect lb (%d); should be 0.\n",
- (int) lb);
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr,
+ "MPI_Type_get_extent of MPI_INT returned incorrect lb (%d); should be 0.\n",
+ (int) lb);
+ }
+ errs++;
}
mpi_err = MPI_Type_ub(type, &ub);
if (mpi_err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr, "MPI_Type_ub of MPI_INT failed.\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Type_ub of MPI_INT failed.\n");
+ }
+ errs++;
}
if (ub != extent - lb) {
- if (verbose) {
- fprintf(stderr, "MPI_Type_ub of MPI_INT returned incorrect ub (%d); should be %d.\n",
- (int) ub, (int) (extent - lb));
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Type_ub of MPI_INT returned incorrect ub (%d); should be %d.\n",
+ (int) ub, (int) (extent - lb));
+ }
+ errs++;
}
type = MPI_FLOAT_INT;
mpi_err = MPI_Type_size(type, &size);
if (mpi_err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr, "MPI_Type_size of MPI_FLOAT_INT failed.\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Type_size of MPI_FLOAT_INT failed.\n");
+ }
+ errs++;
}
if (size != sizeof(float) + sizeof(int)) {
- if (verbose) {
- fprintf(stderr, "MPI_Type_size of MPI_FLOAT_INT returned incorrect size (%d); should be %d.\n",
- size, (int) (sizeof(float) + sizeof(int)));
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr,
+ "MPI_Type_size of MPI_FLOAT_INT returned incorrect size (%d); should be %d.\n",
+ size, (int) (sizeof(float) + sizeof(int)));
+ }
+ errs++;
}
mpi_err = MPI_Type_get_extent(type, &lb, &extent);
if (mpi_err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr, "MPI_Type_get_extent of MPI_FLOAT_INT failed.\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Type_get_extent of MPI_FLOAT_INT failed.\n");
+ }
+ errs++;
}
if (extent != sizeof(foo)) {
- if (verbose) {
- fprintf(stderr, "MPI_Type_get_extent of MPI_FLOAT_INT returned incorrect extent (%d); should be %d.\n",
- (int) extent, (int) sizeof(foo));
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr,
+ "MPI_Type_get_extent of MPI_FLOAT_INT returned incorrect extent (%d); should be %d.\n",
+ (int) extent, (int) sizeof(foo));
+ }
+ errs++;
}
if (lb != 0) {
- if (verbose) {
- fprintf(stderr, "MPI_Type_get_extent of MPI_FLOAT_INT returned incorrect lb (%d); should be 0.\n",
- (int) lb);
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr,
+ "MPI_Type_get_extent of MPI_FLOAT_INT returned incorrect lb (%d); should be 0.\n",
+ (int) lb);
+ }
+ errs++;
}
mpi_err = MPI_Type_ub(type, &ub);
if (mpi_err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr, "MPI_Type_ub of MPI_FLOAT_INT failed.\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Type_ub of MPI_FLOAT_INT failed.\n");
+ }
+ errs++;
}
if (ub != extent - lb) {
- if (verbose) {
- fprintf(stderr, "MPI_Type_ub of MPI_FLOAT_INT returned incorrect ub (%d); should be %d.\n",
- (int) ub, (int) (extent - lb));
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr,
+ "MPI_Type_ub of MPI_FLOAT_INT returned incorrect ub (%d); should be %d.\n",
+ (int) ub, (int) (extent - lb));
+ }
+ errs++;
}
/* print message and exit */
if (errs) {
- fprintf(stderr, "Found %d errors\n", errs);
+ fprintf(stderr, "Found %d errors\n", errs);
}
else {
- printf(" No Errors\n");
+ printf(" No Errors\n");
}
MPI_Finalize();
return 0;
@@ -150,18 +159,18 @@ int main(int argc, char **argv)
int parse_args(int argc, char **argv)
{
/*
- int ret;
-
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
- }
- */
+ * int ret;
+ *
+ * while ((ret = getopt(argc, argv, "v")) >= 0)
+ * {
+ * switch (ret) {
+ * case 'v':
+ * verbose = 1;
+ * break;
+ * }
+ * }
+ */
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
return 0;
}
diff --git a/test/mpi/datatype/sizedtypes.c b/test/mpi/datatype/sizedtypes.c
index 42bec06..c6ae4b3 100644
--- a/test/mpi/datatype/sizedtypes.c
+++ b/test/mpi/datatype/sizedtypes.c
@@ -13,82 +13,82 @@
static char MTEST_Descrip[] = "Test of the sized types, supported in MPI-2";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int size;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Type_size( MPI_REAL4, &size );
+ MPI_Type_size(MPI_REAL4, &size);
if (size != 4) {
- errs ++;
- printf( "MPI_REAL4 has size %d\n", size );
+ errs++;
+ printf("MPI_REAL4 has size %d\n", size);
}
- MPI_Type_size( MPI_REAL8, &size );
+ MPI_Type_size(MPI_REAL8, &size);
if (size != 8) {
- errs ++;
- printf( "MPI_REAL8 has size %d\n", size );
+ errs++;
+ printf("MPI_REAL8 has size %d\n", size);
}
if (MPI_REAL16 != MPI_DATATYPE_NULL) {
- MPI_Type_size( MPI_REAL16, &size );
- if (size != 16) {
- errs ++;
- printf( "MPI_REAL16 has size %d\n", size );
- }
+ MPI_Type_size(MPI_REAL16, &size);
+ if (size != 16) {
+ errs++;
+ printf("MPI_REAL16 has size %d\n", size);
+ }
}
- MPI_Type_size( MPI_COMPLEX8, &size );
+ MPI_Type_size(MPI_COMPLEX8, &size);
if (size != 8) {
- errs ++;
- printf( "MPI_COMPLEX8 has size %d\n", size );
+ errs++;
+ printf("MPI_COMPLEX8 has size %d\n", size);
}
- MPI_Type_size( MPI_COMPLEX16, &size );
+ MPI_Type_size(MPI_COMPLEX16, &size);
if (size != 16) {
- errs ++;
- printf( "MPI_COMPLEX16 has size %d\n", size );
+ errs++;
+ printf("MPI_COMPLEX16 has size %d\n", size);
}
if (MPI_COMPLEX32 != MPI_DATATYPE_NULL) {
- MPI_Type_size( MPI_COMPLEX32, &size );
- if (size != 32) {
- errs ++;
- printf( "MPI_COMPLEX32 has size %d\n", size );
- }
+ MPI_Type_size(MPI_COMPLEX32, &size);
+ if (size != 32) {
+ errs++;
+ printf("MPI_COMPLEX32 has size %d\n", size);
+ }
}
- MPI_Type_size( MPI_INTEGER1, &size );
+ MPI_Type_size(MPI_INTEGER1, &size);
if (size != 1) {
- errs ++;
- printf( "MPI_INTEGER1 has size %d\n", size );
+ errs++;
+ printf("MPI_INTEGER1 has size %d\n", size);
}
- MPI_Type_size( MPI_INTEGER2, &size );
+ MPI_Type_size(MPI_INTEGER2, &size);
if (size != 2) {
- errs ++;
- printf( "MPI_INTEGER2 has size %d\n", size );
+ errs++;
+ printf("MPI_INTEGER2 has size %d\n", size);
}
- MPI_Type_size( MPI_INTEGER4, &size );
+ MPI_Type_size(MPI_INTEGER4, &size);
if (size != 4) {
- errs ++;
- printf( "MPI_INTEGER4 has size %d\n", size );
+ errs++;
+ printf("MPI_INTEGER4 has size %d\n", size);
}
if (MPI_INTEGER8 != MPI_DATATYPE_NULL) {
- MPI_Type_size( MPI_INTEGER8, &size );
- if (size != 8) {
- errs ++;
- printf( "MPI_INTEGER8 has size %d\n", size );
- }
+ MPI_Type_size(MPI_INTEGER8, &size);
+ if (size != 8) {
+ errs++;
+ printf("MPI_INTEGER8 has size %d\n", size);
+ }
}
#ifdef HAVE_MPI_INTEGER16
if (MPI_INTEGER16 != MPI_DATATYPE_NULL) {
- MPI_Type_size( MPI_INTEGER16, &size );
- if (size != 16) {
- errs ++;
- printf( "MPI_INTEGER16 has size %d\n", size );
- }
+ MPI_Type_size(MPI_INTEGER16, &size);
+ if (size != 16) {
+ errs++;
+ printf("MPI_INTEGER16 has size %d\n", size);
+ }
}
#endif
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/datatype/slice-pack-external.c b/test/mpi/datatype/slice-pack-external.c
index 8f4c004..8781619 100644
--- a/test/mpi/datatype/slice-pack-external.c
+++ b/test/mpi/datatype/slice-pack-external.c
@@ -24,22 +24,22 @@ int main(int argc, char *argv[])
int errs = 0;
MPI_Aint sizeofint, bufsize, position;
void *buffer;
-
+
int i, j, k;
-
+
/* Initialize a to some known values. */
for (i = 0; i < 100; i++) {
- for (j = 0; j < 100; j++) {
- for (k = 0; k < 100; k++) {
- a[i][j][k] = i*1000000+j*1000+k;
- }
- }
+ for (j = 0; j < 100; j++) {
+ for (k = 0; k < 100; k++) {
+ a[i][j][k] = i * 1000000 + j * 1000 + k;
+ }
+ }
}
-
+
/* Initialize MPI */
MPI_Init(&argc, &argv);
MPI_Type_extent(MPI_INT, &sizeofint);
-
+
parse_args(argc, argv);
/* Create data types. */
@@ -47,62 +47,52 @@ int main(int argc, char *argv[])
/* On the sheet, the slice is a[0, 2, 4, ..., 16][2-10][1-9]. */
/* Below, the slice is a[0-8][2-10][1, 3, 5, ..., 17]. */
MPI_Type_vector(9, 1, 2, MPI_INT, &oneslice);
- MPI_Type_hvector(9, 1, 100*sizeofint, oneslice, &twoslice);
- MPI_Type_hvector(9, 1, 100*100*sizeofint, twoslice, &threeslice);
-
+ MPI_Type_hvector(9, 1, 100 * sizeofint, oneslice, &twoslice);
+ MPI_Type_hvector(9, 1, 100 * 100 * sizeofint, twoslice, &threeslice);
+
MPI_Type_commit(&threeslice);
-
+
/* Pack it into a buffer. */
position = 0;
/* MPI_Pack_size(1, threeslice, MPI_COMM_WORLD, &bufsize); */
- MPI_Pack_external_size((char*)"external32", 1, threeslice, &bufsize);
- if (bufsize != 2916)
- {
- fprintf(stderr," Error on pack size! Got %d; expecting %d\n", (int) bufsize, 2916);
+ MPI_Pack_external_size((char *) "external32", 1, threeslice, &bufsize);
+ if (bufsize != 2916) {
+ fprintf(stderr, " Error on pack size! Got %d; expecting %d\n", (int) bufsize, 2916);
}
buffer = (void *) malloc((unsigned) bufsize);
/* -1 to indices on sheet to compensate for Fortran --> C */
- MPI_Pack_external((char*)"external32",
- &(a[0][2][1]),
- 1, threeslice,
- buffer,
- bufsize,
- &position);
+ MPI_Pack_external((char *) "external32",
+ &(a[0][2][1]), 1, threeslice, buffer, bufsize, &position);
/* Unpack the buffer into e. */
position = 0;
- MPI_Unpack_external((char*)"external32",
- buffer,
- bufsize,
- &position,
- e, 9*9*9,
- MPI_INT);
-
+ MPI_Unpack_external((char *) "external32", buffer, bufsize, &position, e, 9 * 9 * 9, MPI_INT);
+
/* Display errors, if any. */
for (i = 0; i < 9; i++) {
- for (j = 0; j < 9; j++) {
- for (k = 0; k < 9; k++) {
- /* The truncation in integer division makes this safe. */
- if (e[i][j][k] != a[i][j+2][k*2+1]) {
- errs++;
- if (verbose) {
- printf("Error in location %d x %d x %d: %d, should be %d.\n",
- i, j, k, e[i][j][k], a[i][j+2][k*2+1]);
- }
- }
- }
- }
- }
-
+ for (j = 0; j < 9; j++) {
+ for (k = 0; k < 9; k++) {
+ /* The truncation in integer division makes this safe. */
+ if (e[i][j][k] != a[i][j + 2][k * 2 + 1]) {
+ errs++;
+ if (verbose) {
+ printf("Error in location %d x %d x %d: %d, should be %d.\n",
+ i, j, k, e[i][j][k], a[i][j + 2][k * 2 + 1]);
+ }
+ }
+ }
+ }
+ }
+
/* Release memory. */
free(buffer);
if (errs) {
- fprintf(stderr, "Found %d errors\n", errs);
+ fprintf(stderr, "Found %d errors\n", errs);
}
else {
- printf(" No Errors\n");
+ printf(" No Errors\n");
}
MPI_Type_free(&oneslice);
@@ -119,13 +109,12 @@ static int parse_args(int argc, char **argv)
{
int ret;
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
+ while ((ret = getopt(argc, argv, "v")) >= 0) {
+ switch (ret) {
+ case 'v':
+ verbose = 1;
+ break;
+ }
}
return 0;
}
diff --git a/test/mpi/datatype/slice-pack.c b/test/mpi/datatype/slice-pack.c
index 8fcd3b5..ce6d4a4 100644
--- a/test/mpi/datatype/slice-pack.c
+++ b/test/mpi/datatype/slice-pack.c
@@ -27,25 +27,25 @@ int main(int argc, char *argv[])
MPI_Datatype oneslice, twoslice, threeslice;
int errs = 0;
MPI_Aint sizeofint;
-
+
int bufsize, position;
void *buffer;
-
+
int i, j, k;
-
+
/* Initialize a to some known values. */
for (i = 0; i < 100; i++) {
- for (j = 0; j < 100; j++) {
- for (k = 0; k < 100; k++) {
- a[i][j][k] = i*1000000+j*1000+k;
- }
- }
+ for (j = 0; j < 100; j++) {
+ for (k = 0; k < 100; k++) {
+ a[i][j][k] = i * 1000000 + j * 1000 + k;
+ }
+ }
}
-
+
/* Initialize MPI */
MPI_Init(&argc, &argv);
MPI_Type_extent(MPI_INT, &sizeofint);
-
+
parse_args(argc, argv);
/* Create data types. */
@@ -53,57 +53,47 @@ int main(int argc, char *argv[])
/* On the sheet, the slice is a[0, 2, 4, ..., 16][2-10][1-9]. */
/* Below, the slice is a[0-8][2-10][1, 3, 5, ..., 17]. */
MPI_Type_vector(9, 1, 2, MPI_INT, &oneslice);
- MPI_Type_hvector(9, 1, 100*sizeofint, oneslice, &twoslice);
- MPI_Type_hvector(9, 1, 100*100*sizeofint, twoslice, &threeslice);
-
+ MPI_Type_hvector(9, 1, 100 * sizeofint, oneslice, &twoslice);
+ MPI_Type_hvector(9, 1, 100 * 100 * sizeofint, twoslice, &threeslice);
+
MPI_Type_commit(&threeslice);
-
+
/* Pack it into a buffer. */
position = 0;
MPI_Pack_size(1, threeslice, MPI_COMM_WORLD, &bufsize);
buffer = (void *) malloc((unsigned) bufsize);
/* -1 to indices on sheet to compensate for Fortran --> C */
- MPI_Pack(&(a[0][2][1]),
- 1, threeslice,
- buffer,
- bufsize,
- &position,
- MPI_COMM_WORLD);
+ MPI_Pack(&(a[0][2][1]), 1, threeslice, buffer, bufsize, &position, MPI_COMM_WORLD);
/* Unpack the buffer into e. */
position = 0;
- MPI_Unpack(buffer,
- bufsize,
- &position,
- e, 9*9*9,
- MPI_INT,
- MPI_COMM_WORLD);
-
+ MPI_Unpack(buffer, bufsize, &position, e, 9 * 9 * 9, MPI_INT, MPI_COMM_WORLD);
+
/* Display errors, if any. */
for (i = 0; i < 9; i++) {
- for (j = 0; j < 9; j++) {
- for (k = 0; k < 9; k++) {
- /* The truncation in integer division makes this safe. */
- if (e[i][j][k] != a[i][j+2][k*2+1]) {
- errs++;
- if (verbose) {
- printf("Error in location %d x %d x %d: %d, should be %d.\n",
- i, j, k, e[i][j][k], a[i][j+2][k*2+1]);
- }
- }
- }
- }
- }
-
+ for (j = 0; j < 9; j++) {
+ for (k = 0; k < 9; k++) {
+ /* The truncation in integer division makes this safe. */
+ if (e[i][j][k] != a[i][j + 2][k * 2 + 1]) {
+ errs++;
+ if (verbose) {
+ printf("Error in location %d x %d x %d: %d, should be %d.\n",
+ i, j, k, e[i][j][k], a[i][j + 2][k * 2 + 1]);
+ }
+ }
+ }
+ }
+ }
+
/* Release memory. */
free(buffer);
if (errs) {
- fprintf(stderr, "Found %d errors\n", errs);
+ fprintf(stderr, "Found %d errors\n", errs);
}
else {
- printf(" No Errors\n");
+ printf(" No Errors\n");
}
MPI_Type_free(&oneslice);
@@ -119,18 +109,18 @@ int main(int argc, char *argv[])
static int parse_args(int argc, char **argv)
{
/*
- int ret;
-
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
- }
- */
+ * int ret;
+ *
+ * while ((ret = getopt(argc, argv, "v")) >= 0)
+ * {
+ * switch (ret) {
+ * case 'v':
+ * verbose = 1;
+ * break;
+ * }
+ * }
+ */
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
return 0;
}
diff --git a/test/mpi/datatype/struct-derived-zeros.c b/test/mpi/datatype/struct-derived-zeros.c
index f07841a..b57d9d5 100644
--- a/test/mpi/datatype/struct-derived-zeros.c
+++ b/test/mpi/datatype/struct-derived-zeros.c
@@ -14,47 +14,47 @@ int main(int argc, char *argv[])
{
MPI_Datatype mystruct, vecs[3];
MPI_Aint stride = 5, displs[3];
- int i=0, blockcount[3];
- int errs=0;
+ int i = 0, blockcount[3];
+ int errs = 0;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- for(i = 0; i < 3; i++)
- {
+ for (i = 0; i < 3; i++) {
MPI_Type_hvector(i, 1, stride, MPI_INT, &vecs[i]);
MPI_Type_commit(&vecs[i]);
- blockcount[i]=1;
+ blockcount[i] = 1;
}
- displs[0]=0; displs[1]=-100; displs[2]=-200; /* irrelevant */
+ displs[0] = 0;
+ displs[1] = -100;
+ displs[2] = -200; /* irrelevant */
MPI_Type_struct(3, blockcount, displs, vecs, &mystruct);
MPI_Type_commit(&mystruct);
MPI_Type_free(&mystruct);
- for(i = 0; i < 3; i++)
- {
+ for (i = 0; i < 3; i++) {
MPI_Type_free(&vecs[i]);
}
/* this time with the first argument always 0 */
- for(i = 0; i < 3; i++)
- {
+ for (i = 0; i < 3; i++) {
MPI_Type_hvector(0, 1, stride, MPI_INT, &vecs[i]);
MPI_Type_commit(&vecs[i]);
- blockcount[i]=1;
+ blockcount[i] = 1;
}
- displs[0]=0; displs[1]=-100; displs[2]=-200; /* irrelevant */
+ displs[0] = 0;
+ displs[1] = -100;
+ displs[2] = -200; /* irrelevant */
MPI_Type_struct(3, blockcount, displs, vecs, &mystruct);
MPI_Type_commit(&mystruct);
MPI_Type_free(&mystruct);
- for(i = 0; i < 3; i++)
- {
+ for (i = 0; i < 3; i++) {
MPI_Type_free(&vecs[i]);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
diff --git a/test/mpi/datatype/struct-empty-el.c b/test/mpi/datatype/struct-empty-el.c
index 3704293..5b992d9 100644
--- a/test/mpi/datatype/struct-empty-el.c
+++ b/test/mpi/datatype/struct-empty-el.c
@@ -16,7 +16,7 @@ int parse_args(int argc, char **argv);
int single_struct_test(void);
struct test_struct_1 {
- int a,b,c,d;
+ int a, b, c, d;
};
int main(int argc, char *argv[])
@@ -28,19 +28,20 @@ int main(int argc, char *argv[])
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
err = single_struct_test();
- if (verbose && err) fprintf(stderr, "error in single_struct_test\n");
+ if (verbose && err)
+ fprintf(stderr, "error in single_struct_test\n");
errs += err;
/* print message and exit */
if (errs) {
- fprintf(stderr, "Found %d errors\n", errs);
+ fprintf(stderr, "Found %d errors\n", errs);
}
else {
- printf(" No Errors\n");
+ printf(" No Errors\n");
}
MPI_Finalize();
return 0;
@@ -57,9 +58,9 @@ int single_struct_test(void)
MPI_Status status;
/* note: first element of struct has zero blklen and should be dropped */
- MPI_Aint disps[3] = { 2*sizeof(float), 0, 2*sizeof(int) };
- int blks[3] = { 0, 1, 2 };
- MPI_Datatype types[3] = { MPI_FLOAT, MPI_INT, MPI_INT };
+ MPI_Aint disps[3] = { 2 * sizeof(float), 0, 2 * sizeof(int) };
+ int blks[3] = { 0, 1, 2 };
+ MPI_Datatype types[3] = { MPI_FLOAT, MPI_INT, MPI_INT };
ts1[0].a = -1;
ts1[0].b = -1;
@@ -73,115 +74,115 @@ int single_struct_test(void)
err = MPI_Type_struct(3, blks, disps, types, &mystruct);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Type_struct returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Type_struct returned error\n");
+ }
}
MPI_Type_commit(&mystruct);
err = MPI_Irecv(ts1, 2, mystruct, 0, 0, MPI_COMM_SELF, &request);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Irecv returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Irecv returned error\n");
+ }
}
err = MPI_Send(sendbuf, 6, MPI_INT, 0, 0, MPI_COMM_SELF);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Send returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Send returned error\n");
+ }
}
err = MPI_Wait(&request, &status);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Wait returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Wait returned error\n");
+ }
}
/* verify data */
if (ts1[0].a != 1) {
- errs++;
- if (verbose) {
- fprintf(stderr, "ts1[0].a = %d; should be %d\n", ts1[0].a, 1);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "ts1[0].a = %d; should be %d\n", ts1[0].a, 1);
+ }
}
if (ts1[0].b != -1) {
- errs++;
- if (verbose) {
- fprintf(stderr, "ts1[0].b = %d; should be %d\n", ts1[0].b, -1);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "ts1[0].b = %d; should be %d\n", ts1[0].b, -1);
+ }
}
if (ts1[0].c != 2) {
- errs++;
- if (verbose) {
- fprintf(stderr, "ts1[0].c = %d; should be %d\n", ts1[0].c, 2);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "ts1[0].c = %d; should be %d\n", ts1[0].c, 2);
+ }
}
if (ts1[0].d != 3) {
- errs++;
- if (verbose) {
- fprintf(stderr, "ts1[0].d = %d; should be %d\n", ts1[0].d, 3);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "ts1[0].d = %d; should be %d\n", ts1[0].d, 3);
+ }
}
if (ts1[1].a != 4) {
- errs++;
- if (verbose) {
- fprintf(stderr, "ts1[1].a = %d; should be %d\n", ts1[1].a, 4);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "ts1[1].a = %d; should be %d\n", ts1[1].a, 4);
+ }
}
if (ts1[1].b != -1) {
- errs++;
- if (verbose) {
- fprintf(stderr, "ts1[1].b = %d; should be %d\n", ts1[1].b, -1);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "ts1[1].b = %d; should be %d\n", ts1[1].b, -1);
+ }
}
if (ts1[1].c != 5) {
- errs++;
- if (verbose) {
- fprintf(stderr, "ts1[1].c = %d; should be %d\n", ts1[1].c, 5);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "ts1[1].c = %d; should be %d\n", ts1[1].c, 5);
+ }
}
if (ts1[1].d != 6) {
- errs++;
- if (verbose) {
- fprintf(stderr, "ts1[1].d = %d; should be %d\n", ts1[1].d, 6);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "ts1[1].d = %d; should be %d\n", ts1[1].d, 6);
+ }
}
/* verify count and elements */
err = MPI_Get_count(&status, mystruct, &count);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Get_count returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Get_count returned error\n");
+ }
}
if (count != 2) {
- errs++;
- if (verbose) {
- fprintf(stderr, "count = %d; should be 2\n", count);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "count = %d; should be 2\n", count);
+ }
}
err = MPI_Get_elements(&status, mystruct, &elements);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Get_elements returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Get_elements returned error\n");
+ }
}
if (elements != 6) {
- errs++;
- if (verbose) {
- fprintf(stderr, "elements = %d; should be 6\n", elements);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "elements = %d; should be 6\n", elements);
+ }
}
MPI_Type_free(&mystruct);
@@ -193,18 +194,18 @@ int single_struct_test(void)
int parse_args(int argc, char **argv)
{
/*
- int ret;
-
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
- }
- */
+ * int ret;
+ *
+ * while ((ret = getopt(argc, argv, "v")) >= 0)
+ * {
+ * switch (ret) {
+ * case 'v':
+ * verbose = 1;
+ * break;
+ * }
+ * }
+ */
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
return 0;
}
diff --git a/test/mpi/datatype/struct-ezhov.c b/test/mpi/datatype/struct-ezhov.c
index 036eaf6..992fd1f 100644
--- a/test/mpi/datatype/struct-ezhov.c
+++ b/test/mpi/datatype/struct-ezhov.c
@@ -12,17 +12,17 @@
#define SIZE 340
#define EL_COUNT 1131
-char s_buf[EL_COUNT*SIZE];
-char r_buf[EL_COUNT*SIZE];
+char s_buf[EL_COUNT * SIZE];
+char r_buf[EL_COUNT * SIZE];
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- int rank, size, ret;
- MPI_Status Status;
- MPI_Request request;
- MPI_Datatype struct_type, type1[COUNT];
- MPI_Aint disp1[COUNT] = {0, 0, 332, 340};
- int block1[COUNT] = {1, 56, 2, 1};
+ int rank, size, ret;
+ MPI_Status Status;
+ MPI_Request request;
+ MPI_Datatype struct_type, type1[COUNT];
+ MPI_Aint disp1[COUNT] = { 0, 0, 332, 340 };
+ int block1[COUNT] = { 1, 56, 2, 1 };
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
@@ -32,25 +32,24 @@ int main( int argc, char **argv )
type1[1] = MPI_FLOAT;
type1[2] = MPI_FLOAT;
type1[3] = MPI_UB;
-
+
MPI_Type_struct(4, block1, disp1, type1, &struct_type);
-
+
ret = MPI_Type_commit(&struct_type);
- if (ret != MPI_SUCCESS)
- {
- fprintf(stderr, "Could not make struct type."), fflush(stderr);
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ if (ret != MPI_SUCCESS) {
+ fprintf(stderr, "Could not make struct type."), fflush(stderr);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
-
- memset(s_buf, 0, EL_COUNT*SIZE);
- memset(r_buf, 0, EL_COUNT*SIZE);
+
+ memset(s_buf, 0, EL_COUNT * SIZE);
+ memset(r_buf, 0, EL_COUNT * SIZE);
MPI_Isend(s_buf, EL_COUNT, struct_type, 0, 4, MPI_COMM_WORLD, &request);
- MPI_Recv(r_buf, EL_COUNT, struct_type, 0, 4, MPI_COMM_WORLD, &Status );
+ MPI_Recv(r_buf, EL_COUNT, struct_type, 0, 4, MPI_COMM_WORLD, &Status);
MPI_Wait(&request, &Status);
-
+
MPI_Type_free(&struct_type);
-
+
MPI_Finalize();
printf(" No Errors\n");
diff --git a/test/mpi/datatype/struct-no-real-types.c b/test/mpi/datatype/struct-no-real-types.c
index a1bded0..a0e21cb 100644
--- a/test/mpi/datatype/struct-no-real-types.c
+++ b/test/mpi/datatype/struct-no-real-types.c
@@ -12,7 +12,7 @@
#include <string.h>
#endif
-/*
+/*
The default behavior of the test routines should be to briefly indicate
the cause of any errors - in this test, that means that verbose needs
to be set. Verbose should turn on output that is independent of error
@@ -34,16 +34,16 @@ int main(int argc, char **argv)
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
/* perform some tests */
err = no_real_types_test();
- if (err && verbose) fprintf(stderr, "%d errors in blockindexed test.\n",
- err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in blockindexed test.\n", err);
errs += err;
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
@@ -67,60 +67,51 @@ int no_real_types_test(void)
int size;
MPI_Aint extent;
- err = MPI_Type_create_struct(count,
- &len,
- &disp,
- &type,
- &newtype);
+ err = MPI_Type_create_struct(count, &len, &disp, &type, &newtype);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error creating struct type no_real_types_test()\n");
- }
- MTestPrintError( err );
- errs++;
+ if (verbose) {
+ fprintf(stderr, "error creating struct type no_real_types_test()\n");
+ }
+ MTestPrintError(err);
+ errs++;
}
err = MPI_Type_size(newtype, &size);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error obtaining type size in no_real_types_test()\n");
- }
- MTestPrintError( err );
- errs++;
+ if (verbose) {
+ fprintf(stderr, "error obtaining type size in no_real_types_test()\n");
+ }
+ MTestPrintError(err);
+ errs++;
}
-
+
if (size != 0) {
- if (verbose) {
- fprintf(stderr,
- "error: size != 0 in no_real_types_test()\n");
- }
- errs++;
- }
+ if (verbose) {
+ fprintf(stderr, "error: size != 0 in no_real_types_test()\n");
+ }
+ errs++;
+ }
err = MPI_Type_extent(newtype, &extent);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error obtaining type extent in no_real_types_test()\n");
- }
- MTestPrintError( err );
- errs++;
+ if (verbose) {
+ fprintf(stderr, "error obtaining type extent in no_real_types_test()\n");
+ }
+ MTestPrintError(err);
+ errs++;
}
-
+
if (extent != -10) {
- if (verbose) {
- fprintf(stderr,
- "error: extent is %ld but should be -10 in no_real_types_test()\n",
- (long) extent );
- fprintf( stderr,
- "type map is { (LB,10) }, so UB is 0 and extent is ub-lb\n" );
- }
- errs++;
- }
-
- MPI_Type_free( &newtype );
+ if (verbose) {
+ fprintf(stderr,
+ "error: extent is %ld but should be -10 in no_real_types_test()\n",
+ (long) extent);
+ fprintf(stderr, "type map is { (LB,10) }, so UB is 0 and extent is ub-lb\n");
+ }
+ errs++;
+ }
+
+ MPI_Type_free(&newtype);
return errs;
}
@@ -129,19 +120,18 @@ int no_real_types_test(void)
int parse_args(int argc, char **argv)
{
/*
- int ret;
-
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
- }
- */
+ * int ret;
+ *
+ * while ((ret = getopt(argc, argv, "v")) >= 0)
+ * {
+ * switch (ret) {
+ * case 'v':
+ * verbose = 1;
+ * break;
+ * }
+ * }
+ */
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
return 0;
}
-
diff --git a/test/mpi/datatype/struct-pack.c b/test/mpi/datatype/struct-pack.c
index d7b5719..04c0807 100644
--- a/test/mpi/datatype/struct-pack.c
+++ b/test/mpi/datatype/struct-pack.c
@@ -18,8 +18,8 @@ int array_of_structs_test(void);
int struct_of_structs_test(void);
struct test_struct_1 {
- int a,b;
- char c,d;
+ int a, b;
+ char c, d;
int e;
};
@@ -32,27 +32,30 @@ int main(int argc, char *argv[])
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
err = single_struct_test();
- if (verbose && err) fprintf(stderr, "error in single_struct_test\n");
+ if (verbose && err)
+ fprintf(stderr, "error in single_struct_test\n");
errs += err;
err = array_of_structs_test();
- if (verbose && err) fprintf(stderr, "error in array_of_structs_test\n");
+ if (verbose && err)
+ fprintf(stderr, "error in array_of_structs_test\n");
errs += err;
err = struct_of_structs_test();
- if (verbose && err) fprintf(stderr, "error in struct_of_structs_test\n");
+ if (verbose && err)
+ fprintf(stderr, "error in struct_of_structs_test\n");
errs += err;
/* print message and exit */
if (errs) {
- fprintf(stderr, "Found %d errors\n", errs);
+ fprintf(stderr, "Found %d errors\n", errs);
}
else {
- printf(" No Errors\n");
+ printf(" No Errors\n");
}
MPI_Finalize();
return 0;
@@ -66,7 +69,7 @@ int single_struct_test(void)
MPI_Datatype mystruct;
char *buffer;
- MPI_Aint disps[3] = {0, 2*sizeof(int), 3*sizeof(int)}; /* guessing... */
+ MPI_Aint disps[3] = { 0, 2 * sizeof(int), 3 * sizeof(int) }; /* guessing... */
int blks[3] = { 2, 2, 1 };
MPI_Datatype types[3] = { MPI_INT, MPI_CHAR, MPI_INT };
@@ -78,10 +81,10 @@ int single_struct_test(void)
err = MPI_Type_struct(3, blks, disps, types, &mystruct);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Type_struct returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Type_struct returned error\n");
+ }
}
MPI_Type_commit(&mystruct);
@@ -89,69 +92,55 @@ int single_struct_test(void)
MPI_Pack_size(1, mystruct, MPI_COMM_WORLD, &bufsize);
buffer = (char *) malloc(bufsize);
- err = MPI_Pack(&ts1,
- 1,
- mystruct,
- buffer,
- bufsize,
- &position,
- MPI_COMM_WORLD);
+ err = MPI_Pack(&ts1, 1, mystruct, buffer, bufsize, &position, MPI_COMM_WORLD);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Pack returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Pack returned error\n");
+ }
}
position = 0;
- err = MPI_Unpack(buffer,
- bufsize,
- &position,
- &ts2,
- 1,
- mystruct,
- MPI_COMM_WORLD);
+ err = MPI_Unpack(buffer, bufsize, &position, &ts2, 1, mystruct, MPI_COMM_WORLD);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Unpack returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Unpack returned error\n");
+ }
}
MPI_Type_free(&mystruct);
free(buffer);
if (ts1.a != ts2.a) {
- errs++;
- if (verbose) {
- fprintf(stderr, "ts2.a = %d; should be %d\n", ts2.a, ts1.a);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "ts2.a = %d; should be %d\n", ts2.a, ts1.a);
+ }
}
if (ts1.b != ts2.b) {
- errs++;
- if (verbose) {
- fprintf(stderr, "ts2.b = %d; should be %d\n", ts2.b, ts1.b);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "ts2.b = %d; should be %d\n", ts2.b, ts1.b);
+ }
}
if (ts1.c != ts2.c) {
- errs++;
- if (verbose) {
- fprintf(stderr, "ts2.c = %d; should be %d\n",
- (int) ts2.c, (int) ts1.c);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "ts2.c = %d; should be %d\n", (int) ts2.c, (int) ts1.c);
+ }
}
if (ts1.d != ts2.d) {
- errs++;
- if (verbose) {
- fprintf(stderr, "ts2.d = %d; should be %d\n",
- (int) ts2.d, (int) ts1.d);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "ts2.d = %d; should be %d\n", (int) ts2.d, (int) ts1.d);
+ }
}
if (ts1.e != ts2.e) {
- errs++;
- if (verbose) {
- fprintf(stderr, "ts2.e = %d; should be %d\n", ts2.e, ts1.e);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "ts2.e = %d; should be %d\n", ts2.e, ts1.e);
+ }
}
return errs;
@@ -165,30 +154,30 @@ int array_of_structs_test(void)
MPI_Datatype mystruct;
char *buffer;
- MPI_Aint disps[3] = {0, 2*sizeof(int), 3*sizeof(int)}; /* guessing... */
+ MPI_Aint disps[3] = { 0, 2 * sizeof(int), 3 * sizeof(int) }; /* guessing... */
int blks[3] = { 2, 2, 1 };
MPI_Datatype types[3] = { MPI_INT, MPI_CHAR, MPI_INT };
- for (i=0; i < 10; i++) {
- ts1[i].a = 10*i + 1;
- ts1[i].b = 10*i + 2;
- ts1[i].c = 10*i + 3;
- ts1[i].d = 10*i + 4;
- ts1[i].e = 10*i + 5;
-
- ts2[i].a = -13;
- ts2[i].b = -13;
- ts2[i].c = -13;
- ts2[i].d = -13;
- ts2[i].e = -13;
+ for (i = 0; i < 10; i++) {
+ ts1[i].a = 10 * i + 1;
+ ts1[i].b = 10 * i + 2;
+ ts1[i].c = 10 * i + 3;
+ ts1[i].d = 10 * i + 4;
+ ts1[i].e = 10 * i + 5;
+
+ ts2[i].a = -13;
+ ts2[i].b = -13;
+ ts2[i].c = -13;
+ ts2[i].d = -13;
+ ts2[i].e = -13;
}
err = MPI_Type_struct(3, blks, disps, types, &mystruct);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Type_struct returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Type_struct returned error\n");
+ }
}
MPI_Type_commit(&mystruct);
@@ -196,74 +185,59 @@ int array_of_structs_test(void)
MPI_Pack_size(10, mystruct, MPI_COMM_WORLD, &bufsize);
buffer = (char *) malloc(bufsize);
- err = MPI_Pack(ts1,
- 10,
- mystruct,
- buffer,
- bufsize,
- &position,
- MPI_COMM_WORLD);
+ err = MPI_Pack(ts1, 10, mystruct, buffer, bufsize, &position, MPI_COMM_WORLD);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Pack returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Pack returned error\n");
+ }
}
position = 0;
- err = MPI_Unpack(buffer,
- bufsize,
- &position,
- ts2,
- 10,
- mystruct,
- MPI_COMM_WORLD);
+ err = MPI_Unpack(buffer, bufsize, &position, ts2, 10, mystruct, MPI_COMM_WORLD);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Unpack returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Unpack returned error\n");
+ }
}
MPI_Type_free(&mystruct);
free(buffer);
- for (i=0; i < 10; i++) {
- if (ts1[i].a != ts2[i].a) {
- errs++;
- if (verbose) {
- fprintf(stderr, "ts2[%d].a = %d; should be %d\n",
- i, ts2[i].a, ts1[i].a);
- }
- }
- if (ts1[i].b != ts2[i].b) {
- errs++;
- if (verbose) {
- fprintf(stderr, "ts2[%d].b = %d; should be %d\n",
- i, ts2[i].b, ts1[i].b);
- }
- }
- if (ts1[i].c != ts2[i].c) {
- errs++;
- if (verbose) {
- fprintf(stderr, "ts2[%d].c = %d; should be %d\n",
- i, (int) ts2[i].c, (int) ts1[i].c);
- }
- }
- if (ts1[i].d != ts2[i].d) {
- errs++;
- if (verbose) {
- fprintf(stderr, "ts2[%d].d = %d; should be %d\n",
- i, (int) ts2[i].d, (int) ts1[i].d);
- }
- }
- if (ts1[i].e != ts2[i].e) {
- errs++;
- if (verbose) {
- fprintf(stderr, "ts2[%d].e = %d; should be %d\n",
- i, ts2[i].e, ts1[i].e);
- }
- }
+ for (i = 0; i < 10; i++) {
+ if (ts1[i].a != ts2[i].a) {
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "ts2[%d].a = %d; should be %d\n", i, ts2[i].a, ts1[i].a);
+ }
+ }
+ if (ts1[i].b != ts2[i].b) {
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "ts2[%d].b = %d; should be %d\n", i, ts2[i].b, ts1[i].b);
+ }
+ }
+ if (ts1[i].c != ts2[i].c) {
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "ts2[%d].c = %d; should be %d\n",
+ i, (int) ts2[i].c, (int) ts1[i].c);
+ }
+ }
+ if (ts1[i].d != ts2[i].d) {
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "ts2[%d].d = %d; should be %d\n",
+ i, (int) ts2[i].d, (int) ts1[i].d);
+ }
+ }
+ if (ts1[i].e != ts2[i].e) {
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "ts2[%d].e = %d; should be %d\n", i, ts2[i].e, ts1[i].e);
+ }
+ }
}
return errs;
@@ -275,8 +249,8 @@ int struct_of_structs_test(void)
char buf[50], buf2[50], *packbuf;
- MPI_Aint disps[3] = {0, 3, 0};
- int blks[3] = {2, 1, 0};
+ MPI_Aint disps[3] = { 0, 3, 0 };
+ int blks[3] = { 2, 1, 0 };
MPI_Datatype types[3], chartype, tiletype1, tiletype2, finaltype;
/* build a contig of one char to try to keep optimizations
@@ -284,11 +258,11 @@ int struct_of_structs_test(void)
*/
err = MPI_Type_contiguous(1, MPI_CHAR, &chartype);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "chartype create failed\n");
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "chartype create failed\n");
+ }
+ return errs;
}
/* build a type that we can tile a few times */
@@ -297,40 +271,40 @@ int struct_of_structs_test(void)
err = MPI_Type_struct(2, blks, disps, types, &tiletype1);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "tiletype1 create failed\n");
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "tiletype1 create failed\n");
+ }
+ return errs;
}
/* build the same type again, again to avoid optimizations */
err = MPI_Type_struct(2, blks, disps, types, &tiletype2);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "tiletype2 create failed\n");
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "tiletype2 create failed\n");
+ }
+ return errs;
}
/* build a combination of those two tiletypes */
disps[0] = 0;
disps[1] = 5;
disps[2] = 10;
- blks[0] = 1;
- blks[1] = 1;
- blks[2] = 1;
+ blks[0] = 1;
+ blks[1] = 1;
+ blks[2] = 1;
types[0] = tiletype1;
types[1] = tiletype2;
types[2] = MPI_UB;
err = MPI_Type_struct(3, blks, disps, types, &finaltype);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "finaltype create failed\n");
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "finaltype create failed\n");
+ }
+ return errs;
}
MPI_Type_commit(&finaltype);
@@ -342,54 +316,54 @@ int struct_of_structs_test(void)
packbuf = malloc(bufsize);
if (packbuf == NULL) {
- errs++;
- if (verbose) {
- fprintf(stderr, "pack buffer allocation (%d bytes) failed\n", bufsize);
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "pack buffer allocation (%d bytes) failed\n", bufsize);
+ }
+ return errs;
}
- for (j=0; j < 10; j++) {
- for (i=0; i < 5; i++) {
- if (i == 2 || i == 4) buf[5*j + i] = 0;
- else buf[5*j + i] = i;
- }
+ for (j = 0; j < 10; j++) {
+ for (i = 0; i < 5; i++) {
+ if (i == 2 || i == 4)
+ buf[5 * j + i] = 0;
+ else
+ buf[5 * j + i] = i;
+ }
}
position = 0;
err = MPI_Pack(buf, 5, finaltype, packbuf, bufsize, &position, MPI_COMM_WORLD);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "pack failed\n");
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "pack failed\n");
+ }
+ return errs;
}
memset(buf2, 0, 50);
position = 0;
err = MPI_Unpack(packbuf, bufsize, &position, buf2, 5, finaltype, MPI_COMM_WORLD);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "unpack failed\n");
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "unpack failed\n");
+ }
+ return errs;
}
- for (j=0; j < 10; j++) {
- for (i=0; i < 5; i++) {
- if (buf[5*j + i] != buf2[5*j + i]) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "buf2[%d] = %d; should be %d\n",
- 5*j + i,
- (int) buf2[5*j+i],
- (int) buf[5*j+i]);
- }
- }
- }
+ for (j = 0; j < 10; j++) {
+ for (i = 0; i < 5; i++) {
+ if (buf[5 * j + i] != buf2[5 * j + i]) {
+ errs++;
+ if (verbose) {
+ fprintf(stderr,
+ "buf2[%d] = %d; should be %d\n",
+ 5 * j + i, (int) buf2[5 * j + i], (int) buf[5 * j + i]);
+ }
+ }
+ }
}
free(packbuf);
@@ -400,18 +374,18 @@ int struct_of_structs_test(void)
int parse_args(int argc, char **argv)
{
/*
- int ret;
-
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
- }
- */
+ * int ret;
+ *
+ * while ((ret = getopt(argc, argv, "v")) >= 0)
+ * {
+ * switch (ret) {
+ * case 'v':
+ * verbose = 1;
+ * break;
+ * }
+ * }
+ */
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
return 0;
}
diff --git a/test/mpi/datatype/struct-verydeep.c b/test/mpi/datatype/struct-verydeep.c
index f8bf884..222a0a3 100644
--- a/test/mpi/datatype/struct-verydeep.c
+++ b/test/mpi/datatype/struct-verydeep.c
@@ -16,11 +16,10 @@
extern int MPIDU_Datatype_debug(MPI_Datatype type, int depth);
*/
-int makeHDF5type0(MPI_Datatype *type);
-int makeHDF5type0(MPI_Datatype *type)
+int makeHDF5type0(MPI_Datatype * type);
+int makeHDF5type0(MPI_Datatype * type)
{
- MPI_Datatype ctg, vect, structype, vec2, structype2,
- vec3, structype3, vec4, structype4, vec5;
+ MPI_Datatype ctg, vect, structype, vec2, structype2, vec3, structype3, vec4, structype4, vec5;
int b[3];
MPI_Aint d[3];
@@ -30,37 +29,57 @@ int makeHDF5type0(MPI_Datatype *type)
MPI_Type_vector(1, 5, 1, ctg, &vect);
- b[0] = b[1] = b[2] = 1;
- d[0] = 0; d[1] = 0; d[2] = 40;
- t[0] = MPI_LB; t[1] = vect; t[2] = MPI_UB;
+ b[0] = b[1] = b[2] = 1;
+ d[0] = 0;
+ d[1] = 0;
+ d[2] = 40;
+ t[0] = MPI_LB;
+ t[1] = vect;
+ t[2] = MPI_UB;
MPI_Type_create_struct(3, b, d, t, &structype);
MPI_Type_vector(1, 5, 1, structype, &vec2);
- b[0] = b[1] = b[2] = 1;
- d[0] = 0; d[1] = 2000; d[2] = 400;
- t[0] = MPI_LB; t[1] = vec2; t[2] = MPI_UB;
+ b[0] = b[1] = b[2] = 1;
+ d[0] = 0;
+ d[1] = 2000;
+ d[2] = 400;
+ t[0] = MPI_LB;
+ t[1] = vec2;
+ t[2] = MPI_UB;
MPI_Type_create_struct(3, b, d, t, &structype2);
MPI_Type_vector(1, 5, 1, structype2, &vec3);
- b[0] = b[1] = b[2] = 1;
- d[0] = 0; d[1] = 0; d[2] = 4000;
- t[0] = MPI_LB; t[1] = vec3; t[2] = MPI_UB;
+ b[0] = b[1] = b[2] = 1;
+ d[0] = 0;
+ d[1] = 0;
+ d[2] = 4000;
+ t[0] = MPI_LB;
+ t[1] = vec3;
+ t[2] = MPI_UB;
MPI_Type_create_struct(3, b, d, t, &structype3);
MPI_Type_vector(1, 5, 1, structype3, &vec4);
- b[0] = b[1] = b[2] = 1;
- d[0] = 0; d[1] = 0; d[2] = 40000;
- t[0] = MPI_LB; t[1] = vec4; t[2] = MPI_UB;
+ b[0] = b[1] = b[2] = 1;
+ d[0] = 0;
+ d[1] = 0;
+ d[2] = 40000;
+ t[0] = MPI_LB;
+ t[1] = vec4;
+ t[2] = MPI_UB;
MPI_Type_create_struct(3, b, d, t, &structype4);
MPI_Type_vector(1, 1, 1, structype4, &vec5);
- b[0] = b[1] = b[2] = 1;
- d[0] = 0; d[1] = 160000; d[2] = 200000;
- t[0] = MPI_LB; t[1] = vec5; t[2] = MPI_UB;
+ b[0] = b[1] = b[2] = 1;
+ d[0] = 0;
+ d[1] = 160000;
+ d[2] = 200000;
+ t[0] = MPI_LB;
+ t[1] = vec5;
+ t[2] = MPI_UB;
MPI_Type_create_struct(3, b, d, t, type);
MPI_Type_free(&ctg);
@@ -78,11 +97,10 @@ int makeHDF5type0(MPI_Datatype *type)
return 0;
}
-int makeHDF5type1(MPI_Datatype *type);
-int makeHDF5type1(MPI_Datatype *type)
+int makeHDF5type1(MPI_Datatype * type);
+int makeHDF5type1(MPI_Datatype * type)
{
- MPI_Datatype ctg, vect, structype, vec2, structype2,
- vec3, structype3, vec4, structype4, vec5;
+ MPI_Datatype ctg, vect, structype, vec2, structype2, vec3, structype3, vec4, structype4, vec5;
int b[3];
MPI_Aint d[3];
@@ -92,37 +110,57 @@ int makeHDF5type1(MPI_Datatype *type)
MPI_Type_vector(1, 5, 1, ctg, &vect);
- b[0] = b[1] = b[2] = 1;
- d[0] = 0; d[1] = 20; d[2] = 40;
- t[0] = MPI_LB; t[1] = vect; t[2] = MPI_UB;
+ b[0] = b[1] = b[2] = 1;
+ d[0] = 0;
+ d[1] = 20;
+ d[2] = 40;
+ t[0] = MPI_LB;
+ t[1] = vect;
+ t[2] = MPI_UB;
MPI_Type_create_struct(3, b, d, t, &structype);
MPI_Type_vector(1, 5, 1, structype, &vec2);
- b[0] = b[1] = b[2] = 1;
- d[0] = 0; d[1] = 0; d[2] = 400;
- t[0] = MPI_LB; t[1] = vec2; t[2] = MPI_UB;
+ b[0] = b[1] = b[2] = 1;
+ d[0] = 0;
+ d[1] = 0;
+ d[2] = 400;
+ t[0] = MPI_LB;
+ t[1] = vec2;
+ t[2] = MPI_UB;
MPI_Type_create_struct(3, b, d, t, &structype2);
MPI_Type_vector(1, 5, 1, structype2, &vec3);
- b[0] = b[1] = b[2] = 1;
- d[0] = 0; d[1] = 0; d[2] = 4000;
- t[0] = MPI_LB; t[1] = vec3; t[2] = MPI_UB;
+ b[0] = b[1] = b[2] = 1;
+ d[0] = 0;
+ d[1] = 0;
+ d[2] = 4000;
+ t[0] = MPI_LB;
+ t[1] = vec3;
+ t[2] = MPI_UB;
MPI_Type_create_struct(3, b, d, t, &structype3);
MPI_Type_vector(1, 5, 1, structype3, &vec4);
- b[0] = b[1] = b[2] = 1;
- d[0] = 0; d[1] = 0; d[2] = 40000;
- t[0] = MPI_LB; t[1] = vec4; t[2] = MPI_UB;
+ b[0] = b[1] = b[2] = 1;
+ d[0] = 0;
+ d[1] = 0;
+ d[2] = 40000;
+ t[0] = MPI_LB;
+ t[1] = vec4;
+ t[2] = MPI_UB;
MPI_Type_create_struct(3, b, d, t, &structype4);
MPI_Type_vector(1, 1, 1, structype4, &vec5);
- b[0] = b[1] = b[2] = 1;
- d[0] = 0; d[1] = 160000; d[2] = 200000;
- t[0] = MPI_LB; t[1] = vec5; t[2] = MPI_UB;
+ b[0] = b[1] = b[2] = 1;
+ d[0] = 0;
+ d[1] = 160000;
+ d[2] = 200000;
+ t[0] = MPI_LB;
+ t[1] = vec5;
+ t[2] = MPI_UB;
MPI_Type_create_struct(3, b, d, t, type);
MPI_Type_free(&ctg);
@@ -140,8 +178,8 @@ int makeHDF5type1(MPI_Datatype *type)
return 0;
}
-int makeHDF5type(MPI_Datatype *type);
-int makeHDF5type(MPI_Datatype *type)
+int makeHDF5type(MPI_Datatype * type);
+int makeHDF5type(MPI_Datatype * type)
{
int i;
@@ -154,7 +192,7 @@ int makeHDF5type(MPI_Datatype *type)
makeHDF5type0(&(types[0]));
makeHDF5type1(&(types[1]));
- for (i=0; i< NTYPES; i++) {
+ for (i = 0; i < NTYPES; i++) {
blocklens[i] = 1;
disps[i] = 0;
}
@@ -162,7 +200,7 @@ int makeHDF5type(MPI_Datatype *type)
MPI_Type_create_struct(NTYPES, blocklens, disps, types, type);
MPI_Type_commit(type);
- for(i=0; i<NTYPES; i++) {
+ for (i = 0; i < NTYPES; i++) {
MPI_Type_free(&(types[i]));
}
return 0;
@@ -175,7 +213,7 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv);
makeHDF5type(&hdf5type);
- /*MPIDU_Datatype_debug(hdf5type, 32);*/
+ /*MPIDU_Datatype_debug(hdf5type, 32); */
MPI_Type_free(&hdf5type);
MPI_Finalize();
@@ -184,4 +222,3 @@ int main(int argc, char **argv)
return 0;
}
-
diff --git a/test/mpi/datatype/struct-zero-count.c b/test/mpi/datatype/struct-zero-count.c
index 74b2d19..0b76219 100644
--- a/test/mpi/datatype/struct-zero-count.c
+++ b/test/mpi/datatype/struct-zero-count.c
@@ -23,24 +23,25 @@ int main(int argc, char **argv)
{
int err, errs = 0;
- MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
+ MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
/* perform some tests */
err = builtin_struct_test();
- if (err && verbose) fprintf(stderr, "%d errors in builtin struct test.\n", err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in builtin struct test.\n", err);
errs += err;
/* print message and exit */
if (errs) {
- fprintf(stderr, "Found %d errors\n", errs);
+ fprintf(stderr, "Found %d errors\n", errs);
}
else {
- printf(" No Errors\n");
+ printf(" No Errors\n");
}
MPI_Finalize();
return 0;
@@ -62,54 +63,45 @@ int builtin_struct_test(void)
int size;
MPI_Aint extent;
- err = MPI_Type_create_struct(count,
- (int *) 0,
- (MPI_Aint *) 0,
- (MPI_Datatype *) 0,
- &newtype);
+ err = MPI_Type_create_struct(count, (int *) 0, (MPI_Aint *) 0, (MPI_Datatype *) 0, &newtype);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error creating struct type in builtin_struct_test()\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "error creating struct type in builtin_struct_test()\n");
+ }
+ errs++;
}
err = MPI_Type_size(newtype, &size);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error obtaining type size in builtin_struct_test()\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "error obtaining type size in builtin_struct_test()\n");
+ }
+ errs++;
}
-
+
if (size != 0) {
- if (verbose) {
- fprintf(stderr,
- "error: size != 0 in builtin_struct_test()\n");
- }
- errs++;
- }
+ if (verbose) {
+ fprintf(stderr, "error: size != 0 in builtin_struct_test()\n");
+ }
+ errs++;
+ }
err = MPI_Type_extent(newtype, &extent);
if (err != MPI_SUCCESS) {
- if (verbose) {
- fprintf(stderr,
- "error obtaining type extent in builtin_struct_test()\n");
- }
- errs++;
+ if (verbose) {
+ fprintf(stderr, "error obtaining type extent in builtin_struct_test()\n");
+ }
+ errs++;
}
-
+
if (extent != 0) {
- if (verbose) {
- fprintf(stderr,
- "error: extent != 0 in builtin_struct_test()\n");
- }
- errs++;
- }
+ if (verbose) {
+ fprintf(stderr, "error: extent != 0 in builtin_struct_test()\n");
+ }
+ errs++;
+ }
- MPI_Type_free( &newtype );
+ MPI_Type_free(&newtype);
return errs;
}
@@ -118,19 +110,18 @@ int builtin_struct_test(void)
int parse_args(int argc, char **argv)
{
/*
- int ret;
-
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
- }
- */
+ * int ret;
+ *
+ * while ((ret = getopt(argc, argv, "v")) >= 0)
+ * {
+ * switch (ret) {
+ * case 'v':
+ * verbose = 1;
+ * break;
+ * }
+ * }
+ */
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
return 0;
}
-
diff --git a/test/mpi/datatype/structpack2.c b/test/mpi/datatype/structpack2.c
index 1dcbd2e..ef6a411 100644
--- a/test/mpi/datatype/structpack2.c
+++ b/test/mpi/datatype/structpack2.c
@@ -10,105 +10,104 @@
/* The next is for isprint */
#include <ctype.h>
-int main( int argc, char *argv[])
+int main(int argc, char *argv[])
{
- struct a { int i;
- char c;
- } s[10], s1[10];
- int j;
- int errs = 0, toterrs;
- int rank, size, tsize;
- MPI_Aint text;
- int blens[2];
- MPI_Aint disps[2];
- MPI_Datatype bases[2];
- MPI_Datatype str, con;
- char *buffer;
- int bufsize, position, insize;
+ struct a {
+ int i;
+ char c;
+ } s[10], s1[10];
+ int j;
+ int errs = 0, toterrs;
+ int rank, size, tsize;
+ MPI_Aint text;
+ int blens[2];
+ MPI_Aint disps[2];
+ MPI_Datatype bases[2];
+ MPI_Datatype str, con;
+ char *buffer;
+ int bufsize, position, insize;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
- for( j = 0; j < 10; j ++ ) {
- s[j].i = j + rank;
- s[j].c = j + rank + 'a';
- }
+ for (j = 0; j < 10; j++) {
+ s[j].i = j + rank;
+ s[j].c = j + rank + 'a';
+ }
- blens[0] = blens[1] = 1;
- disps[0] = 0; disps[1] = sizeof(int);
- bases[0] = MPI_INT; bases[1] = MPI_CHAR;
- MPI_Type_struct( 2, blens, disps, bases, &str );
- MPI_Type_commit( &str );
- MPI_Type_contiguous( 10, str, &con );
- MPI_Type_commit( &con );
- MPI_Type_size( con, &tsize );
- MPI_Type_extent( con, &text );
+ blens[0] = blens[1] = 1;
+ disps[0] = 0;
+ disps[1] = sizeof(int);
+ bases[0] = MPI_INT;
+ bases[1] = MPI_CHAR;
+ MPI_Type_struct(2, blens, disps, bases, &str);
+ MPI_Type_commit(&str);
+ MPI_Type_contiguous(10, str, &con);
+ MPI_Type_commit(&con);
+ MPI_Type_size(con, &tsize);
+ MPI_Type_extent(con, &text);
#ifdef DEBUG
- printf("Size of MPI array is %d, extent is %d\n", tsize, text );
+ printf("Size of MPI array is %d, extent is %d\n", tsize, text);
#endif
#ifdef DEBUG
- {
- void * p1, *p2;
- p1 = s;
- p2 = &(s[10].i); /* This statement may fail on some systems */
- printf("C array starts at %p and ends at %p for a length of %d\n",
- s, &(s[9].c), (char *)p2-(char *)p1 );
- }
+ {
+ void *p1, *p2;
+ p1 = s;
+ p2 = &(s[10].i); /* This statement may fail on some systems */
+ printf("C array starts at %p and ends at %p for a length of %d\n",
+ s, &(s[9].c), (char *) p2 - (char *) p1);
+ }
#endif
- MPI_Type_extent( str, &text );
+ MPI_Type_extent(str, &text);
#ifdef DEBUG
- MPI_Type_size( str, &tsize );
- printf("Size of MPI struct is %d, extent is %d\n", tsize, (int)text );
- printf("Size of C struct is %d\n", sizeof(struct a) );
+ MPI_Type_size(str, &tsize);
+ printf("Size of MPI struct is %d, extent is %d\n", tsize, (int) text);
+ printf("Size of C struct is %d\n", sizeof(struct a));
#endif
- if (text != sizeof(struct a)) {
- printf( "Extent of struct a (%d) does not match sizeof (%d)\n",
- (int)text, (int)sizeof(struct a) );
- errs++;
- }
+ if (text != sizeof(struct a)) {
+ printf("Extent of struct a (%d) does not match sizeof (%d)\n",
+ (int) text, (int) sizeof(struct a));
+ errs++;
+ }
- MPI_Pack_size(1, con, MPI_COMM_WORLD, &bufsize);
- buffer = (char *) malloc(bufsize);
+ MPI_Pack_size(1, con, MPI_COMM_WORLD, &bufsize);
+ buffer = (char *) malloc(bufsize);
- position = 0;
- MPI_Pack(s,1,con,buffer,bufsize,&position,MPI_COMM_WORLD);
- insize = position;
- position = 0;
- MPI_Unpack(buffer,insize,&position,s1,1,con,MPI_COMM_WORLD );
+ position = 0;
+ MPI_Pack(s, 1, con, buffer, bufsize, &position, MPI_COMM_WORLD);
+ insize = position;
+ position = 0;
+ MPI_Unpack(buffer, insize, &position, s1, 1, con, MPI_COMM_WORLD);
- for( j = 0; j < 10; j++ ) {
+ for (j = 0; j < 10; j++) {
#ifdef DEBUG
- printf("%d Sent: %d %c, Got: %d %c\n", rank,
- s[j].i, s[j].c, s1[j].i, s1[j].c );
+ printf("%d Sent: %d %c, Got: %d %c\n", rank, s[j].i, s[j].c, s1[j].i, s1[j].c);
#endif
- if ( s1[j].i != j + rank ) {
- errs++;
- printf( "Got s[%d].i = %d (%x); expected %d\n", j, s1[j].i,
- s1[j].i, j + rank );
- }
- if ( s1[j].c != 'a' + j + rank ) {
- errs++;
- /* If the character is not a printing character,
- this can generate an file that diff, for example,
- believes is a binary file */
- if (isprint( (int)(s1[j].c) )) {
- printf( "Got s[%d].c = %c; expected %c\n", j, s1[j].c,
- j + rank + 'a');
- }
- else {
- printf( "Got s[%d].c = %x; expected %c\n", j, (int)s1[j].c,
- j + rank + 'a');
- }
- }
- }
+ if (s1[j].i != j + rank) {
+ errs++;
+ printf("Got s[%d].i = %d (%x); expected %d\n", j, s1[j].i, s1[j].i, j + rank);
+ }
+ if (s1[j].c != 'a' + j + rank) {
+ errs++;
+ /* If the character is not a printing character,
+ * this can generate an file that diff, for example,
+ * believes is a binary file */
+ if (isprint((int) (s1[j].c))) {
+ printf("Got s[%d].c = %c; expected %c\n", j, s1[j].c, j + rank + 'a');
+ }
+ else {
+ printf("Got s[%d].c = %x; expected %c\n", j, (int) s1[j].c, j + rank + 'a');
+ }
+ }
+ }
- MPI_Type_free( &str );
- MPI_Type_free( &con );
- MTest_Finalize( errs );
- MPI_Finalize();
- return 0;
+ MPI_Type_free(&str);
+ MPI_Type_free(&con);
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
}
diff --git a/test/mpi/datatype/subarray-pack.c b/test/mpi/datatype/subarray-pack.c
index 79cd40b..aa73700 100644
--- a/test/mpi/datatype/subarray-pack.c
+++ b/test/mpi/datatype/subarray-pack.c
@@ -21,66 +21,61 @@ int subarray_4d_fortran_test1(void);
/* helper functions */
static int parse_args(int argc, char **argv);
-static int pack_and_unpack(char *typebuf,
- int count,
- MPI_Datatype datatype,
- int typebufsz);
+static int pack_and_unpack(char *typebuf, int count, MPI_Datatype datatype, int typebufsz);
int main(int argc, char **argv)
{
int err, errs = 0;
- MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
+ MPI_Init(&argc, &argv); /* MPI-1.2 doesn't allow for MPI_Init(0,0) */
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
/* perform some tests */
err = subarray_1d_c_test1();
- if (err && verbose) fprintf(stderr,
- "%d errors in 1d subarray c test 1.\n", err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in 1d subarray c test 1.\n", err);
errs += err;
err = subarray_1d_fortran_test1();
- if (err && verbose) fprintf(stderr,
- "%d errors in 1d subarray fortran test 1.\n",
- err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in 1d subarray fortran test 1.\n", err);
errs += err;
err = subarray_2d_c_test1();
- if (err && verbose) fprintf(stderr,
- "%d errors in 2d subarray c test 1.\n", err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in 2d subarray c test 1.\n", err);
errs += err;
err = subarray_2d_fortran_test1();
- if (err && verbose) fprintf(stderr,
- "%d errors in 2d subarray fortran test 1.\n",
- err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in 2d subarray fortran test 1.\n", err);
errs += err;
err = subarray_2d_c_test2();
- if (err && verbose) fprintf(stderr,
- "%d errors in 2d subarray c test 2.\n", err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in 2d subarray c test 2.\n", err);
errs += err;
err = subarray_4d_c_test1();
- if (err && verbose) fprintf(stderr,
- "%d errors in 4d subarray c test 1.\n", err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in 4d subarray c test 1.\n", err);
errs += err;
err = subarray_4d_fortran_test1();
- if (err && verbose) fprintf(stderr,
- "%d errors in 4d subarray fortran test 1.\n", err);
+ if (err && verbose)
+ fprintf(stderr, "%d errors in 4d subarray fortran test 1.\n", err);
errs += err;
/* print message and exit */
if (errs) {
- fprintf(stderr, "Found %d errors\n", errs);
+ fprintf(stderr, "Found %d errors\n", errs);
}
else {
- printf(" No Errors\n");
+ printf(" No Errors\n");
}
MPI_Finalize();
return 0;
@@ -94,62 +89,58 @@ int subarray_1d_c_test1(void)
{
MPI_Datatype subarray;
int array[9] = { -1, 1, 2, 3, -2, -3, -4, -5, -6 };
- int array_size[] = {9};
- int array_subsize[] = {3};
- int array_start[] = {1};
+ int array_size[] = { 9 };
+ int array_subsize[] = { 3 };
+ int array_start[] = { 1 };
int i, err, errs = 0, sizeoftype;
/* set up type */
- err = MPI_Type_create_subarray(1, /* dims */
- array_size,
- array_subsize,
- array_start,
- MPI_ORDER_C,
- MPI_INT,
- &subarray);
+ err = MPI_Type_create_subarray(1, /* dims */
+ array_size,
+ array_subsize, array_start, MPI_ORDER_C, MPI_INT, &subarray);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in MPI_Type_create_subarray call; aborting after %d errors\n",
- errs);
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr,
+ "error in MPI_Type_create_subarray call; aborting after %d errors\n", errs);
+ }
+ return errs;
}
MPI_Type_commit(&subarray);
MPI_Type_size(subarray, &sizeoftype);
if (sizeoftype != 3 * sizeof(int)) {
- errs++;
- if (verbose) fprintf(stderr, "size of type = %d; should be %d\n",
- sizeoftype, (int) (3 * sizeof(int)));
- return errs;
+ errs++;
+ if (verbose)
+ fprintf(stderr, "size of type = %d; should be %d\n",
+ sizeoftype, (int) (3 * sizeof(int)));
+ return errs;
}
err = pack_and_unpack((char *) array, 1, subarray, 9 * sizeof(int));
- for (i=0; i < 9; i++) {
- int goodval;
- switch (i) {
- case 1:
- goodval = 1;
- break;
- case 2:
- goodval = 2;
- break;
- case 3:
- goodval = 3;
- break;
- default:
- goodval = 0; /* pack_and_unpack() zeros before unpacking */
- break;
- }
- if (array[i] != goodval) {
- errs++;
- if (verbose) fprintf(stderr, "array[%d] = %d; should be %d\n",
- i, array[i], goodval);
- }
+ for (i = 0; i < 9; i++) {
+ int goodval;
+ switch (i) {
+ case 1:
+ goodval = 1;
+ break;
+ case 2:
+ goodval = 2;
+ break;
+ case 3:
+ goodval = 3;
+ break;
+ default:
+ goodval = 0; /* pack_and_unpack() zeros before unpacking */
+ break;
+ }
+ if (array[i] != goodval) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "array[%d] = %d; should be %d\n", i, array[i], goodval);
+ }
}
MPI_Type_free(&subarray);
@@ -164,62 +155,59 @@ int subarray_1d_fortran_test1(void)
{
MPI_Datatype subarray;
int array[9] = { -1, 1, 2, 3, -2, -3, -4, -5, -6 };
- int array_size[] = {9};
- int array_subsize[] = {3};
- int array_start[] = {1};
+ int array_size[] = { 9 };
+ int array_subsize[] = { 3 };
+ int array_start[] = { 1 };
int i, err, errs = 0, sizeoftype;
/* set up type */
- err = MPI_Type_create_subarray(1, /* dims */
- array_size,
- array_subsize,
- array_start,
- MPI_ORDER_FORTRAN,
- MPI_INT,
- &subarray);
+ err = MPI_Type_create_subarray(1, /* dims */
+ array_size,
+ array_subsize,
+ array_start, MPI_ORDER_FORTRAN, MPI_INT, &subarray);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in MPI_Type_create_subarray call; aborting after %d errors\n",
- errs);
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr,
+ "error in MPI_Type_create_subarray call; aborting after %d errors\n", errs);
+ }
+ return errs;
}
MPI_Type_commit(&subarray);
MPI_Type_size(subarray, &sizeoftype);
if (sizeoftype != 3 * sizeof(int)) {
- errs++;
- if (verbose) fprintf(stderr, "size of type = %d; should be %d\n",
- sizeoftype, (int) (3 * sizeof(int)));
- return errs;
+ errs++;
+ if (verbose)
+ fprintf(stderr, "size of type = %d; should be %d\n",
+ sizeoftype, (int) (3 * sizeof(int)));
+ return errs;
}
err = pack_and_unpack((char *) array, 1, subarray, 9 * sizeof(int));
- for (i=0; i < 9; i++) {
- int goodval;
- switch (i) {
- case 1:
- goodval = 1;
- break;
- case 2:
- goodval = 2;
- break;
- case 3:
- goodval = 3;
- break;
- default:
- goodval = 0; /* pack_and_unpack() zeros before unpacking */
- break;
- }
- if (array[i] != goodval) {
- errs++;
- if (verbose) fprintf(stderr, "array[%d] = %d; should be %d\n",
- i, array[i], goodval);
- }
+ for (i = 0; i < 9; i++) {
+ int goodval;
+ switch (i) {
+ case 1:
+ goodval = 1;
+ break;
+ case 2:
+ goodval = 2;
+ break;
+ case 3:
+ goodval = 3;
+ break;
+ default:
+ goodval = 0; /* pack_and_unpack() zeros before unpacking */
+ break;
+ }
+ if (array[i] != goodval) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "array[%d] = %d; should be %d\n", i, array[i], goodval);
+ }
}
MPI_Type_free(&subarray);
@@ -235,67 +223,64 @@ int subarray_2d_c_test1(void)
{
MPI_Datatype subarray;
int array[9] = { -1, -2, -3,
- -4, 1, 2,
- -5, 3, 4 };
- int array_size[2] = {3, 3};
- int array_subsize[2] = {2, 2};
- int array_start[2] = {1, 1};
+ -4, 1, 2,
+ -5, 3, 4
+ };
+ int array_size[2] = { 3, 3 };
+ int array_subsize[2] = { 2, 2 };
+ int array_start[2] = { 1, 1 };
int i, err, errs = 0, sizeoftype;
/* set up type */
- err = MPI_Type_create_subarray(2, /* dims */
- array_size,
- array_subsize,
- array_start,
- MPI_ORDER_C,
- MPI_INT,
- &subarray);
+ err = MPI_Type_create_subarray(2, /* dims */
+ array_size,
+ array_subsize, array_start, MPI_ORDER_C, MPI_INT, &subarray);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in MPI_Type_create_subarray call; aborting after %d errors\n",
- errs);
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr,
+ "error in MPI_Type_create_subarray call; aborting after %d errors\n", errs);
+ }
+ return errs;
}
MPI_Type_commit(&subarray);
MPI_Type_size(subarray, &sizeoftype);
- if (sizeoftype != 4*sizeof(int)) {
- errs++;
- if (verbose) fprintf(stderr, "size of type = %d; should be %d\n",
- sizeoftype, (int) (4*sizeof(int)));
- return errs;
+ if (sizeoftype != 4 * sizeof(int)) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "size of type = %d; should be %d\n",
+ sizeoftype, (int) (4 * sizeof(int)));
+ return errs;
}
- err = pack_and_unpack((char *) array, 1, subarray, 9*sizeof(int));
-
- for (i=0; i < 9; i++) {
- int goodval;
- switch (i) {
- case 4:
- goodval = 1;
- break;
- case 5:
- goodval = 2;
- break;
- case 7:
- goodval = 3;
- break;
- case 8:
- goodval = 4;
- break;
- default:
- goodval = 0;
- break;
- }
- if (array[i] != goodval) {
- errs++;
- if (verbose) fprintf(stderr, "array[%d] = %d; should be %d\n",
- i, array[i], goodval);
- }
+ err = pack_and_unpack((char *) array, 1, subarray, 9 * sizeof(int));
+
+ for (i = 0; i < 9; i++) {
+ int goodval;
+ switch (i) {
+ case 4:
+ goodval = 1;
+ break;
+ case 5:
+ goodval = 2;
+ break;
+ case 7:
+ goodval = 3;
+ break;
+ case 8:
+ goodval = 4;
+ break;
+ default:
+ goodval = 0;
+ break;
+ }
+ if (array[i] != goodval) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "array[%d] = %d; should be %d\n", i, array[i], goodval);
+ }
}
MPI_Type_free(&subarray);
@@ -309,61 +294,58 @@ int subarray_2d_c_test1(void)
int subarray_2d_c_test2(void)
{
MPI_Datatype subarray;
- int array[12] = { -1, -2, -3, -4, 1, 2,
- -5, -6, -7, -8, -9, -10 };
- int array_size[2] = {2, 6};
- int array_subsize[2] = {1, 2};
- int array_start[2] = {0, 4};
+ int array[12] = { -1, -2, -3, -4, 1, 2,
+ -5, -6, -7, -8, -9, -10
+ };
+ int array_size[2] = { 2, 6 };
+ int array_subsize[2] = { 1, 2 };
+ int array_start[2] = { 0, 4 };
int i, err, errs = 0, sizeoftype;
/* set up type */
- err = MPI_Type_create_subarray(2, /* dims */
- array_size,
- array_subsize,
- array_start,
- MPI_ORDER_C,
- MPI_INT,
- &subarray);
+ err = MPI_Type_create_subarray(2, /* dims */
+ array_size,
+ array_subsize, array_start, MPI_ORDER_C, MPI_INT, &subarray);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in MPI_Type_create_subarray call; aborting after %d errors\n",
- errs);
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr,
+ "error in MPI_Type_create_subarray call; aborting after %d errors\n", errs);
+ }
+ return errs;
}
MPI_Type_commit(&subarray);
MPI_Type_size(subarray, &sizeoftype);
- if (sizeoftype != 2*sizeof(int)) {
- errs++;
- if (verbose) fprintf(stderr, "size of type = %d; should be %d\n",
- sizeoftype, (int) (2*sizeof(int)));
- return errs;
+ if (sizeoftype != 2 * sizeof(int)) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "size of type = %d; should be %d\n",
+ sizeoftype, (int) (2 * sizeof(int)));
+ return errs;
}
- err = pack_and_unpack((char *) array, 1, subarray, 12*sizeof(int));
-
- for (i=0; i < 12; i++) {
- int goodval;
- switch (i) {
- case 4:
- goodval = 1;
- break;
- case 5:
- goodval = 2;
- break;
- default:
- goodval = 0;
- break;
- }
- if (array[i] != goodval) {
- errs++;
- if (verbose) fprintf(stderr, "array[%d] = %d; should be %d\n",
- i, array[i], goodval);
- }
+ err = pack_and_unpack((char *) array, 1, subarray, 12 * sizeof(int));
+
+ for (i = 0; i < 12; i++) {
+ int goodval;
+ switch (i) {
+ case 4:
+ goodval = 1;
+ break;
+ case 5:
+ goodval = 2;
+ break;
+ default:
+ goodval = 0;
+ break;
+ }
+ if (array[i] != goodval) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "array[%d] = %d; should be %d\n", i, array[i], goodval);
+ }
}
MPI_Type_free(&subarray);
@@ -378,90 +360,87 @@ int subarray_4d_c_test1(void)
{
MPI_Datatype subarray;
int array[] = {
- -1111, -1112, -1113, -1114, -1115, -1116,
- -1121, -1122, -1123, -1124, -1125, -1126,
- -1131, -1132, -1133, -1134, -1135, -1136,
- -1211, -1212, -1213, -1214, -1215, -1216,
- -1221, -1222, -1223, -1224, -1225, -1226,
- -1231, -1232, -1233, -1234, -1235, -1236,
- -2111, -2112, -2113, -2114, 1, -2116,
- -2121, -2122, -2123, -2124, 2, -2126,
- -2131, -2132, -2133, -2134, 3, -2136,
- -2211, -2212, -2213, -2214, 4, -2216,
- -2221, -2222, -2223, -2224, 5, -2226,
- -2231, -2232, -2233, -2234, 6, -2236
+ -1111, -1112, -1113, -1114, -1115, -1116,
+ -1121, -1122, -1123, -1124, -1125, -1126,
+ -1131, -1132, -1133, -1134, -1135, -1136,
+ -1211, -1212, -1213, -1214, -1215, -1216,
+ -1221, -1222, -1223, -1224, -1225, -1226,
+ -1231, -1232, -1233, -1234, -1235, -1236,
+ -2111, -2112, -2113, -2114, 1, -2116,
+ -2121, -2122, -2123, -2124, 2, -2126,
+ -2131, -2132, -2133, -2134, 3, -2136,
+ -2211, -2212, -2213, -2214, 4, -2216,
+ -2221, -2222, -2223, -2224, 5, -2226,
+ -2231, -2232, -2233, -2234, 6, -2236
};
-
- int array_size[4] = {2, 2, 3, 6};
- int array_subsize[4] = {1, 2, 3, 1};
- int array_start[4] = {1, 0, 0, 4};
+
+ int array_size[4] = { 2, 2, 3, 6 };
+ int array_subsize[4] = { 1, 2, 3, 1 };
+ int array_start[4] = { 1, 0, 0, 4 };
int i, err, errs = 0, sizeoftype;
/* set up type */
- err = MPI_Type_create_subarray(4, /* dims */
- array_size,
- array_subsize,
- array_start,
- MPI_ORDER_C,
- MPI_INT,
- &subarray);
+ err = MPI_Type_create_subarray(4, /* dims */
+ array_size,
+ array_subsize, array_start, MPI_ORDER_C, MPI_INT, &subarray);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in MPI_Type_create_subarray call; aborting after %d errors\n",
- errs);
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr,
+ "error in MPI_Type_create_subarray call; aborting after %d errors\n", errs);
+ }
+ return errs;
}
MPI_Type_commit(&subarray);
MPI_Type_size(subarray, &sizeoftype);
- if (sizeoftype != 6*sizeof(int)) {
- errs++;
- if (verbose) fprintf(stderr, "size of type = %d; should be %d\n",
- sizeoftype, (int) (6*sizeof(int)));
- return errs;
+ if (sizeoftype != 6 * sizeof(int)) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "size of type = %d; should be %d\n",
+ sizeoftype, (int) (6 * sizeof(int)));
+ return errs;
}
- err = pack_and_unpack((char *) array, 1, subarray, 72*sizeof(int));
-
- for (i=0; i < 72; i++) {
- int goodval;
- switch (i) {
- case 40:
- goodval = 1;
- break;
- case 46:
- goodval = 2;
- break;
- case 52:
- goodval = 3;
- break;
- case 58:
- goodval = 4;
- break;
- case 64:
- goodval = 5;
- break;
- case 70:
- goodval = 6;
- break;
- default:
- goodval = 0;
- break;
- }
- if (array[i] != goodval) {
- errs++;
- if (verbose) fprintf(stderr, "array[%d] = %d; should be %d\n",
- i, array[i], goodval);
- }
+ err = pack_and_unpack((char *) array, 1, subarray, 72 * sizeof(int));
+
+ for (i = 0; i < 72; i++) {
+ int goodval;
+ switch (i) {
+ case 40:
+ goodval = 1;
+ break;
+ case 46:
+ goodval = 2;
+ break;
+ case 52:
+ goodval = 3;
+ break;
+ case 58:
+ goodval = 4;
+ break;
+ case 64:
+ goodval = 5;
+ break;
+ case 70:
+ goodval = 6;
+ break;
+ default:
+ goodval = 0;
+ break;
+ }
+ if (array[i] != goodval) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "array[%d] = %d; should be %d\n", i, array[i], goodval);
+ }
}
MPI_Type_free(&subarray);
return errs;
}
+
/* subarray_4d_fortran_test1()
*
* Returns the number of errors encountered.
@@ -470,85 +449,82 @@ int subarray_4d_fortran_test1(void)
{
MPI_Datatype subarray;
int array[] = {
- -1111, -1112, -1113, -1114, -1115, -1116,
- -1121, -1122, -1123, -1124, -1125, -1126,
- -1131, -1132, -1133, -1134, -1135, -1136,
- -1211, -1212, -1213, -1214, -1215, -1216,
- -1221, -1222, -1223, -1224, -1225, -1226,
- -1231, -1232, -1233, -1234, -1235, -1236,
- -2111, -2112, -2113, -2114, 1, -2116,
- -2121, -2122, -2123, -2124, 2, -2126,
- -2131, -2132, -2133, -2134, 3, -2136,
- -2211, -2212, -2213, -2214, 4, -2216,
- -2221, -2222, -2223, -2224, 5, -2226,
- -2231, -2232, -2233, -2234, 6, -2236
+ -1111, -1112, -1113, -1114, -1115, -1116,
+ -1121, -1122, -1123, -1124, -1125, -1126,
+ -1131, -1132, -1133, -1134, -1135, -1136,
+ -1211, -1212, -1213, -1214, -1215, -1216,
+ -1221, -1222, -1223, -1224, -1225, -1226,
+ -1231, -1232, -1233, -1234, -1235, -1236,
+ -2111, -2112, -2113, -2114, 1, -2116,
+ -2121, -2122, -2123, -2124, 2, -2126,
+ -2131, -2132, -2133, -2134, 3, -2136,
+ -2211, -2212, -2213, -2214, 4, -2216,
+ -2221, -2222, -2223, -2224, 5, -2226,
+ -2231, -2232, -2233, -2234, 6, -2236
};
-
- int array_size[4] = {6, 3, 2, 2};
- int array_subsize[4] = {1, 3, 2, 1};
- int array_start[4] = {4, 0, 0, 1};
+
+ int array_size[4] = { 6, 3, 2, 2 };
+ int array_subsize[4] = { 1, 3, 2, 1 };
+ int array_start[4] = { 4, 0, 0, 1 };
int i, err, errs = 0, sizeoftype;
/* set up type */
- err = MPI_Type_create_subarray(4, /* dims */
- array_size,
- array_subsize,
- array_start,
- MPI_ORDER_FORTRAN,
- MPI_INT,
- &subarray);
+ err = MPI_Type_create_subarray(4, /* dims */
+ array_size,
+ array_subsize,
+ array_start, MPI_ORDER_FORTRAN, MPI_INT, &subarray);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in MPI_Type_create_subarray call; aborting after %d errors\n",
- errs);
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr,
+ "error in MPI_Type_create_subarray call; aborting after %d errors\n", errs);
+ }
+ return errs;
}
MPI_Type_commit(&subarray);
MPI_Type_size(subarray, &sizeoftype);
- if (sizeoftype != 6*sizeof(int)) {
- errs++;
- if (verbose) fprintf(stderr, "size of type = %d; should be %d\n",
- sizeoftype, (int) (6*sizeof(int)));
- return errs;
+ if (sizeoftype != 6 * sizeof(int)) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "size of type = %d; should be %d\n",
+ sizeoftype, (int) (6 * sizeof(int)));
+ return errs;
}
- err = pack_and_unpack((char *) array, 1, subarray, 72*sizeof(int));
-
- for (i=0; i < 72; i++) {
- int goodval;
- switch (i) {
- case 40:
- goodval = 1;
- break;
- case 46:
- goodval = 2;
- break;
- case 52:
- goodval = 3;
- break;
- case 58:
- goodval = 4;
- break;
- case 64:
- goodval = 5;
- break;
- case 70:
- goodval = 6;
- break;
- default:
- goodval = 0;
- break;
- }
- if (array[i] != goodval) {
- errs++;
- if (verbose) fprintf(stderr, "array[%d] = %d; should be %d\n",
- i, array[i], goodval);
- }
+ err = pack_and_unpack((char *) array, 1, subarray, 72 * sizeof(int));
+
+ for (i = 0; i < 72; i++) {
+ int goodval;
+ switch (i) {
+ case 40:
+ goodval = 1;
+ break;
+ case 46:
+ goodval = 2;
+ break;
+ case 52:
+ goodval = 3;
+ break;
+ case 58:
+ goodval = 4;
+ break;
+ case 64:
+ goodval = 5;
+ break;
+ case 70:
+ goodval = 6;
+ break;
+ default:
+ goodval = 0;
+ break;
+ }
+ if (array[i] != goodval) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "array[%d] = %d; should be %d\n", i, array[i], goodval);
+ }
}
MPI_Type_free(&subarray);
@@ -563,61 +539,59 @@ int subarray_4d_fortran_test1(void)
int subarray_2d_fortran_test1(void)
{
MPI_Datatype subarray;
- int array[12] = { -1, -2, -3, -4, 1, 2,
- -5, -6, -7, -8, -9, -10 };
- int array_size[2] = {6, 2};
- int array_subsize[2] = {2, 1};
- int array_start[2] = {4, 0};
+ int array[12] = { -1, -2, -3, -4, 1, 2,
+ -5, -6, -7, -8, -9, -10
+ };
+ int array_size[2] = { 6, 2 };
+ int array_subsize[2] = { 2, 1 };
+ int array_start[2] = { 4, 0 };
int i, err, errs = 0, sizeoftype;
/* set up type */
- err = MPI_Type_create_subarray(2, /* dims */
- array_size,
- array_subsize,
- array_start,
- MPI_ORDER_FORTRAN,
- MPI_INT,
- &subarray);
+ err = MPI_Type_create_subarray(2, /* dims */
+ array_size,
+ array_subsize,
+ array_start, MPI_ORDER_FORTRAN, MPI_INT, &subarray);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in MPI_Type_create_subarray call; aborting after %d errors\n",
- errs);
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr,
+ "error in MPI_Type_create_subarray call; aborting after %d errors\n", errs);
+ }
+ return errs;
}
MPI_Type_commit(&subarray);
MPI_Type_size(subarray, &sizeoftype);
- if (sizeoftype != 2*sizeof(int)) {
- errs++;
- if (verbose) fprintf(stderr, "size of type = %d; should be %d\n",
- sizeoftype, (int) (2*sizeof(int)));
- return errs;
+ if (sizeoftype != 2 * sizeof(int)) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "size of type = %d; should be %d\n",
+ sizeoftype, (int) (2 * sizeof(int)));
+ return errs;
}
- err = pack_and_unpack((char *) array, 1, subarray, 12*sizeof(int));
-
- for (i=0; i < 12; i++) {
- int goodval;
- switch (i) {
- case 4:
- goodval = 1;
- break;
- case 5:
- goodval = 2;
- break;
- default:
- goodval = 0;
- break;
- }
- if (array[i] != goodval) {
- errs++;
- if (verbose) fprintf(stderr, "array[%d] = %d; should be %d\n",
- i, array[i], goodval);
- }
+ err = pack_and_unpack((char *) array, 1, subarray, 12 * sizeof(int));
+
+ for (i = 0; i < 12; i++) {
+ int goodval;
+ switch (i) {
+ case 4:
+ goodval = 1;
+ break;
+ case 5:
+ goodval = 2;
+ break;
+ default:
+ goodval = 0;
+ break;
+ }
+ if (array[i] != goodval) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "array[%d] = %d; should be %d\n", i, array[i], goodval);
+ }
}
MPI_Type_free(&subarray);
@@ -641,87 +615,64 @@ int subarray_2d_fortran_test1(void)
* between the pack and unpack steps
*
*/
-static int pack_and_unpack(char *typebuf,
- int count,
- MPI_Datatype datatype,
- int typebufsz)
+static int pack_and_unpack(char *typebuf, int count, MPI_Datatype datatype, int typebufsz)
{
char *packbuf;
int err, errs = 0, pack_size, type_size, position;
err = MPI_Type_size(datatype, &type_size);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in MPI_Type_size call; aborting after %d errors\n",
- errs);
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "error in MPI_Type_size call; aborting after %d errors\n", errs);
+ }
+ return errs;
}
type_size *= count;
err = MPI_Pack_size(count, datatype, MPI_COMM_SELF, &pack_size);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in MPI_Pack_size call; aborting after %d errors\n",
- errs);
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "error in MPI_Pack_size call; aborting after %d errors\n", errs);
+ }
+ return errs;
}
packbuf = (char *) malloc(pack_size);
if (packbuf == NULL) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in malloc call; aborting after %d errors\n",
- errs);
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "error in malloc call; aborting after %d errors\n", errs);
+ }
+ return errs;
}
position = 0;
- err = MPI_Pack(typebuf,
- count,
- datatype,
- packbuf,
- type_size,
- &position,
- MPI_COMM_SELF);
+ err = MPI_Pack(typebuf, count, datatype, packbuf, type_size, &position, MPI_COMM_SELF);
if (position != type_size) {
- errs++;
- if (verbose) fprintf(stderr, "position = %d; should be %d (pack)\n",
- position, type_size);
+ errs++;
+ if (verbose)
+ fprintf(stderr, "position = %d; should be %d (pack)\n", position, type_size);
}
memset(typebuf, 0, typebufsz);
position = 0;
- err = MPI_Unpack(packbuf,
- type_size,
- &position,
- typebuf,
- count,
- datatype,
- MPI_COMM_SELF);
+ err = MPI_Unpack(packbuf, type_size, &position, typebuf, count, datatype, MPI_COMM_SELF);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr,
- "error in MPI_Unpack call; aborting after %d errors\n",
- errs);
- }
- return errs;
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "error in MPI_Unpack call; aborting after %d errors\n", errs);
+ }
+ return errs;
}
free(packbuf);
if (position != type_size) {
- errs++;
- if (verbose) fprintf(stderr, "position = %d; should be %d (unpack)\n",
- position, type_size);
+ errs++;
+ if (verbose)
+ fprintf(stderr, "position = %d; should be %d (unpack)\n", position, type_size);
}
return errs;
@@ -730,19 +681,18 @@ static int pack_and_unpack(char *typebuf,
static int parse_args(int argc, char **argv)
{
/*
- int ret;
-
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
- }
- */
+ * int ret;
+ *
+ * while ((ret = getopt(argc, argv, "v")) >= 0)
+ * {
+ * switch (ret) {
+ * case 'v':
+ * verbose = 1;
+ * break;
+ * }
+ * }
+ */
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
return 0;
}
-
diff --git a/test/mpi/datatype/subarray.c b/test/mpi/datatype/subarray.c
index d726b5a..65f491b 100644
--- a/test/mpi/datatype/subarray.c
+++ b/test/mpi/datatype/subarray.c
@@ -18,9 +18,9 @@ int main(int argc, char *argv[])
{
int myrank;
MPI_Datatype subarray;
- int array_size[] = {X, Y, Z};
- int array_subsize[] = {X/2, Y/2, Z};
- int array_start[] = {0, 0, 0};
+ int array_size[] = { X, Y, Z };
+ int array_subsize[] = { X / 2, Y / 2, Z };
+ int array_start[] = { 0, 0, 0 };
int i, j, k;
int errs = 0;
@@ -42,7 +42,7 @@ int main(int argc, char *argv[])
MPI_DOUBLE, &subarray);
MPI_Type_commit(&subarray);
- if(myrank == 0)
+ if (myrank == 0)
MPI_Send(array, 1, subarray, 1, 0, MPI_COMM_WORLD);
else {
MPI_Recv(array, 1, subarray, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
diff --git a/test/mpi/datatype/tfree.c b/test/mpi/datatype/tfree.c
index 301eca8..0d829d9 100644
--- a/test/mpi/datatype/tfree.c
+++ b/test/mpi/datatype/tfree.c
@@ -16,90 +16,89 @@ static char MTEST_Descrip[] = "Test that freed datatypes have reference count se
#define VEC_NELM 128
#define VEC_STRIDE 8
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size, source, dest, i;
- MPI_Comm comm;
- MPI_Status status;
- MPI_Request req;
- MPI_Datatype strideType;
- MPI_Datatype tmpType[1024];
- int *buf = 0;
+ MPI_Comm comm;
+ MPI_Status status;
+ MPI_Request req;
+ MPI_Datatype strideType;
+ MPI_Datatype tmpType[1024];
+ int *buf = 0;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
if (size < 2) {
- fprintf( stderr, "This test requires at least two processes." );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "This test requires at least two processes.");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- source = 0;
- dest = size - 1;
-
- /*
- The idea here is to create a simple but non-contig datatype,
- perform an irecv with it, free it, and then create
- many new datatypes. While not a complete test, if the datatype
- was freed and the space was reused, this test may detect
- that error
- A similar test for sends might work by sending a large enough message
- to force the use of rendezvous send.
- */
- MPI_Type_vector( VEC_NELM, 1, VEC_STRIDE, MPI_INT, &strideType );
- MPI_Type_commit( &strideType );
+ source = 0;
+ dest = size - 1;
+
+ /*
+ * The idea here is to create a simple but non-contig datatype,
+ * perform an irecv with it, free it, and then create
+ * many new datatypes. While not a complete test, if the datatype
+ * was freed and the space was reused, this test may detect
+ * that error
+ * A similar test for sends might work by sending a large enough message
+ * to force the use of rendezvous send.
+ */
+ MPI_Type_vector(VEC_NELM, 1, VEC_STRIDE, MPI_INT, &strideType);
+ MPI_Type_commit(&strideType);
if (rank == dest) {
- buf = (int *)malloc( VEC_NELM * VEC_STRIDE * sizeof(int) );
- for (i=0; i<VEC_NELM*VEC_STRIDE; i++) buf[i] = -i;
- MPI_Irecv( buf, 1, strideType, source, 0, comm, &req );
- MPI_Type_free( &strideType );
-
- for (i=0; i<1024; i++) {
- MPI_Type_vector( VEC_NELM, 1, 1, MPI_INT, &tmpType[i] );
- MPI_Type_commit( &tmpType[i] );
- }
-
- MPI_Sendrecv( NULL, 0, MPI_INT, source, 1,
- NULL, 0, MPI_INT, source, 1, comm, &status );
-
- MPI_Wait( &req, &status );
- for (i=0; i<VEC_NELM; i++) {
- if (buf[VEC_STRIDE*i] != i) {
- errs++;
- if (errs < 10) {
- printf( "buf[%d] = %d, expected %d\n", VEC_STRIDE*i,
- buf[VEC_STRIDE*i], i );
- }
- }
- }
- for (i=0; i<1024; i++) {
- MPI_Type_free( &tmpType[i] );
- }
- free( buf );
+ buf = (int *) malloc(VEC_NELM * VEC_STRIDE * sizeof(int));
+ for (i = 0; i < VEC_NELM * VEC_STRIDE; i++)
+ buf[i] = -i;
+ MPI_Irecv(buf, 1, strideType, source, 0, comm, &req);
+ MPI_Type_free(&strideType);
+
+ for (i = 0; i < 1024; i++) {
+ MPI_Type_vector(VEC_NELM, 1, 1, MPI_INT, &tmpType[i]);
+ MPI_Type_commit(&tmpType[i]);
+ }
+
+ MPI_Sendrecv(NULL, 0, MPI_INT, source, 1, NULL, 0, MPI_INT, source, 1, comm, &status);
+
+ MPI_Wait(&req, &status);
+ for (i = 0; i < VEC_NELM; i++) {
+ if (buf[VEC_STRIDE * i] != i) {
+ errs++;
+ if (errs < 10) {
+ printf("buf[%d] = %d, expected %d\n", VEC_STRIDE * i, buf[VEC_STRIDE * i], i);
+ }
+ }
+ }
+ for (i = 0; i < 1024; i++) {
+ MPI_Type_free(&tmpType[i]);
+ }
+ free(buf);
}
else if (rank == source) {
- buf = (int *)malloc( VEC_NELM * sizeof(int) );
- for (i=0; i<VEC_NELM; i++) buf[i] = i;
- /* Synchronize with the receiver */
- MPI_Sendrecv( NULL, 0, MPI_INT, dest, 1,
- NULL, 0, MPI_INT, dest, 1, comm, &status );
- MPI_Send( buf, VEC_NELM, MPI_INT, dest, 0, comm );
- free( buf );
+ buf = (int *) malloc(VEC_NELM * sizeof(int));
+ for (i = 0; i < VEC_NELM; i++)
+ buf[i] = i;
+ /* Synchronize with the receiver */
+ MPI_Sendrecv(NULL, 0, MPI_INT, dest, 1, NULL, 0, MPI_INT, dest, 1, comm, &status);
+ MPI_Send(buf, VEC_NELM, MPI_INT, dest, 0, comm);
+ free(buf);
}
/* Clean up the strideType */
if (rank != dest) {
- MPI_Type_free( &strideType );
+ MPI_Type_free(&strideType);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/datatype/tmatchsize.c b/test/mpi/datatype/tmatchsize.c
index 76432d7..b631ba1 100644
--- a/test/mpi/datatype/tmatchsize.c
+++ b/test/mpi/datatype/tmatchsize.c
@@ -15,159 +15,157 @@ static char MTEST_Descrip[] = "Test of type_match_size";
/*
* type match size is part of the extended Fortran support, and may not
- * be present in
+ * be present in
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int dsize;
- MPI_Datatype newtype;
+ MPI_Datatype newtype;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
/* Check the most likely cases. Note that it is an error to
- free the type returned by MPI_Type_match_size. Also note
- that it is an error to request a size not supported by the compiler,
- so Type_match_size should generate an error in that case */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * free the type returned by MPI_Type_match_size. Also note
+ * that it is an error to request a size not supported by the compiler,
+ * so Type_match_size should generate an error in that case */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
- err = MPI_Type_match_size( MPI_TYPECLASS_REAL, sizeof(float), &newtype );
+ err = MPI_Type_match_size(MPI_TYPECLASS_REAL, sizeof(float), &newtype);
if (err) {
- errs++;
- MTestPrintErrorMsg( "Float: ", err );
+ errs++;
+ MTestPrintErrorMsg("Float: ", err);
}
else {
- err = MPI_Type_size( newtype, &dsize );
- if (err) {
- errs++;
- MTestPrintErrorMsg( "Float type: ", err );
- }
- else {
- if (dsize != sizeof(float)) {
- errs++;
- printf( "Unexpected size for float (%d != %d)\n",
- dsize, (int) sizeof(float) );
- }
- }
+ err = MPI_Type_size(newtype, &dsize);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Float type: ", err);
+ }
+ else {
+ if (dsize != sizeof(float)) {
+ errs++;
+ printf("Unexpected size for float (%d != %d)\n", dsize, (int) sizeof(float));
+ }
+ }
}
- err = MPI_Type_match_size( MPI_TYPECLASS_REAL, sizeof(double), &newtype );
+ err = MPI_Type_match_size(MPI_TYPECLASS_REAL, sizeof(double), &newtype);
if (err) {
- errs++;
- MTestPrintErrorMsg( "Double: ", err );
+ errs++;
+ MTestPrintErrorMsg("Double: ", err);
}
else {
- MPI_Type_size( newtype, &dsize );
- if (dsize != sizeof(double)) {
- errs++;
- printf( "Unexpected size for double\n" );
- }
+ MPI_Type_size(newtype, &dsize);
+ if (dsize != sizeof(double)) {
+ errs++;
+ printf("Unexpected size for double\n");
+ }
}
#ifdef HAVE_LONG_DOUBLE
- err = MPI_Type_match_size( MPI_TYPECLASS_REAL, sizeof(long double), &newtype );
+ err = MPI_Type_match_size(MPI_TYPECLASS_REAL, sizeof(long double), &newtype);
if (err) {
- errs++;
- MTestPrintErrorMsg( "Long double: ", err );
+ errs++;
+ MTestPrintErrorMsg("Long double: ", err);
}
else {
- MPI_Type_size( newtype, &dsize );
- if (dsize != sizeof(long double)) {
- errs++;
- printf( "Unexpected size for long double\n" );
- }
+ MPI_Type_size(newtype, &dsize);
+ if (dsize != sizeof(long double)) {
+ errs++;
+ printf("Unexpected size for long double\n");
+ }
}
#endif
-
- err = MPI_Type_match_size( MPI_TYPECLASS_INTEGER, sizeof(short), &newtype );
+
+ err = MPI_Type_match_size(MPI_TYPECLASS_INTEGER, sizeof(short), &newtype);
if (err) {
- errs++;
- MTestPrintErrorMsg( "Short: ", err );
+ errs++;
+ MTestPrintErrorMsg("Short: ", err);
}
else {
- MPI_Type_size( newtype, &dsize );
- if (dsize != sizeof(short)) {
- errs++;
- printf( "Unexpected size for short\n" );
- }
+ MPI_Type_size(newtype, &dsize);
+ if (dsize != sizeof(short)) {
+ errs++;
+ printf("Unexpected size for short\n");
+ }
}
- err = MPI_Type_match_size( MPI_TYPECLASS_INTEGER, sizeof(int), &newtype );
+ err = MPI_Type_match_size(MPI_TYPECLASS_INTEGER, sizeof(int), &newtype);
if (err) {
- errs++;
- MTestPrintErrorMsg( "Int: ", err );
+ errs++;
+ MTestPrintErrorMsg("Int: ", err);
}
else {
- MPI_Type_size( newtype, &dsize );
- if (dsize != sizeof(int)) {
- errs++;
- printf( "Unexpected size for int\n" );
- }
+ MPI_Type_size(newtype, &dsize);
+ if (dsize != sizeof(int)) {
+ errs++;
+ printf("Unexpected size for int\n");
+ }
}
- err = MPI_Type_match_size( MPI_TYPECLASS_INTEGER, sizeof(long), &newtype );
+ err = MPI_Type_match_size(MPI_TYPECLASS_INTEGER, sizeof(long), &newtype);
if (err) {
- errs++;
- MTestPrintErrorMsg( "Long: ", err );
+ errs++;
+ MTestPrintErrorMsg("Long: ", err);
}
else {
- MPI_Type_size( newtype, &dsize );
- if (dsize != sizeof(long)) {
- errs++;
- printf( "Unexpected size for long\n" );
- }
+ MPI_Type_size(newtype, &dsize);
+ if (dsize != sizeof(long)) {
+ errs++;
+ printf("Unexpected size for long\n");
+ }
}
#ifdef HAVE_LONG_LONG
- err = MPI_Type_match_size( MPI_TYPECLASS_INTEGER, sizeof(long long), &newtype );
+ err = MPI_Type_match_size(MPI_TYPECLASS_INTEGER, sizeof(long long), &newtype);
if (err) {
- errs++;
- MTestPrintErrorMsg( "Long long: ", err );
+ errs++;
+ MTestPrintErrorMsg("Long long: ", err);
}
else {
- MPI_Type_size( newtype, &dsize );
- if (dsize != sizeof(long long)) {
- errs++;
- printf( "Unexpected size for long long\n" );
- }
+ MPI_Type_size(newtype, &dsize);
+ if (dsize != sizeof(long long)) {
+ errs++;
+ printf("Unexpected size for long long\n");
+ }
}
#endif
/* COMPLEX is a FORTRAN type. The MPICH Type_match_size attempts
- to give a valid datatype, but if Fortran is not available,
- MPI_COMPLEX and MPI_DOUBLE_COMPLEX are not supported.
- Allow this case by testing for MPI_DATATYPE_NULL */
+ * to give a valid datatype, but if Fortran is not available,
+ * MPI_COMPLEX and MPI_DOUBLE_COMPLEX are not supported.
+ * Allow this case by testing for MPI_DATATYPE_NULL */
if (MPI_COMPLEX != MPI_DATATYPE_NULL) {
- err = MPI_Type_match_size( MPI_TYPECLASS_COMPLEX, 2*sizeof(float), &newtype );
- if (err) {
- errs++;
- MTestPrintErrorMsg( "Complex: ", err );
- }
- else {
- MPI_Type_size( newtype, &dsize );
- if (dsize != 2*sizeof(float)) {
- errs++;
- printf( "Unexpected size for complex\n" );
- }
- }
+ err = MPI_Type_match_size(MPI_TYPECLASS_COMPLEX, 2 * sizeof(float), &newtype);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Complex: ", err);
+ }
+ else {
+ MPI_Type_size(newtype, &dsize);
+ if (dsize != 2 * sizeof(float)) {
+ errs++;
+ printf("Unexpected size for complex\n");
+ }
+ }
+ }
+
+ if (MPI_COMPLEX != MPI_DATATYPE_NULL && MPI_DOUBLE_COMPLEX != MPI_DATATYPE_NULL) {
+ err = MPI_Type_match_size(MPI_TYPECLASS_COMPLEX, 2 * sizeof(double), &newtype);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Double complex: ", err);
+ }
+ else {
+ MPI_Type_size(newtype, &dsize);
+ if (dsize != 2 * sizeof(double)) {
+ errs++;
+ printf("Unexpected size for double complex\n");
+ }
+ }
}
- if (MPI_COMPLEX != MPI_DATATYPE_NULL &&
- MPI_DOUBLE_COMPLEX != MPI_DATATYPE_NULL) {
- err = MPI_Type_match_size( MPI_TYPECLASS_COMPLEX, 2*sizeof(double), &newtype );
- if (err) {
- errs++;
- MTestPrintErrorMsg( "Double complex: ", err );
- }
- else {
- MPI_Type_size( newtype, &dsize );
- if (dsize != 2*sizeof(double)) {
- errs++;
- printf( "Unexpected size for double complex\n" );
- }
- }
- }
-
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/datatype/transpose-pack.c b/test/mpi/datatype/transpose-pack.c
index 5bd6a72..4429405 100644
--- a/test/mpi/datatype/transpose-pack.c
+++ b/test/mpi/datatype/transpose-pack.c
@@ -24,77 +24,65 @@ int main(int argc, char *argv[])
int a[100][100], b[100][100];
MPI_Datatype row, xpose;
MPI_Aint sizeofint;
-
+
int err, errs = 0;
int bufsize, position = 0;
void *buffer;
-
+
int i, j;
-
+
/* Initialize a to some known values. */
- for(i = 0; i < 100; i++) {
- for(j = 0; j < 100; j++) {
- a[i][j] = i*1000+j;
- b[i][j] = -1;
- }
+ for (i = 0; i < 100; i++) {
+ for (j = 0; j < 100; j++) {
+ a[i][j] = i * 1000 + j;
+ b[i][j] = -1;
+ }
}
-
+
/* Initialize MPI */
MPI_Init(&argc, &argv);
parse_args(argc, argv);
MPI_Type_extent(MPI_INT, &sizeofint);
-
+
/* Create datatypes. */
MPI_Type_vector(100, 1, 100, MPI_INT, &row);
MPI_Type_hvector(100, 1, sizeofint, row, &xpose);
MPI_Type_commit(&xpose);
-
+
/* Pack it. */
MPI_Pack_size(1, xpose, MPI_COMM_WORLD, &bufsize);
buffer = (char *) malloc((unsigned) bufsize);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
-
- err = MPI_Pack(a,
- 1,
- xpose,
- buffer,
- bufsize,
- &position,
- MPI_COMM_WORLD);
-
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+
+ err = MPI_Pack(a, 1, xpose, buffer, bufsize, &position, MPI_COMM_WORLD);
+
/* Unpack the buffer into b. */
position = 0;
- err = MPI_Unpack(buffer,
- bufsize,
- &position,
- b,
- 100*100,
- MPI_INT,
- MPI_COMM_WORLD);
+ err = MPI_Unpack(buffer, bufsize, &position, b, 100 * 100, MPI_INT, MPI_COMM_WORLD);
for (i = 0; i < 100; i++) {
- for (j = 0; j < 100; j++) {
- if(b[i][j] != a[j][i]) {
- errs++;
- if (verbose) fprintf(stderr, "b[%d][%d] = %d, should be %d\n",
- i, j, b[i][j], a[j][i]);
- }
- }
+ for (j = 0; j < 100; j++) {
+ if (b[i][j] != a[j][i]) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "b[%d][%d] = %d, should be %d\n", i, j, b[i][j], a[j][i]);
+ }
+ }
}
MPI_Type_free(&xpose);
MPI_Type_free(&row);
-
+
/* print message and exit */
if (errs) {
- fprintf(stderr, "Found %d errors\n", errs);
+ fprintf(stderr, "Found %d errors\n", errs);
}
else {
- printf(" No Errors\n");
+ printf(" No Errors\n");
}
MPI_Finalize();
return 0;
@@ -104,18 +92,18 @@ int main(int argc, char *argv[])
int parse_args(int argc, char **argv)
{
/*
- int ret;
-
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
- }
- */
+ * int ret;
+ *
+ * while ((ret = getopt(argc, argv, "v")) >= 0)
+ * {
+ * switch (ret) {
+ * case 'v':
+ * verbose = 1;
+ * break;
+ * }
+ * }
+ */
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
return 0;
}
diff --git a/test/mpi/datatype/tresized.c b/test/mpi/datatype/tresized.c
index 069fddc..079f3da 100644
--- a/test/mpi/datatype/tresized.c
+++ b/test/mpi/datatype/tresized.c
@@ -13,65 +13,68 @@
static char MTEST_Descrip[] = "Test of type resized";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, i;
int rank, size, source, dest;
- int count;
- int *buf;
- MPI_Comm comm;
- MPI_Status status;
- MPI_Datatype newtype;
+ int count;
+ int *buf;
+ MPI_Comm comm;
+ MPI_Status status;
+ MPI_Datatype newtype;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
/* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
source = 0;
- dest = size - 1;
-
- MPI_Type_create_resized( MPI_INT, 0, 3 * sizeof(int), &newtype );
- MPI_Type_commit( &newtype );
+ dest = size - 1;
+
+ MPI_Type_create_resized(MPI_INT, 0, 3 * sizeof(int), &newtype);
+ MPI_Type_commit(&newtype);
for (count = 1; count < 65000; count = count * 2) {
- buf = (int *)malloc( count * 3 * sizeof(int) );
- if (!buf) {
- MPI_Abort( comm, 1 );
- }
- for (i=0; i<3*count; i++) buf[i] = -1;
- if (rank == source) {
- for (i=0; i<count; i++) buf[3*i] = i;
- MPI_Send( buf, count, newtype, dest, 0, comm );
- MPI_Send( buf, count, newtype, dest, 1, comm );
- }
- else if (rank == dest) {
- MPI_Recv( buf, count, MPI_INT, source, 0, comm, &status );
- for (i=0; i<count; i++) {
- if (buf[i] != i) {
- errs++;
- if (errs < 10) {
- printf( "buf[%d] = %d\n", i, buf[i] );
- }
- }
- }
- for (i=0; i<count*3; i++) buf[i] = -1;
- MPI_Recv( buf, count, newtype, source, 1, comm, &status );
- for (i=0; i<count; i++) {
- if (buf[3*i] != i) {
- errs++;
- if (errs < 10) {
- printf( "buf[3*%d] = %d\n", i, buf[i] );
- }
- }
- }
- }
+ buf = (int *) malloc(count * 3 * sizeof(int));
+ if (!buf) {
+ MPI_Abort(comm, 1);
+ }
+ for (i = 0; i < 3 * count; i++)
+ buf[i] = -1;
+ if (rank == source) {
+ for (i = 0; i < count; i++)
+ buf[3 * i] = i;
+ MPI_Send(buf, count, newtype, dest, 0, comm);
+ MPI_Send(buf, count, newtype, dest, 1, comm);
+ }
+ else if (rank == dest) {
+ MPI_Recv(buf, count, MPI_INT, source, 0, comm, &status);
+ for (i = 0; i < count; i++) {
+ if (buf[i] != i) {
+ errs++;
+ if (errs < 10) {
+ printf("buf[%d] = %d\n", i, buf[i]);
+ }
+ }
+ }
+ for (i = 0; i < count * 3; i++)
+ buf[i] = -1;
+ MPI_Recv(buf, count, newtype, source, 1, comm, &status);
+ for (i = 0; i < count; i++) {
+ if (buf[3 * i] != i) {
+ errs++;
+ if (errs < 10) {
+ printf("buf[3*%d] = %d\n", i, buf[i]);
+ }
+ }
+ }
+ }
}
- MPI_Type_free( &newtype );
+ MPI_Type_free(&newtype);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/datatype/tresized2.c b/test/mpi/datatype/tresized2.c
index 064084b..d33bf17 100644
--- a/test/mpi/datatype/tresized2.c
+++ b/test/mpi/datatype/tresized2.c
@@ -13,68 +13,71 @@
static char MTEST_Descrip[] = "Test of type resized with non-zero LB";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, i;
int rank, size, source, dest;
- int count;
- int *buf;
- MPI_Comm comm;
- MPI_Status status;
- MPI_Datatype newtype;
+ int count;
+ int *buf;
+ MPI_Comm comm;
+ MPI_Status status;
+ MPI_Datatype newtype;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
/* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
source = 0;
- dest = size - 1;
+ dest = size - 1;
/* Create an type that is "* INT * "
- that is, there is a int-sized pad at the beginning of the type,
- and the extent is still 3 ints. Note, however, that the INT
- is still at displacement 0, so the effective pattern i*/
- MPI_Type_create_resized( MPI_INT, -(int)sizeof(int), 3 * sizeof(int), &newtype );
- MPI_Type_commit( &newtype );
+ * that is, there is a int-sized pad at the beginning of the type,
+ * and the extent is still 3 ints. Note, however, that the INT
+ * is still at displacement 0, so the effective pattern i */
+ MPI_Type_create_resized(MPI_INT, -(int) sizeof(int), 3 * sizeof(int), &newtype);
+ MPI_Type_commit(&newtype);
for (count = 1; count < 65000; count = count * 2) {
- buf = (int *)malloc( count * 3 * sizeof(int) );
- if (!buf) {
- MPI_Abort( comm, 1 );
- }
- for (i=0; i<3*count; i++) buf[i] = -1;
- if (rank == source) {
- for (i=0; i<count; i++) buf[3*i] = i;
- MPI_Send( buf, count, newtype, dest, 0, comm );
- MPI_Send( buf, count, newtype, dest, 1, comm );
- }
- else if (rank == dest) {
- MPI_Recv( buf, count, MPI_INT, source, 0, comm, &status );
- for (i=0; i<count; i++) {
- if (buf[i] != i) {
- errs++;
- if (errs < 10) {
- printf( "buf[%d] = %d\n", i, buf[i] );
- }
- }
- }
- for (i=0; i<count*3; i++) buf[i] = -1;
- MPI_Recv( buf, count, newtype, source, 1, comm, &status );
- for (i=0; i<count; i++) {
- if (buf[3*i] != i) {
- errs++;
- if (errs < 10) {
- printf( "buf[3*%d] = %d\n", i, buf[i] );
- }
- }
- }
- }
+ buf = (int *) malloc(count * 3 * sizeof(int));
+ if (!buf) {
+ MPI_Abort(comm, 1);
+ }
+ for (i = 0; i < 3 * count; i++)
+ buf[i] = -1;
+ if (rank == source) {
+ for (i = 0; i < count; i++)
+ buf[3 * i] = i;
+ MPI_Send(buf, count, newtype, dest, 0, comm);
+ MPI_Send(buf, count, newtype, dest, 1, comm);
+ }
+ else if (rank == dest) {
+ MPI_Recv(buf, count, MPI_INT, source, 0, comm, &status);
+ for (i = 0; i < count; i++) {
+ if (buf[i] != i) {
+ errs++;
+ if (errs < 10) {
+ printf("buf[%d] = %d\n", i, buf[i]);
+ }
+ }
+ }
+ for (i = 0; i < count * 3; i++)
+ buf[i] = -1;
+ MPI_Recv(buf, count, newtype, source, 1, comm, &status);
+ for (i = 0; i < count; i++) {
+ if (buf[3 * i] != i) {
+ errs++;
+ if (errs < 10) {
+ printf("buf[3*%d] = %d\n", i, buf[i]);
+ }
+ }
+ }
+ }
}
- MPI_Type_free( &newtype );
+ MPI_Type_free(&newtype);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/datatype/triangular-pack.c b/test/mpi/datatype/triangular-pack.c
index 0720524..3c460d0 100644
--- a/test/mpi/datatype/triangular-pack.c
+++ b/test/mpi/datatype/triangular-pack.c
@@ -23,65 +23,65 @@ int main(int argc, char *argv[])
int a[100][100], b[100][100];
int disp[100], block[100];
MPI_Datatype ltype;
-
+
int bufsize, position = 0;
void *buffer;
-
+
int i, j, errs = 0;
-
+
/* Initialize a to some known values and zero out b. */
- for(i = 0; i < 100; i++) {
- for(j = 0; j < 100; j++) {
- a[i][j] = 1000*i + j;
- b[i][j] = 0;
- }
+ for (i = 0; i < 100; i++) {
+ for (j = 0; j < 100; j++) {
+ a[i][j] = 1000 * i + j;
+ b[i][j] = 0;
+ }
}
-
+
/* Initialize MPI */
- MTest_Init( &argc, &argv );
-
+ MTest_Init(&argc, &argv);
+
parse_args(argc, argv);
- for(i = 0; i < 100; i++) {
- /* Fortran version has disp(i) = 100*(i-1) + i and block(i) = 100-i. */
- /* This code here is wrong. It compacts everything together,
- * which isn't what we want.
- * What we want is to put the lower triangular values into b and leave
- * the rest of it unchanged, right?
- */
- block[i] = i+1;
- disp[i] = 100*i;
+ for (i = 0; i < 100; i++) {
+ /* Fortran version has disp(i) = 100*(i-1) + i and block(i) = 100-i. */
+ /* This code here is wrong. It compacts everything together,
+ * which isn't what we want.
+ * What we want is to put the lower triangular values into b and leave
+ * the rest of it unchanged, right?
+ */
+ block[i] = i + 1;
+ disp[i] = 100 * i;
}
-
+
/* Create datatype for lower triangular part. */
MPI_Type_indexed(100, block, disp, MPI_INT, <ype);
MPI_Type_commit(<ype);
-
+
/* Pack it. */
MPI_Pack_size(1, ltype, MPI_COMM_WORLD, &bufsize);
buffer = (void *) malloc((unsigned) bufsize);
- MPI_Pack( a, 1, ltype, buffer, bufsize, &position, MPI_COMM_WORLD );
-
+ MPI_Pack(a, 1, ltype, buffer, bufsize, &position, MPI_COMM_WORLD);
+
/* Unpack the buffer into b. */
position = 0;
MPI_Unpack(buffer, bufsize, &position, b, 1, ltype, MPI_COMM_WORLD);
-
- for(i = 0; i < 100; i++) {
- for(j = 0; j < 100; j++) {
- if (j > i && b[i][j] != 0) {
- errs++;
- if (verbose) fprintf(stderr, "b[%d][%d] = %d; should be %d\n",
- i, j, b[i][j], 0);
- }
- else if (j <= i && b[i][j] != 1000*i + j) {
- errs++;
- if (verbose) fprintf(stderr, "b[%d][%d] = %d; should be %d\n",
- i, j, b[i][j], 1000*i + j);
- }
- }
+
+ for (i = 0; i < 100; i++) {
+ for (j = 0; j < 100; j++) {
+ if (j > i && b[i][j] != 0) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "b[%d][%d] = %d; should be %d\n", i, j, b[i][j], 0);
+ }
+ else if (j <= i && b[i][j] != 1000 * i + j) {
+ errs++;
+ if (verbose)
+ fprintf(stderr, "b[%d][%d] = %d; should be %d\n", i, j, b[i][j], 1000 * i + j);
+ }
+ }
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
@@ -90,13 +90,12 @@ int parse_args(int argc, char **argv)
{
int ret;
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
+ while ((ret = getopt(argc, argv, "v")) >= 0) {
+ switch (ret) {
+ case 'v':
+ verbose = 1;
+ break;
+ }
}
return 0;
}
diff --git a/test/mpi/datatype/typecommit.c b/test/mpi/datatype/typecommit.c
index 61fb7b5..aff7213 100644
--- a/test/mpi/datatype/typecommit.c
+++ b/test/mpi/datatype/typecommit.c
@@ -7,20 +7,18 @@
#include <mpi.h>
#include "mpitest.h"
-void foo(void *sendbuf, MPI_Datatype sendtype, void *recvbuf,
- MPI_Datatype recvtype);
-void foo(void *sendbuf, MPI_Datatype sendtype, void *recvbuf,
- MPI_Datatype recvtype)
+void foo(void *sendbuf, MPI_Datatype sendtype, void *recvbuf, MPI_Datatype recvtype);
+void foo(void *sendbuf, MPI_Datatype sendtype, void *recvbuf, MPI_Datatype recvtype)
{
int blocks[2];
MPI_Aint struct_displs[2];
MPI_Datatype types[2], tmp_type;
blocks[0] = 256;
- MPI_Get_address( sendbuf, &struct_displs[0] );
+ MPI_Get_address(sendbuf, &struct_displs[0]);
types[0] = sendtype;
blocks[1] = 256;
- MPI_Get_address( recvbuf, &struct_displs[1] );
+ MPI_Get_address(recvbuf, &struct_displs[1]);
types[1] = MPI_BYTE;
MPI_Type_create_struct(2, blocks, struct_displs, types, &tmp_type);
@@ -34,15 +32,15 @@ int main(int argc, char **argv)
MTest_Init(&argc, &argv);
- foo((void*) 0x1, MPI_FLOAT_INT, (void*) 0x2, MPI_BYTE);
- foo((void*) 0x1, MPI_DOUBLE_INT, (void*) 0x2, MPI_BYTE);
- foo((void*) 0x1, MPI_LONG_INT, (void*) 0x2, MPI_BYTE);
- foo((void*) 0x1, MPI_SHORT_INT, (void*) 0x2, MPI_BYTE);
- foo((void*) 0x1, MPI_2INT, (void*) 0x2, MPI_BYTE);
+ foo((void *) 0x1, MPI_FLOAT_INT, (void *) 0x2, MPI_BYTE);
+ foo((void *) 0x1, MPI_DOUBLE_INT, (void *) 0x2, MPI_BYTE);
+ foo((void *) 0x1, MPI_LONG_INT, (void *) 0x2, MPI_BYTE);
+ foo((void *) 0x1, MPI_SHORT_INT, (void *) 0x2, MPI_BYTE);
+ foo((void *) 0x1, MPI_2INT, (void *) 0x2, MPI_BYTE);
#ifdef HAVE_LONG_DOUBLE
/* Optional type may be NULL */
if (MPI_LONG_DOUBLE_INT != MPI_DATATYPE_NULL) {
- foo((void*) 0x1, MPI_LONG_DOUBLE_INT, (void*) 0x2, MPI_BYTE);
+ foo((void *) 0x1, MPI_LONG_DOUBLE_INT, (void *) 0x2, MPI_BYTE);
}
#endif
diff --git a/test/mpi/datatype/typefree.c b/test/mpi/datatype/typefree.c
index 83a09dd..cb56941 100644
--- a/test/mpi/datatype/typefree.c
+++ b/test/mpi/datatype/typefree.c
@@ -21,15 +21,15 @@
* to turn on MPICH's internal memory checking.
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
MPI_Datatype type;
- MTest_Init( &argc, &argv );
- MPI_Type_dup( MPI_INT, &type );
- MPI_Type_free( &type );
- MTest_Finalize( errs );
+ MTest_Init(&argc, &argv);
+ MPI_Type_dup(MPI_INT, &type);
+ MPI_Type_free(&type);
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/datatype/typelb.c b/test/mpi/datatype/typelb.c
index 2dedadb..6698e64 100644
--- a/test/mpi/datatype/typelb.c
+++ b/test/mpi/datatype/typelb.c
@@ -7,7 +7,7 @@
#include "mpi.h"
#include <stdio.h>
-int main( int argc, char **argv)
+int main(int argc, char **argv)
{
int blockcnt[2], rank;
MPI_Aint offsets[2], lb, ub, extent;
@@ -19,34 +19,35 @@ int main( int argc, char **argv)
blockcnt[1] = -1;
offsets[1] = -1;
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank == 0) {
- blockcnt[0] = 1;
- offsets[0] = 3;
- MPI_Type_hindexed(1, blockcnt, offsets, MPI_BYTE, &tmp_type);
- blockcnt[0] = 1;
- offsets[0] = 1;
- MPI_Type_hindexed(1, blockcnt, offsets, tmp_type, &newtype);
- MPI_Type_commit(&newtype);
-
- MPI_Type_lb(newtype, &lb);
- MPI_Type_extent(newtype, &extent);
- MPI_Type_ub(newtype, &ub);
-
- /* Check that the results are correct */
+ blockcnt[0] = 1;
+ offsets[0] = 3;
+ MPI_Type_hindexed(1, blockcnt, offsets, MPI_BYTE, &tmp_type);
+ blockcnt[0] = 1;
+ offsets[0] = 1;
+ MPI_Type_hindexed(1, blockcnt, offsets, tmp_type, &newtype);
+ MPI_Type_commit(&newtype);
+
+ MPI_Type_lb(newtype, &lb);
+ MPI_Type_extent(newtype, &extent);
+ MPI_Type_ub(newtype, &ub);
+
+ /* Check that the results are correct */
#ifdef DEBUG
- printf("lb=%ld, ub=%ld, extent=%ld\n", lb, ub, extent);
- printf("Should be lb=4, ub=5, extent=1\n");
+ printf("lb=%ld, ub=%ld, extent=%ld\n", lb, ub, extent);
+ printf("Should be lb=4, ub=5, extent=1\n");
#endif
- if (lb != 4 || ub != 5 || extent != 1) {
- printf ("lb = %d (should be 4), ub = %d (should be 5) extent = %d should be 1\n", (int)lb, (int)ub, (int)extent) ;
- }
- else {
- printf( " No Errors\n" );
- }
-
- MPI_Type_free(&tmp_type);
- MPI_Type_free(&newtype);
+ if (lb != 4 || ub != 5 || extent != 1) {
+ printf("lb = %d (should be 4), ub = %d (should be 5) extent = %d should be 1\n",
+ (int) lb, (int) ub, (int) extent);
+ }
+ else {
+ printf(" No Errors\n");
+ }
+
+ MPI_Type_free(&tmp_type);
+ MPI_Type_free(&newtype);
}
MPI_Finalize();
diff --git a/test/mpi/datatype/typename.c b/test/mpi/datatype/typename.c
index 7b1684c..4cb2c85 100644
--- a/test/mpi/datatype/typename.c
+++ b/test/mpi/datatype/typename.c
@@ -11,183 +11,185 @@
/* Create an array with all of the MPI names in it */
-typedef struct mpi_names_t { MPI_Datatype dtype; const char *name; } mpi_names_t;
+typedef struct mpi_names_t {
+ MPI_Datatype dtype;
+ const char *name;
+} mpi_names_t;
/* The MPI standard specifies that the names must be the MPI names,
not the related language names (e.g., MPI_CHAR, not char) */
static mpi_names_t mpi_names[] = {
- { MPI_CHAR, "MPI_CHAR" },
- { MPI_SIGNED_CHAR, "MPI_SIGNED_CHAR" },
- { MPI_UNSIGNED_CHAR, "MPI_UNSIGNED_CHAR" },
- { MPI_BYTE, "MPI_BYTE" },
- { MPI_WCHAR, "MPI_WCHAR" },
- { MPI_SHORT, "MPI_SHORT" },
- { MPI_UNSIGNED_SHORT, "MPI_UNSIGNED_SHORT" },
- { MPI_INT, "MPI_INT" },
- { MPI_UNSIGNED, "MPI_UNSIGNED" },
- { MPI_LONG, "MPI_LONG" },
- { MPI_UNSIGNED_LONG, "MPI_UNSIGNED_LONG" },
- { MPI_FLOAT, "MPI_FLOAT" },
- { MPI_DOUBLE, "MPI_DOUBLE" },
+ {MPI_CHAR, "MPI_CHAR"},
+ {MPI_SIGNED_CHAR, "MPI_SIGNED_CHAR"},
+ {MPI_UNSIGNED_CHAR, "MPI_UNSIGNED_CHAR"},
+ {MPI_BYTE, "MPI_BYTE"},
+ {MPI_WCHAR, "MPI_WCHAR"},
+ {MPI_SHORT, "MPI_SHORT"},
+ {MPI_UNSIGNED_SHORT, "MPI_UNSIGNED_SHORT"},
+ {MPI_INT, "MPI_INT"},
+ {MPI_UNSIGNED, "MPI_UNSIGNED"},
+ {MPI_LONG, "MPI_LONG"},
+ {MPI_UNSIGNED_LONG, "MPI_UNSIGNED_LONG"},
+ {MPI_FLOAT, "MPI_FLOAT"},
+ {MPI_DOUBLE, "MPI_DOUBLE"},
#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
/* these two types were added in MPI-2.2 */
- { MPI_AINT, "MPI_AINT" },
- { MPI_OFFSET, "MPI_OFFSET" },
+ {MPI_AINT, "MPI_AINT"},
+ {MPI_OFFSET, "MPI_OFFSET"},
#endif
- { MPI_PACKED, "MPI_PACKED" },
- { MPI_LB, "MPI_LB" },
- { MPI_UB, "MPI_UB" },
- { MPI_FLOAT_INT, "MPI_FLOAT_INT" },
- { MPI_DOUBLE_INT, "MPI_DOUBLE_INT" },
- { MPI_LONG_INT, "MPI_LONG_INT" },
- { MPI_SHORT_INT, "MPI_SHORT_INT" },
- { MPI_2INT, "MPI_2INT" },
+ {MPI_PACKED, "MPI_PACKED"},
+ {MPI_LB, "MPI_LB"},
+ {MPI_UB, "MPI_UB"},
+ {MPI_FLOAT_INT, "MPI_FLOAT_INT"},
+ {MPI_DOUBLE_INT, "MPI_DOUBLE_INT"},
+ {MPI_LONG_INT, "MPI_LONG_INT"},
+ {MPI_SHORT_INT, "MPI_SHORT_INT"},
+ {MPI_2INT, "MPI_2INT"},
/* Fortran */
#ifdef HAVE_FORTRAN_BINDING
- { MPI_COMPLEX, "MPI_COMPLEX" },
- { MPI_DOUBLE_COMPLEX, "MPI_DOUBLE_COMPLEX" },
- { MPI_LOGICAL, "MPI_LOGICAL" },
- { MPI_REAL, "MPI_REAL" },
- { MPI_DOUBLE_PRECISION, "MPI_DOUBLE_PRECISION" },
- { MPI_INTEGER, "MPI_INTEGER" },
- { MPI_2INTEGER, "MPI_2INTEGER" },
+ {MPI_COMPLEX, "MPI_COMPLEX"},
+ {MPI_DOUBLE_COMPLEX, "MPI_DOUBLE_COMPLEX"},
+ {MPI_LOGICAL, "MPI_LOGICAL"},
+ {MPI_REAL, "MPI_REAL"},
+ {MPI_DOUBLE_PRECISION, "MPI_DOUBLE_PRECISION"},
+ {MPI_INTEGER, "MPI_INTEGER"},
+ {MPI_2INTEGER, "MPI_2INTEGER"},
/* 2COMPLEX (and the 2DOUBLE_COMPLEX) were in MPI 1.0 but not later */
#ifdef HAVE_MPI_2COMPLEX
- { MPI_2COMPLEX, "MPI_2COMPLEX" },
+ {MPI_2COMPLEX, "MPI_2COMPLEX"},
#endif
#ifdef HAVE_MPI_2DOUBLE_COMPLEX
/* MPI_2DOUBLE_COMPLEX is an extension - it is not part of MPI 2.1 */
- { MPI_2DOUBLE_COMPLEX, "MPI_2DOUBLE_COMPLEX" },
+ {MPI_2DOUBLE_COMPLEX, "MPI_2DOUBLE_COMPLEX"},
#endif
- { MPI_2REAL, "MPI_2REAL" },
- { MPI_2DOUBLE_PRECISION, "MPI_2DOUBLE_PRECISION" },
- { MPI_CHARACTER, "MPI_CHARACTER" },
+ {MPI_2REAL, "MPI_2REAL"},
+ {MPI_2DOUBLE_PRECISION, "MPI_2DOUBLE_PRECISION"},
+ {MPI_CHARACTER, "MPI_CHARACTER"},
#endif
#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
/* these C99 types were added in MPI-2.2 */
- { MPI_INT8_T, "MPI_INT8_T" },
- { MPI_INT16_T, "MPI_INT16_T" },
- { MPI_INT32_T, "MPI_INT32_T" },
- { MPI_INT64_T, "MPI_INT64_T" },
- { MPI_UINT8_T, "MPI_UINT8_T" },
- { MPI_UINT16_T, "MPI_UINT16_T" },
- { MPI_UINT32_T, "MPI_UINT32_T" },
- { MPI_UINT64_T, "MPI_UINT64_T" },
- { MPI_C_BOOL, "MPI_C_BOOL" },
- { MPI_C_FLOAT_COMPLEX, "MPI_C_FLOAT_COMPLEX" },
- { MPI_C_DOUBLE_COMPLEX, "MPI_C_DOUBLE_COMPLEX" },
- { MPI_AINT, "MPI_AINT" },
- { MPI_OFFSET, "MPI_OFFSET" },
+ {MPI_INT8_T, "MPI_INT8_T"},
+ {MPI_INT16_T, "MPI_INT16_T"},
+ {MPI_INT32_T, "MPI_INT32_T"},
+ {MPI_INT64_T, "MPI_INT64_T"},
+ {MPI_UINT8_T, "MPI_UINT8_T"},
+ {MPI_UINT16_T, "MPI_UINT16_T"},
+ {MPI_UINT32_T, "MPI_UINT32_T"},
+ {MPI_UINT64_T, "MPI_UINT64_T"},
+ {MPI_C_BOOL, "MPI_C_BOOL"},
+ {MPI_C_FLOAT_COMPLEX, "MPI_C_FLOAT_COMPLEX"},
+ {MPI_C_DOUBLE_COMPLEX, "MPI_C_DOUBLE_COMPLEX"},
+ {MPI_AINT, "MPI_AINT"},
+ {MPI_OFFSET, "MPI_OFFSET"},
#endif
/* Size-specific types */
- /* Do not move MPI_REAL4 - this is used to indicate the very first
- optional type. In addition, you must not add any required types
- after this type */
- /* See MPI 2.1, Section 16.2. These are required, predefined types.
- If the type is not available (e.g., *only* because the Fortran
- compiler does not support it), the value may be MPI_DATATYPE_NULL */
- { MPI_REAL4, "MPI_REAL4" },
- { MPI_REAL8, "MPI_REAL8" },
- { MPI_REAL16, "MPI_REAL16" },
- { MPI_COMPLEX8, "MPI_COMPLEX8" },
- { MPI_COMPLEX16, "MPI_COMPLEX16" },
- { MPI_COMPLEX32, "MPI_COMPLEX32" },
- { MPI_INTEGER1, "MPI_INTEGER1" },
- { MPI_INTEGER2, "MPI_INTEGER2" },
- { MPI_INTEGER4, "MPI_INTEGER4" },
- { MPI_INTEGER8, "MPI_INTEGER8" },
+ /* Do not move MPI_REAL4 - this is used to indicate the very first
+ * optional type. In addition, you must not add any required types
+ * after this type */
+ /* See MPI 2.1, Section 16.2. These are required, predefined types.
+ * If the type is not available (e.g., *only* because the Fortran
+ * compiler does not support it), the value may be MPI_DATATYPE_NULL */
+ {MPI_REAL4, "MPI_REAL4"},
+ {MPI_REAL8, "MPI_REAL8"},
+ {MPI_REAL16, "MPI_REAL16"},
+ {MPI_COMPLEX8, "MPI_COMPLEX8"},
+ {MPI_COMPLEX16, "MPI_COMPLEX16"},
+ {MPI_COMPLEX32, "MPI_COMPLEX32"},
+ {MPI_INTEGER1, "MPI_INTEGER1"},
+ {MPI_INTEGER2, "MPI_INTEGER2"},
+ {MPI_INTEGER4, "MPI_INTEGER4"},
+ {MPI_INTEGER8, "MPI_INTEGER8"},
#ifdef HAVE_MPI_INTEGER16
/* MPI_INTEGER16 is not included in most of the tables in MPI 2.1,
- and some implementations omit it. An error will be reported, but
- this ifdef allows the test to be built and run. */
- { MPI_INTEGER16, "MPI_INTEGER16" },
+ * and some implementations omit it. An error will be reported, but
+ * this ifdef allows the test to be built and run. */
+ {MPI_INTEGER16, "MPI_INTEGER16"},
#endif
/* Semi-optional types - if the compiler doesn't support long double
- or long long, these might be MPI_DATATYPE_NULL */
- { MPI_LONG_DOUBLE, "MPI_LONG_DOUBLE" },
- { MPI_LONG_LONG_INT, "MPI_LONG_LONG_INT" },
- { MPI_LONG_LONG, "MPI_LONG_LONG" },
- { MPI_UNSIGNED_LONG_LONG, "MPI_UNSIGNED_LONG_LONG" },
- { MPI_LONG_DOUBLE_INT, "MPI_LONG_DOUBLE_INT" },
+ * or long long, these might be MPI_DATATYPE_NULL */
+ {MPI_LONG_DOUBLE, "MPI_LONG_DOUBLE"},
+ {MPI_LONG_LONG_INT, "MPI_LONG_LONG_INT"},
+ {MPI_LONG_LONG, "MPI_LONG_LONG"},
+ {MPI_UNSIGNED_LONG_LONG, "MPI_UNSIGNED_LONG_LONG"},
+ {MPI_LONG_DOUBLE_INT, "MPI_LONG_DOUBLE_INT"},
#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
/* added in MPI-2.2 */
- { MPI_C_LONG_DOUBLE_COMPLEX, "MPI_C_LONG_DOUBLE_COMPLEX" },
- { MPI_AINT, "MPI_AINT" },
- { MPI_OFFSET, "MPI_OFFSET" },
+ {MPI_C_LONG_DOUBLE_COMPLEX, "MPI_C_LONG_DOUBLE_COMPLEX"},
+ {MPI_AINT, "MPI_AINT"},
+ {MPI_OFFSET, "MPI_OFFSET"},
#endif
#if MTEST_HAVE_MIN_MPI_VERSION(3,0)
/* added in MPI 3 */
- { MPI_COUNT, "MPI_COUNT" },
+ {MPI_COUNT, "MPI_COUNT"},
#endif
- { 0, (char *)0 }, /* Sentinal used to indicate the last element */
+ {0, (char *) 0}, /* Sentinal used to indicate the last element */
};
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
char name[MPI_MAX_OBJECT_NAME];
int namelen, i, inOptional;
int errs = 0;
- MTest_Init( &argc, &argv );
-
+ MTest_Init(&argc, &argv);
+
/* Sample some datatypes */
/* See 8.4, "Naming Objects" in MPI-2. The default name is the same
- as the datatype name */
- MPI_Type_get_name( MPI_DOUBLE, name, &namelen );
- if (strncmp( name, "MPI_DOUBLE", MPI_MAX_OBJECT_NAME )) {
- errs++;
- fprintf( stderr, "Expected MPI_DOUBLE but got :%s:\n", name );
+ * as the datatype name */
+ MPI_Type_get_name(MPI_DOUBLE, name, &namelen);
+ if (strncmp(name, "MPI_DOUBLE", MPI_MAX_OBJECT_NAME)) {
+ errs++;
+ fprintf(stderr, "Expected MPI_DOUBLE but got :%s:\n", name);
}
- MPI_Type_get_name( MPI_INT, name, &namelen );
- if (strncmp( name, "MPI_INT", MPI_MAX_OBJECT_NAME )) {
- errs++;
- fprintf( stderr, "Expected MPI_INT but got :%s:\n", name );
+ MPI_Type_get_name(MPI_INT, name, &namelen);
+ if (strncmp(name, "MPI_INT", MPI_MAX_OBJECT_NAME)) {
+ errs++;
+ fprintf(stderr, "Expected MPI_INT but got :%s:\n", name);
}
/* Now we try them ALL */
inOptional = 0;
- for (i=0; mpi_names[i].name != 0; i++) {
- /* Are we in the optional types? */
- if (strcmp( mpi_names[i].name, "MPI_REAL4" ) == 0)
- inOptional = 1;
- /* If this optional type is not supported, skip it */
- if (inOptional && mpi_names[i].dtype == MPI_DATATYPE_NULL) continue;
- if (mpi_names[i].dtype == MPI_DATATYPE_NULL) {
- /* Report an error because all of the standard types
- must be supported */
- errs++;
- fprintf( stderr, "MPI Datatype %s is MPI_DATATYPE_NULL\n",
- mpi_names[i].name );
- continue;
- }
- MTestPrintfMsg( 10, "Checking type %s\n", mpi_names[i].name );
- name[0] = 0;
- MPI_Type_get_name( mpi_names[i].dtype, name, &namelen );
- if (strncmp( name, mpi_names[i].name, namelen )) {
- errs++;
- fprintf( stderr, "Expected %s but got %s\n",
- mpi_names[i].name, name );
- }
+ for (i = 0; mpi_names[i].name != 0; i++) {
+ /* Are we in the optional types? */
+ if (strcmp(mpi_names[i].name, "MPI_REAL4") == 0)
+ inOptional = 1;
+ /* If this optional type is not supported, skip it */
+ if (inOptional && mpi_names[i].dtype == MPI_DATATYPE_NULL)
+ continue;
+ if (mpi_names[i].dtype == MPI_DATATYPE_NULL) {
+ /* Report an error because all of the standard types
+ * must be supported */
+ errs++;
+ fprintf(stderr, "MPI Datatype %s is MPI_DATATYPE_NULL\n", mpi_names[i].name);
+ continue;
+ }
+ MTestPrintfMsg(10, "Checking type %s\n", mpi_names[i].name);
+ name[0] = 0;
+ MPI_Type_get_name(mpi_names[i].dtype, name, &namelen);
+ if (strncmp(name, mpi_names[i].name, namelen)) {
+ errs++;
+ fprintf(stderr, "Expected %s but got %s\n", mpi_names[i].name, name);
+ }
}
/* Try resetting the name */
- MPI_Type_set_name( MPI_INT, (char*)"int" );
+ MPI_Type_set_name(MPI_INT, (char *) "int");
name[0] = 0;
- MPI_Type_get_name( MPI_INT, name, &namelen );
- if (strncmp( name, "int", MPI_MAX_OBJECT_NAME )) {
- errs++;
- fprintf( stderr, "Expected int but got :%s:\n", name );
+ MPI_Type_get_name(MPI_INT, name, &namelen);
+ if (strncmp(name, "int", MPI_MAX_OBJECT_NAME)) {
+ errs++;
+ fprintf(stderr, "Expected int but got :%s:\n", name);
}
#ifndef HAVE_MPI_INTEGER16
errs++;
- fprintf( stderr, "MPI_INTEGER16 is not available\n" );
+ fprintf(stderr, "MPI_INTEGER16 is not available\n");
#endif
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/datatype/unpack.c b/test/mpi/datatype/unpack.c
index 839b8fc..5f0487f 100644
--- a/test/mpi/datatype/unpack.c
+++ b/test/mpi/datatype/unpack.c
@@ -9,7 +9,7 @@
#include <stdlib.h>
#include <string.h>
-/* Test sent in by Avery Ching to report a bug in MPICH.
+/* Test sent in by Avery Ching to report a bug in MPICH.
Adding it as a regression test. */
/*
@@ -30,10 +30,11 @@ static void print_char_buf(char *buf_name, char *buf, int buf_len)
}
*/
-char correct_buf[] = {'a', '_', 'b', 'c', '_', '_', '_', '_', 'd', '_',
- 'e', 'f', 'g', '_', 'h', 'i', 'j', '_', 'k', 'l',
- '_', '_', '_', '_', 'm', '_', 'n', 'o', 'p', '_',
- 'q', 'r'};
+char correct_buf[] = { 'a', '_', 'b', 'c', '_', '_', '_', '_', 'd', '_',
+ 'e', 'f', 'g', '_', 'h', 'i', 'j', '_', 'k', 'l',
+ '_', '_', '_', '_', 'm', '_', 'n', 'o', 'p', '_',
+ 'q', 'r'
+};
#define COUNT 2
@@ -46,8 +47,8 @@ int main(int argc, char **argv)
int mem_dtype_sz = -1;
int mem_buf_sz = -1, unpack_buf_sz = -1, buf_pos = 0;
- int blk_arr[COUNT] = {1, 2};
- int dsp_arr[COUNT] = {0, 2};
+ int blk_arr[COUNT] = { 1, 2 };
+ int dsp_arr[COUNT] = { 0, 2 };
int errs = 0;
MTest_Init(&argc, &argv);
@@ -55,51 +56,45 @@ int main(int argc, char **argv)
MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
/* Creating the datatype to use for unpacking */
- MPI_Type_indexed(COUNT, blk_arr, dsp_arr,
- MPI_CHAR, &tmp_dtype);
+ MPI_Type_indexed(COUNT, blk_arr, dsp_arr, MPI_CHAR, &tmp_dtype);
MPI_Type_commit(&tmp_dtype);
- MPI_Type_indexed(COUNT, blk_arr, dsp_arr,
- tmp_dtype, &mem_dtype);
- MPI_Type_free( &tmp_dtype );
+ MPI_Type_indexed(COUNT, blk_arr, dsp_arr, tmp_dtype, &mem_dtype);
+ MPI_Type_free(&tmp_dtype);
MPI_Type_commit(&mem_dtype);
MPI_Type_size(mem_dtype, &mem_dtype_sz);
MPI_Type_extent(mem_dtype, &mem_dtype_ext);
- mem_buf_sz = 2 * mem_dtype_ext;
+ mem_buf_sz = 2 * mem_dtype_ext;
unpack_buf_sz = 2 * mem_dtype_sz;
- if ((mem_buf = (char *) malloc(mem_buf_sz)) == NULL)
- {
- fprintf(stderr, "malloc mem_buf of size %d failed\n", mem_buf_sz);
- return -1;
+ if ((mem_buf = (char *) malloc(mem_buf_sz)) == NULL) {
+ fprintf(stderr, "malloc mem_buf of size %d failed\n", mem_buf_sz);
+ return -1;
}
memset(mem_buf, '_', mem_buf_sz);
- if ((unpack_buf = (char *) malloc(unpack_buf_sz)) == NULL)
- {
- fprintf(stderr, "malloc unpack_buf of size %d failed\n",
- unpack_buf_sz);
- return -1;
+ if ((unpack_buf = (char *) malloc(unpack_buf_sz)) == NULL) {
+ fprintf(stderr, "malloc unpack_buf of size %d failed\n", unpack_buf_sz);
+ return -1;
}
-
+
for (i = 0; i < unpack_buf_sz; i++)
- unpack_buf[i] = 'a' + i;
-
+ unpack_buf[i] = 'a' + i;
+
/* print_char_buf("mem_buf before unpack", mem_buf, 2 * mem_dtype_ext); */
- MPI_Unpack(unpack_buf, unpack_buf_sz, &buf_pos,
- mem_buf, 2, mem_dtype, MPI_COMM_SELF);
+ MPI_Unpack(unpack_buf, unpack_buf_sz, &buf_pos, mem_buf, 2, mem_dtype, MPI_COMM_SELF);
/* Note: Unpack without a Pack is not technically correct, but should work
* with MPICH. */
/* print_char_buf("mem_buf after unpack", mem_buf, 2 * mem_dtype_ext);
- print_char_buf("correct buffer should be",
- correct_buf, 2 * mem_dtype_ext); */
+ * print_char_buf("correct buffer should be",
+ * correct_buf, 2 * mem_dtype_ext); */
if (memcmp(mem_buf, correct_buf, 2 * mem_dtype_ext)) {
- printf("Unpacked buffer does not match expected buffer\n");
- errs++;
+ printf("Unpacked buffer does not match expected buffer\n");
+ errs++;
}
MPI_Type_free(&mem_dtype);
diff --git a/test/mpi/datatype/unusual-noncontigs.c b/test/mpi/datatype/unusual-noncontigs.c
index 5c608f8..d783c75 100644
--- a/test/mpi/datatype/unusual-noncontigs.c
+++ b/test/mpi/datatype/unusual-noncontigs.c
@@ -10,7 +10,7 @@
#include <string.h>
#include "mpi.h"
-/*
+/*
The default behavior of the test routines should be to briefly indicate
the cause of any errors - in this test, that means that verbose needs
to be set. Verbose should turn on output that is independent of error
@@ -26,7 +26,8 @@ int indexed_negdisp_test(void);
int struct_struct_test(void);
int flatten_test(void);
-int build_array_section_type(MPI_Aint aext, MPI_Aint astart, MPI_Aint aend, MPI_Datatype *datatype);
+int build_array_section_type(MPI_Aint aext, MPI_Aint astart, MPI_Aint aend,
+ MPI_Datatype * datatype);
int main(int argc, char *argv[])
{
@@ -37,35 +38,40 @@ int main(int argc, char *argv[])
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
err = struct_negdisp_test();
- if (verbose && err) fprintf(stderr, "error in struct_negdisp_test\n");
+ if (verbose && err)
+ fprintf(stderr, "error in struct_negdisp_test\n");
errs += err;
err = vector_negstride_test();
- if (verbose && err) fprintf(stderr, "error in vector_negstride_test\n");
+ if (verbose && err)
+ fprintf(stderr, "error in vector_negstride_test\n");
errs += err;
err = indexed_negdisp_test();
- if (verbose && err) fprintf(stderr, "error in indexed_negdisp_test\n");
+ if (verbose && err)
+ fprintf(stderr, "error in indexed_negdisp_test\n");
errs += err;
err = struct_struct_test();
- if (verbose && err) fprintf(stderr, "error in struct_struct_test\n");
+ if (verbose && err)
+ fprintf(stderr, "error in struct_struct_test\n");
errs += err;
err = flatten_test();
- if (verbose && err) fprintf(stderr, "error in flatten_test\n");
+ if (verbose && err)
+ fprintf(stderr, "error in flatten_test\n");
errs += err;
/* print message and exit */
if (errs) {
- fprintf(stderr, "Found %d errors\n", errs);
+ fprintf(stderr, "Found %d errors\n", errs);
}
else {
- printf(" No Errors\n");
+ printf(" No Errors\n");
}
MPI_Finalize();
return 0;
@@ -83,80 +89,80 @@ int struct_negdisp_test(void)
MPI_Request request;
MPI_Status status;
- MPI_Aint disps[2] = { 0, -1*((int) sizeof(int)) };
- int blks[2] = { 1, 1, };
+ MPI_Aint disps[2] = { 0, -1 * ((int) sizeof(int)) };
+ int blks[2] = { 1, 1, };
MPI_Datatype types[2] = { MPI_INT, MPI_INT };
err = MPI_Type_struct(2, blks, disps, types, &mystruct);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Type_struct returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Type_struct returned error\n");
+ }
}
MPI_Type_commit(&mystruct);
- err = MPI_Irecv(recvbuf+1, 4, MPI_INT, 0, 0, MPI_COMM_SELF, &request);
+ err = MPI_Irecv(recvbuf + 1, 4, MPI_INT, 0, 0, MPI_COMM_SELF, &request);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Irecv returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Irecv returned error\n");
+ }
}
- err = MPI_Send(sendbuf+2, 2, mystruct, 0, 0, MPI_COMM_SELF);
+ err = MPI_Send(sendbuf + 2, 2, mystruct, 0, 0, MPI_COMM_SELF);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Send returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Send returned error\n");
+ }
}
err = MPI_Wait(&request, &status);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Wait returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Wait returned error\n");
+ }
}
/* verify data */
if (recvbuf[0] != -1) {
- errs++;
- if (verbose) {
- fprintf(stderr, "recvbuf[0] = %d; should be %d\n", recvbuf[0], -1);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "recvbuf[0] = %d; should be %d\n", recvbuf[0], -1);
+ }
}
if (recvbuf[1] != 3) {
- errs++;
- if (verbose) {
- fprintf(stderr, "recvbuf[1] = %d; should be %d\n", recvbuf[1], 3);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "recvbuf[1] = %d; should be %d\n", recvbuf[1], 3);
+ }
}
if (recvbuf[2] != 2) {
- errs++;
- if (verbose) {
- fprintf(stderr, "recvbuf[2] = %d; should be %d\n", recvbuf[2], 2);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "recvbuf[2] = %d; should be %d\n", recvbuf[2], 2);
+ }
}
if (recvbuf[3] != 5) {
- errs++;
- if (verbose) {
- fprintf(stderr, "recvbuf[3] = %d; should be %d\n", recvbuf[3], 5);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "recvbuf[3] = %d; should be %d\n", recvbuf[3], 5);
+ }
}
if (recvbuf[4] != 4) {
- errs++;
- if (verbose) {
- fprintf(stderr, "recvbuf[4] = %d; should be %d\n", recvbuf[4], 4);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "recvbuf[4] = %d; should be %d\n", recvbuf[4], 4);
+ }
}
if (recvbuf[5] != -6) {
- errs++;
- if (verbose) {
- fprintf(stderr, "recvbuf[5] = %d; should be %d\n", recvbuf[5], -6);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "recvbuf[5] = %d; should be %d\n", recvbuf[5], -6);
+ }
}
MPI_Type_free(&mystruct);
@@ -179,74 +185,74 @@ int vector_negstride_test(void)
err = MPI_Type_vector(2, 1, -1, MPI_INT, &myvector);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Type_vector returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Type_vector returned error\n");
+ }
}
MPI_Type_commit(&myvector);
- err = MPI_Irecv(recvbuf+1, 4, MPI_INT, 0, 0, MPI_COMM_SELF, &request);
+ err = MPI_Irecv(recvbuf + 1, 4, MPI_INT, 0, 0, MPI_COMM_SELF, &request);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Irecv returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Irecv returned error\n");
+ }
}
- err = MPI_Send(sendbuf+2, 2, myvector, 0, 0, MPI_COMM_SELF);
+ err = MPI_Send(sendbuf + 2, 2, myvector, 0, 0, MPI_COMM_SELF);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Send returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Send returned error\n");
+ }
}
err = MPI_Wait(&request, &status);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Wait returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Wait returned error\n");
+ }
}
/* verify data */
if (recvbuf[0] != -1) {
- errs++;
- if (verbose) {
- fprintf(stderr, "recvbuf[0] = %d; should be %d\n", recvbuf[0], -1);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "recvbuf[0] = %d; should be %d\n", recvbuf[0], -1);
+ }
}
if (recvbuf[1] != 3) {
- errs++;
- if (verbose) {
- fprintf(stderr, "recvbuf[1] = %d; should be %d\n", recvbuf[1], 3);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "recvbuf[1] = %d; should be %d\n", recvbuf[1], 3);
+ }
}
if (recvbuf[2] != 2) {
- errs++;
- if (verbose) {
- fprintf(stderr, "recvbuf[2] = %d; should be %d\n", recvbuf[2], 2);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "recvbuf[2] = %d; should be %d\n", recvbuf[2], 2);
+ }
}
if (recvbuf[3] != 5) {
- errs++;
- if (verbose) {
- fprintf(stderr, "recvbuf[3] = %d; should be %d\n", recvbuf[3], 5);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "recvbuf[3] = %d; should be %d\n", recvbuf[3], 5);
+ }
}
if (recvbuf[4] != 4) {
- errs++;
- if (verbose) {
- fprintf(stderr, "recvbuf[4] = %d; should be %d\n", recvbuf[4], 4);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "recvbuf[4] = %d; should be %d\n", recvbuf[4], 4);
+ }
}
if (recvbuf[5] != -6) {
- errs++;
- if (verbose) {
- fprintf(stderr, "recvbuf[5] = %d; should be %d\n", recvbuf[5], -6);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "recvbuf[5] = %d; should be %d\n", recvbuf[5], -6);
+ }
}
MPI_Type_free(&myvector);
@@ -267,79 +273,79 @@ int indexed_negdisp_test(void)
MPI_Request request;
MPI_Status status;
- int disps[2] = { 0, -1 };
- int blks[2] = { 1, 1 };
+ int disps[2] = { 0, -1 };
+ int blks[2] = { 1, 1 };
err = MPI_Type_indexed(2, blks, disps, MPI_INT, &myindexed);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Type_indexed returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Type_indexed returned error\n");
+ }
}
MPI_Type_commit(&myindexed);
- err = MPI_Irecv(recvbuf+1, 4, MPI_INT, 0, 0, MPI_COMM_SELF, &request);
+ err = MPI_Irecv(recvbuf + 1, 4, MPI_INT, 0, 0, MPI_COMM_SELF, &request);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Irecv returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Irecv returned error\n");
+ }
}
- err = MPI_Send(sendbuf+2, 2, myindexed, 0, 0, MPI_COMM_SELF);
+ err = MPI_Send(sendbuf + 2, 2, myindexed, 0, 0, MPI_COMM_SELF);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Send returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Send returned error\n");
+ }
}
err = MPI_Wait(&request, &status);
if (err != MPI_SUCCESS) {
- errs++;
- if (verbose) {
- fprintf(stderr, "MPI_Wait returned error\n");
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "MPI_Wait returned error\n");
+ }
}
/* verify data */
if (recvbuf[0] != -1) {
- errs++;
- if (verbose) {
- fprintf(stderr, "recvbuf[0] = %d; should be %d\n", recvbuf[0], -1);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "recvbuf[0] = %d; should be %d\n", recvbuf[0], -1);
+ }
}
if (recvbuf[1] != 3) {
- errs++;
- if (verbose) {
- fprintf(stderr, "recvbuf[1] = %d; should be %d\n", recvbuf[1], 3);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "recvbuf[1] = %d; should be %d\n", recvbuf[1], 3);
+ }
}
if (recvbuf[2] != 2) {
- errs++;
- if (verbose) {
- fprintf(stderr, "recvbuf[2] = %d; should be %d\n", recvbuf[2], 2);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "recvbuf[2] = %d; should be %d\n", recvbuf[2], 2);
+ }
}
if (recvbuf[3] != 5) {
- errs++;
- if (verbose) {
- fprintf(stderr, "recvbuf[3] = %d; should be %d\n", recvbuf[3], 5);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "recvbuf[3] = %d; should be %d\n", recvbuf[3], 5);
+ }
}
if (recvbuf[4] != 4) {
- errs++;
- if (verbose) {
- fprintf(stderr, "recvbuf[4] = %d; should be %d\n", recvbuf[4], 4);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "recvbuf[4] = %d; should be %d\n", recvbuf[4], 4);
+ }
}
if (recvbuf[5] != -6) {
- errs++;
- if (verbose) {
- fprintf(stderr, "recvbuf[5] = %d; should be %d\n", recvbuf[5], -6);
- }
+ errs++;
+ if (verbose) {
+ fprintf(stderr, "recvbuf[5] = %d; should be %d\n", recvbuf[5], -6);
+ }
}
MPI_Type_free(&myindexed);
@@ -381,39 +387,41 @@ int struct_struct_test(void)
* arrays are row-major. So we invert the order of dimensions. */
#define N (2)
#define M (4)
- int array[N][M] = { {-1, -1, -1, -1}, {-1, -1, -1, -1} };
- int expected[N][M] = { {-1, 1, 2, 5}, {-1, 3, 4, 6} };
- int seq_array[N*M];
+ int array[N][M] = { {-1, -1, -1, -1}, {-1, -1, -1, -1} };
+ int expected[N][M] = { {-1, 1, 2, 5}, {-1, 3, 4, 6} };
+ int seq_array[N * M];
MPI_Aint astart, aend;
MPI_Aint size_exp = 0;
/* 1st section selects elements 1 and 2 out of 2nd dimension, complete 1st dim.
* should receive the values 1, 2, 3, 4 */
astart = 1;
- aend = 2;
+ aend = 2;
err = build_array_section_type(M, astart, aend, &types[0]);
if (err) {
errs++;
- if (verbose) fprintf(stderr, "build_array_section_type failed\n");
+ if (verbose)
+ fprintf(stderr, "build_array_section_type failed\n");
return errs;
}
blens[0] = N;
displ[0] = 0;
- size_exp = size_exp + N * (aend-astart+1) * sizeof(int);
+ size_exp = size_exp + N * (aend - astart + 1) * sizeof(int);
/* 2nd section selects last element of 2nd dimension, complete 1st dim.
* should receive the values 5, 6 */
astart = 3;
- aend = 3;
+ aend = 3;
err = build_array_section_type(M, astart, aend, &types[1]);
if (err) {
errs++;
- if (verbose) fprintf(stderr, "build_array_section_type failed\n");
+ if (verbose)
+ fprintf(stderr, "build_array_section_type failed\n");
return errs;
}
blens[1] = N;
displ[1] = 0;
- size_exp = size_exp + N * (aend-astart+1) * sizeof(int);
+ size_exp = size_exp + N * (aend - astart + 1) * sizeof(int);
/* create type */
err = MPI_Type_create_struct(COUNT, blens, displ, types, &datatype);
@@ -425,14 +433,15 @@ int struct_struct_test(void)
check_err(MPI_Type_size);
if (dt_size != size_exp) {
errs++;
- if (verbose) fprintf(stderr, "unexpected type size\n");
+ if (verbose)
+ fprintf(stderr, "unexpected type size\n");
}
/* send the type to ourselves to make sure that the type describes data correctly */
- for (i = 0; i < (N*M) ; ++i)
- seq_array[i] = i + 1; /* source values 1..(N*M) */
- err = MPI_Isend(&seq_array[0], dt_size/sizeof(int), MPI_INT, 0, 42, MPI_COMM_SELF, &req[0]);
+ for (i = 0; i < (N * M); ++i)
+ seq_array[i] = i + 1; /* source values 1..(N*M) */
+ err = MPI_Isend(&seq_array[0], dt_size / sizeof(int), MPI_INT, 0, 42, MPI_COMM_SELF, &req[0]);
check_err(MPI_Isend);
err = MPI_Irecv(&array[0][0], 1, datatype, 0, 42, MPI_COMM_SELF, &req[1]);
check_err(MPI_Irecv);
@@ -445,7 +454,8 @@ int struct_struct_test(void)
if (array[i][j] != expected[i][j]) {
errs++;
if (verbose)
- fprintf(stderr, "array[%d][%d]=%d, should be %d\n", i, j, array[i][j], expected[i][j]);
+ fprintf(stderr, "array[%d][%d]=%d, should be %d\n", i, j, array[i][j],
+ expected[i][j]);
}
}
}
@@ -478,7 +488,7 @@ int struct_struct_test(void)
1D array ###############################
datatype LB ########### UB
*/
-int build_array_section_type(MPI_Aint aext, MPI_Aint astart, MPI_Aint aend, MPI_Datatype *datatype)
+int build_array_section_type(MPI_Aint aext, MPI_Aint astart, MPI_Aint aend, MPI_Datatype * datatype)
{
#define COUNT (3)
int err, errs = 0;
@@ -517,8 +527,7 @@ int build_array_section_type(MPI_Aint aext, MPI_Aint astart, MPI_Aint aend, MPI_
/* start_idx is the "zero" point for the unpack */
static int pack_and_check_expected(MPI_Datatype type, const char *name,
- int start_idx, int size,
- int *array, int *expected)
+ int start_idx, int size, int *array, int *expected)
{
int i;
int err, errs = 0;
@@ -526,19 +535,21 @@ static int pack_and_check_expected(MPI_Datatype type, const char *name,
int *pack_buf = NULL;
int pos;
int type_size = -1;
- int sendbuf[8] = {0,1,2,3,4,5,6,7};
+ int sendbuf[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
err = MPI_Type_size(type, &type_size);
check_err(MPI_Type_size);
assert(sizeof(sendbuf) >= type_size);
- err = MPI_Pack_size(type_size/sizeof(int), MPI_INT, MPI_COMM_SELF, &pack_size);
+ err = MPI_Pack_size(type_size / sizeof(int), MPI_INT, MPI_COMM_SELF, &pack_size);
check_err(MPI_Pack_size);
pack_buf = malloc(pack_size);
assert(pack_buf);
pos = 0;
- err = MPI_Pack(&sendbuf[0], type_size/sizeof(int), MPI_INT, pack_buf, pack_size, &pos, MPI_COMM_SELF);
+ err =
+ MPI_Pack(&sendbuf[0], type_size / sizeof(int), MPI_INT, pack_buf, pack_size, &pos,
+ MPI_COMM_SELF);
check_err(MPI_Pack);
pos = 0;
err = MPI_Unpack(pack_buf, pack_size, &pos, &array[start_idx], 1, type, MPI_COMM_SELF);
@@ -565,8 +576,8 @@ int flatten_test(void)
#define ARR_SIZE (9)
/* real indices 0 1 2 3 4 5 6 7 8
* indices w/ &array[3] -3 -2 -1 0 1 2 3 4 5 */
- int array[ARR_SIZE] = {-1,-1,-1,-1,-1,-1,-1,-1,-1};
- int expected[ARR_SIZE] = {-1, 0, 1,-1, 2,-1, 3,-1, 4};
+ int array[ARR_SIZE] = { -1, -1, -1, -1, -1, -1, -1, -1, -1 };
+ int expected[ARR_SIZE] = { -1, 0, 1, -1, 2, -1, 3, -1, 4 };
MPI_Datatype idx_type = MPI_DATATYPE_NULL;
MPI_Datatype blkidx_type = MPI_DATATYPE_NULL;
MPI_Datatype combo = MPI_DATATYPE_NULL;
@@ -583,9 +594,9 @@ int flatten_test(void)
* different blens to prevent optimization into a blockindexed
*/
blens[0] = 2;
- displ[0] = -2; /* elements, puts byte after block end at 0 */
+ displ[0] = -2; /* elements, puts byte after block end at 0 */
blens[1] = 1;
- displ[1] = 1; /*elements*/
+ displ[1] = 1; /*elements */
err = MPI_Type_indexed(COUNT, blens, displ, MPI_INT, &idx_type);
check_err(MPI_Type_indexed);
@@ -607,13 +618,13 @@ int flatten_test(void)
* II_I_B_B (I=idx_type, B=blkidx_type)
* 21012345 <-- pos (left of 0 is neg)
*/
- blens[0] = 1;
- adispl[0] = 0; /*bytes*/
- types[0] = idx_type;
+ blens[0] = 1;
+ adispl[0] = 0; /*bytes */
+ types[0] = idx_type;
- blens[1] = 1;
- adispl[1] = 4 * sizeof(int); /* bytes */
- types[1] = blkidx_type;
+ blens[1] = 1;
+ adispl[1] = 4 * sizeof(int); /* bytes */
+ types[1] = blkidx_type;
/* must be a struct in order to trigger flattening code */
err = MPI_Type_create_struct(COUNT, blens, adispl, types, &combo);
@@ -631,23 +642,24 @@ int flatten_test(void)
return errs;
#undef COUNT
}
+
#undef check_err
int parse_args(int argc, char **argv)
{
/*
- int ret;
-
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
- }
- */
+ * int ret;
+ *
+ * while ((ret = getopt(argc, argv, "v")) >= 0)
+ * {
+ * switch (ret) {
+ * case 'v':
+ * verbose = 1;
+ * break;
+ * }
+ * }
+ */
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
return 0;
}
diff --git a/test/mpi/datatype/vecblklen.c b/test/mpi/datatype/vecblklen.c
index cfe0733..50bac85 100644
--- a/test/mpi/datatype/vecblklen.c
+++ b/test/mpi/datatype/vecblklen.c
@@ -12,79 +12,77 @@
/* Inspired by the Intel MPI_Type_vector_blklen test.
Added to include a test of a dataloop optimization that failed.
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Datatype ot, ot2, newtype;
int position, psize, insize, outsize;
- signed char *inbuf=0, *outbuf=0, *pbuf=0, *p;
- int i, j, k;
- int errs = 0;
- int veccount=16, stride=16;
+ signed char *inbuf = 0, *outbuf = 0, *pbuf = 0, *p;
+ int i, j, k;
+ int errs = 0;
+ int veccount = 16, stride = 16;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
/*
* Create a type with some padding
*/
- MPI_Type_contiguous( 59, MPI_CHAR, &ot );
- MPI_Type_create_resized( ot, 0, 64, &ot2 );
+ MPI_Type_contiguous(59, MPI_CHAR, &ot);
+ MPI_Type_create_resized(ot, 0, 64, &ot2);
/*
- Use a vector type with a block size equal to the stride - thus
- tiling the target memory with copies of old type. This is not
- a contiguous copy since oldtype has a gap at the end.
- */
- MPI_Type_vector( veccount, stride, stride, ot2, &newtype );
- MPI_Type_commit( &newtype );
+ * Use a vector type with a block size equal to the stride - thus
+ * tiling the target memory with copies of old type. This is not
+ * a contiguous copy since oldtype has a gap at the end.
+ */
+ MPI_Type_vector(veccount, stride, stride, ot2, &newtype);
+ MPI_Type_commit(&newtype);
insize = veccount * stride * 64;
outsize = insize;
- inbuf = (char *)malloc( insize );
- outbuf = (char *)malloc( outsize );
- for (i=0; i<outsize; i++) {
+ inbuf = (char *) malloc(insize);
+ outbuf = (char *) malloc(outsize);
+ for (i = 0; i < outsize; i++) {
inbuf[i] = i % 64;
outbuf[i] = -1;
}
- MPI_Pack_size( 1, newtype, MPI_COMM_WORLD, &psize );
- pbuf = (char *)malloc( psize );
+ MPI_Pack_size(1, newtype, MPI_COMM_WORLD, &psize);
+ pbuf = (char *) malloc(psize);
position = 0;
- MPI_Pack( inbuf, 1, newtype, pbuf, psize, &position, MPI_COMM_WORLD );
- psize = position;
+ MPI_Pack(inbuf, 1, newtype, pbuf, psize, &position, MPI_COMM_WORLD);
+ psize = position;
position = 0;
- MPI_Unpack( pbuf, psize, &position, outbuf, 1, newtype, MPI_COMM_WORLD );
+ MPI_Unpack(pbuf, psize, &position, outbuf, 1, newtype, MPI_COMM_WORLD);
/* Check the output */
p = outbuf;
- for (i=0; i<veccount; i++) {
- for (j=0; j<stride; j++) {
- for (k=0; k<59; k++) {
+ for (i = 0; i < veccount; i++) {
+ for (j = 0; j < stride; j++) {
+ for (k = 0; k < 59; k++) {
if (*p != k % 64) {
errs++;
- fprintf( stderr, "[%d,%d,%d]expected %d but saw %d\n",
- i, j, k, (k%64), *p );
+ fprintf(stderr, "[%d,%d,%d]expected %d but saw %d\n", i, j, k, (k % 64), *p);
}
p++;
}
- for (k=59; k<64; k++) {
+ for (k = 59; k < 64; k++) {
if (*p != -1) {
errs++;
- fprintf( stderr, "[%d,%d,%d]expected -1 but saw %d\n",
- i, j, k, *p );
+ fprintf(stderr, "[%d,%d,%d]expected -1 but saw %d\n", i, j, k, *p);
}
p++;
}
}
}
- free( pbuf );
- free( inbuf );
- free( outbuf );
+ free(pbuf);
+ free(inbuf);
+ free(outbuf);
- MPI_Type_free( &ot );
- MPI_Type_free( &ot2 );
- MPI_Type_free( &newtype );
- MTest_Finalize( errs );
+ MPI_Type_free(&ot);
+ MPI_Type_free(&ot2);
+ MPI_Type_free(&newtype);
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
diff --git a/test/mpi/datatype/zero-blklen-vector.c b/test/mpi/datatype/zero-blklen-vector.c
index 12b1937..ff1e123 100644
--- a/test/mpi/datatype/zero-blklen-vector.c
+++ b/test/mpi/datatype/zero-blklen-vector.c
@@ -3,35 +3,34 @@
*
* (C) 2003 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
- */
+ */
#include <mpi.h>
#include <stdio.h>
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
- int iam, np;
- int m = 2, n = 0, lda = 1;
- double A[2];
- MPI_Comm comm = MPI_COMM_WORLD;
- MPI_Datatype type = MPI_DOUBLE, vtype;
+ int iam, np;
+ int m = 2, n = 0, lda = 1;
+ double A[2];
+ MPI_Comm comm = MPI_COMM_WORLD;
+ MPI_Datatype type = MPI_DOUBLE, vtype;
- MPI_Init(&argc,&argv);
- MPI_Comm_size(comm, &np);
- MPI_Comm_rank(comm, &iam);
- if (np < 2) {
- printf( "Should be at least 2 processes for the test\n");
- } else {
- MPI_Type_vector(n, m, lda, type, &vtype);
- MPI_Type_commit(&vtype);
- A[0] = -1.0-0.1*iam;
- A[1] = 0.5+0.1*iam;
- printf("In process %i of %i before Bcast: A = %f,%f\n",
- iam, np, A[0], A[1] );
- MPI_Bcast(A, 1, vtype, 0, comm);
- printf("In process %i of %i after Bcast: A = %f,%f\n",
- iam, np, A[0], A[1]);
- MPI_Type_free(&vtype);
- }
+ MPI_Init(&argc, &argv);
+ MPI_Comm_size(comm, &np);
+ MPI_Comm_rank(comm, &iam);
+ if (np < 2) {
+ printf("Should be at least 2 processes for the test\n");
+ }
+ else {
+ MPI_Type_vector(n, m, lda, type, &vtype);
+ MPI_Type_commit(&vtype);
+ A[0] = -1.0 - 0.1 * iam;
+ A[1] = 0.5 + 0.1 * iam;
+ printf("In process %i of %i before Bcast: A = %f,%f\n", iam, np, A[0], A[1]);
+ MPI_Bcast(A, 1, vtype, 0, comm);
+ printf("In process %i of %i after Bcast: A = %f,%f\n", iam, np, A[0], A[1]);
+ MPI_Type_free(&vtype);
+ }
- MPI_Finalize();
+ MPI_Finalize();
}
diff --git a/test/mpi/datatype/zeroblks.c b/test/mpi/datatype/zeroblks.c
index 0c5d390..c9ed61f 100644
--- a/test/mpi/datatype/zeroblks.c
+++ b/test/mpi/datatype/zeroblks.c
@@ -7,7 +7,7 @@
#include "mpi.h"
#include "mpitest.h"
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int position, pack_size, i;
@@ -17,13 +17,13 @@ int main( int argc, char *argv[] )
int recv_buffer[60];
int pack_buffer[1000];
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
/* Initialize data in the buffers */
- for (i=0; i<60; i++) {
- send_buffer[i] = i;
- recv_buffer[i] = -1;
- pack_buffer[i] = -2;
+ for (i = 0; i < 60; i++) {
+ send_buffer[i] = i;
+ recv_buffer[i] = -1;
+ pack_buffer[i] = -2;
}
/* Create an indexed type with an empty first block */
@@ -37,32 +37,28 @@ int main( int argc, char *argv[] )
MPI_Type_commit(&type);
position = 0;
- MPI_Pack( send_buffer, 1, type, pack_buffer, sizeof(pack_buffer),
- &position, MPI_COMM_WORLD );
+ MPI_Pack(send_buffer, 1, type, pack_buffer, sizeof(pack_buffer), &position, MPI_COMM_WORLD);
pack_size = position;
position = 0;
- MPI_Unpack( pack_buffer, pack_size, &position, recv_buffer, 1, type,
- MPI_COMM_WORLD );
+ MPI_Unpack(pack_buffer, pack_size, &position, recv_buffer, 1, type, MPI_COMM_WORLD);
/* Check that the last 40 entries of the recv_buffer have the corresponding
- elements from the send buffer */
- for (i=0; i<20; i++) {
- if (recv_buffer[i] != -1) {
- errs++;
- fprintf( stderr, "recv_buffer[%d] = %d, should = -1\n", i,
- recv_buffer[i] );
- }
+ * elements from the send buffer */
+ for (i = 0; i < 20; i++) {
+ if (recv_buffer[i] != -1) {
+ errs++;
+ fprintf(stderr, "recv_buffer[%d] = %d, should = -1\n", i, recv_buffer[i]);
+ }
}
- for (i=20; i<60; i++) {
- if (recv_buffer[i] != i) {
- errs++;
- fprintf( stderr, "recv_buffer[%d] = %d, should = %d\n", i,
- recv_buffer[i], i );
- }
+ for (i = 20; i < 60; i++) {
+ if (recv_buffer[i] != i) {
+ errs++;
+ fprintf(stderr, "recv_buffer[%d] = %d, should = %d\n", i, recv_buffer[i], i);
+ }
}
- MPI_Type_free( &type );
+ MPI_Type_free(&type);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
diff --git a/test/mpi/datatype/zeroparms.c b/test/mpi/datatype/zeroparms.c
index c9649f7..fe95be1 100644
--- a/test/mpi/datatype/zeroparms.c
+++ b/test/mpi/datatype/zeroparms.c
@@ -7,31 +7,29 @@
#include <stdio.h>
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Datatype newtype;
int b[1], d[1];
- MPI_Init( 0, 0 );
+ MPI_Init(0, 0);
- /* create a legitimate type to see that we don't
+ /* create a legitimate type to see that we don't
* emit spurious errors.
*/
- MPI_Type_hvector( 0, 1, 10, MPI_DOUBLE, &newtype );
- MPI_Type_commit( &newtype );
- MPI_Type_free( &newtype );
+ MPI_Type_hvector(0, 1, 10, MPI_DOUBLE, &newtype);
+ MPI_Type_commit(&newtype);
+ MPI_Type_free(&newtype);
- MPI_Type_indexed( 0, b, d, MPI_DOUBLE, &newtype );
- MPI_Type_commit( &newtype );
+ MPI_Type_indexed(0, b, d, MPI_DOUBLE, &newtype);
+ MPI_Type_commit(&newtype);
- MPI_Sendrecv( b, 1, newtype, 0, 0,
- d, 0, newtype, 0, 0,
- MPI_COMM_WORLD, MPI_STATUS_IGNORE );
+ MPI_Sendrecv(b, 1, newtype, 0, 0, d, 0, newtype, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
- printf( " No Errors\n" );
+ printf(" No Errors\n");
+
+ MPI_Type_free(&newtype);
- MPI_Type_free( &newtype );
-
MPI_Finalize();
return 0;
diff --git a/test/mpi/errhan/adderr.c b/test/mpi/errhan/adderr.c
index 5926535..a0b2fb0 100644
--- a/test/mpi/errhan/adderr.c
+++ b/test/mpi/errhan/adderr.c
@@ -17,52 +17,49 @@
#define NCLASSES 32
#define NCODES 5
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
char string[MPI_MAX_ERROR_STRING], outstring[MPI_MAX_ERROR_STRING];
int newclass[NCLASSES], newcode[NCLASSES][NCODES];
int i, j, slen, outclass;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
/* Initialize the new codes */
- for (i=0; i<NCLASSES; i++) {
- MPI_Add_error_class( &newclass[i] );
- for (j=0; j<NCODES; j++) {
- MPI_Add_error_code( newclass[i], &newcode[i][j] );
- sprintf( string, "code for class %d code %d\n", i, j );
- MPI_Add_error_string( newcode[i][j], string );
- }
+ for (i = 0; i < NCLASSES; i++) {
+ MPI_Add_error_class(&newclass[i]);
+ for (j = 0; j < NCODES; j++) {
+ MPI_Add_error_code(newclass[i], &newcode[i][j]);
+ sprintf(string, "code for class %d code %d\n", i, j);
+ MPI_Add_error_string(newcode[i][j], string);
+ }
}
/* check the values */
- for (i=0; i<NCLASSES; i++) {
- MPI_Error_class( newclass[i], &outclass );
- if (outclass != newclass[i]) {
- errs++;
- printf( "Error class %d is not a valid error code %x %x\n", i,
- outclass, newclass[i]);
- }
- for (j=0; j<NCODES; j++) {
- MPI_Error_class( newcode[i][j], &outclass );
- if (outclass != newclass[i]) {
- errs++;
- printf( "Class of code for %d is not correct %x %x\n", j,
- outclass, newclass[i] );
- }
- MPI_Error_string( newcode[i][j], outstring, &slen );
- sprintf( string, "code for class %d code %d\n", i, j );
- if (strcmp( outstring, string )) {
- errs++;
- printf( "Error string is :%s: but should be :%s:\n",
- outstring, string );
- }
- }
+ for (i = 0; i < NCLASSES; i++) {
+ MPI_Error_class(newclass[i], &outclass);
+ if (outclass != newclass[i]) {
+ errs++;
+ printf("Error class %d is not a valid error code %x %x\n", i, outclass, newclass[i]);
+ }
+ for (j = 0; j < NCODES; j++) {
+ MPI_Error_class(newcode[i][j], &outclass);
+ if (outclass != newclass[i]) {
+ errs++;
+ printf("Class of code for %d is not correct %x %x\n", j, outclass, newclass[i]);
+ }
+ MPI_Error_string(newcode[i][j], outstring, &slen);
+ sprintf(string, "code for class %d code %d\n", i, j);
+ if (strcmp(outstring, string)) {
+ errs++;
+ printf("Error string is :%s: but should be :%s:\n", outstring, string);
+ }
+ }
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/errhan/commcall.c b/test/mpi/errhan/commcall.c
index a118ae7..026d99b 100644
--- a/test/mpi/errhan/commcall.c
+++ b/test/mpi/errhan/commcall.c
@@ -15,79 +15,80 @@ static char MTEST_Descrip[] = "Test comm_call_errhandler";
static int calls = 0;
static int errs = 0;
static MPI_Comm mycomm;
-void eh( MPI_Comm *comm, int *err, ... );
-void eh( MPI_Comm *comm, int *err, ... )
+void eh(MPI_Comm * comm, int *err, ...);
+void eh(MPI_Comm * comm, int *err, ...)
{
if (*err != MPI_ERR_OTHER) {
- errs++;
- printf( "Unexpected error code\n" );
+ errs++;
+ printf("Unexpected error code\n");
}
if (*comm != mycomm) {
- errs++;
- printf( "Unexpected communicator\n" );
+ errs++;
+ printf("Unexpected communicator\n");
}
calls++;
return;
}
-int main( int argc, char *argv[] )
+
+int main(int argc, char *argv[])
{
- MPI_Comm comm;
+ MPI_Comm comm;
MPI_Errhandler newerr;
- int i;
- int reset_handler;
+ int i;
+ int reset_handler;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
mycomm = comm;
- MPI_Comm_create_errhandler( eh, &newerr );
+ MPI_Comm_create_errhandler(eh, &newerr);
- MPI_Comm_set_errhandler( comm, newerr );
- MPI_Comm_call_errhandler( comm, MPI_ERR_OTHER );
- MPI_Errhandler_free( &newerr );
+ MPI_Comm_set_errhandler(comm, newerr);
+ MPI_Comm_call_errhandler(comm, MPI_ERR_OTHER);
+ MPI_Errhandler_free(&newerr);
if (calls != 1) {
- errs++;
- printf( "Error handler not called\n" );
+ errs++;
+ printf("Error handler not called\n");
}
/* Here we apply the test to many copies of a communicator */
for (reset_handler = 0; reset_handler <= 1; ++reset_handler) {
- for (i=0; i<1000; i++) {
+ for (i = 0; i < 1000; i++) {
MPI_Comm comm2;
calls = 0;
- MPI_Comm_dup( MPI_COMM_WORLD, &comm );
+ MPI_Comm_dup(MPI_COMM_WORLD, &comm);
mycomm = comm;
- MPI_Comm_create_errhandler( eh, &newerr );
+ MPI_Comm_create_errhandler(eh, &newerr);
- MPI_Comm_set_errhandler( comm, newerr );
- MPI_Comm_call_errhandler( comm, MPI_ERR_OTHER );
+ MPI_Comm_set_errhandler(comm, newerr);
+ MPI_Comm_call_errhandler(comm, MPI_ERR_OTHER);
if (calls != 1) {
errs++;
- printf( "Error handler not called\n" );
+ printf("Error handler not called\n");
}
- MPI_Comm_dup( comm, &comm2 );
+ MPI_Comm_dup(comm, &comm2);
calls = 0;
mycomm = comm2;
/* comm2 must inherit the error handler from comm */
- MPI_Comm_call_errhandler( comm2, MPI_ERR_OTHER );
+ MPI_Comm_call_errhandler(comm2, MPI_ERR_OTHER);
if (calls != 1) {
errs++;
- printf( "Error handler not called\n" );
+ printf("Error handler not called\n");
}
if (reset_handler) {
/* extra checking of the reference count handling */
- MPI_Comm_set_errhandler( comm, MPI_ERRORS_ARE_FATAL );
+ MPI_Comm_set_errhandler(comm, MPI_ERRORS_ARE_FATAL);
}
- MPI_Errhandler_free( &newerr );
+ MPI_Errhandler_free(&newerr);
- MPI_Comm_free( &comm );
- MPI_Comm_free( &comm2 );
+ MPI_Comm_free(&comm);
+ MPI_Comm_free(&comm2);
}
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/errhan/dynamic_errcode_predefined_errclass.c b/test/mpi/errhan/dynamic_errcode_predefined_errclass.c
index 3fa1c9f..2d8e28a 100644
--- a/test/mpi/errhan/dynamic_errcode_predefined_errclass.c
+++ b/test/mpi/errhan/dynamic_errcode_predefined_errclass.c
@@ -11,7 +11,8 @@
#include <stdio.h>
#include <mpi.h>
-int main(int argc, char **argv) {
+int main(int argc, char **argv)
+{
int errcode, errclass;
MPI_Init(&argc, &argv);
@@ -21,8 +22,9 @@ int main(int argc, char **argv) {
if (errclass != MPI_ERR_ARG) {
printf("ERROR: Got 0x%x, expected 0x%x\n", errclass, MPI_ERR_ARG);
- } else {
- printf( " No Errors\n" );
+ }
+ else {
+ printf(" No Errors\n");
}
MPI_Finalize();
diff --git a/test/mpi/errhan/errfatal.c b/test/mpi/errhan/errfatal.c
index b1463b7..0e9f55a 100644
--- a/test/mpi/errhan/errfatal.c
+++ b/test/mpi/errhan/errfatal.c
@@ -10,36 +10,37 @@
static int verbose = 0;
-int main(int argc, char** argv) {
- int MY_ERROR_CLASS;
- int MY_ERROR_CODE;
- char MY_ERROR_STRING[10];
-
- sprintf(MY_ERROR_STRING, "MY ERROR");
-
- MPI_Init(&argc, &argv);
-
- if (verbose)
- printf("Adding My Error Class\n");
- MPI_Add_error_class(&MY_ERROR_CLASS);
- if (verbose)
- printf("Adding My Error Code\n");
- MPI_Add_error_code(MY_ERROR_CLASS, &MY_ERROR_CODE);
- if (verbose)
- printf("Adding My Error String\n");
- MPI_Add_error_string(MY_ERROR_CODE, MY_ERROR_STRING);
-
- if (verbose)
- printf("Calling Error Handler\n");
- MPI_Comm_call_errhandler(MPI_COMM_WORLD, MY_ERROR_CODE);
-
- /* We should not get here, because the default error handler
- is ERRORS_ARE_FATAL. This makes sure that the correct error
- handler is called and that no failure occured (such as
- a SEGV) in Comm_call_errhandler on the default
- error handler. */
- printf("After the Error Handler Has Been Called\n");
-
- MPI_Finalize();
- return 0;
+int main(int argc, char **argv)
+{
+ int MY_ERROR_CLASS;
+ int MY_ERROR_CODE;
+ char MY_ERROR_STRING[10];
+
+ sprintf(MY_ERROR_STRING, "MY ERROR");
+
+ MPI_Init(&argc, &argv);
+
+ if (verbose)
+ printf("Adding My Error Class\n");
+ MPI_Add_error_class(&MY_ERROR_CLASS);
+ if (verbose)
+ printf("Adding My Error Code\n");
+ MPI_Add_error_code(MY_ERROR_CLASS, &MY_ERROR_CODE);
+ if (verbose)
+ printf("Adding My Error String\n");
+ MPI_Add_error_string(MY_ERROR_CODE, MY_ERROR_STRING);
+
+ if (verbose)
+ printf("Calling Error Handler\n");
+ MPI_Comm_call_errhandler(MPI_COMM_WORLD, MY_ERROR_CODE);
+
+ /* We should not get here, because the default error handler
+ * is ERRORS_ARE_FATAL. This makes sure that the correct error
+ * handler is called and that no failure occured (such as
+ * a SEGV) in Comm_call_errhandler on the default
+ * error handler. */
+ printf("After the Error Handler Has Been Called\n");
+
+ MPI_Finalize();
+ return 0;
}
diff --git a/test/mpi/errhan/errmsg.c b/test/mpi/errhan/errmsg.c
index 9249c53..4c69526 100644
--- a/test/mpi/errhan/errmsg.c
+++ b/test/mpi/errhan/errmsg.c
@@ -6,23 +6,23 @@
#include <stdio.h>
#include "mpi.h"
-void ChkMsg( int, int, const char [] );
+void ChkMsg(int, int, const char[]);
/*
* This routine is used to check the message associated with an error
* code. Currently, it uses MPI_Error_string to get the corresponding
* message for a code, and prints out the cooresponding class and original
* message.
- *
+ *
* Eventually, we should also access the generic anc specific messages
* separately.
*/
-void ChkMsg( int err, int msgclass, const char msg[] )
+void ChkMsg(int err, int msgclass, const char msg[])
{
char errmsg[MPI_MAX_ERROR_STRING];
int len;
- MPI_Error_string( err, errmsg, &len );
-
- fprintf( stdout, "[0x%08x] %2d %s \tgives %s\n", err, msgclass, msg, errmsg );
+ MPI_Error_string(err, errmsg, &len);
+
+ fprintf(stdout, "[0x%08x] %2d %s \tgives %s\n", err, msgclass, msg, errmsg);
}
diff --git a/test/mpi/errhan/errring.c b/test/mpi/errhan/errring.c
index 53d0050..2633143 100644
--- a/test/mpi/errhan/errring.c
+++ b/test/mpi/errhan/errring.c
@@ -8,21 +8,26 @@
#define MPIR_ERR_FATAL 1
#define MPIR_ERR_RECOVERABLE 0
-int MPIR_Err_create_code(int, int, char *, int, int, const char [], const char [], ...);
+int MPIR_Err_create_code(int, int, char *, int, int, const char[], const char[], ...);
void MPIR_Err_print_stack(FILE * fp, int errcode);
int main(int argc, char **argv)
{
int err;
-
- MPI_Init( 0, 0 );
- err = MPIR_Err_create_code(MPI_ERR_INTERN, MPIR_ERR_RECOVERABLE, "main", __LINE__, MPI_ERR_UNKNOWN, "**buffer", 0);
- err = MPIR_Err_create_code(err, MPIR_ERR_RECOVERABLE, "main", __LINE__, MPI_ERR_UNKNOWN, "**count", 0);
- err = MPIR_Err_create_code(err, MPIR_ERR_RECOVERABLE, "main", __LINE__, MPI_ERR_UNKNOWN, "**dtype", 0);
+ MPI_Init(0, 0);
+
+ err =
+ MPIR_Err_create_code(MPI_ERR_INTERN, MPIR_ERR_RECOVERABLE, "main", __LINE__,
+ MPI_ERR_UNKNOWN, "**buffer", 0);
+ err =
+ MPIR_Err_create_code(err, MPIR_ERR_RECOVERABLE, "main", __LINE__, MPI_ERR_UNKNOWN,
+ "**count", 0);
+ err =
+ MPIR_Err_create_code(err, MPIR_ERR_RECOVERABLE, "main", __LINE__, MPI_ERR_UNKNOWN,
+ "**dtype", 0);
MPIR_Err_print_stack(stdout, err);
-
+
MPI_Finalize();
return 0;
}
-
diff --git a/test/mpi/errhan/errstring.c b/test/mpi/errhan/errstring.c
index 2b5b979..4bc4cb3 100644
--- a/test/mpi/errhan/errstring.c
+++ b/test/mpi/errhan/errstring.c
@@ -6,15 +6,15 @@
#include "mpi.h"
#include <stdio.h>
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- char msg[MPI_MAX_ERROR_STRING+1];
+ char msg[MPI_MAX_ERROR_STRING + 1];
int i, len;
- MPI_Init(0,0);
- for (i=0; i<54; i++) {
- MPI_Error_string( i, msg, &len );
- printf( "msg for %d is %s\n", i, msg );
+ MPI_Init(0, 0);
+ for (i = 0; i < 54; i++) {
+ MPI_Error_string(i, msg, &len);
+ printf("msg for %d is %s\n", i, msg);
}
MPI_Finalize();
diff --git a/test/mpi/errhan/errstring2.c b/test/mpi/errhan/errstring2.c
index 5e9761c..f63db76 100644
--- a/test/mpi/errhan/errstring2.c
+++ b/test/mpi/errhan/errstring2.c
@@ -5,16 +5,16 @@
int main(int argc, char *argv[])
{
int errorclass;
- char errorstring[MPI_MAX_ERROR_STRING] = {64,0};
+ char errorstring[MPI_MAX_ERROR_STRING] = { 64, 0 };
int slen;
MPI_Init(&argc, &argv);
MPI_Add_error_class(&errorclass);
MPI_Error_string(errorclass, errorstring, &slen);
if (strncmp(errorstring, "", 1)) {
- fprintf(stderr, "errorclass:%d errorstring:'%s' len:%d\n", errorclass,
- errorstring, slen);
- } else {
- printf(" No Errors\n");
+ fprintf(stderr, "errorclass:%d errorstring:'%s' len:%d\n", errorclass, errorstring, slen);
+ }
+ else {
+ printf(" No Errors\n");
}
MPI_Finalize();
return 0;
diff --git a/test/mpi/errhan/predef_eh.c b/test/mpi/errhan/predef_eh.c
index c467411..2bb0feb 100644
--- a/test/mpi/errhan/predef_eh.c
+++ b/test/mpi/errhan/predef_eh.c
@@ -14,25 +14,24 @@
* communicators does not cause a problem at finalize time. Regression
* test for ticket #1591 */
-void errf(MPI_Comm* comm, int* ec)
+void errf(MPI_Comm * comm, int *ec)
{
/* do nothing */
}
-int main (int argc, char **argv)
+int main(int argc, char **argv)
{
MPI_Errhandler errh;
int wrank;
- MPI_Init (&argc, &argv);
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
- MPI_Comm_create_errhandler((MPI_Comm_errhandler_function*)errf, &errh);
+ MPI_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
+ MPI_Comm_create_errhandler((MPI_Comm_errhandler_function *) errf, &errh);
MPI_Comm_set_errhandler(MPI_COMM_WORLD, errh);
MPI_Comm_set_errhandler(MPI_COMM_SELF, errh);
MPI_Errhandler_free(&errh);
MPI_Finalize();
/* Test harness requirement is that only one process write No Errors */
- if (wrank == 0)
- printf(" No Errors\n");
+ if (wrank == 0)
+ printf(" No Errors\n");
return 0;
}
-
diff --git a/test/mpi/errors/attr/keyvalmis.c b/test/mpi/errors/attr/keyvalmis.c
index 8c22a1d..3553383 100644
--- a/test/mpi/errors/attr/keyvalmis.c
+++ b/test/mpi/errors/attr/keyvalmis.c
@@ -7,145 +7,138 @@
#include "mpi.h"
#include "mpitest.h"
-/*
+/*
* Test for detecting that a Keyval created for one MPI Object cannot be used
- * to set an attribute on a different type of object
+ * to set an attribute on a different type of object
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
- int comm_keyval, win_keyval, type_keyval;
- int comm_aval;
- int err, errs = 0;
- int buf, flag;
- MPI_Win win;
- void *rval;
+ int comm_keyval, win_keyval, type_keyval;
+ int comm_aval;
+ int err, errs = 0;
+ int buf, flag;
+ MPI_Win win;
+ void *rval;
MPI_Datatype dtype;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Comm_create_keyval( MPI_COMM_NULL_COPY_FN,
- MPI_COMM_NULL_DELETE_FN,
- &comm_keyval, 0 );
- MPI_Win_create_keyval( MPI_WIN_NULL_COPY_FN,
- MPI_WIN_NULL_DELETE_FN,
- &win_keyval, 0 );
- MPI_Type_create_keyval( MPI_TYPE_NULL_COPY_FN,
- MPI_TYPE_NULL_DELETE_FN,
- &type_keyval, 0 );
- MPI_Type_contiguous( 4, MPI_DOUBLE, &dtype );
- MPI_Win_create( &buf, sizeof(int), sizeof(int), MPI_INFO_NULL,
- MPI_COMM_WORLD, &win );
+ MPI_Comm_create_keyval(MPI_COMM_NULL_COPY_FN, MPI_COMM_NULL_DELETE_FN, &comm_keyval, 0);
+ MPI_Win_create_keyval(MPI_WIN_NULL_COPY_FN, MPI_WIN_NULL_DELETE_FN, &win_keyval, 0);
+ MPI_Type_create_keyval(MPI_TYPE_NULL_COPY_FN, MPI_TYPE_NULL_DELETE_FN, &type_keyval, 0);
+ MPI_Type_contiguous(4, MPI_DOUBLE, &dtype);
+ MPI_Win_create(&buf, sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win);
- MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
- err = MPI_Comm_set_attr( MPI_COMM_WORLD, win_keyval, &comm_aval );
+ err = MPI_Comm_set_attr(MPI_COMM_WORLD, win_keyval, &comm_aval);
if (err == MPI_SUCCESS) {
- errs++;
- fprintf( stderr, "Comm_set_attr accepted win keyval\n" );
+ errs++;
+ fprintf(stderr, "Comm_set_attr accepted win keyval\n");
}
- err = MPI_Comm_set_attr( MPI_COMM_WORLD, type_keyval, &comm_aval );
+ err = MPI_Comm_set_attr(MPI_COMM_WORLD, type_keyval, &comm_aval);
if (err == MPI_SUCCESS) {
- errs++;
- fprintf( stderr, "Comm_set_attr accepted type keyval\n" );
+ errs++;
+ fprintf(stderr, "Comm_set_attr accepted type keyval\n");
}
- err = MPI_Type_set_attr( dtype, win_keyval, &comm_aval );
+ err = MPI_Type_set_attr(dtype, win_keyval, &comm_aval);
if (err == MPI_SUCCESS) {
- errs++;
- fprintf( stderr, "Type_set_attr accepted win keyval\n" );
+ errs++;
+ fprintf(stderr, "Type_set_attr accepted win keyval\n");
}
- err = MPI_Type_set_attr( dtype, comm_keyval, &comm_aval );
+ err = MPI_Type_set_attr(dtype, comm_keyval, &comm_aval);
if (err == MPI_SUCCESS) {
- errs++;
- fprintf( stderr, "Comm_set_attr accepted type keyval\n" );
+ errs++;
+ fprintf(stderr, "Comm_set_attr accepted type keyval\n");
}
- err = MPI_Win_set_attr( win, comm_keyval, &comm_aval );
+ err = MPI_Win_set_attr(win, comm_keyval, &comm_aval);
if (err == MPI_SUCCESS) {
- errs++;
- fprintf( stderr, "Win_set_attr accepted comm keyval\n" );
+ errs++;
+ fprintf(stderr, "Win_set_attr accepted comm keyval\n");
}
- err = MPI_Win_set_attr( win, type_keyval, &comm_aval );
+ err = MPI_Win_set_attr(win, type_keyval, &comm_aval);
if (err == MPI_SUCCESS) {
- errs++;
- fprintf( stderr, "Win_set_attr accepted type keyval\n" );
+ errs++;
+ fprintf(stderr, "Win_set_attr accepted type keyval\n");
}
- err = MPI_Comm_get_attr( MPI_COMM_WORLD, win_keyval, &rval, &flag );
+ err = MPI_Comm_get_attr(MPI_COMM_WORLD, win_keyval, &rval, &flag);
if (err == MPI_SUCCESS) {
- errs++;
- fprintf( stderr, "Comm_get_attr accepted win keyval\n" );
+ errs++;
+ fprintf(stderr, "Comm_get_attr accepted win keyval\n");
}
- err = MPI_Comm_get_attr( MPI_COMM_WORLD, type_keyval, &rval, &flag );
+ err = MPI_Comm_get_attr(MPI_COMM_WORLD, type_keyval, &rval, &flag);
if (err == MPI_SUCCESS) {
- errs++;
- fprintf( stderr, "Comm_get_attr accepted type keyval\n" );
+ errs++;
+ fprintf(stderr, "Comm_get_attr accepted type keyval\n");
}
- err = MPI_Comm_free_keyval( &win_keyval );
+ err = MPI_Comm_free_keyval(&win_keyval);
if (err == MPI_SUCCESS) {
- errs++;
- fprintf( stderr, "Comm_free_keyval accepted win keyval\n" );
+ errs++;
+ fprintf(stderr, "Comm_free_keyval accepted win keyval\n");
}
- err = MPI_Comm_free_keyval( &type_keyval );
+ err = MPI_Comm_free_keyval(&type_keyval);
if (err == MPI_SUCCESS) {
- errs++;
- fprintf( stderr, "Comm_free_keyval accepted type keyval\n" );
+ errs++;
+ fprintf(stderr, "Comm_free_keyval accepted type keyval\n");
}
if (win_keyval != MPI_KEYVAL_INVALID) {
- err = MPI_Type_free_keyval( &win_keyval );
- if (err == MPI_SUCCESS) {
- errs++;
- fprintf( stderr, "Type_free_keyval accepted win keyval\n" );
- }
+ err = MPI_Type_free_keyval(&win_keyval);
+ if (err == MPI_SUCCESS) {
+ errs++;
+ fprintf(stderr, "Type_free_keyval accepted win keyval\n");
+ }
}
- err = MPI_Type_free_keyval( &comm_keyval );
+ err = MPI_Type_free_keyval(&comm_keyval);
if (err == MPI_SUCCESS) {
- errs++;
- fprintf( stderr, "Type_free_keyval accepted comm keyval\n" );
+ errs++;
+ fprintf(stderr, "Type_free_keyval accepted comm keyval\n");
}
if (type_keyval != MPI_KEYVAL_INVALID) {
- err = MPI_Win_free_keyval( &type_keyval );
- if (err == MPI_SUCCESS) {
- errs++;
- fprintf( stderr, "Win_free_keyval accepted type keyval\n" );
- }
+ err = MPI_Win_free_keyval(&type_keyval);
+ if (err == MPI_SUCCESS) {
+ errs++;
+ fprintf(stderr, "Win_free_keyval accepted type keyval\n");
+ }
}
if (comm_keyval != MPI_KEYVAL_INVALID) {
- err = MPI_Win_free_keyval( &comm_keyval );
- if (err == MPI_SUCCESS) {
- errs++;
- fprintf( stderr, "Win_free_keyval accepted comm keyval\n" );
- }
+ err = MPI_Win_free_keyval(&comm_keyval);
+ if (err == MPI_SUCCESS) {
+ errs++;
+ fprintf(stderr, "Win_free_keyval accepted comm keyval\n");
+ }
}
/* Now, free for real */
if (comm_keyval != MPI_KEYVAL_INVALID) {
- err = MPI_Comm_free_keyval( &comm_keyval );
- if (err != MPI_SUCCESS) {
- errs++;
- fprintf( stderr, "Could not free comm keyval\n" );
- }
+ err = MPI_Comm_free_keyval(&comm_keyval);
+ if (err != MPI_SUCCESS) {
+ errs++;
+ fprintf(stderr, "Could not free comm keyval\n");
+ }
}
if (type_keyval != MPI_KEYVAL_INVALID) {
- err = MPI_Type_free_keyval( &type_keyval );
- if (err != MPI_SUCCESS) {
- errs++;
- fprintf( stderr, "Could not free type keyval\n" );
- }
+ err = MPI_Type_free_keyval(&type_keyval);
+ if (err != MPI_SUCCESS) {
+ errs++;
+ fprintf(stderr, "Could not free type keyval\n");
+ }
}
if (win_keyval != MPI_KEYVAL_INVALID) {
- err = MPI_Win_free_keyval( &win_keyval );
- if (err != MPI_SUCCESS) {
- errs++;
- fprintf( stderr, "Could not free win keyval\n" );
- }
+ err = MPI_Win_free_keyval(&win_keyval);
+ if (err != MPI_SUCCESS) {
+ errs++;
+ fprintf(stderr, "Could not free win keyval\n");
+ }
}
- MPI_Win_free( &win );
- MPI_Type_free( &dtype );
+ MPI_Win_free(&win);
+ MPI_Type_free(&dtype);
+
-
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
diff --git a/test/mpi/errors/basic/debabort.c b/test/mpi/errors/basic/debabort.c
index c156a0f..610ec52 100644
--- a/test/mpi/errors/basic/debabort.c
+++ b/test/mpi/errors/basic/debabort.c
@@ -6,17 +6,17 @@
#include "mpi.h"
#include <stdio.h>
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
- int rank;
- double v1[2], v2[2];
+ int rank;
+ double v1[2], v2[2];
- MPI_Init( &argc, &argv );
+ MPI_Init(&argc, &argv);
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- /* Clearly incorrect program */
- MPI_Allreduce( v1, v2, rank ? 1 : 2, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD );
- MPI_Finalize();
- return 0;
+ /* Clearly incorrect program */
+ MPI_Allreduce(v1, v2, rank ? 1 : 2, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
+ MPI_Finalize();
+ return 0;
}
diff --git a/test/mpi/errors/basic/lefthandles.c b/test/mpi/errors/basic/lefthandles.c
index bed20eb..89e963d 100644
--- a/test/mpi/errors/basic/lefthandles.c
+++ b/test/mpi/errors/basic/lefthandles.c
@@ -5,24 +5,24 @@
*/
#include <mpi.h>
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
- MPI_Comm comm;
- MPI_Datatype ntype;
- int i;
+ MPI_Comm comm;
+ MPI_Datatype ntype;
+ int i;
- MPI_Init( &argc, &argv );
+ MPI_Init(&argc, &argv);
- for (i=0; i<20; i++) {
- MPI_Comm_dup( MPI_COMM_WORLD, &comm );
- }
+ for (i = 0; i < 20; i++) {
+ MPI_Comm_dup(MPI_COMM_WORLD, &comm);
+ }
- MPI_Type_contiguous( 27, MPI_INT, &ntype );
- MPI_Type_contiguous( 27, MPI_INT, &ntype );
- MPI_Type_contiguous( 27, MPI_INT, &ntype );
- MPI_Type_contiguous( 27, MPI_INT, &ntype );
- MPI_Type_contiguous( 27, MPI_INT, &ntype );
- MPI_Finalize();
+ MPI_Type_contiguous(27, MPI_INT, &ntype);
+ MPI_Type_contiguous(27, MPI_INT, &ntype);
+ MPI_Type_contiguous(27, MPI_INT, &ntype);
+ MPI_Type_contiguous(27, MPI_INT, &ntype);
+ MPI_Type_contiguous(27, MPI_INT, &ntype);
+ MPI_Finalize();
- return 0;
+ return 0;
}
diff --git a/test/mpi/errors/coll/bcastlength.c b/test/mpi/errors/coll/bcastlength.c
index ef1b17c..98a7821 100644
--- a/test/mpi/errors/coll/bcastlength.c
+++ b/test/mpi/errors/coll/bcastlength.c
@@ -7,74 +7,72 @@
#include "mpi.h"
#include "mpitest.h"
-/* Very simple test that Bcast handled mismatched lengths (while not a
- common user error, we've seen it several times, so good handling of
- this helps to reduce bug reports)
+/* Very simple test that Bcast handled mismatched lengths (while not a
+ common user error, we've seen it several times, so good handling of
+ this helps to reduce bug reports)
*/
int verbose = 0;
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
- int buf[10], ierr, errs=0;
+ int buf[10], ierr, errs = 0;
int rank;
- char str[MPI_MAX_ERROR_STRING+1];
- int slen;
+ char str[MPI_MAX_ERROR_STRING + 1];
+ int slen;
+
+ MTest_Init(&argc, &argv);
+
+ MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- MTest_Init( &argc, &argv );
-
- MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
-
if (rank == 0) {
- ierr = MPI_Bcast( buf, 1, MPI_INT, 0, MPI_COMM_WORLD );
+ ierr = MPI_Bcast(buf, 1, MPI_INT, 0, MPI_COMM_WORLD);
}
else {
- ierr = MPI_Bcast( buf, 10, MPI_INT, 0, MPI_COMM_WORLD );
+ ierr = MPI_Bcast(buf, 10, MPI_INT, 0, MPI_COMM_WORLD);
}
if (ierr == MPI_SUCCESS) {
- if (rank != 0) {
- /* The root process may not detect that a too-long buffer
- was provided by the non-root processes, but those processes
- should detect this. */
- errs ++;
- printf( "Did not detect mismatched length (long) on process %d\n",
- rank );
- }
+ if (rank != 0) {
+ /* The root process may not detect that a too-long buffer
+ * was provided by the non-root processes, but those processes
+ * should detect this. */
+ errs++;
+ printf("Did not detect mismatched length (long) on process %d\n", rank);
+ }
}
else {
- if (verbose) {
- MPI_Error_string( ierr, str, &slen );
- printf( "Found expected error; message is: %s\n", str );
- }
+ if (verbose) {
+ MPI_Error_string(ierr, str, &slen);
+ printf("Found expected error; message is: %s\n", str);
+ }
}
if (rank == 0) {
- ierr = MPI_Bcast( buf, 10, MPI_INT, 0, MPI_COMM_WORLD );
+ ierr = MPI_Bcast(buf, 10, MPI_INT, 0, MPI_COMM_WORLD);
}
else {
- ierr = MPI_Bcast( buf, 1, MPI_INT, 0, MPI_COMM_WORLD );
+ ierr = MPI_Bcast(buf, 1, MPI_INT, 0, MPI_COMM_WORLD);
}
if (ierr == MPI_SUCCESS) {
- if (rank != 0) {
- /* The root process may not detect that a too-short buffer
- was provided by the non-root processes, but those processes
- should detect this. */
- errs ++;
- printf( "Did not detect mismatched length (short) on process %d\n",
- rank );
- }
+ if (rank != 0) {
+ /* The root process may not detect that a too-short buffer
+ * was provided by the non-root processes, but those processes
+ * should detect this. */
+ errs++;
+ printf("Did not detect mismatched length (short) on process %d\n", rank);
+ }
}
else {
- if (verbose) {
- MPI_Error_string( ierr, str, &slen );
- printf( "Found expected error; message is: %s\n", str );
- }
+ if (verbose) {
+ MPI_Error_string(ierr, str, &slen);
+ printf("Found expected error; message is: %s\n", str);
+ }
}
- MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL );
+ MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL);
- MTest_Finalize( errs );
- MPI_Finalize( );
+ MTest_Finalize(errs);
+ MPI_Finalize();
return 0;
}
diff --git a/test/mpi/errors/coll/noalias.c b/test/mpi/errors/coll/noalias.c
index 4b8bdf1..747ce47 100644
--- a/test/mpi/errors/coll/noalias.c
+++ b/test/mpi/errors/coll/noalias.c
@@ -8,19 +8,19 @@
#include "mpi.h"
#include "mpitest.h"
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
- int err, errs = 0, len, i;
- int rank = -1, size = -1;
- int *buf;
- int *recvbuf;
- char msg[MPI_MAX_ERROR_STRING];
+ int err, errs = 0, len, i;
+ int rank = -1, size = -1;
+ int *buf;
+ int *recvbuf;
+ char msg[MPI_MAX_ERROR_STRING];
- MTest_Init( &argc, &argv );
- MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ MTest_Init(&argc, &argv);
+ MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
buf = malloc(size * sizeof(int));
recvbuf = malloc(size * sizeof(int));
@@ -29,16 +29,16 @@ int main( int argc, char *argv[] )
recvbuf[i] = -1;
}
- err = MPI_Allreduce( buf, buf, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
+ err = MPI_Allreduce(buf, buf, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
if (!err) {
- errs++;
- if (rank == 0)
- printf( "Did not detect aliased arguments in MPI_Allreduce\n" );
+ errs++;
+ if (rank == 0)
+ printf("Did not detect aliased arguments in MPI_Allreduce\n");
}
else {
- /* Check that we can get a message for this error */
- /* (This works if it does not SEGV or hang) */
- MPI_Error_string( err, msg, &len );
+ /* Check that we can get a message for this error */
+ /* (This works if it does not SEGV or hang) */
+ MPI_Error_string(err, msg, &len);
}
/* This case is a bit stranger than the MPI_Allreduce case above, because
@@ -50,22 +50,22 @@ int main( int argc, char *argv[] )
* do our best to carry on in this case by posting a second non-erroneous
* MPI_Reduce on any process that got back an error from the intentionally
* erroneous MPI_Reduce. */
- err = MPI_Reduce( buf, ((rank == 0) ? buf : NULL), 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD );
+ err = MPI_Reduce(buf, ((rank == 0) ? buf : NULL), 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
if (rank == 0) {
if (!err) {
errs++;
if (rank == 0)
- printf( "Did not detect aliased arguments in MPI_Reduce\n" );
+ printf("Did not detect aliased arguments in MPI_Reduce\n");
}
else {
/* Check that we can get a message for this error */
/* (This works if it does not SEGV or hang) */
- MPI_Error_string( err, msg, &len );
+ MPI_Error_string(err, msg, &len);
}
}
if (err) {
/* post a correct MPI_Reduce on any processes that got an error earlier */
- err = MPI_Reduce( buf, recvbuf, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD );
+ err = MPI_Reduce(buf, recvbuf, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
if (err) {
errs++;
printf("make-up reduce failed on rank %d\n", rank);
@@ -74,10 +74,13 @@ int main( int argc, char *argv[] )
/* this case should _not_ trigger an error, thanks to Kenneth Inghram for
* reporting this bug in MPICH */
- err = MPI_Reduce( ((rank == 0) ? MPI_IN_PLACE : buf), buf, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD );
+ err =
+ MPI_Reduce(((rank == 0) ? MPI_IN_PLACE : buf), buf, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
if (err) {
errs++;
- printf("Incorrectly reported aliased arguments in MPI_Reduce with MPI_IN_PLACE on rank %d\n", rank);
+ printf
+ ("Incorrectly reported aliased arguments in MPI_Reduce with MPI_IN_PLACE on rank %d\n",
+ rank);
MPI_Abort(MPI_COMM_WORLD, 1);
printf("FAILED TO MPI_ABORT!!!\n");
}
@@ -87,12 +90,12 @@ int main( int argc, char *argv[] )
if (rank == 0) {
if (!err) {
errs++;
- printf( "Did not detect aliased arguments in MPI_Gather\n" );
+ printf("Did not detect aliased arguments in MPI_Gather\n");
}
else {
/* Check that we can get a message for this error */
/* (This works if it does not SEGV or hang) */
- MPI_Error_string( err, msg, &len );
+ MPI_Error_string(err, msg, &len);
}
}
if (err) {
@@ -109,12 +112,12 @@ int main( int argc, char *argv[] )
if (rank == 0) {
if (!err) {
errs++;
- printf( "Did not detect aliased arguments in MPI_Scatter\n" );
+ printf("Did not detect aliased arguments in MPI_Scatter\n");
}
else {
/* Check that we can get a message for this error */
/* (This works if it does not SEGV or hang) */
- MPI_Error_string( err, msg, &len );
+ MPI_Error_string(err, msg, &len);
}
}
if (err) {
@@ -129,7 +132,7 @@ int main( int argc, char *argv[] )
free(recvbuf);
free(buf);
- MTest_Finalize( errs );
- MPI_Finalize( );
+ MTest_Finalize(errs);
+ MPI_Finalize();
return 0;
}
diff --git a/test/mpi/errors/coll/noalias2.c b/test/mpi/errors/coll/noalias2.c
index b651e65..aac5c3c 100644
--- a/test/mpi/errors/coll/noalias2.c
+++ b/test/mpi/errors/coll/noalias2.c
@@ -52,99 +52,98 @@ int main(int argc, char **argv)
/* enough space for every process to contribute at least NUM_INTS ints to any
* collective operation */
- sbuf = malloc(NUM_INTS*size*sizeof(int));
+ sbuf = malloc(NUM_INTS * size * sizeof(int));
my_assert(sbuf);
- rbuf = malloc(NUM_INTS*size*sizeof(int));
+ rbuf = malloc(NUM_INTS * size * sizeof(int));
my_assert(rbuf);
- scounts = malloc(size*sizeof(int));
+ scounts = malloc(size * sizeof(int));
my_assert(scounts);
- rcounts = malloc(size*sizeof(int));
+ rcounts = malloc(size * sizeof(int));
my_assert(rcounts);
- sdispls = malloc(size*sizeof(int));
+ sdispls = malloc(size * sizeof(int));
my_assert(sdispls);
- rdispls = malloc(size*sizeof(int));
+ rdispls = malloc(size * sizeof(int));
my_assert(rdispls);
- types = malloc(size*sizeof(int));
+ types = malloc(size * sizeof(int));
my_assert(types);
for (i = 0; i < size; ++i) {
- sbuf[2*i] = i;
- sbuf[2*i+1] = i;
- rbuf[2*i] = i;
- rbuf[2*i+1] = i;
- scounts[i] = NUM_INTS;
- rcounts[i] = NUM_INTS;
- sdispls[i] = i * NUM_INTS;
- rdispls[i] = i * NUM_INTS;
- types[i] = MPI_INT;
+ sbuf[2 * i] = i;
+ sbuf[2 * i + 1] = i;
+ rbuf[2 * i] = i;
+ rbuf[2 * i + 1] = i;
+ scounts[i] = NUM_INTS;
+ rcounts[i] = NUM_INTS;
+ sdispls[i] = i * NUM_INTS;
+ rdispls[i] = i * NUM_INTS;
+ types[i] = MPI_INT;
}
if (rank == 0 && MPI_SUCCESS ==
- MPI_Gather(sbuf, NUM_INTS, MPI_INT, sbuf, NUM_INTS, MPI_INT, 0, comm))
+ MPI_Gather(sbuf, NUM_INTS, MPI_INT, sbuf, NUM_INTS, MPI_INT, 0, comm))
errs++;
if (rank == 0 && MPI_SUCCESS ==
- MPI_Gatherv(sbuf, NUM_INTS, MPI_INT, sbuf, rcounts, rdispls, MPI_INT, 0, comm))
+ MPI_Gatherv(sbuf, NUM_INTS, MPI_INT, sbuf, rcounts, rdispls, MPI_INT, 0, comm))
errs++;
if (rank == 0 && MPI_SUCCESS ==
- MPI_Scatter(sbuf, NUM_INTS, MPI_INT, sbuf, NUM_INTS, MPI_INT, 0, comm))
+ MPI_Scatter(sbuf, NUM_INTS, MPI_INT, sbuf, NUM_INTS, MPI_INT, 0, comm))
errs++;
if (rank == 0 && MPI_SUCCESS ==
- MPI_Scatterv(sbuf, scounts, sdispls, MPI_INT, sbuf, NUM_INTS, MPI_INT, 0, comm))
+ MPI_Scatterv(sbuf, scounts, sdispls, MPI_INT, sbuf, NUM_INTS, MPI_INT, 0, comm))
errs++;
- if (MPI_SUCCESS ==
- MPI_Allgather(&sbuf[rank], 1, MPI_INT, sbuf, 1, MPI_INT, comm))
+ if (MPI_SUCCESS == MPI_Allgather(&sbuf[rank], 1, MPI_INT, sbuf, 1, MPI_INT, comm))
errs++;
if (MPI_SUCCESS ==
- MPI_Allgatherv(&sbuf[rank * rcounts[rank]], rcounts[rank], MPI_INT, sbuf, rcounts, rdispls, MPI_INT, comm))
+ MPI_Allgatherv(&sbuf[rank * rcounts[rank]], rcounts[rank], MPI_INT, sbuf, rcounts, rdispls,
+ MPI_INT, comm))
errs++;
- if (MPI_SUCCESS ==
- MPI_Alltoall(sbuf, NUM_INTS, MPI_INT, sbuf, NUM_INTS, MPI_INT, comm))
+ if (MPI_SUCCESS == MPI_Alltoall(sbuf, NUM_INTS, MPI_INT, sbuf, NUM_INTS, MPI_INT, comm))
errs++;
if (MPI_SUCCESS ==
- MPI_Alltoallv(sbuf, scounts, sdispls, MPI_INT, sbuf, scounts, sdispls, MPI_INT, comm))
+ MPI_Alltoallv(sbuf, scounts, sdispls, MPI_INT, sbuf, scounts, sdispls, MPI_INT, comm))
errs++;
if (MPI_SUCCESS ==
- MPI_Alltoallw(sbuf, scounts, sdispls, types, sbuf, scounts, sdispls, types, comm))
+ MPI_Alltoallw(sbuf, scounts, sdispls, types, sbuf, scounts, sdispls, types, comm))
errs++;
- if (rank == 0 && MPI_SUCCESS ==
- MPI_Reduce(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, 0, comm))
+ if (rank == 0 && MPI_SUCCESS == MPI_Reduce(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, 0, comm))
errs++;
- if (MPI_SUCCESS ==
- MPI_Allreduce(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm))
+ if (MPI_SUCCESS == MPI_Allreduce(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm))
errs++;
- if (MPI_SUCCESS ==
- MPI_Reduce_scatter(sbuf, sbuf, rcounts, MPI_INT, MPI_SUM, comm))
+ if (MPI_SUCCESS == MPI_Reduce_scatter(sbuf, sbuf, rcounts, MPI_INT, MPI_SUM, comm))
errs++;
- if (MPI_SUCCESS ==
- MPI_Reduce_scatter_block(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm))
+ if (MPI_SUCCESS == MPI_Reduce_scatter_block(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm))
errs++;
- if (MPI_SUCCESS ==
- MPI_Scan(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm))
+ if (MPI_SUCCESS == MPI_Scan(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm))
errs++;
- if (MPI_SUCCESS ==
- MPI_Exscan(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm))
+ if (MPI_SUCCESS == MPI_Exscan(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm))
errs++;
- if (sbuf) free(sbuf);
- if (rbuf) free(rbuf);
- if (scounts) free(scounts);
- if (rcounts) free(rcounts);
- if (sdispls) free(sdispls);
- if (rdispls) free(rdispls);
+ if (sbuf)
+ free(sbuf);
+ if (rbuf)
+ free(rbuf);
+ if (scounts)
+ free(scounts);
+ if (rcounts)
+ free(rcounts);
+ if (sdispls)
+ free(sdispls);
+ if (rdispls)
+ free(rdispls);
if (rank == 0) {
if (errs)
@@ -155,4 +154,3 @@ int main(int argc, char **argv)
MPI_Finalize();
return 0;
}
-
diff --git a/test/mpi/errors/coll/noalias3.c b/test/mpi/errors/coll/noalias3.c
index 8cf7c25..caaf924 100644
--- a/test/mpi/errors/coll/noalias3.c
+++ b/test/mpi/errors/coll/noalias3.c
@@ -53,99 +53,101 @@ int main(int argc, char **argv)
/* enough space for every process to contribute at least NUM_INTS ints to any
* collective operation */
- sbuf = malloc(NUM_INTS*size*sizeof(int));
+ sbuf = malloc(NUM_INTS * size * sizeof(int));
my_assert(sbuf);
- rbuf = malloc(NUM_INTS*size*sizeof(int));
+ rbuf = malloc(NUM_INTS * size * sizeof(int));
my_assert(rbuf);
- scounts = malloc(size*sizeof(int));
+ scounts = malloc(size * sizeof(int));
my_assert(scounts);
- rcounts = malloc(size*sizeof(int));
+ rcounts = malloc(size * sizeof(int));
my_assert(rcounts);
- sdispls = malloc(size*sizeof(int));
+ sdispls = malloc(size * sizeof(int));
my_assert(sdispls);
- rdispls = malloc(size*sizeof(int));
+ rdispls = malloc(size * sizeof(int));
my_assert(rdispls);
- types = malloc(size*sizeof(int));
+ types = malloc(size * sizeof(int));
my_assert(types);
for (i = 0; i < size; ++i) {
- sbuf[2*i] = i;
- sbuf[2*i+1] = i;
- rbuf[2*i] = i;
- rbuf[2*i+1] = i;
- scounts[i] = NUM_INTS;
- rcounts[i] = NUM_INTS;
- sdispls[i] = i * NUM_INTS;
- rdispls[i] = i * NUM_INTS;
- types[i] = MPI_INT;
+ sbuf[2 * i] = i;
+ sbuf[2 * i + 1] = i;
+ rbuf[2 * i] = i;
+ rbuf[2 * i + 1] = i;
+ scounts[i] = NUM_INTS;
+ rcounts[i] = NUM_INTS;
+ sdispls[i] = i * NUM_INTS;
+ rdispls[i] = i * NUM_INTS;
+ types[i] = MPI_INT;
}
if (rank == 0 && MPI_SUCCESS ==
- MPI_Igather(sbuf, NUM_INTS, MPI_INT, sbuf, NUM_INTS, MPI_INT, 0, comm, &req))
+ MPI_Igather(sbuf, NUM_INTS, MPI_INT, sbuf, NUM_INTS, MPI_INT, 0, comm, &req))
errs++;
if (rank == 0 && MPI_SUCCESS ==
- MPI_Igatherv(sbuf, NUM_INTS, MPI_INT, sbuf, rcounts, rdispls, MPI_INT, 0, comm, &req))
+ MPI_Igatherv(sbuf, NUM_INTS, MPI_INT, sbuf, rcounts, rdispls, MPI_INT, 0, comm, &req))
errs++;
if (rank == 0 && MPI_SUCCESS ==
- MPI_Iscatter(sbuf, NUM_INTS, MPI_INT, sbuf, NUM_INTS, MPI_INT, 0, comm, &req))
+ MPI_Iscatter(sbuf, NUM_INTS, MPI_INT, sbuf, NUM_INTS, MPI_INT, 0, comm, &req))
errs++;
if (rank == 0 && MPI_SUCCESS ==
- MPI_Iscatterv(sbuf, scounts, sdispls, MPI_INT, sbuf, NUM_INTS, MPI_INT, 0, comm, &req))
+ MPI_Iscatterv(sbuf, scounts, sdispls, MPI_INT, sbuf, NUM_INTS, MPI_INT, 0, comm, &req))
errs++;
- if (MPI_SUCCESS ==
- MPI_Iallgather(&sbuf[rank], 1, MPI_INT, sbuf, 1, MPI_INT, comm, &req))
+ if (MPI_SUCCESS == MPI_Iallgather(&sbuf[rank], 1, MPI_INT, sbuf, 1, MPI_INT, comm, &req))
errs++;
if (MPI_SUCCESS ==
- MPI_Iallgatherv(&sbuf[rank * rcounts[rank]], rcounts[rank], MPI_INT, sbuf, rcounts, rdispls, MPI_INT, comm, &req))
+ MPI_Iallgatherv(&sbuf[rank * rcounts[rank]], rcounts[rank], MPI_INT, sbuf, rcounts, rdispls,
+ MPI_INT, comm, &req))
errs++;
- if (MPI_SUCCESS ==
- MPI_Ialltoall(sbuf, NUM_INTS, MPI_INT, sbuf, NUM_INTS, MPI_INT, comm, &req))
+ if (MPI_SUCCESS == MPI_Ialltoall(sbuf, NUM_INTS, MPI_INT, sbuf, NUM_INTS, MPI_INT, comm, &req))
errs++;
if (MPI_SUCCESS ==
- MPI_Ialltoallv(sbuf, scounts, sdispls, MPI_INT, sbuf, scounts, sdispls, MPI_INT, comm, &req))
+ MPI_Ialltoallv(sbuf, scounts, sdispls, MPI_INT, sbuf, scounts, sdispls, MPI_INT, comm,
+ &req))
errs++;
if (MPI_SUCCESS ==
- MPI_Ialltoallw(sbuf, scounts, sdispls, types, sbuf, scounts, sdispls, types, comm, &req))
+ MPI_Ialltoallw(sbuf, scounts, sdispls, types, sbuf, scounts, sdispls, types, comm, &req))
errs++;
if (rank == 0 && MPI_SUCCESS ==
- MPI_Ireduce(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, 0, comm, &req))
+ MPI_Ireduce(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, 0, comm, &req))
errs++;
- if (MPI_SUCCESS ==
- MPI_Iallreduce(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req))
+ if (MPI_SUCCESS == MPI_Iallreduce(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req))
errs++;
- if (MPI_SUCCESS ==
- MPI_Ireduce_scatter(sbuf, sbuf, rcounts, MPI_INT, MPI_SUM, comm, &req))
+ if (MPI_SUCCESS == MPI_Ireduce_scatter(sbuf, sbuf, rcounts, MPI_INT, MPI_SUM, comm, &req))
errs++;
if (MPI_SUCCESS ==
- MPI_Ireduce_scatter_block(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req))
+ MPI_Ireduce_scatter_block(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req))
errs++;
- if (MPI_SUCCESS ==
- MPI_Iscan(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req))
+ if (MPI_SUCCESS == MPI_Iscan(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req))
errs++;
- if (MPI_SUCCESS ==
- MPI_Iexscan(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req))
+ if (MPI_SUCCESS == MPI_Iexscan(sbuf, sbuf, NUM_INTS, MPI_INT, MPI_SUM, comm, &req))
errs++;
- if (sbuf) free(sbuf);
- if (rbuf) free(rbuf);
- if (scounts) free(scounts);
- if (rcounts) free(rcounts);
- if (sdispls) free(sdispls);
- if (rdispls) free(rdispls);
+ if (sbuf)
+ free(sbuf);
+ if (rbuf)
+ free(rbuf);
+ if (scounts)
+ free(scounts);
+ if (rcounts)
+ free(rcounts);
+ if (sdispls)
+ free(sdispls);
+ if (rdispls)
+ free(rdispls);
if (rank == 0) {
if (errs)
@@ -156,4 +158,3 @@ int main(int argc, char **argv)
MPI_Finalize();
return 0;
}
-
diff --git a/test/mpi/errors/coll/reduce_local.c b/test/mpi/errors/coll/reduce_local.c
index 0249eb4..6c56efc 100644
--- a/test/mpi/errors/coll/reduce_local.c
+++ b/test/mpi/errors/coll/reduce_local.c
@@ -18,11 +18,11 @@
int main(int argc, char *argv[])
{
- int err, errs = 0, len, i, errclass;
- int rank = -1, size = -1;
- int *buf;
- int *recvbuf;
- char msg[MPI_MAX_ERROR_STRING];
+ int err, errs = 0, len, i, errclass;
+ int rank = -1, size = -1;
+ int *buf;
+ int *recvbuf;
+ char msg[MPI_MAX_ERROR_STRING];
MTest_Init(&argc, &argv);
MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
diff --git a/test/mpi/errors/coll/rerr.c b/test/mpi/errors/coll/rerr.c
index 65c9daa..1daa6bc 100644
--- a/test/mpi/errors/coll/rerr.c
+++ b/test/mpi/errors/coll/rerr.c
@@ -12,31 +12,31 @@
int verbose = 0;
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
- int a, b, ierr, errs=0;
- char str[MPI_MAX_ERROR_STRING+1];
- int slen;
-
- MTest_Init( &argc, &argv );
-
- MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
-
- ierr = MPI_Reduce( &a, &b, 1, MPI_BYTE, MPI_MAX, 0, MPI_COMM_WORLD );
+ int a, b, ierr, errs = 0;
+ char str[MPI_MAX_ERROR_STRING + 1];
+ int slen;
+
+ MTest_Init(&argc, &argv);
+
+ MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+
+ ierr = MPI_Reduce(&a, &b, 1, MPI_BYTE, MPI_MAX, 0, MPI_COMM_WORLD);
if (ierr == MPI_SUCCESS) {
- errs ++;
- printf( "Did not detect invalid type/op pair (byte,max) in Allreduce\n" );
+ errs++;
+ printf("Did not detect invalid type/op pair (byte,max) in Allreduce\n");
}
else {
- if (verbose) {
- MPI_Error_string( ierr, str, &slen );
- printf( "Found expected error; message is: %s\n", str );
- }
+ if (verbose) {
+ MPI_Error_string(ierr, str, &slen);
+ printf("Found expected error; message is: %s\n", str);
+ }
}
- MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL );
+ MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL);
- MTest_Finalize( errs );
- MPI_Finalize( );
+ MTest_Finalize(errs);
+ MPI_Finalize();
return 0;
}
diff --git a/test/mpi/errors/comm/ccreate1.c b/test/mpi/errors/comm/ccreate1.c
index b081a8d..5d3d28e 100644
--- a/test/mpi/errors/comm/ccreate1.c
+++ b/test/mpi/errors/comm/ccreate1.c
@@ -8,129 +8,130 @@
#include <string.h>
#include "mpitest.h"
-/* Check that Comm_create detects the case where the group is not a subset of
+/* Check that Comm_create detects the case where the group is not a subset of
the group of the input communicator */
-void abortMsg( const char *, int );
+void abortMsg(const char *, int);
-void abortMsg( const char *str, int code )
+void abortMsg(const char *str, int code)
{
char msg[MPI_MAX_ERROR_STRING];
int class, resultLen;
- MPI_Error_class( code, &class );
- MPI_Error_string( code, msg, &resultLen );
- fprintf( stderr, "%s: errcode = %d, class = %d, msg = %s\n",
- str, code, class, msg );
- MPI_Abort( MPI_COMM_WORLD, code );
+ MPI_Error_class(code, &class);
+ MPI_Error_string(code, msg, &resultLen);
+ fprintf(stderr, "%s: errcode = %d, class = %d, msg = %s\n", str, code, class, msg);
+ MPI_Abort(MPI_COMM_WORLD, code);
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
- MPI_Comm evencomm, lowcomm, newcomm;
- int wrank, wsize, gsize, err, errs = 0;
- int ranges[1][3], mygrank;
+ MPI_Comm evencomm, lowcomm, newcomm;
+ int wrank, wsize, gsize, err, errs = 0;
+ int ranges[1][3], mygrank;
MPI_Group wGroup, godd, ghigh, geven;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
- MPI_Comm_size( MPI_COMM_WORLD, &wsize );
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
+ MPI_Comm_size(MPI_COMM_WORLD, &wsize);
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
/* Create some communicators */
- MPI_Comm_split( MPI_COMM_WORLD, wrank % 2, wrank, &evencomm );
- MPI_Comm_split( MPI_COMM_WORLD, wrank < wsize/2, wsize-wrank, &lowcomm );
- MPI_Comm_set_errhandler( evencomm, MPI_ERRORS_RETURN );
- MPI_Comm_set_errhandler( lowcomm, MPI_ERRORS_RETURN );
+ MPI_Comm_split(MPI_COMM_WORLD, wrank % 2, wrank, &evencomm);
+ MPI_Comm_split(MPI_COMM_WORLD, wrank < wsize / 2, wsize - wrank, &lowcomm);
+ MPI_Comm_set_errhandler(evencomm, MPI_ERRORS_RETURN);
+ MPI_Comm_set_errhandler(lowcomm, MPI_ERRORS_RETURN);
/* Create some groups */
- MPI_Comm_group( MPI_COMM_WORLD, &wGroup );
+ MPI_Comm_group(MPI_COMM_WORLD, &wGroup);
- ranges[0][0] = 2*(wsize/2)-1;
+ ranges[0][0] = 2 * (wsize / 2) - 1;
ranges[0][1] = 1;
ranges[0][2] = -2;
- err = MPI_Group_range_incl( wGroup, 1, ranges, &godd );
- if (err) abortMsg( "Failed to create odd group: ", err );
- err = MPI_Group_size( godd, &gsize );
- if (err) abortMsg( "Failed to get size of odd group: ", err );
- if (gsize != wsize/2) {
- fprintf( stderr, "Group godd size is %d should be %d\n", gsize,
- wsize/2 );
- errs++;
+ err = MPI_Group_range_incl(wGroup, 1, ranges, &godd);
+ if (err)
+ abortMsg("Failed to create odd group: ", err);
+ err = MPI_Group_size(godd, &gsize);
+ if (err)
+ abortMsg("Failed to get size of odd group: ", err);
+ if (gsize != wsize / 2) {
+ fprintf(stderr, "Group godd size is %d should be %d\n", gsize, wsize / 2);
+ errs++;
}
-
- ranges[0][0] = wsize/4;
- ranges[0][1] = wsize-1;
+
+ ranges[0][0] = wsize / 4;
+ ranges[0][1] = wsize - 1;
ranges[0][2] = 1;
- err = MPI_Group_range_incl( wGroup, 1, ranges, &ghigh );
- if (err) abortMsg( "Failed to create high group\n", err );
+ err = MPI_Group_range_incl(wGroup, 1, ranges, &ghigh);
+ if (err)
+ abortMsg("Failed to create high group\n", err);
ranges[0][0] = 0;
- ranges[0][1] = wsize-1;
+ ranges[0][1] = wsize - 1;
ranges[0][2] = 2;
- err = MPI_Group_range_incl( wGroup, 1, ranges, &geven );
- if (err) abortMsg( "Failed to create even group:", err );
+ err = MPI_Group_range_incl(wGroup, 1, ranges, &geven);
+ if (err)
+ abortMsg("Failed to create even group:", err);
/* Check that a correct case returns success */
- if ( (wrank % 2) == 0) {
- err = MPI_Group_rank( geven, &mygrank );
- if (err) {
- errs++;
- fprintf( stderr, "Could not get rank from geven group\n" );
- }
- else if (mygrank == MPI_UNDEFINED) {
- errs++;
- fprintf( stderr, "mygrank should be %d but is undefined\n",
- wrank/2);
- }
- err = MPI_Comm_create( evencomm, geven, &newcomm );
- /* printf( "Created new even comm\n" ); */
- if (err != MPI_SUCCESS) {
- errs++;
- fprintf( stderr, "Failed to allow creation from even group\n" );
- }
- else {
- MPI_Comm_free( &newcomm );
- }
+ if ((wrank % 2) == 0) {
+ err = MPI_Group_rank(geven, &mygrank);
+ if (err) {
+ errs++;
+ fprintf(stderr, "Could not get rank from geven group\n");
+ }
+ else if (mygrank == MPI_UNDEFINED) {
+ errs++;
+ fprintf(stderr, "mygrank should be %d but is undefined\n", wrank / 2);
+ }
+ err = MPI_Comm_create(evencomm, geven, &newcomm);
+ /* printf("Created new even comm\n"); */
+ if (err != MPI_SUCCESS) {
+ errs++;
+ fprintf(stderr, "Failed to allow creation from even group\n");
+ }
+ else {
+ MPI_Comm_free(&newcomm);
+ }
}
- /* Now, test that these return errors when we try to use them to create
- groups */
- if ( (wrank % 2) == 0) {
- /* printf( "Even comm...\n" ); */
- /* evencomm is the comm of even-ranked processed in comm world */
- err = MPI_Comm_create( evencomm, godd, &newcomm );
- MPI_Group_rank( godd, &mygrank );
- if (err == MPI_SUCCESS) {
- if (mygrank != MPI_UNDEFINED) {
- errs++;
- fprintf( stderr, "Did not detect group of odd ranks in even comm\n" );
- }
- MPI_Comm_free( &newcomm );
- }
+ /* Now, test that these return errors when we try to use them to create
+ * groups */
+ if ((wrank % 2) == 0) {
+ /* printf("Even comm...\n"); */
+ /* evencomm is the comm of even-ranked processed in comm world */
+ err = MPI_Comm_create(evencomm, godd, &newcomm);
+ MPI_Group_rank(godd, &mygrank);
+ if (err == MPI_SUCCESS) {
+ if (mygrank != MPI_UNDEFINED) {
+ errs++;
+ fprintf(stderr, "Did not detect group of odd ranks in even comm\n");
+ }
+ MPI_Comm_free(&newcomm);
+ }
}
- if (wrank < wsize/2) {
- /* printf( "low comm...\n" ); */
- err = MPI_Comm_create( lowcomm, ghigh, &newcomm );
- MPI_Group_rank( ghigh, &mygrank );
- if (err == MPI_SUCCESS) {
- if (mygrank != MPI_UNDEFINED) {
- errs++;
- fprintf( stderr, "Did not detect group of high ranks in low comm\n" );
- }
- MPI_Comm_free( &newcomm );
- }
+ if (wrank < wsize / 2) {
+ /* printf("low comm...\n"); */
+ err = MPI_Comm_create(lowcomm, ghigh, &newcomm);
+ MPI_Group_rank(ghigh, &mygrank);
+ if (err == MPI_SUCCESS) {
+ if (mygrank != MPI_UNDEFINED) {
+ errs++;
+ fprintf(stderr, "Did not detect group of high ranks in low comm\n");
+ }
+ MPI_Comm_free(&newcomm);
+ }
}
-
- MPI_Comm_free( &lowcomm );
- MPI_Comm_free( &evencomm );
- MPI_Group_free( &ghigh );
- MPI_Group_free( &godd );
- MPI_Group_free( &geven );
- MPI_Group_free( &wGroup );
-
- MTest_Finalize( errs );
+
+ MPI_Comm_free(&lowcomm);
+ MPI_Comm_free(&evencomm);
+ MPI_Group_free(&ghigh);
+ MPI_Group_free(&godd);
+ MPI_Group_free(&geven);
+ MPI_Group_free(&wGroup);
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
diff --git a/test/mpi/errors/comm/cfree.c b/test/mpi/errors/comm/cfree.c
index 08c6fbd..ca63877 100644
--- a/test/mpi/errors/comm/cfree.c
+++ b/test/mpi/errors/comm/cfree.c
@@ -8,35 +8,35 @@
#include "mpitest.h"
/* Check that freed communicators are detected */
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Comm dup, dupcopy;
int errs = 0;
int ierr;
-
- MTest_Init( &argc, &argv );
- MPI_Comm_dup( MPI_COMM_WORLD, &dup );
- MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ MTest_Init(&argc, &argv);
+
+ MPI_Comm_dup(MPI_COMM_WORLD, &dup);
+ MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
dupcopy = dup;
- MPI_Comm_free( &dupcopy );
- ierr = MPI_Barrier( dup );
+ MPI_Comm_free(&dupcopy);
+ ierr = MPI_Barrier(dup);
if (ierr == MPI_SUCCESS) {
- errs ++;
- printf( "Returned wrong code (SUCCESS) in barrier\n" );
+ errs++;
+ printf("Returned wrong code (SUCCESS) in barrier\n");
}
{
- int in, *input = ∈
- int out, *output = &out;
- ierr = MPI_Allgather(input, 1, MPI_INT, output, 1, MPI_INT, dup);
+ int in, *input = ∈
+ int out, *output = &out;
+ ierr = MPI_Allgather(input, 1, MPI_INT, output, 1, MPI_INT, dup);
}
if (ierr == MPI_SUCCESS) {
- errs ++;
- printf( "Returned wrong code (SUCCESS) in allgather\n" );
+ errs++;
+ printf("Returned wrong code (SUCCESS) in allgather\n");
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
diff --git a/test/mpi/errors/comm/manysplit.c b/test/mpi/errors/comm/manysplit.c
index 6c29b33..e71559b 100644
--- a/test/mpi/errors/comm/manysplit.c
+++ b/test/mpi/errors/comm/manysplit.c
@@ -15,40 +15,42 @@
/* Define VERBOSE to get an output line for every communicator */
/* #define VERBOSE 1 */
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
- int i, rank;
- int rc, maxcomm;
- int errs = 0;
- MPI_Comm comm[MAX_COMMS];
+ int i, rank;
+ int rc, maxcomm;
+ int errs = 0;
+ MPI_Comm comm[MAX_COMMS];
- MTest_Init( &argc, &argv );
- MPI_Comm_rank ( MPI_COMM_WORLD, &rank );
- MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ MTest_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
- maxcomm = -1;
- for (i = 0; i < MAX_COMMS; i++) {
+ maxcomm = -1;
+ for (i = 0; i < MAX_COMMS; i++) {
#ifdef VERBOSE
- if (rank == 0) {
- if (i % 20 == 0) {
- fprintf(stderr, "\n %d: ", i); fflush(stdout);
- }
- else {
- fprintf(stderr, "."); fflush(stdout);
- }
- }
+ if (rank == 0) {
+ if (i % 20 == 0) {
+ fprintf(stderr, "\n %d: ", i);
+ fflush(stdout);
+ }
+ else {
+ fprintf(stderr, ".");
+ fflush(stdout);
+ }
+ }
#endif
- rc = MPI_Comm_split(MPI_COMM_WORLD, 1, rank, &comm[i]);
- if (rc != MPI_SUCCESS) {
- break;
+ rc = MPI_Comm_split(MPI_COMM_WORLD, 1, rank, &comm[i]);
+ if (rc != MPI_SUCCESS) {
+ break;
+ }
+ maxcomm = i;
+ }
+ for (i = 0; i <= maxcomm; i++) {
+ MPI_Comm_free(&comm[i]);
}
- maxcomm = i;
- }
- for (i=0; i<=maxcomm; i++) {
- MPI_Comm_free( &comm[i] );
- }
- /* If we complete, there are no errors */
- MTest_Finalize( errs );
- MPI_Finalize();
- return 0;
+ /* If we complete, there are no errors */
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
}
diff --git a/test/mpi/errors/comm/too_many_comms.c b/test/mpi/errors/comm/too_many_comms.c
index 8387d08..f1c4a40 100644
--- a/test/mpi/errors/comm/too_many_comms.c
+++ b/test/mpi/errors/comm/too_many_comms.c
@@ -23,10 +23,11 @@
static const int verbose = 0;
-int main(int argc, char **argv) {
- int rank, nproc, mpi_errno;
- int i, ncomm;
- int errors = 1;
+int main(int argc, char **argv)
+{
+ int rank, nproc, mpi_errno;
+ int i, ncomm;
+ int errors = 1;
MPI_Comm *comm_hdls;
MPI_Init(&argc, &argv);
@@ -44,8 +45,10 @@ int main(int argc, char **argv) {
if (mpi_errno == MPI_SUCCESS) {
ncomm++;
- } else {
- if (verbose) printf("%d: Error creating comm %d\n", rank, i);
+ }
+ else {
+ if (verbose)
+ printf("%d: Error creating comm %d\n", rank, i);
errors = 0;
break;
}
diff --git a/test/mpi/errors/comm/too_many_comms2.c b/test/mpi/errors/comm/too_many_comms2.c
index 8144eba..40b8071 100644
--- a/test/mpi/errors/comm/too_many_comms2.c
+++ b/test/mpi/errors/comm/too_many_comms2.c
@@ -23,10 +23,11 @@
static const int verbose = 0;
-int main(int argc, char **argv) {
- int rank, nproc, mpi_errno;
- int i, ncomm, *ranks;
- int errors = 1;
+int main(int argc, char **argv)
+{
+ int rank, nproc, mpi_errno;
+ int i, ncomm, *ranks;
+ int errors = 1;
MPI_Comm *comm_hdls;
MPI_Group world_group;
@@ -38,7 +39,7 @@ int main(int argc, char **argv) {
MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
comm_hdls = malloc(sizeof(MPI_Comm) * MAX_NCOMM);
- ranks = malloc(sizeof(int) * nproc);
+ ranks = malloc(sizeof(int) * nproc);
for (i = 0; i < nproc; i++)
ranks[i] = i;
@@ -48,7 +49,7 @@ int main(int argc, char **argv) {
MPI_Group comm_group;
/* Comms include ranks: 0; 0,1; 0,1,2; ...; 0; 0,1; 0,1,2; ... */
- MPI_Group_incl(world_group, (i+1) % (nproc+1), /* Adding 1 yields counts of 1..nproc */
+ MPI_Group_incl(world_group, (i + 1) % (nproc + 1), /* Adding 1 yields counts of 1..nproc */
ranks, &comm_group);
/* Note: the comms we create are all varying subsets of MPI_COMM_WORLD */
@@ -56,8 +57,10 @@ int main(int argc, char **argv) {
if (mpi_errno == MPI_SUCCESS) {
ncomm++;
- } else {
- if (verbose) printf("%d: Error creating comm %d\n", rank, i);
+ }
+ else {
+ if (verbose)
+ printf("%d: Error creating comm %d\n", rank, i);
MPI_Group_free(&comm_group);
errors = 0;
break;
diff --git a/test/mpi/errors/comm/too_many_comms3.c b/test/mpi/errors/comm/too_many_comms3.c
index 56fbe6d..614a72d 100644
--- a/test/mpi/errors/comm/too_many_comms3.c
+++ b/test/mpi/errors/comm/too_many_comms3.c
@@ -26,10 +26,11 @@
static const int verbose = 0;
-int main(int argc, char **argv) {
- int rank, nproc, mpi_errno;
- int i, ncomm, *ranks;
- int errors = 1;
+int main(int argc, char **argv)
+{
+ int rank, nproc, mpi_errno;
+ int i, ncomm, *ranks;
+ int errors = 1;
MPI_Comm *comm_hdls;
MPI_Group world_group;
@@ -41,11 +42,11 @@ int main(int argc, char **argv) {
MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
comm_hdls = malloc(sizeof(MPI_Comm) * MAX_NCOMM);
- ranks = malloc(sizeof(int) * nproc);
+ ranks = malloc(sizeof(int) * nproc);
ncomm = 0;
for (i = 0; i < MAX_NCOMM; i++) {
- int incl = i % nproc;
+ int incl = i % nproc;
MPI_Group comm_group;
/* Comms include ranks: 0; 1; 2; ...; 0; 1; ... */
@@ -55,10 +56,13 @@ int main(int argc, char **argv) {
mpi_errno = MPI_Comm_create(MPI_COMM_WORLD, comm_group, &comm_hdls[i]);
if (mpi_errno == MPI_SUCCESS) {
- if (verbose) printf("%d: Created comm %d\n", rank, i);
+ if (verbose)
+ printf("%d: Created comm %d\n", rank, i);
ncomm++;
- } else {
- if (verbose) printf("%d: Error creating comm %d\n", rank, i);
+ }
+ else {
+ if (verbose)
+ printf("%d: Error creating comm %d\n", rank, i);
MPI_Group_free(&comm_group);
errors = 0;
break;
diff --git a/test/mpi/errors/comm/userdup.c b/test/mpi/errors/comm/userdup.c
index ecd2e0c..070779a 100644
--- a/test/mpi/errors/comm/userdup.c
+++ b/test/mpi/errors/comm/userdup.c
@@ -13,131 +13,134 @@
Note that this behavior is not required by the MPI specification
but is a quality of implementation issues - users will expect
- to be able to control the class and code that comes back from
- MPI_Comm_dup (and MPI_Comm_free) in this case.
+ to be able to control the class and code that comes back from
+ MPI_Comm_dup (and MPI_Comm_free) in this case.
*/
-void abortMsg( const char *, int );
-int copybomb_fn( MPI_Comm, int, void *, void *, void *, int * );
+void abortMsg(const char *, int);
+int copybomb_fn(MPI_Comm, int, void *, void *, void *, int *);
static int myErrClass, myErrCode;
static int nCall = 0;
-void abortMsg( const char *str, int code )
+void abortMsg(const char *str, int code)
{
char msg[MPI_MAX_ERROR_STRING];
int class, resultLen;
- MPI_Error_class( code, &class );
- MPI_Error_string( code, msg, &resultLen );
- fprintf( stderr, "%s: errcode = %d, class = %d, msg = %s\n",
- str, code, class, msg );
- MPI_Abort( MPI_COMM_WORLD, code );
+ MPI_Error_class(code, &class);
+ MPI_Error_string(code, msg, &resultLen);
+ fprintf(stderr, "%s: errcode = %d, class = %d, msg = %s\n", str, code, class, msg);
+ MPI_Abort(MPI_COMM_WORLD, code);
}
-int copybomb_fn( MPI_Comm oldcomm, int keyval, void *extra_state,
- void *attribute_val_in, void *attribute_val_out, int *flag)
+int copybomb_fn(MPI_Comm oldcomm, int keyval, void *extra_state,
+ void *attribute_val_in, void *attribute_val_out, int *flag)
{
int err;
/* We always fail to copy */
*flag = 1;
/* Return either the class (as a code) or the code */
- if (nCall == 0) err = myErrClass;
- else err = myErrCode;
+ if (nCall == 0)
+ err = myErrClass;
+ else
+ err = myErrCode;
nCall++;
return err;
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Comm dupWorld, dup2;
int myRank, key, err, errs = 0;
-
- MTest_Init( &argc, &argv );
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ MTest_Init(&argc, &argv);
+
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
/* Create my error class and code */
- MPI_Add_error_class( &myErrClass );
- MPI_Add_error_code( myErrClass, &myErrCode );
- MPI_Add_error_string( myErrClass, (char*)"My error class" );
- MPI_Add_error_string( myErrCode, (char*)"My error code" );
+ MPI_Add_error_class(&myErrClass);
+ MPI_Add_error_code(myErrClass, &myErrCode);
+ MPI_Add_error_string(myErrClass, (char *) "My error class");
+ MPI_Add_error_string(myErrCode, (char *) "My error code");
- MPI_Comm_dup( MPI_COMM_WORLD, &dupWorld );
+ MPI_Comm_dup(MPI_COMM_WORLD, &dupWorld);
- MPI_Comm_rank( MPI_COMM_WORLD, &myRank );
- err = MPI_Comm_create_keyval( copybomb_fn, MPI_COMM_NULL_DELETE_FN,
- &key, NULL );
+ MPI_Comm_rank(MPI_COMM_WORLD, &myRank);
+ err = MPI_Comm_create_keyval(copybomb_fn, MPI_COMM_NULL_DELETE_FN, &key, NULL);
if (err) {
- errs++;
- abortMsg( "Comm_create_keyval", err );
+ errs++;
+ abortMsg("Comm_create_keyval", err);
}
-
- err = MPI_Comm_set_attr( dupWorld, key, &myRank );
+
+ err = MPI_Comm_set_attr(dupWorld, key, &myRank);
if (err) {
- errs++;
- abortMsg( "Comm_set_attr", err );
+ errs++;
+ abortMsg("Comm_set_attr", err);
}
- err = MPI_Comm_dup( dupWorld, &dup2 );
+ err = MPI_Comm_dup(dupWorld, &dup2);
if (err == MPI_SUCCESS) {
- errs++;
- fprintf( stderr, "Comm_dup did not fail\n" );
- MPI_Comm_free( &dup2 );
+ errs++;
+ fprintf(stderr, "Comm_dup did not fail\n");
+ MPI_Comm_free(&dup2);
}
else {
- int eclass, resultLen;
- char msg[MPI_MAX_ERROR_STRING];
- /* Check for expected error class */
- MPI_Error_class( err, &eclass );
- if (eclass != myErrClass) {
- errs++;
- fprintf( stderr, "Unexpected error class = %d, expected user-defined class %d\n", eclass,
- myErrClass );
- }
- else {
- MPI_Error_string( err, msg, &resultLen );
- if (strcmp( msg, "My error class" ) != 0) {
- errs++;
- fprintf( stderr, "Unexpected error string %s\n", msg );
- }
- }
+ int eclass, resultLen;
+ char msg[MPI_MAX_ERROR_STRING];
+ /* Check for expected error class */
+ MPI_Error_class(err, &eclass);
+ if (eclass != myErrClass) {
+ errs++;
+ fprintf(stderr, "Unexpected error class = %d, expected user-defined class %d\n", eclass,
+ myErrClass);
+ }
+ else {
+ MPI_Error_string(err, msg, &resultLen);
+ if (strcmp(msg, "My error class") != 0) {
+ errs++;
+ fprintf(stderr, "Unexpected error string %s\n", msg);
+ }
+ }
}
- err = MPI_Comm_dup( dupWorld, &dup2 );
+ err = MPI_Comm_dup(dupWorld, &dup2);
if (err == MPI_SUCCESS) {
- errs++;
- fprintf( stderr, "Comm_dup did not fail (2)\n" );
- MPI_Comm_free( &dup2 );
+ errs++;
+ fprintf(stderr, "Comm_dup did not fail (2)\n");
+ MPI_Comm_free(&dup2);
}
else {
- int eclass, resultLen;
- char msg[MPI_MAX_ERROR_STRING];
- /* Check for expected error class */
- MPI_Error_class( err, &eclass );
- if (eclass != myErrClass) {
- errs++;
- fprintf( stderr, "Unexpected error class = %d, expected user-defined class %d\n", eclass, myErrClass );
- }
- if (err != myErrCode) {
- errs++;
- fprintf( stderr, "Unexpected error code = %d, expected user-defined code %d\n", err, myErrCode );
- }
- else {
- MPI_Error_string( err, msg, &resultLen );
- if (strcmp( msg, "My error code" ) != 0) {
- errs++;
- fprintf( stderr, "Unexpected error string %s, expected user-defined error string\n", msg );
- }
- }
+ int eclass, resultLen;
+ char msg[MPI_MAX_ERROR_STRING];
+ /* Check for expected error class */
+ MPI_Error_class(err, &eclass);
+ if (eclass != myErrClass) {
+ errs++;
+ fprintf(stderr, "Unexpected error class = %d, expected user-defined class %d\n", eclass,
+ myErrClass);
+ }
+ if (err != myErrCode) {
+ errs++;
+ fprintf(stderr, "Unexpected error code = %d, expected user-defined code %d\n", err,
+ myErrCode);
+ }
+ else {
+ MPI_Error_string(err, msg, &resultLen);
+ if (strcmp(msg, "My error code") != 0) {
+ errs++;
+ fprintf(stderr, "Unexpected error string %s, expected user-defined error string\n",
+ msg);
+ }
+ }
}
- MPI_Comm_free( &dupWorld );
- MPI_Comm_free_keyval( &key );
+ MPI_Comm_free(&dupWorld);
+ MPI_Comm_free_keyval(&key);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
diff --git a/test/mpi/errors/datatype/getcnterr.c b/test/mpi/errors/datatype/getcnterr.c
index f167c14..4f7398e 100644
--- a/test/mpi/errors/datatype/getcnterr.c
+++ b/test/mpi/errors/datatype/getcnterr.c
@@ -7,46 +7,45 @@
#include "mpi.h"
#include "mpitest.h"
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int i, count, err, errs = 0;
MPI_Datatype type_ia;
char omessage[256], imessage[256];
MPI_Status recvstatus, sendstatus;
MPI_Request request;
-
- MTest_Init( &argc, &argv );
-
- MPI_Type_contiguous(4,MPI_DOUBLE_INT,&type_ia);
+
+ MTest_Init(&argc, &argv);
+
+ MPI_Type_contiguous(4, MPI_DOUBLE_INT, &type_ia);
MPI_Type_commit(&type_ia);
- for (i=1;i<256;i++) omessage[i] = i;
-
+ for (i = 1; i < 256; i++)
+ omessage[i] = i;
+
MPI_Isend(omessage, 33, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &request);
MPI_Recv(imessage, 33, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &recvstatus);
MPI_Wait(&request, &sendstatus);
-
+
/* In versions of MPICH through 1.0.7, this call would segfault on
- some platforms (at least on BlueGene). On others, it would fail
- to report an error.
- It should return an error (it is invalid to use a different type
- here than was used in the recv) or at least return MPI_UNDEFINED.
-
- If it returns MPI_UNDEFINED as the count, that will often be
- acceptable.
- */
- MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * some platforms (at least on BlueGene). On others, it would fail
+ * to report an error.
+ * It should return an error (it is invalid to use a different type
+ * here than was used in the recv) or at least return MPI_UNDEFINED.
+ *
+ * If it returns MPI_UNDEFINED as the count, that will often be
+ * acceptable.
+ */
+ MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
err = MPI_Get_elements(&recvstatus, type_ia, &count);
if (err == MPI_SUCCESS && count != MPI_UNDEFINED) {
- errs++;
- printf( "MPI_Get_elements did not report an error\n" );
+ errs++;
+ printf("MPI_Get_elements did not report an error\n");
}
- MPI_Type_free( &type_ia );
+ MPI_Type_free(&type_ia);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
- return 0;
+ return 0;
}
-
-
diff --git a/test/mpi/errors/f77/io/addsize.h.in b/test/mpi/errors/f77/io/addsize.h.in
index 320b3a5..8a5f4fd 100644
--- a/test/mpi/errors/f77/io/addsize.h.in
+++ b/test/mpi/errors/f77/io/addsize.h.in
@@ -1,6 +1,4 @@
-C -*- Mode: Fortran; -*-
-C
-C (C) 2003 by Argonne National Laboratory.
-C See COPYRIGHT in top-level directory.
-C
- @F77_MPI_ADDRESS@ asize
+C - *-Mode:Fortran;
+-*-C C(C)
+2003 by Argonne National Laboratory.C See COPYRIGHT in top - level directory.C
+ @ F77_MPI_ADDRESS @ asize
diff --git a/test/mpi/errors/f77/io/iooffset.h.in b/test/mpi/errors/f77/io/iooffset.h.in
index 61cd7c6..c0b4952 100644
--- a/test/mpi/errors/f77/io/iooffset.h.in
+++ b/test/mpi/errors/f77/io/iooffset.h.in
@@ -1,6 +1,4 @@
-C -*- Mode: Fortran; -*-
-C
-C (C) 2003 by Argonne National Laboratory.
-C See COPYRIGHT in top-level directory.
-C
- @F77_MPI_OFFSET@ offset
+C - *-Mode:Fortran;
+-*-C C(C)
+2003 by Argonne National Laboratory.C See COPYRIGHT in top - level directory.C
+ @ F77_MPI_OFFSET @ offset
diff --git a/test/mpi/errors/faults/collf1.c b/test/mpi/errors/faults/collf1.c
index 4fc7cf5..f123bc3 100644
--- a/test/mpi/errors/faults/collf1.c
+++ b/test/mpi/errors/faults/collf1.c
@@ -13,40 +13,40 @@
static char MTEST_Descrip[] = "Test survivability from faults with collective communication";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int wrank, wsize, rank, size, color;
int tmp;
MPI_Comm newcomm;
- MPI_Init( &argc, &argv );
+ MPI_Init(&argc, &argv);
- MPI_Comm_size( MPI_COMM_WORLD, &wsize );
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
+ MPI_Comm_size(MPI_COMM_WORLD, &wsize);
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
/* Color is 0 or 1; 1 will be the processes that "fault" */
- color = (wrank > 0) && (wrank <= wsize/2);
- MPI_Comm_split( MPI_COMM_WORLD, color, wrank, &newcomm );
+ color = (wrank > 0) && (wrank <= wsize / 2);
+ MPI_Comm_split(MPI_COMM_WORLD, color, wrank, &newcomm);
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
if (color) {
- /* Simulate a fault on some processes */
- exit(1);
+ /* Simulate a fault on some processes */
+ exit(1);
}
-
+
/* Can we still use newcomm? */
- MPI_Comm_size( newcomm, &size );
- MPI_Comm_rank( newcomm, &rank );
+ MPI_Comm_size(newcomm, &size);
+ MPI_Comm_rank(newcomm, &rank);
- MPI_Allreduce( &rank, &tmp, 1, MPI_INT, MPI_SUM, newcomm );
- if (tmp != (size*(size+1)) / 2) {
- printf( "Allreduce gave %d but expected %d\n", tmp, (size*(size+1))/2);
+ MPI_Allreduce(&rank, &tmp, 1, MPI_INT, MPI_SUM, newcomm);
+ if (tmp != (size * (size + 1)) / 2) {
+ printf("Allreduce gave %d but expected %d\n", tmp, (size * (size + 1)) / 2);
}
- MPI_Comm_free( &newcomm );
+ MPI_Comm_free(&newcomm);
MPI_Finalize();
- printf( " No Errors\n" );
+ printf(" No Errors\n");
return 0;
}
diff --git a/test/mpi/errors/faults/collf2.c b/test/mpi/errors/faults/collf2.c
index d0aaea9..a4955a6 100644
--- a/test/mpi/errors/faults/collf2.c
+++ b/test/mpi/errors/faults/collf2.c
@@ -13,59 +13,58 @@
static char MTEST_Descrip[] = "Test error reporting from faults with collective communication";
*/
-int ReportErr( int errcode, const char name[] );
+int ReportErr(int errcode, const char name[]);
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int wrank, wsize, rank, size, color;
int tmp, errs = 0;
MPI_Comm newcomm;
- MPI_Init( &argc, &argv );
+ MPI_Init(&argc, &argv);
- MPI_Comm_size( MPI_COMM_WORLD, &wsize );
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
+ MPI_Comm_size(MPI_COMM_WORLD, &wsize);
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
/* Color is 0 or 1; 1 will be the processes that "fault" */
/* process 0 and wsize/2+1...wsize-1 are in non-faulting group */
- color = (wrank > 0) && (wrank <= wsize/2);
- MPI_Comm_split( MPI_COMM_WORLD, color, wrank, &newcomm );
+ color = (wrank > 0) && (wrank <= wsize / 2);
+ MPI_Comm_split(MPI_COMM_WORLD, color, wrank, &newcomm);
- MPI_Comm_size( newcomm, &size );
- MPI_Comm_rank( newcomm, &rank );
+ MPI_Comm_size(newcomm, &size);
+ MPI_Comm_rank(newcomm, &rank);
/* Set errors return on COMM_WORLD and the new comm */
- MPI_Comm_set_errhandler( MPI_ERRORS_RETURN, MPI_COMM_WORLD );
- MPI_Comm_set_errhandler( MPI_ERRORS_RETURN, newcomm );
+ MPI_Comm_set_errhandler(MPI_ERRORS_RETURN, MPI_COMM_WORLD);
+ MPI_Comm_set_errhandler(MPI_ERRORS_RETURN, newcomm);
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
if (color) {
- /* Simulate a fault on some processes */
- exit(1);
+ /* Simulate a fault on some processes */
+ exit(1);
}
-
+
/* Can we still use newcomm? */
- MPI_Allreduce( &rank, &tmp, 1, MPI_INT, MPI_SUM, newcomm );
- if (tmp != (size*(size+1)) / 2) {
- printf( "Allreduce gave %d but expected %d\n", tmp, (size*(size+1))/2);
- errs ++;
+ MPI_Allreduce(&rank, &tmp, 1, MPI_INT, MPI_SUM, newcomm);
+ if (tmp != (size * (size + 1)) / 2) {
+ printf("Allreduce gave %d but expected %d\n", tmp, (size * (size + 1)) / 2);
+ errs++;
}
- MPI_Comm_free( &newcomm );
+ MPI_Comm_free(&newcomm);
MPI_Finalize();
- printf( " No Errors\n" );
+ printf(" No Errors\n");
return 0;
}
-int ReportErr( int errcode, const char name[] )
+int ReportErr(int errcode, const char name[])
{
int errclass, errlen;
char errmsg[MPI_MAX_ERROR_STRING];
- MPI_Error_class( errcode, &errclass );
- MPI_Error_string( errcode, errmsg, &errlen );
- fprintf( stderr, "In %s, error code %d(class %d) = %s\n",
- name, errcode, errclass, errmsg );
+ MPI_Error_class(errcode, &errclass);
+ MPI_Error_string(errcode, errmsg, &errlen);
+ fprintf(stderr, "In %s, error code %d(class %d) = %s\n", name, errcode, errclass, errmsg);
return 1;
-}
+}
diff --git a/test/mpi/errors/faults/pt2ptf1.c b/test/mpi/errors/faults/pt2ptf1.c
index 553e1dc..4d1f304 100644
--- a/test/mpi/errors/faults/pt2ptf1.c
+++ b/test/mpi/errors/faults/pt2ptf1.c
@@ -13,42 +13,42 @@
static char MTEST_Descrip[] = "Test survivability from faults with point to point communication";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int wrank, wsize, rank, size, color;
int j, tmp;
MPI_Comm newcomm;
- MPI_Init( &argc, &argv );
+ MPI_Init(&argc, &argv);
- MPI_Comm_size( MPI_COMM_WORLD, &wsize );
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
+ MPI_Comm_size(MPI_COMM_WORLD, &wsize);
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
/* Color is 0 or 1; 1 will be the processes that "fault" */
- color = (wrank > 0) && (wrank <= wsize/2);
- MPI_Comm_split( MPI_COMM_WORLD, color, wrank, &newcomm );
+ color = (wrank > 0) && (wrank <= wsize / 2);
+ MPI_Comm_split(MPI_COMM_WORLD, color, wrank, &newcomm);
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
if (color) {
- /* Simulate a fault on some processes */
- exit(1);
+ /* Simulate a fault on some processes */
+ exit(1);
}
-
+
/* Can we still use newcomm? */
- MPI_Comm_size( newcomm, &size );
- MPI_Comm_rank( newcomm, &rank );
+ MPI_Comm_size(newcomm, &size);
+ MPI_Comm_rank(newcomm, &rank);
- for (j=0; j<rank; j++) {
- MPI_Recv( &tmp, 1, MPI_INT, j, 0, newcomm, MPI_STATUS_IGNORE );
+ for (j = 0; j < rank; j++) {
+ MPI_Recv(&tmp, 1, MPI_INT, j, 0, newcomm, MPI_STATUS_IGNORE);
}
- for (j=rank+1; j<size; j++) {
- MPI_Send( &rank, 1, MPI_INT, j, 0, newcomm );
+ for (j = rank + 1; j < size; j++) {
+ MPI_Send(&rank, 1, MPI_INT, j, 0, newcomm);
}
- MPI_Comm_free( &newcomm );
+ MPI_Comm_free(&newcomm);
MPI_Finalize();
- printf( " No Errors\n" );
+ printf(" No Errors\n");
return 0;
}
diff --git a/test/mpi/errors/faults/pt2ptf2.c b/test/mpi/errors/faults/pt2ptf2.c
index 0808ac2..73b8298 100644
--- a/test/mpi/errors/faults/pt2ptf2.c
+++ b/test/mpi/errors/faults/pt2ptf2.c
@@ -13,93 +13,96 @@
static char MTEST_Descrip[] = "Test error reporting from faults with point to point communication";
*/
-int ReportErr( int errcode, const char name[] );
+int ReportErr(int errcode, const char name[]);
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int wrank, wsize, rank, size, color;
int j, tmp;
int err, toterrs, errs = 0;
MPI_Comm newcomm;
- MPI_Init( &argc, &argv );
+ MPI_Init(&argc, &argv);
- MPI_Comm_size( MPI_COMM_WORLD, &wsize );
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
+ MPI_Comm_size(MPI_COMM_WORLD, &wsize);
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
/* Color is 0 or 1; 1 will be the processes that "fault" */
/* process 0 and wsize/2+1...wsize-1 are in non-faulting group */
- color = (wrank > 0) && (wrank <= wsize/2);
- MPI_Comm_split( MPI_COMM_WORLD, color, wrank, &newcomm );
+ color = (wrank > 0) && (wrank <= wsize / 2);
+ MPI_Comm_split(MPI_COMM_WORLD, color, wrank, &newcomm);
- MPI_Comm_size( newcomm, &size );
- MPI_Comm_rank( newcomm, &rank );
+ MPI_Comm_size(newcomm, &size);
+ MPI_Comm_rank(newcomm, &rank);
/* Set errors return on COMM_WORLD and the new comm */
- MPI_Comm_set_errhandler( MPI_ERRORS_RETURN, MPI_COMM_WORLD );
- MPI_Comm_set_errhandler( MPI_ERRORS_RETURN, newcomm );
+ MPI_Comm_set_errhandler(MPI_ERRORS_RETURN, MPI_COMM_WORLD);
+ MPI_Comm_set_errhandler(MPI_ERRORS_RETURN, newcomm);
- err = MPI_Barrier( MPI_COMM_WORLD );
- if (err) errs += ReportErr( err, "Barrier" );
+ err = MPI_Barrier(MPI_COMM_WORLD);
+ if (err)
+ errs += ReportErr(err, "Barrier");
if (color) {
- /* Simulate a fault on some processes */
- exit(1);
+ /* Simulate a fault on some processes */
+ exit(1);
}
else {
- /* To improve the chance that the "faulted" processes will have
- exited, wait for 1 second */
- MTestSleep( 1 );
+ /* To improve the chance that the "faulted" processes will have
+ * exited, wait for 1 second */
+ MTestSleep(1);
}
-
+
/* Can we still use newcomm? */
- for (j=0; j<rank; j++) {
- err = MPI_Recv( &tmp, 1, MPI_INT, j, 0, newcomm, MPI_STATUS_IGNORE );
- if (err) errs += ReportErr( err, "Recv" );
+ for (j = 0; j < rank; j++) {
+ err = MPI_Recv(&tmp, 1, MPI_INT, j, 0, newcomm, MPI_STATUS_IGNORE);
+ if (err)
+ errs += ReportErr(err, "Recv");
}
- for (j=rank+1; j<size; j++) {
- err = MPI_Send( &rank, 1, MPI_INT, j, 0, newcomm );
- if (err) errs += ReportErr( err, "Recv" );
+ for (j = rank + 1; j < size; j++) {
+ err = MPI_Send(&rank, 1, MPI_INT, j, 0, newcomm);
+ if (err)
+ errs += ReportErr(err, "Recv");
}
/* Now, try sending in MPI_COMM_WORLD on dead processes */
/* There is a race condition here - we don't know for sure that the faulted
- processes have exited. However, we can ensure a failure by using
- synchronous sends - the sender will wait until the reciever handles
- receives the message, which will not happen (the process will exit
- without matching the message, even if it has not yet exited). */
- for (j=1; j<=wsize/2; j++) {
- err = MPI_Ssend( &rank, 1, MPI_INT, j, 0, MPI_COMM_WORLD );
- if (!err) {
- errs++;
- fprintf( stderr, "Ssend succeeded to dead process %d\n", j );
- }
+ * processes have exited. However, we can ensure a failure by using
+ * synchronous sends - the sender will wait until the reciever handles
+ * receives the message, which will not happen (the process will exit
+ * without matching the message, even if it has not yet exited). */
+ for (j = 1; j <= wsize / 2; j++) {
+ err = MPI_Ssend(&rank, 1, MPI_INT, j, 0, MPI_COMM_WORLD);
+ if (!err) {
+ errs++;
+ fprintf(stderr, "Ssend succeeded to dead process %d\n", j);
+ }
}
- err = MPI_Allreduce( &errs, &toterrs, 1, MPI_INT, MPI_SUM, newcomm );
- if (err) errs += ReportErr( err, "Allreduce" );
- MPI_Comm_free( &newcomm );
+ err = MPI_Allreduce(&errs, &toterrs, 1, MPI_INT, MPI_SUM, newcomm);
+ if (err)
+ errs += ReportErr(err, "Allreduce");
+ MPI_Comm_free(&newcomm);
MPI_Finalize();
if (wrank == 0) {
- if (toterrs > 0) {
- printf( " Found %d errors\n", toterrs );
- }
- else {
- printf( " No Errors\n" );
- }
+ if (toterrs > 0) {
+ printf(" Found %d errors\n", toterrs);
+ }
+ else {
+ printf(" No Errors\n");
+ }
}
return 0;
}
-int ReportErr( int errcode, const char name[] )
+int ReportErr(int errcode, const char name[])
{
int errclass, errlen;
char errmsg[MPI_MAX_ERROR_STRING];
- MPI_Error_class( errcode, &errclass );
- MPI_Error_string( errcode, errmsg, &errlen );
- fprintf( stderr, "In %s, error code %d(class %d) = %s\n",
- name, errcode, errclass, errmsg );
+ MPI_Error_class(errcode, &errclass);
+ MPI_Error_string(errcode, errmsg, &errlen);
+ fprintf(stderr, "In %s, error code %d(class %d) = %s\n", name, errcode, errclass, errmsg);
return 1;
-}
+}
diff --git a/test/mpi/errors/group/gerr.c b/test/mpi/errors/group/gerr.c
index 234adca..a224b88 100644
--- a/test/mpi/errors/group/gerr.c
+++ b/test/mpi/errors/group/gerr.c
@@ -9,39 +9,39 @@
#include "mpitest.h"
/*
- * Test whether invalid handles to group routines are detected
+ * Test whether invalid handles to group routines are detected
*/
int verbose = 0;
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rc;
int ranks[2];
MPI_Group ng;
- char str[MPI_MAX_ERROR_STRING+1];
- int slen;
+ char str[MPI_MAX_ERROR_STRING + 1];
+ int slen;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
/* Set errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
/* Create some valid input data except for the group handle */
ranks[0] = 0;
- rc = MPI_Group_incl( MPI_COMM_WORLD, 1, ranks, &ng );
+ rc = MPI_Group_incl(MPI_COMM_WORLD, 1, ranks, &ng);
if (rc == MPI_SUCCESS) {
- errs ++;
- printf( "Did not detect invalid handle (comm) in group_incl\n" );
+ errs++;
+ printf("Did not detect invalid handle (comm) in group_incl\n");
}
else {
- if (verbose) {
- MPI_Error_string( rc, str, &slen );
- printf( "Found expected error; message is: %s\n", str );
- }
+ if (verbose) {
+ MPI_Error_string(rc, str, &slen);
+ printf("Found expected error; message is: %s\n", str);
+ }
}
- MTest_Finalize( errs );
- MPI_Finalize( );
+ MTest_Finalize(errs);
+ MPI_Finalize();
return 0;
}
diff --git a/test/mpi/errors/io/file_errhdl.c b/test/mpi/errors/io/file_errhdl.c
index 7b58c2d..ef7955b 100644
--- a/test/mpi/errors/io/file_errhdl.c
+++ b/test/mpi/errors/io/file_errhdl.c
@@ -4,23 +4,23 @@
int main(int argc, char *argv[])
{
- int ierr;
- MPI_File fh;
- MPI_Init(&argc, &argv);
+ int ierr;
+ MPI_File fh;
+ MPI_Init(&argc, &argv);
- MPI_File_open(MPI_COMM_WORLD,"/tmp/datafile",
- MPI_MODE_CREATE|MPI_MODE_RDWR|MPI_MODE_DELETE_ON_CLOSE,
- MPI_INFO_NULL,&fh);
+ MPI_File_open(MPI_COMM_WORLD, "/tmp/datafile",
+ MPI_MODE_CREATE | MPI_MODE_RDWR | MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh);
- MPI_File_set_errhandler(fh,MPI_ERRORS_RETURN);
- ierr = MPI_File_call_errhandler(fh,MPI_ERR_FILE);
- if (ierr != MPI_SUCCESS) {
- fprintf(stderr, "ierr: %d, expected: %d\n", ierr, (int)MPI_SUCCESS);
- } else {
- printf(" No Errors\n");
- }
- MPI_File_close(&fh);
+ MPI_File_set_errhandler(fh, MPI_ERRORS_RETURN);
+ ierr = MPI_File_call_errhandler(fh, MPI_ERR_FILE);
+ if (ierr != MPI_SUCCESS) {
+ fprintf(stderr, "ierr: %d, expected: %d\n", ierr, (int) MPI_SUCCESS);
+ }
+ else {
+ printf(" No Errors\n");
+ }
+ MPI_File_close(&fh);
- MPI_Finalize();
- return 0;
+ MPI_Finalize();
+ return 0;
}
diff --git a/test/mpi/errors/io/fileerrret.c b/test/mpi/errors/io/fileerrret.c
index df08749..813436e 100644
--- a/test/mpi/errors/io/fileerrret.c
+++ b/test/mpi/errors/io/fileerrret.c
@@ -14,51 +14,50 @@
#include "mpitest.h"
static int ncalls = 0;
-void efn( MPI_File *fh, int *code, ... );
-void efn( MPI_File *fh, int *code, ... )
+void efn(MPI_File * fh, int *code, ...);
+void efn(MPI_File * fh, int *code, ...)
{
- ncalls ++;
+ ncalls++;
*code = MPI_SUCCESS;
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_File fh;
MPI_Errhandler eh;
char filename[10];
int errs = 0, rc;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
/* Test that the default error handler is errors return for files */
- strncpy( filename, "t1", sizeof(filename) );
+ strncpy(filename, "t1", sizeof(filename));
- rc = MPI_File_open( MPI_COMM_WORLD, filename,
- MPI_MODE_RDWR, MPI_INFO_NULL, &fh );
+ rc = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
if (!rc) {
- errs++;
- printf( "Did not get error from open for writing without CREATE\n" );
+ errs++;
+ printf("Did not get error from open for writing without CREATE\n");
}
/* Test that we can change the default error handler by changing
- the error handler on MPI_FILE_NULL. */
- MPI_File_create_errhandler( efn, &eh );
- MPI_File_set_errhandler( MPI_FILE_NULL, eh );
+ * the error handler on MPI_FILE_NULL. */
+ MPI_File_create_errhandler(efn, &eh);
+ MPI_File_set_errhandler(MPI_FILE_NULL, eh);
MPI_Errhandler_free(&eh);
- rc = MPI_File_open(MPI_COMM_WORLD, filename,
- MPI_MODE_RDWR, MPI_INFO_NULL, &fh );
+ rc = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
if (rc) {
errs++;
- printf( "Returned error from open (should have called error handler instead)\n");
+ printf("Returned error from open (should have called error handler instead)\n");
}
if (ncalls != 1) {
- errs++;
- printf( "Did not invoke error handler when opening a non-existent file for writing and reading (without MODE_CREATE)\n" );
+ errs++;
+ printf
+ ("Did not invoke error handler when opening a non-existent file for writing and reading (without MODE_CREATE)\n");
}
-
+
/* Find out how many errors we saw */
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
diff --git a/test/mpi/errors/io/openerr.c b/test/mpi/errors/io/openerr.c
index 8135974..a3cdc29 100644
--- a/test/mpi/errors/io/openerr.c
+++ b/test/mpi/errors/io/openerr.c
@@ -14,140 +14,137 @@
#include "mpitest.h"
/*
- * openerr - Test that errors on file open are handled correctly and that the
+ * openerr - Test that errors on file open are handled correctly and that the
* returned error message is accessible
*/
#define BUFLEN 10
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_File fh;
char emsg[MPI_MAX_ERROR_STRING];
- int emsglen, err, ec, errs = 0;
- int amode, rank;
+ int emsglen, err, ec, errs = 0;
+ int amode, rank;
char *name = 0;
MPI_Status st;
- int outbuf[BUFLEN], inbuf[BUFLEN];
+ int outbuf[BUFLEN], inbuf[BUFLEN];
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
name = "not-a-file-to-use";
/* Try to open a file that does/should not exist */
- /* Note that no error message should be printed by MPI_File_open,
- even when there is an error */
- err = MPI_File_open( MPI_COMM_WORLD, name, MPI_MODE_RDONLY,
- MPI_INFO_NULL, &fh );
+ /* Note that no error message should be printed by MPI_File_open,
+ * even when there is an error */
+ err = MPI_File_open(MPI_COMM_WORLD, name, MPI_MODE_RDONLY, MPI_INFO_NULL, &fh);
if (err == MPI_SUCCESS) {
- errs++;
- printf( "Did not return error when opening a file that does not exist\n" );
- MPI_File_close( &fh );
- MPI_File_delete( name, MPI_INFO_NULL );
+ errs++;
+ printf("Did not return error when opening a file that does not exist\n");
+ MPI_File_close(&fh);
+ MPI_File_delete(name, MPI_INFO_NULL);
}
else {
- MPI_Error_class( err, &ec );
- MPI_Error_string( err, emsg, &emsglen );
- MTestPrintfMsg( 2, "Error msg from open: %s\n", emsg );
- if (ec != MPI_ERR_NO_SUCH_FILE && ec != MPI_ERR_IO) {
- errs++;
- printf( "Did not return class ERR_NO_SUCH_FILE or ERR_IO\n" );
- printf( "Returned class %d, message %s\n", ec, emsg );
- }
+ MPI_Error_class(err, &ec);
+ MPI_Error_string(err, emsg, &emsglen);
+ MTestPrintfMsg(2, "Error msg from open: %s\n", emsg);
+ if (ec != MPI_ERR_NO_SUCH_FILE && ec != MPI_ERR_IO) {
+ errs++;
+ printf("Did not return class ERR_NO_SUCH_FILE or ERR_IO\n");
+ printf("Returned class %d, message %s\n", ec, emsg);
+ }
}
/* Now, create a file, write data into it; close, then reopen as
- read only and try to write to it */
-
+ * read only and try to write to it */
+
amode = MPI_MODE_CREATE | MPI_MODE_WRONLY;
- name = "mpio-test-openerrs";
-
- err = MPI_File_open(MPI_COMM_WORLD, name, amode, MPI_INFO_NULL, &fh );
+ name = "mpio-test-openerrs";
+
+ err = MPI_File_open(MPI_COMM_WORLD, name, amode, MPI_INFO_NULL, &fh);
if (err) {
- errs++;
- MTestPrintErrorMsg( "Unable to open file for writing", err );
+ errs++;
+ MTestPrintErrorMsg("Unable to open file for writing", err);
}
else {
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- memset(outbuf, 'A' + rank, BUFLEN);
-
- err = MPI_File_write_at( fh, rank*BUFLEN, outbuf, BUFLEN, MPI_BYTE,
- &st );
- if (err) {
- errs++;
- MTestPrintErrorMsg( "Unable to write file", err );
- }
- MPI_File_close( &fh );
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ memset(outbuf, 'A' + rank, BUFLEN);
+
+ err = MPI_File_write_at(fh, rank * BUFLEN, outbuf, BUFLEN, MPI_BYTE, &st);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Unable to write file", err);
+ }
+ MPI_File_close(&fh);
}
/* Now, open for read only, and delete on close */
amode = MPI_MODE_RDONLY | MPI_MODE_DELETE_ON_CLOSE;
-
- err = MPI_File_open(MPI_COMM_WORLD, name, amode, MPI_INFO_NULL, &fh );
+
+ err = MPI_File_open(MPI_COMM_WORLD, name, amode, MPI_INFO_NULL, &fh);
if (err) {
- errs++;
- MTestPrintErrorMsg( "Unable to reopen file for reading", err );
+ errs++;
+ MTestPrintErrorMsg("Unable to reopen file for reading", err);
}
else {
- /* Try to read it */
-
- /* Clear buffer before reading into it */
-
- memset(inbuf, 0, BUFLEN);
-
- err = MPI_File_read_at( fh, rank*BUFLEN, inbuf, BUFLEN, MPI_BYTE, &st );
- if (err) {
- errs++;
- MTestPrintErrorMsg( "Unable to read file", err );
- }
-
- /* Try to write it (should fail) */
- err = MPI_File_write_at( fh, rank*BUFLEN, outbuf, BUFLEN, MPI_BYTE,
- &st );
- if (err == MPI_SUCCESS) {
- errs++;
- printf( "Write operation succeeded to read-only file\n" );
- }
- else {
- /* Look at error class */
- MPI_Error_class( err, &ec );
- if (ec != MPI_ERR_READ_ONLY && ec != MPI_ERR_ACCESS) {
- errs++;
- printf( "Unexpected error class %d when writing to read-only file\n", ec );
- MTestPrintErrorMsg( "Error msg is: ", err );
- }
- }
- err = MPI_File_close( &fh );
- if (err) {
- errs++;
- MTestPrintErrorMsg( "Failed to close", err );
- }
-
- /* No MPI_Barrier is required here */
-
- /*
- * Test open without CREATE to see if DELETE_ON_CLOSE worked.
- * This should fail if file was deleted correctly.
- */
-
- amode = MPI_MODE_RDONLY;
- err = MPI_File_open(MPI_COMM_WORLD, name, amode, MPI_INFO_NULL, &fh );
- if (err == MPI_SUCCESS) {
- errs++;
- printf( "File was not deleted!\n" );
- MPI_File_close( &fh );
- }
- else {
- MPI_Error_class( err, &ec );
- if (ec != MPI_ERR_NO_SUCH_FILE && ec != MPI_ERR_IO) {
- errs++;
- printf( "Did not return class ERR_NO_SUCH_FILE or ERR_IO\n" );
- printf( "Returned class %d, message %s\n", ec, emsg );
- }
- }
+ /* Try to read it */
+
+ /* Clear buffer before reading into it */
+
+ memset(inbuf, 0, BUFLEN);
+
+ err = MPI_File_read_at(fh, rank * BUFLEN, inbuf, BUFLEN, MPI_BYTE, &st);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Unable to read file", err);
+ }
+
+ /* Try to write it (should fail) */
+ err = MPI_File_write_at(fh, rank * BUFLEN, outbuf, BUFLEN, MPI_BYTE, &st);
+ if (err == MPI_SUCCESS) {
+ errs++;
+ printf("Write operation succeeded to read-only file\n");
+ }
+ else {
+ /* Look at error class */
+ MPI_Error_class(err, &ec);
+ if (ec != MPI_ERR_READ_ONLY && ec != MPI_ERR_ACCESS) {
+ errs++;
+ printf("Unexpected error class %d when writing to read-only file\n", ec);
+ MTestPrintErrorMsg("Error msg is: ", err);
+ }
+ }
+ err = MPI_File_close(&fh);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Failed to close", err);
+ }
+
+ /* No MPI_Barrier is required here */
+
+ /*
+ * Test open without CREATE to see if DELETE_ON_CLOSE worked.
+ * This should fail if file was deleted correctly.
+ */
+
+ amode = MPI_MODE_RDONLY;
+ err = MPI_File_open(MPI_COMM_WORLD, name, amode, MPI_INFO_NULL, &fh);
+ if (err == MPI_SUCCESS) {
+ errs++;
+ printf("File was not deleted!\n");
+ MPI_File_close(&fh);
+ }
+ else {
+ MPI_Error_class(err, &ec);
+ if (ec != MPI_ERR_NO_SUCH_FILE && ec != MPI_ERR_IO) {
+ errs++;
+ printf("Did not return class ERR_NO_SUCH_FILE or ERR_IO\n");
+ printf("Returned class %d, message %s\n", ec, emsg);
+ }
+ }
}
/* */
-
+
/* Find out how many errors we saw */
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
diff --git a/test/mpi/errors/pt2pt/errinstatta.c b/test/mpi/errors/pt2pt/errinstatta.c
index 49929bd..ed79795 100644
--- a/test/mpi/errors/pt2pt/errinstatta.c
+++ b/test/mpi/errors/pt2pt/errinstatta.c
@@ -13,39 +13,39 @@ static char MTEST_Descrip[] = "Test err in status return, using truncated \
messages for MPI_Testall";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
MPI_Comm comm;
MPI_Request r[2];
- MPI_Status s[2];
+ MPI_Status s[2];
int b1[20], b2[20], rank, size, src, dest, i, flag;
int errval, errclass;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- /* Create some receive requests. tags 0-9 will succeed, tags 10-19
- will be used for ERR_TRUNCATE (fewer than 20 messages will be used) */
+ /* Create some receive requests. tags 0-9 will succeed, tags 10-19
+ * will be used for ERR_TRUNCATE (fewer than 20 messages will be used) */
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
- src = 1;
+ src = 1;
dest = 0;
if (rank == dest) {
- MPI_Errhandler_set( comm, MPI_ERRORS_RETURN );
- errval = MPI_Irecv( b1, 10, MPI_INT, src, 0, comm, &r[0] );
- if (errval) {
- errs++;
- MTestPrintError( errval );
- printf( "Error returned from Irecv\n" );
- }
- errval = MPI_Irecv( b2, 10, MPI_INT, src, 10, comm, &r[1] );
- if (errval) {
- errs++;
- MTestPrintError( errval );
- printf( "Error returned from Irecv\n" );
- }
+ MPI_Errhandler_set(comm, MPI_ERRORS_RETURN);
+ errval = MPI_Irecv(b1, 10, MPI_INT, src, 0, comm, &r[0]);
+ if (errval) {
+ errs++;
+ MTestPrintError(errval);
+ printf("Error returned from Irecv\n");
+ }
+ errval = MPI_Irecv(b2, 10, MPI_INT, src, 10, comm, &r[1]);
+ if (errval) {
+ errs++;
+ MTestPrintError(errval);
+ printf("Error returned from Irecv\n");
+ }
/* Wait for Irecvs to be posted before the sender calls send. This
* prevents the operation from completing and returning an error in the
@@ -53,66 +53,65 @@ int main( int argc, char *argv[] )
errval = MPI_Recv(NULL, 0, MPI_INT, src, 100, comm, MPI_STATUS_IGNORE);
if (errval) {
errs++;
- MTestPrintError( errval );
- printf( "Error returned from Recv\n" );
+ MTestPrintError(errval);
+ printf("Error returned from Recv\n");
}
/* Wait for sends to complete at the sender before proceeding */
/* WARNING: This does not guarantee that the sends are ready to
* complete at the receiver. */
- errval = MPI_Recv(NULL, 0, MPI_INT, src, 10, comm, MPI_STATUS_IGNORE);
- if (errval) {
- errs++;
- MTestPrintError( errval );
- printf( "Error returned from Recv\n" );
- }
- for (i=0; i<2; i++) {
- s[i].MPI_ERROR = -1;
- }
+ errval = MPI_Recv(NULL, 0, MPI_INT, src, 10, comm, MPI_STATUS_IGNORE);
+ if (errval) {
+ errs++;
+ MTestPrintError(errval);
+ printf("Error returned from Recv\n");
+ }
+ for (i = 0; i < 2; i++) {
+ s[i].MPI_ERROR = -1;
+ }
/* WARNING: The following assumes that Testall will complete both
* send/irecv pairs. This is *not* guaranteed by the MPI standard. */
- errval = MPI_Testall( 2, r, &flag, s );
- MPI_Error_class( errval, &errclass );
- if (errclass != MPI_ERR_IN_STATUS) {
- errs++;
- printf( "Did not get ERR_IN_STATUS in Testall\n" );
- }
- else if (!flag) {
- errs++;
- printf( "Test returned false for test\n" );
- }
- else {
- /* Check for success */
- for (i=0; i<2; i++) {
- if (s[i].MPI_TAG < 10 && s[i].MPI_ERROR != MPI_SUCCESS) {
- errs++;
- printf( "correct msg had error class %d\n",
- s[i].MPI_ERROR );
- }
- else if (s[i].MPI_TAG >= 10 && s[i].MPI_ERROR == MPI_SUCCESS) {
- errs++;
- printf( "truncated msg had MPI_SUCCESS\n" );
- }
- }
- }
+ errval = MPI_Testall(2, r, &flag, s);
+ MPI_Error_class(errval, &errclass);
+ if (errclass != MPI_ERR_IN_STATUS) {
+ errs++;
+ printf("Did not get ERR_IN_STATUS in Testall\n");
+ }
+ else if (!flag) {
+ errs++;
+ printf("Test returned false for test\n");
+ }
+ else {
+ /* Check for success */
+ for (i = 0; i < 2; i++) {
+ if (s[i].MPI_TAG < 10 && s[i].MPI_ERROR != MPI_SUCCESS) {
+ errs++;
+ printf("correct msg had error class %d\n", s[i].MPI_ERROR);
+ }
+ else if (s[i].MPI_TAG >= 10 && s[i].MPI_ERROR == MPI_SUCCESS) {
+ errs++;
+ printf("truncated msg had MPI_SUCCESS\n");
+ }
+ }
+ }
}
else if (rank == src) {
/* Wait for Irecvs to be posted before the sender calls send */
- MPI_Ssend( NULL, 0, MPI_INT, dest, 100, comm );
+ MPI_Ssend(NULL, 0, MPI_INT, dest, 100, comm);
- /* Send test messages, then send another message so that the test does
- not start until we are sure that the sends have begun */
- MPI_Send( b1, 10, MPI_INT, dest, 0, comm );
- MPI_Send( b2, 11, MPI_INT, dest, 10, comm );
+ /* Send test messages, then send another message so that the test does
+ * not start until we are sure that the sends have begun */
+ MPI_Send(b1, 10, MPI_INT, dest, 0, comm);
+ MPI_Send(b2, 11, MPI_INT, dest, 10, comm);
/* Wait for sends to complete before proceeding to the testsome. */
- MPI_Ssend( NULL, 0, MPI_INT, dest, 10, comm );
+ MPI_Ssend(NULL, 0, MPI_INT, dest, 10, comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/errors/pt2pt/errinstatts.c b/test/mpi/errors/pt2pt/errinstatts.c
index dd247f2..79f1030 100644
--- a/test/mpi/errors/pt2pt/errinstatts.c
+++ b/test/mpi/errors/pt2pt/errinstatts.c
@@ -13,41 +13,41 @@ static char MTEST_Descrip[] = "Test err in status return, using truncated \
messages for MPI_Testsome";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
MPI_Comm comm;
MPI_Request r[2];
- MPI_Status s[2];
- int indices[2], outcount;
+ MPI_Status s[2];
+ int indices[2], outcount;
int errval, errclass;
int b1[20], b2[20], rank, size, src, dest, i, j;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- /* Create some receive requests. tags 0-9 will succeed, tags 10-19
- will be used for ERR_TRUNCATE (fewer than 20 messages will be used) */
+ /* Create some receive requests. tags 0-9 will succeed, tags 10-19
+ * will be used for ERR_TRUNCATE (fewer than 20 messages will be used) */
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
- src = 1;
+ src = 1;
dest = 0;
if (rank == dest) {
- MPI_Errhandler_set( comm, MPI_ERRORS_RETURN );
- errval = MPI_Irecv( b1, 10, MPI_INT, src, 0, comm, &r[0] );
- if (errval) {
- errs++;
- MTestPrintError( errval );
- printf( "Error returned from Irecv\n" );
- }
- errval = MPI_Irecv( b2, 10, MPI_INT, src, 10, comm, &r[1] );
- if (errval) {
- errs++;
- MTestPrintError( errval );
- printf( "Error returned from Irecv\n" );
- }
+ MPI_Errhandler_set(comm, MPI_ERRORS_RETURN);
+ errval = MPI_Irecv(b1, 10, MPI_INT, src, 0, comm, &r[0]);
+ if (errval) {
+ errs++;
+ MTestPrintError(errval);
+ printf("Error returned from Irecv\n");
+ }
+ errval = MPI_Irecv(b2, 10, MPI_INT, src, 10, comm, &r[1]);
+ if (errval) {
+ errs++;
+ MTestPrintError(errval);
+ printf("Error returned from Irecv\n");
+ }
/* Wait for Irecvs to be posted before the sender calls send. This
* prevents the operation from completing and returning an error in the
@@ -55,69 +55,69 @@ int main( int argc, char *argv[] )
errval = MPI_Recv(NULL, 0, MPI_INT, src, 100, comm, MPI_STATUS_IGNORE);
if (errval) {
errs++;
- MTestPrintError( errval );
- printf( "Error returned from Recv\n" );
+ MTestPrintError(errval);
+ printf("Error returned from Recv\n");
}
/* Wait for sends to complete at the sender before proceeding */
/* WARNING: This does not guarantee that the sends are ready to
* complete at the receiver. */
- errval = MPI_Recv(NULL, 0, MPI_INT, src, 10, comm, MPI_STATUS_IGNORE);
- if (errval) {
- errs++;
- MTestPrintError( errval );
- printf( "Error returned from Recv\n" );
- }
- for (i=0; i<2; i++) {
- s[i].MPI_ERROR = -1;
- }
+ errval = MPI_Recv(NULL, 0, MPI_INT, src, 10, comm, MPI_STATUS_IGNORE);
+ if (errval) {
+ errs++;
+ MTestPrintError(errval);
+ printf("Error returned from Recv\n");
+ }
+ for (i = 0; i < 2; i++) {
+ s[i].MPI_ERROR = -1;
+ }
/* WARNING: The following assumes that Testsome will complete both
* send/irecv pairs. This is *not* guaranteed by the MPI standard. */
- errval = MPI_Testsome( 2, r, &outcount, indices, s );
- MPI_Error_class( errval, &errclass );
- if (errclass != MPI_ERR_IN_STATUS) {
- errs++;
- printf( "Did not get ERR_IN_STATUS in Testsome (outcount = %d, should equal 2); class returned was %d\n",
- outcount, errclass );
- }
- else if (outcount != 2) {
- errs++;
- printf( "Test returned outcount = %d\n", outcount );
- }
- else {
- /* Check for success */
- for (i=0; i<outcount; i++) {
- j = i;
- /* Indices is the request index */
- if (s[j].MPI_TAG < 10 && s[j].MPI_ERROR != MPI_SUCCESS) {
- errs++;
- printf( "correct msg had error class %d\n",
- s[j].MPI_ERROR );
- }
- else if (s[j].MPI_TAG >= 10 && s[j].MPI_ERROR == MPI_SUCCESS) {
- errs++;
- printf( "truncated msg had MPI_SUCCESS\n" );
- }
- }
- }
+ errval = MPI_Testsome(2, r, &outcount, indices, s);
+ MPI_Error_class(errval, &errclass);
+ if (errclass != MPI_ERR_IN_STATUS) {
+ errs++;
+ printf
+ ("Did not get ERR_IN_STATUS in Testsome (outcount = %d, should equal 2); class returned was %d\n",
+ outcount, errclass);
+ }
+ else if (outcount != 2) {
+ errs++;
+ printf("Test returned outcount = %d\n", outcount);
+ }
+ else {
+ /* Check for success */
+ for (i = 0; i < outcount; i++) {
+ j = i;
+ /* Indices is the request index */
+ if (s[j].MPI_TAG < 10 && s[j].MPI_ERROR != MPI_SUCCESS) {
+ errs++;
+ printf("correct msg had error class %d\n", s[j].MPI_ERROR);
+ }
+ else if (s[j].MPI_TAG >= 10 && s[j].MPI_ERROR == MPI_SUCCESS) {
+ errs++;
+ printf("truncated msg had MPI_SUCCESS\n");
+ }
+ }
+ }
}
else if (rank == src) {
/* Wait for Irecvs to be posted before the sender calls send */
- MPI_Ssend( NULL, 0, MPI_INT, dest, 100, comm );
+ MPI_Ssend(NULL, 0, MPI_INT, dest, 100, comm);
- /* Send test messages, then send another message so that the test does
- not start until we are sure that the sends have begun */
- MPI_Send( b1, 10, MPI_INT, dest, 0, comm );
- MPI_Send( b2, 11, MPI_INT, dest, 10, comm );
+ /* Send test messages, then send another message so that the test does
+ * not start until we are sure that the sends have begun */
+ MPI_Send(b1, 10, MPI_INT, dest, 0, comm);
+ MPI_Send(b2, 11, MPI_INT, dest, 10, comm);
/* Wait for sends to complete before proceeding to the testsome. */
- MPI_Ssend( NULL, 0, MPI_INT, dest, 10, comm );
+ MPI_Ssend(NULL, 0, MPI_INT, dest, 10, comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/errors/pt2pt/errinstatwa.c b/test/mpi/errors/pt2pt/errinstatwa.c
index 99308e4..576ec1e 100644
--- a/test/mpi/errors/pt2pt/errinstatwa.c
+++ b/test/mpi/errors/pt2pt/errinstatwa.c
@@ -13,40 +13,40 @@ static char MTEST_Descrip[] = "Test err in status return, using truncated \
messages for MPI_Waitall";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
MPI_Comm comm;
MPI_Request r[2];
- MPI_Status s[2];
+ MPI_Status s[2];
int errval, errclass;
int b1[20], b2[20], rank, size, src, dest, i;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- /* Create some receive requests. tags 0-9 will succeed, tags 10-19
- will be used for ERR_TRUNCATE (fewer than 20 messages will be used) */
+ /* Create some receive requests. tags 0-9 will succeed, tags 10-19
+ * will be used for ERR_TRUNCATE (fewer than 20 messages will be used) */
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
- src = 1;
+ src = 1;
dest = 0;
if (rank == dest) {
- MPI_Errhandler_set( comm, MPI_ERRORS_RETURN );
- errval = MPI_Irecv( b1, 10, MPI_INT, src, 0, comm, &r[0] );
- if (errval) {
- errs++;
- MTestPrintError( errval );
- printf( "Error returned from Irecv\n" );
- }
- errval = MPI_Irecv( b2, 10, MPI_INT, src, 10, comm, &r[1] );
- if (errval) {
- errs++;
- MTestPrintError( errval );
- printf( "Error returned from Irecv\n" );
- }
+ MPI_Errhandler_set(comm, MPI_ERRORS_RETURN);
+ errval = MPI_Irecv(b1, 10, MPI_INT, src, 0, comm, &r[0]);
+ if (errval) {
+ errs++;
+ MTestPrintError(errval);
+ printf("Error returned from Irecv\n");
+ }
+ errval = MPI_Irecv(b2, 10, MPI_INT, src, 10, comm, &r[1]);
+ if (errval) {
+ errs++;
+ MTestPrintError(errval);
+ printf("Error returned from Irecv\n");
+ }
/* Wait for Irecvs to be posted before the sender calls send. This
* prevents the operation from completing and returning an error in the
@@ -54,59 +54,58 @@ int main( int argc, char *argv[] )
errval = MPI_Recv(NULL, 0, MPI_INT, src, 100, comm, MPI_STATUS_IGNORE);
if (errval) {
errs++;
- MTestPrintError( errval );
- printf( "Error returned from Recv\n" );
+ MTestPrintError(errval);
+ printf("Error returned from Recv\n");
}
- if (errval) {
- errs++;
- MTestPrintError( errval );
- printf( "Error returned from Barrier\n" );
- }
- for (i=0; i<2; i++) {
- s[i].MPI_ERROR = -1;
- }
- errval = MPI_Waitall( 2, r, s );
- MPI_Error_class( errval, &errclass );
- if (errclass != MPI_ERR_IN_STATUS) {
- errs++;
- printf( "Did not get ERR_IN_STATUS in Waitall\n" );
- }
- else {
- /* Check for success */
- /* We allow ERR_PENDING (neither completed nor in error) in case
- the MPI implementation exits the Waitall when an error
- is detected. Thanks to Jim Hoekstra of Iowa State University
- and Kim McMahon for finding this bug in the test. */
- for (i=0; i<2; i++) {
- if (s[i].MPI_TAG < 10 && (s[i].MPI_ERROR != MPI_SUCCESS &&
- s[i].MPI_ERROR != MPI_ERR_PENDING)) {
- char msg[MPI_MAX_ERROR_STRING];
- int msglen = MPI_MAX_ERROR_STRING;
- errs++;
- printf( "correct msg had error code %d\n",
- s[i].MPI_ERROR );
- MPI_Error_string( s[i].MPI_ERROR, msg, &msglen );
- printf( "Error message was %s\n", msg );
- }
- else if (s[i].MPI_TAG >= 10 && s[i].MPI_ERROR == MPI_SUCCESS) {
- errs++;
- printf( "truncated msg had MPI_SUCCESS\n" );
- }
- }
- }
+ if (errval) {
+ errs++;
+ MTestPrintError(errval);
+ printf("Error returned from Barrier\n");
+ }
+ for (i = 0; i < 2; i++) {
+ s[i].MPI_ERROR = -1;
+ }
+ errval = MPI_Waitall(2, r, s);
+ MPI_Error_class(errval, &errclass);
+ if (errclass != MPI_ERR_IN_STATUS) {
+ errs++;
+ printf("Did not get ERR_IN_STATUS in Waitall\n");
+ }
+ else {
+ /* Check for success */
+ /* We allow ERR_PENDING (neither completed nor in error) in case
+ * the MPI implementation exits the Waitall when an error
+ * is detected. Thanks to Jim Hoekstra of Iowa State University
+ * and Kim McMahon for finding this bug in the test. */
+ for (i = 0; i < 2; i++) {
+ if (s[i].MPI_TAG < 10 && (s[i].MPI_ERROR != MPI_SUCCESS &&
+ s[i].MPI_ERROR != MPI_ERR_PENDING)) {
+ char msg[MPI_MAX_ERROR_STRING];
+ int msglen = MPI_MAX_ERROR_STRING;
+ errs++;
+ printf("correct msg had error code %d\n", s[i].MPI_ERROR);
+ MPI_Error_string(s[i].MPI_ERROR, msg, &msglen);
+ printf("Error message was %s\n", msg);
+ }
+ else if (s[i].MPI_TAG >= 10 && s[i].MPI_ERROR == MPI_SUCCESS) {
+ errs++;
+ printf("truncated msg had MPI_SUCCESS\n");
+ }
+ }
+ }
}
else if (rank == src) {
/* Wait for Irecvs to be posted before the sender calls send */
- MPI_Ssend( NULL, 0, MPI_INT, dest, 100, comm );
+ MPI_Ssend(NULL, 0, MPI_INT, dest, 100, comm);
- MPI_Send( b1, 10, MPI_INT, dest, 0, comm );
- MPI_Send( b2, 11, MPI_INT, dest, 10, comm );
+ MPI_Send(b1, 10, MPI_INT, dest, 0, comm);
+ MPI_Send(b2, 11, MPI_INT, dest, 10, comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/errors/pt2pt/errinstatws.c b/test/mpi/errors/pt2pt/errinstatws.c
index 002d781..a32c630 100644
--- a/test/mpi/errors/pt2pt/errinstatws.c
+++ b/test/mpi/errors/pt2pt/errinstatws.c
@@ -13,41 +13,41 @@ static char MTEST_Descrip[] = "Test err in status return, using truncated \
messages for MPI_Waitsome";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
MPI_Comm comm;
MPI_Request r[2];
- MPI_Status s[2];
- int indices[2], outcount;
+ MPI_Status s[2];
+ int indices[2], outcount;
int errval, errclass;
int b1[20], b2[20], rank, size, src, dest, i, j;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- /* Create some receive requests. tags 0-9 will succeed, tags 10-19
- will be used for ERR_TRUNCATE (fewer than 20 messages will be used) */
+ /* Create some receive requests. tags 0-9 will succeed, tags 10-19
+ * will be used for ERR_TRUNCATE (fewer than 20 messages will be used) */
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
- src = 1;
+ src = 1;
dest = 0;
if (rank == dest) {
- MPI_Errhandler_set( comm, MPI_ERRORS_RETURN );
- errval = MPI_Irecv( b1, 10, MPI_INT, src, 0, comm, &r[0] );
- if (errval) {
- errs++;
- MTestPrintError( errval );
- printf( "Error returned from Irecv\n" );
- }
- errval = MPI_Irecv( b2, 10, MPI_INT, src, 10, comm, &r[1] );
- if (errval) {
- errs++;
- MTestPrintError( errval );
- printf( "Error returned from Irecv\n" );
- }
+ MPI_Errhandler_set(comm, MPI_ERRORS_RETURN);
+ errval = MPI_Irecv(b1, 10, MPI_INT, src, 0, comm, &r[0]);
+ if (errval) {
+ errs++;
+ MTestPrintError(errval);
+ printf("Error returned from Irecv\n");
+ }
+ errval = MPI_Irecv(b2, 10, MPI_INT, src, 10, comm, &r[1]);
+ if (errval) {
+ errs++;
+ MTestPrintError(errval);
+ printf("Error returned from Irecv\n");
+ }
/* Wait for Irecvs to be posted before the sender calls send. This
* prevents the operation from completing and returning an error in the
@@ -55,68 +55,67 @@ int main( int argc, char *argv[] )
errval = MPI_Recv(NULL, 0, MPI_INT, src, 100, comm, MPI_STATUS_IGNORE);
if (errval) {
errs++;
- MTestPrintError( errval );
- printf( "Error returned from Recv\n" );
+ MTestPrintError(errval);
+ printf("Error returned from Recv\n");
}
/* Wait for sends to complete at the sender before proceeding */
/* WARNING: This does not guarantee that the sends are ready to
* complete at the receiver. */
- errval = MPI_Recv(NULL, 0, MPI_INT, src, 10, comm, MPI_STATUS_IGNORE);
- if (errval) {
- errs++;
- MTestPrintError( errval );
- printf( "Error returned from Recv\n" );
- }
- for (i=0; i<2; i++) {
- s[i].MPI_ERROR = -1;
- }
+ errval = MPI_Recv(NULL, 0, MPI_INT, src, 10, comm, MPI_STATUS_IGNORE);
+ if (errval) {
+ errs++;
+ MTestPrintError(errval);
+ printf("Error returned from Recv\n");
+ }
+ for (i = 0; i < 2; i++) {
+ s[i].MPI_ERROR = -1;
+ }
/* WARNING: The following assumes that Waitsome will complete both
* send/irecv pairs. This is *not* guaranteed by the MPI standard. */
- errval = MPI_Waitsome( 2, r, &outcount, indices, s );
- MPI_Error_class( errval, &errclass );
- if (errclass != MPI_ERR_IN_STATUS) {
- errs++;
- printf( "Did not get ERR_IN_STATUS in Waitsome. Got %d.\n", errval );
- }
- else if (outcount != 2) {
- errs++;
- printf( "Wait returned outcount = %d\n", outcount );
- }
- else {
- /* Check for success */
- for (i=0; i<outcount; i++) {
- j = i;
- /* Indices is the request index */
- if (s[j].MPI_TAG < 10 && s[j].MPI_ERROR != MPI_SUCCESS) {
- errs++;
- printf( "correct msg had error class %d\n",
- s[j].MPI_ERROR );
- }
- else if (s[j].MPI_TAG >= 10 && s[j].MPI_ERROR == MPI_SUCCESS) {
- errs++;
- printf( "truncated msg had MPI_SUCCESS\n" );
- }
- }
- }
+ errval = MPI_Waitsome(2, r, &outcount, indices, s);
+ MPI_Error_class(errval, &errclass);
+ if (errclass != MPI_ERR_IN_STATUS) {
+ errs++;
+ printf("Did not get ERR_IN_STATUS in Waitsome. Got %d.\n", errval);
+ }
+ else if (outcount != 2) {
+ errs++;
+ printf("Wait returned outcount = %d\n", outcount);
+ }
+ else {
+ /* Check for success */
+ for (i = 0; i < outcount; i++) {
+ j = i;
+ /* Indices is the request index */
+ if (s[j].MPI_TAG < 10 && s[j].MPI_ERROR != MPI_SUCCESS) {
+ errs++;
+ printf("correct msg had error class %d\n", s[j].MPI_ERROR);
+ }
+ else if (s[j].MPI_TAG >= 10 && s[j].MPI_ERROR == MPI_SUCCESS) {
+ errs++;
+ printf("truncated msg had MPI_SUCCESS\n");
+ }
+ }
+ }
}
else if (rank == src) {
/* Wait for Irecvs to be posted before the sender calls send */
- MPI_Ssend( NULL, 0, MPI_INT, dest, 100, comm );
+ MPI_Ssend(NULL, 0, MPI_INT, dest, 100, comm);
- /* Send test messages, then send another message so that the test does
- not start until we are sure that the sends have begun */
- MPI_Send( b1, 10, MPI_INT, dest, 0, comm );
- MPI_Send( b2, 11, MPI_INT, dest, 10, comm );
+ /* Send test messages, then send another message so that the test does
+ * not start until we are sure that the sends have begun */
+ MPI_Send(b1, 10, MPI_INT, dest, 0, comm);
+ MPI_Send(b2, 11, MPI_INT, dest, 10, comm);
/* Wait for sends to complete before proceeding to the testsome. */
- MPI_Ssend( NULL, 0, MPI_INT, dest, 10, comm );
+ MPI_Ssend(NULL, 0, MPI_INT, dest, 10, comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/errors/pt2pt/proberank.c b/test/mpi/errors/pt2pt/proberank.c
index a8ca625..64726db 100644
--- a/test/mpi/errors/pt2pt/proberank.c
+++ b/test/mpi/errors/pt2pt/proberank.c
@@ -7,27 +7,27 @@
#include "mpi.h"
#include "mpitest.h"
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Status status;
- int err, errs = 0, len;
- char msg[MPI_MAX_ERROR_STRING];
+ int err, errs = 0, len;
+ char msg[MPI_MAX_ERROR_STRING];
- MTest_Init( &argc, &argv );
- MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ MTest_Init(&argc, &argv);
+ MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
- err = MPI_Probe( -80, 1, MPI_COMM_WORLD, &status );
+ err = MPI_Probe(-80, 1, MPI_COMM_WORLD, &status);
if (!err) {
- errs++;
- printf( "Did not detect an erroneous rank in MPI_Probe\n" );
+ errs++;
+ printf("Did not detect an erroneous rank in MPI_Probe\n");
}
else {
- /* Check that we can get a message for this error */
- /* (This works if it does not SEGV or hang) */
- MPI_Error_string( err, msg, &len );
+ /* Check that we can get a message for this error */
+ /* (This works if it does not SEGV or hang) */
+ MPI_Error_string(err, msg, &len);
}
- MTest_Finalize( errs );
- MPI_Finalize( );
+ MTest_Finalize(errs);
+ MPI_Finalize();
return 0;
}
diff --git a/test/mpi/errors/pt2pt/truncmsg1.c b/test/mpi/errors/pt2pt/truncmsg1.c
index f865f2d..02f579f 100644
--- a/test/mpi/errors/pt2pt/truncmsg1.c
+++ b/test/mpi/errors/pt2pt/truncmsg1.c
@@ -13,90 +13,83 @@
*/
static int testShort = 1;
-static int ShortLen = 2;
-static int testMid = 1;
-static int MidLen = 64;
-static int testLong = 1;
-static int LongLen = 100000;
+static int ShortLen = 2;
+static int testMid = 1;
+static int MidLen = 64;
+static int testLong = 1;
+static int LongLen = 100000;
-int checkTruncError( int err, const char *msg );
-int checkOk( int err, const char *msg );
+int checkTruncError(int err, const char *msg);
+int checkOk(int err, const char *msg);
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Status status;
- int err, errs = 0, source, dest, rank, size;
- int *buf = 0;
+ int err, errs = 0, source, dest, rank, size;
+ int *buf = 0;
- MTest_Init( &argc, &argv );
- MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ MTest_Init(&argc, &argv);
+ MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
source = 0;
- dest = size - 1;
+ dest = size - 1;
- buf = (int *)malloc( LongLen * sizeof(int) );
+ buf = (int *) malloc(LongLen * sizeof(int));
if (!buf) {
- fprintf( stderr, "Unable to allocate communication buffer of size %d\n",
- LongLen );
- MPI_Abort( MPI_COMM_WORLD, 1 ) ;
+ fprintf(stderr, "Unable to allocate communication buffer of size %d\n", LongLen);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
if (testShort) {
if (rank == source) {
- err = MPI_Send( buf, ShortLen, MPI_INT, dest, 0, MPI_COMM_WORLD );
- errs += checkOk( err, "short" );
- }
- else if (rank == dest) {
- err = MPI_Recv( buf, ShortLen-1, MPI_INT, source, 0,
- MPI_COMM_WORLD, &status );
- errs += checkTruncError( err, "short" );
- }
- /* Try a message that is arrives after the receive is posted */
- if (rank == source) {
- MPI_Sendrecv( MPI_BOTTOM, 0, MPI_INT, dest, 1,
- MPI_BOTTOM, 0, MPI_INT, dest, 1, MPI_COMM_WORLD,
- MPI_STATUS_IGNORE );
- MPI_Send( buf, ShortLen, MPI_INT, dest, 2, MPI_COMM_WORLD );
- }
- else if (rank == dest) {
- MPI_Request req;
- err = MPI_Irecv( buf, ShortLen - 1, MPI_INT, source, 2,
- MPI_COMM_WORLD, &req );
- errs += checkOk( err, "irecv-short" );
- MPI_Sendrecv( MPI_BOTTOM, 0, MPI_INT, source, 1,
- MPI_BOTTOM, 0, MPI_INT, source, 1, MPI_COMM_WORLD,
- MPI_STATUS_IGNORE );
- err = MPI_Wait( &req, &status );
- errs += checkTruncError( err, "irecv-short" );
- }
+ err = MPI_Send(buf, ShortLen, MPI_INT, dest, 0, MPI_COMM_WORLD);
+ errs += checkOk(err, "short");
+ }
+ else if (rank == dest) {
+ err = MPI_Recv(buf, ShortLen - 1, MPI_INT, source, 0, MPI_COMM_WORLD, &status);
+ errs += checkTruncError(err, "short");
+ }
+ /* Try a message that is arrives after the receive is posted */
+ if (rank == source) {
+ MPI_Sendrecv(MPI_BOTTOM, 0, MPI_INT, dest, 1,
+ MPI_BOTTOM, 0, MPI_INT, dest, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+ MPI_Send(buf, ShortLen, MPI_INT, dest, 2, MPI_COMM_WORLD);
+ }
+ else if (rank == dest) {
+ MPI_Request req;
+ err = MPI_Irecv(buf, ShortLen - 1, MPI_INT, source, 2, MPI_COMM_WORLD, &req);
+ errs += checkOk(err, "irecv-short");
+ MPI_Sendrecv(MPI_BOTTOM, 0, MPI_INT, source, 1,
+ MPI_BOTTOM, 0, MPI_INT, source, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+ err = MPI_Wait(&req, &status);
+ errs += checkTruncError(err, "irecv-short");
+ }
}
if (testMid) {
if (rank == source) {
- err = MPI_Send( buf, MidLen, MPI_INT, dest, 0, MPI_COMM_WORLD );
- errs += checkOk( err, "medium" );
- }
- else if (rank == dest) {
- err = MPI_Recv( buf, MidLen-1, MPI_INT, source, 0,
- MPI_COMM_WORLD, &status );
- errs += checkTruncError( err, "medium" );
- }
+ err = MPI_Send(buf, MidLen, MPI_INT, dest, 0, MPI_COMM_WORLD);
+ errs += checkOk(err, "medium");
+ }
+ else if (rank == dest) {
+ err = MPI_Recv(buf, MidLen - 1, MPI_INT, source, 0, MPI_COMM_WORLD, &status);
+ errs += checkTruncError(err, "medium");
+ }
}
if (testLong) {
if (rank == source) {
- err = MPI_Send( buf, LongLen, MPI_INT, dest, 0, MPI_COMM_WORLD );
- errs += checkOk( err, "long" );
- }
- else if (rank == dest) {
- err = MPI_Recv( buf, LongLen-1, MPI_INT, source, 0,
- MPI_COMM_WORLD, &status );
- errs += checkTruncError( err, "long" );
- }
+ err = MPI_Send(buf, LongLen, MPI_INT, dest, 0, MPI_COMM_WORLD);
+ errs += checkOk(err, "long");
+ }
+ else if (rank == dest) {
+ err = MPI_Recv(buf, LongLen - 1, MPI_INT, source, 0, MPI_COMM_WORLD, &status);
+ errs += checkTruncError(err, "long");
+ }
}
- free( buf );
- MTest_Finalize( errs );
+ free(buf);
+ MTest_Finalize(errs);
MPI_Finalize();
@@ -104,41 +97,37 @@ int main( int argc, char *argv[] )
}
-int checkTruncError( int err, const char *msg )
+int checkTruncError(int err, const char *msg)
{
char errMsg[MPI_MAX_ERROR_STRING];
int errs = 0, msgLen, errclass;
if (!err) {
- errs ++;
- fprintf( stderr,
- "MPI_Recv (%s) returned MPI_SUCCESS instead of truncated message\n",
- msg );
- fflush( stderr );
+ errs++;
+ fprintf(stderr, "MPI_Recv (%s) returned MPI_SUCCESS instead of truncated message\n", msg);
+ fflush(stderr);
}
else {
- MPI_Error_class( err, &errclass );
- if (errclass != MPI_ERR_TRUNCATE) {
- errs ++;
- MPI_Error_string( err, errMsg, &msgLen );
- fprintf( stderr,
- "MPI_Recv (%s) returned unexpected error message: %s\n",
- msg, errMsg );
- fflush( stderr );
- }
+ MPI_Error_class(err, &errclass);
+ if (errclass != MPI_ERR_TRUNCATE) {
+ errs++;
+ MPI_Error_string(err, errMsg, &msgLen);
+ fprintf(stderr, "MPI_Recv (%s) returned unexpected error message: %s\n", msg, errMsg);
+ fflush(stderr);
+ }
}
return errs;
}
-int checkOk( int err, const char *msg )
+int checkOk(int err, const char *msg)
{
char errMsg[MPI_MAX_ERROR_STRING];
int errs = 0, msgLen;
if (err) {
- errs ++;
- MPI_Error_string( err, errMsg, &msgLen );
- fprintf( stderr, "MPI_Send(%s) failed with %s\n", msg, errMsg );
- fflush( stderr );
+ errs++;
+ MPI_Error_string(err, errMsg, &msgLen);
+ fprintf(stderr, "MPI_Send(%s) failed with %s\n", msg, errMsg);
+ fflush(stderr);
}
return errs;
diff --git a/test/mpi/errors/pt2pt/truncmsg2.c b/test/mpi/errors/pt2pt/truncmsg2.c
index fc4b5f3..011fb0b 100644
--- a/test/mpi/errors/pt2pt/truncmsg2.c
+++ b/test/mpi/errors/pt2pt/truncmsg2.c
@@ -6,8 +6,8 @@
/*
* This program was sent in as an example that did not perform as expected.
* The program has a bug in that it is sending 3 characters but receiving
- * three integers, which is not a valid MPI program (the type signatures
- * must match). However, a good MPI implementation will handle this
+ * three integers, which is not a valid MPI program (the type signatures
+ * must match). However, a good MPI implementation will handle this
* gracefully, which is why this test is included in the error directory
*/
#include <stdio.h>
@@ -30,16 +30,16 @@ void if_error(const char *function, const char *data, int ret)
return;
if (data)
- printf("%s for %s returned %d (%#x)\n", function, data, ret,ret);
+ printf("%s for %s returned %d (%#x)\n", function, data, ret, ret);
else
printf("%s returned %d (%#x)\n", function, ret, ret);
exit(INTERNAL_ERROR);
}
-int main (int argc, char *argv[])
+int main(int argc, char *argv[])
{
- int ret,errs = 0;
+ int ret, errs = 0;
char *src, *sendrec;
int bufsize = BUFSIZE;
@@ -48,18 +48,18 @@ int main (int argc, char *argv[])
MPI_Status status;
int small_non_contig_struct_count = 3;
- int small_non_contig_struct_blocklens[] = {1, 1, 1};
- MPI_Aint small_non_contig_struct_disps[] = {0, 2, 4};
- MPI_Datatype small_non_contig_struct_types[] = {MPI_CHAR, MPI_CHAR,MPI_CHAR};
+ int small_non_contig_struct_blocklens[] = { 1, 1, 1 };
+ MPI_Aint small_non_contig_struct_disps[] = { 0, 2, 4 };
+ MPI_Datatype small_non_contig_struct_types[] = { MPI_CHAR, MPI_CHAR, MPI_CHAR };
MPI_Datatype small_non_contig_struct_type;
int contig_indexed_count = 3;
- int contig_indexed_blocklens[] = {1, 2, 1};
- int contig_indexed_indices[] = {4, 8, 16};
+ int contig_indexed_blocklens[] = { 1, 2, 1 };
+ int contig_indexed_indices[] = { 4, 8, 16 };
int contig_indexed_inner_type = MPI_INT;
int contig_indexed_type;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
ret = MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
ret = MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
@@ -69,18 +69,16 @@ int main (int argc, char *argv[])
}
ret = MPI_Type_struct(small_non_contig_struct_count,
- small_non_contig_struct_blocklens,
- small_non_contig_struct_disps,
- small_non_contig_struct_types,
- &small_non_contig_struct_type);
+ small_non_contig_struct_blocklens,
+ small_non_contig_struct_disps,
+ small_non_contig_struct_types, &small_non_contig_struct_type);
if_error("MPI_Type_struct", "small_non_contig_struct_type", ret);
ret = MPI_Type_commit(&small_non_contig_struct_type);
if_error("MPI_Type_commit", "small_non_contig_struct_type", ret);
- ret = MPI_Type_indexed(contig_indexed_count,contig_indexed_blocklens,
- contig_indexed_indices,contig_indexed_inner_type,
- &contig_indexed_type);
+ ret = MPI_Type_indexed(contig_indexed_count, contig_indexed_blocklens,
+ contig_indexed_indices, contig_indexed_inner_type, &contig_indexed_type);
if_error("MPI_Type_indexed", "contig_indexed_type", ret);
ret = MPI_Type_commit(&contig_indexed_type);
@@ -102,36 +100,35 @@ int main (int argc, char *argv[])
}
- for (i=0; i<bufsize; i++) {
- src[i] = (char) i+1;
+ for (i = 0; i < bufsize; i++) {
+ src[i] = (char) i + 1;
}
memset(sendrec, 0, bufsize);
MPI_Barrier(MPI_COMM_WORLD);
if (myrank == 1) {
- MPI_Send(src, 1, small_non_contig_struct_type, 0, 0xabc,MPI_COMM_WORLD);
- } else {
- MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
- ret = MPI_Recv(sendrec, 1, contig_indexed_type, 1, 0xabc,
- MPI_COMM_WORLD, &status);
- if (ret == MPI_SUCCESS) {
- printf( "MPI_Recv succeeded with non-matching datatype signature\n" );
- errs++;
- }
+ MPI_Send(src, 1, small_non_contig_struct_type, 0, 0xabc, MPI_COMM_WORLD);
+ }
+ else {
+ MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+ ret = MPI_Recv(sendrec, 1, contig_indexed_type, 1, 0xabc, MPI_COMM_WORLD, &status);
+ if (ret == MPI_SUCCESS) {
+ printf("MPI_Recv succeeded with non-matching datatype signature\n");
+ errs++;
+ }
}
MPI_Barrier(MPI_COMM_WORLD);
- MPI_Type_free( &small_non_contig_struct_type );
- MPI_Type_free( &contig_indexed_type );
+ MPI_Type_free(&small_non_contig_struct_type);
+ MPI_Type_free(&contig_indexed_type);
MPI_Free_mem(src);
MPI_Free_mem(sendrec);
- MTest_Finalize( errs );
- MPI_Finalize( );
+ MTest_Finalize(errs);
+ MPI_Finalize();
return 0;
}
-
diff --git a/test/mpi/errors/rma/cas_type_check.c b/test/mpi/errors/rma/cas_type_check.c
index d0993cb..eb0b1fb 100644
--- a/test/mpi/errors/rma/cas_type_check.c
+++ b/test/mpi/errors/rma/cas_type_check.c
@@ -18,74 +18,75 @@ do { \
\
val = cmp_val = buf = 0; \
\
- MPI_Win_create( &buf, sizeof(c_type), sizeof(c_type), \
- MPI_INFO_NULL, MPI_COMM_WORLD, &win ); \
+ MPI_Win_create(&buf, sizeof(c_type), sizeof(c_type), \
+ MPI_INFO_NULL, MPI_COMM_WORLD, &win); \
\
- MPI_Win_set_errhandler( win, MPI_ERRORS_RETURN ); \
+ MPI_Win_set_errhandler(win, MPI_ERRORS_RETURN); \
\
- MPI_Win_fence( MPI_MODE_NOPRECEDE, win ); \
+ MPI_Win_fence(MPI_MODE_NOPRECEDE, win); \
for (i = 0; i < 10000; i++) { \
- err = MPI_Compare_and_swap( &val, &cmp_val, &res, \
- mpi_type, 0, 0, win ); \
- MPI_Error_class( err, &err_class ); \
- assert( err_class == expected_err ); \
+ err = MPI_Compare_and_swap(&val, &cmp_val, &res, \
+ mpi_type, 0, 0, win); \
+ MPI_Error_class(err, &err_class); \
+ assert(err_class == expected_err); \
} \
- MPI_Win_fence( MPI_MODE_NOSUCCEED, win); \
+ MPI_Win_fence(MPI_MODE_NOSUCCEED, win); \
\
- MPI_Win_free( &win ); \
+ MPI_Win_free(&win); \
} while (0);
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
- int rank;
+ int rank;
MPI_Datatype my_int;
- MPI_Init( &argc, &argv );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+ MPI_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
/* C Integer */
- CAS_CHECK_TYPE(signed char, MPI_SIGNED_CHAR, MPI_SUCCESS);
- CAS_CHECK_TYPE(short, MPI_SHORT, MPI_SUCCESS);
- CAS_CHECK_TYPE(int, MPI_INT, MPI_SUCCESS);
- CAS_CHECK_TYPE(long, MPI_LONG, MPI_SUCCESS);
- CAS_CHECK_TYPE(long long, MPI_LONG_LONG, MPI_SUCCESS);
- CAS_CHECK_TYPE(unsigned char, MPI_UNSIGNED_CHAR, MPI_SUCCESS);
- CAS_CHECK_TYPE(unsigned short, MPI_UNSIGNED_SHORT, MPI_SUCCESS);
- CAS_CHECK_TYPE(unsigned, MPI_UNSIGNED, MPI_SUCCESS);
- CAS_CHECK_TYPE(unsigned long, MPI_UNSIGNED_LONG, MPI_SUCCESS);
- CAS_CHECK_TYPE(unsigned long long, MPI_UNSIGNED_LONG_LONG, MPI_SUCCESS);
+ CAS_CHECK_TYPE(signed char, MPI_SIGNED_CHAR, MPI_SUCCESS);
+ CAS_CHECK_TYPE(short, MPI_SHORT, MPI_SUCCESS);
+ CAS_CHECK_TYPE(int, MPI_INT, MPI_SUCCESS);
+ CAS_CHECK_TYPE(long, MPI_LONG, MPI_SUCCESS);
+ CAS_CHECK_TYPE(long long, MPI_LONG_LONG, MPI_SUCCESS);
+ CAS_CHECK_TYPE(unsigned char, MPI_UNSIGNED_CHAR, MPI_SUCCESS);
+ CAS_CHECK_TYPE(unsigned short, MPI_UNSIGNED_SHORT, MPI_SUCCESS);
+ CAS_CHECK_TYPE(unsigned, MPI_UNSIGNED, MPI_SUCCESS);
+ CAS_CHECK_TYPE(unsigned long, MPI_UNSIGNED_LONG, MPI_SUCCESS);
+ CAS_CHECK_TYPE(unsigned long long, MPI_UNSIGNED_LONG_LONG, MPI_SUCCESS);
/* Multilanguage Types */
- CAS_CHECK_TYPE(MPI_Aint, MPI_AINT, MPI_SUCCESS);
- CAS_CHECK_TYPE(MPI_Offset, MPI_OFFSET, MPI_SUCCESS);
- CAS_CHECK_TYPE(MPI_Count, MPI_COUNT, MPI_SUCCESS);
+ CAS_CHECK_TYPE(MPI_Aint, MPI_AINT, MPI_SUCCESS);
+ CAS_CHECK_TYPE(MPI_Offset, MPI_OFFSET, MPI_SUCCESS);
+ CAS_CHECK_TYPE(MPI_Count, MPI_COUNT, MPI_SUCCESS);
/* Byte */
- CAS_CHECK_TYPE(char, MPI_BYTE, MPI_SUCCESS);
+ CAS_CHECK_TYPE(char, MPI_BYTE, MPI_SUCCESS);
/* Logical */
- CAS_CHECK_TYPE(char, MPI_C_BOOL, MPI_SUCCESS);
+ CAS_CHECK_TYPE(char, MPI_C_BOOL, MPI_SUCCESS);
/* ERR: Derived datatypes */
MPI_Type_contiguous(sizeof(int), MPI_BYTE, &my_int);
MPI_Type_commit(&my_int);
- CAS_CHECK_TYPE(int, my_int, MPI_ERR_TYPE);
+ CAS_CHECK_TYPE(int, my_int, MPI_ERR_TYPE);
MPI_Type_free(&my_int);
/* ERR: Character types */
- CAS_CHECK_TYPE(char, MPI_CHAR, MPI_SUCCESS);
+ CAS_CHECK_TYPE(char, MPI_CHAR, MPI_SUCCESS);
/* ERR: Floating point */
- CAS_CHECK_TYPE(float, MPI_FLOAT, MPI_ERR_TYPE);
- CAS_CHECK_TYPE(double, MPI_DOUBLE, MPI_ERR_TYPE);
+ CAS_CHECK_TYPE(float, MPI_FLOAT, MPI_ERR_TYPE);
+ CAS_CHECK_TYPE(double, MPI_DOUBLE, MPI_ERR_TYPE);
#ifdef HAVE_LONG_DOUBLE
if (MPI_LONG_DOUBLE != MPI_DATATYPE_NULL) {
- CAS_CHECK_TYPE(long double, MPI_LONG_DOUBLE, MPI_ERR_TYPE);
+ CAS_CHECK_TYPE(long double, MPI_LONG_DOUBLE, MPI_ERR_TYPE);
}
#endif
- if (rank == 0) printf(" No Errors\n");
+ if (rank == 0)
+ printf(" No Errors\n");
MPI_Finalize();
return 0;
diff --git a/test/mpi/errors/rma/win_sync.h b/test/mpi/errors/rma/win_sync.h
index 803ccf5..0b7fc4c 100644
--- a/test/mpi/errors/rma/win_sync.h
+++ b/test/mpi/errors/rma/win_sync.h
@@ -8,7 +8,7 @@
#ifndef WIN_SYNC_H_INCLUDED
#define WIN_SYNC_H_INCLUDED
-#define CHECK_ERR( stmt ) \
+#define CHECK_ERR(stmt) \
do { \
int err_class, err, rank; \
MPI_Comm_rank(MPI_COMM_WORLD, &rank); \
@@ -17,7 +17,7 @@
printf("%d: Operation succeeded, when it should have failed\n", rank); \
errors++; \
} else { \
- MPI_Error_class( err, &err_class ); \
+ MPI_Error_class(err, &err_class); \
if (err_class != MPI_ERR_RMA_SYNC) { \
char str[MPI_MAX_ERROR_STRING]; \
int len; \
diff --git a/test/mpi/errors/rma/win_sync_complete.c b/test/mpi/errors/rma/win_sync_complete.c
index 8c1454c..ad52152 100644
--- a/test/mpi/errors/rma/win_sync_complete.c
+++ b/test/mpi/errors/rma/win_sync_complete.c
@@ -11,16 +11,15 @@
int main(int argc, char *argv[])
{
- int rank;
- int errors = 0, all_errors = 0;
- int buf;
- MPI_Win win;
+ int rank;
+ int errors = 0, all_errors = 0;
+ int buf;
+ MPI_Win win;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- MPI_Win_create(&buf, sizeof(int), sizeof(int),
- MPI_INFO_NULL, MPI_COMM_WORLD, &win);
+ MPI_Win_create(&buf, sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win);
MPI_Win_set_errhandler(win, MPI_ERRORS_RETURN);
@@ -31,7 +30,8 @@ int main(int argc, char *argv[])
MPI_Reduce(&errors, &all_errors, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
- if (rank == 0 && all_errors == 0) printf(" No Errors\n");
+ if (rank == 0 && all_errors == 0)
+ printf(" No Errors\n");
MPI_Finalize();
return 0;
diff --git a/test/mpi/errors/rma/win_sync_free_at.c b/test/mpi/errors/rma/win_sync_free_at.c
index b0195e1..971bac7 100644
--- a/test/mpi/errors/rma/win_sync_free_at.c
+++ b/test/mpi/errors/rma/win_sync_free_at.c
@@ -12,18 +12,17 @@
int main(int argc, char *argv[])
{
- int rank, nproc, i;
- int errors = 0, all_errors = 0;
- int buf, *my_buf;
- MPI_Win win;
- MPI_Group world_group;
+ int rank, nproc, i;
+ int errors = 0, all_errors = 0;
+ int buf, *my_buf;
+ MPI_Win win;
+ MPI_Group world_group;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &nproc);
- MPI_Win_create(&buf, sizeof(int), sizeof(int),
- MPI_INFO_NULL, MPI_COMM_WORLD, &win);
+ MPI_Win_create(&buf, sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win);
MPI_Win_set_errhandler(win, MPI_ERRORS_RETURN);
@@ -31,7 +30,7 @@ int main(int argc, char *argv[])
MPI_Win_post(world_group, 0, win);
MPI_Win_start(world_group, 0, win);
- my_buf = malloc(nproc*sizeof(int));
+ my_buf = malloc(nproc * sizeof(int));
for (i = 0; i < nproc; i++) {
MPI_Get(&my_buf[i], 1, MPI_INT, i, 0, 1, MPI_INT, win);
@@ -50,7 +49,8 @@ int main(int argc, char *argv[])
MPI_Reduce(&errors, &all_errors, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
- if (rank == 0 && all_errors == 0) printf(" No Errors\n");
+ if (rank == 0 && all_errors == 0)
+ printf(" No Errors\n");
MPI_Finalize();
return 0;
diff --git a/test/mpi/errors/rma/win_sync_free_pt.c b/test/mpi/errors/rma/win_sync_free_pt.c
index ca4bb8a..80007ad 100644
--- a/test/mpi/errors/rma/win_sync_free_pt.c
+++ b/test/mpi/errors/rma/win_sync_free_pt.c
@@ -11,16 +11,15 @@
int main(int argc, char *argv[])
{
- int rank;
- int errors = 0, all_errors = 0;
- int buf;
- MPI_Win win;
+ int rank;
+ int errors = 0, all_errors = 0;
+ int buf;
+ MPI_Win win;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- MPI_Win_create(&buf, sizeof(int), sizeof(int),
- MPI_INFO_NULL, MPI_COMM_WORLD, &win);
+ MPI_Win_create(&buf, sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win);
MPI_Win_set_errhandler(win, MPI_ERRORS_RETURN);
@@ -34,7 +33,8 @@ int main(int argc, char *argv[])
MPI_Reduce(&errors, &all_errors, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
- if (rank == 0 && all_errors == 0) printf(" No Errors\n");
+ if (rank == 0 && all_errors == 0)
+ printf(" No Errors\n");
MPI_Finalize();
return 0;
diff --git a/test/mpi/errors/rma/win_sync_lock_at.c b/test/mpi/errors/rma/win_sync_lock_at.c
index 0e2438f..2740038 100644
--- a/test/mpi/errors/rma/win_sync_lock_at.c
+++ b/test/mpi/errors/rma/win_sync_lock_at.c
@@ -12,18 +12,17 @@
int main(int argc, char *argv[])
{
- int rank, nproc, i;
- int errors = 0, all_errors = 0;
- int buf, *my_buf;
- MPI_Win win;
- MPI_Group world_group;
+ int rank, nproc, i;
+ int errors = 0, all_errors = 0;
+ int buf, *my_buf;
+ MPI_Win win;
+ MPI_Group world_group;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &nproc);
- MPI_Win_create(&buf, sizeof(int), sizeof(int),
- MPI_INFO_NULL, MPI_COMM_WORLD, &win);
+ MPI_Win_create(&buf, sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win);
MPI_Win_set_errhandler(win, MPI_ERRORS_RETURN);
@@ -31,7 +30,7 @@ int main(int argc, char *argv[])
MPI_Win_post(world_group, 0, win);
MPI_Win_start(world_group, 0, win);
- my_buf = malloc(nproc*sizeof(int));
+ my_buf = malloc(nproc * sizeof(int));
for (i = 0; i < nproc; i++) {
MPI_Get(&my_buf[i], 1, MPI_INT, i, 0, 1, MPI_INT, win);
@@ -50,7 +49,8 @@ int main(int argc, char *argv[])
MPI_Reduce(&errors, &all_errors, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
- if (rank == 0 && all_errors == 0) printf(" No Errors\n");
+ if (rank == 0 && all_errors == 0)
+ printf(" No Errors\n");
MPI_Finalize();
return 0;
diff --git a/test/mpi/errors/rma/win_sync_lock_fence.c b/test/mpi/errors/rma/win_sync_lock_fence.c
index 8d9ff2b..65ab791 100644
--- a/test/mpi/errors/rma/win_sync_lock_fence.c
+++ b/test/mpi/errors/rma/win_sync_lock_fence.c
@@ -12,17 +12,16 @@
int main(int argc, char *argv[])
{
- int rank, nproc;
- int errors = 0, all_errors = 0;
- int buf, my_buf;
- MPI_Win win;
+ int rank, nproc;
+ int errors = 0, all_errors = 0;
+ int buf, my_buf;
+ MPI_Win win;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &nproc);
- MPI_Win_create(&buf, sizeof(int), sizeof(int),
- MPI_INFO_NULL, MPI_COMM_WORLD, &win);
+ MPI_Win_create(&buf, sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win);
MPI_Win_set_errhandler(win, MPI_ERRORS_RETURN);
@@ -40,7 +39,8 @@ int main(int argc, char *argv[])
MPI_Reduce(&errors, &all_errors, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
- if (rank == 0 && all_errors == 0) printf(" No Errors\n");
+ if (rank == 0 && all_errors == 0)
+ printf(" No Errors\n");
MPI_Finalize();
return 0;
diff --git a/test/mpi/errors/rma/win_sync_lock_pt.c b/test/mpi/errors/rma/win_sync_lock_pt.c
index 834407e..f982e88 100644
--- a/test/mpi/errors/rma/win_sync_lock_pt.c
+++ b/test/mpi/errors/rma/win_sync_lock_pt.c
@@ -11,16 +11,15 @@
int main(int argc, char *argv[])
{
- int rank;
- int errors = 0, all_errors = 0;
- int buf;
- MPI_Win win;
+ int rank;
+ int errors = 0, all_errors = 0;
+ int buf;
+ MPI_Win win;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- MPI_Win_create(&buf, sizeof(int), sizeof(int),
- MPI_INFO_NULL, MPI_COMM_WORLD, &win);
+ MPI_Win_create(&buf, sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win);
MPI_Win_set_errhandler(win, MPI_ERRORS_RETURN);
@@ -34,7 +33,8 @@ int main(int argc, char *argv[])
MPI_Reduce(&errors, &all_errors, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
- if (rank == 0 && all_errors == 0) printf(" No Errors\n");
+ if (rank == 0 && all_errors == 0)
+ printf(" No Errors\n");
MPI_Finalize();
return 0;
diff --git a/test/mpi/errors/rma/win_sync_nested.c b/test/mpi/errors/rma/win_sync_nested.c
index 7e837c0..48c2fff 100644
--- a/test/mpi/errors/rma/win_sync_nested.c
+++ b/test/mpi/errors/rma/win_sync_nested.c
@@ -12,18 +12,17 @@
int main(int argc, char *argv[])
{
- int rank, nproc, i;
- int errors = 0, all_errors = 0;
- int buf, *my_buf;
- MPI_Win win;
- MPI_Group world_group;
+ int rank, nproc, i;
+ int errors = 0, all_errors = 0;
+ int buf, *my_buf;
+ MPI_Win win;
+ MPI_Group world_group;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &nproc);
- MPI_Win_create(&buf, sizeof(int), sizeof(int),
- MPI_INFO_NULL, MPI_COMM_WORLD, &win);
+ MPI_Win_create(&buf, sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win);
MPI_Win_set_errhandler(win, MPI_ERRORS_RETURN);
@@ -31,7 +30,7 @@ int main(int argc, char *argv[])
MPI_Win_post(world_group, 0, win);
MPI_Win_start(world_group, 0, win);
- my_buf = malloc(nproc*sizeof(int));
+ my_buf = malloc(nproc * sizeof(int));
for (i = 0; i < nproc; i++) {
MPI_Get(&my_buf[i], 1, MPI_INT, i, 0, 1, MPI_INT, win);
@@ -53,7 +52,8 @@ int main(int argc, char *argv[])
MPI_Reduce(&errors, &all_errors, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
- if (rank == 0 && all_errors == 0) printf(" No Errors\n");
+ if (rank == 0 && all_errors == 0)
+ printf(" No Errors\n");
MPI_Finalize();
return 0;
diff --git a/test/mpi/errors/rma/win_sync_op.c b/test/mpi/errors/rma/win_sync_op.c
index 2ad2c17..69760f9 100644
--- a/test/mpi/errors/rma/win_sync_op.c
+++ b/test/mpi/errors/rma/win_sync_op.c
@@ -12,17 +12,16 @@
int main(int argc, char *argv[])
{
- int rank, nproc;
- int errors = 0, all_errors = 0;
- int buf, my_buf;
- MPI_Win win;
+ int rank, nproc;
+ int errors = 0, all_errors = 0;
+ int buf, my_buf;
+ MPI_Win win;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &nproc);
- MPI_Win_create(&buf, sizeof(int), sizeof(int),
- MPI_INFO_NULL, MPI_COMM_WORLD, &win);
+ MPI_Win_create(&buf, sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win);
MPI_Win_set_errhandler(win, MPI_ERRORS_RETURN);
@@ -33,7 +32,8 @@ int main(int argc, char *argv[])
MPI_Reduce(&errors, &all_errors, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
- if (rank == 0 && all_errors == 0) printf(" No Errors\n");
+ if (rank == 0 && all_errors == 0)
+ printf(" No Errors\n");
MPI_Finalize();
return 0;
diff --git a/test/mpi/errors/rma/win_sync_unlock.c b/test/mpi/errors/rma/win_sync_unlock.c
index 3b1c24e..ec1ad30 100644
--- a/test/mpi/errors/rma/win_sync_unlock.c
+++ b/test/mpi/errors/rma/win_sync_unlock.c
@@ -11,16 +11,15 @@
int main(int argc, char *argv[])
{
- int rank;
- int errors = 0, all_errors = 0;
- int buf;
- MPI_Win win;
+ int rank;
+ int errors = 0, all_errors = 0;
+ int buf;
+ MPI_Win win;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- MPI_Win_create(&buf, sizeof(int), sizeof(int),
- MPI_INFO_NULL, MPI_COMM_WORLD, &win);
+ MPI_Win_create(&buf, sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win);
MPI_Win_set_errhandler(win, MPI_ERRORS_RETURN);
@@ -31,7 +30,8 @@ int main(int argc, char *argv[])
MPI_Reduce(&errors, &all_errors, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
- if (rank == 0 && all_errors == 0) printf(" No Errors\n");
+ if (rank == 0 && all_errors == 0)
+ printf(" No Errors\n");
MPI_Finalize();
return 0;
diff --git a/test/mpi/errors/rma/winerr.c b/test/mpi/errors/rma/winerr.c
index 22b931f..ed016e6 100644
--- a/test/mpi/errors/rma/winerr.c
+++ b/test/mpi/errors/rma/winerr.c
@@ -16,67 +16,65 @@ static int errs = 0;
static MPI_Win mywin;
static int expected_err_class = MPI_ERR_OTHER;
-void weh( MPI_Win *win, int *err, ... );
-void weh( MPI_Win *win, int *err, ... )
+void weh(MPI_Win * win, int *err, ...);
+void weh(MPI_Win * win, int *err, ...)
{
int errclass;
- MPI_Error_class( *err, &errclass );
+ MPI_Error_class(*err, &errclass);
if (errclass != expected_err_class) {
- errs++;
- printf( "Unexpected error code (class = %d)\n", errclass );
+ errs++;
+ printf("Unexpected error code (class = %d)\n", errclass);
}
if (*win != mywin) {
- errs++;
- printf( "Unexpected window (got %x expected %x)\n",
- (int)*win, (int)mywin );
+ errs++;
+ printf("Unexpected window (got %x expected %x)\n", (int) *win, (int) mywin);
}
calls++;
return;
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int err;
int buf[2];
- MPI_Win win;
- MPI_Comm comm;
+ MPI_Win win;
+ MPI_Comm comm;
MPI_Errhandler newerr, olderr;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Win_create_errhandler( weh, &newerr );
+ MPI_Win_create_errhandler(weh, &newerr);
+
+ MPI_Win_create(buf, 2 * sizeof(int), sizeof(int), MPI_INFO_NULL, comm, &win);
- MPI_Win_create( buf, 2*sizeof(int), sizeof(int),
- MPI_INFO_NULL, comm, &win );
-
mywin = win;
- MPI_Win_get_errhandler( win, &olderr );
+ MPI_Win_get_errhandler(win, &olderr);
if (olderr != MPI_ERRORS_ARE_FATAL) {
- errs++;
- printf( "Expected errors are fatal\n" );
+ errs++;
+ printf("Expected errors are fatal\n");
}
- MPI_Win_set_errhandler( win, newerr );
-
+ MPI_Win_set_errhandler(win, newerr);
+
expected_err_class = MPI_ERR_RANK;
- err = MPI_Put( buf, 1, MPI_INT, -5, 0, 1, MPI_INT, win );
+ err = MPI_Put(buf, 1, MPI_INT, -5, 0, 1, MPI_INT, win);
if (calls != 1) {
- errs ++;
- printf( "newerr not called\n" );
- calls = 1;
+ errs++;
+ printf("newerr not called\n");
+ calls = 1;
}
expected_err_class = MPI_ERR_OTHER;
- MPI_Win_call_errhandler( win, MPI_ERR_OTHER );
+ MPI_Win_call_errhandler(win, MPI_ERR_OTHER);
if (calls != 2) {
- errs ++;
- printf( "newerr not called (2)\n" );
+ errs++;
+ printf("newerr not called (2)\n");
}
- MPI_Win_free( &win );
- MPI_Errhandler_free( &newerr );
-
- MTest_Finalize( errs );
+ MPI_Win_free(&win);
+ MPI_Errhandler_free(&newerr);
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/errors/rma/winerr2.c b/test/mpi/errors/rma/winerr2.c
index 8e3da94..6f0b585 100644
--- a/test/mpi/errors/rma/winerr2.c
+++ b/test/mpi/errors/rma/winerr2.c
@@ -20,118 +20,115 @@ static int expected_err_class = MPI_ERR_OTHER;
static int w1Called = 0;
static int w2Called = 0;
-void weh1( MPI_Win *win, int *err, ... );
-void weh1( MPI_Win *win, int *err, ... )
+void weh1(MPI_Win * win, int *err, ...);
+void weh1(MPI_Win * win, int *err, ...)
{
int errclass;
- w1Called ++;
- MPI_Error_class( *err, &errclass );
+ w1Called++;
+ MPI_Error_class(*err, &errclass);
if (errclass != expected_err_class) {
- errs++;
- printf( "Unexpected error code (class = %d)\n", errclass );
+ errs++;
+ printf("Unexpected error code (class = %d)\n", errclass);
}
if (*win != mywin) {
- errs++;
- printf( "Unexpected window (got %x expected %x)\n",
- (int)*win, (int)mywin );
+ errs++;
+ printf("Unexpected window (got %x expected %x)\n", (int) *win, (int) mywin);
}
calls++;
return;
}
-void weh2( MPI_Win *win, int *err, ... );
-void weh2( MPI_Win *win, int *err, ... )
+void weh2(MPI_Win * win, int *err, ...);
+void weh2(MPI_Win * win, int *err, ...)
{
int errclass;
- w2Called ++;
- MPI_Error_class( *err, &errclass );
+ w2Called++;
+ MPI_Error_class(*err, &errclass);
if (errclass != expected_err_class) {
- errs++;
- printf( "Unexpected error code (class = %d)\n", errclass );
+ errs++;
+ printf("Unexpected error code (class = %d)\n", errclass);
}
if (*win != mywin) {
- errs++;
- printf( "Unexpected window (got %x expected %x)\n",
- (int)*win, (int)mywin );
+ errs++;
+ printf("Unexpected window (got %x expected %x)\n", (int) *win, (int) mywin);
}
calls++;
return;
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int err;
int buf[2];
- MPI_Win win;
- MPI_Comm comm;
+ MPI_Win win;
+ MPI_Comm comm;
MPI_Errhandler newerr1, newerr2, olderr;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Win_create_errhandler( weh1, &newerr1 );
- MPI_Win_create_errhandler( weh2, &newerr2 );
+ MPI_Win_create_errhandler(weh1, &newerr1);
+ MPI_Win_create_errhandler(weh2, &newerr2);
+
+ MPI_Win_create(buf, 2 * sizeof(int), sizeof(int), MPI_INFO_NULL, comm, &win);
- MPI_Win_create( buf, 2*sizeof(int), sizeof(int),
- MPI_INFO_NULL, comm, &win );
-
mywin = win;
- MPI_Win_get_errhandler( win, &olderr );
+ MPI_Win_get_errhandler(win, &olderr);
if (olderr != MPI_ERRORS_ARE_FATAL) {
- errs++;
- printf( "Expected errors are fatal\n" );
+ errs++;
+ printf("Expected errors are fatal\n");
}
- MPI_Win_set_errhandler( win, newerr1 );
+ MPI_Win_set_errhandler(win, newerr1);
/* We should be able to free the error handler now since the window is
- using it */
- MPI_Errhandler_free( &newerr1 );
-
+ * using it */
+ MPI_Errhandler_free(&newerr1);
+
expected_err_class = MPI_ERR_RANK;
- err = MPI_Put( buf, 1, MPI_INT, -5, 0, 1, MPI_INT, win );
+ err = MPI_Put(buf, 1, MPI_INT, -5, 0, 1, MPI_INT, win);
if (w1Called != 1) {
- errs ++;
- printf( "newerr1 not called\n" );
- w1Called = 1;
+ errs++;
+ printf("newerr1 not called\n");
+ w1Called = 1;
}
expected_err_class = MPI_ERR_OTHER;
- MPI_Win_call_errhandler( win, MPI_ERR_OTHER );
+ MPI_Win_call_errhandler(win, MPI_ERR_OTHER);
if (w1Called != 2) {
- errs ++;
- printf( "newerr1 not called (2)\n" );
+ errs++;
+ printf("newerr1 not called (2)\n");
}
if (w1Called != 2 || w2Called != 0) {
- errs++;
- printf( "Error handler weh1 not called the expected number of times\n" );
+ errs++;
+ printf("Error handler weh1 not called the expected number of times\n");
}
- /* Try another error handler. This should allow the MPI implementation to
- free the first error handler */
- MPI_Win_set_errhandler( win, newerr2 );
- MPI_Errhandler_free( &newerr2 );
-
+ /* Try another error handler. This should allow the MPI implementation to
+ * free the first error handler */
+ MPI_Win_set_errhandler(win, newerr2);
+ MPI_Errhandler_free(&newerr2);
+
expected_err_class = MPI_ERR_RANK;
- err = MPI_Put( buf, 1, MPI_INT, -5, 0, 1, MPI_INT, win );
+ err = MPI_Put(buf, 1, MPI_INT, -5, 0, 1, MPI_INT, win);
if (w2Called != 1) {
- errs ++;
- printf( "newerr2 not called\n" );
- calls = 1;
+ errs++;
+ printf("newerr2 not called\n");
+ calls = 1;
}
expected_err_class = MPI_ERR_OTHER;
- MPI_Win_call_errhandler( win, MPI_ERR_OTHER );
+ MPI_Win_call_errhandler(win, MPI_ERR_OTHER);
if (w2Called != 2) {
- errs ++;
- printf( "newerr2 not called (2)\n" );
+ errs++;
+ printf("newerr2 not called (2)\n");
}
if (w1Called != 2 || w2Called != 2) {
- errs++;
- printf( "Error handler weh1 not called the expected number of times\n" );
+ errs++;
+ printf("Error handler weh1 not called the expected number of times\n");
}
- MPI_Win_free( &win );
-
- MTest_Finalize( errs );
+ MPI_Win_free(&win);
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/errors/spawn/badport.c b/test/mpi/errors/spawn/badport.c
index 3a9e6b1..7493095 100644
--- a/test/mpi/errors/spawn/badport.c
+++ b/test/mpi/errors/spawn/badport.c
@@ -10,37 +10,36 @@
/* Set verbose to 1 to see the error message */
static int verbose = 0;
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
- int ierr, errs=0;
+ int ierr, errs = 0;
MPI_Comm newcomm = MPI_COMM_NULL;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
- ierr = MPI_Comm_connect( (char*)"myhost:27", MPI_INFO_NULL, 0,
- MPI_COMM_WORLD, &newcomm );
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+ ierr = MPI_Comm_connect((char *) "myhost:27", MPI_INFO_NULL, 0, MPI_COMM_WORLD, &newcomm);
if (ierr == MPI_SUCCESS) {
- errs++;
- printf( "Comm_connect returned success with bogus port\n" );
- MPI_Comm_free( &newcomm );
+ errs++;
+ printf("Comm_connect returned success with bogus port\n");
+ MPI_Comm_free(&newcomm);
}
else {
- if (verbose) {
- char str[MPI_MAX_ERROR_STRING];
- int slen;
- /* Check the message */
- MPI_Error_string( ierr, str, &slen );
- printf( "Error message is: %s\n", str );
- }
- if (newcomm != MPI_COMM_NULL) {
- errs++;
- printf( "Comm_connect returned a communicator even with an error\n" );
- }
+ if (verbose) {
+ char str[MPI_MAX_ERROR_STRING];
+ int slen;
+ /* Check the message */
+ MPI_Error_string(ierr, str, &slen);
+ printf("Error message is: %s\n", str);
+ }
+ if (newcomm != MPI_COMM_NULL) {
+ errs++;
+ printf("Comm_connect returned a communicator even with an error\n");
+ }
}
fflush(stdout);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
diff --git a/test/mpi/errors/spawn/lookup_name.c b/test/mpi/errors/spawn/lookup_name.c
index 65f759c..6121493 100644
--- a/test/mpi/errors/spawn/lookup_name.c
+++ b/test/mpi/errors/spawn/lookup_name.c
@@ -10,25 +10,25 @@
#include "mpitest.h"
/* calling lookup_name 15 times in a loop when the name has not been
- been published used to cause MPICH to crash. Adding this as a
+ been published used to cause MPICH to crash. Adding this as a
regression test */
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, i;
char port_name[MPI_MAX_PORT_NAME], serv_name[256];
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- strcpy( serv_name, "MyTest" );
+ strcpy(serv_name, "MyTest");
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
- for (i=0; i<20; i++)
- MPI_Lookup_name(serv_name, MPI_INFO_NULL, port_name);
+ for (i = 0; i < 20; i++)
+ MPI_Lookup_name(serv_name, MPI_INFO_NULL, port_name);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/errors/spawn/unpub.c b/test/mpi/errors/spawn/unpub.c
index d770512..66963ee 100644
--- a/test/mpi/errors/spawn/unpub.c
+++ b/test/mpi/errors/spawn/unpub.c
@@ -9,29 +9,29 @@
#include <string.h>
#include "mpitest.h"
-/* calling MPI_Unpublish_name before calling MPI_Publish_name
- (a user error) would cause the process manager to die. This is
+/* calling MPI_Unpublish_name before calling MPI_Publish_name
+ (a user error) would cause the process manager to die. This is
added as a regression test so that it doesn't happen in the future. */
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int rc, errclass, errs = 0;
char port_name[MPI_MAX_PORT_NAME], serv_name[256];
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- strcpy( port_name, "otherhost:122" );
- strcpy( serv_name, "MyTest" );
+ strcpy(port_name, "otherhost:122");
+ strcpy(serv_name, "MyTest");
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
- rc = MPI_Unpublish_name( serv_name, MPI_INFO_NULL, port_name );
+ rc = MPI_Unpublish_name(serv_name, MPI_INFO_NULL, port_name);
MPI_Error_class(rc, &errclass);
if (errclass != MPI_ERR_SERVICE)
++errs;
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/errors/topo/cartsmall.c b/test/mpi/errors/topo/cartsmall.c
index bc7873c..ddcdd2e 100644
--- a/test/mpi/errors/topo/cartsmall.c
+++ b/test/mpi/errors/topo/cartsmall.c
@@ -8,38 +8,38 @@
#include <stdio.h>
#include "mpitest.h"
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
- int errs = 0, err;
- int dims[2];
- int periods[2];
- int size, rank;
+ int errs = 0, err;
+ int dims[2];
+ int periods[2];
+ int size, rank;
MPI_Comm comm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Comm_size( MPI_COMM_WORLD, &size );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
-
- dims[0] = size;
- dims[1] = size;
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+
+ dims[0] = size;
+ dims[1] = size;
periods[0] = 0;
periods[1] = 0;
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
- err = MPI_Cart_create( MPI_COMM_WORLD, 2, dims, periods, 0, &comm );
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+ err = MPI_Cart_create(MPI_COMM_WORLD, 2, dims, periods, 0, &comm);
if (err == MPI_SUCCESS) {
- errs++;
- printf( "Cart_create returned success when dims > size\n" );
+ errs++;
+ printf("Cart_create returned success when dims > size\n");
}
else if (comm != MPI_COMM_NULL) {
- errs++;
- printf( "Expected a null comm from cart create\n" );
+ errs++;
+ printf("Expected a null comm from cart create\n");
}
- MTest_Finalize( errs );
-
+ MTest_Finalize(errs);
+
MPI_Finalize();
-
+
return 0;
}
diff --git a/test/mpi/f08/attr/attrlangc.c b/test/mpi/f08/attr/attrlangc.c
index a228b13..f12e6d6 100644
--- a/test/mpi/f08/attr/attrlangc.c
+++ b/test/mpi/f08/attr/attrlangc.c
@@ -75,119 +75,121 @@ static int ccomm1Extra, ccomm2Extra, ctype2Extra, cwin2Extra;
static int verbose = 0;
/* Forward references */
-int cmpi1read( MPI_Comm comm, int key, void *expected, const char *msg );
-int cmpi2read( MPI_Comm comm, int key, void *expected, const char *msg );
-int cmpi2readtype( MPI_Datatype dtype, int key, void *expected, const char *msg );
+int cmpi1read(MPI_Comm comm, int key, void *expected, const char *msg);
+int cmpi2read(MPI_Comm comm, int key, void *expected, const char *msg);
+int cmpi2readtype(MPI_Datatype dtype, int key, void *expected, const char *msg);
-void ccompareint2aint_( MPI_Fint *in1, MPI_Aint *in2, MPI_Fint *result );
-void ccompareint2void_( MPI_Fint *in1, void *in2, MPI_Fint *result );
-void ccompareaint2void_( MPI_Aint *in1, void *in2, MPI_Fint *result );
+void ccompareint2aint_(MPI_Fint * in1, MPI_Aint * in2, MPI_Fint * result);
+void ccompareint2void_(MPI_Fint * in1, void *in2, MPI_Fint * result);
+void ccompareaint2void_(MPI_Aint * in1, void *in2, MPI_Fint * result);
/* ----------------------------------------------------------------------- */
/* Initialization functions */
/* ----------------------------------------------------------------------- */
-void cgetenvbool_( const char str[], MPI_Fint *val, int d )
+void cgetenvbool_(const char str[], MPI_Fint * val, int d)
{
const char *envval;
- char envname[1024];
+ char envname[1024];
/* Note that the Fortran string may not be null terminated; thus
- we copy d characters and add a null just in case */
- if (d > sizeof(envname)-1) {
- fprintf( stderr, "Environment variable name too long (%d)\n", d );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ * we copy d characters and add a null just in case */
+ if (d > sizeof(envname) - 1) {
+ fprintf(stderr, "Environment variable name too long (%d)\n", d);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- strncpy( envname, str, d );
+ strncpy(envname, str, d);
envname[d] = 0;
- envval = getenv( envname );
+ envval = getenv(envname);
*val = 0;
if (envval) {
- printf( " envval = %s\n", envval );
- if (strcmp(envval,"yes") == 0 || strcmp(envval,"YES") == 0 ||
- strcmp(envval,"true") == 0 || strcmp(envval,"TRUE") == 0 )
- *val = 1;
+ printf(" envval = %s\n", envval);
+ if (strcmp(envval, "yes") == 0 || strcmp(envval, "YES") == 0 ||
+ strcmp(envval, "true") == 0 || strcmp(envval, "TRUE") == 0)
+ *val = 1;
}
}
/* Keep our own copy of the "is verbose" state */
-void cattrinit_( MPI_Fint *fverbose )
+void cattrinit_(MPI_Fint * fverbose)
{
- verbose = (int)*fverbose;
+ verbose = (int) *fverbose;
}
/* Provide attribute sizes (C, Fortran 1, Fortran 2) */
-void cgetsizes_( MPI_Fint *ptrSize, MPI_Fint *intSize, MPI_Fint *aintSize )
+void cgetsizes_(MPI_Fint * ptrSize, MPI_Fint * intSize, MPI_Fint * aintSize)
{
- *ptrSize = (MPI_Fint) sizeof(void*);
- *intSize = (MPI_Fint) sizeof(MPI_Fint);
+ *ptrSize = (MPI_Fint) sizeof(void *);
+ *intSize = (MPI_Fint) sizeof(MPI_Fint);
*aintSize = (MPI_Fint) sizeof(MPI_Aint);
}
/* ----------------------------------------------------------------------- */
/* Copy and delete functions attached to keyvals */
/* ----------------------------------------------------------------------- */
-static int CMPI1_COPY_FN( MPI_Comm comm, int keyval, void *extra,
- void *inval, void *outval, int *flag )
+static int CMPI1_COPY_FN(MPI_Comm comm, int keyval, void *extra,
+ void *inval, void *outval, int *flag)
{
- int inValue = *(int *)inval;
+ int inValue = *(int *) inval;
- if (verbose) printf( " In C MPI-1 copy function: inval = %p, extra = %p\n",
- inval, extra );
+ if (verbose)
+ printf(" In C MPI-1 copy function: inval = %p, extra = %p\n", inval, extra);
*flag = 1;
/* We don't change the attribute */
- *(void **)outval = inval;
+ *(void **) outval = inval;
/* But we do change what it points at */
- *(int*)inval = inValue + 1;
+ *(int *) inval = inValue + 1;
return MPI_SUCCESS;
}
-static int CMPI1_DELETE_FN( MPI_Comm comm, int keyval, void *outval,
- void *extra )
+
+static int CMPI1_DELETE_FN(MPI_Comm comm, int keyval, void *outval, void *extra)
{
- if (verbose) printf( " In C MPI-1 delete function, extra = %p\n", extra );
- *(int*)outval = *(int*)outval - 1;
+ if (verbose)
+ printf(" In C MPI-1 delete function, extra = %p\n", extra);
+ *(int *) outval = *(int *) outval - 1;
return MPI_SUCCESS;
}
-static int TYPE_COPY_FN( MPI_Datatype dtype, int keyval, void *extra,
- void *inval, void *outval, int *flag )
+static int TYPE_COPY_FN(MPI_Datatype dtype, int keyval, void *extra,
+ void *inval, void *outval, int *flag)
{
- int inValue = *(int *)inval;
+ int inValue = *(int *) inval;
if (verbose)
- printf( " In C MPI type copy function, inval = %p, extra = %p\n",
- inval, extra );
+ printf(" In C MPI type copy function, inval = %p, extra = %p\n", inval, extra);
*flag = 1;
/* We don't change the attribute */
- *(void **)outval = inval;
+ *(void **) outval = inval;
/* But we do change what it points at */
- *(int*)inval = inValue + 1;
+ *(int *) inval = inValue + 1;
return MPI_SUCCESS;
}
-static int TYPE_DELETE_FN( MPI_Datatype dtype, int keyval, void *outval,
- void *extra )
+
+static int TYPE_DELETE_FN(MPI_Datatype dtype, int keyval, void *outval, void *extra)
{
- if (verbose) printf( " In C MPI type delete function, extra = %p\n", extra );
+ if (verbose)
+ printf(" In C MPI type delete function, extra = %p\n", extra);
/* We reverse the incrment used in copy (checked after free of the type) */
- *(int*)outval = *(int*)outval - 1;
+ *(int *) outval = *(int *) outval - 1;
return MPI_SUCCESS;
}
/* Note that this function cannot be called in MPI since there is no
win_dup function */
-static int WIN_COPY_FN( MPI_Win win, int keyval, void *extra,
- void *inval, void *outval, int *flag )
+static int WIN_COPY_FN(MPI_Win win, int keyval, void *extra, void *inval, void *outval, int *flag)
{
- int inValue = *(int *)inval;
+ int inValue = *(int *) inval;
- if (verbose) printf( "PANIC: In C MPI win copy function (should never happen)\n" );
+ if (verbose)
+ printf("PANIC: In C MPI win copy function (should never happen)\n");
*flag = 1;
return MPI_SUCCESS;
}
-static int WIN_DELETE_FN( MPI_Win win, int keyval, void *outval,
- void *extra )
+
+static int WIN_DELETE_FN(MPI_Win win, int keyval, void *outval, void *extra)
{
- if (verbose) printf( " In C MPI win delete function, extra = %p\n", extra );
- *(int*)outval = *(int*)outval - 1;
+ if (verbose)
+ printf(" In C MPI win delete function, extra = %p\n", extra);
+ *(int *) outval = *(int *) outval - 1;
return MPI_SUCCESS;
}
@@ -195,32 +197,28 @@ static int WIN_DELETE_FN( MPI_Win win, int keyval, void *outval,
/* Routines to create keyvals in C (with C copy and delete functions */
/* ----------------------------------------------------------------------- */
-void ccreatekeys_( MPI_Fint *ccomm1_key, MPI_Fint *ccomm2_key,
- MPI_Fint *ctype2_key, MPI_Fint *cwin2_key )
+void ccreatekeys_(MPI_Fint * ccomm1_key, MPI_Fint * ccomm2_key,
+ MPI_Fint * ctype2_key, MPI_Fint * cwin2_key)
{
- MPI_Keyval_create( CMPI1_COPY_FN, CMPI1_DELETE_FN, &ccomm1Key,
- &ccomm1Extra );
- *ccomm1_key = (MPI_Fint)ccomm1Key;
+ MPI_Keyval_create(CMPI1_COPY_FN, CMPI1_DELETE_FN, &ccomm1Key, &ccomm1Extra);
+ *ccomm1_key = (MPI_Fint) ccomm1Key;
- MPI_Comm_create_keyval( CMPI1_COPY_FN, CMPI1_DELETE_FN, &ccomm2Key,
- &ccomm2Extra );
- *ccomm2_key = (MPI_Fint)ccomm2Key;
+ MPI_Comm_create_keyval(CMPI1_COPY_FN, CMPI1_DELETE_FN, &ccomm2Key, &ccomm2Extra);
+ *ccomm2_key = (MPI_Fint) ccomm2Key;
- MPI_Type_create_keyval( TYPE_COPY_FN, TYPE_DELETE_FN, &ctype2Key,
- &ctype2Extra );
- *ctype2_key = (MPI_Fint)ctype2Key;
+ MPI_Type_create_keyval(TYPE_COPY_FN, TYPE_DELETE_FN, &ctype2Key, &ctype2Extra);
+ *ctype2_key = (MPI_Fint) ctype2Key;
- MPI_Win_create_keyval( WIN_COPY_FN, WIN_DELETE_FN, &cwin2Key,
- &cwin2Extra );
- *cwin2_key = (MPI_Fint)cwin2Key;
+ MPI_Win_create_keyval(WIN_COPY_FN, WIN_DELETE_FN, &cwin2Key, &cwin2Extra);
+ *cwin2_key = (MPI_Fint) cwin2Key;
}
void cfreekeys_(void)
{
- MPI_Keyval_free( &ccomm1Key );
- MPI_Comm_free_keyval( &ccomm2Key );
- MPI_Type_free_keyval( &ctype2Key );
- MPI_Win_free_keyval( &cwin2Key );
+ MPI_Keyval_free(&ccomm1Key);
+ MPI_Comm_free_keyval(&ccomm2Key);
+ MPI_Type_free_keyval(&ctype2Key);
+ MPI_Win_free_keyval(&cwin2Key);
}
/* ----------------------------------------------------------------------- */
@@ -229,79 +227,73 @@ void cfreekeys_(void)
/* Test c-to-c attributes */
static int ccomm1Attr, ccomm2Attr, ctype2Attr, cwin2Attr;
-void ctoctest_( MPI_Fint *errs )
+void ctoctest_(MPI_Fint * errs)
{
int errcnt = *errs;
- int baseattrval = (1 << (sizeof(int)*8-2))-3;
+ int baseattrval = (1 << (sizeof(int) * 8 - 2)) - 3;
MPI_Datatype cduptype;
- MPI_Comm cdup;
+ MPI_Comm cdup;
/* MPI-1 function */
ccomm1Attr = baseattrval;
- MPI_Attr_put( MPI_COMM_SELF, ccomm1Key, &ccomm1Attr );
+ MPI_Attr_put(MPI_COMM_SELF, ccomm1Key, &ccomm1Attr);
/* Test that we have the same value */
- errcnt += cmpi1read( MPI_COMM_SELF, ccomm1Key, &ccomm1Attr, "C to C" );
+ errcnt += cmpi1read(MPI_COMM_SELF, ccomm1Key, &ccomm1Attr, "C to C");
/* Dup, check that the copy routine does what is expected */
- MPI_Comm_dup( MPI_COMM_SELF, &cdup );
- errcnt += cmpi1read( cdup, ccomm1Key, &ccomm1Attr, "C to C dup" );
+ MPI_Comm_dup(MPI_COMM_SELF, &cdup);
+ errcnt += cmpi1read(cdup, ccomm1Key, &ccomm1Attr, "C to C dup");
if (ccomm1Attr != baseattrval + 1) {
- printf( " Did not increment int in C to C dup: %d %d\n",
- ccomm1Attr, baseattrval + 1 );
- errcnt ++;
+ printf(" Did not increment int in C to C dup: %d %d\n", ccomm1Attr, baseattrval + 1);
+ errcnt++;
}
- MPI_Comm_free( &cdup );
+ MPI_Comm_free(&cdup);
if (ccomm1Attr != baseattrval) {
- printf( " Did not increment int in C to C delete: %d %d\n",
- ccomm1Attr, baseattrval );
- errcnt ++;
+ printf(" Did not increment int in C to C delete: %d %d\n", ccomm1Attr, baseattrval);
+ errcnt++;
}
/* MPI-2 functions */
ccomm1Attr = 0;
ccomm2Attr = baseattrval;
- MPI_Comm_set_attr( MPI_COMM_SELF, ccomm2Key, &ccomm2Attr );
+ MPI_Comm_set_attr(MPI_COMM_SELF, ccomm2Key, &ccomm2Attr);
/* Test that we have the same value */
- errcnt += cmpi2read( MPI_COMM_SELF, ccomm2Key, &ccomm2Attr, "C to C (2)" );
+ errcnt += cmpi2read(MPI_COMM_SELF, ccomm2Key, &ccomm2Attr, "C to C (2)");
/* Dup, check that the copy routine does what is expected */
- MPI_Comm_dup( MPI_COMM_SELF, &cdup );
- errcnt += cmpi2read( cdup, ccomm2Key, &ccomm2Attr, "C to C dup (2)" );
+ MPI_Comm_dup(MPI_COMM_SELF, &cdup);
+ errcnt += cmpi2read(cdup, ccomm2Key, &ccomm2Attr, "C to C dup (2)");
if (ccomm2Attr != baseattrval + 1) {
- printf( " Did not increment int in C to C dup: %d %d\n",
- ccomm2Attr, baseattrval + 1 );
- errcnt ++;
+ printf(" Did not increment int in C to C dup: %d %d\n", ccomm2Attr, baseattrval + 1);
+ errcnt++;
}
- MPI_Comm_free( &cdup );
+ MPI_Comm_free(&cdup);
if (ccomm2Attr != baseattrval) {
- printf( " Did not increment int in C to C delete (2): %d %d\n",
- ccomm2Attr, baseattrval );
- errcnt ++;
+ printf(" Did not increment int in C to C delete (2): %d %d\n", ccomm2Attr, baseattrval);
+ errcnt++;
}
/* MPI-2 functions */
ctype2Attr = baseattrval;
- MPI_Type_set_attr( MPI_INTEGER, ctype2Key, &ctype2Attr );
+ MPI_Type_set_attr(MPI_INTEGER, ctype2Key, &ctype2Attr);
/* Test that we have the same value */
- errcnt += cmpi2readtype( MPI_INTEGER, ctype2Key, &ctype2Attr, "C to C type (2)" );
+ errcnt += cmpi2readtype(MPI_INTEGER, ctype2Key, &ctype2Attr, "C to C type (2)");
/* Dup, check that the copy routine does what is expected */
- MPI_Type_dup( MPI_INTEGER, &cduptype );
- errcnt += cmpi2readtype( cduptype, ctype2Key, &ctype2Attr, "C to C typedup (2)" );
+ MPI_Type_dup(MPI_INTEGER, &cduptype);
+ errcnt += cmpi2readtype(cduptype, ctype2Key, &ctype2Attr, "C to C typedup (2)");
if (ctype2Attr != baseattrval + 1) {
- printf( " Did not increment int in C to C typedup: %d %d\n",
- ctype2Attr, baseattrval + 1 );
- errcnt ++;
+ printf(" Did not increment int in C to C typedup: %d %d\n", ctype2Attr, baseattrval + 1);
+ errcnt++;
}
ccomm1Attr = 0;
- MPI_Type_free( &cduptype );
+ MPI_Type_free(&cduptype);
if (ctype2Attr != baseattrval) {
- printf( " Did not increment int in C to C typedelete (2): %d %d\n",
- ctype2Attr, baseattrval );
- errcnt ++;
+ printf(" Did not increment int in C to C typedelete (2): %d %d\n", ctype2Attr, baseattrval);
+ errcnt++;
}
@@ -313,199 +305,201 @@ void ctoctest_( MPI_Fint *errs )
/* of errors found */
/* ----------------------------------------------------------------------- */
-int cmpi1read( MPI_Comm comm, int key, void *expected, const char *msg )
+int cmpi1read(MPI_Comm comm, int key, void *expected, const char *msg)
{
void *attrval;
- int flag;
- MPI_Attr_get( comm, key, &attrval, &flag );
+ int flag;
+ MPI_Attr_get(comm, key, &attrval, &flag);
if (!flag) {
- printf( " Error: flag false for Attr_get: %s\n", msg );
- return 1;
+ printf(" Error: flag false for Attr_get: %s\n", msg);
+ return 1;
}
if (attrval != expected) {
- printf( " Error: expected %p but saw %p: %s\n", expected, attrval, msg );
- return 1;
+ printf(" Error: expected %p but saw %p: %s\n", expected, attrval, msg);
+ return 1;
}
return 0;
}
-int cmpi2read( MPI_Comm comm, int key, void *expected, const char *msg )
+int cmpi2read(MPI_Comm comm, int key, void *expected, const char *msg)
{
void *attrval;
- int flag;
- MPI_Comm_get_attr( comm, key, &attrval, &flag );
+ int flag;
+ MPI_Comm_get_attr(comm, key, &attrval, &flag);
if (!flag) {
- printf( " Error: flag false for Comm_get_attr: %s\n", msg );
- return 1;
+ printf(" Error: flag false for Comm_get_attr: %s\n", msg);
+ return 1;
}
if (attrval != expected) {
- printf( " Error: expected %p but saw %p: %s\n", expected, attrval, msg );
- return 1;
+ printf(" Error: expected %p but saw %p: %s\n", expected, attrval, msg);
+ return 1;
}
return 0;
}
-int cmpi2readtype( MPI_Datatype dtype, int key, void *expected, const char *msg )
+int cmpi2readtype(MPI_Datatype dtype, int key, void *expected, const char *msg)
{
void *attrval;
- int flag;
- MPI_Type_get_attr( dtype, key, &attrval, &flag );
+ int flag;
+ MPI_Type_get_attr(dtype, key, &attrval, &flag);
if (!flag) {
- printf( " Error: flag false for Type_get_attr: %s\n", msg );
- return 1;
+ printf(" Error: flag false for Type_get_attr: %s\n", msg);
+ return 1;
}
if (attrval != expected) {
- printf( " Error: expected %p but saw %p: %s\n", expected, attrval, msg );
- return 1;
+ printf(" Error: expected %p but saw %p: %s\n", expected, attrval, msg);
+ return 1;
}
return 0;
}
-int cmpi2readwin( MPI_Win win, int key, void *expected, const char *msg )
+
+int cmpi2readwin(MPI_Win win, int key, void *expected, const char *msg)
{
void *attrval;
- int flag;
- MPI_Win_get_attr( win, key, &attrval, &flag );
+ int flag;
+ MPI_Win_get_attr(win, key, &attrval, &flag);
if (!flag) {
- printf( " Error: flag false for Win_get_attr: %s\n", msg );
- return 1;
+ printf(" Error: flag false for Win_get_attr: %s\n", msg);
+ return 1;
}
if (attrval != expected) {
- printf( " Error: expected %p but saw %p: %s\n", expected, attrval, msg );
- return 1;
+ printf(" Error: expected %p but saw %p: %s\n", expected, attrval, msg);
+ return 1;
}
return 0;
}
/* Set in Fortran (MPI-1), read in C */
-void cmpif1read_( MPI_Fint *fcomm, MPI_Fint *fkey, MPI_Fint *expected,
- MPI_Fint *errs, const char *msg, int msglen )
+void cmpif1read_(MPI_Fint * fcomm, MPI_Fint * fkey, MPI_Fint * expected,
+ MPI_Fint * errs, const char *msg, int msglen)
{
void *attrval;
- int flag, result;
- MPI_Comm comm = MPI_Comm_f2c( *fcomm );
+ int flag, result;
+ MPI_Comm comm = MPI_Comm_f2c(*fcomm);
char lmsg[MAX_ATTRTEST_MSG];
- if (msglen > sizeof(lmsg)- 1) {
- fprintf( stderr, "Message too long for buffer (%d)\n", msglen );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ if (msglen > sizeof(lmsg) - 1) {
+ fprintf(stderr, "Message too long for buffer (%d)\n", msglen);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- MPI_Attr_get( comm, *fkey, &attrval, &flag );
+ MPI_Attr_get(comm, *fkey, &attrval, &flag);
if (!flag) {
- *errs = *errs + 1;
- strncpy( lmsg, msg, msglen );
- lmsg[msglen] = 0;
- printf( " Error: flag false for Attr_get (set in F1): %s\n", lmsg );
- return;
+ *errs = *errs + 1;
+ strncpy(lmsg, msg, msglen);
+ lmsg[msglen] = 0;
+ printf(" Error: flag false for Attr_get (set in F1): %s\n", lmsg);
+ return;
}
/* Must be careful to compare as required in the MPI specification */
- ccompareint2void_( expected, attrval, &result );
+ ccompareint2void_(expected, attrval, &result);
if (!result) {
- *errs = *errs + 1;
- strncpy( lmsg, msg, msglen );
- lmsg[msglen] = 0;
- printf( " Error: (set in F1) expected %d but saw %d: %s\n",
- *expected, *(MPI_Fint*)attrval, lmsg );
- return;
+ *errs = *errs + 1;
+ strncpy(lmsg, msg, msglen);
+ lmsg[msglen] = 0;
+ printf(" Error: (set in F1) expected %d but saw %d: %s\n",
+ *expected, *(MPI_Fint *) attrval, lmsg);
+ return;
}
return;
}
/* Set in Fortran (MPI-2), read in C */
-void cmpif2read_( MPI_Fint *fcomm, MPI_Fint *fkey, MPI_Aint *expected,
- MPI_Fint *errs, const char *msg, int msglen )
+void cmpif2read_(MPI_Fint * fcomm, MPI_Fint * fkey, MPI_Aint * expected,
+ MPI_Fint * errs, const char *msg, int msglen)
{
void *attrval;
- int flag, result;
- MPI_Comm comm = MPI_Comm_f2c( *fcomm );
+ int flag, result;
+ MPI_Comm comm = MPI_Comm_f2c(*fcomm);
char lmsg[MAX_ATTRTEST_MSG];
- if (msglen > sizeof(lmsg)- 1) {
- fprintf( stderr, "Message too long for buffer (%d)\n", msglen );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ if (msglen > sizeof(lmsg) - 1) {
+ fprintf(stderr, "Message too long for buffer (%d)\n", msglen);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- MPI_Comm_get_attr( comm, *fkey, &attrval, &flag );
+ MPI_Comm_get_attr(comm, *fkey, &attrval, &flag);
if (!flag) {
- *errs = *errs + 1;
- strncpy( lmsg, msg, msglen );
- lmsg[msglen] = 0;
- printf( " Error: flag false for Comm_get_attr (set in F2): %s\n", lmsg );
- return;
+ *errs = *errs + 1;
+ strncpy(lmsg, msg, msglen);
+ lmsg[msglen] = 0;
+ printf(" Error: flag false for Comm_get_attr (set in F2): %s\n", lmsg);
+ return;
}
- ccompareaint2void_( expected, attrval, &result );
+ ccompareaint2void_(expected, attrval, &result);
if (!result) {
- *errs = *errs + 1;
- strncpy( lmsg, msg, msglen );
- lmsg[msglen] = 0;
- printf( " Error: (set in F2) expected %ld but saw %ld: %s\n",
- (long)*expected, (long)*(MPI_Aint*)attrval, lmsg );
- return;
+ *errs = *errs + 1;
+ strncpy(lmsg, msg, msglen);
+ lmsg[msglen] = 0;
+ printf(" Error: (set in F2) expected %ld but saw %ld: %s\n",
+ (long) *expected, (long) *(MPI_Aint *) attrval, lmsg);
+ return;
}
return;
}
-void cmpif2readtype_( MPI_Fint *ftype, MPI_Fint *fkey, MPI_Aint *expected,
- MPI_Fint *errs, const char *msg, int msglen )
+void cmpif2readtype_(MPI_Fint * ftype, MPI_Fint * fkey, MPI_Aint * expected,
+ MPI_Fint * errs, const char *msg, int msglen)
{
void *attrval;
- int flag, result;
- MPI_Datatype dtype = MPI_Type_f2c( *ftype );
+ int flag, result;
+ MPI_Datatype dtype = MPI_Type_f2c(*ftype);
char lmsg[MAX_ATTRTEST_MSG];
- if (msglen > sizeof(lmsg)- 1) {
- fprintf( stderr, "Message too long for buffer (%d)\n", msglen );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ if (msglen > sizeof(lmsg) - 1) {
+ fprintf(stderr, "Message too long for buffer (%d)\n", msglen);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- MPI_Type_get_attr( dtype, *fkey, &attrval, &flag );
+ MPI_Type_get_attr(dtype, *fkey, &attrval, &flag);
if (!flag) {
- *errs = *errs + 1;
- strncpy( lmsg, msg, msglen );
- lmsg[msglen] = 0;
- printf( " Error: flag false for Type_get_attr (set in F2): %s\n", lmsg );
- return;
+ *errs = *errs + 1;
+ strncpy(lmsg, msg, msglen);
+ lmsg[msglen] = 0;
+ printf(" Error: flag false for Type_get_attr (set in F2): %s\n", lmsg);
+ return;
}
- ccompareaint2void_( expected, attrval, &result );
+ ccompareaint2void_(expected, attrval, &result);
if (!result) {
- *errs = *errs + 1;
- strncpy( lmsg, msg, msglen );
- lmsg[msglen] = 0;
- printf( " Error: (set in F2/Type) expected %ld but saw %ld: %s\n",
- (long)*expected, (long)*(MPI_Aint*)attrval, lmsg );
- return;
+ *errs = *errs + 1;
+ strncpy(lmsg, msg, msglen);
+ lmsg[msglen] = 0;
+ printf(" Error: (set in F2/Type) expected %ld but saw %ld: %s\n",
+ (long) *expected, (long) *(MPI_Aint *) attrval, lmsg);
+ return;
}
return;
}
-void cmpif2readwin_( MPI_Fint *fwin, MPI_Fint *fkey, MPI_Aint *expected,
- MPI_Fint *errs, const char *msg, int msglen )
+
+void cmpif2readwin_(MPI_Fint * fwin, MPI_Fint * fkey, MPI_Aint * expected,
+ MPI_Fint * errs, const char *msg, int msglen)
{
void *attrval;
- int flag, result;
- MPI_Win win = MPI_Win_f2c( *fwin );
+ int flag, result;
+ MPI_Win win = MPI_Win_f2c(*fwin);
char lmsg[MAX_ATTRTEST_MSG];
- if (msglen > sizeof(lmsg)- 1) {
- fprintf( stderr, "Message too long for buffer (%d)\n", msglen );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ if (msglen > sizeof(lmsg) - 1) {
+ fprintf(stderr, "Message too long for buffer (%d)\n", msglen);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- MPI_Win_get_attr( win, *fkey, &attrval, &flag );
+ MPI_Win_get_attr(win, *fkey, &attrval, &flag);
if (!flag) {
- *errs = *errs + 1;
- strncpy( lmsg, msg, msglen );
- lmsg[msglen] = 0;
- printf( " Error: flag false for Win_get_attr (set in F2): %s\n", lmsg );
- return;
+ *errs = *errs + 1;
+ strncpy(lmsg, msg, msglen);
+ lmsg[msglen] = 0;
+ printf(" Error: flag false for Win_get_attr (set in F2): %s\n", lmsg);
+ return;
}
- ccompareaint2void_( expected, attrval, &result );
+ ccompareaint2void_(expected, attrval, &result);
if (!result) {
- *errs = *errs + 1;
- strncpy( lmsg, msg, msglen );
- lmsg[msglen] = 0;
- printf( " Error: (set in F2/Win) expected %ld but saw %ld: %s\n",
- (long)*expected, (long)*(MPI_Aint*)attrval, lmsg );
- return;
+ *errs = *errs + 1;
+ strncpy(lmsg, msg, msglen);
+ lmsg[msglen] = 0;
+ printf(" Error: (set in F2/Win) expected %ld but saw %ld: %s\n",
+ (long) *expected, (long) *(MPI_Aint *) attrval, lmsg);
+ return;
}
return;
}
@@ -515,32 +509,34 @@ void cmpif2readwin_( MPI_Fint *fwin, MPI_Fint *fkey, MPI_Aint *expected,
/* the C attribute functions */
/* ----------------------------------------------------------------------- */
-void csetmpi_( MPI_Fint *fcomm, MPI_Fint *fkey, MPI_Fint *val, MPI_Fint *errs )
+void csetmpi_(MPI_Fint * fcomm, MPI_Fint * fkey, MPI_Fint * val, MPI_Fint * errs)
{
- MPI_Comm comm = MPI_Comm_f2c( *fcomm );
+ MPI_Comm comm = MPI_Comm_f2c(*fcomm);
- MPI_Comm_set_attr( comm, *fkey, (void *)(MPI_Aint)*val );
+ MPI_Comm_set_attr(comm, *fkey, (void *) (MPI_Aint) * val);
}
-void csetmpi2_( MPI_Fint *fcomm, MPI_Fint *fkey, MPI_Aint *val, MPI_Fint *errs )
+
+void csetmpi2_(MPI_Fint * fcomm, MPI_Fint * fkey, MPI_Aint * val, MPI_Fint * errs)
{
- MPI_Comm comm = MPI_Comm_f2c( *fcomm );
+ MPI_Comm comm = MPI_Comm_f2c(*fcomm);
- MPI_Comm_set_attr( comm, *fkey, (void *)*val );
+ MPI_Comm_set_attr(comm, *fkey, (void *) *val);
}
-void csetmpitype_( MPI_Fint *ftype, MPI_Fint *fkey, MPI_Aint *val,
- MPI_Fint *errs )
+
+void csetmpitype_(MPI_Fint * ftype, MPI_Fint * fkey, MPI_Aint * val, MPI_Fint * errs)
{
- MPI_Datatype dtype = MPI_Type_f2c( *ftype );
+ MPI_Datatype dtype = MPI_Type_f2c(*ftype);
- MPI_Type_set_attr( dtype, *fkey, (void *)*val );
+ MPI_Type_set_attr(dtype, *fkey, (void *) *val);
}
-void csetmpiwin_( MPI_Fint *fwin, MPI_Fint *fkey, MPI_Aint *val,
- MPI_Fint *errs )
+
+void csetmpiwin_(MPI_Fint * fwin, MPI_Fint * fkey, MPI_Aint * val, MPI_Fint * errs)
{
- MPI_Win win = MPI_Win_f2c( *fwin );
+ MPI_Win win = MPI_Win_f2c(*fwin);
- MPI_Win_set_attr( win, *fkey, (void *)*val );
+ MPI_Win_set_attr(win, *fkey, (void *) *val);
}
+
/* ----------------------------------------------------------------------- */
/* Comparisons */
/* int with aint */
@@ -553,76 +549,80 @@ void csetmpiwin_( MPI_Fint *fwin, MPI_Fint *fkey, MPI_Aint *val,
/* If one item is shorter than the other, take the low bytes. */
/* If one item is longer than the other, sign extend */
/* ----------------------------------------------------------------------- */
-void ccompareint2aint_( MPI_Fint *in1, MPI_Aint *in2, MPI_Fint *result )
+void ccompareint2aint_(MPI_Fint * in1, MPI_Aint * in2, MPI_Fint * result)
{
static int idx = -1;
if (sizeof(MPI_Fint) == sizeof(MPI_Aint)) {
- *result = *in1 == *in2;
+ *result = *in1 == *in2;
}
else if (sizeof(MPI_Fint) < sizeof(MPI_Aint)) {
- /* Assume Aint no smaller than Fint, and that size of aint
- is a multiple of the size of fint) */
- MPI_Fint *v2 = (MPI_Fint *)in2;
- if (idx < 0) {
- MPI_Aint av = 1;
- MPI_Fint *fa = (MPI_Fint *)&av;
- if ((sizeof(MPI_Aint) % sizeof(MPI_Fint)) != 0) {
- fprintf( stderr,
- "PANIC: size of MPI_Aint = %d not a multiple of MPI_Fint = %d\n",
- (int)sizeof(MPI_Aint), (int)sizeof(MPI_Fint) );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- for (idx = sizeof(MPI_Aint) / sizeof(MPI_Fint); idx >= 0; idx--)
- if (fa[idx]) break;
- if (idx < 0) {
- fprintf( stderr, "Unable to determine low word of Fint in Aint\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- *result = *in1 == v2[idx];
- }
+ /* Assume Aint no smaller than Fint, and that size of aint
+ * is a multiple of the size of fint) */
+ MPI_Fint *v2 = (MPI_Fint *) in2;
+ if (idx < 0) {
+ MPI_Aint av = 1;
+ MPI_Fint *fa = (MPI_Fint *) & av;
+ if ((sizeof(MPI_Aint) % sizeof(MPI_Fint)) != 0) {
+ fprintf(stderr,
+ "PANIC: size of MPI_Aint = %d not a multiple of MPI_Fint = %d\n",
+ (int) sizeof(MPI_Aint), (int) sizeof(MPI_Fint));
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ for (idx = sizeof(MPI_Aint) / sizeof(MPI_Fint); idx >= 0; idx--)
+ if (fa[idx])
+ break;
+ if (idx < 0) {
+ fprintf(stderr, "Unable to determine low word of Fint in Aint\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ *result = *in1 == v2[idx];
+ }
}
else {
- fprintf( stderr, "PANIC: sizeof(MPI_Fint) = %d > sizeof(MPI_Aint) %d\n",
- (int)sizeof(MPI_Fint), (int)sizeof(MPI_Aint) );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "PANIC: sizeof(MPI_Fint) = %d > sizeof(MPI_Aint) %d\n",
+ (int) sizeof(MPI_Fint), (int) sizeof(MPI_Aint));
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
}
-void ccompareint2void_( MPI_Fint *in1, void *in2, MPI_Fint *result )
+
+void ccompareint2void_(MPI_Fint * in1, void *in2, MPI_Fint * result)
{
static int idx = -1;
- if (sizeof(MPI_Fint) == sizeof(void*)) {
- *result = *in1 == *(MPI_Fint*)in2;
- }
- else if (sizeof(MPI_Fint) < sizeof(void*)) {
- /* Assume void* no smaller than Fint, and that size of aint
- is a multiple of the size of fint) */
- MPI_Fint *v2 = (MPI_Fint *)in2;
- if (idx < 0) {
- void *av = (void *)1;
- MPI_Fint *fa = (MPI_Fint *)&av;
- if ((sizeof(void*) % sizeof(MPI_Fint)) != 0) {
- fprintf( stderr,
- "PANIC: size of void * = %d not a multiple of MPI_Fint = %d\n",
- (int)sizeof(void*), (int)sizeof(MPI_Fint) );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- for (idx = sizeof(void*) / sizeof(MPI_Fint); idx >= 0; idx--)
- if (fa[idx]) break;
- if (idx < 0) {
- fprintf( stderr, "Unable to determine low word of Fint in void*\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- *result = *in1 == v2[idx];
- }
+ if (sizeof(MPI_Fint) == sizeof(void *)) {
+ *result = *in1 == *(MPI_Fint *) in2;
+ }
+ else if (sizeof(MPI_Fint) < sizeof(void *)) {
+ /* Assume void* no smaller than Fint, and that size of aint
+ * is a multiple of the size of fint) */
+ MPI_Fint *v2 = (MPI_Fint *) in2;
+ if (idx < 0) {
+ void *av = (void *) 1;
+ MPI_Fint *fa = (MPI_Fint *) & av;
+ if ((sizeof(void *) % sizeof(MPI_Fint)) != 0) {
+ fprintf(stderr,
+ "PANIC: size of void * = %d not a multiple of MPI_Fint = %d\n",
+ (int) sizeof(void *), (int) sizeof(MPI_Fint));
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ for (idx = sizeof(void *) / sizeof(MPI_Fint); idx >= 0; idx--)
+ if (fa[idx])
+ break;
+ if (idx < 0) {
+ fprintf(stderr, "Unable to determine low word of Fint in void*\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ *result = *in1 == v2[idx];
+ }
}
else {
- fprintf( stderr, "PANIC: sizeof(MPI_Fint) = %d > sizeof(void*) %d\n",
- (int)sizeof(MPI_Fint), (int)sizeof(void*) );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "PANIC: sizeof(MPI_Fint) = %d > sizeof(void*) %d\n",
+ (int) sizeof(MPI_Fint), (int) sizeof(void *));
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
}
-void ccompareaint2void_( MPI_Aint *in1, void *in2, MPI_Fint *result )
+
+void ccompareaint2void_(MPI_Aint * in1, void *in2, MPI_Fint * result)
{
/* Note that an aint must be >= void * by definition */
- *result = *in1 == *(MPI_Aint*)in2;
+ *result = *in1 == *(MPI_Aint *) in2;
}
diff --git a/test/mpi/f08/attr/fandcattrc.c b/test/mpi/f08/attr/fandcattrc.c
index e084338..1f0cf68 100644
--- a/test/mpi/f08/attr/fandcattrc.c
+++ b/test/mpi/f08/attr/fandcattrc.c
@@ -36,86 +36,86 @@
#endif
-int chkcomm2inc_ (int *keyval, const int *expected, int *ierr);
-int chkcomm2inc_ (int *keyval, const int *expected, int *ierr)
+int chkcomm2inc_(int *keyval, const int *expected, int *ierr);
+int chkcomm2inc_(int *keyval, const int *expected, int *ierr)
{
- int flag;
+ int flag;
MPI_Aint *val;
/* See Example 16.19 in MPI 2.2, part B. The use of MPI_Aint *val
- and the address of val in the get_attr call is correct, as is
- the use of *val to access the value. */
- MPI_Comm_get_attr( MPI_COMM_WORLD, *keyval, &val, &flag );
+ * and the address of val in the get_attr call is correct, as is
+ * the use of *val to access the value. */
+ MPI_Comm_get_attr(MPI_COMM_WORLD, *keyval, &val, &flag);
if (!flag) {
- *ierr = 1;
+ *ierr = 1;
}
else {
- if (*val != *expected) {
- /* In some cases, using printf from a c routine linked
- with a Fortran routine can cause linking difficulties.
- To avoid problems in running the tests, this print
- is commented out */
- /* printf( "Val = %x, expected = %d\n", val, *expected ); */
- *ierr = *ierr + 1;
- }
+ if (*val != *expected) {
+ /* In some cases, using printf from a c routine linked
+ * with a Fortran routine can cause linking difficulties.
+ * To avoid problems in running the tests, this print
+ * is commented out */
+ /* printf("Val = %x, expected = %d\n", val, *expected); */
+ *ierr = *ierr + 1;
+ }
}
return 0;
}
/* Attribute delete and copy functions for each type */
-int myCommCopyfn( MPI_Comm comm, int keyval, void *extra_state,
- void *attr_val_in, void *attr_val_out, int *flag );
-int myCommCopyfn( MPI_Comm comm, int keyval, void *extra_state,
- void *attr_val_in, void *attr_val_out, int *flag )
+int myCommCopyfn(MPI_Comm comm, int keyval, void *extra_state,
+ void *attr_val_in, void *attr_val_out, int *flag);
+int myCommCopyfn(MPI_Comm comm, int keyval, void *extra_state,
+ void *attr_val_in, void *attr_val_out, int *flag)
{
- *(void **)attr_val_out = (char *)attr_val_in + 2;
+ *(void **) attr_val_out = (char *) attr_val_in + 2;
*flag = 1;
return MPI_SUCCESS;
}
-int myCommDelfn( MPI_Comm comm, int keyval, void *attr_val, void *extra_state );
-int myCommDelfn( MPI_Comm comm, int keyval, void *attr_val, void *extra_state )
+int myCommDelfn(MPI_Comm comm, int keyval, void *attr_val, void *extra_state);
+int myCommDelfn(MPI_Comm comm, int keyval, void *attr_val, void *extra_state)
{
return MPI_SUCCESS;
}
-int myTypeCopyfn( MPI_Datatype dtype, int keyval, void *extra_state,
- void *attr_val_in, void *attr_val_out, int *flag );
-int myTypeCopyfn( MPI_Datatype dtype, int keyval, void *extra_state,
- void *attr_val_in, void *attr_val_out, int *flag )
+int myTypeCopyfn(MPI_Datatype dtype, int keyval, void *extra_state,
+ void *attr_val_in, void *attr_val_out, int *flag);
+int myTypeCopyfn(MPI_Datatype dtype, int keyval, void *extra_state,
+ void *attr_val_in, void *attr_val_out, int *flag)
{
- *(void **)attr_val_out = (char *)attr_val_in + 2;
+ *(void **) attr_val_out = (char *) attr_val_in + 2;
*flag = 1;
return MPI_SUCCESS;
}
-int myTypeDelfn( MPI_Datatype dtype, int keyval, void *attr_val, void *extra_state );
-int myTypeDelfn( MPI_Datatype dtype, int keyval, void *attr_val, void *extra_state )
+int myTypeDelfn(MPI_Datatype dtype, int keyval, void *attr_val, void *extra_state);
+int myTypeDelfn(MPI_Datatype dtype, int keyval, void *attr_val, void *extra_state)
{
return MPI_SUCCESS;
}
-int myWinCopyfn( MPI_Win win, int keyval, void *extra_state,
- void *attr_val_in, void *attr_val_out, int *flag );
-int myWinCopyfn( MPI_Win win, int keyval, void *extra_state,
- void *attr_val_in, void *attr_val_out, int *flag )
+int myWinCopyfn(MPI_Win win, int keyval, void *extra_state,
+ void *attr_val_in, void *attr_val_out, int *flag);
+int myWinCopyfn(MPI_Win win, int keyval, void *extra_state,
+ void *attr_val_in, void *attr_val_out, int *flag)
{
- *(void **)attr_val_out = (char *)attr_val_in + 2;
+ *(void **) attr_val_out = (char *) attr_val_in + 2;
*flag = 1;
return MPI_SUCCESS;
}
-int myWinDelfn( MPI_Win win, int keyval, void *attr_val, void *extra_state );
-int myWinDelfn( MPI_Win win, int keyval, void *attr_val, void *extra_state )
+int myWinDelfn(MPI_Win win, int keyval, void *attr_val, void *extra_state);
+int myWinDelfn(MPI_Win win, int keyval, void *attr_val, void *extra_state)
{
return MPI_SUCCESS;
}
-int chkckeyvals_( int *comm_keyval, int *type_keyval, int *win_keyval );
-int chkckeyvals_( int *comm_keyval, int *type_keyval, int *win_keyval )
+int chkckeyvals_(int *comm_keyval, int *type_keyval, int *win_keyval);
+int chkckeyvals_(int *comm_keyval, int *type_keyval, int *win_keyval)
{
- MPI_Comm_create_keyval( myCommCopyfn, myCommDelfn, comm_keyval, 0 );
- MPI_Type_create_keyval( myTypeCopyfn, myTypeDelfn, type_keyval, 0 );
- MPI_Win_create_keyval( myWinCopyfn, myWinDelfn, win_keyval, 0 );
+ MPI_Comm_create_keyval(myCommCopyfn, myCommDelfn, comm_keyval, 0);
+ MPI_Type_create_keyval(myTypeCopyfn, myTypeDelfn, type_keyval, 0);
+ MPI_Win_create_keyval(myWinCopyfn, myWinDelfn, win_keyval, 0);
return 0;
}
diff --git a/test/mpi/f08/ext/c2f90mult.c b/test/mpi/f08/ext/c2f90mult.c
index 19b802b..51b5cd2 100644
--- a/test/mpi/f08/ext/c2f90mult.c
+++ b/test/mpi/f08/ext/c2f90mult.c
@@ -7,8 +7,8 @@
/*
Check that MPI_xxxx_c2f, applied to the same object several times,
- yields the same handle. We do this because when MPI handles in
- C are a different length than those in Fortran, care needs to
+ yields the same handle. We do this because when MPI handles in
+ C are a different length than those in Fortran, care needs to
be exercised to ensure that the mapping from one to another is unique.
(Test added to test a potential problem in ROMIO for handling MPI_File
on 64-bit systems)
@@ -17,45 +17,45 @@
#include <stdio.h>
#include "mpitest.h"
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Fint handleA, handleB;
- int rc;
- int errs = 0;
- int buf[1];
+ int rc;
+ int errs = 0;
+ int buf[1];
MPI_Request cRequest;
MPI_Status st;
- int tFlag;
+ int tFlag;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
/* Request */
- rc = MPI_Irecv( buf, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &cRequest );
+ rc = MPI_Irecv(buf, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &cRequest);
if (rc) {
- errs++;
- printf( "Unable to create request\n" );
+ errs++;
+ printf("Unable to create request\n");
}
else {
- handleA = MPI_Request_c2f( cRequest );
- handleB = MPI_Request_c2f( cRequest );
- if (handleA != handleB) {
- errs++;
- printf( "MPI_Request_c2f does not give the same handle twice on the same MPI_Request\n" );
- }
+ handleA = MPI_Request_c2f(cRequest);
+ handleB = MPI_Request_c2f(cRequest);
+ if (handleA != handleB) {
+ errs++;
+ printf("MPI_Request_c2f does not give the same handle twice on the same MPI_Request\n");
+ }
}
- MPI_Cancel( &cRequest );
- MPI_Test( &cRequest, &tFlag, &st );
- MPI_Test_cancelled( &st, &tFlag );
+ MPI_Cancel(&cRequest);
+ MPI_Test(&cRequest, &tFlag, &st);
+ MPI_Test_cancelled(&st, &tFlag);
if (!tFlag) {
- errs++;
- printf( "Unable to cancel MPI_Irecv request\n" );
+ errs++;
+ printf("Unable to cancel MPI_Irecv request\n");
}
/* Using MPI_Request_free should be ok, but some MPI implementations
- object to it imediately after the cancel and that isn't essential to
- this test */
+ * object to it imediately after the cancel and that isn't essential to
+ * this test */
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
-
+
return 0;
}
diff --git a/test/mpi/f08/io/c2f902cio.c b/test/mpi/f08/io/c2f902cio.c
index 20f434c..a483434 100644
--- a/test/mpi/f08/io/c2f902cio.c
+++ b/test/mpi/f08/io/c2f902cio.c
@@ -6,7 +6,7 @@
* See COPYRIGHT in top-level directory.
*/
/*
- * This file contains the C routines used in testing the c2f and f2c
+ * This file contains the C routines used in testing the c2f and f2c
* handle conversion functions for MPI_File
* The tests follow this pattern:
*
@@ -30,11 +30,11 @@
#include "../../include/mpitestconf.h"
#include <string.h>
-/*
+/*
Name mapping. All routines are created with names that are lower case
with a single trailing underscore. This matches many compilers.
We use #define to change the name for Fortran compilers that do
- not use the lowercase/underscore pattern
+ not use the lowercase/underscore pattern
*/
#ifdef F77_NAME_UPPER
@@ -50,48 +50,48 @@
defined(F77_NAME_MIXED_USCORE)
/* Else leave name alone (routines have no underscore, so both
of these map to a lowercase, single underscore) */
-#else
+#else
#error 'Unrecognized Fortran name mapping'
#endif
/* Prototypes to keep compilers happy */
-int c2ffile_( int * );
-void f2cfile_( int * );
+int c2ffile_(int *);
+void f2cfile_(int *);
-int c2ffile_ ( int *file )
+int c2ffile_(int *file)
{
- MPI_File cFile = MPI_File_f2c( *file );
+ MPI_File cFile = MPI_File_f2c(*file);
MPI_Group group, wgroup;
int result;
- MPI_File_get_group( cFile, &group );
- MPI_Comm_group( MPI_COMM_WORLD, &wgroup );
+ MPI_File_get_group(cFile, &group);
+ MPI_Comm_group(MPI_COMM_WORLD, &wgroup);
- MPI_Group_compare( group, wgroup, &result );
+ MPI_Group_compare(group, wgroup, &result);
if (result != MPI_IDENT) {
- fprintf( stderr, "File: did not get expected group\n" );
- return 1;
+ fprintf(stderr, "File: did not get expected group\n");
+ return 1;
}
- MPI_Group_free( &group );
- MPI_Group_free( &wgroup );
+ MPI_Group_free(&group);
+ MPI_Group_free(&wgroup);
return 0;
}
-/*
+/*
* The following routines provide handles to the calling Fortran program
*/
-void f2cfile_( int *file )
+void f2cfile_(int *file)
{
MPI_File cFile;
int rc;
- rc = MPI_File_open( MPI_COMM_WORLD, (char*)"temp",
- MPI_MODE_RDWR | MPI_MODE_DELETE_ON_CLOSE | MPI_MODE_CREATE,
- MPI_INFO_NULL, &cFile );
+ rc = MPI_File_open(MPI_COMM_WORLD, (char *) "temp",
+ MPI_MODE_RDWR | MPI_MODE_DELETE_ON_CLOSE | MPI_MODE_CREATE,
+ MPI_INFO_NULL, &cFile);
if (rc) {
- *file = 0;
+ *file = 0;
}
else {
- *file = MPI_File_c2f( cFile );
+ *file = MPI_File_c2f(cFile);
}
}
diff --git a/test/mpi/f08/io/c2f90multio.c b/test/mpi/f08/io/c2f90multio.c
index c6ae682..5d25960 100644
--- a/test/mpi/f08/io/c2f90multio.c
+++ b/test/mpi/f08/io/c2f90multio.c
@@ -15,42 +15,42 @@
#include "mpi.h"
#include <stdio.h>
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Fint handleA, handleB;
- int rc;
- int errs = 0;
- int rank;
+ int rc;
+ int errs = 0;
+ int rank;
MPI_File cFile;
- MPI_Init( &argc, &argv );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+ MPI_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
/* File */
- rc = MPI_File_open( MPI_COMM_WORLD, (char*)"temp",
- MPI_MODE_RDWR | MPI_MODE_DELETE_ON_CLOSE | MPI_MODE_CREATE,
- MPI_INFO_NULL, &cFile );
+ rc = MPI_File_open(MPI_COMM_WORLD, (char *) "temp",
+ MPI_MODE_RDWR | MPI_MODE_DELETE_ON_CLOSE | MPI_MODE_CREATE,
+ MPI_INFO_NULL, &cFile);
if (rc) {
- errs++;
- printf( "Unable to open file \"temp\"\n" );
+ errs++;
+ printf("Unable to open file \"temp\"\n");
}
else {
- handleA = MPI_File_c2f( cFile );
- handleB = MPI_File_c2f( cFile );
- if (handleA != handleB) {
- errs++;
- printf( "MPI_File_c2f does not give the same handle twice on the same MPI_File\n" );
- }
+ handleA = MPI_File_c2f(cFile);
+ handleB = MPI_File_c2f(cFile);
+ if (handleA != handleB) {
+ errs++;
+ printf("MPI_File_c2f does not give the same handle twice on the same MPI_File\n");
+ }
}
- MPI_File_close( &cFile );
+ MPI_File_close(&cFile);
if (rank == 0) {
- if (errs) {
- fprintf(stderr, "Found %d errors\n", errs);
- }
- else {
- printf(" No Errors\n");
- }
+ if (errs) {
+ fprintf(stderr, "Found %d errors\n", errs);
+ }
+ else {
+ printf(" No Errors\n");
+ }
}
MPI_Finalize();
diff --git a/test/mpi/f08/rma/c2f902cwin.c b/test/mpi/f08/rma/c2f902cwin.c
index fb18e1b..af4dc5e 100644
--- a/test/mpi/f08/rma/c2f902cwin.c
+++ b/test/mpi/f08/rma/c2f902cwin.c
@@ -56,26 +56,26 @@
#endif
/* Prototypes to keep compilers happy */
-int c2fwin_( int * );
-void f2cwin_( int * );
+int c2fwin_(int *);
+void f2cwin_(int *);
-int c2fwin_( int *win )
+int c2fwin_(int *win)
{
- MPI_Win cWin = MPI_Win_f2c( *win );
+ MPI_Win cWin = MPI_Win_f2c(*win);
MPI_Group group, wgroup;
int result;
- MPI_Win_get_group( cWin, &group );
- MPI_Comm_group( MPI_COMM_WORLD, &wgroup );
+ MPI_Win_get_group(cWin, &group);
+ MPI_Comm_group(MPI_COMM_WORLD, &wgroup);
- MPI_Group_compare( group, wgroup, &result );
+ MPI_Group_compare(group, wgroup, &result);
if (result != MPI_IDENT) {
- fprintf( stderr, "Win: did not get expected group\n" );
- return 1;
+ fprintf(stderr, "Win: did not get expected group\n");
+ return 1;
}
- MPI_Group_free( &group );
- MPI_Group_free( &wgroup );
+ MPI_Group_free(&group);
+ MPI_Group_free(&wgroup);
return 0;
}
@@ -83,10 +83,9 @@ int c2fwin_( int *win )
/*
* The following routines provide handles to the calling Fortran program
*/
-void f2cwin_( int *win )
+void f2cwin_(int *win)
{
MPI_Win cWin;
- MPI_Win_create( 0, 0, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &cWin );
- *win = MPI_Win_c2f( cWin );
+ MPI_Win_create(0, 0, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &cWin);
+ *win = MPI_Win_c2f(cWin);
}
-
diff --git a/test/mpi/f77/attr/attraints.h.in b/test/mpi/f77/attr/attraints.h.in
index b8113dd..d814372 100644
--- a/test/mpi/f77/attr/attraints.h.in
+++ b/test/mpi/f77/attr/attraints.h.in
@@ -1,6 +1,4 @@
-C -*- Mode: Fortran; -*-
-C
-C (C) 2003 by Argonne National Laboratory.
-C See COPYRIGHT in top-level directory.
-C
- @F77_MPI_ADDRESS@ extrastate, valin, valout, val
+C - *-Mode:Fortran;
+-*-C C(C)
+2003 by Argonne National Laboratory.C See COPYRIGHT in top - level directory.C
+ @ F77_MPI_ADDRESS @ extrastate, valin, valout, val
diff --git a/test/mpi/f77/datatype/bottomc.c b/test/mpi/f77/datatype/bottomc.c
index d94bd24..698a408 100644
--- a/test/mpi/f77/datatype/bottomc.c
+++ b/test/mpi/f77/datatype/bottomc.c
@@ -32,10 +32,10 @@
#error 'Unrecognized Fortran name mapping'
#endif
-void c_routine_(MPI_Fint *ftype, int *errs)
+void c_routine_(MPI_Fint * ftype, int *errs)
{
int count = 5;
- int lens[2] = {1,1};
+ int lens[2] = { 1, 1 };
int buf[6];
int i, rank;
@@ -54,16 +54,20 @@ void c_routine_(MPI_Fint *ftype, int *errs)
if (rank == 0) {
/* the message sent contains an int count of 5, followed
- by the 5 MPI_INTEGER entries of the Fortran array R.
- Here we assume MPI_INTEGER has the same size as MPI_INT
+ * by the 5 MPI_INTEGER entries of the Fortran array R.
+ * Here we assume MPI_INTEGER has the same size as MPI_INT
*/
assert(sizeof(MPI_Fint) == sizeof(int));
MPI_Send(MPI_BOTTOM, 1, newtype, 1, 0, MPI_COMM_WORLD);
- } else {
+ }
+ else {
MPI_Recv(buf, 6, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
- if (buf[0] != 5) *errs++;
- for (i=1; i < 6; i++) if (buf[i] != i) *errs++;
+ if (buf[0] != 5)
+ *errs++;
+ for (i = 1; i < 6; i++)
+ if (buf[i] != i)
+ *errs++;
}
MPI_Type_free(&newtype);
diff --git a/test/mpi/f77/datatype/typeaints.h.in b/test/mpi/f77/datatype/typeaints.h.in
index bcbcccb..50d3fa8 100644
--- a/test/mpi/f77/datatype/typeaints.h.in
+++ b/test/mpi/f77/datatype/typeaints.h.in
@@ -1,6 +1,4 @@
-C -*- Mode: Fortran; -*-
-C
-C (C) 2003 by Argonne National Laboratory.
-C See COPYRIGHT in top-level directory.
-C
- @F77_MPI_ADDRESS@ aint, aintv(max_asizev)
+C - *-Mode:Fortran;
+-*-C C(C)
+2003 by Argonne National Laboratory.C See COPYRIGHT in top - level directory.C
+ @ F77_MPI_ADDRESS @ aint, aintv(max_asizev)
diff --git a/test/mpi/f77/ext/add1size.h.in b/test/mpi/f77/ext/add1size.h.in
index 320b3a5..8a5f4fd 100644
--- a/test/mpi/f77/ext/add1size.h.in
+++ b/test/mpi/f77/ext/add1size.h.in
@@ -1,6 +1,4 @@
-C -*- Mode: Fortran; -*-
-C
-C (C) 2003 by Argonne National Laboratory.
-C See COPYRIGHT in top-level directory.
-C
- @F77_MPI_ADDRESS@ asize
+C - *-Mode:Fortran;
+-*-C C(C)
+2003 by Argonne National Laboratory.C See COPYRIGHT in top - level directory.C
+ @ F77_MPI_ADDRESS @ asize
diff --git a/test/mpi/f77/ext/c2f2c.c b/test/mpi/f77/ext/c2f2c.c
index 4e048b2..4eac548 100644
--- a/test/mpi/f77/ext/c2f2c.c
+++ b/test/mpi/f77/ext/c2f2c.c
@@ -5,7 +5,7 @@
* See COPYRIGHT in top-level directory.
*/
/*
- * This file contains the C routines used in testing the c2f and f2c
+ * This file contains the C routines used in testing the c2f and f2c
* handle conversion functions, except for MPI_File and MPI_Win (to
* allow working with MPI implementations that do not include those
* features).
@@ -32,11 +32,11 @@
#include "../../include/mpitestconf.h"
#include <string.h>
-/*
+/*
Name mapping. All routines are created with names that are lower case
with a single trailing underscore. This matches many compilers.
We use #define to change the name for Fortran compilers that do
- not use the lowercase/underscore pattern
+ not use the lowercase/underscore pattern
*/
#ifdef F77_NAME_UPPER
@@ -78,186 +78,182 @@
defined(F77_NAME_MIXED_USCORE)
/* Else leave name alone (routines have no underscore, so both
of these map to a lowercase, single underscore) */
-#else
+#else
#error 'Unrecognized Fortran name mapping'
#endif
/* Prototypes to keep compilers happy */
-MPI_Fint c2fcomm_( MPI_Fint * );
-MPI_Fint c2fgroup_( MPI_Fint * );
-MPI_Fint c2finfo_( MPI_Fint * );
-MPI_Fint c2frequest_( MPI_Fint * );
-MPI_Fint c2ftype_( MPI_Fint * );
-MPI_Fint c2fop_( MPI_Fint * );
-MPI_Fint c2ferrhandler_( MPI_Fint * );
-
-void f2ccomm_( MPI_Fint * );
-void f2cgroup_( MPI_Fint * );
-void f2cinfo_( MPI_Fint * );
-void f2crequest_( MPI_Fint * );
-void f2ctype_( MPI_Fint * );
-void f2cop_( MPI_Fint * );
-void f2cerrhandler_( MPI_Fint * );
-
-
-MPI_Fint c2fcomm_ (MPI_Fint *comm)
+MPI_Fint c2fcomm_(MPI_Fint *);
+MPI_Fint c2fgroup_(MPI_Fint *);
+MPI_Fint c2finfo_(MPI_Fint *);
+MPI_Fint c2frequest_(MPI_Fint *);
+MPI_Fint c2ftype_(MPI_Fint *);
+MPI_Fint c2fop_(MPI_Fint *);
+MPI_Fint c2ferrhandler_(MPI_Fint *);
+
+void f2ccomm_(MPI_Fint *);
+void f2cgroup_(MPI_Fint *);
+void f2cinfo_(MPI_Fint *);
+void f2crequest_(MPI_Fint *);
+void f2ctype_(MPI_Fint *);
+void f2cop_(MPI_Fint *);
+void f2cerrhandler_(MPI_Fint *);
+
+
+MPI_Fint c2fcomm_(MPI_Fint * comm)
{
MPI_Comm cComm = MPI_Comm_f2c(*comm);
int cSize, wSize, cRank, wRank;
- MPI_Comm_size( MPI_COMM_WORLD, &wSize );
- MPI_Comm_rank( MPI_COMM_WORLD, &wRank );
- MPI_Comm_size( cComm, &cSize );
- MPI_Comm_rank( cComm, &cRank );
+ MPI_Comm_size(MPI_COMM_WORLD, &wSize);
+ MPI_Comm_rank(MPI_COMM_WORLD, &wRank);
+ MPI_Comm_size(cComm, &cSize);
+ MPI_Comm_rank(cComm, &cRank);
if (wSize != cSize || wRank != cRank) {
- fprintf( stderr, "Comm: Did not get expected size,rank (got %d,%d)",
- cSize, cRank );
- return 1;
+ fprintf(stderr, "Comm: Did not get expected size,rank (got %d,%d)", cSize, cRank);
+ return 1;
}
return 0;
}
-MPI_Fint c2fgroup_ (MPI_Fint *group)
+MPI_Fint c2fgroup_(MPI_Fint * group)
{
MPI_Group cGroup = MPI_Group_f2c(*group);
int cSize, wSize, cRank, wRank;
/* We pass in the group of comm world */
- MPI_Comm_size( MPI_COMM_WORLD, &wSize );
- MPI_Comm_rank( MPI_COMM_WORLD, &wRank );
- MPI_Group_size( cGroup, &cSize );
- MPI_Group_rank( cGroup, &cRank );
+ MPI_Comm_size(MPI_COMM_WORLD, &wSize);
+ MPI_Comm_rank(MPI_COMM_WORLD, &wRank);
+ MPI_Group_size(cGroup, &cSize);
+ MPI_Group_rank(cGroup, &cRank);
if (wSize != cSize || wRank != cRank) {
- fprintf( stderr, "Group: Did not get expected size,rank (got %d,%d)",
- cSize, cRank );
- return 1;
+ fprintf(stderr, "Group: Did not get expected size,rank (got %d,%d)", cSize, cRank);
+ return 1;
}
return 0;
}
-MPI_Fint c2ftype_ ( MPI_Fint *type )
+MPI_Fint c2ftype_(MPI_Fint * type)
{
- MPI_Datatype dtype = MPI_Type_f2c( *type );
+ MPI_Datatype dtype = MPI_Type_f2c(*type);
if (dtype != MPI_INTEGER) {
- fprintf( stderr, "Type: Did not get expected type\n" );
- return 1;
+ fprintf(stderr, "Type: Did not get expected type\n");
+ return 1;
}
return 0;
}
-MPI_Fint c2finfo_ ( MPI_Fint *info )
+MPI_Fint c2finfo_(MPI_Fint * info)
{
- MPI_Info cInfo = MPI_Info_f2c( *info );
+ MPI_Info cInfo = MPI_Info_f2c(*info);
int flag;
char value[100];
MPI_Fint errs = 0;
- MPI_Info_get( cInfo, (char*)"host", sizeof(value), value, &flag );
- if (!flag || strcmp(value,"myname") != 0) {
- fprintf( stderr, "Info: Wrong value or no value for host\n" );
- errs++;
+ MPI_Info_get(cInfo, (char *) "host", sizeof(value), value, &flag);
+ if (!flag || strcmp(value, "myname") != 0) {
+ fprintf(stderr, "Info: Wrong value or no value for host\n");
+ errs++;
}
- MPI_Info_get( cInfo, (char*)"wdir", sizeof(value), value, &flag );
- if (!flag || strcmp( value, "/rdir/foo" ) != 0) {
- fprintf( stderr, "Info: Wrong value of no value for wdir\n" );
- errs++;
+ MPI_Info_get(cInfo, (char *) "wdir", sizeof(value), value, &flag);
+ if (!flag || strcmp(value, "/rdir/foo") != 0) {
+ fprintf(stderr, "Info: Wrong value of no value for wdir\n");
+ errs++;
}
return errs;
}
-MPI_Fint c2frequest_ ( MPI_Fint *request )
+MPI_Fint c2frequest_(MPI_Fint * request)
{
- MPI_Request req = MPI_Request_f2c( *request );
+ MPI_Request req = MPI_Request_f2c(*request);
MPI_Status status;
int flag;
- MPI_Test( &req, &flag, &status );
- MPI_Test_cancelled( &status, &flag );
- if (!flag) {
- fprintf( stderr, "Request: Wrong value for flag\n" );
- return 1;
+ MPI_Test(&req, &flag, &status);
+ MPI_Test_cancelled(&status, &flag);
+ if (!flag) {
+ fprintf(stderr, "Request: Wrong value for flag\n");
+ return 1;
}
else {
- *request = MPI_Request_c2f( req );
+ *request = MPI_Request_c2f(req);
}
return 0;
}
-MPI_Fint c2fop_ ( MPI_Fint *op )
+MPI_Fint c2fop_(MPI_Fint * op)
{
- MPI_Op cOp = MPI_Op_f2c( *op );
-
+ MPI_Op cOp = MPI_Op_f2c(*op);
+
if (cOp != MPI_SUM) {
- fprintf( stderr, "Op: did not get sum\n" );
- return 1;
+ fprintf(stderr, "Op: did not get sum\n");
+ return 1;
}
return 0;
}
-MPI_Fint c2ferrhandler_ ( MPI_Fint *errh )
+MPI_Fint c2ferrhandler_(MPI_Fint * errh)
{
- MPI_Errhandler errhand = MPI_Errhandler_f2c( *errh );
+ MPI_Errhandler errhand = MPI_Errhandler_f2c(*errh);
if (errhand != MPI_ERRORS_RETURN) {
- fprintf( stderr, "Errhandler: did not get errors return\n" );
- return 1;
+ fprintf(stderr, "Errhandler: did not get errors return\n");
+ return 1;
}
-
+
return 0;
}
-/*
+/*
* The following routines provide handles to the calling Fortran program
*/
-void f2ccomm_( MPI_Fint * comm )
+void f2ccomm_(MPI_Fint * comm)
{
- *comm = MPI_Comm_c2f( MPI_COMM_WORLD );
+ *comm = MPI_Comm_c2f(MPI_COMM_WORLD);
}
-void f2cgroup_( MPI_Fint * group )
+void f2cgroup_(MPI_Fint * group)
{
MPI_Group wgroup;
- MPI_Comm_group( MPI_COMM_WORLD, &wgroup );
- *group = MPI_Group_c2f( wgroup );
+ MPI_Comm_group(MPI_COMM_WORLD, &wgroup);
+ *group = MPI_Group_c2f(wgroup);
}
-void f2ctype_( MPI_Fint * type )
+void f2ctype_(MPI_Fint * type)
{
- *type = MPI_Type_c2f( MPI_INTEGER );
+ *type = MPI_Type_c2f(MPI_INTEGER);
}
-void f2cinfo_( MPI_Fint * info )
+void f2cinfo_(MPI_Fint * info)
{
MPI_Info cinfo;
- MPI_Info_create( &cinfo );
- MPI_Info_set( cinfo, (char*)"host", (char*)"myname" );
- MPI_Info_set( cinfo, (char*)"wdir", (char*)"/rdir/foo" );
+ MPI_Info_create(&cinfo);
+ MPI_Info_set(cinfo, (char *) "host", (char *) "myname");
+ MPI_Info_set(cinfo, (char *) "wdir", (char *) "/rdir/foo");
- *info = MPI_Info_c2f( cinfo );
+ *info = MPI_Info_c2f(cinfo);
}
-void f2crequest_( MPI_Fint * req )
+void f2crequest_(MPI_Fint * req)
{
MPI_Request cReq;
- MPI_Irecv( NULL, 0, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG,
- MPI_COMM_WORLD, &cReq );
- MPI_Cancel( &cReq );
- *req = MPI_Request_c2f( cReq );
-
+ MPI_Irecv(NULL, 0, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &cReq);
+ MPI_Cancel(&cReq);
+ *req = MPI_Request_c2f(cReq);
+
}
-void f2cop_( MPI_Fint * op )
+void f2cop_(MPI_Fint * op)
{
- *op = MPI_Op_c2f( MPI_SUM );
+ *op = MPI_Op_c2f(MPI_SUM);
}
-void f2cerrhandler_( MPI_Fint *errh )
+void f2cerrhandler_(MPI_Fint * errh)
{
- *errh = MPI_Errhandler_c2f( MPI_ERRORS_RETURN );
+ *errh = MPI_Errhandler_c2f(MPI_ERRORS_RETURN);
}
-
diff --git a/test/mpi/f77/ext/c2fmult.c b/test/mpi/f77/ext/c2fmult.c
index 07c21d6..517abba 100644
--- a/test/mpi/f77/ext/c2fmult.c
+++ b/test/mpi/f77/ext/c2fmult.c
@@ -6,8 +6,8 @@
/*
Check that MPI_xxxx_c2f, applied to the same object several times,
- yields the same handle. We do this because when MPI handles in
- C are a different length than those in Fortran, care needs to
+ yields the same handle. We do this because when MPI handles in
+ C are a different length than those in Fortran, care needs to
be exercised to ensure that the mapping from one to another is unique.
(Test added to test a potential problem in ROMIO for handling MPI_File
on 64-bit systems)
@@ -16,45 +16,45 @@
#include <stdio.h>
#include "mpitest.h"
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Fint handleA, handleB;
- int rc;
- int errs = 0;
- int buf[1];
+ int rc;
+ int errs = 0;
+ int buf[1];
MPI_Request cRequest;
MPI_Status st;
- int tFlag;
+ int tFlag;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
/* Request */
- rc = MPI_Irecv( buf, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &cRequest );
+ rc = MPI_Irecv(buf, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &cRequest);
if (rc) {
- errs++;
- printf( "Unable to create request\n" );
+ errs++;
+ printf("Unable to create request\n");
}
else {
- handleA = MPI_Request_c2f( cRequest );
- handleB = MPI_Request_c2f( cRequest );
- if (handleA != handleB) {
- errs++;
- printf( "MPI_Request_c2f does not give the same handle twice on the same MPI_Request\n" );
- }
+ handleA = MPI_Request_c2f(cRequest);
+ handleB = MPI_Request_c2f(cRequest);
+ if (handleA != handleB) {
+ errs++;
+ printf("MPI_Request_c2f does not give the same handle twice on the same MPI_Request\n");
+ }
}
- MPI_Cancel( &cRequest );
- MPI_Test( &cRequest, &tFlag, &st );
- MPI_Test_cancelled( &st, &tFlag );
+ MPI_Cancel(&cRequest);
+ MPI_Test(&cRequest, &tFlag, &st);
+ MPI_Test_cancelled(&st, &tFlag);
if (!tFlag) {
- errs++;
- printf( "Unable to cancel MPI_Irecv request\n" );
+ errs++;
+ printf("Unable to cancel MPI_Irecv request\n");
}
/* Using MPI_Request_free should be ok, but some MPI implementations
- object to it imediately after the cancel and that isn't essential to
- this test */
+ * object to it imediately after the cancel and that isn't essential to
+ * this test */
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
-
+
return 0;
}
diff --git a/test/mpi/f77/ext/ctypesfromc.c b/test/mpi/f77/ext/ctypesfromc.c
index 51015da..a5d22ff 100644
--- a/test/mpi/f77/ext/ctypesfromc.c
+++ b/test/mpi/f77/ext/ctypesfromc.c
@@ -11,8 +11,8 @@
* The tests follow this pattern:
*
* Fortran main program
- * calls the c routine f2ctype with each of the C types and the name of
- * the type. That c routine using MPI_Type_f2c to convert the
+ * calls the c routine f2ctype with each of the C types and the name of
+ * the type. That c routine using MPI_Type_f2c to convert the
* Fortran handle to a C handle, and then compares it to the corresponding
* C type, which is found by looking up the C handle by name
*
@@ -36,42 +36,45 @@
/* This is extracted from the test in test/mpi/types/typename.c ; only the
C types are included. */
-typedef struct mpi_names_t { MPI_Datatype dtype; const char *name; } mpi_names_t;
+typedef struct mpi_names_t {
+ MPI_Datatype dtype;
+ const char *name;
+} mpi_names_t;
/* The MPI standard specifies that the names must be the MPI names,
not the related language names (e.g., MPI_CHAR, not char) */
static mpi_names_t mpi_names[] = {
- { MPI_CHAR, "MPI_CHAR" },
- { MPI_SIGNED_CHAR, "MPI_SIGNED_CHAR" },
- { MPI_UNSIGNED_CHAR, "MPI_UNSIGNED_CHAR" },
- { MPI_WCHAR, "MPI_WCHAR" },
- { MPI_SHORT, "MPI_SHORT" },
- { MPI_UNSIGNED_SHORT, "MPI_UNSIGNED_SHORT" },
- { MPI_INT, "MPI_INT" },
- { MPI_UNSIGNED, "MPI_UNSIGNED" },
- { MPI_LONG, "MPI_LONG" },
- { MPI_UNSIGNED_LONG, "MPI_UNSIGNED_LONG" },
- { MPI_FLOAT, "MPI_FLOAT" },
- { MPI_DOUBLE, "MPI_DOUBLE" },
- { MPI_FLOAT_INT, "MPI_FLOAT_INT" },
- { MPI_DOUBLE_INT, "MPI_DOUBLE_INT" },
- { MPI_LONG_INT, "MPI_LONG_INT" },
- { MPI_SHORT_INT, "MPI_SHORT_INT" },
- { MPI_2INT, "MPI_2INT" },
- { MPI_LONG_DOUBLE, "MPI_LONG_DOUBLE" },
- { MPI_LONG_LONG_INT, "MPI_LONG_LONG_INT" },
- { MPI_LONG_LONG, "MPI_LONG_LONG" },
- { MPI_UNSIGNED_LONG_LONG, "MPI_UNSIGNED_LONG_LONG" },
- { MPI_LONG_DOUBLE_INT, "MPI_LONG_DOUBLE_INT" },
- { 0, (char *)0 }, /* Sentinal used to indicate the last element */
+ {MPI_CHAR, "MPI_CHAR"},
+ {MPI_SIGNED_CHAR, "MPI_SIGNED_CHAR"},
+ {MPI_UNSIGNED_CHAR, "MPI_UNSIGNED_CHAR"},
+ {MPI_WCHAR, "MPI_WCHAR"},
+ {MPI_SHORT, "MPI_SHORT"},
+ {MPI_UNSIGNED_SHORT, "MPI_UNSIGNED_SHORT"},
+ {MPI_INT, "MPI_INT"},
+ {MPI_UNSIGNED, "MPI_UNSIGNED"},
+ {MPI_LONG, "MPI_LONG"},
+ {MPI_UNSIGNED_LONG, "MPI_UNSIGNED_LONG"},
+ {MPI_FLOAT, "MPI_FLOAT"},
+ {MPI_DOUBLE, "MPI_DOUBLE"},
+ {MPI_FLOAT_INT, "MPI_FLOAT_INT"},
+ {MPI_DOUBLE_INT, "MPI_DOUBLE_INT"},
+ {MPI_LONG_INT, "MPI_LONG_INT"},
+ {MPI_SHORT_INT, "MPI_SHORT_INT"},
+ {MPI_2INT, "MPI_2INT"},
+ {MPI_LONG_DOUBLE, "MPI_LONG_DOUBLE"},
+ {MPI_LONG_LONG_INT, "MPI_LONG_LONG_INT"},
+ {MPI_LONG_LONG, "MPI_LONG_LONG"},
+ {MPI_UNSIGNED_LONG_LONG, "MPI_UNSIGNED_LONG_LONG"},
+ {MPI_LONG_DOUBLE_INT, "MPI_LONG_DOUBLE_INT"},
+ {0, (char *) 0}, /* Sentinal used to indicate the last element */
};
-/*
+/*
Name mapping. All routines are created with names that are lower case
with a single trailing underscore. This matches many compilers.
We use #define to change the name for Fortran compilers that do
- not use the lowercase/underscore pattern
+ not use the lowercase/underscore pattern
*/
#ifdef F77_NAME_UPPER
@@ -85,34 +88,34 @@ static mpi_names_t mpi_names[] = {
defined(F77_NAME_MIXED_USCORE)
/* Else leave name alone (routines have no underscore, so both
of these map to a lowercase, single underscore) */
-#else
+#else
#error 'Unrecognized Fortran name mapping'
#endif
/* Prototypes to keep compilers happy */
-int f2ctype_( MPI_Fint *, MPI_Fint * );
+int f2ctype_(MPI_Fint *, MPI_Fint *);
/* */
-int f2ctype_( MPI_Fint *fhandle, MPI_Fint *typeidx )
+int f2ctype_(MPI_Fint * fhandle, MPI_Fint * typeidx)
{
int errs = 0;
MPI_Datatype ctype;
- /* printf( "Testing %s\n", mpi_names[*typeidx].name ); */
- ctype = MPI_Type_f2c( *fhandle );
+ /* printf("Testing %s\n", mpi_names[*typeidx].name); */
+ ctype = MPI_Type_f2c(*fhandle);
if (ctype != mpi_names[*typeidx].dtype) {
- char mytypename[MPI_MAX_OBJECT_NAME];
- int mytypenamelen;
- /* An implementation is not *required* to deliver the
- corresponding C version of the MPI Datatype bit-for-bit. But
- if *must* act like it - e.g., the datatype name must be the same */
- MPI_Type_get_name( ctype, mytypename, &mytypenamelen );
- if (strcmp( mytypename, mpi_names[*typeidx].name ) != 0) {
- errs++;
- printf( "C and Fortran types for %s (c name is %s) do not match f=%d, ctof=%d.\n",
- mpi_names[*typeidx].name, mytypename, *fhandle, MPI_Type_c2f( ctype ) );
- }
+ char mytypename[MPI_MAX_OBJECT_NAME];
+ int mytypenamelen;
+ /* An implementation is not *required* to deliver the
+ * corresponding C version of the MPI Datatype bit-for-bit. But
+ * if *must* act like it - e.g., the datatype name must be the same */
+ MPI_Type_get_name(ctype, mytypename, &mytypenamelen);
+ if (strcmp(mytypename, mpi_names[*typeidx].name) != 0) {
+ errs++;
+ printf("C and Fortran types for %s (c name is %s) do not match f=%d, ctof=%d.\n",
+ mpi_names[*typeidx].name, mytypename, *fhandle, MPI_Type_c2f(ctype));
+ }
}
-
+
return errs;
}
diff --git a/test/mpi/f77/io/c2f2cio.c b/test/mpi/f77/io/c2f2cio.c
index 37f5e5c..5c1371f 100644
--- a/test/mpi/f77/io/c2f2cio.c
+++ b/test/mpi/f77/io/c2f2cio.c
@@ -5,7 +5,7 @@
* See COPYRIGHT in top-level directory.
*/
/*
- * This file contains the C routines used in testing the c2f and f2c
+ * This file contains the C routines used in testing the c2f and f2c
* handle conversion functions for MPI_File
* The tests follow this pattern:
*
@@ -29,11 +29,11 @@
#include "../../include/mpitestconf.h"
#include <string.h>
-/*
+/*
Name mapping. All routines are created with names that are lower case
with a single trailing underscore. This matches many compilers.
We use #define to change the name for Fortran compilers that do
- not use the lowercase/underscore pattern
+ not use the lowercase/underscore pattern
*/
#ifdef F77_NAME_UPPER
@@ -49,48 +49,48 @@
defined(F77_NAME_MIXED_USCORE)
/* Else leave name alone (routines have no underscore, so both
of these map to a lowercase, single underscore) */
-#else
+#else
#error 'Unrecognized Fortran name mapping'
#endif
/* Prototypes to keep compilers happy */
-int c2ffile_( int * );
-void f2cfile_( int * );
+int c2ffile_(int *);
+void f2cfile_(int *);
-int c2ffile_ ( int *file )
+int c2ffile_(int *file)
{
- MPI_File cFile = MPI_File_f2c( *file );
+ MPI_File cFile = MPI_File_f2c(*file);
MPI_Group group, wgroup;
int result;
- MPI_File_get_group( cFile, &group );
- MPI_Comm_group( MPI_COMM_WORLD, &wgroup );
+ MPI_File_get_group(cFile, &group);
+ MPI_Comm_group(MPI_COMM_WORLD, &wgroup);
- MPI_Group_compare( group, wgroup, &result );
+ MPI_Group_compare(group, wgroup, &result);
if (result != MPI_IDENT) {
- fprintf( stderr, "File: did not get expected group\n" );
- return 1;
+ fprintf(stderr, "File: did not get expected group\n");
+ return 1;
}
- MPI_Group_free( &group );
- MPI_Group_free( &wgroup );
+ MPI_Group_free(&group);
+ MPI_Group_free(&wgroup);
return 0;
}
-/*
+/*
* The following routines provide handles to the calling Fortran program
*/
-void f2cfile_( int *file )
+void f2cfile_(int *file)
{
MPI_File cFile;
int rc;
- rc = MPI_File_open( MPI_COMM_WORLD, (char*)"temp",
- MPI_MODE_RDWR | MPI_MODE_DELETE_ON_CLOSE | MPI_MODE_CREATE,
- MPI_INFO_NULL, &cFile );
+ rc = MPI_File_open(MPI_COMM_WORLD, (char *) "temp",
+ MPI_MODE_RDWR | MPI_MODE_DELETE_ON_CLOSE | MPI_MODE_CREATE,
+ MPI_INFO_NULL, &cFile);
if (rc) {
- *file = 0;
+ *file = 0;
}
else {
- *file = MPI_File_c2f( cFile );
+ *file = MPI_File_c2f(cFile);
}
}
diff --git a/test/mpi/f77/io/c2fmultio.c b/test/mpi/f77/io/c2fmultio.c
index fae6834..5d25960 100644
--- a/test/mpi/f77/io/c2fmultio.c
+++ b/test/mpi/f77/io/c2fmultio.c
@@ -6,8 +6,8 @@
/*
Check that MPI_File_c2f, applied to the same object several times,
- yields the same handle. We do this because when MPI handles in
- C are a different length than those in Fortran, care needs to
+ yields the same handle. We do this because when MPI handles in
+ C are a different length than those in Fortran, care needs to
be exercised to ensure that the mapping from one to another is unique.
(Test added to test a potential problem in ROMIO for handling MPI_File
on 64-bit systems)
@@ -15,45 +15,45 @@
#include "mpi.h"
#include <stdio.h>
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Fint handleA, handleB;
- int rc;
- int errs = 0;
- int rank;
+ int rc;
+ int errs = 0;
+ int rank;
MPI_File cFile;
- MPI_Init( &argc, &argv );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+ MPI_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
/* File */
- rc = MPI_File_open( MPI_COMM_WORLD, (char*)"temp",
- MPI_MODE_RDWR | MPI_MODE_DELETE_ON_CLOSE | MPI_MODE_CREATE,
- MPI_INFO_NULL, &cFile );
+ rc = MPI_File_open(MPI_COMM_WORLD, (char *) "temp",
+ MPI_MODE_RDWR | MPI_MODE_DELETE_ON_CLOSE | MPI_MODE_CREATE,
+ MPI_INFO_NULL, &cFile);
if (rc) {
- errs++;
- printf( "Unable to open file \"temp\"\n" );
+ errs++;
+ printf("Unable to open file \"temp\"\n");
}
else {
- handleA = MPI_File_c2f( cFile );
- handleB = MPI_File_c2f( cFile );
- if (handleA != handleB) {
- errs++;
- printf( "MPI_File_c2f does not give the same handle twice on the same MPI_File\n" );
- }
+ handleA = MPI_File_c2f(cFile);
+ handleB = MPI_File_c2f(cFile);
+ if (handleA != handleB) {
+ errs++;
+ printf("MPI_File_c2f does not give the same handle twice on the same MPI_File\n");
+ }
}
- MPI_File_close( &cFile );
+ MPI_File_close(&cFile);
if (rank == 0) {
- if (errs) {
- fprintf(stderr, "Found %d errors\n", errs);
- }
- else {
- printf(" No Errors\n");
- }
+ if (errs) {
+ fprintf(stderr, "Found %d errors\n", errs);
+ }
+ else {
+ printf(" No Errors\n");
+ }
}
-
+
MPI_Finalize();
-
+
return 0;
}
diff --git a/test/mpi/f77/io/ioaint.h.in b/test/mpi/f77/io/ioaint.h.in
index b494484..12f03da 100644
--- a/test/mpi/f77/io/ioaint.h.in
+++ b/test/mpi/f77/io/ioaint.h.in
@@ -1,6 +1,4 @@
-C -*- Mode: Fortran; -*-
-C
-C (C) 2003 by Argonne National Laboratory.
-C See COPYRIGHT in top-level directory.
-C
- @F77_MPI_ADDRESS@ aint
+C - *-Mode:Fortran;
+-*-C C(C)
+2003 by Argonne National Laboratory.C See COPYRIGHT in top - level directory.C
+ @ F77_MPI_ADDRESS @ aint
diff --git a/test/mpi/f77/io/iodisp.h.in b/test/mpi/f77/io/iodisp.h.in
index 9ce4709..3d8da4c 100644
--- a/test/mpi/f77/io/iodisp.h.in
+++ b/test/mpi/f77/io/iodisp.h.in
@@ -1,6 +1,4 @@
-C -*- Mode: Fortran; -*-
-C
-C (C) 2003 by Argonne National Laboratory.
-C See COPYRIGHT in top-level directory.
-C
- @F77_MPI_OFFSET@ disp
+C - *-Mode:Fortran;
+-*-C C(C)
+2003 by Argonne National Laboratory.C See COPYRIGHT in top - level directory.C
+ @ F77_MPI_OFFSET @ disp
diff --git a/test/mpi/f77/io/iooffset.h.in b/test/mpi/f77/io/iooffset.h.in
index 61cd7c6..c0b4952 100644
--- a/test/mpi/f77/io/iooffset.h.in
+++ b/test/mpi/f77/io/iooffset.h.in
@@ -1,6 +1,4 @@
-C -*- Mode: Fortran; -*-
-C
-C (C) 2003 by Argonne National Laboratory.
-C See COPYRIGHT in top-level directory.
-C
- @F77_MPI_OFFSET@ offset
+C - *-Mode:Fortran;
+-*-C C(C)
+2003 by Argonne National Laboratory.C See COPYRIGHT in top - level directory.C
+ @ F77_MPI_OFFSET @ offset
diff --git a/test/mpi/f77/pt2pt/attr1aints.h.in b/test/mpi/f77/pt2pt/attr1aints.h.in
index b8113dd..d814372 100644
--- a/test/mpi/f77/pt2pt/attr1aints.h.in
+++ b/test/mpi/f77/pt2pt/attr1aints.h.in
@@ -1,6 +1,4 @@
-C -*- Mode: Fortran; -*-
-C
-C (C) 2003 by Argonne National Laboratory.
-C See COPYRIGHT in top-level directory.
-C
- @F77_MPI_ADDRESS@ extrastate, valin, valout, val
+C - *-Mode:Fortran;
+-*-C C(C)
+2003 by Argonne National Laboratory.C See COPYRIGHT in top - level directory.C
+ @ F77_MPI_ADDRESS @ extrastate, valin, valout, val
diff --git a/test/mpi/f77/rma/addsize.h.in b/test/mpi/f77/rma/addsize.h.in
index 320b3a5..8a5f4fd 100644
--- a/test/mpi/f77/rma/addsize.h.in
+++ b/test/mpi/f77/rma/addsize.h.in
@@ -1,6 +1,4 @@
-C -*- Mode: Fortran; -*-
-C
-C (C) 2003 by Argonne National Laboratory.
-C See COPYRIGHT in top-level directory.
-C
- @F77_MPI_ADDRESS@ asize
+C - *-Mode:Fortran;
+-*-C C(C)
+2003 by Argonne National Laboratory.C See COPYRIGHT in top - level directory.C
+ @ F77_MPI_ADDRESS @ asize
diff --git a/test/mpi/f77/rma/c2f2cwin.c b/test/mpi/f77/rma/c2f2cwin.c
index c09933e..08b92ac 100644
--- a/test/mpi/f77/rma/c2f2cwin.c
+++ b/test/mpi/f77/rma/c2f2cwin.c
@@ -5,8 +5,8 @@
* See COPYRIGHT in top-level directory.
*/
/*
- * This file contains the C routines used in testing the c2f and f2c
- * handle conversion functions for MPI_Win
+ * This file contains the C routines used in testing the c2f and f2c
+ * handle conversion functions for MPI_Win
*
* The tests follow this pattern:
*
@@ -30,11 +30,11 @@
#include "../../include/mpitestconf.h"
#include <string.h>
-/*
+/*
Name mapping. All routines are created with names that are lower case
with a single trailing underscore. This matches many compilers.
We use #define to change the name for Fortran compilers that do
- not use the lowercase/underscore pattern
+ not use the lowercase/underscore pattern
*/
#ifdef F77_NAME_UPPER
@@ -50,42 +50,41 @@
defined(F77_NAME_MIXED_USCORE)
/* Else leave name alone (routines have no underscore, so both
of these map to a lowercase, single underscore) */
-#else
+#else
#error 'Unrecognized Fortran name mapping'
#endif
/* Prototypes to keep compilers happy */
-int c2fwin_( int * );
-void f2cwin_( int * );
+int c2fwin_(int *);
+void f2cwin_(int *);
-int c2fwin_( int *win )
+int c2fwin_(int *win)
{
- MPI_Win cWin = MPI_Win_f2c( *win );
+ MPI_Win cWin = MPI_Win_f2c(*win);
MPI_Group group, wgroup;
int result;
- MPI_Win_get_group( cWin, &group );
- MPI_Comm_group( MPI_COMM_WORLD, &wgroup );
+ MPI_Win_get_group(cWin, &group);
+ MPI_Comm_group(MPI_COMM_WORLD, &wgroup);
- MPI_Group_compare( group, wgroup, &result );
+ MPI_Group_compare(group, wgroup, &result);
if (result != MPI_IDENT) {
- fprintf( stderr, "Win: did not get expected group\n" );
- return 1;
+ fprintf(stderr, "Win: did not get expected group\n");
+ return 1;
}
- MPI_Group_free( &group );
- MPI_Group_free( &wgroup );
+ MPI_Group_free(&group);
+ MPI_Group_free(&wgroup);
return 0;
}
-/*
+/*
* The following routines provide handles to the calling Fortran program
*/
-void f2cwin_( int *win )
+void f2cwin_(int *win)
{
MPI_Win cWin;
- MPI_Win_create( 0, 0, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &cWin );
- *win = MPI_Win_c2f( cWin );
+ MPI_Win_create(0, 0, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &cWin);
+ *win = MPI_Win_c2f(cWin);
}
-
diff --git a/test/mpi/f77/spawn/type1aint.h.in b/test/mpi/f77/spawn/type1aint.h.in
index dc00288..12f03da 100644
--- a/test/mpi/f77/spawn/type1aint.h.in
+++ b/test/mpi/f77/spawn/type1aint.h.in
@@ -1,6 +1,4 @@
-C -*- Mode: Fortran; -*-
-C
-C (C) 2003 by Argonne National Laboratory.
-C See COPYRIGHT in top-level directory.
-C
- @F77_MPI_ADDRESS@ aint
+C - *-Mode:Fortran;
+-*-C C(C)
+2003 by Argonne National Laboratory.C See COPYRIGHT in top - level directory.C
+ @ F77_MPI_ADDRESS @ aint
diff --git a/test/mpi/f90/attr/attrlangc.c b/test/mpi/f90/attr/attrlangc.c
index 2ee4ef5..f12e6d6 100644
--- a/test/mpi/f90/attr/attrlangc.c
+++ b/test/mpi/f90/attr/attrlangc.c
@@ -15,17 +15,17 @@
C strings */
#define MAX_ATTRTEST_MSG 256
-/*
+/*
* FIXME: This code assumes that character strings are passed from Fortran
* by placing the string length, as an int, at the end of the argument list
- * This is common but not universal.
+ * This is common but not universal.
*/
-/*
+/*
Name mapping. All routines are created with names that are lower case
with a single trailing underscore. This matches many compilers.
We use #define to change the name for Fortran compilers that do
- not use the lowercase/underscore pattern
+ not use the lowercase/underscore pattern
*/
#ifdef F77_NAME_UPPER
@@ -65,7 +65,7 @@
defined(F77_NAME_MIXED_USCORE)
/* Else leave name alone (routines have no underscore, so both
of these map to a lowercase, single underscore) */
-#else
+#else
#error 'Unrecognized Fortran name mapping'
#endif
@@ -75,119 +75,121 @@ static int ccomm1Extra, ccomm2Extra, ctype2Extra, cwin2Extra;
static int verbose = 0;
/* Forward references */
-int cmpi1read( MPI_Comm comm, int key, void *expected, const char *msg );
-int cmpi2read( MPI_Comm comm, int key, void *expected, const char *msg );
-int cmpi2readtype( MPI_Datatype dtype, int key, void *expected, const char *msg );
+int cmpi1read(MPI_Comm comm, int key, void *expected, const char *msg);
+int cmpi2read(MPI_Comm comm, int key, void *expected, const char *msg);
+int cmpi2readtype(MPI_Datatype dtype, int key, void *expected, const char *msg);
-void ccompareint2aint_( MPI_Fint *in1, MPI_Aint *in2, MPI_Fint *result );
-void ccompareint2void_( MPI_Fint *in1, void *in2, MPI_Fint *result );
-void ccompareaint2void_( MPI_Aint *in1, void *in2, MPI_Fint *result );
+void ccompareint2aint_(MPI_Fint * in1, MPI_Aint * in2, MPI_Fint * result);
+void ccompareint2void_(MPI_Fint * in1, void *in2, MPI_Fint * result);
+void ccompareaint2void_(MPI_Aint * in1, void *in2, MPI_Fint * result);
/* ----------------------------------------------------------------------- */
/* Initialization functions */
/* ----------------------------------------------------------------------- */
-void cgetenvbool_( const char str[], MPI_Fint *val, int d )
+void cgetenvbool_(const char str[], MPI_Fint * val, int d)
{
const char *envval;
- char envname[1024];
+ char envname[1024];
/* Note that the Fortran string may not be null terminated; thus
- we copy d characters and add a null just in case */
- if (d > sizeof(envname)-1) {
- fprintf( stderr, "Environment variable name too long (%d)\n", d );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ * we copy d characters and add a null just in case */
+ if (d > sizeof(envname) - 1) {
+ fprintf(stderr, "Environment variable name too long (%d)\n", d);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- strncpy( envname, str, d );
+ strncpy(envname, str, d);
envname[d] = 0;
- envval = getenv( envname );
+ envval = getenv(envname);
*val = 0;
if (envval) {
- printf( " envval = %s\n", envval );
- if (strcmp(envval,"yes") == 0 || strcmp(envval,"YES") == 0 ||
- strcmp(envval,"true") == 0 || strcmp(envval,"TRUE") == 0 )
- *val = 1;
+ printf(" envval = %s\n", envval);
+ if (strcmp(envval, "yes") == 0 || strcmp(envval, "YES") == 0 ||
+ strcmp(envval, "true") == 0 || strcmp(envval, "TRUE") == 0)
+ *val = 1;
}
}
/* Keep our own copy of the "is verbose" state */
-void cattrinit_( MPI_Fint *fverbose )
+void cattrinit_(MPI_Fint * fverbose)
{
- verbose = (int)*fverbose;
+ verbose = (int) *fverbose;
}
/* Provide attribute sizes (C, Fortran 1, Fortran 2) */
-void cgetsizes_( MPI_Fint *ptrSize, MPI_Fint *intSize, MPI_Fint *aintSize )
+void cgetsizes_(MPI_Fint * ptrSize, MPI_Fint * intSize, MPI_Fint * aintSize)
{
- *ptrSize = (MPI_Fint) sizeof(void*);
- *intSize = (MPI_Fint) sizeof(MPI_Fint);
+ *ptrSize = (MPI_Fint) sizeof(void *);
+ *intSize = (MPI_Fint) sizeof(MPI_Fint);
*aintSize = (MPI_Fint) sizeof(MPI_Aint);
}
/* ----------------------------------------------------------------------- */
/* Copy and delete functions attached to keyvals */
/* ----------------------------------------------------------------------- */
-static int CMPI1_COPY_FN( MPI_Comm comm, int keyval, void *extra,
- void *inval, void *outval, int *flag )
+static int CMPI1_COPY_FN(MPI_Comm comm, int keyval, void *extra,
+ void *inval, void *outval, int *flag)
{
- int inValue = *(int *)inval;
+ int inValue = *(int *) inval;
- if (verbose) printf( " In C MPI-1 copy function: inval = %p, extra = %p\n",
- inval, extra );
+ if (verbose)
+ printf(" In C MPI-1 copy function: inval = %p, extra = %p\n", inval, extra);
*flag = 1;
/* We don't change the attribute */
- *(void **)outval = inval;
+ *(void **) outval = inval;
/* But we do change what it points at */
- *(int*)inval = inValue + 1;
+ *(int *) inval = inValue + 1;
return MPI_SUCCESS;
}
-static int CMPI1_DELETE_FN( MPI_Comm comm, int keyval, void *outval,
- void *extra )
+
+static int CMPI1_DELETE_FN(MPI_Comm comm, int keyval, void *outval, void *extra)
{
- if (verbose) printf( " In C MPI-1 delete function, extra = %p\n", extra );
- *(int*)outval = *(int*)outval - 1;
+ if (verbose)
+ printf(" In C MPI-1 delete function, extra = %p\n", extra);
+ *(int *) outval = *(int *) outval - 1;
return MPI_SUCCESS;
}
-static int TYPE_COPY_FN( MPI_Datatype dtype, int keyval, void *extra,
- void *inval, void *outval, int *flag )
+static int TYPE_COPY_FN(MPI_Datatype dtype, int keyval, void *extra,
+ void *inval, void *outval, int *flag)
{
- int inValue = *(int *)inval;
+ int inValue = *(int *) inval;
- if (verbose)
- printf( " In C MPI type copy function, inval = %p, extra = %p\n",
- inval, extra );
+ if (verbose)
+ printf(" In C MPI type copy function, inval = %p, extra = %p\n", inval, extra);
*flag = 1;
/* We don't change the attribute */
- *(void **)outval = inval;
+ *(void **) outval = inval;
/* But we do change what it points at */
- *(int*)inval = inValue + 1;
+ *(int *) inval = inValue + 1;
return MPI_SUCCESS;
}
-static int TYPE_DELETE_FN( MPI_Datatype dtype, int keyval, void *outval,
- void *extra )
+
+static int TYPE_DELETE_FN(MPI_Datatype dtype, int keyval, void *outval, void *extra)
{
- if (verbose) printf( " In C MPI type delete function, extra = %p\n", extra );
+ if (verbose)
+ printf(" In C MPI type delete function, extra = %p\n", extra);
/* We reverse the incrment used in copy (checked after free of the type) */
- *(int*)outval = *(int*)outval - 1;
+ *(int *) outval = *(int *) outval - 1;
return MPI_SUCCESS;
}
-/* Note that this function cannot be called in MPI since there is no
+/* Note that this function cannot be called in MPI since there is no
win_dup function */
-static int WIN_COPY_FN( MPI_Win win, int keyval, void *extra,
- void *inval, void *outval, int *flag )
+static int WIN_COPY_FN(MPI_Win win, int keyval, void *extra, void *inval, void *outval, int *flag)
{
- int inValue = *(int *)inval;
+ int inValue = *(int *) inval;
- if (verbose) printf( "PANIC: In C MPI win copy function (should never happen)\n" );
+ if (verbose)
+ printf("PANIC: In C MPI win copy function (should never happen)\n");
*flag = 1;
return MPI_SUCCESS;
}
-static int WIN_DELETE_FN( MPI_Win win, int keyval, void *outval,
- void *extra )
+
+static int WIN_DELETE_FN(MPI_Win win, int keyval, void *outval, void *extra)
{
- if (verbose) printf( " In C MPI win delete function, extra = %p\n", extra );
- *(int*)outval = *(int*)outval - 1;
+ if (verbose)
+ printf(" In C MPI win delete function, extra = %p\n", extra);
+ *(int *) outval = *(int *) outval - 1;
return MPI_SUCCESS;
}
@@ -195,32 +197,28 @@ static int WIN_DELETE_FN( MPI_Win win, int keyval, void *outval,
/* Routines to create keyvals in C (with C copy and delete functions */
/* ----------------------------------------------------------------------- */
-void ccreatekeys_( MPI_Fint *ccomm1_key, MPI_Fint *ccomm2_key,
- MPI_Fint *ctype2_key, MPI_Fint *cwin2_key )
+void ccreatekeys_(MPI_Fint * ccomm1_key, MPI_Fint * ccomm2_key,
+ MPI_Fint * ctype2_key, MPI_Fint * cwin2_key)
{
- MPI_Keyval_create( CMPI1_COPY_FN, CMPI1_DELETE_FN, &ccomm1Key,
- &ccomm1Extra );
- *ccomm1_key = (MPI_Fint)ccomm1Key;
-
- MPI_Comm_create_keyval( CMPI1_COPY_FN, CMPI1_DELETE_FN, &ccomm2Key,
- &ccomm2Extra );
- *ccomm2_key = (MPI_Fint)ccomm2Key;
-
- MPI_Type_create_keyval( TYPE_COPY_FN, TYPE_DELETE_FN, &ctype2Key,
- &ctype2Extra );
- *ctype2_key = (MPI_Fint)ctype2Key;
-
- MPI_Win_create_keyval( WIN_COPY_FN, WIN_DELETE_FN, &cwin2Key,
- &cwin2Extra );
- *cwin2_key = (MPI_Fint)cwin2Key;
+ MPI_Keyval_create(CMPI1_COPY_FN, CMPI1_DELETE_FN, &ccomm1Key, &ccomm1Extra);
+ *ccomm1_key = (MPI_Fint) ccomm1Key;
+
+ MPI_Comm_create_keyval(CMPI1_COPY_FN, CMPI1_DELETE_FN, &ccomm2Key, &ccomm2Extra);
+ *ccomm2_key = (MPI_Fint) ccomm2Key;
+
+ MPI_Type_create_keyval(TYPE_COPY_FN, TYPE_DELETE_FN, &ctype2Key, &ctype2Extra);
+ *ctype2_key = (MPI_Fint) ctype2Key;
+
+ MPI_Win_create_keyval(WIN_COPY_FN, WIN_DELETE_FN, &cwin2Key, &cwin2Extra);
+ *cwin2_key = (MPI_Fint) cwin2Key;
}
void cfreekeys_(void)
{
- MPI_Keyval_free( &ccomm1Key );
- MPI_Comm_free_keyval( &ccomm2Key );
- MPI_Type_free_keyval( &ctype2Key );
- MPI_Win_free_keyval( &cwin2Key );
+ MPI_Keyval_free(&ccomm1Key);
+ MPI_Comm_free_keyval(&ccomm2Key);
+ MPI_Type_free_keyval(&ctype2Key);
+ MPI_Win_free_keyval(&cwin2Key);
}
/* ----------------------------------------------------------------------- */
@@ -229,82 +227,76 @@ void cfreekeys_(void)
/* Test c-to-c attributes */
static int ccomm1Attr, ccomm2Attr, ctype2Attr, cwin2Attr;
-void ctoctest_( MPI_Fint *errs )
+void ctoctest_(MPI_Fint * errs)
{
int errcnt = *errs;
- int baseattrval = (1 << (sizeof(int)*8-2))-3;
+ int baseattrval = (1 << (sizeof(int) * 8 - 2)) - 3;
MPI_Datatype cduptype;
- MPI_Comm cdup;
+ MPI_Comm cdup;
/* MPI-1 function */
ccomm1Attr = baseattrval;
- MPI_Attr_put( MPI_COMM_SELF, ccomm1Key, &ccomm1Attr );
+ MPI_Attr_put(MPI_COMM_SELF, ccomm1Key, &ccomm1Attr);
/* Test that we have the same value */
- errcnt += cmpi1read( MPI_COMM_SELF, ccomm1Key, &ccomm1Attr, "C to C" );
+ errcnt += cmpi1read(MPI_COMM_SELF, ccomm1Key, &ccomm1Attr, "C to C");
/* Dup, check that the copy routine does what is expected */
- MPI_Comm_dup( MPI_COMM_SELF, &cdup );
- errcnt += cmpi1read( cdup, ccomm1Key, &ccomm1Attr, "C to C dup" );
+ MPI_Comm_dup(MPI_COMM_SELF, &cdup);
+ errcnt += cmpi1read(cdup, ccomm1Key, &ccomm1Attr, "C to C dup");
if (ccomm1Attr != baseattrval + 1) {
- printf( " Did not increment int in C to C dup: %d %d\n",
- ccomm1Attr, baseattrval + 1 );
- errcnt ++;
+ printf(" Did not increment int in C to C dup: %d %d\n", ccomm1Attr, baseattrval + 1);
+ errcnt++;
}
- MPI_Comm_free( &cdup );
+ MPI_Comm_free(&cdup);
if (ccomm1Attr != baseattrval) {
- printf( " Did not increment int in C to C delete: %d %d\n",
- ccomm1Attr, baseattrval );
- errcnt ++;
+ printf(" Did not increment int in C to C delete: %d %d\n", ccomm1Attr, baseattrval);
+ errcnt++;
}
/* MPI-2 functions */
ccomm1Attr = 0;
ccomm2Attr = baseattrval;
- MPI_Comm_set_attr( MPI_COMM_SELF, ccomm2Key, &ccomm2Attr );
+ MPI_Comm_set_attr(MPI_COMM_SELF, ccomm2Key, &ccomm2Attr);
/* Test that we have the same value */
- errcnt += cmpi2read( MPI_COMM_SELF, ccomm2Key, &ccomm2Attr, "C to C (2)" );
+ errcnt += cmpi2read(MPI_COMM_SELF, ccomm2Key, &ccomm2Attr, "C to C (2)");
/* Dup, check that the copy routine does what is expected */
- MPI_Comm_dup( MPI_COMM_SELF, &cdup );
- errcnt += cmpi2read( cdup, ccomm2Key, &ccomm2Attr, "C to C dup (2)" );
+ MPI_Comm_dup(MPI_COMM_SELF, &cdup);
+ errcnt += cmpi2read(cdup, ccomm2Key, &ccomm2Attr, "C to C dup (2)");
if (ccomm2Attr != baseattrval + 1) {
- printf( " Did not increment int in C to C dup: %d %d\n",
- ccomm2Attr, baseattrval + 1 );
- errcnt ++;
+ printf(" Did not increment int in C to C dup: %d %d\n", ccomm2Attr, baseattrval + 1);
+ errcnt++;
}
- MPI_Comm_free( &cdup );
+ MPI_Comm_free(&cdup);
if (ccomm2Attr != baseattrval) {
- printf( " Did not increment int in C to C delete (2): %d %d\n",
- ccomm2Attr, baseattrval );
- errcnt ++;
+ printf(" Did not increment int in C to C delete (2): %d %d\n", ccomm2Attr, baseattrval);
+ errcnt++;
}
/* MPI-2 functions */
ctype2Attr = baseattrval;
- MPI_Type_set_attr( MPI_INTEGER, ctype2Key, &ctype2Attr );
+ MPI_Type_set_attr(MPI_INTEGER, ctype2Key, &ctype2Attr);
/* Test that we have the same value */
- errcnt += cmpi2readtype( MPI_INTEGER, ctype2Key, &ctype2Attr, "C to C type (2)" );
+ errcnt += cmpi2readtype(MPI_INTEGER, ctype2Key, &ctype2Attr, "C to C type (2)");
/* Dup, check that the copy routine does what is expected */
- MPI_Type_dup( MPI_INTEGER, &cduptype );
- errcnt += cmpi2readtype( cduptype, ctype2Key, &ctype2Attr, "C to C typedup (2)" );
+ MPI_Type_dup(MPI_INTEGER, &cduptype);
+ errcnt += cmpi2readtype(cduptype, ctype2Key, &ctype2Attr, "C to C typedup (2)");
if (ctype2Attr != baseattrval + 1) {
- printf( " Did not increment int in C to C typedup: %d %d\n",
- ctype2Attr, baseattrval + 1 );
- errcnt ++;
+ printf(" Did not increment int in C to C typedup: %d %d\n", ctype2Attr, baseattrval + 1);
+ errcnt++;
}
ccomm1Attr = 0;
- MPI_Type_free( &cduptype );
+ MPI_Type_free(&cduptype);
if (ctype2Attr != baseattrval) {
- printf( " Did not increment int in C to C typedelete (2): %d %d\n",
- ctype2Attr, baseattrval );
- errcnt ++;
+ printf(" Did not increment int in C to C typedelete (2): %d %d\n", ctype2Attr, baseattrval);
+ errcnt++;
}
-
+
*errs = errcnt;
}
@@ -313,199 +305,201 @@ void ctoctest_( MPI_Fint *errs )
/* of errors found */
/* ----------------------------------------------------------------------- */
-int cmpi1read( MPI_Comm comm, int key, void *expected, const char *msg )
+int cmpi1read(MPI_Comm comm, int key, void *expected, const char *msg)
{
void *attrval;
- int flag;
- MPI_Attr_get( comm, key, &attrval, &flag );
+ int flag;
+ MPI_Attr_get(comm, key, &attrval, &flag);
if (!flag) {
- printf( " Error: flag false for Attr_get: %s\n", msg );
- return 1;
+ printf(" Error: flag false for Attr_get: %s\n", msg);
+ return 1;
}
if (attrval != expected) {
- printf( " Error: expected %p but saw %p: %s\n", expected, attrval, msg );
- return 1;
+ printf(" Error: expected %p but saw %p: %s\n", expected, attrval, msg);
+ return 1;
}
return 0;
}
-int cmpi2read( MPI_Comm comm, int key, void *expected, const char *msg )
+int cmpi2read(MPI_Comm comm, int key, void *expected, const char *msg)
{
void *attrval;
- int flag;
- MPI_Comm_get_attr( comm, key, &attrval, &flag );
+ int flag;
+ MPI_Comm_get_attr(comm, key, &attrval, &flag);
if (!flag) {
- printf( " Error: flag false for Comm_get_attr: %s\n", msg );
- return 1;
+ printf(" Error: flag false for Comm_get_attr: %s\n", msg);
+ return 1;
}
if (attrval != expected) {
- printf( " Error: expected %p but saw %p: %s\n", expected, attrval, msg );
- return 1;
+ printf(" Error: expected %p but saw %p: %s\n", expected, attrval, msg);
+ return 1;
}
return 0;
}
-int cmpi2readtype( MPI_Datatype dtype, int key, void *expected, const char *msg )
+int cmpi2readtype(MPI_Datatype dtype, int key, void *expected, const char *msg)
{
void *attrval;
- int flag;
- MPI_Type_get_attr( dtype, key, &attrval, &flag );
+ int flag;
+ MPI_Type_get_attr(dtype, key, &attrval, &flag);
if (!flag) {
- printf( " Error: flag false for Type_get_attr: %s\n", msg );
- return 1;
+ printf(" Error: flag false for Type_get_attr: %s\n", msg);
+ return 1;
}
if (attrval != expected) {
- printf( " Error: expected %p but saw %p: %s\n", expected, attrval, msg );
- return 1;
+ printf(" Error: expected %p but saw %p: %s\n", expected, attrval, msg);
+ return 1;
}
return 0;
}
-int cmpi2readwin( MPI_Win win, int key, void *expected, const char *msg )
+
+int cmpi2readwin(MPI_Win win, int key, void *expected, const char *msg)
{
void *attrval;
- int flag;
- MPI_Win_get_attr( win, key, &attrval, &flag );
+ int flag;
+ MPI_Win_get_attr(win, key, &attrval, &flag);
if (!flag) {
- printf( " Error: flag false for Win_get_attr: %s\n", msg );
- return 1;
+ printf(" Error: flag false for Win_get_attr: %s\n", msg);
+ return 1;
}
if (attrval != expected) {
- printf( " Error: expected %p but saw %p: %s\n", expected, attrval, msg );
- return 1;
+ printf(" Error: expected %p but saw %p: %s\n", expected, attrval, msg);
+ return 1;
}
return 0;
}
/* Set in Fortran (MPI-1), read in C */
-void cmpif1read_( MPI_Fint *fcomm, MPI_Fint *fkey, MPI_Fint *expected,
- MPI_Fint *errs, const char *msg, int msglen )
+void cmpif1read_(MPI_Fint * fcomm, MPI_Fint * fkey, MPI_Fint * expected,
+ MPI_Fint * errs, const char *msg, int msglen)
{
void *attrval;
- int flag, result;
- MPI_Comm comm = MPI_Comm_f2c( *fcomm );
+ int flag, result;
+ MPI_Comm comm = MPI_Comm_f2c(*fcomm);
char lmsg[MAX_ATTRTEST_MSG];
- if (msglen > sizeof(lmsg)- 1) {
- fprintf( stderr, "Message too long for buffer (%d)\n", msglen );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ if (msglen > sizeof(lmsg) - 1) {
+ fprintf(stderr, "Message too long for buffer (%d)\n", msglen);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- MPI_Attr_get( comm, *fkey, &attrval, &flag );
+ MPI_Attr_get(comm, *fkey, &attrval, &flag);
if (!flag) {
- *errs = *errs + 1;
- strncpy( lmsg, msg, msglen );
- lmsg[msglen] = 0;
- printf( " Error: flag false for Attr_get (set in F1): %s\n", lmsg );
- return;
+ *errs = *errs + 1;
+ strncpy(lmsg, msg, msglen);
+ lmsg[msglen] = 0;
+ printf(" Error: flag false for Attr_get (set in F1): %s\n", lmsg);
+ return;
}
/* Must be careful to compare as required in the MPI specification */
- ccompareint2void_( expected, attrval, &result );
+ ccompareint2void_(expected, attrval, &result);
if (!result) {
- *errs = *errs + 1;
- strncpy( lmsg, msg, msglen );
- lmsg[msglen] = 0;
- printf( " Error: (set in F1) expected %d but saw %d: %s\n",
- *expected, *(MPI_Fint*)attrval, lmsg );
- return;
+ *errs = *errs + 1;
+ strncpy(lmsg, msg, msglen);
+ lmsg[msglen] = 0;
+ printf(" Error: (set in F1) expected %d but saw %d: %s\n",
+ *expected, *(MPI_Fint *) attrval, lmsg);
+ return;
}
return;
}
/* Set in Fortran (MPI-2), read in C */
-void cmpif2read_( MPI_Fint *fcomm, MPI_Fint *fkey, MPI_Aint *expected,
- MPI_Fint *errs, const char *msg, int msglen )
+void cmpif2read_(MPI_Fint * fcomm, MPI_Fint * fkey, MPI_Aint * expected,
+ MPI_Fint * errs, const char *msg, int msglen)
{
void *attrval;
- int flag, result;
- MPI_Comm comm = MPI_Comm_f2c( *fcomm );
+ int flag, result;
+ MPI_Comm comm = MPI_Comm_f2c(*fcomm);
char lmsg[MAX_ATTRTEST_MSG];
- if (msglen > sizeof(lmsg)- 1) {
- fprintf( stderr, "Message too long for buffer (%d)\n", msglen );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ if (msglen > sizeof(lmsg) - 1) {
+ fprintf(stderr, "Message too long for buffer (%d)\n", msglen);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- MPI_Comm_get_attr( comm, *fkey, &attrval, &flag );
+ MPI_Comm_get_attr(comm, *fkey, &attrval, &flag);
if (!flag) {
- *errs = *errs + 1;
- strncpy( lmsg, msg, msglen );
- lmsg[msglen] = 0;
- printf( " Error: flag false for Comm_get_attr (set in F2): %s\n", lmsg );
- return;
+ *errs = *errs + 1;
+ strncpy(lmsg, msg, msglen);
+ lmsg[msglen] = 0;
+ printf(" Error: flag false for Comm_get_attr (set in F2): %s\n", lmsg);
+ return;
}
- ccompareaint2void_( expected, attrval, &result );
+ ccompareaint2void_(expected, attrval, &result);
if (!result) {
- *errs = *errs + 1;
- strncpy( lmsg, msg, msglen );
- lmsg[msglen] = 0;
- printf( " Error: (set in F2) expected %ld but saw %ld: %s\n",
- (long)*expected, (long)*(MPI_Aint*)attrval, lmsg );
- return;
+ *errs = *errs + 1;
+ strncpy(lmsg, msg, msglen);
+ lmsg[msglen] = 0;
+ printf(" Error: (set in F2) expected %ld but saw %ld: %s\n",
+ (long) *expected, (long) *(MPI_Aint *) attrval, lmsg);
+ return;
}
return;
}
-void cmpif2readtype_( MPI_Fint *ftype, MPI_Fint *fkey, MPI_Aint *expected,
- MPI_Fint *errs, const char *msg, int msglen )
+void cmpif2readtype_(MPI_Fint * ftype, MPI_Fint * fkey, MPI_Aint * expected,
+ MPI_Fint * errs, const char *msg, int msglen)
{
void *attrval;
- int flag, result;
- MPI_Datatype dtype = MPI_Type_f2c( *ftype );
+ int flag, result;
+ MPI_Datatype dtype = MPI_Type_f2c(*ftype);
char lmsg[MAX_ATTRTEST_MSG];
- if (msglen > sizeof(lmsg)- 1) {
- fprintf( stderr, "Message too long for buffer (%d)\n", msglen );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ if (msglen > sizeof(lmsg) - 1) {
+ fprintf(stderr, "Message too long for buffer (%d)\n", msglen);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- MPI_Type_get_attr( dtype, *fkey, &attrval, &flag );
+ MPI_Type_get_attr(dtype, *fkey, &attrval, &flag);
if (!flag) {
- *errs = *errs + 1;
- strncpy( lmsg, msg, msglen );
- lmsg[msglen] = 0;
- printf( " Error: flag false for Type_get_attr (set in F2): %s\n", lmsg );
- return;
+ *errs = *errs + 1;
+ strncpy(lmsg, msg, msglen);
+ lmsg[msglen] = 0;
+ printf(" Error: flag false for Type_get_attr (set in F2): %s\n", lmsg);
+ return;
}
- ccompareaint2void_( expected, attrval, &result );
+ ccompareaint2void_(expected, attrval, &result);
if (!result) {
- *errs = *errs + 1;
- strncpy( lmsg, msg, msglen );
- lmsg[msglen] = 0;
- printf( " Error: (set in F2/Type) expected %ld but saw %ld: %s\n",
- (long)*expected, (long)*(MPI_Aint*)attrval, lmsg );
- return;
+ *errs = *errs + 1;
+ strncpy(lmsg, msg, msglen);
+ lmsg[msglen] = 0;
+ printf(" Error: (set in F2/Type) expected %ld but saw %ld: %s\n",
+ (long) *expected, (long) *(MPI_Aint *) attrval, lmsg);
+ return;
}
return;
}
-void cmpif2readwin_( MPI_Fint *fwin, MPI_Fint *fkey, MPI_Aint *expected,
- MPI_Fint *errs, const char *msg, int msglen )
+
+void cmpif2readwin_(MPI_Fint * fwin, MPI_Fint * fkey, MPI_Aint * expected,
+ MPI_Fint * errs, const char *msg, int msglen)
{
void *attrval;
- int flag, result;
- MPI_Win win = MPI_Win_f2c( *fwin );
+ int flag, result;
+ MPI_Win win = MPI_Win_f2c(*fwin);
char lmsg[MAX_ATTRTEST_MSG];
- if (msglen > sizeof(lmsg)- 1) {
- fprintf( stderr, "Message too long for buffer (%d)\n", msglen );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ if (msglen > sizeof(lmsg) - 1) {
+ fprintf(stderr, "Message too long for buffer (%d)\n", msglen);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- MPI_Win_get_attr( win, *fkey, &attrval, &flag );
+ MPI_Win_get_attr(win, *fkey, &attrval, &flag);
if (!flag) {
- *errs = *errs + 1;
- strncpy( lmsg, msg, msglen );
- lmsg[msglen] = 0;
- printf( " Error: flag false for Win_get_attr (set in F2): %s\n", lmsg );
- return;
+ *errs = *errs + 1;
+ strncpy(lmsg, msg, msglen);
+ lmsg[msglen] = 0;
+ printf(" Error: flag false for Win_get_attr (set in F2): %s\n", lmsg);
+ return;
}
- ccompareaint2void_( expected, attrval, &result );
+ ccompareaint2void_(expected, attrval, &result);
if (!result) {
- *errs = *errs + 1;
- strncpy( lmsg, msg, msglen );
- lmsg[msglen] = 0;
- printf( " Error: (set in F2/Win) expected %ld but saw %ld: %s\n",
- (long)*expected, (long)*(MPI_Aint*)attrval, lmsg );
- return;
+ *errs = *errs + 1;
+ strncpy(lmsg, msg, msglen);
+ lmsg[msglen] = 0;
+ printf(" Error: (set in F2/Win) expected %ld but saw %ld: %s\n",
+ (long) *expected, (long) *(MPI_Aint *) attrval, lmsg);
+ return;
}
return;
}
@@ -515,32 +509,34 @@ void cmpif2readwin_( MPI_Fint *fwin, MPI_Fint *fkey, MPI_Aint *expected,
/* the C attribute functions */
/* ----------------------------------------------------------------------- */
-void csetmpi_( MPI_Fint *fcomm, MPI_Fint *fkey, MPI_Fint *val, MPI_Fint *errs )
+void csetmpi_(MPI_Fint * fcomm, MPI_Fint * fkey, MPI_Fint * val, MPI_Fint * errs)
{
- MPI_Comm comm = MPI_Comm_f2c( *fcomm );
-
- MPI_Comm_set_attr( comm, *fkey, (void *)(MPI_Aint)*val );
+ MPI_Comm comm = MPI_Comm_f2c(*fcomm);
+
+ MPI_Comm_set_attr(comm, *fkey, (void *) (MPI_Aint) * val);
}
-void csetmpi2_( MPI_Fint *fcomm, MPI_Fint *fkey, MPI_Aint *val, MPI_Fint *errs )
+
+void csetmpi2_(MPI_Fint * fcomm, MPI_Fint * fkey, MPI_Aint * val, MPI_Fint * errs)
{
- MPI_Comm comm = MPI_Comm_f2c( *fcomm );
-
- MPI_Comm_set_attr( comm, *fkey, (void *)*val );
+ MPI_Comm comm = MPI_Comm_f2c(*fcomm);
+
+ MPI_Comm_set_attr(comm, *fkey, (void *) *val);
}
-void csetmpitype_( MPI_Fint *ftype, MPI_Fint *fkey, MPI_Aint *val,
- MPI_Fint *errs )
+
+void csetmpitype_(MPI_Fint * ftype, MPI_Fint * fkey, MPI_Aint * val, MPI_Fint * errs)
{
- MPI_Datatype dtype = MPI_Type_f2c( *ftype );
-
- MPI_Type_set_attr( dtype, *fkey, (void *)*val );
+ MPI_Datatype dtype = MPI_Type_f2c(*ftype);
+
+ MPI_Type_set_attr(dtype, *fkey, (void *) *val);
}
-void csetmpiwin_( MPI_Fint *fwin, MPI_Fint *fkey, MPI_Aint *val,
- MPI_Fint *errs )
+
+void csetmpiwin_(MPI_Fint * fwin, MPI_Fint * fkey, MPI_Aint * val, MPI_Fint * errs)
{
- MPI_Win win = MPI_Win_f2c( *fwin );
-
- MPI_Win_set_attr( win, *fkey, (void *)*val );
+ MPI_Win win = MPI_Win_f2c(*fwin);
+
+ MPI_Win_set_attr(win, *fkey, (void *) *val);
}
+
/* ----------------------------------------------------------------------- */
/* Comparisons */
/* int with aint */
@@ -553,76 +549,80 @@ void csetmpiwin_( MPI_Fint *fwin, MPI_Fint *fkey, MPI_Aint *val,
/* If one item is shorter than the other, take the low bytes. */
/* If one item is longer than the other, sign extend */
/* ----------------------------------------------------------------------- */
-void ccompareint2aint_( MPI_Fint *in1, MPI_Aint *in2, MPI_Fint *result )
+void ccompareint2aint_(MPI_Fint * in1, MPI_Aint * in2, MPI_Fint * result)
{
static int idx = -1;
if (sizeof(MPI_Fint) == sizeof(MPI_Aint)) {
- *result = *in1 == *in2;
+ *result = *in1 == *in2;
}
else if (sizeof(MPI_Fint) < sizeof(MPI_Aint)) {
- /* Assume Aint no smaller than Fint, and that size of aint
- is a multiple of the size of fint) */
- MPI_Fint *v2 = (MPI_Fint *)in2;
- if (idx < 0) {
- MPI_Aint av = 1;
- MPI_Fint *fa = (MPI_Fint *)&av;
- if ((sizeof(MPI_Aint) % sizeof(MPI_Fint)) != 0) {
- fprintf( stderr,
- "PANIC: size of MPI_Aint = %d not a multiple of MPI_Fint = %d\n",
- (int)sizeof(MPI_Aint), (int)sizeof(MPI_Fint) );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- for (idx = sizeof(MPI_Aint) / sizeof(MPI_Fint); idx >= 0; idx--)
- if (fa[idx]) break;
- if (idx < 0) {
- fprintf( stderr, "Unable to determine low word of Fint in Aint\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- *result = *in1 == v2[idx];
- }
+ /* Assume Aint no smaller than Fint, and that size of aint
+ * is a multiple of the size of fint) */
+ MPI_Fint *v2 = (MPI_Fint *) in2;
+ if (idx < 0) {
+ MPI_Aint av = 1;
+ MPI_Fint *fa = (MPI_Fint *) & av;
+ if ((sizeof(MPI_Aint) % sizeof(MPI_Fint)) != 0) {
+ fprintf(stderr,
+ "PANIC: size of MPI_Aint = %d not a multiple of MPI_Fint = %d\n",
+ (int) sizeof(MPI_Aint), (int) sizeof(MPI_Fint));
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ for (idx = sizeof(MPI_Aint) / sizeof(MPI_Fint); idx >= 0; idx--)
+ if (fa[idx])
+ break;
+ if (idx < 0) {
+ fprintf(stderr, "Unable to determine low word of Fint in Aint\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ *result = *in1 == v2[idx];
+ }
}
else {
- fprintf( stderr, "PANIC: sizeof(MPI_Fint) = %d > sizeof(MPI_Aint) %d\n",
- (int)sizeof(MPI_Fint), (int)sizeof(MPI_Aint) );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "PANIC: sizeof(MPI_Fint) = %d > sizeof(MPI_Aint) %d\n",
+ (int) sizeof(MPI_Fint), (int) sizeof(MPI_Aint));
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
}
-void ccompareint2void_( MPI_Fint *in1, void *in2, MPI_Fint *result )
+
+void ccompareint2void_(MPI_Fint * in1, void *in2, MPI_Fint * result)
{
static int idx = -1;
- if (sizeof(MPI_Fint) == sizeof(void*)) {
- *result = *in1 == *(MPI_Fint*)in2;
- }
- else if (sizeof(MPI_Fint) < sizeof(void*)) {
- /* Assume void* no smaller than Fint, and that size of aint
- is a multiple of the size of fint) */
- MPI_Fint *v2 = (MPI_Fint *)in2;
- if (idx < 0) {
- void *av = (void *)1;
- MPI_Fint *fa = (MPI_Fint *)&av;
- if ((sizeof(void*) % sizeof(MPI_Fint)) != 0) {
- fprintf( stderr,
- "PANIC: size of void * = %d not a multiple of MPI_Fint = %d\n",
- (int)sizeof(void*), (int)sizeof(MPI_Fint) );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- for (idx = sizeof(void*) / sizeof(MPI_Fint); idx >= 0; idx--)
- if (fa[idx]) break;
- if (idx < 0) {
- fprintf( stderr, "Unable to determine low word of Fint in void*\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- *result = *in1 == v2[idx];
- }
+ if (sizeof(MPI_Fint) == sizeof(void *)) {
+ *result = *in1 == *(MPI_Fint *) in2;
+ }
+ else if (sizeof(MPI_Fint) < sizeof(void *)) {
+ /* Assume void* no smaller than Fint, and that size of aint
+ * is a multiple of the size of fint) */
+ MPI_Fint *v2 = (MPI_Fint *) in2;
+ if (idx < 0) {
+ void *av = (void *) 1;
+ MPI_Fint *fa = (MPI_Fint *) & av;
+ if ((sizeof(void *) % sizeof(MPI_Fint)) != 0) {
+ fprintf(stderr,
+ "PANIC: size of void * = %d not a multiple of MPI_Fint = %d\n",
+ (int) sizeof(void *), (int) sizeof(MPI_Fint));
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ for (idx = sizeof(void *) / sizeof(MPI_Fint); idx >= 0; idx--)
+ if (fa[idx])
+ break;
+ if (idx < 0) {
+ fprintf(stderr, "Unable to determine low word of Fint in void*\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ *result = *in1 == v2[idx];
+ }
}
else {
- fprintf( stderr, "PANIC: sizeof(MPI_Fint) = %d > sizeof(void*) %d\n",
- (int)sizeof(MPI_Fint), (int)sizeof(void*) );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "PANIC: sizeof(MPI_Fint) = %d > sizeof(void*) %d\n",
+ (int) sizeof(MPI_Fint), (int) sizeof(void *));
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
}
-void ccompareaint2void_( MPI_Aint *in1, void *in2, MPI_Fint *result )
+
+void ccompareaint2void_(MPI_Aint * in1, void *in2, MPI_Fint * result)
{
/* Note that an aint must be >= void * by definition */
- *result = *in1 == *(MPI_Aint*)in2;
+ *result = *in1 == *(MPI_Aint *) in2;
}
diff --git a/test/mpi/f90/attr/fandcattrc.c b/test/mpi/f90/attr/fandcattrc.c
index 27c39ad..1f0cf68 100644
--- a/test/mpi/f90/attr/fandcattrc.c
+++ b/test/mpi/f90/attr/fandcattrc.c
@@ -11,11 +11,11 @@
#include "../../include/mpitestconf.h"
#include <string.h>
-/*
+/*
Name mapping. All routines are created with names that are lower case
with a single trailing underscore. This matches many compilers.
We use #define to change the name for Fortran compilers that do
- not use the lowercase/underscore pattern
+ not use the lowercase/underscore pattern
*/
#ifdef F77_NAME_UPPER
@@ -31,91 +31,91 @@
defined(F77_NAME_MIXED_USCORE)
/* Else leave name alone (routines have no underscore, so both
of these map to a lowercase, single underscore) */
-#else
+#else
#error 'Unrecognized Fortran name mapping'
#endif
-int chkcomm2inc_ (int *keyval, const int *expected, int *ierr);
-int chkcomm2inc_ (int *keyval, const int *expected, int *ierr)
+int chkcomm2inc_(int *keyval, const int *expected, int *ierr);
+int chkcomm2inc_(int *keyval, const int *expected, int *ierr)
{
- int flag;
+ int flag;
MPI_Aint *val;
/* See Example 16.19 in MPI 2.2, part B. The use of MPI_Aint *val
- and the address of val in the get_attr call is correct, as is
- the use of *val to access the value. */
- MPI_Comm_get_attr( MPI_COMM_WORLD, *keyval, &val, &flag );
+ * and the address of val in the get_attr call is correct, as is
+ * the use of *val to access the value. */
+ MPI_Comm_get_attr(MPI_COMM_WORLD, *keyval, &val, &flag);
if (!flag) {
- *ierr = 1;
+ *ierr = 1;
}
else {
- if (*val != *expected) {
- /* In some cases, using printf from a c routine linked
- with a Fortran routine can cause linking difficulties.
- To avoid problems in running the tests, this print
- is commented out */
- /* printf( "Val = %x, expected = %d\n", val, *expected ); */
- *ierr = *ierr + 1;
- }
+ if (*val != *expected) {
+ /* In some cases, using printf from a c routine linked
+ * with a Fortran routine can cause linking difficulties.
+ * To avoid problems in running the tests, this print
+ * is commented out */
+ /* printf("Val = %x, expected = %d\n", val, *expected); */
+ *ierr = *ierr + 1;
+ }
}
return 0;
}
/* Attribute delete and copy functions for each type */
-int myCommCopyfn( MPI_Comm comm, int keyval, void *extra_state,
- void *attr_val_in, void *attr_val_out, int *flag );
-int myCommCopyfn( MPI_Comm comm, int keyval, void *extra_state,
- void *attr_val_in, void *attr_val_out, int *flag )
+int myCommCopyfn(MPI_Comm comm, int keyval, void *extra_state,
+ void *attr_val_in, void *attr_val_out, int *flag);
+int myCommCopyfn(MPI_Comm comm, int keyval, void *extra_state,
+ void *attr_val_in, void *attr_val_out, int *flag)
{
- *(void **)attr_val_out = (char *)attr_val_in + 2;
+ *(void **) attr_val_out = (char *) attr_val_in + 2;
*flag = 1;
return MPI_SUCCESS;
}
-int myCommDelfn( MPI_Comm comm, int keyval, void *attr_val, void *extra_state );
-int myCommDelfn( MPI_Comm comm, int keyval, void *attr_val, void *extra_state )
+int myCommDelfn(MPI_Comm comm, int keyval, void *attr_val, void *extra_state);
+int myCommDelfn(MPI_Comm comm, int keyval, void *attr_val, void *extra_state)
{
return MPI_SUCCESS;
}
-int myTypeCopyfn( MPI_Datatype dtype, int keyval, void *extra_state,
- void *attr_val_in, void *attr_val_out, int *flag );
-int myTypeCopyfn( MPI_Datatype dtype, int keyval, void *extra_state,
- void *attr_val_in, void *attr_val_out, int *flag )
+int myTypeCopyfn(MPI_Datatype dtype, int keyval, void *extra_state,
+ void *attr_val_in, void *attr_val_out, int *flag);
+int myTypeCopyfn(MPI_Datatype dtype, int keyval, void *extra_state,
+ void *attr_val_in, void *attr_val_out, int *flag)
{
- *(void **)attr_val_out = (char *)attr_val_in + 2;
+ *(void **) attr_val_out = (char *) attr_val_in + 2;
*flag = 1;
return MPI_SUCCESS;
}
-int myTypeDelfn( MPI_Datatype dtype, int keyval, void *attr_val, void *extra_state );
-int myTypeDelfn( MPI_Datatype dtype, int keyval, void *attr_val, void *extra_state )
+int myTypeDelfn(MPI_Datatype dtype, int keyval, void *attr_val, void *extra_state);
+int myTypeDelfn(MPI_Datatype dtype, int keyval, void *attr_val, void *extra_state)
{
return MPI_SUCCESS;
}
-int myWinCopyfn( MPI_Win win, int keyval, void *extra_state,
- void *attr_val_in, void *attr_val_out, int *flag );
-int myWinCopyfn( MPI_Win win, int keyval, void *extra_state,
- void *attr_val_in, void *attr_val_out, int *flag )
+int myWinCopyfn(MPI_Win win, int keyval, void *extra_state,
+ void *attr_val_in, void *attr_val_out, int *flag);
+int myWinCopyfn(MPI_Win win, int keyval, void *extra_state,
+ void *attr_val_in, void *attr_val_out, int *flag)
{
- *(void **)attr_val_out = (char *)attr_val_in + 2;
+ *(void **) attr_val_out = (char *) attr_val_in + 2;
*flag = 1;
return MPI_SUCCESS;
}
-int myWinDelfn( MPI_Win win, int keyval, void *attr_val, void *extra_state );
-int myWinDelfn( MPI_Win win, int keyval, void *attr_val, void *extra_state )
+int myWinDelfn(MPI_Win win, int keyval, void *attr_val, void *extra_state);
+int myWinDelfn(MPI_Win win, int keyval, void *attr_val, void *extra_state)
{
return MPI_SUCCESS;
}
-int chkckeyvals_( int *comm_keyval, int *type_keyval, int *win_keyval );
-int chkckeyvals_( int *comm_keyval, int *type_keyval, int *win_keyval )
+int chkckeyvals_(int *comm_keyval, int *type_keyval, int *win_keyval);
+int chkckeyvals_(int *comm_keyval, int *type_keyval, int *win_keyval)
{
- MPI_Comm_create_keyval( myCommCopyfn, myCommDelfn, comm_keyval, 0 );
- MPI_Type_create_keyval( myTypeCopyfn, myTypeDelfn, type_keyval, 0 );
- MPI_Win_create_keyval( myWinCopyfn, myWinDelfn, win_keyval, 0 );
+ MPI_Comm_create_keyval(myCommCopyfn, myCommDelfn, comm_keyval, 0);
+ MPI_Type_create_keyval(myTypeCopyfn, myTypeDelfn, type_keyval, 0);
+ MPI_Win_create_keyval(myWinCopyfn, myWinDelfn, win_keyval, 0);
return 0;
}
diff --git a/test/mpi/f90/f90types/createf90types.c b/test/mpi/f90/f90types/createf90types.c
index 7fdf1ab..a0960bf 100644
--- a/test/mpi/f90/f90types/createf90types.c
+++ b/test/mpi/f90/f90types/createf90types.c
@@ -11,8 +11,9 @@
#include <string.h>
#include "mpitest.h"
-static int cases[6][2] = {{3,10},{3,MPI_UNDEFINED},{MPI_UNDEFINED,10},
- {7,30},{7,MPI_UNDEFINED},{MPI_UNDEFINED,30}};
+static int cases[6][2] = { {3, 10}, {3, MPI_UNDEFINED}, {MPI_UNDEFINED, 10},
+{7, 30}, {7, MPI_UNDEFINED}, {MPI_UNDEFINED, 30}
+};
/*
static char MTEST_Descrip[] = "Test the routines to access the Fortran 90 datatypes from C";
@@ -30,79 +31,74 @@ static char MTEST_Descrip[] = "Test the routines to access the Fortran 90 dataty
} while (0)
/* Check the return from the routine */
-static int checkType( const char str[], int p, int r, int f90kind,
- int err, MPI_Datatype dtype )
+static int checkType(const char str[], int p, int r, int f90kind, int err, MPI_Datatype dtype)
{
int errs = 0;
if (dtype == MPI_DATATYPE_NULL) {
- printf( "Unable to find a real type for (p=%d,r=%d) in %s\n",
- p, r, str );
- errs++;
+ printf("Unable to find a real type for (p=%d,r=%d) in %s\n", p, r, str);
+ errs++;
}
if (err) {
- errs++;
- MTestPrintError( err );
+ errs++;
+ MTestPrintError(err);
}
if (!errs) {
- int nints, nadds, ndtypes, combiner;
-
- /* Check that we got the correct type */
- MPI_Type_get_envelope( dtype, &nints, &nadds, &ndtypes, &combiner );
- if (combiner != f90kind) {
- errs++;
- printf( "Wrong combiner type (got %d, should be %d) for %s\n",
- combiner, f90kind, str );
- }
- else {
- int parms[2];
- MPI_Datatype outtype;
- parms[0] = 0;
- parms[1] = 0;
-
- if (ndtypes != 0) {
- errs++;
- printf( "Section 8.6 states that the array_of_datatypes entry is empty for the create_f90 types\n" );
- }
- MPI_Type_get_contents( dtype, 2, 0, 1, parms, 0, &outtype );
- switch (combiner) {
- case MPI_COMBINER_F90_REAL:
- case MPI_COMBINER_F90_COMPLEX:
- if (nints != 2) {
- errs++;
- printf( "Returned %d integer values, 2 expected for %s\n",
- nints, str );
- }
- if (parms[0] != p || parms[1] != r) {
- errs++;
- printf( "Returned (p=%d,r=%d); expected (p=%d,r=%d) for %s\n",
- parms[0], parms[1], p, r, str );
- }
- break;
- case MPI_COMBINER_F90_INTEGER:
- if (nints != 1) {
- errs++;
- printf( "Returned %d integer values, 1 expected for %s\n",
- nints, str );
- }
- if (parms[0] != p) {
- errs++;
- printf( "Returned (p=%d); expected (p=%d) for %s\n",
- parms[0], p, str );
- }
- break;
- default:
- errs++;
- printf( "Unrecognized combiner for %s\n", str );
- break;
- }
-
- }
+ int nints, nadds, ndtypes, combiner;
+
+ /* Check that we got the correct type */
+ MPI_Type_get_envelope(dtype, &nints, &nadds, &ndtypes, &combiner);
+ if (combiner != f90kind) {
+ errs++;
+ printf("Wrong combiner type (got %d, should be %d) for %s\n", combiner, f90kind, str);
+ }
+ else {
+ int parms[2];
+ MPI_Datatype outtype;
+ parms[0] = 0;
+ parms[1] = 0;
+
+ if (ndtypes != 0) {
+ errs++;
+ printf
+ ("Section 8.6 states that the array_of_datatypes entry is empty for the create_f90 types\n");
+ }
+ MPI_Type_get_contents(dtype, 2, 0, 1, parms, 0, &outtype);
+ switch (combiner) {
+ case MPI_COMBINER_F90_REAL:
+ case MPI_COMBINER_F90_COMPLEX:
+ if (nints != 2) {
+ errs++;
+ printf("Returned %d integer values, 2 expected for %s\n", nints, str);
+ }
+ if (parms[0] != p || parms[1] != r) {
+ errs++;
+ printf("Returned (p=%d,r=%d); expected (p=%d,r=%d) for %s\n",
+ parms[0], parms[1], p, r, str);
+ }
+ break;
+ case MPI_COMBINER_F90_INTEGER:
+ if (nints != 1) {
+ errs++;
+ printf("Returned %d integer values, 1 expected for %s\n", nints, str);
+ }
+ if (parms[0] != p) {
+ errs++;
+ printf("Returned (p=%d); expected (p=%d) for %s\n", parms[0], p, str);
+ }
+ break;
+ default:
+ errs++;
+ printf("Unrecognized combiner for %s\n", str);
+ break;
+ }
+
+ }
}
if (!errs) {
- char buf0[64]; /* big enough to hold any single type */
- char buf1[64]; /* big enough to hold any single type */
+ char buf0[64]; /* big enough to hold any single type */
+ char buf1[64]; /* big enough to hold any single type */
MPI_Request req[2];
int dt_size = 0;
@@ -130,7 +126,7 @@ static int checkType( const char str[], int p, int r, int f90kind,
return errs;
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int p, r;
int errs = 0;
@@ -138,44 +134,42 @@ int main( int argc, char *argv[] )
int i, j, nLoop = 1;
MPI_Datatype newtype;
- MTest_Init(0,0);
+ MTest_Init(0, 0);
if (argc > 1) {
- nLoop = atoi( argv[1] );
+ nLoop = atoi(argv[1]);
}
/* Set the handler to errors return, since according to the
- standard, it is invalid to provide p and/or r that are unsupported */
+ * standard, it is invalid to provide p and/or r that are unsupported */
+
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ for (i = 0; i < nLoop; i++) {
- for (i=0; i<nLoop; i++) {
-
- /* These should be a valid type similar to MPI_REAL and MPI_REAL8 */
- for (j=0; j<6; j++) {
+ /* These should be a valid type similar to MPI_REAL and MPI_REAL8 */
+ for (j = 0; j < 6; j++) {
p = cases[j][0];
r = cases[j][1];
- err = MPI_Type_create_f90_real( p, r, &newtype );
- errs += checkType( "REAL", p, r, MPI_COMBINER_F90_REAL, err, newtype );
+ err = MPI_Type_create_f90_real(p, r, &newtype);
+ errs += checkType("REAL", p, r, MPI_COMBINER_F90_REAL, err, newtype);
}
- /* These should be a valid type similar to MPI_COMPLEX and MPI_COMPLEX8 */
- for (j=0; j<6; j++) {
+ /* These should be a valid type similar to MPI_COMPLEX and MPI_COMPLEX8 */
+ for (j = 0; j < 6; j++) {
p = cases[j][0];
r = cases[j][1];
- err = MPI_Type_create_f90_complex( p, r, &newtype );
- errs += checkType( "COMPLEX", p, r, MPI_COMBINER_F90_COMPLEX,
- err, newtype );
+ err = MPI_Type_create_f90_complex(p, r, &newtype);
+ errs += checkType("COMPLEX", p, r, MPI_COMBINER_F90_COMPLEX, err, newtype);
}
-
- /* This should be a valid type similar to MPI_INTEGER */
- p = 3;
- r = 10;
- err = MPI_Type_create_f90_integer( p, &newtype );
- errs += checkType( "INTEGER", p, r, MPI_COMBINER_F90_INTEGER,
- err, newtype );
+
+ /* This should be a valid type similar to MPI_INTEGER */
+ p = 3;
+ r = 10;
+ err = MPI_Type_create_f90_integer(p, &newtype);
+ errs += checkType("INTEGER", p, r, MPI_COMBINER_F90_INTEGER, err, newtype);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/ft/abort.c b/test/mpi/ft/abort.c
index a2f6d59..ea7ac1c 100644
--- a/test/mpi/ft/abort.c
+++ b/test/mpi/ft/abort.c
@@ -17,8 +17,7 @@ int main(int argc, char **argv)
if (rank == 0)
MPI_Abort(MPI_COMM_WORLD, 1);
- while(1)
- ;
+ while (1);
MPI_Finalize();
return 0;
diff --git a/test/mpi/ft/agree.c b/test/mpi/ft/agree.c
index 8ef003f..d7587f3 100644
--- a/test/mpi/ft/agree.c
+++ b/test/mpi/ft/agree.c
@@ -24,32 +24,39 @@ int main(int argc, char **argv)
MPI_Abort(MPI_COMM_WORLD, 1);
}
- if (2 == rank) exit(EXIT_FAILURE);
+ if (2 == rank)
+ exit(EXIT_FAILURE);
- if (0 == rank) flag = 0;
+ if (0 == rank)
+ flag = 0;
rc = MPIX_Comm_agree(MPI_COMM_WORLD, &flag);
MPI_Error_class(rc, &errclass);
if (errclass != MPIX_ERR_PROC_FAILED) {
- fprintf(stderr, "[%d] Expected MPIX_ERR_PROC_FAILED after agree. Received: %d\n", rank, errclass);
+ fprintf(stderr, "[%d] Expected MPIX_ERR_PROC_FAILED after agree. Received: %d\n", rank,
+ errclass);
MPI_Abort(MPI_COMM_WORLD, 1);
errs++;
- } else if (0 != flag) {
+ }
+ else if (0 != flag) {
fprintf(stderr, "[%d] Expected flag to be 0. Received: %d\n", rank, flag);
errs++;
}
MPIX_Comm_failure_ack(MPI_COMM_WORLD);
- if (0 == rank) flag = 0;
- else flag = 1;
+ if (0 == rank)
+ flag = 0;
+ else
+ flag = 1;
rc = MPIX_Comm_agree(MPI_COMM_WORLD, &flag);
MPI_Error_class(rc, &errclass);
if (MPI_SUCCESS != rc) {
fprintf(stderr, "[%d] Expected MPI_SUCCESS after agree. Received: %d\n", rank, errclass);
MPI_Abort(MPI_COMM_WORLD, 1);
errs++;
- } else if (0 != flag) {
+ }
+ else if (0 != flag) {
fprintf(stderr, "[%d] Expected flag to be 0. Received: %d\n", rank, flag);
MPI_Abort(MPI_COMM_WORLD, 1);
errs++;
diff --git a/test/mpi/ft/agree_shrink.c b/test/mpi/ft/agree_shrink.c
index 0420b66..e8f51b1 100644
--- a/test/mpi/ft/agree_shrink.c
+++ b/test/mpi/ft/agree_shrink.c
@@ -27,7 +27,8 @@ int main(int argc, char **argv)
MPI_Abort(dup, 1);
}
- if (2 == rank) exit(EXIT_FAILURE);
+ if (2 == rank)
+ exit(EXIT_FAILURE);
if (MPI_SUCCESS == (rc = MPIX_Comm_agree(dup, &flag))) {
MPI_Error_class(rc, &ec);
diff --git a/test/mpi/ft/anysource.c b/test/mpi/ft/anysource.c
index 25aee93..89778cf 100644
--- a/test/mpi/ft/anysource.c
+++ b/test/mpi/ft/anysource.c
@@ -58,7 +58,9 @@ int main(int argc, char **argv)
err = MPI_Wait(&request, &status);
MPI_Error_class(err, &ec);
if (MPIX_ERR_PROC_FAILED_PENDING != ec) {
- fprintf(stderr, "Expected a MPIX_ERR_PROC_FAILED_PENDING (%d) for receive from ANY_SOURCE: %d\n", MPIX_ERR_PROC_FAILED_PENDING, ec);
+ fprintf(stderr,
+ "Expected a MPIX_ERR_PROC_FAILED_PENDING (%d) for receive from ANY_SOURCE: %d\n",
+ MPIX_ERR_PROC_FAILED_PENDING, ec);
MPI_Abort(MPI_COMM_WORLD, 1);
}
@@ -79,7 +81,8 @@ int main(int argc, char **argv)
}
fprintf(stdout, " %s\n", buf);
- } else if (rank == 2) {
+ }
+ else if (rank == 2) {
char buf[10] = "No errors";
err = MPI_Recv(NULL, 0, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
if (MPI_SUCCESS != err) {
diff --git a/test/mpi/ft/barrier.c b/test/mpi/ft/barrier.c
index 6e33f11..271061d 100644
--- a/test/mpi/ft/barrier.c
+++ b/test/mpi/ft/barrier.c
@@ -24,8 +24,8 @@ int main(int argc, char **argv)
MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
if (size < 2) {
- fprintf( stderr, "Must run with at least 2 processes\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Must run with at least 2 processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
if (rank == 1) {
@@ -40,14 +40,17 @@ int main(int argc, char **argv)
if (errclass == MPIX_ERR_PROC_FAILED) {
printf(" No Errors\n");
fflush(stdout);
- } else {
- fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n", errclass);
+ }
+ else {
+ fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n",
+ errclass);
}
#else
if (err) {
printf(" No Errors\n");
fflush(stdout);
- } else {
+ }
+ else {
fprintf(stderr, "Program reported MPI_SUCCESS, but an error code was expected.\n");
}
#endif
diff --git a/test/mpi/ft/bcast.c b/test/mpi/ft/bcast.c
index 02b2ee2..f721eeb 100644
--- a/test/mpi/ft/bcast.c
+++ b/test/mpi/ft/bcast.c
@@ -17,7 +17,7 @@
int main(int argc, char **argv)
{
int rank, size, rc, errclass, toterrs, errs = 0;
- int deadprocs[] = {1};
+ int deadprocs[] = { 1 };
char buf[100000];
MPI_Group world, newgroup;
MPI_Comm newcomm;
@@ -32,8 +32,8 @@ int main(int argc, char **argv)
MPI_Comm_create_group(MPI_COMM_WORLD, newgroup, 0, &newcomm);
if (size < 3) {
- fprintf( stderr, "Must run with at least 3 processes\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Must run with at least 3 processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
if (rank == 1) {
@@ -50,7 +50,8 @@ int main(int argc, char **argv)
#if defined (MPICH) && (MPICH_NUMVERSION >= 30100102)
MPI_Error_class(rc, &errclass);
if ((rc) && (errclass != MPIX_ERR_PROC_FAILED)) {
- fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n", errclass);
+ fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n",
+ errclass);
errs++;
}
#endif
@@ -65,21 +66,22 @@ int main(int argc, char **argv)
#if defined (MPICH) && (MPICH_NUMVERSION >= 30100102)
MPI_Error_class(rc, &errclass);
if ((rc) && (errclass != MPIX_ERR_PROC_FAILED)) {
- fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n", errclass);
+ fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n",
+ errclass);
errs++;
}
#endif
rc = MPI_Reduce(&errs, &toterrs, 1, MPI_INT, MPI_SUM, 0, newcomm);
- if(rc)
+ if (rc)
fprintf(stderr, "Failed to get errors from other processes\n");
if (rank == 0) {
if (toterrs) {
- printf( " Found %d errors\n", toterrs );
+ printf(" Found %d errors\n", toterrs);
}
else {
- printf( " No Errors\n" );
+ printf(" No Errors\n");
}
fflush(stdout);
}
diff --git a/test/mpi/ft/die.c b/test/mpi/ft/die.c
index 990d274..f122697 100644
--- a/test/mpi/ft/die.c
+++ b/test/mpi/ft/die.c
@@ -21,7 +21,7 @@ int main(int argc, char **argv)
if (rank == 0) {
printf(" No Errors\n");
- fflush( stdout );
+ fflush(stdout);
}
MPI_Finalize();
diff --git a/test/mpi/ft/failure_ack.c b/test/mpi/ft/failure_ack.c
index e5acc41..14672b7 100644
--- a/test/mpi/ft/failure_ack.c
+++ b/test/mpi/ft/failure_ack.c
@@ -18,15 +18,15 @@ int main(int argc, char **argv)
char buf[10] = " No errors";
char error[MPI_MAX_ERROR_STRING];
MPI_Group failed_grp, one_grp, world_grp;
- int one[] = {1};
- int world_ranks[] = {0,1,2};
+ int one[] = { 1 };
+ int world_ranks[] = { 0, 1, 2 };
int failed_ranks[3];
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
if (size < 3) {
- fprintf( stderr, "Must run with at least 3 processes\n" );
+ fprintf(stderr, "Must run with at least 3 processes\n");
MPI_Abort(MPI_COMM_WORLD, 1);
}
@@ -104,7 +104,8 @@ int main(int argc, char **argv)
}
fprintf(stdout, " No errors\n");
- } else if (rank == 2) {
+ }
+ else if (rank == 2) {
MPI_Ssend(buf, 10, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
exit(EXIT_FAILURE);
diff --git a/test/mpi/ft/gather.c b/test/mpi/ft/gather.c
index 997d58b..7b0c227 100644
--- a/test/mpi/ft/gather.c
+++ b/test/mpi/ft/gather.c
@@ -25,15 +25,15 @@ int main(int argc, char **argv)
MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
if (size < 3) {
- fprintf( stderr, "Must run with at least 3 processes\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Must run with at least 3 processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
if (rank == 1) {
exit(EXIT_FAILURE);
}
- recvbuf = (int *)malloc(size*sizeof(int));
+ recvbuf = (int *) malloc(size * sizeof(int));
err = MPI_Gather(sendbuf, 1, MPI_INT, recvbuf, size, MPI_INT, 0, MPI_COMM_WORLD);
@@ -43,14 +43,17 @@ int main(int argc, char **argv)
if (errclass == MPIX_ERR_PROC_FAILED) {
printf(" No Errors\n");
fflush(stdout);
- } else {
- fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n", errclass);
+ }
+ else {
+ fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n",
+ errclass);
}
#else
if (err) {
printf(" No Errors\n");
fflush(stdout);
- } else {
+ }
+ else {
fprintf(stderr, "Program reported MPI_SUCCESS, but an error code was expected.\n");
}
#endif
diff --git a/test/mpi/ft/irecvdead.c b/test/mpi/ft/irecvdead.c
index f97c6f5..2e19a85 100644
--- a/test/mpi/ft/irecvdead.c
+++ b/test/mpi/ft/irecvdead.c
@@ -24,8 +24,8 @@ int main(int argc, char **argv)
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
if (size < 2) {
- fprintf( stderr, "Must run with at least 2 processes\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Must run with at least 2 processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
if (rank == 1) {
@@ -44,14 +44,17 @@ int main(int argc, char **argv)
if (errclass == MPIX_ERR_PROC_FAILED) {
printf(" No Errors\n");
fflush(stdout);
- } else {
- fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n", errclass);
+ }
+ else {
+ fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n",
+ errclass);
}
#else
if (err) {
printf(" No Errors\n");
fflush(stdout);
- } else {
+ }
+ else {
fprintf(stderr, "Program reported MPI_SUCCESS, but an error code was expected.\n");
}
#endif
diff --git a/test/mpi/ft/isendalive.c b/test/mpi/ft/isendalive.c
index 8da1a48..74df787 100644
--- a/test/mpi/ft/isendalive.c
+++ b/test/mpi/ft/isendalive.c
@@ -24,7 +24,7 @@ int main(int argc, char **argv)
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
if (size < 3) {
- fprintf( stderr, "Must run with at least 3 processes\n" );
+ fprintf(stderr, "Must run with at least 3 processes\n");
MPI_Abort(MPI_COMM_WORLD, 1);
}
@@ -33,7 +33,7 @@ int main(int argc, char **argv)
}
if (rank == 0) {
- err = MPI_Isend("No Errors", 10, MPI_CHAR, 2, 0, MPI_COMM_WORLD, &request);
+ err = MPI_Isend("No Errors", 10, MPI_CHAR, 2, 0, MPI_COMM_WORLD, &request);
err += MPI_Wait(&request, MPI_STATUS_IGNORE);
if (err) {
fprintf(stderr, "An error occurred during the send operation\n");
@@ -41,11 +41,12 @@ int main(int argc, char **argv)
}
if (rank == 2) {
- err = MPI_Irecv(buf, 10, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &request);
+ err = MPI_Irecv(buf, 10, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &request);
err += MPI_Wait(&request, MPI_STATUS_IGNORE);
if (err) {
fprintf(stderr, "An error occurred during the recv operation\n");
- } else {
+ }
+ else {
printf(" %s\n", buf);
fflush(stdout);
}
diff --git a/test/mpi/ft/isenddead.c b/test/mpi/ft/isenddead.c
index a915c3e..fbb626c 100644
--- a/test/mpi/ft/isenddead.c
+++ b/test/mpi/ft/isenddead.c
@@ -23,8 +23,8 @@ int main(int argc, char **argv)
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
if (size < 2) {
- fprintf( stderr, "Must run with at least 2 processes\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Must run with at least 2 processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
if (rank == 1) {
@@ -41,8 +41,10 @@ int main(int argc, char **argv)
#if defined (MPICH) && (MPICH_NUMVERSION >= 30100102)
MPI_Error_class(err, &errclass);
if ((err) && (errclass != MPIX_ERR_PROC_FAILED)) {
- fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n", errclass);
- } else {
+ fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n",
+ errclass);
+ }
+ else {
printf(" No Errors\n");
fflush(stdout);
}
diff --git a/test/mpi/ft/multi_isendalive.c b/test/mpi/ft/multi_isendalive.c
index 24a08c8..85c29f8 100644
--- a/test/mpi/ft/multi_isendalive.c
+++ b/test/mpi/ft/multi_isendalive.c
@@ -25,7 +25,7 @@ int main(int argc, char **argv)
MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
if (size < 4) {
- fprintf( stderr, "Must run with at least 4 processes\n" );
+ fprintf(stderr, "Must run with at least 4 processes\n");
MPI_Abort(MPI_COMM_WORLD, 1);
}
@@ -34,7 +34,7 @@ int main(int argc, char **argv)
}
if (rank == 0) {
- err = MPI_Issend("No Errors", 10, MPI_CHAR, 3, 0, MPI_COMM_WORLD, &request);
+ err = MPI_Issend("No Errors", 10, MPI_CHAR, 3, 0, MPI_COMM_WORLD, &request);
err += MPI_Wait(&request, MPI_STATUS_IGNORE);
if (err) {
fprintf(stderr, "An error occurred during the send operation\n");
@@ -42,7 +42,7 @@ int main(int argc, char **argv)
}
if (rank == 3) {
- err = MPI_Irecv(buf, 10, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &request);
+ err = MPI_Irecv(buf, 10, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &request);
err += MPI_Wait(&request, MPI_STATUS_IGNORE);
if (err) {
fprintf(stderr, "An error occurred during the recv operation\n");
@@ -54,7 +54,7 @@ int main(int argc, char **argv)
}
if (rank == 0) {
- err = MPI_Issend("No Errors", 10, MPI_CHAR, 2, 0, MPI_COMM_WORLD, &request);
+ err = MPI_Issend("No Errors", 10, MPI_CHAR, 2, 0, MPI_COMM_WORLD, &request);
err += MPI_Wait(&request, MPI_STATUS_IGNORE);
if (err) {
fprintf(stderr, "An error occurred during the send operation\n");
@@ -62,11 +62,12 @@ int main(int argc, char **argv)
}
if (rank == 2) {
- err = MPI_Irecv(buf, 10, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &request);
+ err = MPI_Irecv(buf, 10, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &request);
err += MPI_Wait(&request, MPI_STATUS_IGNORE);
if (err) {
fprintf(stderr, "An error occurred during the recv operation\n");
- } else {
+ }
+ else {
printf(" %s\n", buf);
fflush(stdout);
}
diff --git a/test/mpi/ft/nbccoll.c b/test/mpi/ft/nbccoll.c
index f5b6cf4..37a49fe 100644
--- a/test/mpi/ft/nbccoll.c
+++ b/test/mpi/ft/nbccoll.c
@@ -36,8 +36,8 @@ int main(int argc, char **argv)
MPI_Group_free(&small_grp);
if (size < 4) {
- fprintf( stderr, "Must run with at least 2 processes\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Must run with at least 2 processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
if (rank == excl) {
diff --git a/test/mpi/ft/recvdead.c b/test/mpi/ft/recvdead.c
index 931afdf..c8ee947 100644
--- a/test/mpi/ft/recvdead.c
+++ b/test/mpi/ft/recvdead.c
@@ -23,8 +23,8 @@ int main(int argc, char **argv)
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
if (size < 2) {
- fprintf( stderr, "Must run with at least 2 processes\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Must run with at least 2 processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
if (rank == 1) {
@@ -39,14 +39,17 @@ int main(int argc, char **argv)
if (errclass == MPIX_ERR_PROC_FAILED) {
printf(" No Errors\n");
fflush(stdout);
- } else {
- fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n", errclass);
+ }
+ else {
+ fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n",
+ errclass);
}
#else
if (err) {
printf(" No Errors\n");
fflush(stdout);
- } else {
+ }
+ else {
fprintf(stderr, "Program reported MPI_SUCCESS, but an error code was expected.\n");
}
#endif
diff --git a/test/mpi/ft/reduce.c b/test/mpi/ft/reduce.c
index 993fe07..79937aa 100644
--- a/test/mpi/ft/reduce.c
+++ b/test/mpi/ft/reduce.c
@@ -25,8 +25,8 @@ int main(int argc, char **argv)
MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
if (size < 3) {
- fprintf( stderr, "Must run with at least 3 processes\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Must run with at least 3 processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
if (rank == 1) {
@@ -41,14 +41,17 @@ int main(int argc, char **argv)
if (errclass == MPIX_ERR_PROC_FAILED) {
printf(" No Errors\n");
fflush(stdout);
- } else {
- fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n", errclass);
+ }
+ else {
+ fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n",
+ errclass);
}
#else
if (err) {
printf(" No Errors\n");
fflush(stdout);
- } else {
+ }
+ else {
fprintf(stderr, "Program reported MPI_SUCCESS, but an error code was expected.\n");
}
#endif
diff --git a/test/mpi/ft/revoke_nofail.c b/test/mpi/ft/revoke_nofail.c
index df7b470..006613e 100644
--- a/test/mpi/ft/revoke_nofail.c
+++ b/test/mpi/ft/revoke_nofail.c
@@ -24,7 +24,7 @@ int main(int argc, char **argv)
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
if (size < 2) {
- fprintf( stderr, "Must run with at least 2 processes\n" );
+ fprintf(stderr, "Must run with at least 2 processes\n");
MPI_Abort(MPI_COMM_WORLD, 1);
}
@@ -40,7 +40,8 @@ int main(int argc, char **argv)
MPI_Error_class(rc, &ec);
if (ec != MPIX_ERR_REVOKED) {
MPI_Error_string(ec, error, &size);
- fprintf(stderr, "[%d] MPI_Barrier should have returned MPIX_ERR_REVOKED (%d), but it actually returned: %d\n%s\n",
+ fprintf(stderr,
+ "[%d] MPI_Barrier should have returned MPIX_ERR_REVOKED (%d), but it actually returned: %d\n%s\n",
rank, MPIX_ERR_REVOKED, ec, error);
MPI_Abort(MPI_COMM_WORLD, 1);
}
diff --git a/test/mpi/ft/revoke_shrink.c b/test/mpi/ft/revoke_shrink.c
index 2e30213..50fb081 100644
--- a/test/mpi/ft/revoke_shrink.c
+++ b/test/mpi/ft/revoke_shrink.c
@@ -14,7 +14,8 @@
MPI_Comm comm_all;
-void error_handler(MPI_Comm *communicator, int *error_code, ...) {
+void error_handler(MPI_Comm * communicator, int *error_code, ...)
+{
MPI_Comm *new_comm = malloc(sizeof(MPI_Comm));
MPIX_Comm_revoke(comm_all);
@@ -25,7 +26,8 @@ void error_handler(MPI_Comm *communicator, int *error_code, ...) {
comm_all = *new_comm;
}
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
int rank, size, i;
int sum = 0, val = 1;
int errs = 0;
@@ -50,7 +52,8 @@ int main(int argc, char *argv[]) {
sum = 0;
if (i == 5 && rank == 1) {
exit(1);
- } else if (i != 5) {
+ }
+ else if (i != 5) {
MPI_Allreduce(&val, &sum, 1, MPI_INT, MPI_SUM, comm_all);
if (sum != size && rank == 0) {
errs++;
@@ -61,7 +64,8 @@ int main(int argc, char *argv[]) {
if (0 == rank && errs) {
fprintf(stdout, " Found %d errors\n", errs);
- } else if (0 == rank) {
+ }
+ else if (0 == rank) {
fprintf(stdout, " No errors\n");
}
diff --git a/test/mpi/ft/scatter.c b/test/mpi/ft/scatter.c
index 390abe2..b38ea97 100644
--- a/test/mpi/ft/scatter.c
+++ b/test/mpi/ft/scatter.c
@@ -18,7 +18,7 @@ int main(int argc, char **argv)
int rank, size, i, rc, errclass, toterrs, errs = 0;
char rbuf[100000];
char *sendbuf;
- int deadprocs[1] = {1};
+ int deadprocs[1] = { 1 };
MPI_Group world, newgroup;
MPI_Comm newcomm;
@@ -28,8 +28,8 @@ int main(int argc, char **argv)
MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
if (size < 3) {
- fprintf( stderr, "Must run with at least 3 processes\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Must run with at least 3 processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
MPI_Comm_group(MPI_COMM_WORLD, &world);
@@ -41,12 +41,12 @@ int main(int argc, char **argv)
}
/* try a small send first */
- sendbuf = (char *)malloc(10*size*sizeof(char));
+ sendbuf = (char *) malloc(10 * size * sizeof(char));
if (rank == 0) {
- for (i=0;i<size;i++) {
- strcpy(sendbuf + i*10, "No Errors");
- }
+ for (i = 0; i < size; i++) {
+ strcpy(sendbuf + i * 10, "No Errors");
+ }
}
rc = MPI_Scatter(sendbuf, 10, MPI_CHAR, rbuf, 10, MPI_CHAR, 0, MPI_COMM_WORLD);
@@ -54,7 +54,8 @@ int main(int argc, char **argv)
#if defined (MPICH) && (MPICH_NUMVERSION >= 30100102)
MPI_Error_class(rc, &errclass);
if ((rc) && (errclass != MPIX_ERR_PROC_FAILED)) {
- fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n", errclass);
+ fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n",
+ errclass);
errs++;
}
#endif
@@ -62,12 +63,12 @@ int main(int argc, char **argv)
/* reset the buffers and try a larger scatter */
free(sendbuf);
memset(rbuf, 0, sizeof(rbuf));
- sendbuf = (char *)malloc(100000*size*sizeof(char));
+ sendbuf = (char *) malloc(100000 * size * sizeof(char));
if (rank == 0) {
- for (i=0;i<size;i++) {
- strcpy(sendbuf + i*100000, "No Errors");
- }
+ for (i = 0; i < size; i++) {
+ strcpy(sendbuf + i * 100000, "No Errors");
+ }
}
rc = MPI_Scatter(sendbuf, 100000, MPI_CHAR, rbuf, 100000, MPI_CHAR, 0, MPI_COMM_WORLD);
@@ -75,21 +76,22 @@ int main(int argc, char **argv)
#if defined (MPICH) && (MPICH_NUMVERSION >= 30100102)
MPI_Error_class(rc, &errclass);
if ((rc) && (errclass != MPIX_ERR_PROC_FAILED)) {
- fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n", errclass);
+ fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n",
+ errclass);
errs++;
}
#endif
rc = MPI_Reduce(&errs, &toterrs, 1, MPI_INT, MPI_SUM, 0, newcomm);
- if(rc)
+ if (rc)
fprintf(stderr, "Failed to get errors from other processes\n");
if (rank == 0) {
if (toterrs) {
- printf( " Found %d errors\n", toterrs );
+ printf(" Found %d errors\n", toterrs);
}
else {
- printf( " No Errors\n" );
+ printf(" No Errors\n");
}
fflush(stdout);
}
diff --git a/test/mpi/ft/sendalive.c b/test/mpi/ft/sendalive.c
index 8c87179..90fb21e 100644
--- a/test/mpi/ft/sendalive.c
+++ b/test/mpi/ft/sendalive.c
@@ -36,7 +36,8 @@ int main(int argc, char **argv)
err = MPI_Recv(buf, 10, MPI_CHAR, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
if (err) {
fprintf(stderr, "An error occurred during the recv operation\n");
- } else {
+ }
+ else {
printf(" %s\n", buf);
fflush(stdout);
}
diff --git a/test/mpi/ft/senddead.c b/test/mpi/ft/senddead.c
index 49b07f9..85ae6a1 100644
--- a/test/mpi/ft/senddead.c
+++ b/test/mpi/ft/senddead.c
@@ -22,8 +22,8 @@ int main(int argc, char **argv)
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
if (size < 2) {
- fprintf( stderr, "Must run with at least 2 processes\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Must run with at least 2 processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
if (rank == 1) {
@@ -36,15 +36,18 @@ int main(int argc, char **argv)
#if defined (MPICH) && (MPICH_NUMVERSION >= 30100102)
MPI_Error_class(err, &errclass);
if ((err) && (errclass != MPIX_ERR_PROC_FAILED)) {
- fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n", errclass);
+ fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n",
+ errclass);
}
#endif
err = MPI_Send(buf, 100000, MPI_CHAR, 1, 0, MPI_COMM_WORLD);
#if defined (MPICH) && (MPICH_NUMVERSION >= 30100102)
MPI_Error_class(err, &errclass);
if ((err) && (errclass != MPIX_ERR_PROC_FAILED)) {
- fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n", errclass);
- } else {
+ fprintf(stderr, "Wrong error code (%d) returned. Expected MPIX_ERR_PROC_FAILED\n",
+ errclass);
+ }
+ else {
printf(" No Errors\n");
fflush(stdout);
}
diff --git a/test/mpi/ft/shrink.c b/test/mpi/ft/shrink.c
index d5494d7..0346491 100644
--- a/test/mpi/ft/shrink.c
+++ b/test/mpi/ft/shrink.c
@@ -28,7 +28,8 @@ int main(int argc, char **argv)
MPI_Abort(MPI_COMM_WORLD, 1);
}
- if (2 == rank) exit(EXIT_FAILURE);
+ if (2 == rank)
+ exit(EXIT_FAILURE);
rc = MPIX_Comm_shrink(MPI_COMM_WORLD, &newcomm);
if (rc) {
@@ -39,7 +40,7 @@ int main(int argc, char **argv)
}
MPI_Comm_size(newcomm, &newsize);
- if (newsize != size-1)
+ if (newsize != size - 1)
errs++;
rc = MPI_Barrier(newcomm);
@@ -52,7 +53,8 @@ int main(int argc, char **argv)
MPI_Comm_free(&newcomm);
- if (0 == rank) fprintf(stdout, " No Errors\n");
+ if (0 == rank)
+ fprintf(stdout, " No Errors\n");
MPI_Finalize();
diff --git a/test/mpi/group/glpid.c b/test/mpi/group/glpid.c
index 2893ac0..43b1364 100644
--- a/test/mpi/group/glpid.c
+++ b/test/mpi/group/glpid.c
@@ -8,12 +8,12 @@
#include "mpi.h"
#include "mpiimpl.h"
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPID_Group group, *group_ptr = &group;
int i;
- MPI_Init( &argc, &argv );
+ MPI_Init(&argc, &argv);
/* Setup a sample group */
group.handle = 1;
@@ -22,25 +22,24 @@ int main( int argc, char *argv[] )
group.rank = 0;
group.idx_of_first_lpid = -1;
group.lrank_to_lpid = (MPID_Group_pmap_t *)
- MPIU_Malloc( group.size * sizeof(MPID_Group_pmap_t) );
- for (i=0; i<group.size; i++) {
- group.lrank_to_lpid[i].lrank = i;
- group.lrank_to_lpid[i].lpid = group.size - i - 1;
- group.lrank_to_lpid[i].next_lpid = -1;
- group.lrank_to_lpid[i].flag = 0;
+ MPIU_Malloc(group.size * sizeof(MPID_Group_pmap_t));
+ for (i = 0; i < group.size; i++) {
+ group.lrank_to_lpid[i].lrank = i;
+ group.lrank_to_lpid[i].lpid = group.size - i - 1;
+ group.lrank_to_lpid[i].next_lpid = -1;
+ group.lrank_to_lpid[i].flag = 0;
}
/* Set up the group lpid list */
- MPIR_Group_setup_lpid_list( group_ptr );
+ MPIR_Group_setup_lpid_list(group_ptr);
/* Print the group structure */
- printf ("Index of first lpid = %d\n", group.idx_of_first_lpid );
- for (i=0; i<group.size; i++) {
- printf( "lrank_to_lpid[%d].next_lpid = %d, .lpid = %d\n",
- i, group.lrank_to_lpid[i].next_lpid,
- group.lrank_to_lpid[i].lpid );
+ printf("Index of first lpid = %d\n", group.idx_of_first_lpid);
+ for (i = 0; i < group.size; i++) {
+ printf("lrank_to_lpid[%d].next_lpid = %d, .lpid = %d\n",
+ i, group.lrank_to_lpid[i].next_lpid, group.lrank_to_lpid[i].lpid);
}
- MPI_Finalize( );
+ MPI_Finalize();
return 0;
}
diff --git a/test/mpi/group/groupcreate.c b/test/mpi/group/groupcreate.c
index c8952d8..ffbad0f 100644
--- a/test/mpi/group/groupcreate.c
+++ b/test/mpi/group/groupcreate.c
@@ -8,79 +8,78 @@
/* stdlib.h Needed for malloc declaration */
#include <stdlib.h>
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
int i, n, n_goal = 2048, n_all, rc, n_ranks, *ranks, rank, size, len;
int group_size;
MPI_Group *group_array, world_group;
char msg[MPI_MAX_ERROR_STRING];
- MPI_Init( &argc, &argv );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+ MPI_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
n = n_goal;
-
- group_array = (MPI_Group *)malloc( n * sizeof(MPI_Group) );
- MPI_Comm_group( MPI_COMM_WORLD, &world_group );
+ group_array = (MPI_Group *) malloc(n * sizeof(MPI_Group));
+
+ MPI_Comm_group(MPI_COMM_WORLD, &world_group);
n_ranks = size;
- ranks = (int *)malloc( size * sizeof(int) );
- for (i=0; i<size; i++) ranks[i] = i;
+ ranks = (int *) malloc(size * sizeof(int));
+ for (i = 0; i < size; i++)
+ ranks[i] = i;
+
+ MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+ for (i = 0; i < n; i++) {
+ rc = MPI_Group_incl(world_group, n_ranks, ranks, group_array + i);
+ if (rc) {
+ fprintf(stderr, "Error when creating group number %d\n", i);
+ MPI_Error_string(rc, msg, &len);
+ fprintf(stderr, "%s\n", msg);
+ n = i + 1;
+ break;
+ }
+ else {
+ /* Check that the group was created (and that any errors were
+ * caught) */
+ rc = MPI_Group_size(group_array[i], &group_size);
+ if (group_size != size) {
+ fprintf(stderr, "Group number %d not correct (size = %d)\n", i, size);
+ n = i + 1;
+ break;
+ }
+ }
- MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
- for (i=0; i<n; i++) {
- rc = MPI_Group_incl( world_group, n_ranks, ranks, group_array + i );
- if (rc) {
- fprintf( stderr, "Error when creating group number %d\n", i );
- MPI_Error_string( rc, msg, &len );
- fprintf( stderr, "%s\n", msg );
- n = i + 1;
- break;
- }
- else {
- /* Check that the group was created (and that any errors were
- caught) */
- rc = MPI_Group_size( group_array[i], &group_size );
- if (group_size != size) {
- fprintf( stderr, "Group number %d not correct (size = %d)\n",
- i, size );
- n = i + 1;
- break;
- }
- }
-
}
- for (i=0; i<n; i++) {
- rc = MPI_Group_free( group_array + i );
- if (rc) {
- fprintf( stderr, "Error when freeing group number %d\n", i );
- MPI_Error_string( rc, msg, &len );
- fprintf( stderr, "%s\n", msg );
- break;
- }
+ for (i = 0; i < n; i++) {
+ rc = MPI_Group_free(group_array + i);
+ if (rc) {
+ fprintf(stderr, "Error when freeing group number %d\n", i);
+ MPI_Error_string(rc, msg, &len);
+ fprintf(stderr, "%s\n", msg);
+ break;
+ }
}
- MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL );
- MPI_Group_free( &world_group );
+ MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL);
+ MPI_Group_free(&world_group);
- MPI_Reduce( &n, &n_all, 1, MPI_INT, MPI_MIN, 0, MPI_COMM_WORLD );
+ MPI_Reduce(&n, &n_all, 1, MPI_INT, MPI_MIN, 0, MPI_COMM_WORLD);
if (rank == 0) {
- /* printf( "Completed test of %d type creations\n", n_all ); */
- if (n_all != n_goal) {
- printf (
-"This MPI implementation limits the number of groups that can be created\n\
+ /* printf("Completed test of %d type creations\n", n_all); */
+ if (n_all != n_goal) {
+ printf("This MPI implementation limits the number of groups that can be created\n\
This is allowed by the standard and is not a bug, but is a limit on the\n\
-implementation\n" );
- }
- else {
- printf( " No Errors\n" );
- }
+implementation\n");
+ }
+ else {
+ printf(" No Errors\n");
+ }
}
- free( group_array );
+ free(group_array);
- MPI_Finalize( );
+ MPI_Finalize();
return 0;
}
diff --git a/test/mpi/group/groupnullincl.c b/test/mpi/group/groupnullincl.c
index 029471b..0f6224b 100644
--- a/test/mpi/group/groupnullincl.c
+++ b/test/mpi/group/groupnullincl.c
@@ -8,7 +8,7 @@
#include <stdio.h>
#include "mpitest.h"
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rc, result;
@@ -16,57 +16,58 @@ int main( int argc, char *argv[] )
MPI_Group group, outgroup;
MPI_Comm comm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
- while (MTestGetComm( &comm, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
+ while (MTestGetComm(&comm, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
- MPI_Comm_group( comm, &group );
- rc = MPI_Group_incl( group, 0, 0, &outgroup );
- if (rc) {
- errs++;
- MTestPrintError( rc );
- printf( "Error in creating an empty group with (0,0)\n" );
-
- /* Some MPI implementations may reject a null "ranks" pointer */
- rc = MPI_Group_incl( group, 0, ranks, &outgroup );
- if (rc) {
- errs++;
- MTestPrintError( rc );
- printf( "Error in creating an empty group with (0,ranks)\n" );
- }
- }
+ MPI_Comm_group(comm, &group);
+ rc = MPI_Group_incl(group, 0, 0, &outgroup);
+ if (rc) {
+ errs++;
+ MTestPrintError(rc);
+ printf("Error in creating an empty group with (0,0)\n");
- if (outgroup != MPI_GROUP_EMPTY) {
- /* Is the group equivalent to group empty? */
- rc = MPI_Group_compare( outgroup, MPI_GROUP_EMPTY, &result );
- if (result != MPI_IDENT) {
- errs++;
- MTestPrintError( rc );
- printf( "Did not create a group equivalent to an empty group\n" );
- }
- }
- rc = MPI_Group_free( &group );
- if (rc) {
- errs++;
- MTestPrintError( rc );
- }
- if (outgroup != MPI_GROUP_NULL) {
- rc = MPI_Group_free( &outgroup );
- if (rc) {
- errs++;
- MTestPrintError( rc );
- }
- }
+ /* Some MPI implementations may reject a null "ranks" pointer */
+ rc = MPI_Group_incl(group, 0, ranks, &outgroup);
+ if (rc) {
+ errs++;
+ MTestPrintError(rc);
+ printf("Error in creating an empty group with (0,ranks)\n");
+ }
+ }
- MTestFreeComm( &comm );
+ if (outgroup != MPI_GROUP_EMPTY) {
+ /* Is the group equivalent to group empty? */
+ rc = MPI_Group_compare(outgroup, MPI_GROUP_EMPTY, &result);
+ if (result != MPI_IDENT) {
+ errs++;
+ MTestPrintError(rc);
+ printf("Did not create a group equivalent to an empty group\n");
+ }
+ }
+ rc = MPI_Group_free(&group);
+ if (rc) {
+ errs++;
+ MTestPrintError(rc);
+ }
+ if (outgroup != MPI_GROUP_NULL) {
+ rc = MPI_Group_free(&outgroup);
+ if (rc) {
+ errs++;
+ MTestPrintError(rc);
+ }
+ }
+
+ MTestFreeComm(&comm);
}
-
- MTest_Finalize( errs );
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/group/grouptest.c b/test/mpi/group/grouptest.c
index 9915cc9..86ae025 100644
--- a/test/mpi/group/grouptest.c
+++ b/test/mpi/group/grouptest.c
@@ -8,170 +8,171 @@
#include <stdio.h>
#include <stdlib.h>
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Group g1, g2, g4, g5, g45, selfgroup, g6;
int ranks[16], size, rank, myrank, range[1][3];
int errs = 0;
int i, rin[16], rout[16], result;
- MPI_Init(0,0);
-
- MPI_Comm_group( MPI_COMM_WORLD, &g1 );
- MPI_Comm_rank( MPI_COMM_WORLD, &myrank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
- if (size < 8) {
- fprintf( stderr,
- "Test requires 8 processes (16 prefered) only %d provided\n",
- size );
- errs++;
- }
-
- /* 16 members, this process is rank 0, return in group 1 */
- ranks[0] = myrank; ranks[1] = 2; ranks[2] = 7;
- if (myrank == 2) ranks[1] = 3;
- if (myrank == 7) ranks[2] = 6;
- MPI_Group_incl( g1, 3, ranks, &g2 );
-
- /* Check the resulting group */
- MPI_Group_size( g2, &size );
- MPI_Group_rank( g2, &rank );
-
- if (size != 3) {
- fprintf( stderr, "Size should be %d, is %d\n", 3, size );
- errs++;
- }
- if (rank != 0) {
- fprintf( stderr, "Rank should be %d, is %d\n", 0, rank );
- errs++;
- }
-
- rin[0] = 0; rin[1] = 1; rin[2] = 2;
- MPI_Group_translate_ranks( g2, 3, rin, g1, rout );
- for (i=0; i<3; i++) {
- if (rout[i] != ranks[i]) {
- fprintf( stderr, "translated rank[%d] %d should be %d\n",
- i, rout[i], ranks[i] );
- errs++;
- }
- }
-
- /* Translate the process of the self group against another group */
- MPI_Comm_group( MPI_COMM_SELF, &selfgroup );
- rin[0] = 0;
- MPI_Group_translate_ranks( selfgroup, 1, rin, g1, rout );
- if (rout[0] != myrank) {
- fprintf( stderr, "translated of self is %d should be %d\n",
- rout[0], myrank );
- errs++;
- }
-
- for (i=0; i<size; i++)
- rin[i] = i;
- MPI_Group_translate_ranks( g1, size, rin, selfgroup, rout );
- for (i=0; i<size; i++) {
- if (i == myrank && rout[i] != 0) {
- fprintf( stderr, "translated world to self of %d is %d\n",
- i, rout[i] );
- errs++;
- }
- else if (i != myrank && rout[i] != MPI_UNDEFINED) {
- fprintf( stderr, "translated world to self of %d should be undefined, is %d\n",
- i, rout[i] );
- errs++;
- }
- }
- MPI_Group_free( &selfgroup );
-
- /* Exclude everyone in our group */
- {
- int ii, *lranks, g1size;
-
- MPI_Group_size( g1, &g1size );
-
- lranks = (int *)malloc( g1size * sizeof(int) );
- for (ii=0; ii<g1size; ii++) lranks[ii] = ii;
- MPI_Group_excl( g1, g1size, lranks, &g6 );
- if (g6 != MPI_GROUP_EMPTY) {
- fprintf( stderr, "Group formed by excluding all ranks not empty\n" );
- errs++;
- MPI_Group_free( &g6 );
- }
- free( lranks );
- }
-
- /* Add tests for additional group operations */
- /*
- g2 = incl 1,3,7
- g3 = excl 1,3,7
- intersect ( w, g2 ) => g2
- intersect ( w, g3 ) => g3
- intersect ( g2, g3 ) => empty
-
- g4 = rincl 1:n-1:2
- g5 = rexcl 1:n-1:2
- union( g4, g5 ) => world
- g6 = rincl n-1:1:-1
- g7 = rexcl n-1:1:-1
- union( g6, g7 ) => concat of entries, similar to world
- diff( w, g2 ) => g3
- */
- MPI_Group_free( &g2 );
-
- range[0][0] = 1;
- range[0][1] = size-1;
- range[0][2] = 2;
- MPI_Group_range_excl( g1, 1, range, &g5 );
-
- range[0][0] = 1;
- range[0][1] = size-1;
- range[0][2] = 2;
- MPI_Group_range_incl( g1, 1, range, &g4 );
-
- MPI_Group_union( g4, g5, &g45 );
-
- MPI_Group_compare( MPI_GROUP_EMPTY, g4, &result );
- if (result != MPI_UNEQUAL) {
- errs++;
- fprintf( stderr, "Comparison with empty group gave %d, not 3\n",
- result );
- }
- MPI_Group_free( &g4 );
- MPI_Group_free( &g5 );
- MPI_Group_free( &g45 );
-
- /* Now, duplicate the test, but using negative strides */
- range[0][0] = size-1;
- range[0][1] = 1;
- range[0][2] = -2;
- MPI_Group_range_excl( g1, 1, range, &g5 );
-
- range[0][0] = size-1;
- range[0][1] = 1;
- range[0][2] = -2;
- MPI_Group_range_incl( g1, 1, range, &g4 );
-
- MPI_Group_union( g4, g5, &g45 );
-
- MPI_Group_compare( MPI_GROUP_EMPTY, g4, &result );
- if (result != MPI_UNEQUAL) {
- errs++;
- fprintf( stderr, "Comparison with empty group (formed with negative strides) gave %d, not 3\n",
- result );
- }
- MPI_Group_free( &g4 );
- MPI_Group_free( &g5 );
- MPI_Group_free( &g45 );
- MPI_Group_free( &g1 );
-
- if (myrank == 0)
+ MPI_Init(0, 0);
+
+ MPI_Comm_group(MPI_COMM_WORLD, &g1);
+ MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ if (size < 8) {
+ fprintf(stderr, "Test requires 8 processes (16 prefered) only %d provided\n", size);
+ errs++;
+ }
+
+ /* 16 members, this process is rank 0, return in group 1 */
+ ranks[0] = myrank;
+ ranks[1] = 2;
+ ranks[2] = 7;
+ if (myrank == 2)
+ ranks[1] = 3;
+ if (myrank == 7)
+ ranks[2] = 6;
+ MPI_Group_incl(g1, 3, ranks, &g2);
+
+ /* Check the resulting group */
+ MPI_Group_size(g2, &size);
+ MPI_Group_rank(g2, &rank);
+
+ if (size != 3) {
+ fprintf(stderr, "Size should be %d, is %d\n", 3, size);
+ errs++;
+ }
+ if (rank != 0) {
+ fprintf(stderr, "Rank should be %d, is %d\n", 0, rank);
+ errs++;
+ }
+
+ rin[0] = 0;
+ rin[1] = 1;
+ rin[2] = 2;
+ MPI_Group_translate_ranks(g2, 3, rin, g1, rout);
+ for (i = 0; i < 3; i++) {
+ if (rout[i] != ranks[i]) {
+ fprintf(stderr, "translated rank[%d] %d should be %d\n", i, rout[i], ranks[i]);
+ errs++;
+ }
+ }
+
+ /* Translate the process of the self group against another group */
+ MPI_Comm_group(MPI_COMM_SELF, &selfgroup);
+ rin[0] = 0;
+ MPI_Group_translate_ranks(selfgroup, 1, rin, g1, rout);
+ if (rout[0] != myrank) {
+ fprintf(stderr, "translated of self is %d should be %d\n", rout[0], myrank);
+ errs++;
+ }
+
+ for (i = 0; i < size; i++)
+ rin[i] = i;
+ MPI_Group_translate_ranks(g1, size, rin, selfgroup, rout);
+ for (i = 0; i < size; i++) {
+ if (i == myrank && rout[i] != 0) {
+ fprintf(stderr, "translated world to self of %d is %d\n", i, rout[i]);
+ errs++;
+ }
+ else if (i != myrank && rout[i] != MPI_UNDEFINED) {
+ fprintf(stderr, "translated world to self of %d should be undefined, is %d\n",
+ i, rout[i]);
+ errs++;
+ }
+ }
+ MPI_Group_free(&selfgroup);
+
+ /* Exclude everyone in our group */
{
- if (errs == 0) {
- printf( " No Errors\n" );
- }
- else {
- printf( "Found %d errors\n", errs );
- }
+ int ii, *lranks, g1size;
+
+ MPI_Group_size(g1, &g1size);
+
+ lranks = (int *) malloc(g1size * sizeof(int));
+ for (ii = 0; ii < g1size; ii++)
+ lranks[ii] = ii;
+ MPI_Group_excl(g1, g1size, lranks, &g6);
+ if (g6 != MPI_GROUP_EMPTY) {
+ fprintf(stderr, "Group formed by excluding all ranks not empty\n");
+ errs++;
+ MPI_Group_free(&g6);
+ }
+ free(lranks);
+ }
+
+ /* Add tests for additional group operations */
+ /*
+ * g2 = incl 1,3,7
+ * g3 = excl 1,3,7
+ * intersect (w, g2) => g2
+ * intersect (w, g3) => g3
+ * intersect (g2, g3) => empty
+ *
+ * g4 = rincl 1:n-1:2
+ * g5 = rexcl 1:n-1:2
+ * union(g4, g5) => world
+ * g6 = rincl n-1:1:-1
+ * g7 = rexcl n-1:1:-1
+ * union(g6, g7) => concat of entries, similar to world
+ * diff(w, g2) => g3
+ */
+ MPI_Group_free(&g2);
+
+ range[0][0] = 1;
+ range[0][1] = size - 1;
+ range[0][2] = 2;
+ MPI_Group_range_excl(g1, 1, range, &g5);
+
+ range[0][0] = 1;
+ range[0][1] = size - 1;
+ range[0][2] = 2;
+ MPI_Group_range_incl(g1, 1, range, &g4);
+
+ MPI_Group_union(g4, g5, &g45);
+
+ MPI_Group_compare(MPI_GROUP_EMPTY, g4, &result);
+ if (result != MPI_UNEQUAL) {
+ errs++;
+ fprintf(stderr, "Comparison with empty group gave %d, not 3\n", result);
+ }
+ MPI_Group_free(&g4);
+ MPI_Group_free(&g5);
+ MPI_Group_free(&g45);
+
+ /* Now, duplicate the test, but using negative strides */
+ range[0][0] = size - 1;
+ range[0][1] = 1;
+ range[0][2] = -2;
+ MPI_Group_range_excl(g1, 1, range, &g5);
+
+ range[0][0] = size - 1;
+ range[0][1] = 1;
+ range[0][2] = -2;
+ MPI_Group_range_incl(g1, 1, range, &g4);
+
+ MPI_Group_union(g4, g5, &g45);
+
+ MPI_Group_compare(MPI_GROUP_EMPTY, g4, &result);
+ if (result != MPI_UNEQUAL) {
+ errs++;
+ fprintf(stderr,
+ "Comparison with empty group (formed with negative strides) gave %d, not 3\n",
+ result);
+ }
+ MPI_Group_free(&g4);
+ MPI_Group_free(&g5);
+ MPI_Group_free(&g45);
+ MPI_Group_free(&g1);
+
+ if (myrank == 0) {
+ if (errs == 0) {
+ printf(" No Errors\n");
+ }
+ else {
+ printf("Found %d errors\n", errs);
+ }
}
MPI_Finalize();
diff --git a/test/mpi/group/grouptest2.c b/test/mpi/group/grouptest2.c
index 7d8fb7e..00cb465 100644
--- a/test/mpi/group/grouptest2.c
+++ b/test/mpi/group/grouptest2.c
@@ -24,188 +24,187 @@ MPI_Group_union
/* stdlib.h Needed for malloc declaration */
#include <stdlib.h>
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- int errs=0, toterr;
+ int errs = 0, toterr;
MPI_Group basegroup;
MPI_Group g1, g2, g3, g4, g5, g6, g7, g8, g9, g10;
MPI_Group g3a, g3b;
- MPI_Comm comm, newcomm, splitcomm, dupcomm;
- int i, grp_rank, rank, grp_size, size, result;
- int nranks, *ranks, *ranks_out;
- int range[1][3];
- int worldrank;
+ MPI_Comm comm, newcomm, splitcomm, dupcomm;
+ int i, grp_rank, rank, grp_size, size, result;
+ int nranks, *ranks, *ranks_out;
+ int range[1][3];
+ int worldrank;
- MPI_Init( &argc, &argv );
- MPI_Comm_rank( MPI_COMM_WORLD, &worldrank );
+ MPI_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &worldrank);
comm = MPI_COMM_WORLD;
- MPI_Comm_group( comm, &basegroup );
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_group(comm, &basegroup);
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
/* Get the basic information on this group */
- MPI_Group_rank( basegroup, &grp_rank );
+ MPI_Group_rank(basegroup, &grp_rank);
if (grp_rank != rank) {
- errs++;
- fprintf( stdout, "group rank %d != comm rank %d\n", grp_rank, rank );
+ errs++;
+ fprintf(stdout, "group rank %d != comm rank %d\n", grp_rank, rank);
}
- MPI_Group_size( basegroup, &grp_size );
+ MPI_Group_size(basegroup, &grp_size);
if (grp_size != size) {
- errs++;
- fprintf( stdout, "group size %d != comm size %d\n", grp_size, size );
+ errs++;
+ fprintf(stdout, "group size %d != comm size %d\n", grp_size, size);
}
/* Form a new communicator with inverted ranking */
- MPI_Comm_split( comm, 0, size - rank, &newcomm );
- MPI_Comm_group( newcomm, &g1 );
- ranks = (int *)malloc( size * sizeof(int) );
- ranks_out = (int *)malloc( size * sizeof(int) );
- for (i=0; i<size; i++) ranks[i] = i;
+ MPI_Comm_split(comm, 0, size - rank, &newcomm);
+ MPI_Comm_group(newcomm, &g1);
+ ranks = (int *) malloc(size * sizeof(int));
+ ranks_out = (int *) malloc(size * sizeof(int));
+ for (i = 0; i < size; i++)
+ ranks[i] = i;
nranks = size;
- MPI_Group_translate_ranks( g1, nranks, ranks, basegroup, ranks_out );
- for (i=0; i<size; i++) {
- if (ranks_out[i] != (size - 1) - i) {
- errs++;
- fprintf( stdout, "Translate ranks got %d expected %d\n",
- ranks_out[i], (size - 1) - i );
- }
+ MPI_Group_translate_ranks(g1, nranks, ranks, basegroup, ranks_out);
+ for (i = 0; i < size; i++) {
+ if (ranks_out[i] != (size - 1) - i) {
+ errs++;
+ fprintf(stdout, "Translate ranks got %d expected %d\n", ranks_out[i], (size - 1) - i);
+ }
}
/* Check Compare */
- MPI_Group_compare( basegroup, g1, &result );
+ MPI_Group_compare(basegroup, g1, &result);
if (result != MPI_SIMILAR) {
- errs++;
- fprintf( stdout, "Group compare should have been similar, was %d\n",
- result );
+ errs++;
+ fprintf(stdout, "Group compare should have been similar, was %d\n", result);
}
- MPI_Comm_dup( comm, &dupcomm );
- MPI_Comm_group( dupcomm, &g2 );
- MPI_Group_compare( basegroup, g2, &result );
+ MPI_Comm_dup(comm, &dupcomm);
+ MPI_Comm_group(dupcomm, &g2);
+ MPI_Group_compare(basegroup, g2, &result);
if (result != MPI_IDENT) {
- errs++;
- fprintf( stdout, "Group compare should have been ident, was %d\n",
- result );
+ errs++;
+ fprintf(stdout, "Group compare should have been ident, was %d\n", result);
}
- MPI_Comm_split( comm, rank < size/2, rank, &splitcomm );
- MPI_Comm_group( splitcomm, &g3 );
- MPI_Group_compare( basegroup, g3, &result );
+ MPI_Comm_split(comm, rank < size / 2, rank, &splitcomm);
+ MPI_Comm_group(splitcomm, &g3);
+ MPI_Group_compare(basegroup, g3, &result);
if (result != MPI_UNEQUAL) {
- errs++;
- fprintf( stdout, "Group compare should have been unequal, was %d\n",
- result );
+ errs++;
+ fprintf(stdout, "Group compare should have been unequal, was %d\n", result);
}
/* Build two groups that have this process and one other, but do not
- have the same processes */
+ * have the same processes */
ranks[0] = rank;
ranks[1] = (rank + 1) % size;
- MPI_Group_incl( basegroup, 2, ranks, &g3a );
+ MPI_Group_incl(basegroup, 2, ranks, &g3a);
ranks[1] = (rank + size - 1) % size;
- MPI_Group_incl( basegroup, 2, ranks, &g3b );
- MPI_Group_compare( g3a, g3b, &result );
+ MPI_Group_incl(basegroup, 2, ranks, &g3b);
+ MPI_Group_compare(g3a, g3b, &result);
if (result != MPI_UNEQUAL) {
errs++;
- fprintf( stdout, "Group compare of equal sized but different groups should have been unequal, was %d\n", result );
+ fprintf(stdout,
+ "Group compare of equal sized but different groups should have been unequal, was %d\n",
+ result);
}
-
+
/* Build two new groups by excluding members; use Union to put them
together again */
/* Exclude 0 */
- for (i=0; i<size; i++) ranks[i] = i;
- MPI_Group_excl( basegroup, 1, ranks, &g4 );
+ for (i = 0; i < size; i++)
+ ranks[i] = i;
+ MPI_Group_excl(basegroup, 1, ranks, &g4);
/* Exclude 1-(size-1) */
- MPI_Group_excl( basegroup, size-1, ranks+1, &g5 );
- MPI_Group_union( g5, g4, &g6 );
- MPI_Group_compare( basegroup, g6, &result );
+ MPI_Group_excl(basegroup, size - 1, ranks + 1, &g5);
+ MPI_Group_union(g5, g4, &g6);
+ MPI_Group_compare(basegroup, g6, &result);
if (result != MPI_IDENT) {
- int usize;
- errs++;
- /* See ordering requirements on union */
- fprintf( stdout, "Group excl and union did not give ident groups\n" );
- fprintf( stdout, "[%d] result of compare was %d\n", rank, result );
- MPI_Group_size( g6, &usize );
- fprintf( stdout, "Size of union is %d, should be %d\n", usize, size );
+ int usize;
+ errs++;
+ /* See ordering requirements on union */
+ fprintf(stdout, "Group excl and union did not give ident groups\n");
+ fprintf(stdout, "[%d] result of compare was %d\n", rank, result);
+ MPI_Group_size(g6, &usize);
+ fprintf(stdout, "Size of union is %d, should be %d\n", usize, size);
}
- MPI_Group_union( basegroup, g4, &g7 );
- MPI_Group_compare( basegroup, g7, &result );
+ MPI_Group_union(basegroup, g4, &g7);
+ MPI_Group_compare(basegroup, g7, &result);
if (result != MPI_IDENT) {
- int usize;
- errs++;
- fprintf( stdout, "Group union of overlapping groups failed\n" );
- fprintf( stdout, "[%d] result of compare was %d\n", rank, result );
- MPI_Group_size( g7, &usize );
- fprintf( stdout, "Size of union is %d, should be %d\n", usize, size );
+ int usize;
+ errs++;
+ fprintf(stdout, "Group union of overlapping groups failed\n");
+ fprintf(stdout, "[%d] result of compare was %d\n", rank, result);
+ MPI_Group_size(g7, &usize);
+ fprintf(stdout, "Size of union is %d, should be %d\n", usize, size);
}
/* Use range_excl instead of ranks */
- /* printf ("range excl\n" ); fflush( stdout ); */
+ /* printf ("range excl\n"); fflush(stdout); */
range[0][0] = 1;
- range[0][1] = size-1;
+ range[0][1] = size - 1;
range[0][2] = 1;
- MPI_Group_range_excl( basegroup, 1, range, &g8 );
- /* printf( "out of range excl\n" ); fflush( stdout ); */
- MPI_Group_compare( g5, g8, &result );
- /* printf( "out of compare\n" ); fflush( stdout ); */
+ MPI_Group_range_excl(basegroup, 1, range, &g8);
+ /* printf("out of range excl\n"); fflush(stdout); */
+ MPI_Group_compare(g5, g8, &result);
+ /* printf("out of compare\n"); fflush(stdout); */
if (result != MPI_IDENT) {
- errs++;
- fprintf( stdout, "Group range excl did not give ident groups\n" );
+ errs++;
+ fprintf(stdout, "Group range excl did not give ident groups\n");
}
- /* printf( "intersection\n" ); fflush( stdout ); */
- MPI_Group_intersection( basegroup, g4, &g9 );
- MPI_Group_compare( g9, g4, &result );
+ /* printf("intersection\n"); fflush(stdout); */
+ MPI_Group_intersection(basegroup, g4, &g9);
+ MPI_Group_compare(g9, g4, &result);
if (result != MPI_IDENT) {
- errs++;
- fprintf( stdout, "Group intersection did not give ident groups\n" );
+ errs++;
+ fprintf(stdout, "Group intersection did not give ident groups\n");
}
/* Exclude EVERYTHING and check against MPI_GROUP_EMPTY */
- /* printf( "range excl all\n" ); fflush( stdout ); */
+ /* printf("range excl all\n"); fflush(stdout); */
range[0][0] = 0;
- range[0][1] = size-1;
+ range[0][1] = size - 1;
range[0][2] = 1;
- MPI_Group_range_excl( basegroup, 1, range, &g10 );
+ MPI_Group_range_excl(basegroup, 1, range, &g10);
- /* printf( "done range excl all\n" ); fflush(stdout); */
- MPI_Group_compare( g10, MPI_GROUP_EMPTY, &result );
- /* printf( "done compare to MPI_GROUP_EMPTY\n" ); fflush(stdout); */
+ /* printf("done range excl all\n"); fflush(stdout); */
+ MPI_Group_compare(g10, MPI_GROUP_EMPTY, &result);
+ /* printf("done compare to MPI_GROUP_EMPTY\n"); fflush(stdout); */
if (result != MPI_IDENT) {
- errs++;
- fprintf( stdout,
- "MPI_GROUP_EMPTY didn't compare against empty group\n");
+ errs++;
+ fprintf(stdout, "MPI_GROUP_EMPTY didn't compare against empty group\n");
}
- /* printf( "freeing groups\n" ); fflush( stdout ); */
- MPI_Group_free( &basegroup );
- MPI_Group_free( &g1 );
- MPI_Group_free( &g2 );
- MPI_Group_free( &g3 );
- MPI_Group_free( &g3a );
- MPI_Group_free( &g3b );
- MPI_Group_free( &g4 );
- MPI_Group_free( &g5 );
- MPI_Group_free( &g6 );
- MPI_Group_free( &g7 );
- MPI_Group_free( &g8 );
- MPI_Group_free( &g9 );
- MPI_Group_free( &g10 );
- MPI_Comm_free( &dupcomm );
- MPI_Comm_free( &splitcomm );
- MPI_Comm_free( &newcomm );
-
- MPI_Allreduce( &errs, &toterr, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
+ /* printf("freeing groups\n"); fflush(stdout); */
+ MPI_Group_free(&basegroup);
+ MPI_Group_free(&g1);
+ MPI_Group_free(&g2);
+ MPI_Group_free(&g3);
+ MPI_Group_free(&g3a);
+ MPI_Group_free(&g3b);
+ MPI_Group_free(&g4);
+ MPI_Group_free(&g5);
+ MPI_Group_free(&g6);
+ MPI_Group_free(&g7);
+ MPI_Group_free(&g8);
+ MPI_Group_free(&g9);
+ MPI_Group_free(&g10);
+ MPI_Comm_free(&dupcomm);
+ MPI_Comm_free(&splitcomm);
+ MPI_Comm_free(&newcomm);
+
+ MPI_Allreduce(&errs, &toterr, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
if (worldrank == 0) {
- if (toterr == 0)
- printf( " No Errors\n" );
- else
- printf( "Found %d errors in MPI Group routines\n", toterr );
+ if (toterr == 0)
+ printf(" No Errors\n");
+ else
+ printf("Found %d errors in MPI Group routines\n", toterr);
}
MPI_Finalize();
diff --git a/test/mpi/group/gtranks.c b/test/mpi/group/gtranks.c
index e5f032f..5b20967 100644
--- a/test/mpi/group/gtranks.c
+++ b/test/mpi/group/gtranks.c
@@ -9,60 +9,56 @@
#define MAX_WORLD_SIZE 1024
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
- int ranks[MAX_WORLD_SIZE], ranksout[MAX_WORLD_SIZE],
- ranksin[MAX_WORLD_SIZE];
+ int ranks[MAX_WORLD_SIZE], ranksout[MAX_WORLD_SIZE], ranksin[MAX_WORLD_SIZE];
int range[1][3];
MPI_Group gworld, gself, ngroup, galt;
- MPI_Comm comm;
+ MPI_Comm comm;
int rank, size, i, nelms;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Comm_group( MPI_COMM_SELF, &gself );
+ MPI_Comm_group(MPI_COMM_SELF, &gself);
comm = MPI_COMM_WORLD;
- MPI_Comm_size( comm, &size );
- MPI_Comm_rank( comm, &rank );
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
if (size > MAX_WORLD_SIZE) {
- fprintf( stderr,
- "This test requires a comm world with no more than %d processes\n",
- MAX_WORLD_SIZE );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr,
+ "This test requires a comm world with no more than %d processes\n", MAX_WORLD_SIZE);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
if (size < 4) {
- fprintf( stderr, "This test requiers at least 4 processes\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "This test requiers at least 4 processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- MPI_Comm_group( comm, &gworld );
- for (i=0; i<size; i++) {
- ranks[i] = i;
- ranksout[i] = -1;
+ MPI_Comm_group(comm, &gworld);
+ for (i = 0; i < size; i++) {
+ ranks[i] = i;
+ ranksout[i] = -1;
}
/* Try translating ranks from comm world compared against
- comm self, so most will be UNDEFINED */
- MPI_Group_translate_ranks( gworld, size, ranks, gself, ranksout );
-
- for (i=0; i<size; i++) {
- if (i == rank) {
- if (ranksout[i] != 0) {
- printf( "[%d] Rank %d is %d but should be 0\n", rank,
- i, ranksout[i] );
- errs++;
- }
- }
- else {
- if (ranksout[i] != MPI_UNDEFINED) {
- printf( "[%d] Rank %d is %d but should be undefined\n", rank,
- i, ranksout[i] );
- errs++;
- }
- }
+ * comm self, so most will be UNDEFINED */
+ MPI_Group_translate_ranks(gworld, size, ranks, gself, ranksout);
+
+ for (i = 0; i < size; i++) {
+ if (i == rank) {
+ if (ranksout[i] != 0) {
+ printf("[%d] Rank %d is %d but should be 0\n", rank, i, ranksout[i]);
+ errs++;
+ }
+ }
+ else {
+ if (ranksout[i] != MPI_UNDEFINED) {
+ printf("[%d] Rank %d is %d but should be undefined\n", rank, i, ranksout[i]);
+ errs++;
+ }
+ }
}
/* MPI-2 Errata requires that MPI_PROC_NULL is mapped to MPI_PROC_NULL */
@@ -70,98 +66,94 @@ int main( int argc, char *argv[] )
ranks[1] = 1;
ranks[2] = rank;
ranks[3] = MPI_PROC_NULL;
- for (i=0; i<4; i++) ranksout[i] = -1;
+ for (i = 0; i < 4; i++)
+ ranksout[i] = -1;
- MPI_Group_translate_ranks( gworld, 4, ranks, gself, ranksout );
+ MPI_Group_translate_ranks(gworld, 4, ranks, gself, ranksout);
if (ranksout[0] != MPI_PROC_NULL) {
- printf( "[%d] Rank[0] should be MPI_PROC_NULL but is %d\n",
- rank, ranksout[0] );
- errs++;
+ printf("[%d] Rank[0] should be MPI_PROC_NULL but is %d\n", rank, ranksout[0]);
+ errs++;
}
if (rank != 1 && ranksout[1] != MPI_UNDEFINED) {
- printf( "[%d] Rank[1] should be MPI_UNDEFINED but is %d\n",
- rank, ranksout[1] );
- errs++;
+ printf("[%d] Rank[1] should be MPI_UNDEFINED but is %d\n", rank, ranksout[1]);
+ errs++;
}
if (rank == 1 && ranksout[1] != 0) {
- printf( "[%d] Rank[1] should be 0 but is %d\n",
- rank, ranksout[1] );
- errs++;
+ printf("[%d] Rank[1] should be 0 but is %d\n", rank, ranksout[1]);
+ errs++;
}
if (ranksout[2] != 0) {
- printf( "[%d] Rank[2] should be 0 but is %d\n",
- rank, ranksout[2] );
- errs++;
+ printf("[%d] Rank[2] should be 0 but is %d\n", rank, ranksout[2]);
+ errs++;
}
if (ranksout[3] != MPI_PROC_NULL) {
- printf( "[%d] Rank[3] should be MPI_PROC_NULL but is %d\n",
- rank, ranksout[3] );
- errs++;
+ printf("[%d] Rank[3] should be MPI_PROC_NULL but is %d\n", rank, ranksout[3]);
+ errs++;
}
MPI_Group_free(&gself);
/* Now, try comparing small groups against larger groups, and use groups
- with irregular members (to bypass optimizations in group_translate_ranks
- for simple groups)
+ * with irregular members (to bypass optimizations in group_translate_ranks
+ * for simple groups)
*/
nelms = 0;
ranks[nelms++] = size - 2;
ranks[nelms++] = 0;
if (rank != 0 && rank != size - 2) {
- ranks[nelms++] = rank;
+ ranks[nelms++] = rank;
}
- MPI_Group_incl( gworld, nelms, ranks, &ngroup );
+ MPI_Group_incl(gworld, nelms, ranks, &ngroup);
- for (i=0; i<nelms; i++) ranksout[i] = -1;
+ for (i = 0; i < nelms; i++)
+ ranksout[i] = -1;
ranksin[0] = 1;
ranksin[1] = 0;
ranksin[2] = MPI_PROC_NULL;
ranksin[3] = 2;
- MPI_Group_translate_ranks( ngroup, nelms+1, ranksin, gworld, ranksout );
- for (i=0; i<nelms+1; i++) {
- if (ranksin[i] == MPI_PROC_NULL) {
- if (ranksout[i] != MPI_PROC_NULL) {
- fprintf( stderr, "Input rank for proc_null but output was %d\n",
- ranksout[i] );
- errs++;
- }
- }
- else if (ranksout[i] != ranks[ranksin[i]]) {
- fprintf( stderr, "Expected ranksout[%d] = %d but found %d\n",
- i, ranks[ranksin[i]], ranksout[i] );
- errs++;
- }
+ MPI_Group_translate_ranks(ngroup, nelms + 1, ranksin, gworld, ranksout);
+ for (i = 0; i < nelms + 1; i++) {
+ if (ranksin[i] == MPI_PROC_NULL) {
+ if (ranksout[i] != MPI_PROC_NULL) {
+ fprintf(stderr, "Input rank for proc_null but output was %d\n", ranksout[i]);
+ errs++;
+ }
+ }
+ else if (ranksout[i] != ranks[ranksin[i]]) {
+ fprintf(stderr, "Expected ranksout[%d] = %d but found %d\n",
+ i, ranks[ranksin[i]], ranksout[i]);
+ errs++;
+ }
}
-
- range[0][0] = size -1 ;
+
+ range[0][0] = size - 1;
range[0][1] = 0;
range[0][2] = -1;
- MPI_Group_range_incl( gworld, 1, range, &galt);
- for (i=0; i<nelms+1; i++) ranksout[i] = -1;
- MPI_Group_translate_ranks( ngroup, nelms+1, ranksin, galt, ranksout );
- for (i=0; i<nelms+1; i++) {
- if (ranksin[i] == MPI_PROC_NULL) {
- if (ranksout[i] != MPI_PROC_NULL) {
- fprintf( stderr, "Input rank for proc_null but output was %d\n",
- ranksout[i] );
- errs++;
- }
- }
- else if (ranksout[i] != (size-1)-ranks[ranksin[i]]) {
- fprintf( stderr, "Expected ranksout[%d] = %d but found %d\n",
- i, (size-1)-ranks[ranksin[i]], ranksout[i] );
- errs++;
- }
+ MPI_Group_range_incl(gworld, 1, range, &galt);
+ for (i = 0; i < nelms + 1; i++)
+ ranksout[i] = -1;
+ MPI_Group_translate_ranks(ngroup, nelms + 1, ranksin, galt, ranksout);
+ for (i = 0; i < nelms + 1; i++) {
+ if (ranksin[i] == MPI_PROC_NULL) {
+ if (ranksout[i] != MPI_PROC_NULL) {
+ fprintf(stderr, "Input rank for proc_null but output was %d\n", ranksout[i]);
+ errs++;
+ }
+ }
+ else if (ranksout[i] != (size - 1) - ranks[ranksin[i]]) {
+ fprintf(stderr, "Expected ranksout[%d] = %d but found %d\n",
+ i, (size - 1) - ranks[ranksin[i]], ranksout[i]);
+ errs++;
+ }
}
-
-
+
+
MPI_Group_free(&gworld);
MPI_Group_free(&galt);
MPI_Group_free(&ngroup);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
diff --git a/test/mpi/group/gtranksperf.c b/test/mpi/group/gtranksperf.c
index 98b79d2..4ccf58b 100644
--- a/test/mpi/group/gtranksperf.c
+++ b/test/mpi/group/gtranksperf.c
@@ -8,7 +8,7 @@
#include <stdlib.h>
#include "mpitest.h"
-#include <math.h> /* for fabs(3) */
+#include <math.h> /* for fabs(3) */
/* Measure and compare the relative performance of MPI_Group_translate_ranks
* with small and large group2 sizes but a constant number of ranks. This
@@ -22,56 +22,58 @@
/* number of iterations used for timing */
#define NUM_LOOPS (1000000)
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int *ranks;
int *ranksout;
MPI_Group gworld, grev, gself;
- MPI_Comm comm;
- MPI_Comm commrev;
+ MPI_Comm comm;
+ MPI_Comm commrev;
int rank, size, i;
double start, end, time1, time2;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_size( comm, &size );
- MPI_Comm_rank( comm, &rank );
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
- ranks = malloc(size*sizeof(int));
- ranksout = malloc(size*sizeof(int));
+ ranks = malloc(size * sizeof(int));
+ ranksout = malloc(size * sizeof(int));
if (!ranks || !ranksout) {
fprintf(stderr, "out of memory\n");
MPI_Abort(MPI_COMM_WORLD, 1);
}
/* generate a comm with the rank order reversed */
- MPI_Comm_split(comm, 0, (size-rank-1), &commrev);
+ MPI_Comm_split(comm, 0, (size - rank - 1), &commrev);
MPI_Comm_group(commrev, &grev);
MPI_Comm_group(MPI_COMM_SELF, &gself);
MPI_Comm_group(comm, &gworld);
/* sanity check correctness first */
- for (i=0; i < size; i++) {
+ for (i = 0; i < size; i++) {
ranks[i] = i;
ranksout[i] = -1;
}
MPI_Group_translate_ranks(grev, size, ranks, gworld, ranksout);
- for (i=0; i < size; i++) {
- if (ranksout[i] != (size-i-1)) {
+ for (i = 0; i < size; i++) {
+ if (ranksout[i] != (size - i - 1)) {
if (rank == 0)
- printf("%d: (gworld) expected ranksout[%d]=%d, got %d\n", rank, i, (size-rank-1), ranksout[i]);
+ printf("%d: (gworld) expected ranksout[%d]=%d, got %d\n", rank, i,
+ (size - rank - 1), ranksout[i]);
++errs;
}
}
MPI_Group_translate_ranks(grev, size, ranks, gself, ranksout);
- for (i=0; i < size; i++) {
- int expected = (i == (size-rank-1) ? 0 : MPI_UNDEFINED);
+ for (i = 0; i < size; i++) {
+ int expected = (i == (size - rank - 1) ? 0 : MPI_UNDEFINED);
if (ranksout[i] != expected) {
if (rank == 0)
- printf("%d: (gself) expected ranksout[%d]=%d, got %d\n", rank, i, expected, ranksout[i]);
+ printf("%d: (gself) expected ranksout[%d]=%d, got %d\n", rank, i, expected,
+ ranksout[i]);
++errs;
}
}
@@ -88,10 +90,11 @@ int main( int argc, char *argv[] )
if (rank != 0) {
MTestSleep(10);
}
- else /* rank==0 */ {
- MTestSleep(1); /* try to avoid timing while everyone else is making syscalls */
+ else { /* rank==0 */
- MPI_Group_translate_ranks(grev, size, ranks, gworld, ranksout); /*throwaway iter*/
+ MTestSleep(1); /* try to avoid timing while everyone else is making syscalls */
+
+ MPI_Group_translate_ranks(grev, size, ranks, gworld, ranksout); /*throwaway iter */
start = MPI_Wtime();
for (i = 0; i < NUM_LOOPS; ++i) {
MPI_Group_translate_ranks(grev, size, ranks, gworld, ranksout);
@@ -99,7 +102,7 @@ int main( int argc, char *argv[] )
end = MPI_Wtime();
time1 = end - start;
- MPI_Group_translate_ranks(grev, size, ranks, gself, ranksout); /*throwaway iter*/
+ MPI_Group_translate_ranks(grev, size, ranks, gself, ranksout); /*throwaway iter */
start = MPI_Wtime();
for (i = 0; i < NUM_LOOPS; ++i) {
MPI_Group_translate_ranks(grev, size, ranks, gself, ranksout);
@@ -111,7 +114,7 @@ int main( int argc, char *argv[] )
if (fabs(time1 - time2) > (2.00 * time2)) {
printf("too much difference in MPI_Group_translate_ranks performance:\n");
printf("time1=%f time2=%f\n", time1, time2);
- printf("(fabs(time1-time2)/time2)=%f\n", (fabs(time1-time2)/time2));
+ printf("(fabs(time1-time2)/time2)=%f\n", (fabs(time1 - time2) / time2));
if (time1 < time2) {
printf("also, (time1<time2) is surprising...\n");
}
diff --git a/test/mpi/impls/hydra/dummy.c b/test/mpi/impls/hydra/dummy.c
index 1eae58a..17c310f 100644
--- a/test/mpi/impls/hydra/dummy.c
+++ b/test/mpi/impls/hydra/dummy.c
@@ -5,7 +5,7 @@
*/
/* */
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
return 0;
}
diff --git a/test/mpi/impls/mpich/mpi_t/collparmt.c b/test/mpi/impls/mpich/mpi_t/collparmt.c
index e691291..f816c2e 100644
--- a/test/mpi/impls/mpich/mpi_t/collparmt.c
+++ b/test/mpi/impls/mpich/mpi_t/collparmt.c
@@ -8,135 +8,131 @@
#include "mpi.h"
#include "mpitestconf.h"
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
- int i, ncvar, cnameLen, verbosity, binding, scope;
- int wrank, wsize, provided;
- char cname[256];
- char buf1[400], buf2[400], buf3[500];
+ int i, ncvar, cnameLen, verbosity, binding, scope;
+ int wrank, wsize, provided;
+ char cname[256];
+ char buf1[400], buf2[400], buf3[500];
MPI_Datatype dtype;
- MPI_T_enum enumtype;
+ MPI_T_enum enumtype;
MPI_T_cvar_handle bcastHandle, bcastLongHandle;
- int bcastCount, bcastScope, bcastCvar=-1;
- int bcastLongCount, bcastLongScope, bcastLongCvar=-1;
- int gatherScope, gatherCvar=-1;
- int newval;
- int errs = 0;
+ int bcastCount, bcastScope, bcastCvar = -1;
+ int bcastLongCount, bcastLongScope, bcastLongCvar = -1;
+ int gatherScope, gatherCvar = -1;
+ int newval;
+ int errs = 0;
- MPI_Init( &argc, &argv );
- MPI_T_init_thread( MPI_THREAD_SINGLE, &provided );
+ MPI_Init(&argc, &argv);
+ MPI_T_init_thread(MPI_THREAD_SINGLE, &provided);
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
- MPI_Comm_size( MPI_COMM_WORLD, &wsize );
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
+ MPI_Comm_size(MPI_COMM_WORLD, &wsize);
- MPI_T_cvar_get_num( &ncvar );
+ MPI_T_cvar_get_num(&ncvar);
/* Find collective tuning cvars */
- for (i=0; i<ncvar; i++) {
- cnameLen = sizeof(cname);
- MPI_T_cvar_get_info( i, cname, &cnameLen, &verbosity, &dtype,
- &enumtype, NULL, NULL, &binding, &scope );
- if (strcmp( cname, "MPIR_CVAR_GATHER_VSMALL_MSG_SIZE" ) == 0) {
- gatherCvar = i;
- gatherScope = scope;
- }
- else if (strcmp( cname, "MPIR_CVAR_BCAST_SHORT_MSG_SIZE" ) == 0) {
- bcastCvar = i;
- bcastScope = scope;
- if (binding != MPI_T_BIND_NO_OBJECT &&
- binding != MPI_T_BIND_MPI_COMM) {
- fprintf( stderr, "Unexpected binding for MPIR_CVAR_BCAST_SHORT_MSG\n" );
- errs++;
- }
- }
- else if (strcmp( cname, "MPIR_CVAR_BCAST_LONG_MSG_SIZE" ) == 0) {
- bcastLongCvar = i;
- bcastLongScope = scope;
- if (binding != MPI_T_BIND_NO_OBJECT &&
- binding != MPI_T_BIND_MPI_COMM) {
- fprintf( stderr, "Unexpected binding for MPIR_CVAR_BCAST_LONG_MSG\n" );
- errs++;
- }
- }
- else if (strcmp( cname, "MPIR_CVAR_BCAST_MIN_PROCS" ) == 0) {
- }
+ for (i = 0; i < ncvar; i++) {
+ cnameLen = sizeof(cname);
+ MPI_T_cvar_get_info(i, cname, &cnameLen, &verbosity, &dtype,
+ &enumtype, NULL, NULL, &binding, &scope);
+ if (strcmp(cname, "MPIR_CVAR_GATHER_VSMALL_MSG_SIZE") == 0) {
+ gatherCvar = i;
+ gatherScope = scope;
+ }
+ else if (strcmp(cname, "MPIR_CVAR_BCAST_SHORT_MSG_SIZE") == 0) {
+ bcastCvar = i;
+ bcastScope = scope;
+ if (binding != MPI_T_BIND_NO_OBJECT && binding != MPI_T_BIND_MPI_COMM) {
+ fprintf(stderr, "Unexpected binding for MPIR_CVAR_BCAST_SHORT_MSG\n");
+ errs++;
+ }
+ }
+ else if (strcmp(cname, "MPIR_CVAR_BCAST_LONG_MSG_SIZE") == 0) {
+ bcastLongCvar = i;
+ bcastLongScope = scope;
+ if (binding != MPI_T_BIND_NO_OBJECT && binding != MPI_T_BIND_MPI_COMM) {
+ fprintf(stderr, "Unexpected binding for MPIR_CVAR_BCAST_LONG_MSG\n");
+ errs++;
+ }
+ }
+ else if (strcmp(cname, "MPIR_CVAR_BCAST_MIN_PROCS") == 0) {
+ }
}
/* Change the BCAST cvar. If the parameter has local scope,
- change it only on some processes */
+ * change it only on some processes */
if (bcastCvar < 0 || bcastLongCvar < 0) {
/* Skip because we did not find a corresponding control variable */
}
else {
- MPI_T_cvar_handle_alloc( bcastCvar, NULL, &bcastHandle,
- &bcastCount );
- if (bcastScope == MPI_T_SCOPE_LOCAL) {
- if ((wrank & 0x1)) {
- newval = 100;
- MPI_T_cvar_write( bcastHandle, &newval );
- MPI_T_cvar_read( bcastHandle, &newval );
- if (newval != 100) {
- errs++;
- fprintf( stderr, "cvar write failed for bcast\n" );
- }
- }
- }
- else {
- newval = 100;
- MPI_T_cvar_write( bcastHandle, &newval );
- MPI_T_cvar_read( bcastHandle, &newval );
- if (newval != 100) {
- errs++;
- fprintf( stderr, "cvar write failed for bcast\n" );
- }
- }
+ MPI_T_cvar_handle_alloc(bcastCvar, NULL, &bcastHandle, &bcastCount);
+ if (bcastScope == MPI_T_SCOPE_LOCAL) {
+ if ((wrank & 0x1)) {
+ newval = 100;
+ MPI_T_cvar_write(bcastHandle, &newval);
+ MPI_T_cvar_read(bcastHandle, &newval);
+ if (newval != 100) {
+ errs++;
+ fprintf(stderr, "cvar write failed for bcast\n");
+ }
+ }
+ }
+ else {
+ newval = 100;
+ MPI_T_cvar_write(bcastHandle, &newval);
+ MPI_T_cvar_read(bcastHandle, &newval);
+ if (newval != 100) {
+ errs++;
+ fprintf(stderr, "cvar write failed for bcast\n");
+ }
+ }
- MPI_T_cvar_handle_alloc( bcastLongCvar, NULL, &bcastLongHandle,
- &bcastLongCount );
- if (bcastLongScope == MPI_T_SCOPE_LOCAL) {
- if ((wrank & 0x1)) {
- newval = 200;
- MPI_T_cvar_write( bcastLongHandle, &newval );
- MPI_T_cvar_read( bcastLongHandle, &newval );
- if (newval != 200) {
- errs++;
- fprintf( stderr, "cvar write failed for bcast long\n" );
- }
- }
- }
- else {
- newval = 100;
- MPI_T_cvar_write( bcastLongHandle, &newval );
- MPI_T_cvar_read( bcastLongHandle, &newval );
- if (newval != 100) {
- errs++;
- fprintf( stderr, "cvar write failed for bcast long\n" );
- }
- }
+ MPI_T_cvar_handle_alloc(bcastLongCvar, NULL, &bcastLongHandle, &bcastLongCount);
+ if (bcastLongScope == MPI_T_SCOPE_LOCAL) {
+ if ((wrank & 0x1)) {
+ newval = 200;
+ MPI_T_cvar_write(bcastLongHandle, &newval);
+ MPI_T_cvar_read(bcastLongHandle, &newval);
+ if (newval != 200) {
+ errs++;
+ fprintf(stderr, "cvar write failed for bcast long\n");
+ }
+ }
+ }
+ else {
+ newval = 100;
+ MPI_T_cvar_write(bcastLongHandle, &newval);
+ MPI_T_cvar_read(bcastLongHandle, &newval);
+ if (newval != 100) {
+ errs++;
+ fprintf(stderr, "cvar write failed for bcast long\n");
+ }
+ }
- /* Test 1: Everyone under the new size */
- MPI_Bcast( buf1, 40, MPI_BYTE, 0, MPI_COMM_WORLD );
+ /* Test 1: Everyone under the new size */
+ MPI_Bcast(buf1, 40, MPI_BYTE, 0, MPI_COMM_WORLD);
- /* Test 2: Everyone between the old and new size */
- /* As of 8/16/13, it appears that the small and medium algorithm
- are the same; at least, local changes do not cause deadlocks */
- MPI_Bcast( buf2, 150, MPI_BYTE, 0, MPI_COMM_WORLD );
+ /* Test 2: Everyone between the old and new size */
+ /* As of 8/16/13, it appears that the small and medium algorithm
+ * are the same; at least, local changes do not cause deadlocks */
+ MPI_Bcast(buf2, 150, MPI_BYTE, 0, MPI_COMM_WORLD);
- /* Test 3: Everyone over the new long size */
- /* As of 8/16/13, this causes the program to hang, almost
- certainly because the parameters much be changed collectively
- but incorrectly indicate that they have local scope */
- MPI_Bcast( buf3, 250, MPI_BYTE, 0, MPI_COMM_WORLD );
+ /* Test 3: Everyone over the new long size */
+ /* As of 8/16/13, this causes the program to hang, almost
+ * certainly because the parameters much be changed collectively
+ * but incorrectly indicate that they have local scope */
+ MPI_Bcast(buf3, 250, MPI_BYTE, 0, MPI_COMM_WORLD);
- MPI_T_cvar_handle_free( &bcastHandle );
- MPI_T_cvar_handle_free( &bcastLongHandle );
+ MPI_T_cvar_handle_free(&bcastHandle);
+ MPI_T_cvar_handle_free(&bcastLongHandle);
}
/* Change the GATHER cvar. If the parameter has local scope,
- change it only on some processes. Use a subcommunicator if the
- size of comm_world is too large */
+ * change it only on some processes. Use a subcommunicator if the
+ * size of comm_world is too large */
/* For full coverage, should address all parameters for collective
- algorithm selection */
+ * algorithm selection */
if (wrank == 0) {
if (errs) {
diff --git a/test/mpi/include/dtypes.h b/test/mpi/include/dtypes.h
index 3a3c888..91cf762 100644
--- a/test/mpi/include/dtypes.h
+++ b/test/mpi/include/dtypes.h
@@ -1,13 +1,10 @@
#ifndef MPITEST_DTYPES
#define MPITEST_DTYPES
-void MTestDatatype2Generate ( MPI_Datatype *, void **, void **, int *, int *,
- int * );
-void MTestDatatype2Allocate ( MPI_Datatype **, void ***, void ***,
- int **, int **, int * );
-int MTestDatatype2Check ( void *, void *, int );
-int MTestDatatype2CheckAndPrint ( void *, void *, int, char *, int );
-void MTestDatatype2Free ( MPI_Datatype *, void **, void **,
- int *, int *, int );
-void MTestDatatype2BasicOnly( void );
+void MTestDatatype2Generate(MPI_Datatype *, void **, void **, int *, int *, int *);
+void MTestDatatype2Allocate(MPI_Datatype **, void ***, void ***, int **, int **, int *);
+int MTestDatatype2Check(void *, void *, int);
+int MTestDatatype2CheckAndPrint(void *, void *, int, char *, int);
+void MTestDatatype2Free(MPI_Datatype *, void **, void **, int *, int *, int);
+void MTestDatatype2BasicOnly(void);
#endif
diff --git a/test/mpi/include/mpitest.h b/test/mpi/include/mpitest.h
index a773f28..984c8c0 100644
--- a/test/mpi/include/mpitest.h
+++ b/test/mpi/include/mpitest.h
@@ -10,21 +10,21 @@
#include "mpitestconf.h"
/*
- * Init and finalize test
+ * Init and finalize test
*/
-void MTest_Init( int *, char *** );
-void MTest_Init_thread( int *, char ***, int, int * );
-void MTest_Finalize( int );
-void MTestPrintError( int );
-void MTestPrintErrorMsg( const char [], int );
-void MTestPrintfMsg( int, const char [], ... );
-void MTestError( const char [] );
-int MTestReturnValue( int );
+void MTest_Init(int *, char ***);
+void MTest_Init_thread(int *, char ***, int, int *);
+void MTest_Finalize(int);
+void MTestPrintError(int);
+void MTestPrintErrorMsg(const char[], int);
+void MTestPrintfMsg(int, const char[], ...);
+void MTestError(const char[]);
+int MTestReturnValue(int);
/*
* Utilities
*/
-void MTestSleep( int );
+void MTestSleep(int);
void MTestGetDbgInfo(int *dbgflag, int *verbose);
/*
@@ -32,19 +32,19 @@ void MTestGetDbgInfo(int *dbgflag, int *verbose);
* buf is set to null when an MTestDatatype is created; the
* InitBuf routine will allocate (if necessary) and initialize
* the data. InitBuf may be called multiple times (this is particularly
- * important for recv bufs), in which case the buffer will only
+ * important for recv bufs), in which case the buffer will only
* be allocated if it has not already been created.
*/
typedef struct _MTestDatatype {
MPI_Datatype datatype;
- void *buf; /* buffer to use in communication */
- MPI_Aint count; /* count to use for this datatype */
- int isBasic; /* true if the type is predefined */
- int printErrors; /* true if errors should be printed
- (used by the CheckBuf routines) */
+ void *buf; /* buffer to use in communication */
+ MPI_Aint count; /* count to use for this datatype */
+ int isBasic; /* true if the type is predefined */
+ int printErrors; /* true if errors should be printed
+ * (used by the CheckBuf routines) */
/* The following is optional data that is used by some of
- the derived datatypes */
- int nblock, *index;
+ * the derived datatypes */
+ int nblock, *index;
/* stride, and blksize are in bytes */
MPI_Aint stride, blksize, *displ_in_bytes;
int *displs, basesize;
@@ -52,9 +52,9 @@ typedef struct _MTestDatatype {
/* used in subarray */
int arr_sizes[2], arr_subsizes[2], arr_starts[2], order;
- void *(*InitBuf)( struct _MTestDatatype * );
- void *(*FreeBuf)( struct _MTestDatatype * );
- int (*CheckBuf)( struct _MTestDatatype * );
+ void *(*InitBuf) (struct _MTestDatatype *);
+ void *(*FreeBuf) (struct _MTestDatatype *);
+ int (*CheckBuf) (struct _MTestDatatype *);
} MTestDatatype;
/* The max value of count must be very large to ensure that we
@@ -75,30 +75,30 @@ void MTestInitMinDatatypes(void);
* It generate tests for all basic datatypes. */
void MTestInitBasicDatatypes(void);
-int MTestCheckRecv( MPI_Status *, MTestDatatype * );
-int MTestGetDatatypes( MTestDatatype *, MTestDatatype *, MPI_Aint );
-void MTestResetDatatypes( void );
-void MTestFreeDatatype( MTestDatatype * );
-const char *MTestGetDatatypeName( MTestDatatype * );
-int MTestGetDatatypeIndex( void );
-
-int MTestGetIntracomm( MPI_Comm *, int );
-int MTestGetIntracommGeneral( MPI_Comm *, int, int );
-int MTestGetIntercomm( MPI_Comm *, int *, int );
-int MTestGetComm( MPI_Comm *, int );
+int MTestCheckRecv(MPI_Status *, MTestDatatype *);
+int MTestGetDatatypes(MTestDatatype *, MTestDatatype *, MPI_Aint);
+void MTestResetDatatypes(void);
+void MTestFreeDatatype(MTestDatatype *);
+const char *MTestGetDatatypeName(MTestDatatype *);
+int MTestGetDatatypeIndex(void);
+
+int MTestGetIntracomm(MPI_Comm *, int);
+int MTestGetIntracommGeneral(MPI_Comm *, int, int);
+int MTestGetIntercomm(MPI_Comm *, int *, int);
+int MTestGetComm(MPI_Comm *, int);
int MTestTestIntercomm(MPI_Comm intercomm);
int MTestTestIntracomm(MPI_Comm intracomm);
int MTestTestComm(MPI_Comm comm);
-const char *MTestGetIntracommName( void );
-const char *MTestGetIntercommName( void );
-void MTestFreeComm( MPI_Comm * );
+const char *MTestGetIntracommName(void);
+const char *MTestGetIntercommName(void);
+void MTestFreeComm(MPI_Comm *);
-int MTestSpawnPossible( int * );
+int MTestSpawnPossible(int *);
#ifdef HAVE_MPI_WIN_CREATE
-int MTestGetWin( MPI_Win *, int );
-const char *MTestGetWinName( void );
-void MTestFreeWin( MPI_Win * );
+int MTestGetWin(MPI_Win *, int);
+const char *MTestGetWinName(void);
+void MTestFreeWin(MPI_Win *);
#endif
/* These macros permit overrides via:
diff --git a/test/mpi/include/mpitestcxx.h b/test/mpi/include/mpitestcxx.h
index 32d3131..6c1e878 100644
--- a/test/mpi/include/mpitestcxx.h
+++ b/test/mpi/include/mpitestcxx.h
@@ -11,57 +11,57 @@
#ifndef MTEST_INCLUDED
#define MTEST_INCLUDED
/*
- * Init and finalize test
+ * Init and finalize test
*/
-void MTest_Init( void );
-void MTest_Finalize( int );
-void MTestPrintError( int );
-void MTestPrintErrorMsg( const char [], int );
-void MTestPrintfMsg( int, const char [], ... );
-void MTestError( const char [] );
+void MTest_Init(void);
+void MTest_Finalize(int);
+void MTestPrintError(int);
+void MTestPrintErrorMsg(const char[], int);
+void MTestPrintfMsg(int, const char[], ...);
+void MTestError(const char[]);
/*
* This structure contains the information used to test datatypes
*/
typedef struct _MTestDatatype {
MPI::Datatype datatype;
- void *buf; /* buffer to use in communication */
- int count; /* count to use for this datatype */
- int isBasic; /* true if the type is predefined */
- int printErrors; /* true if errors should be printed
- (used by the CheckBuf routines) */
+ void *buf; /* buffer to use in communication */
+ int count; /* count to use for this datatype */
+ int isBasic; /* true if the type is predefined */
+ int printErrors; /* true if errors should be printed
+ * (used by the CheckBuf routines) */
/* The following is optional data that is used by some of
- the derived datatypes */
- int stride, nelm, blksize, *index;
+ * the derived datatypes */
+ int stride, nelm, blksize, *index;
/* stride, nelm, and blksize are in bytes */
int *displs, basesize;
/* displacements are in multiples of base type; basesize is the
- size of that type*/
- void *(*InitBuf)( struct _MTestDatatype * );
- void *(*FreeBuf)( struct _MTestDatatype * );
- int (*CheckBuf)( struct _MTestDatatype * );
+ * size of that type */
+ void *(*InitBuf) (struct _MTestDatatype *);
+ void *(*FreeBuf) (struct _MTestDatatype *);
+ int (*CheckBuf) (struct _MTestDatatype *);
} MTestDatatype;
-int MTestCheckRecv( MPI::Status &, MTestDatatype * );
-int MTestGetDatatypes( MTestDatatype *, MTestDatatype *, int );
-void MTestResetDatatypes( void );
-void MTestFreeDatatype( MTestDatatype * );
-const char *MTestGetDatatypeName( MTestDatatype * );
+int MTestCheckRecv(MPI::Status &, MTestDatatype *);
+int MTestGetDatatypes(MTestDatatype *, MTestDatatype *, int);
+void MTestResetDatatypes(void);
+void MTestFreeDatatype(MTestDatatype *);
+const char *MTestGetDatatypeName(MTestDatatype *);
-int MTestGetIntracomm( MPI::Intracomm &, int );
-int MTestGetIntracommGeneral( MPI::Intracomm &, int, bool );
-int MTestGetIntercomm( MPI::Intercomm &, int &, int );
-int MTestGetComm( MPI::Comm **, int );
-const char *MTestGetIntracommName( void );
-const char *MTestGetIntercommName( void );
-void MTestFreeComm( MPI::Comm &comm );
+int MTestGetIntracomm(MPI::Intracomm &, int);
+int MTestGetIntracommGeneral(MPI::Intracomm &, int, bool);
+int MTestGetIntercomm(MPI::Intercomm &, int &, int);
+int MTestGetComm(MPI::Comm **, int);
+const char *MTestGetIntracommName(void);
+const char *MTestGetIntercommName(void);
+void MTestFreeComm(MPI::Comm & comm);
-int MTestSpawnPossible( int * );
+int MTestSpawnPossible(int *);
#ifdef HAVE_MPI_WIN_CREATE
-int MTestGetWin( MPI::Win &, bool );
-const char *MTestGetWinName( void );
-void MTestFreeWin( MPI::Win & );
+int MTestGetWin(MPI::Win &, bool);
+const char *MTestGetWinName(void);
+void MTestFreeWin(MPI::Win &);
#endif
#endif
diff --git a/test/mpi/include/mpithreadtest.h b/test/mpi/include/mpithreadtest.h
index 5594b57..669f933 100644
--- a/test/mpi/include/mpithreadtest.h
+++ b/test/mpi/include/mpithreadtest.h
@@ -9,10 +9,10 @@
#include "mpitestconf.h"
-/*
- Define routines to start a thread for different thread packages.
+/*
+ Define routines to start a thread for different thread packages.
The routine that is started is expected to return data when it
- exits; the type of this data is
+ exits; the type of this data is
MTEST_THREAD_RETURN_TYPE
*/
@@ -35,12 +35,12 @@
/* A dummy retval that is ignored */
#define MTEST_THREAD_RETVAL_IGN 0
-int MTest_Start_thread(MTEST_THREAD_RETURN_TYPE (*fn)(void *p),void *arg);
-int MTest_Join_threads( void );
-int MTest_thread_lock_create( MTEST_THREAD_LOCK_TYPE *);
-int MTest_thread_lock( MTEST_THREAD_LOCK_TYPE *);
-int MTest_thread_unlock( MTEST_THREAD_LOCK_TYPE *);
-int MTest_thread_lock_free( MTEST_THREAD_LOCK_TYPE *);
+int MTest_Start_thread(MTEST_THREAD_RETURN_TYPE(*fn) (void *p), void *arg);
+int MTest_Join_threads(void);
+int MTest_thread_lock_create(MTEST_THREAD_LOCK_TYPE *);
+int MTest_thread_lock(MTEST_THREAD_LOCK_TYPE *);
+int MTest_thread_unlock(MTEST_THREAD_LOCK_TYPE *);
+int MTest_thread_lock_free(MTEST_THREAD_LOCK_TYPE *);
int MTest_thread_barrier_init(void);
int MTest_thread_barrier(int);
int MTest_thread_barrier_free(void);
diff --git a/test/mpi/info/infodel.c b/test/mpi/info/infodel.c
index a62f362..b281847 100644
--- a/test/mpi/info/infodel.c
+++ b/test/mpi/info/infodel.c
@@ -14,70 +14,70 @@
#endif
#define NKEYS 3
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
MPI_Info info;
- char *keys[NKEYS] = { (char*)"file", (char*)"soft", (char*)"host" };
- char *values[NKEYS] = { (char*)"runfile.txt", (char*)"2:1000:4,3:1000:7",
- (char*)"myhost.myorg.org" };
+ char *keys[NKEYS] = { (char *) "file", (char *) "soft", (char *) "host" };
+ char *values[NKEYS] = { (char *) "runfile.txt", (char *) "2:1000:4,3:1000:7",
+ (char *) "myhost.myorg.org"
+ };
char value[MPI_MAX_INFO_VAL];
int i, flag, nkeys;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Info_create( &info );
+ MPI_Info_create(&info);
/* Use only named keys incase the info implementation only supports
- the predefined keys (e.g., IBM) */
- for (i=0; i<NKEYS; i++) {
- MPI_Info_set( info, keys[i], values[i] );
+ * the predefined keys (e.g., IBM) */
+ for (i = 0; i < NKEYS; i++) {
+ MPI_Info_set(info, keys[i], values[i]);
}
/* Check that all values are present */
- for (i=0; i<NKEYS; i++) {
- MPI_Info_get( info, keys[i], MPI_MAX_INFO_VAL, value, &flag );
- if (!flag) {
- errs++;
- printf( "No value for key %s\n", keys[i] );
- }
- if (strcmp( value, values[i] )) {
- errs++;
- printf( "Incorrect value for key %s, got %s expected %s\n",
- keys[i], value, values[i] );
- }
+ for (i = 0; i < NKEYS; i++) {
+ MPI_Info_get(info, keys[i], MPI_MAX_INFO_VAL, value, &flag);
+ if (!flag) {
+ errs++;
+ printf("No value for key %s\n", keys[i]);
+ }
+ if (strcmp(value, values[i])) {
+ errs++;
+ printf("Incorrect value for key %s, got %s expected %s\n", keys[i], value, values[i]);
+ }
}
/* Now, change one value and remove another, then check again */
- MPI_Info_delete( info, keys[NKEYS-1] );
- MPI_Info_get_nkeys( info, &nkeys );
+ MPI_Info_delete(info, keys[NKEYS - 1]);
+ MPI_Info_get_nkeys(info, &nkeys);
if (nkeys != NKEYS - 1) {
- errs++;
- printf( "Deleting a key did not change the number of keys\n" );
+ errs++;
+ printf("Deleting a key did not change the number of keys\n");
}
- values[0] = (char*)"backfile.txt";
- MPI_Info_set( info, keys[0], values[0] );
- for (i=0; i<NKEYS-1; i++) {
- MPI_Info_get( info, keys[i], MPI_MAX_INFO_VAL, value, &flag );
- if (!flag) {
- errs++;
- printf( "(after reset) No value for key %s\n", keys[i] );
- }
- if (strcmp( value, values[i] )) {
- errs++;
- printf( "(after reset) Incorrect value for key %s, got %s expected %s\n",
- keys[i], value, values[i] );
- }
+ values[0] = (char *) "backfile.txt";
+ MPI_Info_set(info, keys[0], values[0]);
+ for (i = 0; i < NKEYS - 1; i++) {
+ MPI_Info_get(info, keys[i], MPI_MAX_INFO_VAL, value, &flag);
+ if (!flag) {
+ errs++;
+ printf("(after reset) No value for key %s\n", keys[i]);
+ }
+ if (strcmp(value, values[i])) {
+ errs++;
+ printf("(after reset) Incorrect value for key %s, got %s expected %s\n",
+ keys[i], value, values[i]);
+ }
}
- MPI_Info_free( &info );
+ MPI_Info_free(&info);
if (info != MPI_INFO_NULL) {
- errs++;
- printf( "MPI_Info_free should set info to MPI_INFO_NULL\n" );
+ errs++;
+ printf("MPI_Info_free should set info to MPI_INFO_NULL\n");
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/info/infodup.c b/test/mpi/info/infodup.c
index b89d020..4c79749 100644
--- a/test/mpi/info/infodup.c
+++ b/test/mpi/info/infodup.c
@@ -13,7 +13,7 @@
#include <string.h>
#endif
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
MPI_Info info1, infodup;
@@ -21,62 +21,61 @@ int main( int argc, char *argv[] )
char key[MPI_MAX_INFO_KEY], keydup[MPI_MAX_INFO_KEY];
char value[MPI_MAX_INFO_VAL], valdup[MPI_MAX_INFO_VAL];
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Info_create( &info1 );
+ MPI_Info_create(&info1);
/* Use only named keys incase the info implementation only supports
- the predefined keys (e.g., IBM) */
- MPI_Info_set( info1, (char*)"host", (char*)"myhost.myorg.org" );
- MPI_Info_set( info1, (char*)"file", (char*)"runfile.txt" );
- MPI_Info_set( info1, (char*)"soft", (char*)"2:1000:4,3:1000:7" );
+ * the predefined keys (e.g., IBM) */
+ MPI_Info_set(info1, (char *) "host", (char *) "myhost.myorg.org");
+ MPI_Info_set(info1, (char *) "file", (char *) "runfile.txt");
+ MPI_Info_set(info1, (char *) "soft", (char *) "2:1000:4,3:1000:7");
- MPI_Info_dup( info1, &infodup );
+ MPI_Info_dup(info1, &infodup);
- MPI_Info_get_nkeys( infodup, &nkeysdup );
- MPI_Info_get_nkeys( info1, &nkeys );
+ MPI_Info_get_nkeys(infodup, &nkeysdup);
+ MPI_Info_get_nkeys(info1, &nkeys);
if (nkeys != nkeysdup) {
- errs++;
- printf( "Dup'ed info has a different number of keys; is %d should be %d\n",
- nkeysdup, nkeys );
+ errs++;
+ printf("Dup'ed info has a different number of keys; is %d should be %d\n", nkeysdup, nkeys);
}
vallen = MPI_MAX_INFO_VAL;
- for (i=0; i<nkeys; i++) {
- /* MPI requires that the keys are in the same order after the dup */
- MPI_Info_get_nthkey( info1, i, key );
- MPI_Info_get_nthkey( infodup, i, keydup );
- if (strcmp(key, keydup)) {
- errs++;
- printf( "keys do not match: %s should be %s\n", keydup, key );
- }
+ for (i = 0; i < nkeys; i++) {
+ /* MPI requires that the keys are in the same order after the dup */
+ MPI_Info_get_nthkey(info1, i, key);
+ MPI_Info_get_nthkey(infodup, i, keydup);
+ if (strcmp(key, keydup)) {
+ errs++;
+ printf("keys do not match: %s should be %s\n", keydup, key);
+ }
- vallen = MPI_MAX_INFO_VAL;
- MPI_Info_get( info1, key, vallen, value, &flag );
- MPI_Info_get( infodup, keydup, vallen, valdup, &flagdup );
- if (!flag || !flagdup) {
- errs++;
- printf( "Info get failed for key %s\n", key );
- }
- else if (strcmp( value, valdup )) {
- errs++;
- printf( "Info values for key %s not the same after dup\n", key );
- }
+ vallen = MPI_MAX_INFO_VAL;
+ MPI_Info_get(info1, key, vallen, value, &flag);
+ MPI_Info_get(infodup, keydup, vallen, valdup, &flagdup);
+ if (!flag || !flagdup) {
+ errs++;
+ printf("Info get failed for key %s\n", key);
+ }
+ else if (strcmp(value, valdup)) {
+ errs++;
+ printf("Info values for key %s not the same after dup\n", key);
+ }
}
- /* Change info and check that infodup does NOT have the new value
- (ensure that lazy dups are still duped) */
- MPI_Info_set( info1, (char*)"path", (char*)"/a:/b:/c/d" );
+ /* Change info and check that infodup does NOT have the new value
+ * (ensure that lazy dups are still duped) */
+ MPI_Info_set(info1, (char *) "path", (char *) "/a:/b:/c/d");
- MPI_Info_get( infodup, (char*)"path", vallen, value, &flag );
+ MPI_Info_get(infodup, (char *) "path", vallen, value, &flag);
if (flag) {
- errs++;
- printf( "inserting path into info changed infodup\n" );
+ errs++;
+ printf("inserting path into info changed infodup\n");
}
-
- MPI_Info_free( &info1 );
- MPI_Info_free( &infodup );
-
- MTest_Finalize( errs );
+
+ MPI_Info_free(&info1);
+ MPI_Info_free(&infodup);
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/info/infoenv.c b/test/mpi/info/infoenv.c
index ff895c8..5b0fa1c 100644
--- a/test/mpi/info/infoenv.c
+++ b/test/mpi/info/infoenv.c
@@ -13,7 +13,8 @@ int main(int argc, char *argv[])
{
char value[MPI_MAX_INFO_VAL];
char *keys[] = { "command", "argv", "maxprocs", "soft", "host", "arch", "wdir", "file",
- "thread_level", 0 };
+ "thread_level", 0
+ };
int flag, i;
MPI_Init(NULL, NULL);
diff --git a/test/mpi/info/infoget.c b/test/mpi/info/infoget.c
index cdc0f1d..09487fe 100644
--- a/test/mpi/info/infoget.c
+++ b/test/mpi/info/infoget.c
@@ -15,16 +15,16 @@ int main(int argc, char *argv[])
{
MPI_Info info;
const char *key = "key", *val = "val";
- char buff[3 + 1]; /* strlen("val") + 1 */
- int flag, errs=0;
+ char buff[3 + 1]; /* strlen("val") + 1 */
+ int flag, errs = 0;
MTest_Init(&argc, &argv);
MPI_Info_create(&info);
MPI_Info_set(info, key, val);
- MPI_Info_get(info, key, sizeof(buff)-1, buff, &flag);
+ MPI_Info_get(info, key, sizeof(buff) - 1, buff, &flag);
if (flag) {
- if (strncmp(buff, val, sizeof(buff)-1) != 0) {
+ if (strncmp(buff, val, sizeof(buff) - 1) != 0) {
errs++;
printf("returned value is %s, should be %s\n", buff, val);
}
diff --git a/test/mpi/info/infomany.c b/test/mpi/info/infomany.c
index c9f8213..7f71f57 100644
--- a/test/mpi/info/infomany.c
+++ b/test/mpi/info/infomany.c
@@ -20,86 +20,86 @@
#define info_list 16
/* #define DBG */
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Info infos[MAX_INFOS];
char key[64], value[64];
- int errs = 0;
- int i, j;
+ int errs = 0;
+ int i, j;
- MTest_Init( &argc, &argv );
-
- for (i=0; i<MAX_INFOS; i++) {
- MPI_Info_create( &infos[i] );
+ MTest_Init(&argc, &argv);
+
+ for (i = 0; i < MAX_INFOS; i++) {
+ MPI_Info_create(&infos[i]);
#ifdef DBG
- printf( "Info handle is %x\n", infos[i] );
+ printf("Info handle is %x\n", infos[i]);
#endif
- for (j=0; j<info_list; j++) {
- sprintf( key, "key%d-%d", i, j );
- sprintf( value, "value%d-%d", i, j );
+ for (j = 0; j < info_list; j++) {
+ sprintf(key, "key%d-%d", i, j);
+ sprintf(value, "value%d-%d", i, j);
#ifdef DBG
- printf( "Creating key/value %s=%s\n", key, value );
+ printf("Creating key/value %s=%s\n", key, value);
#endif
- MPI_Info_set( infos[i], key, value );
- }
+ MPI_Info_set(infos[i], key, value);
+ }
#ifdef DBG
- { int nkeys;
- MPI_Info_get_nkeys( infos[0], &nkeys );
- if (nkeys != info_list) {
- printf( "infos[0] changed at %d info\n", i );}
- }
+ {
+ int nkeys;
+ MPI_Info_get_nkeys(infos[0], &nkeys);
+ if (nkeys != info_list) {
+ printf("infos[0] changed at %d info\n", i);
+ }
+ }
#endif
}
-
- for (i=0; i<MAX_INFOS; i++) {
- int nkeys;
- /*printf( "info = %x\n", infos[i] );
- print_handle( infos[i] ); printf( "\n" );*/
- MPI_Info_get_nkeys( infos[i], &nkeys );
- if (nkeys != info_list) {
- errs++;
- if (errs < MAX_ERRORS) {
- printf( "Wrong number of keys for info %d; got %d, should be %d\n",
- i, nkeys, info_list );
- }
- }
- for (j=0; j<nkeys; j++) {
- char keystr[64];
- char valstr[64];
- int flag;
- MPI_Info_get_nthkey( infos[i], j, key );
- sprintf( keystr, "key%d-%d", i, j );
- if (strcmp( keystr, key ) != 0) {
- errs++;
- if (errs < MAX_ERRORS) {
- printf( "Wrong key for info %d; got %s expected %s\n",
- i, key, keystr );
- }
- continue;
- }
- MPI_Info_get( infos[i], key, sizeof(value), value, &flag );
- if (!flag) {
- errs++;
- if (errs < MAX_ERRORS) {
- printf( "Get failed to return value for info %d\n", i );
- }
- continue;
- }
- sprintf( valstr, "value%d-%d", i, j );
- if (strcmp( valstr, value ) != 0) {
- errs++;
- if (errs < MAX_ERRORS) {
- printf( "Wrong value for info %d; got %s expected %s\n",
- i, value, valstr );
- }
- }
- }
+
+ for (i = 0; i < MAX_INFOS; i++) {
+ int nkeys;
+ /*printf("info = %x\n", infos[i]);
+ * print_handle(infos[i]); printf("\n"); */
+ MPI_Info_get_nkeys(infos[i], &nkeys);
+ if (nkeys != info_list) {
+ errs++;
+ if (errs < MAX_ERRORS) {
+ printf("Wrong number of keys for info %d; got %d, should be %d\n",
+ i, nkeys, info_list);
+ }
+ }
+ for (j = 0; j < nkeys; j++) {
+ char keystr[64];
+ char valstr[64];
+ int flag;
+ MPI_Info_get_nthkey(infos[i], j, key);
+ sprintf(keystr, "key%d-%d", i, j);
+ if (strcmp(keystr, key) != 0) {
+ errs++;
+ if (errs < MAX_ERRORS) {
+ printf("Wrong key for info %d; got %s expected %s\n", i, key, keystr);
+ }
+ continue;
+ }
+ MPI_Info_get(infos[i], key, sizeof(value), value, &flag);
+ if (!flag) {
+ errs++;
+ if (errs < MAX_ERRORS) {
+ printf("Get failed to return value for info %d\n", i);
+ }
+ continue;
+ }
+ sprintf(valstr, "value%d-%d", i, j);
+ if (strcmp(valstr, value) != 0) {
+ errs++;
+ if (errs < MAX_ERRORS) {
+ printf("Wrong value for info %d; got %s expected %s\n", i, value, valstr);
+ }
+ }
+ }
}
- for (i=0; i<MAX_INFOS; i++) {
- MPI_Info_free( &infos[i] );
+ for (i = 0; i < MAX_INFOS; i++) {
+ MPI_Info_free(&infos[i]);
}
-
- MTest_Finalize( errs );
- MPI_Finalize( );
+
+ MTest_Finalize(errs);
+ MPI_Finalize();
return 0;
}
diff --git a/test/mpi/info/infomany2.c b/test/mpi/info/infomany2.c
index f400648..68f4271 100644
--- a/test/mpi/info/infomany2.c
+++ b/test/mpi/info/infomany2.c
@@ -27,107 +27,107 @@
#define DBGPRINTF(a)
#endif
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Info infos[MAX_INFOS];
char key[64], value[64];
- int errs = 0;
- int i, j;
+ int errs = 0;
+ int i, j;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
/* We create max_info items, then delete the middle third of them,
- then recreate them, then check them, then
- delete them all. This checks that the MPICH algorithm for
- handling large numbers of items works correctly; other MPI
- implementations should also be able to handle this */
+ * then recreate them, then check them, then
+ * delete them all. This checks that the MPICH algorithm for
+ * handling large numbers of items works correctly; other MPI
+ * implementations should also be able to handle this */
/* Create them all */
- for (i=0; i<MAX_INFOS; i++) {
- MPI_Info_create( &infos[i] );
- DBGPRINTF( ( "Info handle is %x\n", infos[i] ) );
- for (j=0; j<info_list; j++) {
- sprintf( key, "key%d-%d", i, j );
- sprintf( value, "value%d-%d", i, j );
- DBGPRINTF( ( "Creating key/value %s=%s\n", key, value ));
- MPI_Info_set( infos[i], key, value );
- }
+ for (i = 0; i < MAX_INFOS; i++) {
+ MPI_Info_create(&infos[i]);
+ DBGPRINTF(("Info handle is %x\n", infos[i]));
+ for (j = 0; j < info_list; j++) {
+ sprintf(key, "key%d-%d", i, j);
+ sprintf(value, "value%d-%d", i, j);
+ DBGPRINTF(("Creating key/value %s=%s\n", key, value));
+ MPI_Info_set(infos[i], key, value);
+ }
#ifdef DBG
- { int nkeys;
- MPI_Info_get_nkeys( infos[0], &nkeys );
- if (nkeys != info_list) {
- printf( "infos[0] changed at %d info\n", i );}
- }
+ {
+ int nkeys;
+ MPI_Info_get_nkeys(infos[0], &nkeys);
+ if (nkeys != info_list) {
+ printf("infos[0] changed at %d info\n", i);
+ }
+ }
#endif
}
/* Delete the middle set */
- for (i=MAX_INFOS/3; i<(2*MAX_INFOS/3); i++) {
- MPI_Info_free( &infos[i] );
+ for (i = MAX_INFOS / 3; i < (2 * MAX_INFOS / 3); i++) {
+ MPI_Info_free(&infos[i]);
}
-
+
/* Recreate the middle set */
- for (i=MAX_INFOS/3; i<(2*MAX_INFOS/3); i++) {
- MPI_Info_create( &infos[i] );
- DBGPRINTF( ( "Info handle is %x\n", infos[i] ) );
- for (j=0; j<info_list; j++) {
- sprintf( key, "key%d-%d", i, j );
- sprintf( value, "value%d-%d", i, j );
- DBGPRINTF( ( "Creating key/value %s=%s\n", key, value ));
- MPI_Info_set( infos[i], key, value );
- }
+ for (i = MAX_INFOS / 3; i < (2 * MAX_INFOS / 3); i++) {
+ MPI_Info_create(&infos[i]);
+ DBGPRINTF(("Info handle is %x\n", infos[i]));
+ for (j = 0; j < info_list; j++) {
+ sprintf(key, "key%d-%d", i, j);
+ sprintf(value, "value%d-%d", i, j);
+ DBGPRINTF(("Creating key/value %s=%s\n", key, value));
+ MPI_Info_set(infos[i], key, value);
+ }
}
/* Now, check that they are still valid */
- for (i=0; i<MAX_INFOS; i++) {
- int nkeys;
- /*printf( "info = %x\n", infos[i] );
- print_handle( infos[i] ); printf( "\n" );*/
- MPI_Info_get_nkeys( infos[i], &nkeys );
- if (nkeys != info_list) {
- errs++;
- if (errs < MAX_ERRORS) {
- printf( "Wrong number of keys for info %d; got %d, should be %d\n",
- i, nkeys, info_list );
- }
- }
- for (j=0; j<nkeys; j++) {
- char keystr[64];
- char valstr[64];
- int flag;
- MPI_Info_get_nthkey( infos[i], j, key );
- sprintf( keystr, "key%d-%d", i, j );
- if (strcmp( keystr, key ) != 0) {
- errs++;
- if (errs < MAX_ERRORS) {
- printf( "Wrong key for info %d; got %s expected %s\n",
- i, key, keystr );
- }
- continue;
- }
- MPI_Info_get( infos[i], key, 64, value, &flag );
- if (!flag) {
- errs++;
- if (errs < MAX_ERRORS) {
- printf( "Get failed to return value for info %d\n", i );
- }
- continue;
- }
- sprintf( valstr, "value%d-%d", i, j );
- if (strcmp( valstr, value ) != 0) {
- errs++;
- if (errs < MAX_ERRORS) {
- printf( "Wrong value for info %d; got %s expected %s\n",
- i, value, valstr );
- }
- }
- }
+ for (i = 0; i < MAX_INFOS; i++) {
+ int nkeys;
+ /*printf("info = %x\n", infos[i]);
+ * print_handle(infos[i]); printf("\n"); */
+ MPI_Info_get_nkeys(infos[i], &nkeys);
+ if (nkeys != info_list) {
+ errs++;
+ if (errs < MAX_ERRORS) {
+ printf("Wrong number of keys for info %d; got %d, should be %d\n",
+ i, nkeys, info_list);
+ }
+ }
+ for (j = 0; j < nkeys; j++) {
+ char keystr[64];
+ char valstr[64];
+ int flag;
+ MPI_Info_get_nthkey(infos[i], j, key);
+ sprintf(keystr, "key%d-%d", i, j);
+ if (strcmp(keystr, key) != 0) {
+ errs++;
+ if (errs < MAX_ERRORS) {
+ printf("Wrong key for info %d; got %s expected %s\n", i, key, keystr);
+ }
+ continue;
+ }
+ MPI_Info_get(infos[i], key, 64, value, &flag);
+ if (!flag) {
+ errs++;
+ if (errs < MAX_ERRORS) {
+ printf("Get failed to return value for info %d\n", i);
+ }
+ continue;
+ }
+ sprintf(valstr, "value%d-%d", i, j);
+ if (strcmp(valstr, value) != 0) {
+ errs++;
+ if (errs < MAX_ERRORS) {
+ printf("Wrong value for info %d; got %s expected %s\n", i, value, valstr);
+ }
+ }
+ }
}
- for (i=0; i<MAX_INFOS; i++) {
- MPI_Info_free( &infos[i] );
+ for (i = 0; i < MAX_INFOS; i++) {
+ MPI_Info_free(&infos[i]);
}
-
- MTest_Finalize( errs );
- MPI_Finalize( );
+
+ MTest_Finalize(errs);
+ MPI_Finalize();
return 0;
}
diff --git a/test/mpi/info/infoorder.c b/test/mpi/info/infoorder.c
index aa1db8c..e1189c4 100644
--- a/test/mpi/info/infoorder.c
+++ b/test/mpi/info/infoorder.c
@@ -14,153 +14,154 @@
#endif
#define NKEYS 3
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
MPI_Info info;
- char *keys1[NKEYS] = { (char*)"file", (char*)"soft", (char*)"host" };
- char *values1[NKEYS] = { (char*)"runfile.txt", (char*)"2:1000:4,3:1000:7",
- (char*)"myhost.myorg.org" };
+ char *keys1[NKEYS] = { (char *) "file", (char *) "soft", (char *) "host" };
+ char *values1[NKEYS] = { (char *) "runfile.txt", (char *) "2:1000:4,3:1000:7",
+ (char *) "myhost.myorg.org"
+ };
char value[MPI_MAX_INFO_VAL];
int i, flag;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
/* 1,2,3 */
- MPI_Info_create( &info );
+ MPI_Info_create(&info);
/* Use only named keys incase the info implementation only supports
- the predefined keys (e.g., IBM) */
- for (i=0; i<NKEYS; i++) {
- MPI_Info_set( info, keys1[i], values1[i] );
+ * the predefined keys (e.g., IBM) */
+ for (i = 0; i < NKEYS; i++) {
+ MPI_Info_set(info, keys1[i], values1[i]);
}
/* Check that all values are present */
- for (i=0; i<NKEYS; i++) {
- MPI_Info_get( info, keys1[i], MPI_MAX_INFO_VAL, value, &flag );
- if (!flag) {
- errs++;
- printf( "No value for key %s\n", keys1[i] );
- }
- if (strcmp( value, values1[i] )) {
- errs++;
- printf( "Incorrect value for key %s\n", keys1[i] );
- }
+ for (i = 0; i < NKEYS; i++) {
+ MPI_Info_get(info, keys1[i], MPI_MAX_INFO_VAL, value, &flag);
+ if (!flag) {
+ errs++;
+ printf("No value for key %s\n", keys1[i]);
+ }
+ if (strcmp(value, values1[i])) {
+ errs++;
+ printf("Incorrect value for key %s\n", keys1[i]);
+ }
}
- MPI_Info_free( &info );
+ MPI_Info_free(&info);
/* 3,2,1 */
- MPI_Info_create( &info );
+ MPI_Info_create(&info);
/* Use only named keys incase the info implementation only supports
- the predefined keys (e.g., IBM) */
- for (i=NKEYS-1; i>=0; i--) {
- MPI_Info_set( info, keys1[i], values1[i] );
+ * the predefined keys (e.g., IBM) */
+ for (i = NKEYS - 1; i >= 0; i--) {
+ MPI_Info_set(info, keys1[i], values1[i]);
}
/* Check that all values are present */
- for (i=0; i<NKEYS; i++) {
- MPI_Info_get( info, keys1[i], MPI_MAX_INFO_VAL, value, &flag );
- if (!flag) {
- errs++;
- printf( "No value for key %s\n", keys1[i] );
- }
- if (strcmp( value, values1[i] )) {
- errs++;
- printf( "Incorrect value for key %s\n", keys1[i] );
- }
+ for (i = 0; i < NKEYS; i++) {
+ MPI_Info_get(info, keys1[i], MPI_MAX_INFO_VAL, value, &flag);
+ if (!flag) {
+ errs++;
+ printf("No value for key %s\n", keys1[i]);
+ }
+ if (strcmp(value, values1[i])) {
+ errs++;
+ printf("Incorrect value for key %s\n", keys1[i]);
+ }
}
- MPI_Info_free( &info );
+ MPI_Info_free(&info);
/* 1,3,2 */
- MPI_Info_create( &info );
+ MPI_Info_create(&info);
/* Use only named keys incase the info implementation only supports
- the predefined keys (e.g., IBM) */
- MPI_Info_set( info, keys1[0], values1[0] );
- MPI_Info_set( info, keys1[2], values1[2] );
- MPI_Info_set( info, keys1[1], values1[1] );
+ * the predefined keys (e.g., IBM) */
+ MPI_Info_set(info, keys1[0], values1[0]);
+ MPI_Info_set(info, keys1[2], values1[2]);
+ MPI_Info_set(info, keys1[1], values1[1]);
/* Check that all values are present */
- for (i=0; i<NKEYS; i++) {
- MPI_Info_get( info, keys1[i], MPI_MAX_INFO_VAL, value, &flag );
- if (!flag) {
- errs++;
- printf( "No value for key %s\n", keys1[i] );
- }
- if (strcmp( value, values1[i] )) {
- errs++;
- printf( "Incorrect value for key %s\n", keys1[i] );
- }
+ for (i = 0; i < NKEYS; i++) {
+ MPI_Info_get(info, keys1[i], MPI_MAX_INFO_VAL, value, &flag);
+ if (!flag) {
+ errs++;
+ printf("No value for key %s\n", keys1[i]);
+ }
+ if (strcmp(value, values1[i])) {
+ errs++;
+ printf("Incorrect value for key %s\n", keys1[i]);
+ }
}
- MPI_Info_free( &info );
+ MPI_Info_free(&info);
/* 2,1,3 */
- MPI_Info_create( &info );
+ MPI_Info_create(&info);
/* Use only named keys incase the info implementation only supports
- the predefined keys (e.g., IBM) */
- MPI_Info_set( info, keys1[1], values1[1] );
- MPI_Info_set( info, keys1[0], values1[0] );
- MPI_Info_set( info, keys1[2], values1[2] );
+ * the predefined keys (e.g., IBM) */
+ MPI_Info_set(info, keys1[1], values1[1]);
+ MPI_Info_set(info, keys1[0], values1[0]);
+ MPI_Info_set(info, keys1[2], values1[2]);
/* Check that all values are present */
- for (i=0; i<NKEYS; i++) {
- MPI_Info_get( info, keys1[i], MPI_MAX_INFO_VAL, value, &flag );
- if (!flag) {
- errs++;
- printf( "No value for key %s\n", keys1[i] );
- }
- if (strcmp( value, values1[i] )) {
- errs++;
- printf( "Incorrect value for key %s\n", keys1[i] );
- }
+ for (i = 0; i < NKEYS; i++) {
+ MPI_Info_get(info, keys1[i], MPI_MAX_INFO_VAL, value, &flag);
+ if (!flag) {
+ errs++;
+ printf("No value for key %s\n", keys1[i]);
+ }
+ if (strcmp(value, values1[i])) {
+ errs++;
+ printf("Incorrect value for key %s\n", keys1[i]);
+ }
}
- MPI_Info_free( &info );
+ MPI_Info_free(&info);
/* 2,3,1 */
- MPI_Info_create( &info );
+ MPI_Info_create(&info);
/* Use only named keys incase the info implementation only supports
- the predefined keys (e.g., IBM) */
- MPI_Info_set( info, keys1[1], values1[1] );
- MPI_Info_set( info, keys1[2], values1[2] );
- MPI_Info_set( info, keys1[0], values1[0] );
+ * the predefined keys (e.g., IBM) */
+ MPI_Info_set(info, keys1[1], values1[1]);
+ MPI_Info_set(info, keys1[2], values1[2]);
+ MPI_Info_set(info, keys1[0], values1[0]);
/* Check that all values are present */
- for (i=0; i<NKEYS; i++) {
- MPI_Info_get( info, keys1[i], MPI_MAX_INFO_VAL, value, &flag );
- if (!flag) {
- errs++;
- printf( "No value for key %s\n", keys1[i] );
- }
- if (strcmp( value, values1[i] )) {
- errs++;
- printf( "Incorrect value for key %s\n", keys1[i] );
- }
+ for (i = 0; i < NKEYS; i++) {
+ MPI_Info_get(info, keys1[i], MPI_MAX_INFO_VAL, value, &flag);
+ if (!flag) {
+ errs++;
+ printf("No value for key %s\n", keys1[i]);
+ }
+ if (strcmp(value, values1[i])) {
+ errs++;
+ printf("Incorrect value for key %s\n", keys1[i]);
+ }
}
- MPI_Info_free( &info );
-
+ MPI_Info_free(&info);
+
/* 3,1,2 */
- MPI_Info_create( &info );
+ MPI_Info_create(&info);
/* Use only named keys incase the info implementation only supports
- the predefined keys (e.g., IBM) */
- MPI_Info_set( info, keys1[2], values1[2] );
- MPI_Info_set( info, keys1[0], values1[0] );
- MPI_Info_set( info, keys1[1], values1[1] );
+ * the predefined keys (e.g., IBM) */
+ MPI_Info_set(info, keys1[2], values1[2]);
+ MPI_Info_set(info, keys1[0], values1[0]);
+ MPI_Info_set(info, keys1[1], values1[1]);
/* Check that all values are present */
- for (i=0; i<NKEYS; i++) {
- MPI_Info_get( info, keys1[i], MPI_MAX_INFO_VAL, value, &flag );
- if (!flag) {
- errs++;
- printf( "No value for key %s\n", keys1[i] );
- }
- if (strcmp( value, values1[i] )) {
- errs++;
- printf( "Incorrect value for key %s\n", keys1[i] );
- }
+ for (i = 0; i < NKEYS; i++) {
+ MPI_Info_get(info, keys1[i], MPI_MAX_INFO_VAL, value, &flag);
+ if (!flag) {
+ errs++;
+ printf("No value for key %s\n", keys1[i]);
+ }
+ if (strcmp(value, values1[i])) {
+ errs++;
+ printf("Incorrect value for key %s\n", keys1[i]);
+ }
}
- MPI_Info_free( &info );
-
- MTest_Finalize( errs );
+ MPI_Info_free(&info);
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/info/infotest.c b/test/mpi/info/infotest.c
index f560e8b..10e1934 100644
--- a/test/mpi/info/infotest.c
+++ b/test/mpi/info/infotest.c
@@ -13,44 +13,44 @@
#include <string.h>
#endif
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Info i1, i2;
int errs = 0;
char value[64];
int flag;
- MPI_Init( 0, 0 );
-
- MPI_Info_create( &i1 );
- MPI_Info_create( &i2 );
+ MPI_Init(0, 0);
- MPI_Info_set( i1, (char*)"key1", (char*)"value1" );
- MPI_Info_set( i2, (char*)"key2", (char*)"value2" );
+ MPI_Info_create(&i1);
+ MPI_Info_create(&i2);
- MPI_Info_get( i1, (char*)"key2", 64, value, &flag );
+ MPI_Info_set(i1, (char *) "key1", (char *) "value1");
+ MPI_Info_set(i2, (char *) "key2", (char *) "value2");
+
+ MPI_Info_get(i1, (char *) "key2", 64, value, &flag);
if (flag) {
- printf( "Found key2 in info1\n" );
- errs ++;
+ printf("Found key2 in info1\n");
+ errs++;
}
- MPI_Info_get( i1, (char*)"key1", 64, value, &flag );
+ MPI_Info_get(i1, (char *) "key1", 64, value, &flag);
if (!flag) {
- errs++;
- printf( "Did not find key1 in info1\n" );
+ errs++;
+ printf("Did not find key1 in info1\n");
}
- else if (strcmp( value, "value1" )) {
- errs++;
- printf( "Found wrong value (%s), expected value1\n", value );
+ else if (strcmp(value, "value1")) {
+ errs++;
+ printf("Found wrong value (%s), expected value1\n", value);
}
- MPI_Info_free( &i1 );
- MPI_Info_free( &i2 );
+ MPI_Info_free(&i1);
+ MPI_Info_free(&i2);
if (errs) {
- printf( " Found %d errors\n", errs );
+ printf(" Found %d errors\n", errs);
}
else {
- printf( " No Errors\n" );
+ printf(" No Errors\n");
}
- MPI_Finalize( );
+ MPI_Finalize();
return 0;
}
diff --git a/test/mpi/info/infovallen.c b/test/mpi/info/infovallen.c
index fdce0e3..22fbfe5 100644
--- a/test/mpi/info/infovallen.c
+++ b/test/mpi/info/infovallen.c
@@ -10,52 +10,52 @@
#include "mpitest.h"
#define NKEYS 3
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
MPI_Info info;
- char *keys[NKEYS] = { (char*)"file", (char*)"soft", (char*)"host" };
- char *values[NKEYS] = { (char*)"runfile.txt", (char*)"2:1000:4,3:1000:7",
- (char*)"myhost.myorg.org" };
+ char *keys[NKEYS] = { (char *) "file", (char *) "soft", (char *) "host" };
+ char *values[NKEYS] = { (char *) "runfile.txt", (char *) "2:1000:4,3:1000:7",
+ (char *) "myhost.myorg.org"
+ };
char value[MPI_MAX_INFO_VAL];
int i, flag, vallen;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Info_create( &info );
+ MPI_Info_create(&info);
/* Use only named keys incase the info implementation only supports
- the predefined keys (e.g., IBM) */
- for (i=0; i<NKEYS; i++) {
- MPI_Info_set( info, keys[i], values[i] );
+ * the predefined keys (e.g., IBM) */
+ for (i = 0; i < NKEYS; i++) {
+ MPI_Info_set(info, keys[i], values[i]);
}
/* Check that all values are present */
- for (i=0; i<NKEYS; i++) {
- MPI_Info_get_valuelen( info, keys[i], &vallen, &flag );
- if (!flag) {
- errs++;
- printf( "get_valuelen failed for valid key %s\n", keys[i] );
- }
- MPI_Info_get( info, keys[i], MPI_MAX_INFO_VAL, value, &flag );
- if (!flag) {
- errs++;
- printf( "No value for key %s\n", keys[i] );
- }
- if (strcmp( value, values[i] )) {
- errs++;
- printf( "Incorrect value for key %s\n", keys[i] );
- }
- if (strlen(value) != vallen) {
- errs++;
- printf( "value_len returned %d but actual len is %d\n",
- vallen, (int) strlen(value) );
- }
+ for (i = 0; i < NKEYS; i++) {
+ MPI_Info_get_valuelen(info, keys[i], &vallen, &flag);
+ if (!flag) {
+ errs++;
+ printf("get_valuelen failed for valid key %s\n", keys[i]);
+ }
+ MPI_Info_get(info, keys[i], MPI_MAX_INFO_VAL, value, &flag);
+ if (!flag) {
+ errs++;
+ printf("No value for key %s\n", keys[i]);
+ }
+ if (strcmp(value, values[i])) {
+ errs++;
+ printf("Incorrect value for key %s\n", keys[i]);
+ }
+ if (strlen(value) != vallen) {
+ errs++;
+ printf("value_len returned %d but actual len is %d\n", vallen, (int) strlen(value));
+ }
}
- MPI_Info_free( &info );
-
- MTest_Finalize( errs );
+ MPI_Info_free(&info);
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/init/attrself.c b/test/mpi/init/attrself.c
index 9f68ce2..027a413 100644
--- a/test/mpi/init/attrself.c
+++ b/test/mpi/init/attrself.c
@@ -13,126 +13,129 @@ static char MTestDescrip[] = "Test creating and inserting attributes in \
different orders to ensure that the list management code handles all cases.";
*/
-int checkAttrs( MPI_Comm, int, int [], int [] );
-int delete_fn( MPI_Comm, int, void *, void *);
+int checkAttrs(MPI_Comm, int, int[], int[]);
+int delete_fn(MPI_Comm, int, void *, void *);
#define NKEYS 5
-static int key[NKEYS]; /* Keys in creation order */
-static int keyorder[NKEYS]; /* Index (into key) of keys in order added to comm
- (key[keyorder[0]] is first set) */
+static int key[NKEYS]; /* Keys in creation order */
+static int keyorder[NKEYS]; /* Index (into key) of keys in order added to comm
+ * (key[keyorder[0]] is first set) */
static int nkeys = 0;
static int ncall = 0;
-static int errs = 0;
-/*
- * Test that attributes on comm self are deleted in LIFO order
+static int errs = 0;
+/*
+ * Test that attributes on comm self are deleted in LIFO order
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
- int attrval[10];
- int wrank, i;
+ int attrval[10];
+ int wrank, i;
MPI_Comm comm;
- MPI_Init( &argc, &argv );
+ MPI_Init(&argc, &argv);
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
comm = MPI_COMM_SELF;
-
+
/* Create key values */
- for (nkeys=0; nkeys<NKEYS; nkeys++) {
- MPI_Comm_create_keyval( MPI_NULL_COPY_FN, delete_fn,
- &key[nkeys], (void *)0 );
- attrval[nkeys] = 1024 * nkeys;
+ for (nkeys = 0; nkeys < NKEYS; nkeys++) {
+ MPI_Comm_create_keyval(MPI_NULL_COPY_FN, delete_fn, &key[nkeys], (void *) 0);
+ attrval[nkeys] = 1024 * nkeys;
}
-
+
/* Insert attribute in several orders. Test after put with get,
- then delete, then confirm delete with get. */
-
- MPI_Comm_set_attr( comm, key[3], &attrval[3] ); keyorder[0] = 3;
- MPI_Comm_set_attr( comm, key[2], &attrval[2] ); keyorder[1] = 2;
- MPI_Comm_set_attr( comm, key[0], &attrval[0] ); keyorder[2] = 0;
- MPI_Comm_set_attr( comm, key[1], &attrval[1] ); keyorder[3] = 1;
- MPI_Comm_set_attr( comm, key[4], &attrval[4] ); keyorder[4] = 4;
-
- errs += checkAttrs( comm, NKEYS, key, attrval );
-
- for (i=0; i<NKEYS; i++) {
- /* Save the key value so that we can compare it in the
- delete function */
- int keyval = key[i];
- MPI_Comm_free_keyval( &keyval );
+ * then delete, then confirm delete with get. */
+
+ MPI_Comm_set_attr(comm, key[3], &attrval[3]);
+ keyorder[0] = 3;
+ MPI_Comm_set_attr(comm, key[2], &attrval[2]);
+ keyorder[1] = 2;
+ MPI_Comm_set_attr(comm, key[0], &attrval[0]);
+ keyorder[2] = 0;
+ MPI_Comm_set_attr(comm, key[1], &attrval[1]);
+ keyorder[3] = 1;
+ MPI_Comm_set_attr(comm, key[4], &attrval[4]);
+ keyorder[4] = 4;
+
+ errs += checkAttrs(comm, NKEYS, key, attrval);
+
+ for (i = 0; i < NKEYS; i++) {
+ /* Save the key value so that we can compare it in the
+ * delete function */
+ int keyval = key[i];
+ MPI_Comm_free_keyval(&keyval);
}
-
+
MPI_Finalize();
-
+
if (wrank == 0) {
- if (ncall != nkeys) {
- printf( "Deleted %d keys but should have deleted %d\n",
- ncall, nkeys );
- errs++;
- }
- if (errs == 0) printf( " No Errors\n" );
- else printf( " Found %d errors\n", errs );
+ if (ncall != nkeys) {
+ printf("Deleted %d keys but should have deleted %d\n", ncall, nkeys);
+ errs++;
+ }
+ if (errs == 0)
+ printf(" No Errors\n");
+ else
+ printf(" Found %d errors\n", errs);
}
return 0;
-
+
}
-int checkAttrs( MPI_Comm comm, int n, int lkey[], int attrval[] )
+int checkAttrs(MPI_Comm comm, int n, int lkey[], int attrval[])
{
int lerrs = 0;
int i, flag, *val_p;
- for (i=0; i<n; i++) {
- MPI_Comm_get_attr( comm, lkey[i], &val_p, &flag );
- if (!flag) {
- lerrs++;
- fprintf( stderr, "Attribute for key %d not set\n", i );
- }
- else if (val_p != &attrval[i]) {
- lerrs++;
- fprintf( stderr, "Atribute value for key %d not correct\n",
- i );
- }
+ for (i = 0; i < n; i++) {
+ MPI_Comm_get_attr(comm, lkey[i], &val_p, &flag);
+ if (!flag) {
+ lerrs++;
+ fprintf(stderr, "Attribute for key %d not set\n", i);
+ }
+ else if (val_p != &attrval[i]) {
+ lerrs++;
+ fprintf(stderr, "Atribute value for key %d not correct\n", i);
+ }
}
return lerrs;
}
/* We *should* be deleting key[keyorder[nkeys-ncall]] */
-int delete_fn( MPI_Comm comm, int keyval, void *attribute_val,
- void *extra_state)
+int delete_fn(MPI_Comm comm, int keyval, void *attribute_val, void *extra_state)
{
if (ncall >= nkeys) {
- printf( "delete function called too many times!\n" );
- errs++;
+ printf("delete function called too many times!\n");
+ errs++;
}
- /* As of MPI 2.2, the order of deletion of attributes on
- MPI_COMM_SELF is defined */
+ /* As of MPI 2.2, the order of deletion of attributes on
+ * MPI_COMM_SELF is defined */
if (MPI_VERSION > 2 || (MPI_VERSION == 2 && MPI_SUBVERSION >= 2)) {
- if (keyval != key[keyorder[nkeys-1-ncall]]) {
- printf( "Expected key # %d but found key with value %d\n",
- keyorder[nkeys-1-ncall], keyval );
- errs++;
- }
+ if (keyval != key[keyorder[nkeys - 1 - ncall]]) {
+ printf("Expected key # %d but found key with value %d\n",
+ keyorder[nkeys - 1 - ncall], keyval);
+ errs++;
+ }
}
ncall++;
return MPI_SUCCESS;
}
/*
-int checkNoAttrs( MPI_Comm comm, int n, int lkey[] )
+int checkNoAttrs(MPI_Comm comm, int n, int lkey[])
{
int lerrs = 0;
int i, flag, *val_p;
for (i=0; i<n; i++) {
- MPI_Comm_get_attr( comm, lkey[i], &val_p, &flag );
+ MPI_Comm_get_attr(comm, lkey[i], &val_p, &flag);
if (flag) {
lerrs++;
- fprintf( stderr, "Attribute for key %d set but should be deleted\n", i );
+ fprintf(stderr, "Attribute for key %d set but should be deleted\n", i);
}
}
diff --git a/test/mpi/init/exitst1.c b/test/mpi/init/exitst1.c
index 3ea4e46..c16c64c 100644
--- a/test/mpi/init/exitst1.c
+++ b/test/mpi/init/exitst1.c
@@ -5,13 +5,13 @@
*/
#include "mpi.h"
-/*
- * This is a special test to check that mpiexec handles zero/non-zero
+/*
+ * This is a special test to check that mpiexec handles zero/non-zero
* return status from an application
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
- MPI_Init( 0, 0 );
- MPI_Finalize( );
+ MPI_Init(0, 0);
+ MPI_Finalize();
return 1;
}
diff --git a/test/mpi/init/exitst2.c b/test/mpi/init/exitst2.c
index 7a9b19c..cba7733 100644
--- a/test/mpi/init/exitst2.c
+++ b/test/mpi/init/exitst2.c
@@ -5,16 +5,16 @@
*/
#include "mpi.h"
-/*
- * This is a special test to check that mpiexec handles zero/non-zero
- * return status from an application. In this case, each process
+/*
+ * This is a special test to check that mpiexec handles zero/non-zero
+ * return status from an application. In this case, each process
* returns a different return status
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int rank;
- MPI_Init( 0, 0 );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Finalize( );
+ MPI_Init(0, 0);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Finalize();
return rank;
}
diff --git a/test/mpi/init/exitst3.c b/test/mpi/init/exitst3.c
index 9943e3b..36899ec 100644
--- a/test/mpi/init/exitst3.c
+++ b/test/mpi/init/exitst3.c
@@ -5,22 +5,22 @@
*/
#include "mpi.h"
-/*
+/*
* This is a special test to check that mpiexec handles the death of
* some processes without an Abort or clean exit
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int rank, size;
- MPI_Init( 0, 0 );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
- MPI_Barrier( MPI_COMM_WORLD );
- if (rank == size-1) {
- /* Cause some processes to exit */
- int *p =0 ;
- *p = rank;
+ MPI_Init(0, 0);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ MPI_Barrier(MPI_COMM_WORLD);
+ if (rank == size - 1) {
+ /* Cause some processes to exit */
+ int *p = 0;
+ *p = rank;
}
- MPI_Finalize( );
+ MPI_Finalize();
return 0;
}
diff --git a/test/mpi/init/finalized.c b/test/mpi/init/finalized.c
index 32ac134..79acd8b 100644
--- a/test/mpi/init/finalized.c
+++ b/test/mpi/init/finalized.c
@@ -9,13 +9,13 @@
/* FIXME: This test program assumes that MPI_Error_string will work even
if MPI is not initialized. That is not guaranteed. */
-/* Normally, when checking for error returns from MPI calls, you must ensure
+/* Normally, when checking for error returns from MPI calls, you must ensure
that the error handler on the relevant object (communicator, file, or
- window) has been set to MPI_ERRORS_RETURN. The tests in this
+ window) has been set to MPI_ERRORS_RETURN. The tests in this
program are a special case, as either a failure or an abort will
indicate a problem */
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int error;
int flag;
@@ -25,92 +25,81 @@ int main( int argc, char *argv[] )
flag = 0;
error = MPI_Finalized(&flag);
- if (error != MPI_SUCCESS)
- {
- MPI_Error_string(error, err_string, &length);
- printf("MPI_Finalized failed: %s\n", err_string);
- fflush(stdout);
- return error;
+ if (error != MPI_SUCCESS) {
+ MPI_Error_string(error, err_string, &length);
+ printf("MPI_Finalized failed: %s\n", err_string);
+ fflush(stdout);
+ return error;
}
- if (flag)
- {
- printf("MPI_Finalized returned true before MPI_Init.\n");
- return -1;
+ if (flag) {
+ printf("MPI_Finalized returned true before MPI_Init.\n");
+ return -1;
}
error = MPI_Init(&argc, &argv);
- if (error != MPI_SUCCESS)
- {
- MPI_Error_string(error, err_string, &length);
- printf("MPI_Init failed: %s\n", err_string);
- fflush(stdout);
- return error;
+ if (error != MPI_SUCCESS) {
+ MPI_Error_string(error, err_string, &length);
+ printf("MPI_Init failed: %s\n", err_string);
+ fflush(stdout);
+ return error;
}
error = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- if (error != MPI_SUCCESS)
- {
- MPI_Error_string(error, err_string, &length);
- printf("MPI_Comm_rank failed: %s\n", err_string);
- fflush(stdout);
- MPI_Abort(MPI_COMM_WORLD, error);
- return error;
+ if (error != MPI_SUCCESS) {
+ MPI_Error_string(error, err_string, &length);
+ printf("MPI_Comm_rank failed: %s\n", err_string);
+ fflush(stdout);
+ MPI_Abort(MPI_COMM_WORLD, error);
+ return error;
}
flag = 0;
error = MPI_Finalized(&flag);
- if (error != MPI_SUCCESS)
- {
- MPI_Error_string(error, err_string, &length);
- printf("MPI_Finalized failed: %s\n", err_string);
- fflush(stdout);
- MPI_Abort(MPI_COMM_WORLD, error);
- return error;
+ if (error != MPI_SUCCESS) {
+ MPI_Error_string(error, err_string, &length);
+ printf("MPI_Finalized failed: %s\n", err_string);
+ fflush(stdout);
+ MPI_Abort(MPI_COMM_WORLD, error);
+ return error;
}
- if (flag)
- {
- printf("MPI_Finalized returned true before MPI_Finalize.\n");
- fflush(stdout);
- MPI_Abort(MPI_COMM_WORLD, error);
- return -1;
+ if (flag) {
+ printf("MPI_Finalized returned true before MPI_Finalize.\n");
+ fflush(stdout);
+ MPI_Abort(MPI_COMM_WORLD, error);
+ return -1;
}
error = MPI_Barrier(MPI_COMM_WORLD);
- if (error != MPI_SUCCESS)
- {
- MPI_Error_string(error, err_string, &length);
- printf("MPI_Barrier failed: %s\n", err_string);
- fflush(stdout);
- MPI_Abort(MPI_COMM_WORLD, error);
- return error;
+ if (error != MPI_SUCCESS) {
+ MPI_Error_string(error, err_string, &length);
+ printf("MPI_Barrier failed: %s\n", err_string);
+ fflush(stdout);
+ MPI_Abort(MPI_COMM_WORLD, error);
+ return error;
}
error = MPI_Finalize();
- if (error != MPI_SUCCESS)
- {
- MPI_Error_string(error, err_string, &length);
- printf("MPI_Finalize failed: %s\n", err_string);
- fflush(stdout);
- return error;
+ if (error != MPI_SUCCESS) {
+ MPI_Error_string(error, err_string, &length);
+ printf("MPI_Finalize failed: %s\n", err_string);
+ fflush(stdout);
+ return error;
}
flag = 0;
error = MPI_Finalized(&flag);
- if (error != MPI_SUCCESS)
- {
- MPI_Error_string(error, err_string, &length);
- printf("MPI_Finalized failed: %s\n", err_string);
- fflush(stdout);
- return error;
+ if (error != MPI_SUCCESS) {
+ MPI_Error_string(error, err_string, &length);
+ printf("MPI_Finalized failed: %s\n", err_string);
+ fflush(stdout);
+ return error;
}
- if (!flag)
- {
- printf("MPI_Finalized returned false after MPI_Finalize.\n");
- return -1;
+ if (!flag) {
+ printf("MPI_Finalized returned false after MPI_Finalize.\n");
+ return -1;
}
- if (rank == 0)
- {
- printf(" No Errors\n");
+ if (rank == 0) {
+ printf(" No Errors\n");
}
- return 0;
+ return 0;
}
diff --git a/test/mpi/init/initstat.c b/test/mpi/init/initstat.c
index 800321f..6d278fa 100644
--- a/test/mpi/init/initstat.c
+++ b/test/mpi/init/initstat.c
@@ -8,29 +8,28 @@
#include <stdio.h>
#include "mpitest.h"
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int provided, flag, claimed;
- /* MTest_Init( &argc, &argv ); */
+ /* MTest_Init(&argc, &argv); */
- MPI_Init_thread( 0, 0, MPI_THREAD_MULTIPLE, &provided );
-
- MPI_Is_thread_main( &flag );
+ MPI_Init_thread(0, 0, MPI_THREAD_MULTIPLE, &provided);
+
+ MPI_Is_thread_main(&flag);
if (!flag) {
- errs++;
- printf( "This thread called init_thread but Is_thread_main gave false\n" );
+ errs++;
+ printf("This thread called init_thread but Is_thread_main gave false\n");
}
- MPI_Query_thread( &claimed );
+ MPI_Query_thread(&claimed);
if (claimed != provided) {
- errs++;
- printf( "Query thread gave thread level %d but Init_thread gave %d\n",
- claimed, provided );
+ errs++;
+ printf("Query thread gave thread level %d but Init_thread gave %d\n", claimed, provided);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/init/timeout.c b/test/mpi/init/timeout.c
index 3c1cca8..316eb50 100644
--- a/test/mpi/init/timeout.c
+++ b/test/mpi/init/timeout.c
@@ -7,14 +7,14 @@
/* This is a program that tests the ability of mpiexec to timeout a process
after no more than 3 minutes. By default, it will run for 5 minutes */
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
double t1;
double deltaTime = 300;
- MPI_Init( 0, 0 );
+ MPI_Init(0, 0);
t1 = MPI_Wtime();
- while (MPI_Wtime() - t1 < deltaTime) ;
- MPI_Finalize( );
+ while (MPI_Wtime() - t1 < deltaTime);
+ MPI_Finalize();
return 0;
}
diff --git a/test/mpi/init/version.c b/test/mpi/init/version.c
index 40c5895..46044d0 100644
--- a/test/mpi/init/version.c
+++ b/test/mpi/init/version.c
@@ -8,27 +8,25 @@
#include <stdio.h>
#include "mpitest.h"
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int majversion, subversion;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Get_version( &majversion, &subversion );
+ MPI_Get_version(&majversion, &subversion);
if (majversion != MPI_VERSION) {
- errs++;
- printf( "Major version is %d but is %d in the mpi.h file\n",
- majversion, MPI_VERSION );
+ errs++;
+ printf("Major version is %d but is %d in the mpi.h file\n", majversion, MPI_VERSION);
}
if (subversion != MPI_SUBVERSION) {
- errs++;
- printf( "Minor version is %d but is %d in the mpi.h file\n",
- subversion, MPI_SUBVERSION );
+ errs++;
+ printf("Minor version is %d but is %d in the mpi.h file\n", subversion, MPI_SUBVERSION);
}
-
- MTest_Finalize( errs );
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/io/async.c b/test/mpi/io/async.c
index c38a485..aa0141b 100644
--- a/test/mpi/io/async.c
+++ b/test/mpi/io/async.c
@@ -1,5 +1,5 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
-/*
+/*
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
@@ -18,22 +18,22 @@ static char MTEST_Descrip[] = "Test contig asynchronous I/O";
/* Uses asynchronous I/O. Each process writes to separate files and
reads them back. The file name is taken as a command-line argument,
- and the process rank is appended to it.*/
+ and the process rank is appended to it.*/
static void handle_error(int errcode, char *str)
{
- char msg[MPI_MAX_ERROR_STRING];
- int resultlen;
- MPI_Error_string(errcode, msg, &resultlen);
- fprintf(stderr, "%s: %s\n", str, msg);
- MPI_Abort(MPI_COMM_WORLD, 1);
+ char msg[MPI_MAX_ERROR_STRING];
+ int resultlen;
+ MPI_Error_string(errcode, msg, &resultlen);
+ fprintf(stderr, "%s: %s\n", str, msg);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
int main(int argc, char **argv)
{
int *buf, i, rank, nints, len, err;
- char *filename=0, *tmp;
- int errs=0;
+ char *filename = 0, *tmp;
+ int errs = 0;
int SIZE = DEFAULT_SIZE;
MPI_File fh;
MPI_Status status;
@@ -43,115 +43,124 @@ int main(int argc, char **argv)
MPIO_Request request;
#endif
- MTest_Init(&argc,&argv);
+ MTest_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
-/* process 0 takes the file name as a command-line argument and
+/* process 0 takes the file name as a command-line argument and
broadcasts it to other processes */
if (!rank) {
- i = 1;
- argv++;
- /* Skip unrecognized arguments */
- while (i < argc) {
- if (strcmp( *argv, "-fname" ) == 0) {
- argv++;
- i++;
- len = (int)strlen(*argv);
- filename = (char *) malloc(len+10);
- strcpy(filename, *argv);
- }
- else if (strcmp( *argv, "-size" ) == 0) {
- argv++;
- i++;
- SIZE = strtol( *argv, 0, 10 );
- if (errno) {
- fprintf( stderr, "-size requires a numeric argument\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- else if (SIZE <= 0) {
- fprintf( stderr, "-size requires a positive value\n" );
- }
- }
- else {
- i++;
- argv++;
- }
- }
-
- if (!filename) {
- /* Use a default filename of testfile */
- len = 8;
- filename = (char *)malloc(len + 10);
- strcpy( filename, "testfile" );
- }
- MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
- MPI_Bcast(filename, len+10, MPI_CHAR, 0, MPI_COMM_WORLD);
- MPI_Bcast( &SIZE, 1, MPI_INT, 0, MPI_COMM_WORLD );
+ i = 1;
+ argv++;
+ /* Skip unrecognized arguments */
+ while (i < argc) {
+ if (strcmp(*argv, "-fname") == 0) {
+ argv++;
+ i++;
+ len = (int) strlen(*argv);
+ filename = (char *) malloc(len + 10);
+ strcpy(filename, *argv);
+ }
+ else if (strcmp(*argv, "-size") == 0) {
+ argv++;
+ i++;
+ SIZE = strtol(*argv, 0, 10);
+ if (errno) {
+ fprintf(stderr, "-size requires a numeric argument\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ else if (SIZE <= 0) {
+ fprintf(stderr, "-size requires a positive value\n");
+ }
+ }
+ else {
+ i++;
+ argv++;
+ }
+ }
+
+ if (!filename) {
+ /* Use a default filename of testfile */
+ len = 8;
+ filename = (char *) malloc(len + 10);
+ strcpy(filename, "testfile");
+ }
+ MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ MPI_Bcast(filename, len + 10, MPI_CHAR, 0, MPI_COMM_WORLD);
+ MPI_Bcast(&SIZE, 1, MPI_INT, 0, MPI_COMM_WORLD);
}
else {
- MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
- filename = (char *) malloc(len+10);
- MPI_Bcast(filename, len+10, MPI_CHAR, 0, MPI_COMM_WORLD);
- MPI_Bcast( &SIZE, 1, MPI_INT, 0, MPI_COMM_WORLD );
+ MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ filename = (char *) malloc(len + 10);
+ MPI_Bcast(filename, len + 10, MPI_CHAR, 0, MPI_COMM_WORLD);
+ MPI_Bcast(&SIZE, 1, MPI_INT, 0, MPI_COMM_WORLD);
}
- /* printf( "Starting (size=%d, file=%s)...\n", SIZE, filename ); fflush(stdout); */
+ /* printf("Starting (size=%d, file=%s)...\n", SIZE, filename); fflush(stdout); */
buf = (int *) malloc(SIZE);
- nints = SIZE/sizeof(int);
- for (i=0; i<nints; i++) buf[i] = rank*100000 + i;
+ nints = SIZE / sizeof(int);
+ for (i = 0; i < nints; i++)
+ buf[i] = rank * 100000 + i;
/* each process opens a separate file called filename.'myrank' */
- tmp = (char *) malloc(len+10);
+ tmp = (char *) malloc(len + 10);
strcpy(tmp, filename);
sprintf(filename, "%s.%d", tmp, rank);
free(tmp);
- err = MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_CREATE | MPI_MODE_RDWR,
- MPI_INFO_NULL, &fh);
- if (err != MPI_SUCCESS) handle_error(err, "MPI_File_open");
+ err = MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_CREATE | MPI_MODE_RDWR,
+ MPI_INFO_NULL, &fh);
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_open");
- err = MPI_File_set_view(fh, 0, MPI_INT, MPI_INT, (char*)"native", MPI_INFO_NULL);
- if (err != MPI_SUCCESS) handle_error(err, "MPI_File_set_view");
+ err = MPI_File_set_view(fh, 0, MPI_INT, MPI_INT, (char *) "native", MPI_INFO_NULL);
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_set_view");
err = MPI_File_iwrite(fh, buf, nints, MPI_INT, &request);
- if (err != MPI_SUCCESS) handle_error(err, "MPI_File_iwrtie");
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_iwrtie");
#ifdef MPIO_USES_MPI_REQUEST
- MPI_Wait( &request, &status );
-#else
+ MPI_Wait(&request, &status);
+#else
MPIO_Wait(&request, &status);
#endif
MPI_File_close(&fh);
/* reopen the file and read the data back */
- for (i=0; i<nints; i++) buf[i] = 0;
- err = MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_CREATE | MPI_MODE_RDWR,
- MPI_INFO_NULL, &fh);
- if (err != MPI_SUCCESS) handle_error(err, "MPI_File_open (read)");
- err = MPI_File_set_view(fh, 0, MPI_INT, MPI_INT, (char*)"native", MPI_INFO_NULL);
- if (err != MPI_SUCCESS) handle_error(err, "MPI_File_set_view (read)");
+ for (i = 0; i < nints; i++)
+ buf[i] = 0;
+ err = MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_CREATE | MPI_MODE_RDWR,
+ MPI_INFO_NULL, &fh);
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_open (read)");
+ err = MPI_File_set_view(fh, 0, MPI_INT, MPI_INT, (char *) "native", MPI_INFO_NULL);
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_set_view (read)");
err = MPI_File_iread(fh, buf, nints, MPI_INT, &request);
- if (err != MPI_SUCCESS) handle_error(err, "MPI_File_iread");
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_iread");
#ifdef MPIO_USES_MPI_REQUEST
- MPI_Wait( &request, &status );
-#else
+ MPI_Wait(&request, &status);
+#else
MPIO_Wait(&request, &status);
#endif
MPI_File_close(&fh);
/* check if the data read is correct */
- for (i=0; i<nints; i++) {
- if (buf[i] != (rank*100000 + i)) {
- errs++;
- if (errs < 25) {
- fprintf(stderr, "Process %d: error, read %d, should be %d\n", rank, buf[i], rank*100000+i);
- }
- else if (errs == 25) {
- fprintf(stderr, "Reached maximum number of errors to report\n" );
- }
- }
+ for (i = 0; i < nints; i++) {
+ if (buf[i] != (rank * 100000 + i)) {
+ errs++;
+ if (errs < 25) {
+ fprintf(stderr, "Process %d: error, read %d, should be %d\n", rank, buf[i],
+ rank * 100000 + i);
+ }
+ else if (errs == 25) {
+ fprintf(stderr, "Reached maximum number of errors to report\n");
+ }
+ }
}
free(buf);
@@ -159,5 +168,5 @@ int main(int argc, char **argv)
MTest_Finalize(errs);
MPI_Finalize();
- return 0;
+ return 0;
}
diff --git a/test/mpi/io/async_any.c b/test/mpi/io/async_any.c
index cf3d436..450894a 100644
--- a/test/mpi/io/async_any.c
+++ b/test/mpi/io/async_any.c
@@ -1,5 +1,5 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
-/*
+/*
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
@@ -18,90 +18,91 @@ static char MTEST_Descrip[] = "Test asynchronous I/O w/ multiple completion";
/* Uses asynchronous I/O. Each process writes to separate files and
reads them back. The file name is taken as a command-line argument,
- and the process rank is appended to it.*/
+ and the process rank is appended to it.*/
int main(int argc, char **argv)
{
int *buf, i, rank, nints, len;
char *filename, *tmp;
- int errs=0;
+ int errs = 0;
MPI_File fh;
MPI_Status statuses[NUMOPS];
MPI_Request requests[NUMOPS];
- MTest_Init(&argc,&argv);
+ MTest_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
-/* process 0 takes the file name as a command-line argument and
+/* process 0 takes the file name as a command-line argument and
broadcasts it to other processes */
if (!rank) {
- i = 1;
- while ((i < argc) && strcmp("-fname", *argv)) {
- i++;
- argv++;
- }
- if (i >= argc) {
- /* Use a default filename of testfile */
- len = 8;
- filename = (char *)malloc(len + 10);
- strcpy( filename, "testfile" );
- /*
- fprintf(stderr, "\n*# Usage: async_any -fname filename\n\n");
- MPI_Abort(MPI_COMM_WORLD, 1);
- */
- }
- else {
- argv++;
- len = (int)strlen(*argv);
- filename = (char *) malloc(len+10);
- strcpy(filename, *argv);
- }
- MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
- MPI_Bcast(filename, len+10, MPI_CHAR, 0, MPI_COMM_WORLD);
+ i = 1;
+ while ((i < argc) && strcmp("-fname", *argv)) {
+ i++;
+ argv++;
+ }
+ if (i >= argc) {
+ /* Use a default filename of testfile */
+ len = 8;
+ filename = (char *) malloc(len + 10);
+ strcpy(filename, "testfile");
+ /*
+ * fprintf(stderr, "\n*# Usage: async_any -fname filename\n\n");
+ * MPI_Abort(MPI_COMM_WORLD, 1);
+ */
+ }
+ else {
+ argv++;
+ len = (int) strlen(*argv);
+ filename = (char *) malloc(len + 10);
+ strcpy(filename, *argv);
+ }
+ MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ MPI_Bcast(filename, len + 10, MPI_CHAR, 0, MPI_COMM_WORLD);
}
else {
- MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
- filename = (char *) malloc(len+10);
- MPI_Bcast(filename, len+10, MPI_CHAR, 0, MPI_COMM_WORLD);
+ MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ filename = (char *) malloc(len + 10);
+ MPI_Bcast(filename, len + 10, MPI_CHAR, 0, MPI_COMM_WORLD);
}
buf = (int *) malloc(SIZE);
- nints = SIZE/sizeof(int);
- for (i=0; i<nints; i++) buf[i] = rank*100000 + i;
+ nints = SIZE / sizeof(int);
+ for (i = 0; i < nints; i++)
+ buf[i] = rank * 100000 + i;
/* each process opens a separate file called filename.'myrank' */
- tmp = (char *) malloc(len+10);
+ tmp = (char *) malloc(len + 10);
strcpy(tmp, filename);
sprintf(filename, "%s.%d", tmp, rank);
- MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_CREATE | MPI_MODE_RDWR,
- MPI_INFO_NULL, &fh);
- MPI_File_set_view(fh, 0, MPI_INT, MPI_INT, (char*)"native", MPI_INFO_NULL);
- for (i=0; i < NUMOPS; i++) {
- MPI_File_iwrite(fh, buf, nints, MPI_INT, &(requests[i]));
+ MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
+ MPI_File_set_view(fh, 0, MPI_INT, MPI_INT, (char *) "native", MPI_INFO_NULL);
+ for (i = 0; i < NUMOPS; i++) {
+ MPI_File_iwrite(fh, buf, nints, MPI_INT, &(requests[i]));
}
MPI_Waitall(NUMOPS, requests, statuses);
MPI_File_close(&fh);
/* reopen the file and read the data back */
- for (i=0; i<nints; i++) buf[i] = 0;
- MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_CREATE | MPI_MODE_RDWR,
- MPI_INFO_NULL, &fh);
- MPI_File_set_view(fh, 0, MPI_INT, MPI_INT, (char*)"native", MPI_INFO_NULL);
- for (i=0; i < NUMOPS; i++) {
- MPI_File_iread(fh, buf, nints, MPI_INT, &(requests[i]));
+ for (i = 0; i < nints; i++)
+ buf[i] = 0;
+ MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
+ MPI_File_set_view(fh, 0, MPI_INT, MPI_INT, (char *) "native", MPI_INFO_NULL);
+ for (i = 0; i < NUMOPS; i++) {
+ MPI_File_iread(fh, buf, nints, MPI_INT, &(requests[i]));
}
MPI_Waitall(NUMOPS, requests, statuses);
MPI_File_close(&fh);
/* check if the data read is correct */
- for (i=0; i<nints; i++) {
- if (buf[i] != (rank*100000 + i)) {
- errs++;
- fprintf(stderr, "Process %d: error, read %d, should be %d\n", rank, buf[i], rank*100000+i);
- }
+ for (i = 0; i < nints; i++) {
+ if (buf[i] != (rank * 100000 + i)) {
+ errs++;
+ fprintf(stderr, "Process %d: error, read %d, should be %d\n", rank, buf[i],
+ rank * 100000 + i);
+ }
}
free(buf);
@@ -110,5 +111,5 @@ int main(int argc, char **argv)
MTest_Finalize(errs);
MPI_Finalize();
- return 0;
+ return 0;
}
diff --git a/test/mpi/io/bigtype.c b/test/mpi/io/bigtype.c
index 11e3ea3..a5f6cea 100644
--- a/test/mpi/io/bigtype.c
+++ b/test/mpi/io/bigtype.c
@@ -12,7 +12,7 @@
//#define BIGDT 2147483643
#define BIGDT 2147483647
-int main(int argc, char** argv)
+int main(int argc, char **argv)
{
MPI_File fh;
@@ -26,38 +26,38 @@ int main(int argc, char** argv)
int block_len[2];
MPI_Datatype type[2];
- MPI_Init (&argc, &argv);
+ MPI_Init(&argc, &argv);
if (sizeof(MPI_Aint) <= sizeof(int)) {
- /* can't test on this platform... */
- goto exit;
+ /* can't test on this platform... */
+ goto exit;
}
k = 0;
- /* create a large buffer 2*/
- buf_write = malloc (NUM_X*NUM_Y*sizeof(int));
+ /* create a large buffer 2 */
+ buf_write = malloc(NUM_X * NUM_Y * sizeof(int));
if (buf_write == NULL) {
fprintf(stderr, "not enough memory\n");
exit(1);
}
- buf_read = malloc (NUM_X*NUM_Y*sizeof(int));
+ buf_read = malloc(NUM_X * NUM_Y * sizeof(int));
if (buf_read == NULL) {
fprintf(stderr, "not enough memory\n");
exit(1);
}
- memset(buf_read, 0, NUM_X*NUM_Y*sizeof(int));
+ memset(buf_read, 0, NUM_X * NUM_Y * sizeof(int));
- for (i=0; i<NUM_X ; i++) {
- for (j=0 ; j<NUM_Y ; j++) {
+ for (i = 0; i < NUM_X; i++) {
+ for (j = 0; j < NUM_Y; j++) {
buf_write[k] = k;
- k++;
+ k++;
}
}
/* Big Datatype (2^31 - 1 bytes) */
- MPI_Type_contiguous (BIGDT, MPI_BYTE, &inner_type);
+ MPI_Type_contiguous(BIGDT, MPI_BYTE, &inner_type);
/* Small Datatype (1 byte) */
- MPI_Type_contiguous (1, MPI_BYTE, &rem_type);
+ MPI_Type_contiguous(1, MPI_BYTE, &rem_type);
type[0] = inner_type;
type[1] = rem_type;
@@ -66,69 +66,57 @@ int main(int argc, char** argv)
disp[0] = 0;
disp[1] = BIGDT;
- /* combine both types*/
+ /* combine both types */
MPI_Type_struct(2, block_len, disp, type, &mem_type);
MPI_Type_commit(&mem_type);
MPI_Type_free(&rem_type);
MPI_Type_free(&inner_type);
- MPI_Type_contiguous (4, MPI_BYTE, &int_type);
+ MPI_Type_contiguous(4, MPI_BYTE, &int_type);
{
- /* This creates a big type that is actually contituous, touching an
- * optimization that was at one point buggy */
+ /* This creates a big type that is actually contituous, touching an
+ * optimization that was at one point buggy */
MPI_Type_vector(1, NUM_X, 1, int_type, &file_type);
}
MPI_Type_commit(&file_type);
MPI_Type_free(&int_type);
- if(MPI_File_open (MPI_COMM_WORLD, "testfile", MPI_MODE_RDWR | MPI_MODE_CREATE,
+ if (MPI_File_open(MPI_COMM_WORLD, "testfile", MPI_MODE_RDWR | MPI_MODE_CREATE,
MPI_INFO_NULL, &fh) != 0) {
- fprintf(stderr, "Can't open file: %s\n","testfile");
+ fprintf(stderr, "Can't open file: %s\n", "testfile");
exit(1);
}
- if (MPI_SUCCESS != MPI_File_set_view(fh, 2144, MPI_BYTE,
- file_type, "native", MPI_INFO_NULL)) {
- fprintf (stderr, "ERROR SET VIEW\n");
+ if (MPI_SUCCESS != MPI_File_set_view(fh, 2144, MPI_BYTE, file_type, "native", MPI_INFO_NULL)) {
+ fprintf(stderr, "ERROR SET VIEW\n");
exit(1);
}
/* write everything */
- rc = MPI_File_write_at_all (fh,
- 0,
- buf_write,
- 1,
- mem_type,
- MPI_STATUS_IGNORE);
- if (rc != MPI_SUCCESS){
- fprintf (stderr, "%d ERROR WRITE AT ALL\n", rc);
+ rc = MPI_File_write_at_all(fh, 0, buf_write, 1, mem_type, MPI_STATUS_IGNORE);
+ if (rc != MPI_SUCCESS) {
+ fprintf(stderr, "%d ERROR WRITE AT ALL\n", rc);
exit(1);
}
- if (MPI_SUCCESS != MPI_File_set_view(fh, 2144, MPI_BYTE,
- file_type, "native", MPI_INFO_NULL)) {
- fprintf (stderr, "ERROR SET VIEW\n");
+ if (MPI_SUCCESS != MPI_File_set_view(fh, 2144, MPI_BYTE, file_type, "native", MPI_INFO_NULL)) {
+ fprintf(stderr, "ERROR SET VIEW\n");
exit(1);
}
/* read everything */
- rc = MPI_File_read_at_all (fh,
- 0,
- buf_read,
- 1,
- mem_type,
- MPI_STATUS_IGNORE);
+ rc = MPI_File_read_at_all(fh, 0, buf_read, 1, mem_type, MPI_STATUS_IGNORE);
if (rc != MPI_SUCCESS) {
- fprintf (stderr, "%d ERROR READ AT ALL\n", rc);
+ fprintf(stderr, "%d ERROR READ AT ALL\n", rc);
exit(1);
}
- for (k=0 ; k<NUM_X*NUM_Y ; k++) {
- if(buf_read[k] != buf_write[k]) {
+ for (k = 0; k < NUM_X * NUM_Y; k++) {
+ if (buf_read[k] != buf_write[k]) {
fprintf(stderr, "Verfiy Failed index %zu: expected %d found %d\n",
- k, buf_write[k], buf_read[k]);
+ k, buf_write[k], buf_read[k]);
assert(0);
}
}
@@ -137,11 +125,11 @@ int main(int argc, char** argv)
free(buf_read);
MPI_File_close(&fh);
- MPI_Type_free (&mem_type);
+ MPI_Type_free(&mem_type);
MPI_Type_free(&file_type);
-exit:
- MPI_Finalize ();
+ exit:
+ MPI_Finalize();
printf(" No Errors\n");
return 0;
diff --git a/test/mpi/io/getextent.c b/test/mpi/io/getextent.c
index ac8fc1b..a0ea76a 100644
--- a/test/mpi/io/getextent.c
+++ b/test/mpi/io/getextent.c
@@ -12,30 +12,29 @@
static char MTEST_Descrip[] = "Test file_get_extent";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
MPI_File fh;
MPI_Comm comm;
MPI_Aint extent, nextent;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_File_open( comm, (char*)"test.ord",
- MPI_MODE_RDWR | MPI_MODE_CREATE |
- MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh );
+ MPI_File_open(comm, (char *) "test.ord",
+ MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh);
- MPI_File_get_type_extent( fh, MPI_INT, &extent );
- MPI_Type_extent( MPI_INT, &nextent );
+ MPI_File_get_type_extent(fh, MPI_INT, &extent);
+ MPI_Type_extent(MPI_INT, &nextent);
if (nextent != extent) {
errs++;
- fprintf( stderr, "Native extent not the same as the file extent\n" );
+ fprintf(stderr, "Native extent not the same as the file extent\n");
}
- MPI_File_close( &fh );
+ MPI_File_close(&fh);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/io/hindexed_io.c b/test/mpi/io/hindexed_io.c
index 3261278..475fc5a 100644
--- a/test/mpi/io/hindexed_io.c
+++ b/test/mpi/io/hindexed_io.c
@@ -17,9 +17,10 @@ static void handle_error(int errcode, char *str)
fprintf(stderr, "%s: %s\n", str, msg);
MPI_Abort(MPI_COMM_WORLD, 1);
}
-#define CHECK(fn) { int errcode; errcode = (fn); if (errcode != MPI_SUCCESS) handle_error(errcode, #fn ); }
-int main(int argc, char** argv)
+#define CHECK(fn) { int errcode; errcode = (fn); if (errcode != MPI_SUCCESS) handle_error(errcode, #fn); }
+
+int main(int argc, char **argv)
{
MPI_File fh;
@@ -27,23 +28,23 @@ int main(int argc, char** argv)
int *data = NULL;
int *verify = NULL;
int data_size = DATA_SIZE;
- int i, j,k, nr_errors=0;
+ int i, j, k, nr_errors = 0;
MPI_Aint disp[BLK_COUNT];
int block_lens[BLK_COUNT];
- char* filename = "unnamed.dat";
+ char *filename = "unnamed.dat";
- MPI_Init (&argc, &argv);
- disp[0] = (MPI_Aint)(PAD);
- disp[1] = (MPI_Aint)(data_size*1 + PAD);
- disp[2] = (MPI_Aint)(data_size*2 + PAD);
+ MPI_Init(&argc, &argv);
+ disp[0] = (MPI_Aint) (PAD);
+ disp[1] = (MPI_Aint) (data_size * 1 + PAD);
+ disp[2] = (MPI_Aint) (data_size * 2 + PAD);
block_lens[0] = data_size;
block_lens[1] = data_size;
block_lens[2] = data_size;
data = malloc(data_size);
- verify = malloc(data_size*BLK_COUNT + HEADER + PAD);
- for(i=0 ; i<data_size/sizeof(int) ; i++)
+ verify = malloc(data_size * BLK_COUNT + HEADER + PAD);
+ for (i = 0; i < data_size / sizeof(int); i++)
data[i] = i;
MPI_Type_create_hindexed_block(BLK_COUNT, data_size, disp, MPI_BYTE, &file_type);
@@ -52,54 +53,51 @@ int main(int argc, char** argv)
MPI_Type_create_hvector(BLK_COUNT, data_size, 0, MPI_BYTE, &mem_type);
MPI_Type_commit(&mem_type);
- if( 1 < argc ) filename = argv[1];
+ if (1 < argc)
+ filename = argv[1];
- CHECK(MPI_File_open (MPI_COMM_WORLD, filename,
- MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_DELETE_ON_CLOSE,
- MPI_INFO_NULL, &fh) != 0);
+ CHECK(MPI_File_open(MPI_COMM_WORLD, filename,
+ MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_DELETE_ON_CLOSE,
+ MPI_INFO_NULL, &fh) != 0);
- CHECK(MPI_File_set_view(fh, HEADER, MPI_BYTE,
- file_type, "native", MPI_INFO_NULL));
+ CHECK(MPI_File_set_view(fh, HEADER, MPI_BYTE, file_type, "native", MPI_INFO_NULL));
/* write everything */
- CHECK(MPI_File_write_at_all (fh, 0,
- data, 1, mem_type,
- MPI_STATUS_IGNORE));
+ CHECK(MPI_File_write_at_all(fh, 0, data, 1, mem_type, MPI_STATUS_IGNORE));
/* verify */
- CHECK(MPI_File_set_view(fh, 0, MPI_BYTE, MPI_BYTE,
- "native", MPI_INFO_NULL));
+ CHECK(MPI_File_set_view(fh, 0, MPI_BYTE, MPI_BYTE, "native", MPI_INFO_NULL));
CHECK(MPI_File_read_at_all(fh, 0,
- verify, (HEADER+PAD+BLK_COUNT*DATA_SIZE)/sizeof(int), MPI_INT,
- MPI_STATUS_IGNORE));
+ verify, (HEADER + PAD + BLK_COUNT * DATA_SIZE) / sizeof(int),
+ MPI_INT, MPI_STATUS_IGNORE));
/* header and block padding should have no data */
- for (i=0; i<(HEADER+PAD)/sizeof(int); i++) {
- if (verify[i] != 0) {
- nr_errors++;
- fprintf(stderr, "expected 0, read %d\n", verify[i]);
- }
+ for (i = 0; i < (HEADER + PAD) / sizeof(int); i++) {
+ if (verify[i] != 0) {
+ nr_errors++;
+ fprintf(stderr, "expected 0, read %d\n", verify[i]);
+ }
}
/* blocks are replicated */
- for (j=0; j<BLK_COUNT; j++ ) {
- for (k=0; k<(DATA_SIZE/sizeof(int)); k++) {
- if (verify[(HEADER+PAD)/sizeof(int) + k + j*(DATA_SIZE/sizeof(int))] !=
- data[k]) {
- nr_errors++;
- fprintf(stderr, "expcted %d, read %d\n", data[k],
- verify[(HEADER+PAD)/sizeof(int) + k + j*(DATA_SIZE/sizeof(int))]);
- }
- i++;
- }
+ for (j = 0; j < BLK_COUNT; j++) {
+ for (k = 0; k < (DATA_SIZE / sizeof(int)); k++) {
+ if (verify[(HEADER + PAD) / sizeof(int) + k + j * (DATA_SIZE / sizeof(int))] != data[k]) {
+ nr_errors++;
+ fprintf(stderr, "expcted %d, read %d\n", data[k],
+ verify[(HEADER + PAD) / sizeof(int) + k + j * (DATA_SIZE / sizeof(int))]);
+ }
+ i++;
+ }
}
MPI_File_close(&fh);
- MPI_Type_free (&mem_type);
+ MPI_Type_free(&mem_type);
MPI_Type_free(&file_type);
- if (nr_errors == 0) printf(" No Errors\n");
+ if (nr_errors == 0)
+ printf(" No Errors\n");
- MPI_Finalize ();
+ MPI_Finalize();
free(data);
return 0;
diff --git a/test/mpi/io/i_aggregation1.c b/test/mpi/io/i_aggregation1.c
index 67d39f0..a2339f9 100644
--- a/test/mpi/io/i_aggregation1.c
+++ b/test/mpi/io/i_aggregation1.c
@@ -34,19 +34,18 @@ static void Usage(int line)
fprintf(stderr,
"Usage (line %d): %s [-d] [-h] -f filename\n"
"\t-d for debugging\n"
- "\t-h to turn on the hints to force collective aggregation\n",
- line, prog);
+ "\t-h to turn on the hints to force collective aggregation\n", line, prog);
}
exit(0);
}
-static void fatal_error(int mpi_ret, MPI_Status *mpi_stat, const char *msg)
+static void fatal_error(int mpi_ret, MPI_Status * mpi_stat, const char *msg)
{
fprintf(stderr, "Fatal error %s: %d\n", msg, mpi_ret);
MPI_Abort(MPI_COMM_WORLD, -1);
}
-static void print_hints(int rank, MPI_File *mfh)
+static void print_hints(int rank, MPI_File * mfh)
{
MPI_Info info;
int nkeys;
@@ -73,18 +72,18 @@ static void print_hints(int rank, MPI_File *mfh)
static void fill_buffer(char *buffer, int bufsize, int rank, MPI_Offset offset)
{
- memset((void *)buffer, 0, bufsize);
+ memset((void *) buffer, 0, bufsize);
snprintf(buffer, bufsize, "Hello from %d at %lld\n", rank, offset);
}
static MPI_Offset get_offset(int rank, int num_objs, int obj_size, int which_obj)
{
MPI_Offset offset;
- offset = (MPI_Offset)rank * num_objs * obj_size + which_obj * obj_size;
+ offset = (MPI_Offset) rank *num_objs * obj_size + which_obj * obj_size;
return offset;
}
-static void write_file(char *target, int rank, MPI_Info *info)
+static void write_file(char *target, int rank, MPI_Info * info)
{
MPI_File wfh;
MPI_Request *request;
@@ -93,15 +92,15 @@ static void write_file(char *target, int rank, MPI_Info *info)
int i;
char **buffer;
- request = (MPI_Request *)malloc(NUM_OBJS * sizeof(MPI_Request));
- mpi_stat = (MPI_Status *)malloc(NUM_OBJS * sizeof(MPI_Status));
- buffer = (char **)malloc(NUM_OBJS * sizeof(char *));
+ request = (MPI_Request *) malloc(NUM_OBJS * sizeof(MPI_Request));
+ mpi_stat = (MPI_Status *) malloc(NUM_OBJS * sizeof(MPI_Status));
+ buffer = (char **) malloc(NUM_OBJS * sizeof(char *));
- if (debug) printf("%d writing file %s\n", rank, target);
+ if (debug)
+ printf("%d writing file %s\n", rank, target);
if ((mpi_ret = MPI_File_open(MPI_COMM_WORLD, target,
- MPI_MODE_WRONLY | MPI_MODE_CREATE,
- *info, &wfh))
+ MPI_MODE_WRONLY | MPI_MODE_CREATE, *info, &wfh))
!= MPI_SUCCESS) {
fatal_error(mpi_ret, NULL, "open for write");
}
@@ -109,9 +108,10 @@ static void write_file(char *target, int rank, MPI_Info *info)
/* nonblocking collective write */
for (i = 0; i < NUM_OBJS; i++) {
MPI_Offset offset = get_offset(rank, NUM_OBJS, OBJ_SIZE, i);
- buffer[i] = (char *)malloc(OBJ_SIZE);
+ buffer[i] = (char *) malloc(OBJ_SIZE);
fill_buffer(buffer[i], OBJ_SIZE, rank, offset);
- if (debug) printf("%s", buffer[i]);
+ if (debug)
+ printf("%s", buffer[i]);
if ((mpi_ret = MPI_File_iwrite_at_all(wfh, offset, buffer[i], OBJ_SIZE,
MPI_CHAR, &request[i]))
!= MPI_SUCCESS) {
@@ -119,16 +119,19 @@ static void write_file(char *target, int rank, MPI_Info *info)
}
}
- if (debug) print_hints(rank, &wfh);
+ if (debug)
+ print_hints(rank, &wfh);
MPI_Waitall(NUM_OBJS, request, mpi_stat);
if ((mpi_ret = MPI_File_close(&wfh)) != MPI_SUCCESS) {
fatal_error(mpi_ret, NULL, "close for write");
}
- if (debug) printf("%d wrote file %s\n", rank, target);
+ if (debug)
+ printf("%d wrote file %s\n", rank, target);
- for (i = 0; i < NUM_OBJS; i++) free(buffer[i]);
+ for (i = 0; i < NUM_OBJS; i++)
+ free(buffer[i]);
free(buffer);
free(mpi_stat);
free(request);
@@ -145,7 +148,7 @@ static int reduce_corruptions(int corrupt_blocks)
return sum;
}
-static void read_file(char *target, int rank, MPI_Info *info, int *corrupt_blocks)
+static void read_file(char *target, int rank, MPI_Info * info, int *corrupt_blocks)
{
MPI_File rfh;
MPI_Offset *offset;
@@ -156,13 +159,14 @@ static void read_file(char *target, int rank, MPI_Info *info, int *corrupt_block
char **buffer;
char **verify_buf = NULL;
- offset = (MPI_Offset *)malloc(NUM_OBJS * sizeof(MPI_Offset));
- request = (MPI_Request *)malloc(NUM_OBJS * sizeof(MPI_Request));
- mpi_stat = (MPI_Status *)malloc(NUM_OBJS * sizeof(MPI_Status));
- buffer = (char **)malloc(NUM_OBJS * sizeof(char *));
- verify_buf = (char **)malloc(NUM_OBJS * sizeof(char *));
+ offset = (MPI_Offset *) malloc(NUM_OBJS * sizeof(MPI_Offset));
+ request = (MPI_Request *) malloc(NUM_OBJS * sizeof(MPI_Request));
+ mpi_stat = (MPI_Status *) malloc(NUM_OBJS * sizeof(MPI_Status));
+ buffer = (char **) malloc(NUM_OBJS * sizeof(char *));
+ verify_buf = (char **) malloc(NUM_OBJS * sizeof(char *));
- if (debug) printf("%d reading file %s\n", rank, target);
+ if (debug)
+ printf("%d reading file %s\n", rank, target);
if ((mpi_ret = MPI_File_open(MPI_COMM_WORLD, target, MPI_MODE_RDONLY,
*info, &rfh)) != MPI_SUCCESS) {
@@ -172,10 +176,11 @@ static void read_file(char *target, int rank, MPI_Info *info, int *corrupt_block
/* nonblocking collective read */
for (i = 0; i < NUM_OBJS; i++) {
offset[i] = get_offset(rank, NUM_OBJS, OBJ_SIZE, i);
- buffer[i] = (char *)malloc(OBJ_SIZE);
- verify_buf[i] = (char *)malloc(OBJ_SIZE);
+ buffer[i] = (char *) malloc(OBJ_SIZE);
+ verify_buf[i] = (char *) malloc(OBJ_SIZE);
fill_buffer(verify_buf[i], OBJ_SIZE, rank, offset[i]);
- if (debug) printf("Expecting %s", verify_buf[i]);
+ if (debug)
+ printf("Expecting %s", verify_buf[i]);
if ((mpi_ret = MPI_File_iread_at_all(rfh, offset[i], buffer[i],
OBJ_SIZE, MPI_CHAR, &request[i]))
!= MPI_SUCCESS) {
@@ -191,8 +196,7 @@ static void read_file(char *target, int rank, MPI_Info *info, int *corrupt_block
(*corrupt_blocks)++;
printf("Corruption at %lld\n", offset[i]);
if (debug) {
- printf("\tExpecting %s\n" "\tRecieved %s\n",
- verify_buf[i], buffer[i]);
+ printf("\tExpecting %s\n" "\tRecieved %s\n", verify_buf[i], buffer[i]);
}
}
}
@@ -212,7 +216,7 @@ static void read_file(char *target, int rank, MPI_Info *info, int *corrupt_block
free(offset);
}
-static void set_hints(MPI_Info *info)
+static void set_hints(MPI_Info * info)
{
MPI_Info_set(*info, "romio_cb_write", "enable");
MPI_Info_set(*info, "romio_no_indep_rw", "1");
@@ -254,7 +258,8 @@ int main(int argc, char *argv[])
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if ((mpi_ret = MPI_Info_create(&info)) != MPI_SUCCESS) {
- if (rank == 0) fatal_error(mpi_ret, NULL, "MPI_info_create.\n");
+ if (rank == 0)
+ fatal_error(mpi_ret, NULL, "MPI_info_create.\n");
}
prog = strdup(argv[0]);
@@ -278,7 +283,8 @@ int main(int argc, char *argv[])
if (!target) {
Usage(__LINE__);
}
- } else {
+ }
+ else {
target = "testfile";
set_hints(&info);
}
@@ -292,8 +298,7 @@ int main(int argc, char *argv[])
fprintf(stdout, " No Errors\n");
}
else {
- fprintf(stdout, "%d/%d blocks corrupt\n", corrupt_blocks,
- nproc * NUM_OBJS);
+ fprintf(stdout, "%d/%d blocks corrupt\n", corrupt_blocks, nproc * NUM_OBJS);
}
}
MPI_Info_free(&info);
diff --git a/test/mpi/io/i_aggregation2.c b/test/mpi/io/i_aggregation2.c
index 99b0be4..bf92aba 100644
--- a/test/mpi/io/i_aggregation2.c
+++ b/test/mpi/io/i_aggregation2.c
@@ -57,25 +57,27 @@ int main(int argc, char **argv)
}
off = rank * sizeof(buffer);
- errcode = MPI_File_open(MPI_COMM_WORLD, filename,
- MPI_MODE_WRONLY | MPI_MODE_CREATE, info, &fh);
- if (errcode != MPI_SUCCESS) handle_error(errcode, "MPI_File_open");
- errcode = MPI_File_iwrite_at_all(fh, off, buffer, BUFSIZE, MPI_INT,
- &request);
- if (errcode != MPI_SUCCESS) handle_error(errcode, "MPI_File_iwrite_at_all");
+ errcode = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_WRONLY | MPI_MODE_CREATE, info, &fh);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_open");
+ errcode = MPI_File_iwrite_at_all(fh, off, buffer, BUFSIZE, MPI_INT, &request);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_iwrite_at_all");
MPI_Wait(&request, &status);
errcode = MPI_File_close(&fh);
- if (errcode != MPI_SUCCESS) handle_error(errcode, "MPI_File_close");
-
- errcode = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, info,
- &fh);
- if (errcode != MPI_SUCCESS) handle_error(errcode, "MPI_File_open");
- errcode = MPI_File_iread_at_all(fh, off, buf2, BUFSIZE, MPI_INT,
- &request);
- if (errcode != MPI_SUCCESS) handle_error(errcode, "MPI_File_iread_at_all");
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_close");
+
+ errcode = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, info, &fh);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_open");
+ errcode = MPI_File_iread_at_all(fh, off, buf2, BUFSIZE, MPI_INT, &request);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_iread_at_all");
MPI_Wait(&request, &status);
errcode = MPI_File_close(&fh);
- if (errcode != MPI_SUCCESS) handle_error(errcode, "MPI_File_close");
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_close");
for (i = 0; i < BUFSIZE; i++) {
if (buf2[i] != 10000 + rank)
diff --git a/test/mpi/io/i_bigtype.c b/test/mpi/io/i_bigtype.c
index 35aa8de..90d9234 100644
--- a/test/mpi/io/i_bigtype.c
+++ b/test/mpi/io/i_bigtype.c
@@ -47,7 +47,7 @@ int main(int argc, char **argv)
/* create a large buffer 2 */
buf_write = malloc(NUM_X * NUM_Y * sizeof(int));
buf_read = malloc(NUM_X * NUM_Y * sizeof(int));
- if (buf_write == NULL || buf_read == NULL ) {
+ if (buf_write == NULL || buf_read == NULL) {
fprintf(stderr, "Not enough memory\n");
exit(1);
}
@@ -96,8 +96,7 @@ int main(int argc, char **argv)
exit(1);
}
- rc = MPI_File_set_view(fh, 2144, MPI_BYTE, file_type, "native",
- MPI_INFO_NULL);
+ rc = MPI_File_set_view(fh, 2144, MPI_BYTE, file_type, "native", MPI_INFO_NULL);
if (rc != MPI_SUCCESS) {
fprintf(stderr, "ERROR SET VIEW\n");
exit(1);
@@ -111,8 +110,7 @@ int main(int argc, char **argv)
}
MPI_Wait(&request, &status);
- rc = MPI_File_set_view(fh, 2144, MPI_BYTE, file_type, "native",
- MPI_INFO_NULL);
+ rc = MPI_File_set_view(fh, 2144, MPI_BYTE, file_type, "native", MPI_INFO_NULL);
if (rc != MPI_SUCCESS) {
fprintf(stderr, "ERROR SET VIEW\n");
exit(1);
diff --git a/test/mpi/io/i_coll_test.c b/test/mpi/io/i_coll_test.c
index 5f65cc5..b43c56c 100644
--- a/test/mpi/io/i_coll_test.c
+++ b/test/mpi/io/i_coll_test.c
@@ -57,7 +57,7 @@ int main(int argc, char **argv)
}
else {
MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
- filename = (char *)malloc(len + 1);
+ filename = (char *) malloc(len + 1);
MPI_Bcast(filename, len + 1, MPI_CHAR, 0, MPI_COMM_WORLD);
}
@@ -78,7 +78,8 @@ int main(int argc, char **argv)
array_of_dargs[1] = MPI_DISTRIBUTE_DFLT_DARG;
array_of_dargs[2] = MPI_DISTRIBUTE_DFLT_DARG;
- for (i = 0; i < ndims; i++) array_of_psizes[i] = 0;
+ for (i = 0; i < ndims; i++)
+ array_of_psizes[i] = 0;
MPI_Dims_create(nprocs, ndims, array_of_psizes);
MPI_Type_create_darray(nprocs, mynod, ndims, array_of_gsizes,
@@ -90,8 +91,9 @@ int main(int argc, char **argv)
MPI_Type_size_x(newtype, &bufcount);
bufcount = bufcount / sizeof(int);
- writebuf = (int *)malloc(bufcount * sizeof(int));
- for (i = 0; i < bufcount; i++) writebuf[i] = 1;
+ writebuf = (int *) malloc(bufcount * sizeof(int));
+ for (i = 0; i < bufcount; i++)
+ writebuf[i] = 1;
array_size = array_of_gsizes[0] * array_of_gsizes[1] * array_of_gsizes[2];
tmpbuf = (int *) calloc(array_size, sizeof(int));
@@ -108,47 +110,50 @@ int main(int argc, char **argv)
free(tmpbuf);
if (j != bufcount) {
- fprintf(stderr, "Error in initializing writebuf on process %d\n",
- mynod);
+ fprintf(stderr, "Error in initializing writebuf on process %d\n", mynod);
MPI_Abort(MPI_COMM_WORLD, 1);
}
/* end of initialization */
/* write the array to the file */
- errcode = MPI_File_open(MPI_COMM_WORLD, filename,
- MPI_MODE_CREATE | MPI_MODE_RDWR, info, &fh);
- if (errcode != MPI_SUCCESS) handle_error(errcode, "MPI_File_open");
+ errcode = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, info, &fh);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_open");
errcode = MPI_File_set_view(fh, 0, MPI_INT, newtype, "native", info);
- if (errcode != MPI_SUCCESS) handle_error(errcode, "MPI_File_set_view");
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_set_view");
errcode = MPI_File_iwrite_all(fh, writebuf, bufcount, MPI_INT, &request);
- if (errcode != MPI_SUCCESS) handle_error(errcode, "MPI_File_iwrite_all");
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_iwrite_all");
MPI_Wait(&request, &status);
errcode = MPI_File_close(&fh);
- if (errcode != MPI_SUCCESS) handle_error(errcode, "MPI_File_close");
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_close");
if (!mynod) {
/* wkl suggests potential for false " No Errors" if both read
* and write use the same file view */
/* solution: rank 0 reads entire file and checks write values */
- errcode = MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_RDONLY, info,
- &fh);
- if (errcode != MPI_SUCCESS) handle_error(errcode, "MPI_File_open");
+ errcode = MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_RDONLY, info, &fh);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_open");
- readbuf = (int *)malloc(array_size * sizeof(int));
+ readbuf = (int *) malloc(array_size * sizeof(int));
errcode = MPI_File_read(fh, readbuf, array_size, MPI_INT, &status);
- if (errcode != MPI_SUCCESS) handle_error(errcode, "MPI_File_read");
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_read");
errcode = MPI_File_close(&fh);
- if (errcode != MPI_SUCCESS) handle_error(errcode, "MPI_File_close");
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_close");
for (i = 0; i < array_size; i++)
if (readbuf[i] != i) {
errs++;
- fprintf(stderr, "Error: write integer %d but read %d\n",
- i, readbuf[i]);
+ fprintf(stderr, "Error: write integer %d but read %d\n", i, readbuf[i]);
break;
}
free(readbuf);
@@ -156,18 +161,21 @@ int main(int argc, char **argv)
MPI_Barrier(MPI_COMM_WORLD);
/* now read it back */
- readbuf = (int *)malloc(bufcount * sizeof(int));
- errcode = MPI_File_open(MPI_COMM_WORLD, filename,
- MPI_MODE_CREATE | MPI_MODE_RDWR, info, &fh);
- if (errcode != MPI_SUCCESS) handle_error(errcode, "MPI_File_open");
+ readbuf = (int *) malloc(bufcount * sizeof(int));
+ errcode = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, info, &fh);
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_open");
errcode = MPI_File_set_view(fh, 0, MPI_INT, newtype, "native", info);
- if (errcode != MPI_SUCCESS) handle_error(errcode, "MPI_File_set_view");
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_set_view");
errcode = MPI_File_iread_all(fh, readbuf, bufcount, MPI_INT, &request);
- if (errcode != MPI_SUCCESS) handle_error(errcode, "MPI_File_iread_all");
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_iread_all");
MPI_Wait(&request, &status);
errcode = MPI_File_close(&fh);
- if (errcode != MPI_SUCCESS) handle_error(errcode, "MPI_File_close");
+ if (errcode != MPI_SUCCESS)
+ handle_error(errcode, "MPI_File_close");
/* check the data read */
for (i = 0; i < bufcount; i++) {
@@ -191,7 +199,8 @@ int main(int argc, char **argv)
MPI_Type_free(&newtype);
free(readbuf);
free(writebuf);
- if (mynod) free(filename);
+ if (mynod)
+ free(filename);
MPI_Finalize();
return 0;
diff --git a/test/mpi/io/i_darray_read.c b/test/mpi/io/i_darray_read.c
index 8fc970d..bde03ce 100644
--- a/test/mpi/io/i_darray_read.c
+++ b/test/mpi/io/i_darray_read.c
@@ -60,26 +60,25 @@ int main(int argc, char *argv[])
/* Set up type */
CHECK(MPI_Type_create_darray(size, rank, 2, gsize, distrib,
- bsize, psize, MPI_ORDER_FORTRAN, MPI_DOUBLE,
- &darray));
+ bsize, psize, MPI_ORDER_FORTRAN, MPI_DOUBLE, &darray));
CHECK(MPI_Type_commit(&darray));
CHECK(MPI_Type_size(darray, &tsize));
nelem = tsize / sizeof(double);
- for (i = 0; i < (NSIDE * NSIDE); i++) data[i] = i;
+ for (i = 0; i < (NSIDE * NSIDE); i++)
+ data[i] = i;
if (rank == 0) {
CHECK(MPI_File_open(MPI_COMM_SELF, filename,
- MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL,
- &dfile));
+ MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &dfile));
CHECK(MPI_File_write(dfile, data, NSIDE * NSIDE, MPI_DOUBLE, &status));
CHECK(MPI_File_close(&dfile));
}
MPI_Barrier(MPI_COMM_WORLD);
/* Allocate buffer */
- ldata = (double *)malloc(tsize);
- pdata = (double *)malloc(tsize);
+ ldata = (double *) malloc(tsize);
+ pdata = (double *) malloc(tsize);
/* Use Pack to pull out array */
bpos = 0;
@@ -88,10 +87,8 @@ int main(int argc, char *argv[])
MPI_Barrier(MPI_COMM_WORLD);
/* Read in array from file. */
- CHECK(MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY,
- MPI_INFO_NULL, &mpi_fh));
- CHECK(MPI_File_set_view(mpi_fh, 0, MPI_DOUBLE, darray, "native",
- MPI_INFO_NULL));
+ CHECK(MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, MPI_INFO_NULL, &mpi_fh));
+ CHECK(MPI_File_set_view(mpi_fh, 0, MPI_DOUBLE, darray, "native", MPI_INFO_NULL));
CHECK(MPI_File_iread_all(mpi_fh, ldata, nelem, MPI_DOUBLE, &request));
CHECK(MPI_Wait(&request, &status));
CHECK(MPI_File_close(&mpi_fh));
diff --git a/test/mpi/io/i_hindexed.c b/test/mpi/io/i_hindexed.c
index 93471eb..315084c 100644
--- a/test/mpi/io/i_hindexed.c
+++ b/test/mpi/io/i_hindexed.c
@@ -82,8 +82,8 @@ int main(int argc, char **argv)
num_io = 2;
- request = (MPI_Request *)malloc(num_io * sizeof(MPI_Request));
- statuses = (MPI_Status *)malloc(num_io * sizeof(MPI_Status));
+ request = (MPI_Request *) malloc(num_io * sizeof(MPI_Request));
+ statuses = (MPI_Status *) malloc(num_io * sizeof(MPI_Status));
/*-----------------------------------------------------------------------*/
/* process rank in each dimension */
@@ -103,16 +103,15 @@ int main(int argc, char **argv)
/* define data type for file view */
count = array_of_subsizes[0] * 2; /* 2 is the no. blocks along X */
- blocklengths = (int *)malloc(count * sizeof(int));
- displacements = (MPI_Aint *)malloc(count * sizeof(MPI_Aint));
+ blocklengths = (int *) malloc(count * sizeof(int));
+ displacements = (MPI_Aint *) malloc(count * sizeof(MPI_Aint));
for (i = 0; i < count; i++)
blocklengths[i] = array_of_subsizes[1] / 2;
for (i = 0; i < array_of_subsizes[0]; i++)
for (j = 0; j < 2; j++)
displacements[i * 2 + j] = offset + i * 2 * array_of_sizes[1]
- + j * XLEN / 2;
- MPI_Type_create_hindexed(count, blocklengths, displacements, MPI_CHAR,
- &ftype);
+ + j * XLEN / 2;
+ MPI_Type_create_hindexed(count, blocklengths, displacements, MPI_CHAR, &ftype);
MPI_Type_commit(&ftype);
MPI_Type_size_x(ftype, &ftype_size);
@@ -146,17 +145,16 @@ int main(int argc, char **argv)
*/
/* initialize the write buffer */
- buf = (char *)malloc(array_of_subsizes[0] * array_of_subsizes[1]);
+ buf = (char *) malloc(array_of_subsizes[0] * array_of_subsizes[1]);
for (i = 0; i < array_of_subsizes[0] * array_of_subsizes[1]; i++)
buf[i] = '0' + rank * 20 + i % 79;
/* zero file contents --------------------------------------------------- */
if (rank == 0) {
- char *wr_buf = (char *)calloc(num_io * global_array_size, 1);
+ char *wr_buf = (char *) calloc(num_io * global_array_size, 1);
MPI_File_open(MPI_COMM_SELF, filename,
MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &fh);
- MPI_File_write(fh, wr_buf, num_io * global_array_size, MPI_CHAR,
- &status);
+ MPI_File_write(fh, wr_buf, num_io * global_array_size, MPI_CHAR, &status);
MPI_File_close(&fh);
free(wr_buf);
}
@@ -182,9 +180,8 @@ int main(int argc, char **argv)
/* read and print file contents ----------------------------------------- */
if (rank == 0) {
char *ptr;
- char *rd_buf = (char *)calloc(num_io * global_array_size, 1);
- MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_RDONLY, MPI_INFO_NULL,
- &fh);
+ char *rd_buf = (char *) calloc(num_io * global_array_size, 1);
+ MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_RDONLY, MPI_INFO_NULL, &fh);
MPI_File_read(fh, rd_buf, num_io * global_array_size, MPI_CHAR, &status);
MPI_File_close(&fh);
diff --git a/test/mpi/io/i_hindexed_io.c b/test/mpi/io/i_hindexed_io.c
index 40e9f99..9b99e04 100644
--- a/test/mpi/io/i_hindexed_io.c
+++ b/test/mpi/io/i_hindexed_io.c
@@ -53,8 +53,7 @@ int main(int argc, char **argv)
for (i = 0; i < data_size / sizeof(int); i++)
data[i] = i;
- MPI_Type_create_hindexed_block(BLK_COUNT, data_size, disp, MPI_BYTE,
- &file_type);
+ MPI_Type_create_hindexed_block(BLK_COUNT, data_size, disp, MPI_BYTE, &file_type);
MPI_Type_commit(&file_type);
MPI_Type_create_hvector(BLK_COUNT, data_size, 0, MPI_BYTE, &mem_type);
@@ -64,22 +63,20 @@ int main(int argc, char **argv)
filename = argv[1];
CHECK(MPI_File_open(MPI_COMM_WORLD, filename,
- MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_DELETE_ON_CLOSE,
- MPI_INFO_NULL, &fh) != 0);
+ MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_DELETE_ON_CLOSE,
+ MPI_INFO_NULL, &fh) != 0);
- CHECK(MPI_File_set_view(fh, HEADER, MPI_BYTE, file_type, "native",
- MPI_INFO_NULL));
+ CHECK(MPI_File_set_view(fh, HEADER, MPI_BYTE, file_type, "native", MPI_INFO_NULL));
/* write everything */
CHECK(MPI_File_iwrite_at_all(fh, 0, data, 1, mem_type, &request));
MPI_Wait(&request, &status);
/* verify */
- CHECK(MPI_File_set_view(fh, 0, MPI_BYTE, MPI_BYTE, "native",
- MPI_INFO_NULL));
+ CHECK(MPI_File_set_view(fh, 0, MPI_BYTE, MPI_BYTE, "native", MPI_INFO_NULL));
CHECK(MPI_File_iread_at_all(fh, 0,
- verify, (HEADER + PAD + BLK_COUNT * DATA_SIZE) / sizeof(int),
- MPI_INT, &request));
+ verify, (HEADER + PAD + BLK_COUNT * DATA_SIZE) / sizeof(int),
+ MPI_INT, &request));
MPI_Wait(&request, &status);
/* header and block padding should have no data */
@@ -92,12 +89,11 @@ int main(int argc, char **argv)
/* blocks are replicated */
for (j = 0; j < BLK_COUNT; j++) {
for (k = 0; k < (DATA_SIZE / sizeof(int)); k++) {
- if (verify[(HEADER+PAD)/sizeof(int) + k + j*(DATA_SIZE/sizeof(int))]
+ if (verify[(HEADER + PAD) / sizeof(int) + k + j * (DATA_SIZE / sizeof(int))]
!= data[k]) {
nr_errors++;
fprintf(stderr, "expcted %d, read %d\n", data[k],
- verify[(HEADER+PAD)/sizeof(int) + k +
- j*(DATA_SIZE/sizeof(int))]);
+ verify[(HEADER + PAD) / sizeof(int) + k + j * (DATA_SIZE / sizeof(int))]);
}
i++;
}
diff --git a/test/mpi/io/i_noncontig.c b/test/mpi/io/i_noncontig.c
index 735db4d..d1c9c73 100644
--- a/test/mpi/io/i_noncontig.c
+++ b/test/mpi/io/i_noncontig.c
@@ -1,5 +1,5 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
-/*
+/*
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
@@ -22,7 +22,7 @@ static char MTEST_Descrip[] = "Test nonblocking I/O";
int main(int argc, char **argv)
{
int *buf, i, mynod, nprocs, len, b[3];
- int errs=0;
+ int errs = 0;
MPI_Aint d[3];
MPI_File fh;
MPI_Status status;
@@ -30,7 +30,7 @@ int main(int argc, char **argv)
MPI_Datatype typevec, newtype, t[3];
MPI_Request req;
- MTest_Init(&argc,&argv);
+ MTest_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &mynod);
@@ -39,46 +39,46 @@ int main(int argc, char **argv)
MPI_Abort(MPI_COMM_WORLD, 1);
}
-/* process 0 takes the file name as a command-line argument and
+/* process 0 takes the file name as a command-line argument and
broadcasts it to other processes */
if (!mynod) {
- i = 1;
- while ((i < argc) && strcmp("-fname", *argv)) {
- i++;
- argv++;
- }
- if (i >= argc) {
- len = 8;
- filename = (char *)malloc(len + 10);
- strcpy( filename, "testfile" );
- /*
- fprintf(stderr, "\n*# Usage: i_noncontig -fname filename\n\n");
- MPI_Abort(MPI_COMM_WORLD, 1);
- */
- }
- else {
- argv++;
- len = (int)strlen(*argv);
- filename = (char *) malloc(len+1);
- strcpy(filename, *argv);
- }
- MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
- MPI_Bcast(filename, len+1, MPI_CHAR, 0, MPI_COMM_WORLD);
+ i = 1;
+ while ((i < argc) && strcmp("-fname", *argv)) {
+ i++;
+ argv++;
+ }
+ if (i >= argc) {
+ len = 8;
+ filename = (char *) malloc(len + 10);
+ strcpy(filename, "testfile");
+ /*
+ * fprintf(stderr, "\n*# Usage: i_noncontig -fname filename\n\n");
+ * MPI_Abort(MPI_COMM_WORLD, 1);
+ */
+ }
+ else {
+ argv++;
+ len = (int) strlen(*argv);
+ filename = (char *) malloc(len + 1);
+ strcpy(filename, *argv);
+ }
+ MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ MPI_Bcast(filename, len + 1, MPI_CHAR, 0, MPI_COMM_WORLD);
}
else {
- MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
- filename = (char *) malloc(len+1);
- MPI_Bcast(filename, len+1, MPI_CHAR, 0, MPI_COMM_WORLD);
+ MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
+ filename = (char *) malloc(len + 1);
+ MPI_Bcast(filename, len + 1, MPI_CHAR, 0, MPI_COMM_WORLD);
}
- buf = (int *) malloc(SIZE*sizeof(int));
+ buf = (int *) malloc(SIZE * sizeof(int));
- MPI_Type_vector(SIZE/2, 1, 2, MPI_INT, &typevec);
+ MPI_Type_vector(SIZE / 2, 1, 2, MPI_INT, &typevec);
b[0] = b[1] = b[2] = 1;
d[0] = 0;
- d[1] = mynod*sizeof(int);
- d[2] = SIZE*sizeof(int);
+ d[1] = mynod * sizeof(int);
+ d[2] = SIZE * sizeof(int);
t[0] = MPI_LB;
t[1] = typevec;
t[2] = MPI_UB;
@@ -89,53 +89,52 @@ int main(int argc, char **argv)
if (!mynod) {
#if VERBOSE
- fprintf(stderr, "\ntesting noncontiguous in memory, noncontiguous in file using nonblocking I/O\n");
+ fprintf(stderr,
+ "\ntesting noncontiguous in memory, noncontiguous in file using nonblocking I/O\n");
#endif
- MPI_File_delete(filename, MPI_INFO_NULL);
+ MPI_File_delete(filename, MPI_INFO_NULL);
}
MPI_Barrier(MPI_COMM_WORLD);
- MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE |
- MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
- MPI_File_set_view(fh, 0, MPI_INT, newtype, (char*)"native", MPI_INFO_NULL);
+ MPI_File_set_view(fh, 0, MPI_INT, newtype, (char *) "native", MPI_INFO_NULL);
- for (i=0; i<SIZE; i++) buf[i] = i + mynod*SIZE;
+ for (i = 0; i < SIZE; i++)
+ buf[i] = i + mynod * SIZE;
MPI_File_iwrite(fh, buf, 1, newtype, &req);
MPI_Wait(&req, &status);
MPI_Barrier(MPI_COMM_WORLD);
- for (i=0; i<SIZE; i++) buf[i] = -1;
+ for (i = 0; i < SIZE; i++)
+ buf[i] = -1;
MPI_File_iread_at(fh, 0, buf, 1, newtype, &req);
MPI_Wait(&req, &status);
- for (i=0; i<SIZE; i++) {
- if (!mynod) {
- if ((i%2) && (buf[i] != -1)) {
- errs++;
- fprintf(stderr, "Process %d: buf %d is %d, should be -1\n",
- mynod, i, buf[i]);
- }
- if (!(i%2) && (buf[i] != i)) {
- errs++;
- fprintf(stderr, "Process %d: buf %d is %d, should be %d\n",
- mynod, i, buf[i], i);
- }
- }
- else {
- if ((i%2) && (buf[i] != i + mynod*SIZE)) {
- errs++;
- fprintf(stderr, "Process %d: buf %d is %d, should be %d\n",
- mynod, i, buf[i], i + mynod*SIZE);
- }
- if (!(i%2) && (buf[i] != -1)) {
- errs++;
- fprintf(stderr, "Process %d: buf %d is %d, should be -1\n",
- mynod, i, buf[i]);
- }
- }
+ for (i = 0; i < SIZE; i++) {
+ if (!mynod) {
+ if ((i % 2) && (buf[i] != -1)) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be -1\n", mynod, i, buf[i]);
+ }
+ if (!(i % 2) && (buf[i] != i)) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be %d\n", mynod, i, buf[i], i);
+ }
+ }
+ else {
+ if ((i % 2) && (buf[i] != i + mynod * SIZE)) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be %d\n",
+ mynod, i, buf[i], i + mynod * SIZE);
+ }
+ if (!(i % 2) && (buf[i] != -1)) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be -1\n", mynod, i, buf[i]);
+ }
+ }
}
MPI_File_close(&fh);
@@ -144,51 +143,50 @@ int main(int argc, char **argv)
if (!mynod) {
#if VERBOSE
- fprintf(stderr, "\ntesting noncontiguous in memory, contiguous in file using nonblocking I/O\n");
+ fprintf(stderr,
+ "\ntesting noncontiguous in memory, contiguous in file using nonblocking I/O\n");
#endif
- MPI_File_delete(filename, MPI_INFO_NULL);
+ MPI_File_delete(filename, MPI_INFO_NULL);
}
MPI_Barrier(MPI_COMM_WORLD);
- MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE |
- MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
- for (i=0; i<SIZE; i++) buf[i] = i + mynod*SIZE;
- MPI_File_iwrite_at(fh, mynod*(SIZE/2)*sizeof(int), buf, 1, newtype, &req);
+ for (i = 0; i < SIZE; i++)
+ buf[i] = i + mynod * SIZE;
+ MPI_File_iwrite_at(fh, mynod * (SIZE / 2) * sizeof(int), buf, 1, newtype, &req);
MPI_Wait(&req, &status);
MPI_Barrier(MPI_COMM_WORLD);
- for (i=0; i<SIZE; i++) buf[i] = -1;
+ for (i = 0; i < SIZE; i++)
+ buf[i] = -1;
- MPI_File_iread_at(fh, mynod*(SIZE/2)*sizeof(int), buf, 1, newtype, &req);
+ MPI_File_iread_at(fh, mynod * (SIZE / 2) * sizeof(int), buf, 1, newtype, &req);
MPI_Wait(&req, &status);
- for (i=0; i<SIZE; i++) {
- if (!mynod) {
- if ((i%2) && (buf[i] != -1)) {
- errs++;
- fprintf(stderr, "Process %d: buf %d is %d, should be -1\n",
- mynod, i, buf[i]);
- }
- if (!(i%2) && (buf[i] != i)) {
- errs++;
- fprintf(stderr, "Process %d: buf %d is %d, should be %d\n",
- mynod, i, buf[i], i);
- }
- }
- else {
- if ((i%2) && (buf[i] != i + mynod*SIZE)) {
- errs++;
- fprintf(stderr, "Process %d: buf %d is %d, should be %d\n",
- mynod, i, buf[i], i + mynod*SIZE);
- }
- if (!(i%2) && (buf[i] != -1)) {
- errs++;
- fprintf(stderr, "Process %d: buf %d is %d, should be -1\n",
- mynod, i, buf[i]);
- }
- }
+ for (i = 0; i < SIZE; i++) {
+ if (!mynod) {
+ if ((i % 2) && (buf[i] != -1)) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be -1\n", mynod, i, buf[i]);
+ }
+ if (!(i % 2) && (buf[i] != i)) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be %d\n", mynod, i, buf[i], i);
+ }
+ }
+ else {
+ if ((i % 2) && (buf[i] != i + mynod * SIZE)) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be %d\n",
+ mynod, i, buf[i], i + mynod * SIZE);
+ }
+ if (!(i % 2) && (buf[i] != -1)) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be -1\n", mynod, i, buf[i]);
+ }
+ }
}
MPI_File_close(&fh);
@@ -197,43 +195,44 @@ int main(int argc, char **argv)
if (!mynod) {
#if VERBOSE
- fprintf(stderr, "\ntesting contiguous in memory, noncontiguous in file using nonblocking I/O\n");
+ fprintf(stderr,
+ "\ntesting contiguous in memory, noncontiguous in file using nonblocking I/O\n");
#endif
- MPI_File_delete(filename, MPI_INFO_NULL);
+ MPI_File_delete(filename, MPI_INFO_NULL);
}
MPI_Barrier(MPI_COMM_WORLD);
- MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE |
- MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
- MPI_File_set_view(fh, 0, MPI_INT, newtype, (char*)"native", MPI_INFO_NULL);
+ MPI_File_set_view(fh, 0, MPI_INT, newtype, (char *) "native", MPI_INFO_NULL);
- for (i=0; i<SIZE; i++) buf[i] = i + mynod*SIZE;
+ for (i = 0; i < SIZE; i++)
+ buf[i] = i + mynod * SIZE;
MPI_File_iwrite(fh, buf, SIZE, MPI_INT, &req);
MPI_Wait(&req, &status);
MPI_Barrier(MPI_COMM_WORLD);
- for (i=0; i<SIZE; i++) buf[i] = -1;
+ for (i = 0; i < SIZE; i++)
+ buf[i] = -1;
MPI_File_iread_at(fh, 0, buf, SIZE, MPI_INT, &req);
MPI_Wait(&req, &status);
- for (i=0; i<SIZE; i++) {
- if (!mynod) {
- if (buf[i] != i) {
- errs++;
- fprintf(stderr, "Process %d: buf %d is %d, should be %d\n",
- mynod, i, buf[i], i);
- }
- }
- else {
- if (buf[i] != i + mynod*SIZE) {
- errs++;
- fprintf(stderr, "Process %d: buf %d is %d, should be %d\n",
- mynod, i, buf[i], i + mynod*SIZE);
- }
- }
+ for (i = 0; i < SIZE; i++) {
+ if (!mynod) {
+ if (buf[i] != i) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be %d\n", mynod, i, buf[i], i);
+ }
+ }
+ else {
+ if (buf[i] != i + mynod * SIZE) {
+ errs++;
+ fprintf(stderr, "Process %d: buf %d is %d, should be %d\n",
+ mynod, i, buf[i], i + mynod * SIZE);
+ }
+ }
}
MPI_File_close(&fh);
diff --git a/test/mpi/io/i_noncontig_coll.c b/test/mpi/io/i_noncontig_coll.c
index 474023d..a7d9cbb 100644
--- a/test/mpi/io/i_noncontig_coll.c
+++ b/test/mpi/io/i_noncontig_coll.c
@@ -43,11 +43,11 @@ int main(int argc, char **argv)
}
else {
MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
- filename = (char *)malloc(len + 1);
+ filename = (char *) malloc(len + 1);
MPI_Bcast(filename, len + 1, MPI_CHAR, 0, MPI_COMM_WORLD);
}
- buf = (int *)malloc(SIZE * sizeof(int));
+ buf = (int *) malloc(SIZE * sizeof(int));
MPI_Type_vector(SIZE / 2, 1, 2, MPI_INT, &typevec);
@@ -66,14 +66,13 @@ int main(int argc, char **argv)
if (!mynod) {
#if VERBOSE
fprintf(stderr, "\ntesting noncontiguous in memory, noncontiguous in "
- "file using collective I/O\n");
+ "file using collective I/O\n");
#endif
MPI_File_delete(filename, MPI_INFO_NULL);
}
MPI_Barrier(MPI_COMM_WORLD);
- MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR,
- MPI_INFO_NULL, &fh);
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
MPI_File_set_view(fh, 0, MPI_INT, newtype, "native", MPI_INFO_NULL);
@@ -94,13 +93,11 @@ int main(int argc, char **argv)
if (!mynod) {
if ((i % 2) && (buf[i] != -1)) {
errs++;
- fprintf(stderr, "Process %d: buf %d is %d, should be -1\n",
- mynod, i, buf[i]);
+ fprintf(stderr, "Process %d: buf %d is %d, should be -1\n", mynod, i, buf[i]);
}
if (!(i % 2) && (buf[i] != i)) {
errs++;
- fprintf(stderr, "Process %d: buf %d is %d, should be %d\n",
- mynod, i, buf[i], i);
+ fprintf(stderr, "Process %d: buf %d is %d, should be %d\n", mynod, i, buf[i], i);
}
}
else {
@@ -111,8 +108,7 @@ int main(int argc, char **argv)
}
if (!(i % 2) && (buf[i] != -1)) {
errs++;
- fprintf(stderr, "Process %d: buf %d is %d, should be -1\n",
- mynod, i, buf[i]);
+ fprintf(stderr, "Process %d: buf %d is %d, should be -1\n", mynod, i, buf[i]);
}
}
}
@@ -124,39 +120,36 @@ int main(int argc, char **argv)
if (!mynod) {
#if VERBOSE
fprintf(stderr, "\ntesting noncontiguous in memory, contiguous in file "
- "using collective I/O\n");
+ "using collective I/O\n");
#endif
MPI_File_delete(filename, MPI_INFO_NULL);
}
MPI_Barrier(MPI_COMM_WORLD);
- MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR,
- MPI_INFO_NULL, &fh);
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
- for (i = 0; i < SIZE; i++) buf[i] = i + mynod * SIZE;
- MPI_File_iwrite_at_all(fh, mynod * (SIZE / 2) * sizeof(int), buf, 1,
- newtype, &request);
+ for (i = 0; i < SIZE; i++)
+ buf[i] = i + mynod * SIZE;
+ MPI_File_iwrite_at_all(fh, mynod * (SIZE / 2) * sizeof(int), buf, 1, newtype, &request);
MPI_Barrier(MPI_COMM_WORLD);
MPI_Wait(&request, &status);
- for (i = 0; i < SIZE; i++) buf[i] = -1;
+ for (i = 0; i < SIZE; i++)
+ buf[i] = -1;
- MPI_File_iread_at_all(fh, mynod * (SIZE / 2) * sizeof(int), buf, 1,
- newtype, &request);
+ MPI_File_iread_at_all(fh, mynod * (SIZE / 2) * sizeof(int), buf, 1, newtype, &request);
MPI_Wait(&request, &status);
for (i = 0; i < SIZE; i++) {
if (!mynod) {
if ((i % 2) && (buf[i] != -1)) {
errs++;
- fprintf(stderr, "Process %d: buf %d is %d, should be -1\n",
- mynod, i, buf[i]);
+ fprintf(stderr, "Process %d: buf %d is %d, should be -1\n", mynod, i, buf[i]);
}
if (!(i % 2) && (buf[i] != i)) {
errs++;
- fprintf(stderr, "Process %d: buf %d is %d, should be %d\n",
- mynod, i, buf[i], i);
+ fprintf(stderr, "Process %d: buf %d is %d, should be %d\n", mynod, i, buf[i], i);
}
}
else {
@@ -167,8 +160,7 @@ int main(int argc, char **argv)
}
if (!(i % 2) && (buf[i] != -1)) {
errs++;
- fprintf(stderr, "Process %d: buf %d is %d, should be -1\n",
- mynod, i, buf[i]);
+ fprintf(stderr, "Process %d: buf %d is %d, should be -1\n", mynod, i, buf[i]);
}
}
}
@@ -180,18 +172,18 @@ int main(int argc, char **argv)
if (!mynod) {
#if VERBOSE
fprintf(stderr, "\ntesting contiguous in memory, noncontiguous in file "
- "using collective I/O\n");
+ "using collective I/O\n");
#endif
MPI_File_delete(filename, MPI_INFO_NULL);
}
MPI_Barrier(MPI_COMM_WORLD);
- MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR,
- MPI_INFO_NULL, &fh);
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
MPI_File_set_view(fh, 0, MPI_INT, newtype, "native", MPI_INFO_NULL);
- for (i = 0; i < SIZE; i++) buf[i] = i + mynod * SIZE;
+ for (i = 0; i < SIZE; i++)
+ buf[i] = i + mynod * SIZE;
MPI_File_iwrite_all(fh, buf, SIZE, MPI_INT, &request);
MPI_Barrier(MPI_COMM_WORLD);
@@ -207,8 +199,7 @@ int main(int argc, char **argv)
if (!mynod) {
if (buf[i] != i) {
errs++;
- fprintf(stderr, "Process %d: buf %d is %d, should be %d\n",
- mynod, i, buf[i], i);
+ fprintf(stderr, "Process %d: buf %d is %d, should be %d\n", mynod, i, buf[i], i);
}
}
else {
@@ -234,7 +225,8 @@ int main(int argc, char **argv)
MPI_Type_free(&newtype);
free(buf);
- if (mynod) free(filename);
+ if (mynod)
+ free(filename);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/io/i_noncontig_coll2.c b/test/mpi/io/i_noncontig_coll2.c
index 3b97f24..1d3782b 100644
--- a/test/mpi/io/i_noncontig_coll2.c
+++ b/test/mpi/io/i_noncontig_coll2.c
@@ -23,8 +23,7 @@
/* we are going to muck with this later to make it evenly divisible by however many compute nodes we have */
#define STARTING_SIZE 5000
-int test_file(char *filename, int mynod, int nprocs, char *cb_hosts,
- const char *msg, int verbose);
+int test_file(char *filename, int mynod, int nprocs, char *cb_hosts, const char *msg, int verbose);
#define ADIOI_Free free
#define ADIOI_Malloc malloc
@@ -86,7 +85,7 @@ int cb_gather_name_array(MPI_Comm comm, ADIO_cb_name_array * arrayp)
MPI_Get_processor_name(my_procname, &my_procname_len);
/* allocate space for everything */
- array = (ADIO_cb_name_array)malloc(sizeof(*array));
+ array = (ADIO_cb_name_array) malloc(sizeof(*array));
if (array == NULL) {
return -1;
}
@@ -96,13 +95,13 @@ int cb_gather_name_array(MPI_Comm comm, ADIO_cb_name_array * arrayp)
/* process 0 keeps the real list */
array->namect = commsize;
- array->names = (char **)ADIOI_Malloc(sizeof(char *) * commsize);
+ array->names = (char **) ADIOI_Malloc(sizeof(char *) * commsize);
if (array->names == NULL) {
return -1;
}
procname = array->names; /* simpler to read */
- procname_len = (int *)ADIOI_Malloc(commsize * sizeof(int));
+ procname_len = (int *) ADIOI_Malloc(commsize * sizeof(int));
if (procname_len == NULL) {
return -1;
}
@@ -145,7 +144,7 @@ int cb_gather_name_array(MPI_Comm comm, ADIO_cb_name_array * arrayp)
disp = malloc(commsize * sizeof(int));
disp[0] = 0;
for (i = 1; i < commsize; i++) {
- disp[i] = (int)(procname[i] - procname[0]);
+ disp[i] = (int) (procname[i] - procname[0]);
}
}
@@ -274,7 +273,7 @@ int main(int argc, char **argv)
}
else {
MPI_Bcast(&len, 1, MPI_INT, 0, MPI_COMM_WORLD);
- filename = (char *)malloc(len + 1);
+ filename = (char *) malloc(len + 1);
MPI_Bcast(filename, len + 1, MPI_CHAR, 0, MPI_COMM_WORLD);
}
@@ -304,8 +303,7 @@ int main(int argc, char **argv)
}
/* first, no hinting */
- errs += test_file(filename, mynod, nprocs, NULL,
- "collective w/o hinting", verbose);
+ errs += test_file(filename, mynod, nprocs, NULL, "collective w/o hinting", verbose);
/* hint, but no change in order */
default_str(mynod, cb_config_len, array, cb_config_string);
@@ -330,10 +328,13 @@ int main(int argc, char **argv)
MPI_Allreduce(&errs, &sum_errs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
if (!mynod) {
- if (sum_errs) fprintf(stderr, "Found %d error cases\n", sum_errs);
- else printf(" No Errors\n");
+ if (sum_errs)
+ fprintf(stderr, "Found %d error cases\n", sum_errs);
+ else
+ printf(" No Errors\n");
}
- if (mynod) free(filename);
+ if (mynod)
+ free(filename);
free(cb_config_string);
MPI_Finalize();
return 0;
@@ -341,8 +342,7 @@ int main(int argc, char **argv)
#define SEEDER(x,y,z) ((x)*1000000 + (y) + (x)*(z))
-int test_file(char *filename, int mynod, int nprocs, char *cb_hosts,
- const char *msg, int verbose)
+int test_file(char *filename, int mynod, int nprocs, char *cb_hosts, const char *msg, int verbose)
{
MPI_Datatype typevec, newtype, t[3];
int *buf, i, b[3], errcode, errors = 0;
@@ -356,7 +356,7 @@ int test_file(char *filename, int mynod, int nprocs, char *cb_hosts,
if (mynod == 0 && verbose)
fprintf(stderr, "%s\n", msg);
- buf = (int *)malloc(SIZE * sizeof(int));
+ buf = (int *) malloc(SIZE * sizeof(int));
if (buf == NULL) {
perror("test_file");
MPI_Abort(MPI_COMM_WORLD, -1);
@@ -388,20 +388,20 @@ int test_file(char *filename, int mynod, int nprocs, char *cb_hosts,
if (!mynod) {
if (verbose)
fprintf(stderr, "\ntesting noncontiguous in memory, noncontiguous "
- "in file using collective I/O\n");
+ "in file using collective I/O\n");
MPI_File_delete(filename, info);
}
MPI_Barrier(MPI_COMM_WORLD);
- errcode = MPI_File_open(MPI_COMM_WORLD, filename,
- MPI_MODE_CREATE | MPI_MODE_RDWR, info, &fh);
+ errcode = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, info, &fh);
if (errcode != MPI_SUCCESS) {
handle_error(errcode, "MPI_File_open");
}
MPI_File_set_view(fh, 0, MPI_INT, newtype, "native", info);
- for (i = 0; i < SIZE; i++) buf[i] = SEEDER(mynod, i, SIZE);
+ for (i = 0; i < SIZE; i++)
+ buf[i] = SEEDER(mynod, i, SIZE);
errcode = MPI_File_iwrite_all(fh, buf, 1, newtype, &request);
if (errcode != MPI_SUCCESS) {
handle_error(errcode, "nc mem - nc file: MPI_File_iwrite_all");
@@ -410,7 +410,8 @@ int test_file(char *filename, int mynod, int nprocs, char *cb_hosts,
MPI_Barrier(MPI_COMM_WORLD);
MPI_Wait(&request, &status);
- for (i = 0; i < SIZE; i++) buf[i] = -1;
+ for (i = 0; i < SIZE; i++)
+ buf[i] = -1;
errcode = MPI_File_iread_at_all(fh, 0, buf, 1, newtype, &request);
if (errcode != MPI_SUCCESS) {
@@ -428,8 +429,7 @@ int test_file(char *filename, int mynod, int nprocs, char *cb_hosts,
for (i = 0; i < mynod; i++) {
if (buf[i] != -1) {
if (verbose)
- fprintf(stderr, "Process %d: buf is %d, should be -1\n",
- mynod, buf[i]);
+ fprintf(stderr, "Process %d: buf is %d, should be -1\n", mynod, buf[i]);
errors++;
}
}
@@ -440,8 +440,7 @@ int test_file(char *filename, int mynod, int nprocs, char *cb_hosts,
for (/* 'i' set in above loop */ ; i < SIZE; i++) {
if (((i - mynod) % nprocs) && buf[i] != -1) {
if (verbose)
- fprintf(stderr, "Process %d: buf %d is %d, should be -1\n",
- mynod, i, buf[i]);
+ fprintf(stderr, "Process %d: buf %d is %d, should be -1\n", mynod, i, buf[i]);
errors++;
}
if (!((i - mynod) % nprocs) && buf[i] != SEEDER(mynod, i, SIZE)) {
@@ -458,15 +457,15 @@ int test_file(char *filename, int mynod, int nprocs, char *cb_hosts,
if (!mynod) {
if (verbose)
fprintf(stderr, "\ntesting noncontiguous in memory, contiguous in "
- "file using collective I/O\n");
+ "file using collective I/O\n");
MPI_File_delete(filename, info);
}
MPI_Barrier(MPI_COMM_WORLD);
- MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR,
- info, &fh);
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, info, &fh);
- for (i = 0; i < SIZE; i++) buf[i] = SEEDER(mynod, i, SIZE);
+ for (i = 0; i < SIZE; i++)
+ buf[i] = SEEDER(mynod, i, SIZE);
errcode = MPI_File_iwrite_at_all(fh, mynod * (SIZE / nprocs) * sizeof(int),
buf, 1, newtype, &request);
if (errcode != MPI_SUCCESS)
@@ -488,16 +487,14 @@ int test_file(char *filename, int mynod, int nprocs, char *cb_hosts,
for (i = 0; i < mynod; i++) {
if (buf[i] != -1) {
if (verbose)
- fprintf(stderr, "Process %d: buf is %d, should be -1\n",
- mynod, buf[i]);
+ fprintf(stderr, "Process %d: buf is %d, should be -1\n", mynod, buf[i]);
errors++;
}
}
for (/* i set in above loop */ ; i < SIZE; i++) {
if (((i - mynod) % nprocs) && buf[i] != -1) {
if (verbose)
- fprintf(stderr, "Process %d: buf %d is %d, should be -1\n",
- mynod, i, buf[i]);
+ fprintf(stderr, "Process %d: buf %d is %d, should be -1\n", mynod, i, buf[i]);
errors++;
}
if (!((i - mynod) % nprocs) && buf[i] != SEEDER(mynod, i, SIZE)) {
@@ -515,13 +512,12 @@ int test_file(char *filename, int mynod, int nprocs, char *cb_hosts,
if (!mynod) {
if (verbose)
fprintf(stderr, "\ntesting contiguous in memory, noncontiguous in "
- "file using collective I/O\n");
+ "file using collective I/O\n");
MPI_File_delete(filename, info);
}
MPI_Barrier(MPI_COMM_WORLD);
- MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR,
- info, &fh);
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, info, &fh);
MPI_File_set_view(fh, 0, MPI_INT, newtype, "native", info);
@@ -534,7 +530,8 @@ int test_file(char *filename, int mynod, int nprocs, char *cb_hosts,
MPI_Barrier(MPI_COMM_WORLD);
MPI_Wait(&request, &status);
- for (i = 0; i < SIZE; i++) buf[i] = -1;
+ for (i = 0; i < SIZE; i++)
+ buf[i] = -1;
errcode = MPI_File_iread_at_all(fh, 0, buf, SIZE, MPI_INT, &request);
if (errcode != MPI_SUCCESS)
@@ -555,6 +552,7 @@ int test_file(char *filename, int mynod, int nprocs, char *cb_hosts,
MPI_Type_free(&newtype);
free(buf);
- if (info != MPI_INFO_NULL) MPI_Info_free(&info);
+ if (info != MPI_INFO_NULL)
+ MPI_Info_free(&info);
return errors;
}
diff --git a/test/mpi/io/i_rdwrord.c b/test/mpi/io/i_rdwrord.c
index eed3f7b..147edb6 100644
--- a/test/mpi/io/i_rdwrord.c
+++ b/test/mpi/io/i_rdwrord.c
@@ -24,13 +24,12 @@ int main(int argc, char *argv[])
MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_File_open(comm, (char *)"test.ord",
- MPI_MODE_RDWR | MPI_MODE_CREATE |
- MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh);
+ MPI_File_open(comm, (char *) "test.ord",
+ MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh);
MPI_Comm_size(comm, &size);
MPI_Comm_rank(comm, &rank);
- buf = (int *)malloc(size * sizeof(int));
+ buf = (int *) malloc(size * sizeof(int));
buf[0] = rank;
rc = MPI_File_write_ordered(fh, buf, 1, MPI_INT, &status);
if (rc != MPI_SUCCESS) {
@@ -57,7 +56,8 @@ int main(int argc, char *argv[])
}
MPI_File_seek_shared(fh, 0, MPI_SEEK_SET);
- for (i = 0; i < size; i++) buf[i] = -1;
+ for (i = 0; i < size; i++)
+ buf[i] = -1;
MPI_File_read_ordered(fh, buf, 1, MPI_INT, &status);
if (buf[0] != rank) {
errs++;
diff --git a/test/mpi/io/i_setviewcur.c b/test/mpi/io/i_setviewcur.c
index 61e1558..3d0e2a0 100644
--- a/test/mpi/io/i_setviewcur.c
+++ b/test/mpi/io/i_setviewcur.c
@@ -89,8 +89,7 @@ int main(int argc, char *argv[])
}
if (buf[0] != size) {
errs++;
- fprintf(stderr, "Unexpected value for the header = %d, should be %d\n",
- buf[0], size);
+ fprintf(stderr, "Unexpected value for the header = %d, should be %d\n", buf[0], size);
fflush(stderr);
}
}
diff --git a/test/mpi/io/i_types_with_zeros.c b/test/mpi/io/i_types_with_zeros.c
index d18b065..1ed2a55 100644
--- a/test/mpi/io/i_types_with_zeros.c
+++ b/test/mpi/io/i_types_with_zeros.c
@@ -45,7 +45,8 @@ static int test_indexed_with_zeros(char *filename, int testcase)
MPI_Comm_size(MPI_COMM_WORLD, &np);
/* set up the number of integers to write in each iteration */
- for (i = 0; i < MAXLEN; i++) nelms[i] = 0;
+ for (i = 0; i < MAXLEN; i++)
+ nelms[i] = 0;
if (rank == 0)
nelms[4] = nelms[5] = nelms[7] = 1;
if (rank == 1)
@@ -56,13 +57,15 @@ static int test_indexed_with_zeros(char *filename, int testcase)
for (i = 0; i < MAXLEN; i++)
buf[i] = -999;
err = MPI_File_open(MPI_COMM_SELF, filename,
- MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL,
- &fh);
- if (err != MPI_SUCCESS) handle_error(err, "MPI_File_open");
+ MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &fh);
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_open");
err = MPI_File_write(fh, buf, MAXLEN, MPI_INT, &status);
- if (err != MPI_SUCCESS) handle_error(err, "MPI_File_write");
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_write");
err = MPI_File_close(&fh);
- if (err != MPI_SUCCESS) handle_error(err, "MPI_File_close");
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_close");
}
MPI_Barrier(MPI_COMM_WORLD);
@@ -77,46 +80,53 @@ static int test_indexed_with_zeros(char *filename, int testcase)
num++;
}
switch (testcase) {
- case INDEXED:
- MPI_Type_indexed(num, blocklen, indices, MPI_INT, &filetype);
- break;
- case HINDEXED:
- MPI_Type_hindexed(num, blocklen, addrs, MPI_INT, &filetype);
- break;
- case STRUCT:
- MPI_Type_create_struct(num, blocklen, addrs, types, &filetype);
- break;
- default:
- fprintf(stderr, "unknown testcase!\n");
- return (-100);
+ case INDEXED:
+ MPI_Type_indexed(num, blocklen, indices, MPI_INT, &filetype);
+ break;
+ case HINDEXED:
+ MPI_Type_hindexed(num, blocklen, addrs, MPI_INT, &filetype);
+ break;
+ case STRUCT:
+ MPI_Type_create_struct(num, blocklen, addrs, types, &filetype);
+ break;
+ default:
+ fprintf(stderr, "unknown testcase!\n");
+ return (-100);
}
MPI_Type_commit(&filetype);
/* initialize write buffer and write to file */
- for (i = 0; i < MAXLEN; i++) buf[i] = 1;
- err = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_WRONLY,
- MPI_INFO_NULL, &fh);
- if (err != MPI_SUCCESS) handle_error(err, "MPI_File_open");
+ for (i = 0; i < MAXLEN; i++)
+ buf[i] = 1;
+ err = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_WRONLY, MPI_INFO_NULL, &fh);
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_open");
err = MPI_File_set_view(fh, 0, MPI_INT, filetype, "native", MPI_INFO_NULL);
- if (err != MPI_SUCCESS) handle_error(err, "MPI_File_set_view");
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_set_view");
err = MPI_File_iwrite_all(fh, buf, buflen, MPI_INT, &request);
- if (err != MPI_SUCCESS) handle_error(err, "MPI_File_iwrite_all");
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_iwrite_all");
err = MPI_Wait(&request, &status);
- if (err != MPI_SUCCESS) handle_error(err, "MPI_Wait");
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_Wait");
MPI_Type_free(&filetype);
err = MPI_File_close(&fh);
- if (err != MPI_SUCCESS) handle_error(err, "MPI_File_close");
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_close");
/* read back and check */
if (rank == 0) {
- err = MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_RDONLY,
- MPI_INFO_NULL, &fh);
- if (err != MPI_SUCCESS) handle_error(err, "MPI_File_open");
+ err = MPI_File_open(MPI_COMM_SELF, filename, MPI_MODE_RDONLY, MPI_INFO_NULL, &fh);
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_open");
err = MPI_File_read(fh, buf, MAXLEN, MPI_INT, &status);
- if (err != MPI_SUCCESS) handle_error(err, "MPI_File_read");
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_read");
err = MPI_File_close(&fh);
- if (err != MPI_SUCCESS) handle_error(err, "MPI_File_close");
+ if (err != MPI_SUCCESS)
+ handle_error(err, "MPI_File_close");
for (i = 0; i < MAXLEN; i++) {
if (buf[i] < 0) {
nr_errors++;
@@ -140,7 +150,8 @@ int main(int argc, char **argv)
MPI_Comm_size(MPI_COMM_WORLD, &np);
if (np != 2) {
- if (rank == 0) fprintf(stderr, "Must run on 2 MPI processes\n");
+ if (rank == 0)
+ fprintf(stderr, "Must run on 2 MPI processes\n");
MPI_Finalize();
return 1;
}
@@ -148,7 +159,8 @@ int main(int argc, char **argv)
nr_errors += test_indexed_with_zeros(filename, HINDEXED);
nr_errors += test_indexed_with_zeros(filename, STRUCT);
- if (rank == 0 && nr_errors == 0) printf(" No Errors\n");
+ if (rank == 0 && nr_errors == 0)
+ printf(" No Errors\n");
MPI_Finalize();
return 0;
diff --git a/test/mpi/io/rdwrord.c b/test/mpi/io/rdwrord.c
index 245b266..81415ee 100644
--- a/test/mpi/io/rdwrord.c
+++ b/test/mpi/io/rdwrord.c
@@ -13,7 +13,7 @@
static char MTEST_Descrip[] = "Test reading and writing ordered output";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int size, rank, i, *buf, rc;
@@ -21,48 +21,48 @@ int main( int argc, char *argv[] )
MPI_Comm comm;
MPI_Status status;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_File_open( comm, (char*)"test.ord",
- MPI_MODE_RDWR | MPI_MODE_CREATE |
- MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh );
+ MPI_File_open(comm, (char *) "test.ord",
+ MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh);
- MPI_Comm_size( comm, &size );
- MPI_Comm_rank( comm, &rank );
- buf = (int *)malloc( size * sizeof(int) );
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
+ buf = (int *) malloc(size * sizeof(int));
buf[0] = rank;
- rc = MPI_File_write_ordered( fh, buf, 1, MPI_INT, &status );
+ rc = MPI_File_write_ordered(fh, buf, 1, MPI_INT, &status);
if (rc) {
- MTestPrintErrorMsg( "File_write_ordered", rc );
- errs++;
+ MTestPrintErrorMsg("File_write_ordered", rc);
+ errs++;
}
/* make sure all writes finish before we seek/read */
MPI_Barrier(comm);
-
+
/* Set the individual pointer to 0, since we want to use a read_all */
- MPI_File_seek( fh, 0, MPI_SEEK_SET );
- MPI_File_read_all( fh, buf, size, MPI_INT, &status );
+ MPI_File_seek(fh, 0, MPI_SEEK_SET);
+ MPI_File_read_all(fh, buf, size, MPI_INT, &status);
- for (i=0; i<size; i++) {
- if (buf[i] != i) {
- errs++;
- fprintf( stderr, "%d: buf[%d] = %d\n", rank, i, buf[i] );
- }
+ for (i = 0; i < size; i++) {
+ if (buf[i] != i) {
+ errs++;
+ fprintf(stderr, "%d: buf[%d] = %d\n", rank, i, buf[i]);
+ }
}
- MPI_File_seek_shared( fh, 0, MPI_SEEK_SET );
- for (i=0; i<size; i++) buf[i] = -1;
- MPI_File_read_ordered( fh, buf, 1, MPI_INT, &status );
+ MPI_File_seek_shared(fh, 0, MPI_SEEK_SET);
+ for (i = 0; i < size; i++)
+ buf[i] = -1;
+ MPI_File_read_ordered(fh, buf, 1, MPI_INT, &status);
if (buf[0] != rank) {
- errs++;
- fprintf( stderr, "%d: buf[0] = %d\n", rank, buf[0] );
+ errs++;
+ fprintf(stderr, "%d: buf[0] = %d\n", rank, buf[0]);
}
- free( buf );
- MPI_File_close( &fh );
+ free(buf);
+ MPI_File_close(&fh);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/io/rdwrzero.c b/test/mpi/io/rdwrzero.c
index c41fcca..2ef2961 100644
--- a/test/mpi/io/rdwrzero.c
+++ b/test/mpi/io/rdwrzero.c
@@ -20,7 +20,7 @@
static char MTEST_Descrip[] = "Test reading and writing zero bytes (set status correctly)";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int size, rank, i, *buf, count, rc;
@@ -28,93 +28,94 @@ int main( int argc, char *argv[] )
MPI_Comm comm;
MPI_Status status;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- rc = MPI_File_open( comm, (char*)"test.ord",
- MPI_MODE_RDWR | MPI_MODE_CREATE |
- MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh );
+ rc = MPI_File_open(comm, (char *) "test.ord",
+ MPI_MODE_RDWR | MPI_MODE_CREATE |
+ MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh);
if (rc) {
- MTestPrintErrorMsg( "File_open", rc );
- errs++;
- /* If the open fails, there isn't anything else that we can do */
- goto fn_fail;
+ MTestPrintErrorMsg("File_open", rc);
+ errs++;
+ /* If the open fails, there isn't anything else that we can do */
+ goto fn_fail;
}
- MPI_Comm_size( comm, &size );
- MPI_Comm_rank( comm, &rank );
- buf = (int *)malloc( size * sizeof(int) );
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
+ buf = (int *) malloc(size * sizeof(int));
buf[0] = rank;
/* Write to file */
- rc = MPI_File_write_ordered( fh, buf, 1, MPI_INT, &status );
+ rc = MPI_File_write_ordered(fh, buf, 1, MPI_INT, &status);
if (rc) {
- MTestPrintErrorMsg( "File_write_ordered", rc );
- errs++;
+ MTestPrintErrorMsg("File_write_ordered", rc);
+ errs++;
}
else {
- MPI_Get_count( &status, MPI_INT, &count );
- if (count != 1) {
- errs++;
- fprintf( stderr, "Wrong count (%d) on write-ordered\n", count );
- }
+ MPI_Get_count(&status, MPI_INT, &count);
+ if (count != 1) {
+ errs++;
+ fprintf(stderr, "Wrong count (%d) on write-ordered\n", count);
+ }
}
/* Set the individual pointer to 0, since we want to use a read_all */
- MPI_File_seek( fh, 0, MPI_SEEK_SET );
+ MPI_File_seek(fh, 0, MPI_SEEK_SET);
/* Read nothing (check status) */
- memset( &status, 0xff, sizeof(MPI_Status) );
- MPI_File_read( fh, buf, 0, MPI_INT, &status );
- MPI_Get_count( &status, MPI_INT, &count );
+ memset(&status, 0xff, sizeof(MPI_Status));
+ MPI_File_read(fh, buf, 0, MPI_INT, &status);
+ MPI_Get_count(&status, MPI_INT, &count);
if (count != 0) {
- errs++;
- fprintf( stderr, "Count not zero (%d) on read\n", count );
+ errs++;
+ fprintf(stderr, "Count not zero (%d) on read\n", count);
}
/* Write nothing (check status) */
- memset( &status, 0xff, sizeof(MPI_Status) );
- MPI_File_write( fh, buf, 0, MPI_INT, &status );
+ memset(&status, 0xff, sizeof(MPI_Status));
+ MPI_File_write(fh, buf, 0, MPI_INT, &status);
if (count != 0) {
- errs++;
- fprintf( stderr, "Count not zero (%d) on write\n", count );
+ errs++;
+ fprintf(stderr, "Count not zero (%d) on write\n", count);
}
/* Read shared nothing (check status) */
- MPI_File_seek_shared( fh, 0, MPI_SEEK_SET );
+ MPI_File_seek_shared(fh, 0, MPI_SEEK_SET);
/* Read nothing (check status) */
- memset( &status, 0xff, sizeof(MPI_Status) );
- MPI_File_read_shared( fh, buf, 0, MPI_INT, &status );
- MPI_Get_count( &status, MPI_INT, &count );
+ memset(&status, 0xff, sizeof(MPI_Status));
+ MPI_File_read_shared(fh, buf, 0, MPI_INT, &status);
+ MPI_Get_count(&status, MPI_INT, &count);
if (count != 0) {
- errs++;
- fprintf( stderr, "Count not zero (%d) on read shared\n", count );
+ errs++;
+ fprintf(stderr, "Count not zero (%d) on read shared\n", count);
}
-
+
/* Write nothing (check status) */
- memset( &status, 0xff, sizeof(MPI_Status) );
- MPI_File_write_shared( fh, buf, 0, MPI_INT, &status );
+ memset(&status, 0xff, sizeof(MPI_Status));
+ MPI_File_write_shared(fh, buf, 0, MPI_INT, &status);
if (count != 0) {
- errs++;
- fprintf( stderr, "Count not zero (%d) on write\n", count );
+ errs++;
+ fprintf(stderr, "Count not zero (%d) on write\n", count);
}
- MPI_Barrier( comm );
+ MPI_Barrier(comm);
- MPI_File_seek_shared( fh, 0, MPI_SEEK_SET );
- for (i=0; i<size; i++) buf[i] = -1;
- MPI_File_read_ordered( fh, buf, 1, MPI_INT, &status );
+ MPI_File_seek_shared(fh, 0, MPI_SEEK_SET);
+ for (i = 0; i < size; i++)
+ buf[i] = -1;
+ MPI_File_read_ordered(fh, buf, 1, MPI_INT, &status);
if (buf[0] != rank) {
- errs++;
- fprintf( stderr, "%d: buf = %d\n", rank, buf[0] );
+ errs++;
+ fprintf(stderr, "%d: buf = %d\n", rank, buf[0]);
}
- free( buf );
+ free(buf);
- MPI_File_close( &fh );
+ MPI_File_close(&fh);
- fn_fail:
- MTest_Finalize( errs );
+ fn_fail:
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/io/resized.c b/test/mpi/io/resized.c
index 4c857b9..359c57c 100644
--- a/test/mpi/io/resized.c
+++ b/test/mpi/io/resized.c
@@ -1,5 +1,5 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
-/*
+/*
* (C) 2008 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
@@ -16,14 +16,14 @@ static char MTEST_Descrip[] = "Test file views with MPI_Type_create_resized";
int main(int argc, char **argv)
{
int i, nprocs, len, mpi_errno, buf[2], newbuf[4];
- int errs=0;
+ int errs = 0;
MPI_Offset size;
MPI_Aint lb, extent;
MPI_File fh;
char *filename;
MPI_Datatype newtype;
- MTest_Init(&argc,&argv);
+ MTest_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
if (nprocs != 1) {
@@ -33,38 +33,38 @@ int main(int argc, char **argv)
i = 1;
while ((i < argc) && strcmp("-fname", *argv)) {
- i++;
- argv++;
+ i++;
+ argv++;
}
if (i >= argc) {
- len = 8;
- filename = (char *)malloc(len + 10);
- strcpy( filename, "testfile" );
- /*
- fprintf(stderr, "\n*# Usage: resized -fname filename\n\n");
- MPI_Abort(MPI_COMM_WORLD, 1);
- */
+ len = 8;
+ filename = (char *) malloc(len + 10);
+ strcpy(filename, "testfile");
+ /*
+ * fprintf(stderr, "\n*# Usage: resized -fname filename\n\n");
+ * MPI_Abort(MPI_COMM_WORLD, 1);
+ */
}
else {
- argv++;
- len = (int)strlen(*argv);
- filename = (char *) malloc(len+1);
- strcpy(filename, *argv);
+ argv++;
+ len = (int) strlen(*argv);
+ filename = (char *) malloc(len + 1);
+ strcpy(filename, *argv);
}
MPI_File_delete(filename, MPI_INFO_NULL);
/* create a resized type comprising an integer with an lb at sizeof(int) and extent = 3*sizeof(int) */
lb = sizeof(int);
- extent = 3*sizeof(int);
- MPI_Type_create_resized(MPI_INT, lb, extent, &newtype);
+ extent = 3 * sizeof(int);
+ MPI_Type_create_resized(MPI_INT, lb, extent, &newtype);
MPI_Type_commit(&newtype);
/* initialize the file */
- MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE |
- MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
- for (i=0; i<4; i++) newbuf[i] = 55;
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
+ for (i = 0; i < 4; i++)
+ newbuf[i] = 55;
MPI_File_write(fh, newbuf, 4, MPI_INT, MPI_STATUS_IGNORE);
MPI_File_close(&fh);
@@ -73,49 +73,55 @@ int main(int argc, char **argv)
buf[0] = 10;
buf[1] = 20;
- MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE |
- MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
- mpi_errno = MPI_File_set_view(fh, 0, MPI_INT, newtype, (char*)"native", MPI_INFO_NULL);
- if (mpi_errno != MPI_SUCCESS) errs++;
+ mpi_errno = MPI_File_set_view(fh, 0, MPI_INT, newtype, (char *) "native", MPI_INFO_NULL);
+ if (mpi_errno != MPI_SUCCESS)
+ errs++;
- MPI_File_write(fh, buf, 2, MPI_INT, MPI_STATUS_IGNORE);
+ MPI_File_write(fh, buf, 2, MPI_INT, MPI_STATUS_IGNORE);
MPI_File_close(&fh);
-
+
/* read back file view with resized type and verify */
MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, MPI_INFO_NULL, &fh);
- mpi_errno = MPI_File_set_view(fh, 0, MPI_INT, newtype, (char*)"native", MPI_INFO_NULL);
- if (mpi_errno != MPI_SUCCESS) errs++;
+ mpi_errno = MPI_File_set_view(fh, 0, MPI_INT, newtype, (char *) "native", MPI_INFO_NULL);
+ if (mpi_errno != MPI_SUCCESS)
+ errs++;
- for (i=0; i<4; i++) newbuf[i] = 100;
+ for (i = 0; i < 4; i++)
+ newbuf[i] = 100;
MPI_File_read(fh, newbuf, 2, MPI_INT, MPI_STATUS_IGNORE);
- if ((newbuf[0] != 10) || (newbuf[1] != 20) || (newbuf[2] !=100) || (newbuf[3] != 100)) {
- errs++;
- fprintf(stderr, "newbuf[0] is %d, should be 10,\n newbuf[1] is %d, should be 20\n newbuf[2] is %d, should be 100,\n newbuf[3] is %d, should be 100,\n", newbuf[0], newbuf[1], newbuf[2], newbuf[3]);
+ if ((newbuf[0] != 10) || (newbuf[1] != 20) || (newbuf[2] != 100) || (newbuf[3] != 100)) {
+ errs++;
+ fprintf(stderr,
+ "newbuf[0] is %d, should be 10,\n newbuf[1] is %d, should be 20\n newbuf[2] is %d, should be 100,\n newbuf[3] is %d, should be 100,\n",
+ newbuf[0], newbuf[1], newbuf[2], newbuf[3]);
}
MPI_File_close(&fh);
/* read file back and verify */
- MPI_File_open(MPI_COMM_WORLD, filename,
- MPI_MODE_RDONLY, MPI_INFO_NULL, &fh);
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, MPI_INFO_NULL, &fh);
MPI_File_get_size(fh, &size);
- if (size != 4*sizeof(int)) {
- errs++;
- fprintf(stderr, "file size is %lld, should be %d\n", size, (int)(4*sizeof(int)));
+ if (size != 4 * sizeof(int)) {
+ errs++;
+ fprintf(stderr, "file size is %lld, should be %d\n", size, (int) (4 * sizeof(int)));
}
- for (i=0; i<4; i++) newbuf[i] = 100;
+ for (i = 0; i < 4; i++)
+ newbuf[i] = 100;
MPI_File_read(fh, newbuf, 4, MPI_INT, MPI_STATUS_IGNORE);
- if ((newbuf[0] != 10) || (newbuf[3] != 20) || (newbuf[1] !=55) || (newbuf[2] != 55)) {
- errs++;
- fprintf(stderr, "newbuf[0] is %d, should be 10,\n newbuf[1] is %d, should be 55,\n newbuf[2] is %d, should be 55,\n newbuf[3] is %d, should be 20\n", newbuf[0], newbuf[1], newbuf[2], newbuf[3]);
+ if ((newbuf[0] != 10) || (newbuf[3] != 20) || (newbuf[1] != 55) || (newbuf[2] != 55)) {
+ errs++;
+ fprintf(stderr,
+ "newbuf[0] is %d, should be 10,\n newbuf[1] is %d, should be 55,\n newbuf[2] is %d, should be 55,\n newbuf[3] is %d, should be 20\n",
+ newbuf[0], newbuf[1], newbuf[2], newbuf[3]);
}
MPI_File_close(&fh);
diff --git a/test/mpi/io/resized2.c b/test/mpi/io/resized2.c
index a60ff26..687a538 100644
--- a/test/mpi/io/resized2.c
+++ b/test/mpi/io/resized2.c
@@ -1,5 +1,5 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
-/*
+/*
* (C) 2008 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
@@ -16,14 +16,14 @@ static char MTEST_Descrip[] = "Test file views with MPI_Type_create_resized";
int main(int argc, char **argv)
{
int i, nprocs, len, mpi_errno, buf[2], newbuf[4];
- int errs=0;
+ int errs = 0;
MPI_Offset size;
MPI_Aint lb, extent;
MPI_File fh;
char *filename;
MPI_Datatype newtype, newtype1;
- MTest_Init(&argc,&argv);
+ MTest_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
if (nprocs != 1) {
@@ -33,40 +33,40 @@ int main(int argc, char **argv)
i = 1;
while ((i < argc) && strcmp("-fname", *argv)) {
- i++;
- argv++;
+ i++;
+ argv++;
}
if (i >= argc) {
- len = 8;
- filename = (char *)malloc(len + 10);
- strcpy( filename, "testfile" );
- /*
- fprintf(stderr, "\n*# Usage: resized -fname filename\n\n");
- MPI_Abort(MPI_COMM_WORLD, 1);
- */
+ len = 8;
+ filename = (char *) malloc(len + 10);
+ strcpy(filename, "testfile");
+ /*
+ * fprintf(stderr, "\n*# Usage: resized -fname filename\n\n");
+ * MPI_Abort(MPI_COMM_WORLD, 1);
+ */
}
else {
- argv++;
- len = (int)strlen(*argv);
- filename = (char *) malloc(len+1);
- strcpy(filename, *argv);
+ argv++;
+ len = (int) strlen(*argv);
+ filename = (char *) malloc(len + 1);
+ strcpy(filename, *argv);
}
MPI_File_delete(filename, MPI_INFO_NULL);
/* create a resized type comprising an integer with an lb at sizeof(int) and extent = 3*sizeof(int) */
lb = sizeof(int);
- extent = 3*sizeof(int);
- MPI_Type_create_resized(MPI_INT, lb, extent, &newtype1);
+ extent = 3 * sizeof(int);
+ MPI_Type_create_resized(MPI_INT, lb, extent, &newtype1);
MPI_Type_commit(&newtype1);
- MPI_Type_create_resized(newtype1, lb, extent, &newtype);
+ MPI_Type_create_resized(newtype1, lb, extent, &newtype);
MPI_Type_commit(&newtype);
/* initialize the file */
- MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE |
- MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
- for (i=0; i<4; i++) newbuf[i] = 55;
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
+ for (i = 0; i < 4; i++)
+ newbuf[i] = 55;
MPI_File_write(fh, newbuf, 4, MPI_INT, MPI_STATUS_IGNORE);
MPI_File_close(&fh);
@@ -75,49 +75,55 @@ int main(int argc, char **argv)
buf[0] = 10;
buf[1] = 20;
- MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE |
- MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
- mpi_errno = MPI_File_set_view(fh, 0, MPI_INT, newtype, (char*)"native", MPI_INFO_NULL);
- if (mpi_errno != MPI_SUCCESS) errs++;
+ mpi_errno = MPI_File_set_view(fh, 0, MPI_INT, newtype, (char *) "native", MPI_INFO_NULL);
+ if (mpi_errno != MPI_SUCCESS)
+ errs++;
- MPI_File_write(fh, buf, 2, MPI_INT, MPI_STATUS_IGNORE);
+ MPI_File_write(fh, buf, 2, MPI_INT, MPI_STATUS_IGNORE);
MPI_File_close(&fh);
-
+
/* read back file view with resized type and verify */
MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, MPI_INFO_NULL, &fh);
- mpi_errno = MPI_File_set_view(fh, 0, MPI_INT, newtype, (char*)"native", MPI_INFO_NULL);
- if (mpi_errno != MPI_SUCCESS) errs++;
+ mpi_errno = MPI_File_set_view(fh, 0, MPI_INT, newtype, (char *) "native", MPI_INFO_NULL);
+ if (mpi_errno != MPI_SUCCESS)
+ errs++;
- for (i=0; i<4; i++) newbuf[i] = 100;
+ for (i = 0; i < 4; i++)
+ newbuf[i] = 100;
MPI_File_read(fh, newbuf, 2, MPI_INT, MPI_STATUS_IGNORE);
- if ((newbuf[0] != 10) || (newbuf[1] != 20) || (newbuf[2] !=100) || (newbuf[3] != 100)) {
- errs++;
- fprintf(stderr, "newbuf[0] is %d, should be 10,\n newbuf[1] is %d, should be 20\n newbuf[2] is %d, should be 100,\n newbuf[3] is %d, should be 100,\n", newbuf[0], newbuf[1], newbuf[2], newbuf[3]);
+ if ((newbuf[0] != 10) || (newbuf[1] != 20) || (newbuf[2] != 100) || (newbuf[3] != 100)) {
+ errs++;
+ fprintf(stderr,
+ "newbuf[0] is %d, should be 10,\n newbuf[1] is %d, should be 20\n newbuf[2] is %d, should be 100,\n newbuf[3] is %d, should be 100,\n",
+ newbuf[0], newbuf[1], newbuf[2], newbuf[3]);
}
MPI_File_close(&fh);
/* read file back and verify */
- MPI_File_open(MPI_COMM_WORLD, filename,
- MPI_MODE_RDONLY, MPI_INFO_NULL, &fh);
+ MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, MPI_INFO_NULL, &fh);
MPI_File_get_size(fh, &size);
- if (size != 4*sizeof(int)) {
- errs++;
- fprintf(stderr, "file size is %lld, should be %d\n", size, (int)(4*sizeof(int)));
+ if (size != 4 * sizeof(int)) {
+ errs++;
+ fprintf(stderr, "file size is %lld, should be %d\n", size, (int) (4 * sizeof(int)));
}
- for (i=0; i<4; i++) newbuf[i] = 100;
+ for (i = 0; i < 4; i++)
+ newbuf[i] = 100;
MPI_File_read(fh, newbuf, 4, MPI_INT, MPI_STATUS_IGNORE);
- if ((newbuf[0] != 10) || (newbuf[3] != 20) || (newbuf[1] !=55) || (newbuf[2] != 55)) {
- errs++;
- fprintf(stderr, "newbuf[0] is %d, should be 10,\n newbuf[1] is %d, should be 55,\n newbuf[2] is %d, should be 55,\n newbuf[3] is %d, should be 20\n", newbuf[0], newbuf[1], newbuf[2], newbuf[3]);
+ if ((newbuf[0] != 10) || (newbuf[3] != 20) || (newbuf[1] != 55) || (newbuf[2] != 55)) {
+ errs++;
+ fprintf(stderr,
+ "newbuf[0] is %d, should be 10,\n newbuf[1] is %d, should be 55,\n newbuf[2] is %d, should be 55,\n newbuf[3] is %d, should be 20\n",
+ newbuf[0], newbuf[1], newbuf[2], newbuf[3]);
}
MPI_File_close(&fh);
diff --git a/test/mpi/io/setinfo.c b/test/mpi/io/setinfo.c
index 1ed9c60..487dc43 100644
--- a/test/mpi/io/setinfo.c
+++ b/test/mpi/io/setinfo.c
@@ -17,107 +17,106 @@
static char MTEST_Descrip[] = "Test file_set_view";
*/
-/*
+/*
* access style is explicitly described as modifiable. values include
* read_once, read_mostly, write_once, write_mostlye, random
*
- *
+ *
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int buf[10];
int rank;
- MPI_Comm comm;
- MPI_Status status;
- MPI_File fh;
- MPI_Info infoin, infoout;
- char value[1024];
- int flag, count;
+ MPI_Comm comm;
+ MPI_Status status;
+ MPI_File fh;
+ MPI_Info infoin, infoout;
+ char value[1024];
+ int flag, count;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Info_create( &infoin );
- MPI_Info_set( infoin, (char*)"access_style", (char*)"write_once,random" );
- MPI_File_open( comm, (char*)"testfile", MPI_MODE_RDWR | MPI_MODE_CREATE, infoin, &fh );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Info_create(&infoin);
+ MPI_Info_set(infoin, (char *) "access_style", (char *) "write_once,random");
+ MPI_File_open(comm, (char *) "testfile", MPI_MODE_RDWR | MPI_MODE_CREATE, infoin, &fh);
buf[0] = rank;
- err = MPI_File_write_ordered( fh, buf, 1, MPI_INT, &status );
+ err = MPI_File_write_ordered(fh, buf, 1, MPI_INT, &status);
if (err) {
- errs ++;
- MTestPrintError( err );
+ errs++;
+ MTestPrintError(err);
}
- MPI_Info_set( infoin, (char*)"access_style", (char*)"read_once" );
- err = MPI_File_seek_shared( fh, 0, MPI_SEEK_SET );
+ MPI_Info_set(infoin, (char *) "access_style", (char *) "read_once");
+ err = MPI_File_seek_shared(fh, 0, MPI_SEEK_SET);
if (err) {
- errs ++;
- MTestPrintError( err );
+ errs++;
+ MTestPrintError(err);
}
-
- err = MPI_File_set_info( fh, infoin );
+
+ err = MPI_File_set_info(fh, infoin);
if (err) {
- errs ++;
- MTestPrintError( err );
+ errs++;
+ MTestPrintError(err);
}
- MPI_Info_free( &infoin );
+ MPI_Info_free(&infoin);
buf[0] = -1;
-
- err = MPI_File_read_ordered( fh, buf, 1, MPI_INT, &status );
+
+ err = MPI_File_read_ordered(fh, buf, 1, MPI_INT, &status);
if (err) {
- errs ++;
- MTestPrintError( err );
+ errs++;
+ MTestPrintError(err);
}
- MPI_Get_count( &status, MPI_INT, &count );
+ MPI_Get_count(&status, MPI_INT, &count);
if (count != 1) {
- errs++;
- printf( "Expected to read one int, read %d\n", count );
+ errs++;
+ printf("Expected to read one int, read %d\n", count);
}
if (buf[0] != rank) {
- errs++;
- printf( "Did not read expected value (%d)\n", buf[0] );
+ errs++;
+ printf("Did not read expected value (%d)\n", buf[0]);
}
- err = MPI_File_get_info( fh, &infoout );
+ err = MPI_File_get_info(fh, &infoout);
if (err) {
- errs ++;
- MTestPrintError( err );
+ errs++;
+ MTestPrintError(err);
}
- MPI_Info_get( infoout, (char*)"access_style", 1024, value, &flag );
+ MPI_Info_get(infoout, (char *) "access_style", 1024, value, &flag);
/* Note that an implementation is allowed to ignore the set_info,
- so we'll accept either the original or the updated version */
+ * so we'll accept either the original or the updated version */
if (!flag) {
- ;
- /*
- errs++;
- printf( "Access style hint not saved\n" );
- */
+ ;
+ /*
+ * errs++;
+ * printf("Access style hint not saved\n");
+ */
}
else {
- if (strcmp( value, "read_once" ) != 0 &&
- strcmp( value, "write_once,random" ) != 0) {
- errs++;
- printf( "value for access_style unexpected; is %s\n", value );
- }
+ if (strcmp(value, "read_once") != 0 && strcmp(value, "write_once,random") != 0) {
+ errs++;
+ printf("value for access_style unexpected; is %s\n", value);
+ }
}
- MPI_Info_free( &infoout );
- err = MPI_File_close( &fh );
+ MPI_Info_free(&infoout);
+ err = MPI_File_close(&fh);
if (err) {
- errs ++;
- MTestPrintError( err );
+ errs++;
+ MTestPrintError(err);
}
- MPI_Barrier( comm );
- MPI_Comm_rank( comm, &rank );
+ MPI_Barrier(comm);
+ MPI_Comm_rank(comm, &rank);
if (rank == 0) {
- err = MPI_File_delete( (char*)"testfile", MPI_INFO_NULL );
- if (err) {
- errs ++;
- MTestPrintError( err );
- }
+ err = MPI_File_delete((char *) "testfile", MPI_INFO_NULL);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
}
-
- MTest_Finalize( errs );
- MPI_Finalize( );
+
+ MTest_Finalize(errs);
+ MPI_Finalize();
return 0;
}
diff --git a/test/mpi/io/setviewcur.c b/test/mpi/io/setviewcur.c
index e04459b..2f35c73 100644
--- a/test/mpi/io/setviewcur.c
+++ b/test/mpi/io/setviewcur.c
@@ -13,7 +13,7 @@
static char MTEST_Descrip[] = "Test set_view with DISPLACEMENT_CURRENT";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int size, rank, *buf;
@@ -22,70 +22,101 @@ int main( int argc, char *argv[] )
MPI_Comm comm;
MPI_Status status;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
/* This test reads a header then sets the view to every "size" int,
- using set view and current displacement. The file is first written
- using a combination of collective and ordered writes */
-
+ * using set view and current displacement. The file is first written
+ * using a combination of collective and ordered writes */
+
comm = MPI_COMM_WORLD;
- err = MPI_File_open( comm, (char*)"test.ord",
- MPI_MODE_WRONLY | MPI_MODE_CREATE, MPI_INFO_NULL, &fh );
- if (err) { errs++; MTestPrintErrorMsg( "Open(1)", err ); }
- MPI_Comm_size( comm, &size );
- MPI_Comm_rank( comm, &rank );
- buf = (int *)malloc( size * sizeof(int) );
+ err = MPI_File_open(comm, (char *) "test.ord",
+ MPI_MODE_WRONLY | MPI_MODE_CREATE, MPI_INFO_NULL, &fh);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Open(1)", err);
+ }
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
+ buf = (int *) malloc(size * sizeof(int));
buf[0] = size;
- err = MPI_File_write_all( fh, buf, 1, MPI_INT, &status );
- if (err) { errs++; MTestPrintErrorMsg( "Write_all", err ); }
- err = MPI_File_get_position( fh, &offset );
- if (err) { errs++; MTestPrintErrorMsg( "Get_position", err ); }
- err = MPI_File_seek_shared( fh, offset, MPI_SEEK_SET );
- if (err) { errs++; MTestPrintErrorMsg( "Seek_shared", err ); }
+ err = MPI_File_write_all(fh, buf, 1, MPI_INT, &status);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Write_all", err);
+ }
+ err = MPI_File_get_position(fh, &offset);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Get_position", err);
+ }
+ err = MPI_File_seek_shared(fh, offset, MPI_SEEK_SET);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Seek_shared", err);
+ }
buf[0] = rank;
- err = MPI_File_write_ordered( fh, buf, 1, MPI_INT, &status );
- if (err) { errs++; MTestPrintErrorMsg( "Write_ordered", err ); }
- err = MPI_File_close( &fh );
- if (err) { errs++; MTestPrintErrorMsg( "Close(1)", err ); }
+ err = MPI_File_write_ordered(fh, buf, 1, MPI_INT, &status);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Write_ordered", err);
+ }
+ err = MPI_File_close(&fh);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Close(1)", err);
+ }
/* Reopen the file as sequential */
- err = MPI_File_open( comm, (char*)"test.ord",
- MPI_MODE_RDONLY | MPI_MODE_SEQUENTIAL |
- MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh );
- if (err) { errs++; MTestPrintErrorMsg( "Open(Read)", err ); }
-
+ err = MPI_File_open(comm, (char *) "test.ord",
+ MPI_MODE_RDONLY | MPI_MODE_SEQUENTIAL |
+ MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Open(Read)", err);
+ }
+
if (rank == 0) {
- err = MPI_File_read_shared( fh, buf, 1, MPI_INT, &status );
- if (err) { errs++; MTestPrintErrorMsg( "Read_all", err ); }
- if (buf[0] != size) {
- errs++;
- fprintf(stderr, "Unexpected value for the header = %d, should be %d\n",
- buf[0], size ); fflush(stderr);
- }
+ err = MPI_File_read_shared(fh, buf, 1, MPI_INT, &status);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Read_all", err);
+ }
+ if (buf[0] != size) {
+ errs++;
+ fprintf(stderr, "Unexpected value for the header = %d, should be %d\n", buf[0], size);
+ fflush(stderr);
+ }
}
- MPI_Barrier( comm );
+ MPI_Barrier(comm);
/* All processes must provide the same file view for MODE_SEQUENTIAL */
- /* See MPI 2.1, 13.3 - DISPLACEMENT_CURRENT is *required* for
- MODE_SEQUENTIAL files */
- err = MPI_File_set_view( fh, MPI_DISPLACEMENT_CURRENT, MPI_INT,
- MPI_INT, (char*)"native", MPI_INFO_NULL );
- if (err) {
- errs++;
- MTestPrintErrorMsg( "Set_view (DISPLACEMENT_CURRENT)", err );
+ /* See MPI 2.1, 13.3 - DISPLACEMENT_CURRENT is *required* for
+ * MODE_SEQUENTIAL files */
+ err = MPI_File_set_view(fh, MPI_DISPLACEMENT_CURRENT, MPI_INT,
+ MPI_INT, (char *) "native", MPI_INFO_NULL);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Set_view (DISPLACEMENT_CURRENT)", err);
}
buf[0] = -1;
- err = MPI_File_read_ordered( fh, buf, 1, MPI_INT, &status );
- if (err) { errs++; MTestPrintErrorMsg( "Read_all", err ); }
+ err = MPI_File_read_ordered(fh, buf, 1, MPI_INT, &status);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Read_all", err);
+ }
if (buf[0] != rank) {
- errs++;
- fprintf( stderr, "%d: buf[0] = %d\n", rank, buf[0] ); fflush(stderr);
+ errs++;
+ fprintf(stderr, "%d: buf[0] = %d\n", rank, buf[0]);
+ fflush(stderr);
}
- free( buf );
- err = MPI_File_close( &fh );
- if (err) { errs++; MTestPrintErrorMsg( "Close(2)", err ); }
+ free(buf);
+ err = MPI_File_close(&fh);
+ if (err) {
+ errs++;
+ MTestPrintErrorMsg("Close(2)", err);
+ }
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/io/userioerr.c b/test/mpi/io/userioerr.c
index bc13368..806df69 100644
--- a/test/mpi/io/userioerr.c
+++ b/test/mpi/io/userioerr.c
@@ -14,46 +14,46 @@ int verbose = 0;
int handlerCalled = 0;
/* Prototype to suppress compiler warnings */
-void user_handler( MPI_File *fh, int *errcode, ... );
+void user_handler(MPI_File * fh, int *errcode, ...);
-void user_handler( MPI_File *fh, int *errcode, ... )
+void user_handler(MPI_File * fh, int *errcode, ...)
{
if (*errcode != MPI_SUCCESS) {
- handlerCalled++;
- if (verbose) {
- printf( "In user_handler with code %d\n", *errcode );
- }
+ handlerCalled++;
+ if (verbose) {
+ printf("In user_handler with code %d\n", *errcode);
+ }
}
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
- int rank, errs = 0, rc;
+ int rank, errs = 0, rc;
MPI_Errhandler ioerr_handler;
- MPI_Status status;
- MPI_File fh;
- char inbuf[80];
+ MPI_Status status;
+ MPI_File fh;
+ char inbuf[80];
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
/* Create a file to which to attach the handler */
- rc = MPI_File_open( MPI_COMM_WORLD, (char*)"test.txt",
- MPI_MODE_CREATE | MPI_MODE_WRONLY | MPI_MODE_DELETE_ON_CLOSE,
- MPI_INFO_NULL, &fh );
+ rc = MPI_File_open(MPI_COMM_WORLD, (char *) "test.txt",
+ MPI_MODE_CREATE | MPI_MODE_WRONLY | MPI_MODE_DELETE_ON_CLOSE,
+ MPI_INFO_NULL, &fh);
if (rc) {
- errs ++;
- printf( "Unable to open test.txt for writing\n" );
+ errs++;
+ printf("Unable to open test.txt for writing\n");
}
- rc = MPI_File_create_errhandler( user_handler, &ioerr_handler );
+ rc = MPI_File_create_errhandler(user_handler, &ioerr_handler);
if (rc) {
errs++;
printf("MPI_File_create_Errhandler returned an error code: %d\n", rc);
}
- rc = MPI_File_set_errhandler( fh, ioerr_handler );
+ rc = MPI_File_set_errhandler(fh, ioerr_handler);
if (rc) {
errs++;
printf("MPI_File_set_errhandler returned an error code: %d\n", rc);
@@ -67,19 +67,19 @@ int main( int argc, char *argv[] )
}
/* This should generate an error because the file mode is WRONLY */
- rc = MPI_File_read_at( fh, 0, inbuf, 80, MPI_BYTE, &status );
+ rc = MPI_File_read_at(fh, 0, inbuf, 80, MPI_BYTE, &status);
if (handlerCalled != 1) {
- errs++;
- printf( "User-defined error handler was not called\n" );
+ errs++;
+ printf("User-defined error handler was not called\n");
}
- rc = MPI_File_close( &fh );
+ rc = MPI_File_close(&fh);
if (rc) {
errs++;
- printf("MPI_File_close returned an error code: %d\n",rc);
+ printf("MPI_File_close returned an error code: %d\n", rc);
}
- MTest_Finalize( errs );
- MPI_Finalize( );
+ MTest_Finalize(errs);
+ MPI_Finalize();
return 0;
}
diff --git a/test/mpi/manual/connectstuff.h b/test/mpi/manual/connectstuff.h
index 8da90cb..dbb7962 100644
--- a/test/mpi/manual/connectstuff.h
+++ b/test/mpi/manual/connectstuff.h
@@ -2,17 +2,17 @@
#define _CONNECTSTUFF
/* handlers */
-void startWatchdog( int seconds );
-void strokeWatchdog( void );
-void installSegvHandler( void );
-void installExitHandler( const char * fname );
-void indicateConnectSucceeded( void );
+void startWatchdog(int seconds);
+void strokeWatchdog(void);
+void installSegvHandler(void);
+void installExitHandler(const char *fname);
+void indicateConnectSucceeded(void);
/* util */
-void msg( const char * fmt, ... );
-void printStackTrace( void );
-void safeSleep( double seconds );
-char * getPortFromFile( const char * fmt, ... );
-char * writePortToFile( const char * port, const char * fmt, ... );
+void msg(const char *fmt, ...);
+void printStackTrace(void);
+void safeSleep(double seconds);
+char *getPortFromFile(const char *fmt, ...);
+char *writePortToFile(const char *port, const char *fmt, ...);
#endif
diff --git a/test/mpi/manual/dimsbalanced.c b/test/mpi/manual/dimsbalanced.c
index da883ec..e31862e 100644
--- a/test/mpi/manual/dimsbalanced.c
+++ b/test/mpi/manual/dimsbalanced.c
@@ -7,7 +7,7 @@
MPI_Dims_create is. This test can be run with a single process
and does not need mpiexec.
- There is no standard result. Instead, the output should be examined to
+ There is no standard result. Instead, the output should be examined to
see if the results are acceptable. For example, make sure that Dims_create
of 2*2*2 in three dimensions returns 2,2,2 (and not 1,1,8).
*/
@@ -17,46 +17,53 @@
static int verbose = 1;
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int i, j, dims[3], size;
- MPI_Init( &argc, &argv );
-
- for (i=2; i<12; i++) {
- for (j=0; j<2; j++) dims[j] = 0;
- MPI_Dims_create( i * i, 2, dims );
- if (verbose) printf( "Dims_create(%d,2) = (%d,%d)\n",
- i*i, dims[0], dims[1]);
- for (j=0; j<3; j++) dims[j] = 0;
- MPI_Dims_create( i * i * i, 3, dims );
- if (verbose) printf( "Dims_create(%d,3) = (%d,%d,%d)\n",
- i*i*i, dims[0], dims[1], dims[2]);
+ MPI_Init(&argc, &argv);
+
+ for (i = 2; i < 12; i++) {
+ for (j = 0; j < 2; j++)
+ dims[j] = 0;
+ MPI_Dims_create(i * i, 2, dims);
+ if (verbose)
+ printf("Dims_create(%d,2) = (%d,%d)\n", i * i, dims[0], dims[1]);
+ for (j = 0; j < 3; j++)
+ dims[j] = 0;
+ MPI_Dims_create(i * i * i, 3, dims);
+ if (verbose)
+ printf("Dims_create(%d,3) = (%d,%d,%d)\n", i * i * i, dims[0], dims[1], dims[2]);
}
- size = 2*5*7*11;
- for (j=0; j<3; j++) dims[j] = 0;
- MPI_Dims_create( size, 2, dims );
- if (verbose) printf( "Dims_create(%d,2) = (%d,%d)\n",
- size, dims[0], dims[1]);
- for (j=0; j<3; j++) dims[j] = 0;
- MPI_Dims_create( size, 3, dims );
- if (verbose) printf( "Dims_create(%d,3) = (%d,%d,%d)\n",
- size, dims[0], dims[1], dims[2]);
- size = 5*5*2*7*7*7;
- for (j=0; j<3; j++) dims[j] = 0;
- MPI_Dims_create( size, 2, dims );
- if (verbose) printf( "Dims_create(%d,2) = (%d,%d)\n",
- size, dims[0], dims[1]);
- for (j=0; j<3; j++) dims[j] = 0;
- MPI_Dims_create( size, 3, dims );
- if (verbose) printf( "Dims_create(%d,3) = (%d,%d,%d)\n",
- size, dims[0], dims[1], dims[2]);
-
+ size = 2 * 5 * 7 * 11;
+ for (j = 0; j < 3; j++)
+ dims[j] = 0;
+ MPI_Dims_create(size, 2, dims);
+ if (verbose)
+ printf("Dims_create(%d,2) = (%d,%d)\n", size, dims[0], dims[1]);
+ for (j = 0; j < 3; j++)
+ dims[j] = 0;
+ MPI_Dims_create(size, 3, dims);
+ if (verbose)
+ printf("Dims_create(%d,3) = (%d,%d,%d)\n", size, dims[0], dims[1], dims[2]);
+ size = 5 * 5 * 2 * 7 * 7 * 7;
+ for (j = 0; j < 3; j++)
+ dims[j] = 0;
+ MPI_Dims_create(size, 2, dims);
+ if (verbose)
+ printf("Dims_create(%d,2) = (%d,%d)\n", size, dims[0], dims[1]);
+ for (j = 0; j < 3; j++)
+ dims[j] = 0;
+ MPI_Dims_create(size, 3, dims);
+ if (verbose)
+ printf("Dims_create(%d,3) = (%d,%d,%d)\n", size, dims[0], dims[1], dims[2]);
+
size = 12;
- for (j=0; j<3; j++) dims[j] = 0;
- MPI_Dims_create( size, 2, dims );
- if (verbose) printf( "Dims_create(%d,2) = (%d,%d)\n",
- size, dims[0], dims[1]);
+ for (j = 0; j < 3; j++)
+ dims[j] = 0;
+ MPI_Dims_create(size, 2, dims);
+ if (verbose)
+ printf("Dims_create(%d,2) = (%d,%d)\n", size, dims[0], dims[1]);
MPI_Finalize();
diff --git a/test/mpi/manual/mpi_t/mpit_test.c b/test/mpi/manual/mpi_t/mpit_test.c
index 28db9ca..2968919 100644
--- a/test/mpi/manual/mpi_t/mpit_test.c
+++ b/test/mpi/manual/mpi_t/mpit_test.c
@@ -57,7 +57,8 @@ int main(int argc, char **argv)
assert(num != 0xdeadbeef);
for (i = 0; i < num; ++i) {
name_len = desc_len = STR_SZ;
- MPI_T_cvar_get_info(i, name, &name_len, &verb, &dtype, &enumtype, desc, &desc_len, &bind, &scope);
+ MPI_T_cvar_get_info(i, name, &name_len, &verb, &dtype, &enumtype, desc, &desc_len, &bind,
+ &scope);
printf("index=%d\n", i);
printf("--> name='%s' name_len=%d desc='%s' desc_len=%d\n", name, name_len, desc, desc_len);
printf("--> verb=%d dtype=%#x bind=%d scope=%d\n", verb, dtype, bind, scope);
@@ -85,7 +86,7 @@ int main(int argc, char **argv)
printf("--> doubled val=%f\n", val);
}
else if (dtype == MPI_CHAR) {
- char *str = malloc(count+1);
+ char *str = malloc(count + 1);
MPI_T_cvar_read(handle, str);
printf("--> str='%s'\n", str);
/* just write the string back unmodified for now */
@@ -107,13 +108,13 @@ int main(int argc, char **argv)
}
#else
-/* Simple null program to allow building this file with non-MPICH
+/* Simple null program to allow building this file with non-MPICH
implementations */
int main(int argc, char **argv)
{
- MPI_Init( &argc, &argv );
- printf( " No Errors\n" );
- MPI_Finalize();
- return 0;
+ MPI_Init(&argc, &argv);
+ printf(" No Errors\n");
+ MPI_Finalize();
+ return 0;
}
#endif
diff --git a/test/mpi/manual/mpi_t/mpit_test2.c b/test/mpi/manual/mpi_t/mpit_test2.c
index 7ff6d1f..d714b67 100644
--- a/test/mpi/manual/mpi_t/mpit_test2.c
+++ b/test/mpi/manual/mpi_t/mpit_test2.c
@@ -77,7 +77,8 @@ int main(int argc, char **argv)
assert(num != 0xdeadbeef);
for (i = 0; i < num; ++i) {
name_len = desc_len = STR_SZ;
- MPI_T_pvar_get_info(i, name, &name_len, &verb, &varclass, &dtype, &enumtype, desc, &desc_len, &bind, &readonly, &continuous, &atomic);
+ MPI_T_pvar_get_info(i, name, &name_len, &verb, &varclass, &dtype, &enumtype, desc,
+ &desc_len, &bind, &readonly, &continuous, &atomic);
printf("index=%d\n", i);
printf("--> name='%s' name_len=%d desc='%s' desc_len=%d\n", name, name_len, desc, desc_len);
printf("--> verb=%d varclass=%d dtype=%#x bind=%d readonly=%d continuous=%d atomic=%d\n",
@@ -140,29 +141,29 @@ int main(int argc, char **argv)
unexpected_queue_match_attempts = 0x0123abcd;
print_vars(1);
- MPI_Isend(&buf1, 1, MPI_INT, 0, /*tag=*/11, MPI_COMM_SELF, &r1);
+ MPI_Isend(&buf1, 1, MPI_INT, 0, /*tag= */ 11, MPI_COMM_SELF, &r1);
print_vars(2);
printf("expected (posted_qlen,unexpected_qlen) = (0,1)\n");
- MPI_Isend(&buf1, 1, MPI_INT, 0, /*tag=*/22, MPI_COMM_SELF, &r2);
+ MPI_Isend(&buf1, 1, MPI_INT, 0, /*tag= */ 22, MPI_COMM_SELF, &r2);
print_vars(3);
printf("expected (posted_qlen,unexpected_qlen) = (0,2)\n");
- MPI_Irecv(&buf2, 1, MPI_INT, 0, /*tag=*/33, MPI_COMM_SELF, &r3);
+ MPI_Irecv(&buf2, 1, MPI_INT, 0, /*tag= */ 33, MPI_COMM_SELF, &r3);
print_vars(4);
printf("expected (posted_qlen,unexpected_qlen) = (1,2)\n");
- MPI_Recv(&buf3, 1, MPI_INT, 0, /*tag=*/22, MPI_COMM_SELF, MPI_STATUS_IGNORE);
+ MPI_Recv(&buf3, 1, MPI_INT, 0, /*tag= */ 22, MPI_COMM_SELF, MPI_STATUS_IGNORE);
MPI_Wait(&r2, MPI_STATUS_IGNORE);
print_vars(5);
printf("expected (posted_qlen,unexpected_qlen) = (1,1)\n");
- MPI_Recv(&buf3, 1, MPI_INT, 0, /*tag=*/11, MPI_COMM_SELF, MPI_STATUS_IGNORE);
+ MPI_Recv(&buf3, 1, MPI_INT, 0, /*tag= */ 11, MPI_COMM_SELF, MPI_STATUS_IGNORE);
MPI_Wait(&r1, MPI_STATUS_IGNORE);
print_vars(6);
printf("expected (posted_qlen,unexpected_qlen) = (1,0)\n");
- MPI_Send(&buf3, 1, MPI_INT, 0, /*tag=*/33, MPI_COMM_SELF);
+ MPI_Send(&buf3, 1, MPI_INT, 0, /*tag= */ 33, MPI_COMM_SELF);
MPI_Wait(&r3, MPI_STATUS_IGNORE);
print_vars(7);
printf("expected (posted_qlen,unexpected_qlen) = (0,0)\n");
@@ -191,13 +192,13 @@ int main(int argc, char **argv)
return 0;
}
#else
-/* Simple null program to allow building this file with non-MPICH
+/* Simple null program to allow building this file with non-MPICH
implementations */
int main(int argc, char **argv)
{
- MPI_Init( &argc, &argv );
- printf( " No Errors\n" );
- MPI_Finalize();
- return 0;
+ MPI_Init(&argc, &argv);
+ printf(" No Errors\n");
+ MPI_Finalize();
+ return 0;
}
#endif
diff --git a/test/mpi/manual/mpi_t/nem_fbox_fallback_to_queue_count.c b/test/mpi/manual/mpi_t/nem_fbox_fallback_to_queue_count.c
index 4f4f2af..42f6884 100644
--- a/test/mpi/manual/mpi_t/nem_fbox_fallback_to_queue_count.c
+++ b/test/mpi/manual/mpi_t/nem_fbox_fallback_to_queue_count.c
@@ -24,12 +24,13 @@
err = (func); \
if (err != MPI_SUCCESS) \
MPI_Abort(MPI_COMM_WORLD, err); \
- } while(0)
+ } while (0)
#define STR_LEN 100
#define BUF_COUNT 10
uint64_t null_fbox[2] = { 0 };
+
int err, rank;
MPI_T_pvar_session session;
MPI_T_pvar_handle fbox_handle;
@@ -41,12 +42,15 @@ void blank_test()
{
uint64_t temp[2] = { -1 };
- temp[0] = 0x1234; temp[1] = 0xABCD;
+ temp[0] = 0x1234;
+ temp[1] = 0xABCD;
TRY(MPI_T_pvar_write(session, fbox_handle, temp));
- temp[0] = 0xCD34; temp[1] = 0x12AB;
+ temp[0] = 0xCD34;
+ temp[1] = 0x12AB;
TRY(MPI_T_pvar_read(session, fbox_handle, temp));
- assert(temp[0] == 0x1234); assert(temp[1] == 0xABCD);
+ assert(temp[0] == 0x1234);
+ assert(temp[1] == 0xABCD);
}
/* Nemesis' fastbox falls back to regular queues when more than one message
@@ -56,7 +60,7 @@ void blank_test()
* queue every time. */
void send_first_test()
{
- uint64_t nem_fbox_fall_back_to_queue_count[2] = {-1};
+ uint64_t nem_fbox_fall_back_to_queue_count[2] = { -1 };
/* Reset the fbox variable. */
MPI_T_pvar_reset(session, fbox_handle);
@@ -91,11 +95,12 @@ void send_first_test()
*/
MTestSleep(1);
- } else if (rank == 1) {
+ }
+ else if (rank == 1) {
char recv_buf[BUF_COUNT];
MPI_Status status;
- MTestSleep(1); /* see above */
+ MTestSleep(1); /* see above */
MPI_Recv(recv_buf, BUF_COUNT, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &status);
MPI_Recv(recv_buf, BUF_COUNT, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &status);
@@ -103,8 +108,8 @@ void send_first_test()
MPI_Recv(recv_buf, BUF_COUNT, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &status);
}
- MPI_Barrier(MPI_COMM_WORLD); /* ensure we've finished this test before
- * moving on to the next */
+ MPI_Barrier(MPI_COMM_WORLD); /* ensure we've finished this test before
+ * moving on to the next */
}
/* By posting receives ahead of time, messages should be taken out of the
@@ -116,7 +121,7 @@ void send_first_test()
*/
void recv_first_test()
{
- uint64_t nem_fbox_fall_back_to_queue_count[2] = {-1};
+ uint64_t nem_fbox_fall_back_to_queue_count[2] = { -1 };
/* Reset the fbox variable. */
MPI_T_pvar_reset(session, fbox_handle);
@@ -145,7 +150,8 @@ void recv_first_test()
MPI_Send(send_buf, BUF_COUNT, MPI_CHAR, 1, 0, MPI_COMM_WORLD);
TRY(MPI_T_pvar_read(session, fbox_handle, nem_fbox_fall_back_to_queue_count));
assert(nem_fbox_fall_back_to_queue_count[1] == 0);
- } else if (rank == 1) {
+ }
+ else if (rank == 1) {
char recv_buf[BUF_COUNT];
MPI_Request reqs[4];
@@ -162,8 +168,8 @@ void recv_first_test()
MPI_Waitall(4, reqs, status);
}
- MPI_Barrier(MPI_COMM_WORLD); /* ensure we've finished this test before
- * moving on to the next */
+ MPI_Barrier(MPI_COMM_WORLD); /* ensure we've finished this test before
+ * moving on to the next */
}
int main(int argc, char *argv[])
diff --git a/test/mpi/manual/mpi_t/unexpected_recvq_buffer_size.c b/test/mpi/manual/mpi_t/unexpected_recvq_buffer_size.c
index f30bba7..55dd71a 100644
--- a/test/mpi/manual/mpi_t/unexpected_recvq_buffer_size.c
+++ b/test/mpi/manual/mpi_t/unexpected_recvq_buffer_size.c
@@ -20,7 +20,7 @@
err = (func); \
if (err != MPI_SUCCESS) \
MPI_Abort(MPI_COMM_WORLD, err); \
- } while(0)
+ } while (0)
#define EAGER_SIZE 10
#define RNDV_SIZE 100000
@@ -43,28 +43,29 @@ void reversed_tags_test()
MPI_Send(send_buf, EAGER_SIZE, MPI_INT, 1, 0xB, MPI_COMM_WORLD);
MPI_Send(send_buf, EAGER_SIZE, MPI_INT, 1, 0xC, MPI_COMM_WORLD);
MPI_Send(send_buf, EAGER_SIZE, MPI_INT, 1, 0xD, MPI_COMM_WORLD);
- } else if (rank == 1) {
+ }
+ else if (rank == 1) {
int recv_buf[EAGER_SIZE];
MPI_Status status;
MPI_Recv(recv_buf, EAGER_SIZE, MPI_INT, 0, 0xD, MPI_COMM_WORLD, &status);
TRY(MPI_T_pvar_read(session, uqsize_handle, &unexpected_recvq_buffer_size));
- assert(unexpected_recvq_buffer_size == 3*EAGER_SIZE*sizeof(int));
+ assert(unexpected_recvq_buffer_size == 3 * EAGER_SIZE * sizeof(int));
MPI_Recv(recv_buf, EAGER_SIZE, MPI_INT, 0, 0xC, MPI_COMM_WORLD, &status);
TRY(MPI_T_pvar_read(session, uqsize_handle, &unexpected_recvq_buffer_size));
- assert(unexpected_recvq_buffer_size == 2*EAGER_SIZE*sizeof(int));
+ assert(unexpected_recvq_buffer_size == 2 * EAGER_SIZE * sizeof(int));
MPI_Recv(recv_buf, EAGER_SIZE, MPI_INT, 0, 0xB, MPI_COMM_WORLD, &status);
TRY(MPI_T_pvar_read(session, uqsize_handle, &unexpected_recvq_buffer_size));
- assert(unexpected_recvq_buffer_size == 1*EAGER_SIZE*sizeof(int));
+ assert(unexpected_recvq_buffer_size == 1 * EAGER_SIZE * sizeof(int));
MPI_Recv(recv_buf, EAGER_SIZE, MPI_INT, 0, 0xA, MPI_COMM_WORLD, &status);
TRY(MPI_T_pvar_read(session, uqsize_handle, &unexpected_recvq_buffer_size));
- assert(unexpected_recvq_buffer_size == 0*EAGER_SIZE*sizeof(int));
+ assert(unexpected_recvq_buffer_size == 0 * EAGER_SIZE * sizeof(int));
}
- MPI_Barrier(MPI_COMM_WORLD); /* make sure this test is over before going to the next one */
+ MPI_Barrier(MPI_COMM_WORLD); /* make sure this test is over before going to the next one */
}
/* Rendezvous-based messages will never be unexpected (except for the initial RTS,
@@ -79,7 +80,8 @@ void rndv_test()
MPI_Send(send_buf, RNDV_SIZE, MPI_INT, 1, 0, MPI_COMM_WORLD);
MPI_Send(send_buf, RNDV_SIZE, MPI_INT, 1, 0, MPI_COMM_WORLD);
- } else if (rank == 1) {
+ }
+ else if (rank == 1) {
int recv_buf[RNDV_SIZE];
MPI_Status status;
@@ -92,7 +94,7 @@ void rndv_test()
assert(unexpected_recvq_buffer_size == 0);
}
- MPI_Barrier(MPI_COMM_WORLD); /* make sure this test is over before going to the next one */
+ MPI_Barrier(MPI_COMM_WORLD); /* make sure this test is over before going to the next one */
}
int main(int argc, char *argv[])
diff --git a/test/mpi/manual/segfault.c b/test/mpi/manual/segfault.c
index 1364fce..52ac411 100644
--- a/test/mpi/manual/segfault.c
+++ b/test/mpi/manual/segfault.c
@@ -15,11 +15,10 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank == 0) {
- (*ptr)++; /* will segfault */
+ (*ptr)++; /* will segfault */
/* never get below here, just present to prevent dead-code elimination */
printf("*ptr=%d\n", (*ptr));
}
MPI_Finalize();
return 0;
}
-
diff --git a/test/mpi/manual/singjoin.c b/test/mpi/manual/singjoin.c
index ff9316b..0aa3590 100644
--- a/test/mpi/manual/singjoin.c
+++ b/test/mpi/manual/singjoin.c
@@ -9,7 +9,7 @@
* is started as a singleton process.
*
* To run
- *
+ *
* Start the server:
*
* ./singjoin -s -p 54321
@@ -39,252 +39,251 @@
#include <mpi.h>
#ifndef HAVE_WINDOWS_H
- #define SOCKET_FD_TYPE int
- #define INVALID_SOCKET_FD -1
+#define SOCKET_FD_TYPE int
+#define INVALID_SOCKET_FD -1
#else
- #define SOCKET_FD_TYPE SOCKET
- #define INVALID_SOCKET_FD INVALID_SOCKET
- #define bcopy(s1, s2, n) memmove(s2, s1, n)
+#define SOCKET_FD_TYPE SOCKET
+#define INVALID_SOCKET_FD INVALID_SOCKET
+#define bcopy(s1, s2, n) memmove(s2, s1, n)
#endif
-int parse_args(int argc, char ** argv);
-void usage(char * name);
+int parse_args(int argc, char **argv);
+void usage(char *name);
SOCKET_FD_TYPE server_routine(int portnum);
SOCKET_FD_TYPE client_routine(int portnum);
-int is_server=0;
-int is_client=0;
-int opt_port=0;
+int is_server = 0;
+int is_client = 0;
+int opt_port = 0;
/* open a socket, establish a connection with a client, and return the fd */
SOCKET_FD_TYPE server_routine(int portnum)
{
- SOCKET_FD_TYPE listenfd, peer_fd;
+ SOCKET_FD_TYPE listenfd, peer_fd;
int ret, peer_addr_size;
- struct sockaddr_in server_addr, peer_addr;
-
- listenfd = socket(AF_INET, SOCK_STREAM, 0);
- if (listenfd == INVALID_SOCKET_FD) {
- perror("server socket");
- return -1;
- }
-
- memset(&server_addr, 0, sizeof(server_addr));
- server_addr.sin_family = AF_INET;
- server_addr.sin_addr.s_addr = INADDR_ANY;
- server_addr.sin_port = htons(portnum);
- ret = bind(listenfd, (struct sockaddr *)&server_addr, sizeof(server_addr));
- if (ret < 0) {
- perror("server binding");
- return -1;
- }
-
- ret = listen(listenfd, 1024);
- if (ret < 0) {
- perror( "server listen" );
- return -1;
- }
+ struct sockaddr_in server_addr, peer_addr;
- peer_addr_size = sizeof(peer_addr);
- peer_fd = accept(listenfd, (struct sockaddr *)&peer_addr, &peer_addr_size);
+ listenfd = socket(AF_INET, SOCK_STREAM, 0);
+ if (listenfd == INVALID_SOCKET_FD) {
+ perror("server socket");
+ return -1;
+ }
- if (peer_fd < 0) {
- perror( "server accept" );
- return -1;
- }
- return peer_fd;
+ memset(&server_addr, 0, sizeof(server_addr));
+ server_addr.sin_family = AF_INET;
+ server_addr.sin_addr.s_addr = INADDR_ANY;
+ server_addr.sin_port = htons(portnum);
+ ret = bind(listenfd, (struct sockaddr *) &server_addr, sizeof(server_addr));
+ if (ret < 0) {
+ perror("server binding");
+ return -1;
+ }
+
+ ret = listen(listenfd, 1024);
+ if (ret < 0) {
+ perror("server listen");
+ return -1;
+ }
+
+ peer_addr_size = sizeof(peer_addr);
+ peer_fd = accept(listenfd, (struct sockaddr *) &peer_addr, &peer_addr_size);
+
+ if (peer_fd < 0) {
+ perror("server accept");
+ return -1;
+ }
+ return peer_fd;
}
/* open a socket, establish a connection with a server, and return the fd */
SOCKET_FD_TYPE client_routine(int portnum)
{
- SOCKET_FD_TYPE sockfd;
- struct sockaddr_in server_addr;
- struct hostent *server_ent;
- char hostname[MPI_MAX_PROCESSOR_NAME];
- int hostnamelen;
-
- sockfd = socket(AF_INET, SOCK_STREAM, 0);
- if (sockfd == INVALID_SOCKET_FD) {
- perror("client socket");
- return -1;
- }
-
- /* Try to get the processor name from MPI */
- MPI_Get_processor_name( hostname, &hostnamelen );
- server_ent = gethostbyname(hostname);
- if (server_ent == NULL) {
- fprintf(stderr, "gethostbyname fails\n");
- return -1;
- }
-
- memset(&server_addr, 0, sizeof(server_addr));
- server_addr.sin_family = AF_INET;
- server_addr.sin_port = htons(portnum);
- /* POSIX might define h_addr_list only and not define h_addr */
+ SOCKET_FD_TYPE sockfd;
+ struct sockaddr_in server_addr;
+ struct hostent *server_ent;
+ char hostname[MPI_MAX_PROCESSOR_NAME];
+ int hostnamelen;
+
+ sockfd = socket(AF_INET, SOCK_STREAM, 0);
+ if (sockfd == INVALID_SOCKET_FD) {
+ perror("client socket");
+ return -1;
+ }
+
+ /* Try to get the processor name from MPI */
+ MPI_Get_processor_name(hostname, &hostnamelen);
+ server_ent = gethostbyname(hostname);
+ if (server_ent == NULL) {
+ fprintf(stderr, "gethostbyname fails\n");
+ return -1;
+ }
+
+ memset(&server_addr, 0, sizeof(server_addr));
+ server_addr.sin_family = AF_INET;
+ server_addr.sin_port = htons(portnum);
+ /* POSIX might define h_addr_list only and not define h_addr */
#ifdef HAVE_H_ADDR_LIST
- bcopy(server_ent->h_addr_list[0],
- (char *)&server_addr.sin_addr.s_addr, server_ent->h_length);
+ bcopy(server_ent->h_addr_list[0], (char *) &server_addr.sin_addr.s_addr, server_ent->h_length);
#else
- bcopy(server_ent->h_addr,
- (char *)&server_addr.sin_addr.s_addr, server_ent->h_length);
+ bcopy(server_ent->h_addr, (char *) &server_addr.sin_addr.s_addr, server_ent->h_length);
#endif
- if (connect(sockfd, (struct sockaddr* )&server_addr, sizeof(server_addr)) < 0) {
- perror("client connect");
- return -1;
- }
- return sockfd;
+ if (connect(sockfd, (struct sockaddr *) &server_addr, sizeof(server_addr)) < 0) {
+ perror("client connect");
+ return -1;
+ }
+ return sockfd;
}
-void usage(char * name)
+void usage(char *name)
{
- fprintf(stderr, "usage: %s [-s|-c] -p <PORT>\n", name);
- fprintf(stderr, " specify one and only one of -s or -c\n");
- fprintf(stderr, " port is mandatory\n");
+ fprintf(stderr, "usage: %s [-s|-c] -p <PORT>\n", name);
+ fprintf(stderr, " specify one and only one of -s or -c\n");
+ fprintf(stderr, " port is mandatory\n");
}
#ifdef HAVE_WINDOWS_H
-static int get_option(int argc, char **argv, int arg_cnt){
- if(argv == NULL){
- return -1;
+static int get_option(int argc, char **argv, int arg_cnt)
+{
+ if (argv == NULL) {
+ return -1;
}
- if(*argv == NULL){
+ if (*argv == NULL) {
return -1;
}
- if(arg_cnt < 0 || arg_cnt >= argc){
+ if (arg_cnt < 0 || arg_cnt >= argc) {
return -1;
}
- if(strlen(argv[arg_cnt]) < 2){
+ if (strlen(argv[arg_cnt]) < 2) {
return -1;
}
- return(*(argv[arg_cnt]+1));
+ return (*(argv[arg_cnt] + 1));
}
#endif
-int parse_args(int argc, char ** argv)
+int parse_args(int argc, char **argv)
{
#ifndef HAVE_WINDOWS_H
- int c;
- extern char* optarg;
- while ( (c = getopt(argc, argv, "csp:")) != -1 ) {
- switch (c) {
- case 's':
- is_server = 1;
- break;
- case 'c':
- is_client = 1;
- break;
- case 'p':
- opt_port = atoi(optarg);
- break;
- case '?':
- case ':':
- default:
- usage(argv[0]);
- return -1;
- }
- }
- if ( (is_client == 0 ) && (is_server == 0)) {
- usage(argv[0]);
- return -1;
- }
- if (opt_port == 0) {
- usage(argv[0]);
- return -1;
- }
- return 0;
+ int c;
+ extern char *optarg;
+ while ((c = getopt(argc, argv, "csp:")) != -1) {
+ switch (c) {
+ case 's':
+ is_server = 1;
+ break;
+ case 'c':
+ is_client = 1;
+ break;
+ case 'p':
+ opt_port = atoi(optarg);
+ break;
+ case '?':
+ case ':':
+ default:
+ usage(argv[0]);
+ return -1;
+ }
+ }
+ if ((is_client == 0) && (is_server == 0)) {
+ usage(argv[0]);
+ return -1;
+ }
+ if (opt_port == 0) {
+ usage(argv[0]);
+ return -1;
+ }
+ return 0;
#else
- int arg_cnt=1;
+ int arg_cnt = 1;
int c;
- while((c = get_option(argc, argv, arg_cnt++)) > 0){
- switch(c){
+ while ((c = get_option(argc, argv, arg_cnt++)) > 0) {
+ switch (c) {
case 's':
- is_server = 1;
- break;
+ is_server = 1;
+ break;
case 'c':
- is_client = 1;
- break;
+ is_client = 1;
+ break;
case 'p':
- opt_port = atoi(argv[arg_cnt++]);
- break;
+ opt_port = atoi(argv[arg_cnt++]);
+ break;
default:
- usage(argv[0]);
- return -1;
+ usage(argv[0]);
+ return -1;
}
}
- if ( (is_client == 0 ) && (is_server == 0)) {
- usage(argv[0]);
+ if ((is_client == 0) && (is_server == 0)) {
+ usage(argv[0]);
return -1;
- }
- if (opt_port == 0) {
- usage(argv[0]);
+ }
+ if (opt_port == 0) {
+ usage(argv[0]);
return -1;
- }
+ }
return 0;
#endif
}
-int main (int argc, char ** argv)
+int main(int argc, char **argv)
{
- int rank, size;
+ int rank, size;
SOCKET_FD_TYPE fd = INVALID_SOCKET_FD;
- MPI_Comm intercomm, intracomm;
-
- MPI_Init(&argc, &argv);
- MPI_Comm_size( MPI_COMM_WORLD, &size );
- if (size != 1) {
- fprintf( stderr, "This test requires that only one process be in each comm_world\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- if(parse_args(argc, argv) == -1){
+ MPI_Comm intercomm, intracomm;
+
+ MPI_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ if (size != 1) {
+ fprintf(stderr, "This test requires that only one process be in each comm_world\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ if (parse_args(argc, argv) == -1) {
fprintf(stderr, "Unable to parse the command line arguments\n");
MPI_Abort(MPI_COMM_WORLD, 1);
}
- if (is_server) {
- fd = server_routine(opt_port);
+ if (is_server) {
+ fd = server_routine(opt_port);
- } else if (is_client) {
- fd = client_routine(opt_port);
- }
+ }
+ else if (is_client) {
+ fd = client_routine(opt_port);
+ }
- if (fd == INVALID_SOCKET_FD) {
- return -1;
- }
+ if (fd == INVALID_SOCKET_FD) {
+ return -1;
+ }
#ifdef SINGLETON_KICK
/* #warning isn't standard C, so we comment out this directive */
/* #warning using singleton workaround */
- {
- int *usize, aflag;
- MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_UNIVERSE_SIZE,
- &usize, &aflag);
- }
+ {
+ int *usize, aflag;
+ MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_UNIVERSE_SIZE, &usize, &aflag);
+ }
#endif
- MPI_Comm_join(fd, &intercomm);
+ MPI_Comm_join(fd, &intercomm);
- if (is_server) {
- MPI_Send( MPI_BOTTOM, 0, MPI_INT, 0, 0, intercomm );
- }
- else {
- MPI_Recv( MPI_BOTTOM, 0, MPI_INT, 0, 0, intercomm,
- MPI_STATUS_IGNORE );
- printf( "Completed receive on intercomm\n" ); fflush(stdout);
- }
+ if (is_server) {
+ MPI_Send(MPI_BOTTOM, 0, MPI_INT, 0, 0, intercomm);
+ }
+ else {
+ MPI_Recv(MPI_BOTTOM, 0, MPI_INT, 0, 0, intercomm, MPI_STATUS_IGNORE);
+ printf("Completed receive on intercomm\n");
+ fflush(stdout);
+ }
- MPI_Intercomm_merge(intercomm, 0, &intracomm);
- MPI_Comm_rank(intracomm, &rank);
- MPI_Comm_size(intracomm, &size);
+ MPI_Intercomm_merge(intercomm, 0, &intracomm);
+ MPI_Comm_rank(intracomm, &rank);
+ MPI_Comm_size(intracomm, &size);
- printf("[%d/%d] after Intercomm_merge\n", rank, size);
+ printf("[%d/%d] after Intercomm_merge\n", rank, size);
- MPI_Comm_free(&intracomm);
- MPI_Comm_disconnect(&intercomm);
- MPI_Finalize();
- return 0;
+ MPI_Comm_free(&intracomm);
+ MPI_Comm_disconnect(&intercomm);
+ MPI_Finalize();
+ return 0;
}
diff --git a/test/mpi/manual/spawntest_child.c b/test/mpi/manual/spawntest_child.c
index ea74199..1a2716c 100644
--- a/test/mpi/manual/spawntest_child.c
+++ b/test/mpi/manual/spawntest_child.c
@@ -1,10 +1,10 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
-/*
+/*
* (C) 2009 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-/*
+/*
* Test code provided by Guruprasad H. Kora
*/
@@ -14,37 +14,38 @@
int main(int argc, char **argv)
{
- int my_rank;
- int size;
- MPI_Comm parentcomm;
- MPI_Comm allcomm;
-
- MPI_Init(&argc, &argv);
-
- MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
- MPI_Comm_size(MPI_COMM_WORLD, &size);
-
- MPI_Comm_get_parent(&parentcomm);
-
- if ( parentcomm == MPI_COMM_NULL )
- {
- fprintf(stdout, "parentcomm is null\n");
+ int my_rank;
+ int size;
+ MPI_Comm parentcomm;
+ MPI_Comm allcomm;
+
+ MPI_Init(&argc, &argv);
+
+ MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+
+ MPI_Comm_get_parent(&parentcomm);
+
+ if (parentcomm == MPI_COMM_NULL) {
+ fprintf(stdout, "parentcomm is null\n");
}
-
- MPI_Intercomm_merge( parentcomm, 1, &allcomm);
-
- /* Without the Free of allcomm, the children *must not exit* until the
- master calls MPI_Finalize. */
- MPI_Barrier( allcomm );
- /* According to 10.5.4, case 1b in MPI2.2, the children and master are
- still connected unless MPI_Comm_disconnect is used with allcomm.
- MPI_Comm_free is not sufficient */
- MPI_Comm_free( &allcomm );
- MPI_Comm_disconnect( &parentcomm );
-
- fprintf(stdout, "%s:%d\n", __FILE__, __LINE__ );fflush(stdout);
- MPI_Finalize();
-
- fprintf(stdout, "%d:child exiting.\n", my_rank );fflush(stdout);
- return 0;
+
+ MPI_Intercomm_merge(parentcomm, 1, &allcomm);
+
+ /* Without the Free of allcomm, the children *must not exit* until the
+ * master calls MPI_Finalize. */
+ MPI_Barrier(allcomm);
+ /* According to 10.5.4, case 1b in MPI2.2, the children and master are
+ * still connected unless MPI_Comm_disconnect is used with allcomm.
+ * MPI_Comm_free is not sufficient */
+ MPI_Comm_free(&allcomm);
+ MPI_Comm_disconnect(&parentcomm);
+
+ fprintf(stdout, "%s:%d\n", __FILE__, __LINE__);
+ fflush(stdout);
+ MPI_Finalize();
+
+ fprintf(stdout, "%d:child exiting.\n", my_rank);
+ fflush(stdout);
+ return 0;
}
diff --git a/test/mpi/manual/spawntest_master.c b/test/mpi/manual/spawntest_master.c
index b576649..396042a 100644
--- a/test/mpi/manual/spawntest_master.c
+++ b/test/mpi/manual/spawntest_master.c
@@ -1,10 +1,10 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
-/*
+/*
* (C) 2009 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-/*
+/*
* Test code provided by Guruprasad H. Kora
*/
@@ -15,46 +15,48 @@
#define NUM_SPAWNS 4
-int main( int argc, char *argv[] ) {
- int np = NUM_SPAWNS;
- int my_rank, size;
- int errcodes[NUM_SPAWNS];
- MPI_Comm allcomm;
- MPI_Comm intercomm;
-
- MPI_Init( &argc, &argv );
- MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
- MPI_Comm_size(MPI_COMM_WORLD, &size);
-
-
- MPI_Comm_spawn( (char*)"./spawntest_child", MPI_ARGV_NULL, np,
- MPI_INFO_NULL, 0, MPI_COMM_WORLD, &intercomm, errcodes );
-
- if ( intercomm == MPI_COMM_NULL ) {
- fprintf(stdout, "intercomm is null\n");
- }
-
- MPI_Intercomm_merge(intercomm, 0, &allcomm);
-
- MPI_Comm_rank(allcomm, &my_rank);
- MPI_Comm_size(allcomm, &size);
-
- /* Without the Free of allcomm, the children *must not exit* until the
- master calls MPI_Finalize. */
- MPI_Barrier( allcomm );
- /* According to 10.5.4, case 1b in MPI2.2, the children and master are
- still connected unless MPI_Comm_disconnect is used with allcomm.
- MPI_Comm_free is not sufficient */
- MPI_Comm_free( &allcomm );
- MPI_Comm_disconnect( &intercomm );
-
- fprintf(stdout, "%s:%d: MTestSleep starting; children should exit\n",
- __FILE__, __LINE__ );fflush(stdout);
- MTestSleep(30);
- fprintf(stdout,
- "%s:%d: MTestSleep done; all children should have already exited\n",
- __FILE__, __LINE__ );fflush(stdout);
-
- MPI_Finalize();
- return 0;
+int main(int argc, char *argv[])
+{
+ int np = NUM_SPAWNS;
+ int my_rank, size;
+ int errcodes[NUM_SPAWNS];
+ MPI_Comm allcomm;
+ MPI_Comm intercomm;
+
+ MPI_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+
+
+ MPI_Comm_spawn((char *) "./spawntest_child", MPI_ARGV_NULL, np,
+ MPI_INFO_NULL, 0, MPI_COMM_WORLD, &intercomm, errcodes);
+
+ if (intercomm == MPI_COMM_NULL) {
+ fprintf(stdout, "intercomm is null\n");
+ }
+
+ MPI_Intercomm_merge(intercomm, 0, &allcomm);
+
+ MPI_Comm_rank(allcomm, &my_rank);
+ MPI_Comm_size(allcomm, &size);
+
+ /* Without the Free of allcomm, the children *must not exit* until the
+ * master calls MPI_Finalize. */
+ MPI_Barrier(allcomm);
+ /* According to 10.5.4, case 1b in MPI2.2, the children and master are
+ * still connected unless MPI_Comm_disconnect is used with allcomm.
+ * MPI_Comm_free is not sufficient */
+ MPI_Comm_free(&allcomm);
+ MPI_Comm_disconnect(&intercomm);
+
+ fprintf(stdout, "%s:%d: MTestSleep starting; children should exit\n", __FILE__, __LINE__);
+ fflush(stdout);
+ MTestSleep(30);
+ fprintf(stdout,
+ "%s:%d: MTestSleep done; all children should have already exited\n",
+ __FILE__, __LINE__);
+ fflush(stdout);
+
+ MPI_Finalize();
+ return 0;
}
diff --git a/test/mpi/manual/tchandlers.c b/test/mpi/manual/tchandlers.c
index d6e63fa..f659913 100644
--- a/test/mpi/manual/tchandlers.c
+++ b/test/mpi/manual/tchandlers.c
@@ -20,82 +20,90 @@
#include "connectstuff.h"
static char sFnameToDelete[PATH_MAX];
-static int sWatchdogTimeout = -1;
+static int sWatchdogTimeout = -1;
static size_t sWatchdogStrokeCount = 0;
-static void * threadLooper( void * x ) {
+static void *threadLooper(void *x)
+{
int runTime = 0;
size_t lastStrokeSeen = sWatchdogStrokeCount;
/* allow to run for up to 2 minutes */
- while( runTime < sWatchdogTimeout ) {
- safeSleep( 5 );
+ while (runTime < sWatchdogTimeout) {
+ safeSleep(5);
runTime += 5;
- if( lastStrokeSeen == sWatchdogStrokeCount ) {
- msg( "Watchdog not stroked for a while, printing stack: \n" );
+ if (lastStrokeSeen == sWatchdogStrokeCount) {
+ msg("Watchdog not stroked for a while, printing stack: \n");
printStackTrace();
}
lastStrokeSeen = sWatchdogStrokeCount;
}
- msg( "Watchdog about to abort with a timeout after %d\n", runTime );
- _exit( 20 );
+ msg("Watchdog about to abort with a timeout after %d\n", runTime);
+ _exit(20);
return NULL;
}
-static void term_handler( int sig ) {
- msg( "removing file: %s\n", sFnameToDelete );
- unlink( sFnameToDelete );
+static void term_handler(int sig)
+{
+ msg("removing file: %s\n", sFnameToDelete);
+ unlink(sFnameToDelete);
}
-static void segv_handler( int sig ) {
- msg( "SEGV detected!\n" );
+static void segv_handler(int sig)
+{
+ msg("SEGV detected!\n");
printStackTrace();
- _exit( 10 );
+ _exit(10);
}
-void indicateConnectSucceeded( void ) {
+void indicateConnectSucceeded(void)
+{
char fnameToCreate[PATH_MAX];
- FILE * fp;
- snprintf( fnameToCreate, PATH_MAX, "%s.done", sFnameToDelete );
- msg( "Creating file: %s\n", fnameToCreate );
- fp = fopen( fnameToCreate, "wt" );
- if( fp != NULL ) {
- fclose( fp );
+ FILE *fp;
+ snprintf(fnameToCreate, PATH_MAX, "%s.done", sFnameToDelete);
+ msg("Creating file: %s\n", fnameToCreate);
+ fp = fopen(fnameToCreate, "wt");
+ if (fp != NULL) {
+ fclose(fp);
}
}
-void startWatchdog( int seconds ) {
+void startWatchdog(int seconds)
+{
pthread_t theThread;
sWatchdogTimeout = seconds;
- msg( "Starting watchdog - timeout in %d\n", seconds );
- pthread_create( &theThread, NULL, threadLooper, NULL );
+ msg("Starting watchdog - timeout in %d\n", seconds);
+ pthread_create(&theThread, NULL, threadLooper, NULL);
}
-void strokeWatchdog() {
+void strokeWatchdog()
+{
sWatchdogStrokeCount++;
}
-void installSegvHandler( void ) {
+void installSegvHandler(void)
+{
struct sigaction new_action;
new_action.sa_handler = segv_handler;
- sigemptyset( &new_action.sa_mask );
+ sigemptyset(&new_action.sa_mask);
new_action.sa_flags = 0;
- sigaction( SIGSEGV, &new_action, NULL );
- msg( "Installed SEGV handler\n" );
+ sigaction(SIGSEGV, &new_action, NULL);
+ msg("Installed SEGV handler\n");
}
-void installExitHandler( const char * fname ) {
+void installExitHandler(const char *fname)
+{
/* Install signal handler */
struct sigaction new_action;
- if( strlen( fname ) > PATH_MAX ) {
- msg( "Fname: <%s> too long - aborting", fname );
- _exit( 12 );
+ if (strlen(fname) > PATH_MAX) {
+ msg("Fname: <%s> too long - aborting", fname);
+ _exit(12);
}
- strncpy( sFnameToDelete, fname, PATH_MAX );
+ strncpy(sFnameToDelete, fname, PATH_MAX);
new_action.sa_handler = term_handler;
- sigemptyset( &new_action.sa_mask );
+ sigemptyset(&new_action.sa_mask);
new_action.sa_flags = 0;
- sigaction( SIGINT, &new_action, NULL );
- sigaction( SIGTERM, &new_action, NULL );
- msg( "Installed signal handlers\n" );
+ sigaction(SIGINT, &new_action, NULL);
+ sigaction(SIGTERM, &new_action, NULL);
+ msg("Installed signal handlers\n");
}
diff --git a/test/mpi/manual/tcutil.c b/test/mpi/manual/tcutil.c
index d12af44..0a3a4b8 100644
--- a/test/mpi/manual/tcutil.c
+++ b/test/mpi/manual/tcutil.c
@@ -23,88 +23,94 @@
#include "connectstuff.h"
-static void printTimeStamp( void ) {
+static void printTimeStamp(void)
+{
time_t t;
- struct tm * ltime;
- time( &t );
- ltime = localtime( &t );
- printf( "%04d-%02d-%02d %02d:%02d:%02d: ", 1900 + ltime->tm_year,
- ltime->tm_mon, ltime->tm_mday, ltime->tm_hour, ltime->tm_min, ltime->tm_sec );
- fflush( stdout );
+ struct tm *ltime;
+ time(&t);
+ ltime = localtime(&t);
+ printf("%04d-%02d-%02d %02d:%02d:%02d: ", 1900 + ltime->tm_year,
+ ltime->tm_mon, ltime->tm_mday, ltime->tm_hour, ltime->tm_min, ltime->tm_sec);
+ fflush(stdout);
}
-void safeSleep( double seconds ) {
+void safeSleep(double seconds)
+{
struct timespec sleepAmt = { 0, 0 };
int ret = 0;
- sleepAmt.tv_sec = floor( seconds );
- sleepAmt.tv_nsec = 1e9 * ( seconds - floor( seconds ) );
- ret = nanosleep( &sleepAmt, NULL );
- if( ret == -1 ) {
- printf( "Safesleep returned early. Sorry\n" );
+ sleepAmt.tv_sec = floor(seconds);
+ sleepAmt.tv_nsec = 1e9 * (seconds - floor(seconds));
+ ret = nanosleep(&sleepAmt, NULL);
+ if (ret == -1) {
+ printf("Safesleep returned early. Sorry\n");
}
}
-void printStackTrace() {
+void printStackTrace()
+{
static char cmd[512];
- int ierr;
- snprintf( cmd, 512, "/bin/sh -c \"/home/eellis/bin/pstack1 %d\"", getpid() );
- ierr = system( cmd );
- fflush( stdout );
+ int ierr;
+ snprintf(cmd, 512, "/bin/sh -c \"/home/eellis/bin/pstack1 %d\"", getpid());
+ ierr = system(cmd);
+ fflush(stdout);
}
-void msg( const char * fmt, ... ) {
+void msg(const char *fmt, ...)
+{
va_list ap;
- va_start( ap, fmt );
+ va_start(ap, fmt);
printTimeStamp();
- vprintf( fmt, ap );
- fflush( stdout );
- va_end( ap );
+ vprintf(fmt, ap);
+ fflush(stdout);
+ va_end(ap);
}
/*
* You should free the string once you've used it
*/
-char * getPortFromFile( const char * fmt, ... ) {
+char *getPortFromFile(const char *fmt, ...)
+{
char fname[PATH_MAX];
char dirname[PATH_MAX];
char *retPort;
char *cerr;
va_list ap;
- FILE * fp;
+ FILE *fp;
int done = 0;
int count = 0; /* Just used for the NFS sync - not really a count */
-
- retPort = (char * ) calloc( MPI_MAX_PORT_NAME + 1, sizeof( char ) );
- va_start( ap, fmt );
- vsnprintf( fname, PATH_MAX, fmt, ap );
- va_end( ap );
-
- srand( getpid() );
+ retPort = (char *) calloc(MPI_MAX_PORT_NAME + 1, sizeof(char));
- while( !done ) {
+ va_start(ap, fmt);
+ vsnprintf(fname, PATH_MAX, fmt, ap);
+ va_end(ap);
+
+ srand(getpid());
+
+ while (!done) {
count += rand();
- fp = fopen( fname, "rt" );
- if( fp != NULL ) {
- cerr = fgets( retPort, MPI_MAX_PORT_NAME, fp );
- fclose( fp );
+ fp = fopen(fname, "rt");
+ if (fp != NULL) {
+ cerr = fgets(retPort, MPI_MAX_PORT_NAME, fp);
+ fclose(fp);
/* ignore bogus tag - assume that the real tag must be longer than 8
* characters */
- if( strlen( retPort ) >= 8 ) {
+ if (strlen(retPort) >= 8) {
done = 1;
- }
- }
- if ( !done ) {
+ }
+ }
+ if (!done) {
int retcode;
- safeSleep( 0.1 );
+ safeSleep(0.1);
/* force NFS to update by creating and then deleting a subdirectory. Ouch. */
- snprintf( dirname, PATH_MAX, "%s___%d", fname, count );
- retcode = mkdir( dirname, 0777 );
- if( retcode != 0 ) {
- perror( "Calling mkdir" );
- _exit( 9 );
- } else {
- rmdir( dirname );
+ snprintf(dirname, PATH_MAX, "%s___%d", fname, count);
+ retcode = mkdir(dirname, 0777);
+ if (retcode != 0) {
+ perror("Calling mkdir");
+ _exit(9);
+ }
+ else {
+ rmdir(dirname);
}
}
}
@@ -114,21 +120,22 @@ char * getPortFromFile( const char * fmt, ... ) {
/*
* Returns the filename written to. Free this once you're done.
*/
-char * writePortToFile( const char * port, const char * fmt, ... ) {
- char * fname;
+char *writePortToFile(const char *port, const char *fmt, ...)
+{
+ char *fname;
va_list ap;
- FILE * fp;
-
- fname = (char *) calloc( PATH_MAX, sizeof( char ) );
-
- va_start( ap, fmt );
- vsnprintf( fname, PATH_MAX, fmt, ap );
- va_end( ap );
-
- fp = fopen( fname, "wt" );
- fprintf( fp, "%s\n", port );
- fclose( fp );
-
- msg( "Wrote port <%s> to file <%s>\n", port, fname );
+ FILE *fp;
+
+ fname = (char *) calloc(PATH_MAX, sizeof(char));
+
+ va_start(ap, fmt);
+ vsnprintf(fname, PATH_MAX, fmt, ap);
+ va_end(ap);
+
+ fp = fopen(fname, "wt");
+ fprintf(fp, "%s\n", port);
+ fclose(fp);
+
+ msg("Wrote port <%s> to file <%s>\n", port, fname);
return fname;
}
diff --git a/test/mpi/manual/testconnect.c b/test/mpi/manual/testconnect.c
index f82166f..2486e02 100644
--- a/test/mpi/manual/testconnect.c
+++ b/test/mpi/manual/testconnect.c
@@ -4,7 +4,7 @@
* See COPYRIGHT in top-level directory.
*/
-/* Test from Edric Ellis
+/* Test from Edric Ellis
To launch,
Run multiple copies of "testconnect" should be run something like this:
@@ -20,115 +20,118 @@
#include <stdlib.h>
#include <unistd.h>
-char * fname;
-int cachedRank = -1;
+char *fname;
+int cachedRank = -1;
MPI_Comm comm;
-void term_handler( int );
-void segv_handler( int );
+void term_handler(int);
+void segv_handler(int);
-void term_handler( int sig ) {
- if (sig) {
- printf( "Saw signal %d\n", sig );
- }
- printf( "removing file: %s\n", fname ); fflush(stdout);
- unlink( fname );
+void term_handler(int sig)
+{
+ if (sig) {
+ printf("Saw signal %d\n", sig);
+ }
+ printf("removing file: %s\n", fname);
+ fflush(stdout);
+ unlink(fname);
if (sig != 0) {
- MPI_Abort( comm, 42 );
- exit( 0 );
+ MPI_Abort(comm, 42);
+ exit(0);
}
}
-void segv_handler( int sig ) {
- printf( "SEGV detected!\n" ); fflush(stdout);
+void segv_handler(int sig)
+{
+ printf("SEGV detected!\n");
+ fflush(stdout);
}
-int main( int argc, char ** argv ) {
+int main(int argc, char **argv)
+{
MPI_Comm tmp;
int size = 0;
char portName[MPI_MAX_PORT_NAME];
- char * port = &portName[0];
+ char *port = &portName[0];
int doPrint = 1;
int totalSize = 0;
int myNum = -1;
- FILE * fh;
+ FILE *fh;
- if( argc < 4 ) {
- printf( "Please call with a filename for the port\n" );
- exit( 1 );
+ if (argc < 4) {
+ printf("Please call with a filename for the port\n");
+ exit(1);
}
fname = argv[1];
- totalSize = atoi( argv[2] );
- if (argv[3])
- myNum = atoi( argv[3] );
- printf( "[%d] Waiting for: %d\n", myNum, totalSize );
-
- MPI_Init( 0, 0 );
-
- /* the existance of the file is used to decide which processes
- first do a connect to the root process. */
- fh = fopen( fname, "rt" );
- if( fh == NULL ) {
- fh = fopen( fname, "wt" );
- MPI_Open_port( MPI_INFO_NULL, portName );
+ totalSize = atoi(argv[2]);
+ if (argv[3])
+ myNum = atoi(argv[3]);
+ printf("[%d] Waiting for: %d\n", myNum, totalSize);
+
+ MPI_Init(0, 0);
+
+ /* the existance of the file is used to decide which processes
+ * first do a connect to the root process. */
+ fh = fopen(fname, "rt");
+ if (fh == NULL) {
+ fh = fopen(fname, "wt");
+ MPI_Open_port(MPI_INFO_NULL, portName);
port = portName;
- fprintf( fh, "%s\n", portName );
- fclose( fh );
+ fprintf(fh, "%s\n", portName);
+ fclose(fh);
- if (doPrint) {
- printf( "[%d] Wrote port %s to %s\n", myNum, port, fname ); fflush(stdout);
- }
+ if (doPrint) {
+ printf("[%d] Wrote port %s to %s\n", myNum, port, fname);
+ fflush(stdout);
+ }
comm = MPI_COMM_WORLD;
- } else {
+ }
+ else {
char *cerr;
- cerr = fgets( port, MPI_MAX_PORT_NAME, fh );
- fclose( fh );
- if (doPrint) {
- printf( "[%d] about to connect: Port from %s is: %s\n",
- myNum, fname, port );
- fflush(stdout);
- }
- MPI_Comm_connect( port, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &tmp );
- if (doPrint) {
- printf( "[%d] connect-side: about to perform intercomm merge\n",
- myNum );
- fflush(stdout);
- }
- MPI_Intercomm_merge( tmp, 1, &comm );
- if (doPrint) {
- printf( "[%d] connect-side: intercomm merge complete\n", myNum );
- fflush(stdout);
- }
- MPI_Comm_free( &tmp );
+ cerr = fgets(port, MPI_MAX_PORT_NAME, fh);
+ fclose(fh);
+ if (doPrint) {
+ printf("[%d] about to connect: Port from %s is: %s\n", myNum, fname, port);
+ fflush(stdout);
+ }
+ MPI_Comm_connect(port, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &tmp);
+ if (doPrint) {
+ printf("[%d] connect-side: about to perform intercomm merge\n", myNum);
+ fflush(stdout);
+ }
+ MPI_Intercomm_merge(tmp, 1, &comm);
+ if (doPrint) {
+ printf("[%d] connect-side: intercomm merge complete\n", myNum);
+ fflush(stdout);
+ }
+ MPI_Comm_free(&tmp);
}
- MPI_Comm_size( comm, &size );
-
- while( size < totalSize ) {
- MPI_Comm_accept( port, MPI_INFO_NULL, 0, comm, &tmp );
- if (doPrint) {
- printf( "[%d] accept-side: about to perform intercomm merge\n",
- myNum );
- fflush(stdout);
- }
- MPI_Intercomm_merge( tmp, 0, &comm );
- if (doPrint) {
- printf( "[%d] accept-side: about to perform intercomm merge\n",
- myNum );
- fflush(stdout);
- }
- MPI_Comm_rank( comm, &cachedRank );
- MPI_Comm_free( &tmp );
- MPI_Comm_size( comm, &size );
- if( doPrint ) {
- printf( "[%d] Size of comm is %d\n", myNum, size );
- fflush( stdout );
+ MPI_Comm_size(comm, &size);
+
+ while (size < totalSize) {
+ MPI_Comm_accept(port, MPI_INFO_NULL, 0, comm, &tmp);
+ if (doPrint) {
+ printf("[%d] accept-side: about to perform intercomm merge\n", myNum);
+ fflush(stdout);
+ }
+ MPI_Intercomm_merge(tmp, 0, &comm);
+ if (doPrint) {
+ printf("[%d] accept-side: about to perform intercomm merge\n", myNum);
+ fflush(stdout);
+ }
+ MPI_Comm_rank(comm, &cachedRank);
+ MPI_Comm_free(&tmp);
+ MPI_Comm_size(comm, &size);
+ if (doPrint) {
+ printf("[%d] Size of comm is %d\n", myNum, size);
+ fflush(stdout);
}
}
- printf( "[%d] All done.\n", myNum );
- fflush( stdout );
- term_handler( 0 );
+ printf("[%d] All done.\n", myNum);
+ fflush(stdout);
+ term_handler(0);
MPI_Finalize();
diff --git a/test/mpi/manual/testconnectserial.c b/test/mpi/manual/testconnectserial.c
index 8e3fc69..19f9a56 100644
--- a/test/mpi/manual/testconnectserial.c
+++ b/test/mpi/manual/testconnectserial.c
@@ -15,116 +15,118 @@
#include "connectstuff.h"
-int main( int argc, char ** argv ) {
+int main(int argc, char **argv)
+{
MPI_Comm tmp, comm, startComm;
- char * fname;
- char * actualFname = NULL;
- char * globalFname = NULL;
+ char *fname;
+ char *actualFname = NULL;
+ char *globalFname = NULL;
int totalSize, expectedRank, size, cachedRank;
char portName[MPI_MAX_PORT_NAME];
int rankToAccept = 1;
/* Debug - print out where we picked up the MPICH build from */
#ifdef MPICHLIBSTR
- msg( "MPICH library taken from: %s\n", MPICHLIBSTR );
+ msg("MPICH library taken from: %s\n", MPICHLIBSTR);
#endif
- if( argc != 4 ) {
- printf( "Usage: %s <fname> <totalSize> <idx-1-based>\n", argv[0] );
- exit( 1 );
+ if (argc != 4) {
+ printf("Usage: %s <fname> <totalSize> <idx-1-based>\n", argv[0]);
+ exit(1);
}
/* This is the base name of the file into which we write the port */
fname = argv[1];
/* This is the total number of processes launched */
- totalSize = atoi( argv[2] );
+ totalSize = atoi(argv[2]);
/* Each process knows its expected rank */
- expectedRank = atoi( argv[3] )-1;
+ expectedRank = atoi(argv[3]) - 1;
/* Start a watchdog thread which will abort after 120 seconds, and will
* print stack traces using GDB every 5 seconds if you don't call
* strokeWatchdog() */
- startWatchdog( 120 );
+ startWatchdog(120);
/* Print a debug header */
- msg( "Waiting for: %d - my rank is %d\n", totalSize, expectedRank );
+ msg("Waiting for: %d - my rank is %d\n", totalSize, expectedRank);
/* Singleton init */
- MPI_Init( 0, 0 );
+ MPI_Init(0, 0);
/* Duplicate from MPI_COMM_SELF the starting point */
- MPI_Comm_dup( MPI_COMM_SELF, &startComm );
+ MPI_Comm_dup(MPI_COMM_SELF, &startComm);
-
- if( expectedRank == 0 ) {
+
+ if (expectedRank == 0) {
/* This process opens the port, and writes the information to the file */
- MPI_Open_port( MPI_INFO_NULL, portName );
-
+ MPI_Open_port(MPI_INFO_NULL, portName);
+
/* Write the port to fname.<rank> so that the connecting processes can
* wait their turn by checking for the correct file to show up */
- actualFname = writePortToFile( portName, "%s.%d", fname, rankToAccept++ );
+ actualFname = writePortToFile(portName, "%s.%d", fname, rankToAccept++);
/* The wrapper script I'm using checks for the existance of "fname", so
* create that - even though it isn't used */
- globalFname = writePortToFile( portName, fname );
- installExitHandler( globalFname );
+ globalFname = writePortToFile(portName, fname);
+ installExitHandler(globalFname);
comm = startComm;
- } else {
- char * readPort;
- readPort = getPortFromFile( "%s.%d", fname, expectedRank );
- strncpy( portName, readPort, MPI_MAX_PORT_NAME );
- free( readPort );
- msg( "Read port <%s>\n", portName );
-
- MPI_Comm_connect( portName, MPI_INFO_NULL, 0, startComm, &comm );
- MPI_Intercomm_merge( comm, 1, &tmp );
+ }
+ else {
+ char *readPort;
+ readPort = getPortFromFile("%s.%d", fname, expectedRank);
+ strncpy(portName, readPort, MPI_MAX_PORT_NAME);
+ free(readPort);
+ msg("Read port <%s>\n", portName);
+
+ MPI_Comm_connect(portName, MPI_INFO_NULL, 0, startComm, &comm);
+ MPI_Intercomm_merge(comm, 1, &tmp);
comm = tmp;
- MPI_Comm_size( comm, &size );
- msg( "After my first merge, size is now: %d\n", size );
+ MPI_Comm_size(comm, &size);
+ msg("After my first merge, size is now: %d\n", size);
}
- while( size < totalSize ) {
+ while (size < totalSize) {
/* Make sure we don't print a stack until we stall */
strokeWatchdog();
/* Accept the connection */
- MPI_Comm_accept( portName, MPI_INFO_NULL, 0, comm, &tmp );
+ MPI_Comm_accept(portName, MPI_INFO_NULL, 0, comm, &tmp);
/* Merge into intracomm */
- MPI_Intercomm_merge( tmp, 0, &comm );
+ MPI_Intercomm_merge(tmp, 0, &comm);
/* Free the intercomm */
- MPI_Comm_free( &tmp );
+ MPI_Comm_free(&tmp);
/* See where we're up to */
- MPI_Comm_rank( comm, &cachedRank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &cachedRank);
+ MPI_Comm_size(comm, &size);
- if( expectedRank == 0 ) {
- msg( "Up to size: %d\n", size );
+ if (expectedRank == 0) {
+ msg("Up to size: %d\n", size);
/* Delete the old file, create the new one */
- unlink( actualFname );
- free( actualFname );
+ unlink(actualFname);
+ free(actualFname);
/* Allow the next rank to connect */
- actualFname = writePortToFile( portName, "%s.%d", fname, rankToAccept++ );
+ actualFname = writePortToFile(portName, "%s.%d", fname, rankToAccept++);
}
}
- MPI_Comm_rank( comm, &cachedRank );
+ MPI_Comm_rank(comm, &cachedRank);
- msg( "All done - I got rank: %d.\n", cachedRank );
+ msg("All done - I got rank: %d.\n", cachedRank);
- MPI_Barrier( comm );
+ MPI_Barrier(comm);
- if( expectedRank == 0 ) {
+ if (expectedRank == 0) {
/* Cleanup on rank zero - delete some files */
- MTestSleep( 4 );
- unlink( actualFname );
- free( actualFname );
- unlink( globalFname );
- free( globalFname );
+ MTestSleep(4);
+ unlink(actualFname);
+ free(actualFname);
+ unlink(globalFname);
+ free(globalFname);
/* This lets my wrapper script know that we did everything correctly */
indicateConnectSucceeded();
diff --git a/test/mpi/mpi_t/cvarwrite.c b/test/mpi/mpi_t/cvarwrite.c
index 41d0b29..0506aa0 100644
--- a/test/mpi/mpi_t/cvarwrite.c
+++ b/test/mpi/mpi_t/cvarwrite.c
@@ -13,7 +13,7 @@
#define MAX_STR_CVAR_LEN 512
#define MAX_VAR_NAME_LEN 128
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
int i;
int required, provided;
@@ -40,52 +40,63 @@ int main(int argc, char* argv[])
for (i = 0; i < num_cvar; i++) {
MPI_T_cvar_get_info(i, name, &namelen, &verbosity, &datatype, &enumtype,
- NULL /* desc is intentionly ignored to test NULL input */, &desclen, &binding, &scope);
- if (binding != MPI_T_BIND_NO_OBJECT) continue;
+ NULL /* desc is intentionly ignored to test NULL input */ , &desclen,
+ &binding, &scope);
+ if (binding != MPI_T_BIND_NO_OBJECT)
+ continue;
MPI_T_cvar_handle_alloc(i, NULL, &chandle, &count);
if (count == 1 || (datatype == MPI_CHAR && count < sizeof(cin))) {
if (MPI_INT == datatype) {
iin = 123;
iout = 456;
- MPI_T_cvar_read(chandle, &iold); /* Read the old value */
- MPI_T_cvar_write(chandle, &iin); /* Write an arbitrary value */
- MPI_T_cvar_read(chandle, &iout); /* Read the value again */
- MPI_T_cvar_write(chandle, &iold); /* Restore the old value */
- if (iin != iout) errs++;
- } else if (MPI_UNSIGNED == datatype) {
+ MPI_T_cvar_read(chandle, &iold); /* Read the old value */
+ MPI_T_cvar_write(chandle, &iin); /* Write an arbitrary value */
+ MPI_T_cvar_read(chandle, &iout); /* Read the value again */
+ MPI_T_cvar_write(chandle, &iold); /* Restore the old value */
+ if (iin != iout)
+ errs++;
+ }
+ else if (MPI_UNSIGNED == datatype) {
uin = 133;
uout = 986;
MPI_T_cvar_read(chandle, &uold);
MPI_T_cvar_write(chandle, &uin);
MPI_T_cvar_read(chandle, &uout);
MPI_T_cvar_write(chandle, &uold);
- if (uin != uout) errs++;
- } else if (MPI_UNSIGNED_LONG == datatype) {
+ if (uin != uout)
+ errs++;
+ }
+ else if (MPI_UNSIGNED_LONG == datatype) {
ulin = 1830;
ulout = 2014;
MPI_T_cvar_read(chandle, &ulold);
MPI_T_cvar_write(chandle, &ulin);
MPI_T_cvar_read(chandle, &ulout);
MPI_T_cvar_write(chandle, &ulold);
- if (ulin != ulout) errs++;
- } else if (MPI_UNSIGNED_LONG_LONG == datatype) {
+ if (ulin != ulout)
+ errs++;
+ }
+ else if (MPI_UNSIGNED_LONG_LONG == datatype) {
ullin = 11930;
ullout = 52014;
MPI_T_cvar_read(chandle, &ullold);
MPI_T_cvar_write(chandle, &ullin);
MPI_T_cvar_read(chandle, &ullout);
MPI_T_cvar_write(chandle, &ullold);
- if (ullin != ullout) errs++;
- } else if (MPI_CHAR == datatype) {
- strcpy(cin, "GARBAGE MPI_CHAR CVAR VALUE");
+ if (ullin != ullout)
+ errs++;
+ }
+ else if (MPI_CHAR == datatype) {
+ strcpy(cin, "GARBAGE MPI_CHAR CVAR VALUE");
strcpy(cout, "TEMPORARY MPI_CHAR CVAR VALUE");
MPI_T_cvar_read(chandle, cold);
MPI_T_cvar_write(chandle, cin);
MPI_T_cvar_read(chandle, cout);
MPI_T_cvar_write(chandle, cold);
/* printf("%s = %s\n", name, cold); */
- if (strcmp(cin, cout)) errs++;
+ if (strcmp(cin, cout))
+ errs++;
}
}
diff --git a/test/mpi/mpi_t/getindex.c b/test/mpi/mpi_t/getindex.c
index ede43a6..6518645 100644
--- a/test/mpi/mpi_t/getindex.c
+++ b/test/mpi/mpi_t/getindex.c
@@ -27,23 +27,28 @@ int main(int argc, char *argv[])
/* Test MPI_T_cvar_get_index with both valid and bogus names */
MPI_T_cvar_get_num(&num_cvar);
- if (verbose) fprintf(stdout, "%d MPI Control Variables\n", num_cvar);
+ if (verbose)
+ fprintf(stdout, "%d MPI Control Variables\n", num_cvar);
for (i = 0; i < num_cvar; i++) {
namelen = sizeof(name);
MPI_T_cvar_get_info(i, name, &namelen, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
if (namelen <= 128) {
errno = MPI_T_cvar_get_index(name, &cvar_index);
- if (errno != MPI_SUCCESS || cvar_index != i) errs++;
+ if (errno != MPI_SUCCESS || cvar_index != i)
+ errs++;
}
}
errno = MPI_T_cvar_get_index("AN INVALID CVAR NAME FOR TEST", &cvar_index);
- if (errno != MPI_T_ERR_INVALID_NAME) errs++;
+ if (errno != MPI_T_ERR_INVALID_NAME)
+ errs++;
- if (errs) fprintf(stdout, "Errors found in MPI_T_cvar_get_index\n");
+ if (errs)
+ fprintf(stdout, "Errors found in MPI_T_cvar_get_index\n");
/* Test MPI_T_pvar_get_index with both valid and bogus names */
MPI_T_pvar_get_num(&num_pvar);
- if (verbose) fprintf(stdout, "%d MPI Performance Variables\n", num_pvar);
+ if (verbose)
+ fprintf(stdout, "%d MPI Performance Variables\n", num_pvar);
for (i = 0; i < num_pvar; i++) {
namelen = sizeof(name);
@@ -51,31 +56,41 @@ int main(int argc, char *argv[])
NULL, NULL, NULL, NULL, NULL);
if (namelen <= 128) {
errno = MPI_T_pvar_get_index(name, pvar_class, &pvar_index);
- if (errno != MPI_SUCCESS || pvar_index != i) errs++;
+ if (errno != MPI_SUCCESS || pvar_index != i)
+ errs++;
}
}
- errno = MPI_T_pvar_get_index("AN INVALID PVAR NAME FOR TEST", MPI_T_PVAR_CLASS_COUNTER, &cvar_index);
- if (errno != MPI_T_ERR_INVALID_NAME) errs++;
- if (errs) fprintf(stdout, "Errors found in MPI_T_cvar_get_index\n");
+ errno =
+ MPI_T_pvar_get_index("AN INVALID PVAR NAME FOR TEST", MPI_T_PVAR_CLASS_COUNTER,
+ &cvar_index);
+ if (errno != MPI_T_ERR_INVALID_NAME)
+ errs++;
+ if (errs)
+ fprintf(stdout, "Errors found in MPI_T_cvar_get_index\n");
/* Test MPI_T_category_get_index with both valid and bogus names */
MPI_T_category_get_num(&num_cat);
- if (verbose) fprintf(stdout, "%d MPI_T categories\n", num_cat);
+ if (verbose)
+ fprintf(stdout, "%d MPI_T categories\n", num_cat);
for (i = 0; i < num_cat; i++) {
namelen = sizeof(name);
MPI_T_category_get_info(i, name, &namelen, NULL, NULL, NULL, NULL, NULL);
if (namelen <= 128) {
errno = MPI_T_category_get_index(name, &cat_index);
- if (errno != MPI_SUCCESS || cat_index != i) errs++;
+ if (errno != MPI_SUCCESS || cat_index != i)
+ errs++;
}
}
errno = MPI_T_category_get_index("AN INVALID CATEGORY NAME FOR TEST", &cat_index);
- if (errno != MPI_T_ERR_INVALID_NAME) errs++;
- if (errs) fprintf(stdout, "Errors found in MPI_T_cvar_get_index\n");
+ if (errno != MPI_T_ERR_INVALID_NAME)
+ errs++;
+ if (errs)
+ fprintf(stdout, "Errors found in MPI_T_cvar_get_index\n");
MPI_T_finalize();
MPI_Finalize();
- if (errs == 0) fprintf(stdout, " No Errors\n");
+ if (errs == 0)
+ fprintf(stdout, " No Errors\n");
return 0;
}
diff --git a/test/mpi/mpi_t/mpi_t_str.c b/test/mpi/mpi_t/mpi_t_str.c
index ab48e15..31a0ffa 100644
--- a/test/mpi/mpi_t/mpi_t_str.c
+++ b/test/mpi/mpi_t/mpi_t_str.c
@@ -39,9 +39,9 @@ int main(int argc, char **argv)
int num_pvars, num_cvars, num_cat;
#define STR_SZ (50)
int name_len;
- char name[STR_SZ+1] = ""; /* +1 to check for overrun */
+ char name[STR_SZ + 1] = ""; /* +1 to check for overrun */
int desc_len;
- char desc[STR_SZ+1] = ""; /* +1 to check for overrun */
+ char desc[STR_SZ + 1] = ""; /* +1 to check for overrun */
int verb;
MPI_Datatype dtype;
int count;
@@ -50,7 +50,7 @@ int main(int argc, char **argv)
int provided;
/* Init'ed to a garbage value, to trigger MPI_T bugs easily if there are. */
- MPI_T_enum enumtype = (MPI_T_enum)0x31415926;
+ MPI_T_enum enumtype = (MPI_T_enum) 0x31415926;
MPI_Init(&argc, &argv);
MPI_T_init_thread(MPI_THREAD_SINGLE, &provided);
@@ -67,7 +67,7 @@ int main(int argc, char **argv)
/* pass NULL string, non-zero lengths; should get full lengths */
full_name_len = full_desc_len = 1;
MPI_T_cvar_get_info(i, NULL, &full_name_len, &verb, &dtype,
- &enumtype, NULL, &full_desc_len, &bind, &scope);
+ &enumtype, NULL, &full_desc_len, &bind, &scope);
check(full_name_len >= 0);
check(full_desc_len >= 0);
@@ -92,8 +92,8 @@ int main(int argc, char **argv)
name[j] = j % CHAR_MAX;
desc[j] = j % CHAR_MAX;
}
- MPI_T_cvar_get_info(i, name, /*name_len=*/NULL, &verb, &dtype,
- &enumtype, desc, /*desc_len=*/NULL, &bind, &scope);
+ MPI_T_cvar_get_info(i, name, /*name_len= */ NULL, &verb, &dtype,
+ &enumtype, desc, /*desc_len= */ NULL, &bind, &scope);
for (j = 0; j < STR_SZ; ++j) {
check(name[j] == j % CHAR_MAX);
check(desc[j] == j % CHAR_MAX);
@@ -129,32 +129,30 @@ int main(int argc, char **argv)
/* pass non-NULL string, zero lengths; should get full lengths also */
name_len = desc_len = 0;
MPI_T_pvar_get_info(i, name, &name_len, &verb, &varclass, &dtype,
- &enumtype, desc, &desc_len, &bind, &readonly,
- &continuous, &atomic);
+ &enumtype, desc, &desc_len, &bind, &readonly, &continuous, &atomic);
check(full_name_len == name_len);
check(full_desc_len == desc_len);
/* regular call, no NULLs; should truncate (with termination) to STR_SZ
* if necessary, otherwise returns strlen+1 in the corresponding "_len"
* var */
- name[STR_SZ] = (char)'Z';
- desc[STR_SZ] = (char)'Z';
+ name[STR_SZ] = (char) 'Z';
+ desc[STR_SZ] = (char) 'Z';
name_len = desc_len = STR_SZ;
MPI_T_pvar_get_info(i, name, &name_len, &verb, &varclass, &dtype,
- &enumtype, desc, &desc_len, &bind, &readonly,
- &continuous, &atomic);
+ &enumtype, desc, &desc_len, &bind, &readonly, &continuous, &atomic);
check((strlen(name) + 1) == min(name_len, STR_SZ));
check((strlen(desc) + 1) == min(desc_len, STR_SZ));
- check(name[STR_SZ] == (char)'Z');
- check(desc[STR_SZ] == (char)'Z');
+ check(name[STR_SZ] == (char) 'Z');
+ check(desc[STR_SZ] == (char) 'Z');
/* pass NULL lengths, string buffers should be left alone */
for (j = 0; j < STR_SZ; ++j) {
name[j] = j % CHAR_MAX;
desc[j] = j % CHAR_MAX;
}
- MPI_T_pvar_get_info(i, name, /*name_len=*/NULL, &verb, &varclass, &dtype,
- &enumtype, desc, /*desc_len=*/NULL, &bind, &readonly,
+ MPI_T_pvar_get_info(i, name, /*name_len= */ NULL, &verb, &varclass, &dtype,
+ &enumtype, desc, /*desc_len= */ NULL, &bind, &readonly,
&continuous, &atomic);
for (j = 0; j < STR_SZ; ++j) {
check(name[j] == j % CHAR_MAX);
@@ -169,38 +167,38 @@ int main(int argc, char **argv)
/* pass NULL string, non-zero lengths; should get full lengths */
full_name_len = full_desc_len = 1;
MPI_T_category_get_info(i, NULL, &full_name_len, NULL, &full_desc_len,
- &num_cvars, &num_pvars, /*num_categories=*/&j);
+ &num_cvars, &num_pvars, /*num_categories= */ &j);
check(full_name_len >= 0);
check(full_desc_len >= 0);
/* pass non-NULL string, zero lengths; should get full lengths also */
name_len = desc_len = 0;
MPI_T_category_get_info(i, name, &name_len, desc, &desc_len,
- &num_cvars, &num_pvars, /*num_categories=*/&j);
+ &num_cvars, &num_pvars, /*num_categories= */ &j);
check(full_name_len == name_len);
check(full_desc_len == desc_len);
/* regular call, no NULLs; should truncate (with termination) to STR_SZ
* if necessary, otherwise returns strlen+1 in the corresponding "_len"
* var */
- name[STR_SZ] = (char)'Z';
- desc[STR_SZ] = (char)'Z';
+ name[STR_SZ] = (char) 'Z';
+ desc[STR_SZ] = (char) 'Z';
name_len = desc_len = STR_SZ;
MPI_T_category_get_info(i, name, &name_len, desc, &desc_len,
- &num_cvars, &num_pvars, /*num_categories=*/&j);
+ &num_cvars, &num_pvars, /*num_categories= */ &j);
check((strlen(name) + 1) == min(name_len, STR_SZ));
check((strlen(desc) + 1) == min(desc_len, STR_SZ));
- check(name[STR_SZ] == (char)'Z');
- check(desc[STR_SZ] == (char)'Z');
+ check(name[STR_SZ] == (char) 'Z');
+ check(desc[STR_SZ] == (char) 'Z');
/* pass NULL lengths, string buffers should be left alone */
for (j = 0; j < STR_SZ; ++j) {
name[j] = j % CHAR_MAX;
desc[j] = j % CHAR_MAX;
}
- MPI_T_category_get_info(i, name, /*name_len=*/NULL, desc,
- /*desc_len=*/NULL, &num_cvars, &num_pvars,
- /*num_categories=*/&j);
+ MPI_T_category_get_info(i, name, /*name_len= */ NULL, desc,
+ /*desc_len= */ NULL, &num_cvars, &num_pvars,
+ /*num_categories= */ &j);
for (j = 0; j < STR_SZ; ++j) {
check(name[j] == j % CHAR_MAX);
check(desc[j] == j % CHAR_MAX);
@@ -229,4 +227,3 @@ int main(int argc, char **argv)
return 0;
}
-
diff --git a/test/mpi/mpi_t/mpit_vars.c b/test/mpi/mpi_t/mpit_vars.c
index ea18680..d7020fc 100644
--- a/test/mpi/mpi_t/mpit_vars.c
+++ b/test/mpi/mpi_t/mpit_vars.c
@@ -188,7 +188,8 @@ int PrintCategories(FILE * fp)
MPI_T_category_get_info(i, name, &nameLen, desc, &descLen, &numCvars,
&numPvars, &numSubcat);
if (verbose) {
- fprintf(fp, "Category %s has %d control variables, %d performance variables, %d subcategories\n",
+ fprintf(fp,
+ "Category %s has %d control variables, %d performance variables, %d subcategories\n",
name, numCvars, numPvars, numSubcat);
fprintf(fp, "\tDescription: %s\n", desc);
}
@@ -294,9 +295,9 @@ char *mpit_validDtypeStr(MPI_Datatype datatype)
strncpy(typename, "Invalid:", MPI_MAX_OBJECT_NAME);
MPI_Type_get_name(datatype, typename + 8, &tlen);
/* We must check location typename[8] to see if
- MPI_Type_get_name returned a name (not all datatypes
- have names). If it did not, then we indicate that
- with a different message */
+ * MPI_Type_get_name returned a name (not all datatypes
+ * have names). If it did not, then we indicate that
+ * with a different message */
if (typename[8])
p = typename;
else
diff --git a/test/mpi/perf/allredtrace.c b/test/mpi/perf/allredtrace.c
index 8d7265a..8fb077b 100644
--- a/test/mpi/perf/allredtrace.c
+++ b/test/mpi/perf/allredtrace.c
@@ -5,13 +5,13 @@
*/
/*
- * This code is intended to test the trace overhead when using an
+ * This code is intended to test the trace overhead when using an
* MPI tracing package. To perform the test, follow these steps:
*
* 1) Run with the versbose mode selected to determine the delay argument
* to use in subsequent tests:
* mpiexec -n 4096 allredtrace -v
- * Assume that the computed delay count is 6237; that value is used in
+ * Assume that the computed delay count is 6237; that value is used in
* the following.
*
* 2) Run with an explicit delay count, without tracing enabled:
@@ -20,7 +20,7 @@
* 3) Build allredtrace with tracing enabled, then run:
* mpiexec -n 4096 allredtrace -delaycount 6237
*
- * Compare the total times. The tracing version should take slightly
+ * Compare the total times. The tracing version should take slightly
* longer but no more than, for example, 15%.
*/
#include "mpi.h"
@@ -30,126 +30,132 @@
static int verbose = 0;
static int lCount = 0;
-void Delay( int );
-void SetupDelay( double );
+void Delay(int);
+void SetupDelay(double);
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
double usecPerCall = 100;
double t, t1, tsum;
int i, nLoop = 100;
int rank;
- MPI_Init( &argc, &argv );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
-
- /* Process arguments. We allow the delay count to be set from the
- command line to ensure reproducibility*/
- for (i=1; i<argc; i++) {
- if (strcmp( argv[i], "-delaycount" ) == 0) {
- i++;
- lCount = atoi( argv[i] );
- }
- else if (strcmp( argv[i], "-v" ) == 0) {
- verbose = 1;
- }
- else {
- fprintf( stderr, "Unrecognized argument %s\n", argv[i] );
- exit(1);
- }
+ MPI_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+
+ /* Process arguments. We allow the delay count to be set from the
+ * command line to ensure reproducibility */
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-delaycount") == 0) {
+ i++;
+ lCount = atoi(argv[i]);
+ }
+ else if (strcmp(argv[i], "-v") == 0) {
+ verbose = 1;
+ }
+ else {
+ fprintf(stderr, "Unrecognized argument %s\n", argv[i]);
+ exit(1);
+ }
}
if (lCount == 0) {
- SetupDelay( usecPerCall );
+ SetupDelay(usecPerCall);
}
-
- MPI_Barrier( MPI_COMM_WORLD );
+
+ MPI_Barrier(MPI_COMM_WORLD);
t = MPI_Wtime();
- for (i=0; i<nLoop; i++) {
- MPI_Allreduce( &t1, &tsum, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD );
- Delay( lCount );
+ for (i = 0; i < nLoop; i++) {
+ MPI_Allreduce(&t1, &tsum, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
+ Delay(lCount);
}
t = MPI_Wtime() - t;
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
if (rank == 0) {
- printf( "For delay count %d, time is %e\n", lCount, t );
+ printf("For delay count %d, time is %e\n", lCount, t);
}
-
- MPI_Barrier( MPI_COMM_WORLD );
+
+ MPI_Barrier(MPI_COMM_WORLD);
MPI_Finalize();
-
+
return 0;
}
-void SetupDelay( double usec )
+void SetupDelay(double usec)
{
double t, tick;
double sec = 1.0e-6 * usec;
int nLoop, i, direction;
-
+
/* Compute the number of times to run the tests to get an accurate
- number given the timer resolution. */
+ * number given the timer resolution. */
nLoop = 1;
tick = 100 * MPI_Wtick();
do {
- nLoop = 2 * nLoop;
- t = MPI_Wtime();
- for (i=0; i<nLoop; i++) {
- MPI_Wtime();
- }
- t = MPI_Wtime() - t;
+ nLoop = 2 * nLoop;
+ t = MPI_Wtime();
+ for (i = 0; i < nLoop; i++) {
+ MPI_Wtime();
+ }
+ t = MPI_Wtime() - t;
}
- while ( t < tick && nLoop < 100000 );
+ while (t < tick && nLoop < 100000);
+
+ if (verbose)
+ printf("nLoop = %d\n", nLoop);
- if (verbose) printf( "nLoop = %d\n", nLoop );
-
/* Start with an estimated count */
lCount = 128;
direction = 0;
while (1) {
- t = MPI_Wtime();
- for (i=0; i<nLoop; i++) {
- Delay( lCount );
- }
- t = MPI_Wtime() - t;
- t = t / nLoop;
- if (verbose) printf( "lCount = %d, time = %e\n", lCount, t );
- if (t > 10 * tick) nLoop = nLoop / 2;
-
- /* Compare measured delay */
- if (t > 2*sec) {
- lCount = lCount / 2;
- if (direction == 1) break;
- direction = -1;
- }
- else if (t < sec / 2) {
- lCount = lCount * 2;
- if (direction == -1) break;
- direction = 1;
- }
- else if (t < sec) {
- /* sec/2 <= t < sec , so estimate the lCount to hit sec */
- lCount = (sec/t) * lCount;
- }
- else
- break;
+ t = MPI_Wtime();
+ for (i = 0; i < nLoop; i++) {
+ Delay(lCount);
+ }
+ t = MPI_Wtime() - t;
+ t = t / nLoop;
+ if (verbose)
+ printf("lCount = %d, time = %e\n", lCount, t);
+ if (t > 10 * tick)
+ nLoop = nLoop / 2;
+
+ /* Compare measured delay */
+ if (t > 2 * sec) {
+ lCount = lCount / 2;
+ if (direction == 1)
+ break;
+ direction = -1;
+ }
+ else if (t < sec / 2) {
+ lCount = lCount * 2;
+ if (direction == -1)
+ break;
+ direction = 1;
+ }
+ else if (t < sec) {
+ /* sec/2 <= t < sec , so estimate the lCount to hit sec */
+ lCount = (sec / t) * lCount;
+ }
+ else
+ break;
}
- if (verbose) printf( "lCount = %d, t = %e\n", lCount, t );
+ if (verbose)
+ printf("lCount = %d, t = %e\n", lCount, t);
/* Should coordinate with the other processes - take the max? */
}
volatile double delayCounter = 0;
-void Delay( int count )
+void Delay(int count)
{
int i;
delayCounter = 0.0;
- for (i=0; i<count; i++) {
- delayCounter += 2.73;
+ for (i = 0; i < count; i++) {
+ delayCounter += 2.73;
}
}
diff --git a/test/mpi/perf/commcreatep.c b/test/mpi/perf/commcreatep.c
index 975dc89..e8d1f63 100644
--- a/test/mpi/perf/commcreatep.c
+++ b/test/mpi/perf/commcreatep.c
@@ -12,68 +12,69 @@
#define MAX_LOG_WSIZE 31
#define MAX_LOOP 20
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Group gworld, g;
- MPI_Comm comm, newcomm[MAX_LOOP];
- int wsize, wrank, range[1][3], errs=0;
- double t[MAX_LOG_WSIZE], tf;
- int maxi, i, k, ts, gsize[MAX_LOG_WSIZE];
+ MPI_Comm comm, newcomm[MAX_LOOP];
+ int wsize, wrank, range[1][3], errs = 0;
+ double t[MAX_LOG_WSIZE], tf;
+ int maxi, i, k, ts, gsize[MAX_LOG_WSIZE];
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Comm_size( MPI_COMM_WORLD, &wsize );
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
+ MPI_Comm_size(MPI_COMM_WORLD, &wsize);
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
if (wrank == 0)
- MTestPrintfMsg( 1, "size\ttime\n" );
+ MTestPrintfMsg(1, "size\ttime\n");
- MPI_Comm_group( MPI_COMM_WORLD, &gworld );
+ MPI_Comm_group(MPI_COMM_WORLD, &gworld);
ts = 1;
comm = MPI_COMM_WORLD;
- for (i=0; ts<=wsize; i++, ts = ts + ts) {
- /* Create some groups with at most ts members */
- range[0][0] = ts-1;
- range[0][1] = 0;
- range[0][2] = -1;
- MPI_Group_range_incl( gworld, 1, range, &g );
-
- MPI_Barrier( MPI_COMM_WORLD );
- tf = MPI_Wtime();
- for (k=0; k<MAX_LOOP; k++)
- MPI_Comm_create( comm, g, &newcomm[k] );
- tf = MPI_Wtime() - tf;
- MPI_Allreduce( &tf, &t[i], 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD );
- t[i] = t[i] / MAX_LOOP;
- gsize[i] = ts;
- if (wrank == 0)
- MTestPrintfMsg( 1, "%d\t%e\n", ts, t[i] );
- MPI_Group_free( &g );
- if (newcomm[0] != MPI_COMM_NULL)
- for (k=0; k<MAX_LOOP; k++)
- MPI_Comm_free( &newcomm[k] );
+ for (i = 0; ts <= wsize; i++, ts = ts + ts) {
+ /* Create some groups with at most ts members */
+ range[0][0] = ts - 1;
+ range[0][1] = 0;
+ range[0][2] = -1;
+ MPI_Group_range_incl(gworld, 1, range, &g);
+
+ MPI_Barrier(MPI_COMM_WORLD);
+ tf = MPI_Wtime();
+ for (k = 0; k < MAX_LOOP; k++)
+ MPI_Comm_create(comm, g, &newcomm[k]);
+ tf = MPI_Wtime() - tf;
+ MPI_Allreduce(&tf, &t[i], 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD);
+ t[i] = t[i] / MAX_LOOP;
+ gsize[i] = ts;
+ if (wrank == 0)
+ MTestPrintfMsg(1, "%d\t%e\n", ts, t[i]);
+ MPI_Group_free(&g);
+ if (newcomm[0] != MPI_COMM_NULL)
+ for (k = 0; k < MAX_LOOP; k++)
+ MPI_Comm_free(&newcomm[k]);
}
- MPI_Group_free( &gworld );
- maxi = i-1;
+ MPI_Group_free(&gworld);
+ maxi = i - 1;
/* The cost should be linear or at worst ts*log(ts).
- We can check this in a number of ways.
+ * We can check this in a number of ways.
*/
if (wrank == 0) {
- for (i=4; i<=maxi; i++) {
- double rdiff;
- if (t[i] > 0) {
- rdiff = (t[i] - t[i-1]) / t[i];
- if (rdiff >= 4) {
- errs++;
- fprintf( stderr, "Relative difference between group of size %d and %d is %e exceeds 4\n",
- gsize[i-1], gsize[i], rdiff );
- }
- }
- }
+ for (i = 4; i <= maxi; i++) {
+ double rdiff;
+ if (t[i] > 0) {
+ rdiff = (t[i] - t[i - 1]) / t[i];
+ if (rdiff >= 4) {
+ errs++;
+ fprintf(stderr,
+ "Relative difference between group of size %d and %d is %e exceeds 4\n",
+ gsize[i - 1], gsize[i], rdiff);
+ }
+ }
+ }
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
diff --git a/test/mpi/perf/dtpack.c b/test/mpi/perf/dtpack.c
index a31a55d..b3791ae 100644
--- a/test/mpi/perf/dtpack.c
+++ b/test/mpi/perf/dtpack.c
@@ -4,13 +4,13 @@
* See COPYRIGHT in top-level directory.
*/
/*
- * This code may be used to test the performance of some of the
+ * This code may be used to test the performance of some of the
* noncontiguous datatype operations, including vector and indexed
- * pack and unpack operations. To simplify the use of this code for
+ * pack and unpack operations. To simplify the use of this code for
* tuning an MPI implementation, it uses no communication, just the
* MPI_Pack and MPI_Unpack routines. In addition, the individual tests are
* in separate routines, making it easier to compare the compiler-generated
- * code for the user (manual) pack/unpack with the code used by
+ * code for the user (manual) pack/unpack with the code used by
* the MPI implementation. Further, to be fair to the MPI implementation,
* the routines are passed the source and destination buffers; this ensures
* that the compiler can't optimize for statically allocated buffers.
@@ -33,441 +33,455 @@ static int verbose = 0;
double mean(double *list, int count);
double mean(double *list, int count)
{
- double retval;
- int i;
+ double retval;
+ int i;
- retval = 0;
- for (i = 0; i < count; i++)
- retval += list[i];
- retval /= count;
+ retval = 0;
+ for (i = 0; i < count; i++)
+ retval += list[i];
+ retval /= count;
- return retval;
+ return retval;
}
double noise(double *list, int count);
double noise(double *list, int count)
{
- double *margin, retval;
- int i;
+ double *margin, retval;
+ int i;
- if (!(margin = malloc(count * sizeof(double)))) {
- printf("Unable to allocate memory\n");
- return -1;
- }
+ if (!(margin = malloc(count * sizeof(double)))) {
+ printf("Unable to allocate memory\n");
+ return -1;
+ }
- for (i = 0; i < count; i++)
- margin[i] = list[i] / mean(list, count);
+ for (i = 0; i < count; i++)
+ margin[i] = list[i] / mean(list, count);
- retval = 0;
- for (i = 0; i < count; i++) {
- retval += ((margin[i] - 1) * (margin[i] - 1));
- }
- retval /= count;
- if (retval < 0) retval = -retval;
+ retval = 0;
+ for (i = 0; i < count; i++) {
+ retval += ((margin[i] - 1) * (margin[i] - 1));
+ }
+ retval /= count;
+ if (retval < 0)
+ retval = -retval;
- return retval;
+ return retval;
}
/* Here are the tests */
/* Test packing a vector of individual doubles */
/* We don't use restrict in the function args because assignments between
- restrict pointers is not valid in C and some compilers, such as the
+ restrict pointers is not valid in C and some compilers, such as the
IBM xlc compilers, flag that use as an error.*/
-int TestVecPackDouble( int n, int stride,
- double *avgTimeUser, double *avgTimeMPI,
- double *dest, const double *src );
-int TestVecPackDouble( int n, int stride,
- double *avgTimeUser, double *avgTimeMPI,
- double *dest, const double *src )
+int TestVecPackDouble(int n, int stride,
+ double *avgTimeUser, double *avgTimeMPI, double *dest, const double *src);
+int TestVecPackDouble(int n, int stride,
+ double *avgTimeUser, double *avgTimeMPI, double *dest, const double *src)
{
- double *restrict d_dest;
- const double *restrict d_src;
- register int i, j;
- int rep, position;
- double t1, t2, t[NTRIALS];
- MPI_Datatype vectype;
-
- /* User code */
- if (verbose) printf("TestVecPackDouble (USER): ");
- for (j = 0; j < NTRIALS; j++) {
- t1 = MPI_Wtime();
- for (rep=0; rep<N_REPS; rep++) {
- i = n;
- d_dest = dest;
- d_src = src;
- while (i--) {
- *d_dest++ = *d_src;
- d_src += stride;
- }
- }
- t2 = MPI_Wtime() - t1;
- t[j] = t2;
- if (verbose) printf("%.3f ", t[j]);
- }
- if (verbose) printf("[%.3f]\n", noise(t, NTRIALS));
- /* If there is too much noise, discard the test */
- if (noise(t, NTRIALS) > VARIANCE_THRESHOLD) {
- *avgTimeUser = 0;
- *avgTimeMPI = 0;
- if (verbose)
- printf("Too much noise; discarding measurement\n");
- return 0;
- }
- *avgTimeUser = mean(t, NTRIALS) / N_REPS;
-
- /* MPI Vector code */
- MPI_Type_vector( n, 1, stride, MPI_DOUBLE, &vectype );
- MPI_Type_commit( &vectype );
-
- if (verbose) printf("TestVecPackDouble (MPI): ");
- for (j = 0; j < NTRIALS; j++) {
- t1 = MPI_Wtime();
- for (rep=0; rep<N_REPS; rep++) {
- position = 0;
- MPI_Pack( (void *)src, 1, vectype, dest, n*sizeof(double),
- &position, MPI_COMM_SELF );
- }
- t2 = MPI_Wtime() - t1;
- t[j] = t2;
- if (verbose) printf("%.3f ", t[j]);
- }
- if (verbose) printf("[%.3f]\n", noise(t, NTRIALS));
- /* If there is too much noise, discard the test */
- if (noise(t, NTRIALS) > VARIANCE_THRESHOLD) {
- *avgTimeUser = 0;
- *avgTimeMPI = 0;
- if (verbose)
- printf("Too much noise; discarding measurement\n");
- }
- else {
- *avgTimeMPI = mean(t, NTRIALS) / N_REPS;
- }
-
- MPI_Type_free( &vectype );
-
- return 0;
+ double *restrict d_dest;
+ const double *restrict d_src;
+ register int i, j;
+ int rep, position;
+ double t1, t2, t[NTRIALS];
+ MPI_Datatype vectype;
+
+ /* User code */
+ if (verbose)
+ printf("TestVecPackDouble (USER): ");
+ for (j = 0; j < NTRIALS; j++) {
+ t1 = MPI_Wtime();
+ for (rep = 0; rep < N_REPS; rep++) {
+ i = n;
+ d_dest = dest;
+ d_src = src;
+ while (i--) {
+ *d_dest++ = *d_src;
+ d_src += stride;
+ }
+ }
+ t2 = MPI_Wtime() - t1;
+ t[j] = t2;
+ if (verbose)
+ printf("%.3f ", t[j]);
+ }
+ if (verbose)
+ printf("[%.3f]\n", noise(t, NTRIALS));
+ /* If there is too much noise, discard the test */
+ if (noise(t, NTRIALS) > VARIANCE_THRESHOLD) {
+ *avgTimeUser = 0;
+ *avgTimeMPI = 0;
+ if (verbose)
+ printf("Too much noise; discarding measurement\n");
+ return 0;
+ }
+ *avgTimeUser = mean(t, NTRIALS) / N_REPS;
+
+ /* MPI Vector code */
+ MPI_Type_vector(n, 1, stride, MPI_DOUBLE, &vectype);
+ MPI_Type_commit(&vectype);
+
+ if (verbose)
+ printf("TestVecPackDouble (MPI): ");
+ for (j = 0; j < NTRIALS; j++) {
+ t1 = MPI_Wtime();
+ for (rep = 0; rep < N_REPS; rep++) {
+ position = 0;
+ MPI_Pack((void *) src, 1, vectype, dest, n * sizeof(double), &position, MPI_COMM_SELF);
+ }
+ t2 = MPI_Wtime() - t1;
+ t[j] = t2;
+ if (verbose)
+ printf("%.3f ", t[j]);
+ }
+ if (verbose)
+ printf("[%.3f]\n", noise(t, NTRIALS));
+ /* If there is too much noise, discard the test */
+ if (noise(t, NTRIALS) > VARIANCE_THRESHOLD) {
+ *avgTimeUser = 0;
+ *avgTimeMPI = 0;
+ if (verbose)
+ printf("Too much noise; discarding measurement\n");
+ }
+ else {
+ *avgTimeMPI = mean(t, NTRIALS) / N_REPS;
+ }
+
+ MPI_Type_free(&vectype);
+
+ return 0;
}
/* Test unpacking a vector of individual doubles */
/* See above for why restrict is not used in the function args */
-int TestVecUnPackDouble( int n, int stride,
- double *avgTimeUser, double *avgTimeMPI,
- double *dest, const double *src );
-int TestVecUnPackDouble( int n, int stride,
- double *avgTimeUser, double *avgTimeMPI,
- double *dest, const double *src )
+int TestVecUnPackDouble(int n, int stride,
+ double *avgTimeUser, double *avgTimeMPI, double *dest, const double *src);
+int TestVecUnPackDouble(int n, int stride,
+ double *avgTimeUser, double *avgTimeMPI, double *dest, const double *src)
{
- double *restrict d_dest;
- const double *restrict d_src;
- register int i, j;
- int rep, position;
- double t1, t2, t[NTRIALS];
- MPI_Datatype vectype;
-
- /* User code */
- if (verbose) printf("TestVecUnPackDouble (USER): ");
- for (j = 0; j < NTRIALS; j++) {
- t1 = MPI_Wtime();
- for (rep=0; rep<N_REPS; rep++) {
- i = n;
- d_dest = dest;
- d_src = src;
- while (i--) {
- *d_dest = *d_src++;
- d_dest += stride;
- }
- }
- t2 = MPI_Wtime() - t1;
- t[j] = t2;
- if (verbose) printf("%.3f ", t[j]);
- }
- if (verbose) printf("[%.3f]\n", noise(t, NTRIALS));
- /* If there is too much noise, discard the test */
- if (noise(t, NTRIALS) > VARIANCE_THRESHOLD) {
- *avgTimeUser = 0;
- *avgTimeMPI = 0;
- if (verbose)
- printf("Too much noise; discarding measurement\n");
- return 0;
- }
- *avgTimeUser = mean(t, NTRIALS) / N_REPS;
-
- /* MPI Vector code */
- MPI_Type_vector( n, 1, stride, MPI_DOUBLE, &vectype );
- MPI_Type_commit( &vectype );
-
- if (verbose) printf("TestVecUnPackDouble (MPI): ");
- for (j = 0; j < NTRIALS; j++) {
- t1 = MPI_Wtime();
- for (rep=0; rep<N_REPS; rep++) {
- position = 0;
- MPI_Unpack( (void *)src, n*sizeof(double),
- &position, dest, 1, vectype, MPI_COMM_SELF );
- }
- t2 = MPI_Wtime() - t1;
- t[j] = t2;
- if (verbose) printf("%.3f ", t[j]);
- }
- if (verbose) printf("[%.3f]\n", noise(t, NTRIALS));
- /* If there is too much noise, discard the test */
- if (noise(t, NTRIALS) > VARIANCE_THRESHOLD) {
- *avgTimeUser = 0;
- *avgTimeMPI = 0;
- if (verbose)
- printf("Too much noise; discarding measurement\n");
- }
- else {
- *avgTimeMPI = mean(t, NTRIALS) / N_REPS;
- }
-
- MPI_Type_free( &vectype );
-
- return 0;
+ double *restrict d_dest;
+ const double *restrict d_src;
+ register int i, j;
+ int rep, position;
+ double t1, t2, t[NTRIALS];
+ MPI_Datatype vectype;
+
+ /* User code */
+ if (verbose)
+ printf("TestVecUnPackDouble (USER): ");
+ for (j = 0; j < NTRIALS; j++) {
+ t1 = MPI_Wtime();
+ for (rep = 0; rep < N_REPS; rep++) {
+ i = n;
+ d_dest = dest;
+ d_src = src;
+ while (i--) {
+ *d_dest = *d_src++;
+ d_dest += stride;
+ }
+ }
+ t2 = MPI_Wtime() - t1;
+ t[j] = t2;
+ if (verbose)
+ printf("%.3f ", t[j]);
+ }
+ if (verbose)
+ printf("[%.3f]\n", noise(t, NTRIALS));
+ /* If there is too much noise, discard the test */
+ if (noise(t, NTRIALS) > VARIANCE_THRESHOLD) {
+ *avgTimeUser = 0;
+ *avgTimeMPI = 0;
+ if (verbose)
+ printf("Too much noise; discarding measurement\n");
+ return 0;
+ }
+ *avgTimeUser = mean(t, NTRIALS) / N_REPS;
+
+ /* MPI Vector code */
+ MPI_Type_vector(n, 1, stride, MPI_DOUBLE, &vectype);
+ MPI_Type_commit(&vectype);
+
+ if (verbose)
+ printf("TestVecUnPackDouble (MPI): ");
+ for (j = 0; j < NTRIALS; j++) {
+ t1 = MPI_Wtime();
+ for (rep = 0; rep < N_REPS; rep++) {
+ position = 0;
+ MPI_Unpack((void *) src, n * sizeof(double),
+ &position, dest, 1, vectype, MPI_COMM_SELF);
+ }
+ t2 = MPI_Wtime() - t1;
+ t[j] = t2;
+ if (verbose)
+ printf("%.3f ", t[j]);
+ }
+ if (verbose)
+ printf("[%.3f]\n", noise(t, NTRIALS));
+ /* If there is too much noise, discard the test */
+ if (noise(t, NTRIALS) > VARIANCE_THRESHOLD) {
+ *avgTimeUser = 0;
+ *avgTimeMPI = 0;
+ if (verbose)
+ printf("Too much noise; discarding measurement\n");
+ }
+ else {
+ *avgTimeMPI = mean(t, NTRIALS) / N_REPS;
+ }
+
+ MPI_Type_free(&vectype);
+
+ return 0;
}
/* Test packing a vector of 2-individual doubles */
/* See above for why restrict is not used in the function args */
-int TestVecPack2Double( int n, int stride,
- double *avgTimeUser, double *avgTimeMPI,
- double *dest, const double *src );
-int TestVecPack2Double( int n, int stride,
- double *avgTimeUser, double *avgTimeMPI,
- double *dest, const double *src )
+int TestVecPack2Double(int n, int stride,
+ double *avgTimeUser, double *avgTimeMPI, double *dest, const double *src);
+int TestVecPack2Double(int n, int stride,
+ double *avgTimeUser, double *avgTimeMPI, double *dest, const double *src)
{
- double *restrict d_dest;
- const double *restrict d_src;
- register int i, j;
- int rep, position;
- double t1, t2, t[NTRIALS];
- MPI_Datatype vectype;
-
- /* User code */
- if (verbose) printf("TestVecPack2Double (USER): ");
- for (j = 0; j < NTRIALS; j++) {
- t1 = MPI_Wtime();
- for (rep=0; rep<N_REPS; rep++) {
- i = n;
- d_dest = dest;
- d_src = src;
- while (i--) {
- *d_dest++ = d_src[0];
- *d_dest++ = d_src[1];
- d_src += stride;
- }
- }
- t2 = MPI_Wtime() - t1;
- t[j] = t2;
- if (verbose) printf("%.3f ", t[j]);
- }
- if (verbose) printf("[%.3f]\n", noise(t, NTRIALS));
- /* If there is too much noise, discard the test */
- if (noise(t, NTRIALS) > VARIANCE_THRESHOLD) {
- *avgTimeUser = 0;
- *avgTimeMPI = 0;
- if (verbose)
- printf("Too much noise; discarding measurement\n");
- return 0;
- }
- *avgTimeUser = mean(t, NTRIALS) / N_REPS;
-
- /* MPI Vector code */
- MPI_Type_vector( n, 2, stride, MPI_DOUBLE, &vectype );
- MPI_Type_commit( &vectype );
-
- if (verbose) printf("TestVecPack2Double (MPI): ");
- for (j = 0; j < NTRIALS; j++) {
- t1 = MPI_Wtime();
- for (rep=0; rep<N_REPS; rep++) {
- position = 0;
- MPI_Pack( (void *)src, 1, vectype, dest, 2*n*sizeof(double),
- &position, MPI_COMM_SELF );
- }
- t2 = MPI_Wtime() - t1;
- t[j] = t2;
- if (verbose) printf("%.3f ", t[j]);
- }
- if (verbose) printf("[%.3f]\n", noise(t, NTRIALS));
- /* If there is too much noise, discard the test */
- if (noise(t, NTRIALS) > VARIANCE_THRESHOLD) {
- *avgTimeUser = 0;
- *avgTimeMPI = 0;
- if (verbose)
- printf("Too much noise; discarding measurement\n");
- }
- else {
- *avgTimeMPI = mean(t, NTRIALS) / N_REPS;
- }
- MPI_Type_free( &vectype );
-
- return 0;
+ double *restrict d_dest;
+ const double *restrict d_src;
+ register int i, j;
+ int rep, position;
+ double t1, t2, t[NTRIALS];
+ MPI_Datatype vectype;
+
+ /* User code */
+ if (verbose)
+ printf("TestVecPack2Double (USER): ");
+ for (j = 0; j < NTRIALS; j++) {
+ t1 = MPI_Wtime();
+ for (rep = 0; rep < N_REPS; rep++) {
+ i = n;
+ d_dest = dest;
+ d_src = src;
+ while (i--) {
+ *d_dest++ = d_src[0];
+ *d_dest++ = d_src[1];
+ d_src += stride;
+ }
+ }
+ t2 = MPI_Wtime() - t1;
+ t[j] = t2;
+ if (verbose)
+ printf("%.3f ", t[j]);
+ }
+ if (verbose)
+ printf("[%.3f]\n", noise(t, NTRIALS));
+ /* If there is too much noise, discard the test */
+ if (noise(t, NTRIALS) > VARIANCE_THRESHOLD) {
+ *avgTimeUser = 0;
+ *avgTimeMPI = 0;
+ if (verbose)
+ printf("Too much noise; discarding measurement\n");
+ return 0;
+ }
+ *avgTimeUser = mean(t, NTRIALS) / N_REPS;
+
+ /* MPI Vector code */
+ MPI_Type_vector(n, 2, stride, MPI_DOUBLE, &vectype);
+ MPI_Type_commit(&vectype);
+
+ if (verbose)
+ printf("TestVecPack2Double (MPI): ");
+ for (j = 0; j < NTRIALS; j++) {
+ t1 = MPI_Wtime();
+ for (rep = 0; rep < N_REPS; rep++) {
+ position = 0;
+ MPI_Pack((void *) src, 1, vectype, dest, 2 * n * sizeof(double),
+ &position, MPI_COMM_SELF);
+ }
+ t2 = MPI_Wtime() - t1;
+ t[j] = t2;
+ if (verbose)
+ printf("%.3f ", t[j]);
+ }
+ if (verbose)
+ printf("[%.3f]\n", noise(t, NTRIALS));
+ /* If there is too much noise, discard the test */
+ if (noise(t, NTRIALS) > VARIANCE_THRESHOLD) {
+ *avgTimeUser = 0;
+ *avgTimeMPI = 0;
+ if (verbose)
+ printf("Too much noise; discarding measurement\n");
+ }
+ else {
+ *avgTimeMPI = mean(t, NTRIALS) / N_REPS;
+ }
+ MPI_Type_free(&vectype);
+
+ return 0;
}
/* This creates an indexed type that is like a vector (for simplicity
- of construction). There is a possibility that the MPI implementation
+ of construction). There is a possibility that the MPI implementation
will recognize and simplify this (e.g., in MPI_Type_commit); if so,
- let us know and we'll add a version that is not as regular
+ let us know and we'll add a version that is not as regular
*/
/* See above for why restrict is not used in the function args */
-int TestIndexPackDouble( int n, int stride,
- double *avgTimeUser, double *avgTimeMPI,
- double *dest, const double *src );
-int TestIndexPackDouble( int n, int stride,
- double *avgTimeUser, double *avgTimeMPI,
- double *dest, const double *src )
+int TestIndexPackDouble(int n, int stride,
+ double *avgTimeUser, double *avgTimeMPI, double *dest, const double *src);
+int TestIndexPackDouble(int n, int stride,
+ double *avgTimeUser, double *avgTimeMPI, double *dest, const double *src)
{
- double *restrict d_dest;
- const double *restrict d_src;
- register int i, j;
- int rep, position;
- int *restrict displs = 0;
- double t1, t2, t[NTRIALS];
- MPI_Datatype indextype;
-
- displs = (int *)malloc( n * sizeof(int) );
- for (i=0; i<n; i++) displs[i] = i * stride;
-
- /* User code */
- if (verbose) printf("TestIndexPackDouble (USER): ");
- for (j = 0; j < NTRIALS; j++) {
- t1 = MPI_Wtime();
- for (rep=0; rep<N_REPS; rep++) {
- i = n;
- d_dest = dest;
- d_src = src;
- for (i=0; i<n; i++) {
- *d_dest++ = d_src[displs[i]];
- }
- }
- t2 = MPI_Wtime() - t1;
- t[j] = t2;
- if (verbose) printf("%.3f ", t[j]);
- }
- if (verbose) printf("[%.3f]\n", noise(t, NTRIALS));
- /* If there is too much noise, discard the test */
- if (noise(t, NTRIALS) > VARIANCE_THRESHOLD) {
- *avgTimeUser = 0;
- *avgTimeMPI = 0;
- if (verbose)
- printf("Too much noise; discarding measurement\n");
- return 0;
- }
- *avgTimeUser = mean(t, NTRIALS) / N_REPS;
-
- /* MPI Index code */
- MPI_Type_create_indexed_block( n, 1, displs, MPI_DOUBLE, &indextype );
- MPI_Type_commit( &indextype );
-
- free( displs );
-
- if (verbose) printf("TestIndexPackDouble (MPI): ");
- for (j = 0; j < NTRIALS; j++) {
- t1 = MPI_Wtime();
- for (rep=0; rep<N_REPS; rep++) {
- position = 0;
- MPI_Pack( (void *)src, 1, indextype, dest, n*sizeof(double),
- &position, MPI_COMM_SELF );
- }
- t2 = MPI_Wtime() - t1;
- t[j] = t2;
- if (verbose) printf("%.3f ", t[j]);
- }
- if (verbose) printf("[%.3f]\n", noise(t, NTRIALS));
- /* If there is too much noise, discard the test */
- if (noise(t, NTRIALS) > VARIANCE_THRESHOLD) {
- *avgTimeUser = 0;
- *avgTimeMPI = 0;
- if (verbose)
- printf("Too much noise; discarding measurement\n");
- }
- else {
- *avgTimeMPI = mean(t, NTRIALS) / N_REPS;
- }
- MPI_Type_free( &indextype );
-
- return 0;
+ double *restrict d_dest;
+ const double *restrict d_src;
+ register int i, j;
+ int rep, position;
+ int *restrict displs = 0;
+ double t1, t2, t[NTRIALS];
+ MPI_Datatype indextype;
+
+ displs = (int *) malloc(n * sizeof(int));
+ for (i = 0; i < n; i++)
+ displs[i] = i * stride;
+
+ /* User code */
+ if (verbose)
+ printf("TestIndexPackDouble (USER): ");
+ for (j = 0; j < NTRIALS; j++) {
+ t1 = MPI_Wtime();
+ for (rep = 0; rep < N_REPS; rep++) {
+ i = n;
+ d_dest = dest;
+ d_src = src;
+ for (i = 0; i < n; i++) {
+ *d_dest++ = d_src[displs[i]];
+ }
+ }
+ t2 = MPI_Wtime() - t1;
+ t[j] = t2;
+ if (verbose)
+ printf("%.3f ", t[j]);
+ }
+ if (verbose)
+ printf("[%.3f]\n", noise(t, NTRIALS));
+ /* If there is too much noise, discard the test */
+ if (noise(t, NTRIALS) > VARIANCE_THRESHOLD) {
+ *avgTimeUser = 0;
+ *avgTimeMPI = 0;
+ if (verbose)
+ printf("Too much noise; discarding measurement\n");
+ return 0;
+ }
+ *avgTimeUser = mean(t, NTRIALS) / N_REPS;
+
+ /* MPI Index code */
+ MPI_Type_create_indexed_block(n, 1, displs, MPI_DOUBLE, &indextype);
+ MPI_Type_commit(&indextype);
+
+ free(displs);
+
+ if (verbose)
+ printf("TestIndexPackDouble (MPI): ");
+ for (j = 0; j < NTRIALS; j++) {
+ t1 = MPI_Wtime();
+ for (rep = 0; rep < N_REPS; rep++) {
+ position = 0;
+ MPI_Pack((void *) src, 1, indextype, dest, n * sizeof(double),
+ &position, MPI_COMM_SELF);
+ }
+ t2 = MPI_Wtime() - t1;
+ t[j] = t2;
+ if (verbose)
+ printf("%.3f ", t[j]);
+ }
+ if (verbose)
+ printf("[%.3f]\n", noise(t, NTRIALS));
+ /* If there is too much noise, discard the test */
+ if (noise(t, NTRIALS) > VARIANCE_THRESHOLD) {
+ *avgTimeUser = 0;
+ *avgTimeMPI = 0;
+ if (verbose)
+ printf("Too much noise; discarding measurement\n");
+ }
+ else {
+ *avgTimeMPI = mean(t, NTRIALS) / N_REPS;
+ }
+ MPI_Type_free(&indextype);
+
+ return 0;
}
-int Report( const char *name, const char *packname,
- double avgTimeMPI, double avgTimeUser );
-int Report( const char *name, const char *packname,
- double avgTimeMPI, double avgTimeUser )
+int Report(const char *name, const char *packname, double avgTimeMPI, double avgTimeUser);
+int Report(const char *name, const char *packname, double avgTimeMPI, double avgTimeUser)
{
- double diffTime, maxTime;
- int errs=0;
-
- /* Move this into a common routine */
- diffTime = avgTimeMPI - avgTimeUser;
- if (diffTime < 0) diffTime = - diffTime;
- if (avgTimeMPI > avgTimeUser) maxTime = avgTimeMPI;
- else maxTime = avgTimeUser;
-
- if (verbose) {
- printf( "%-30s:\t%g\t%g\t(%g%%)\n", name,
- avgTimeMPI, avgTimeUser,
- 100 * (diffTime / maxTime) );
- fflush(stdout);
- }
- if (avgTimeMPI > avgTimeUser && (diffTime > THRESHOLD * maxTime)) {
- errs++;
- printf( "%s:\tMPI %s code is too slow: MPI %g\t User %g\n",
- name, packname, avgTimeMPI, avgTimeUser );
- }
-
- return errs;
+ double diffTime, maxTime;
+ int errs = 0;
+
+ /* Move this into a common routine */
+ diffTime = avgTimeMPI - avgTimeUser;
+ if (diffTime < 0)
+ diffTime = -diffTime;
+ if (avgTimeMPI > avgTimeUser)
+ maxTime = avgTimeMPI;
+ else
+ maxTime = avgTimeUser;
+
+ if (verbose) {
+ printf("%-30s:\t%g\t%g\t(%g%%)\n", name,
+ avgTimeMPI, avgTimeUser, 100 * (diffTime / maxTime));
+ fflush(stdout);
+ }
+ if (avgTimeMPI > avgTimeUser && (diffTime > THRESHOLD * maxTime)) {
+ errs++;
+ printf("%s:\tMPI %s code is too slow: MPI %g\t User %g\n",
+ name, packname, avgTimeMPI, avgTimeUser);
+ }
+
+ return errs;
}
/* Finally, here's the main program */
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int n, stride, err, errs = 0;
void *dest, *src;
double avgTimeUser, avgTimeMPI;
- MPI_Init( &argc, &argv );
- if (getenv("MPITEST_VERBOSE")) verbose = 1;
+ MPI_Init(&argc, &argv);
+ if (getenv("MPITEST_VERBOSE"))
+ verbose = 1;
- n = 30000;
+ n = 30000;
stride = 4;
- dest = (void *)malloc( n * sizeof(double) );
- src = (void *)malloc( n * ((1+stride)*sizeof(double)) );
+ dest = (void *) malloc(n * sizeof(double));
+ src = (void *) malloc(n * ((1 + stride) * sizeof(double)));
/* Touch the source and destination arrays */
- memset( src, 0, n * (1+stride)*sizeof(double) );
- memset( dest, 0, n * sizeof(double) );
+ memset(src, 0, n * (1 + stride) * sizeof(double));
+ memset(dest, 0, n * sizeof(double));
- err = TestVecPackDouble( n, stride, &avgTimeUser, &avgTimeMPI,
- dest, src );
- errs += Report( "VecPackDouble", "Pack", avgTimeMPI, avgTimeUser );
+ err = TestVecPackDouble(n, stride, &avgTimeUser, &avgTimeMPI, dest, src);
+ errs += Report("VecPackDouble", "Pack", avgTimeMPI, avgTimeUser);
- err = TestVecUnPackDouble( n, stride, &avgTimeUser, &avgTimeMPI,
- src, dest );
- errs += Report( "VecUnPackDouble", "Unpack", avgTimeMPI, avgTimeUser );
+ err = TestVecUnPackDouble(n, stride, &avgTimeUser, &avgTimeMPI, src, dest);
+ errs += Report("VecUnPackDouble", "Unpack", avgTimeMPI, avgTimeUser);
- err = TestIndexPackDouble( n, stride, &avgTimeUser, &avgTimeMPI,
- dest, src );
- errs += Report( "VecIndexDouble", "Pack", avgTimeMPI, avgTimeUser );
+ err = TestIndexPackDouble(n, stride, &avgTimeUser, &avgTimeMPI, dest, src);
+ errs += Report("VecIndexDouble", "Pack", avgTimeMPI, avgTimeUser);
free(dest);
free(src);
-
- dest = (void *)malloc( 2*n * sizeof(double) );
- src = (void *)malloc( (1 + n) * ((1+stride)*sizeof(double)) );
- memset( dest, 0, 2*n * sizeof(double) );
- memset( src, 0, (1+n) * (1+stride)*sizeof(double) );
- err = TestVecPack2Double( n, stride, &avgTimeUser, &avgTimeMPI,
- dest, src );
- errs += Report( "VecPack2Double", "Pack", avgTimeMPI, avgTimeUser );
+
+ dest = (void *) malloc(2 * n * sizeof(double));
+ src = (void *) malloc((1 + n) * ((1 + stride) * sizeof(double)));
+ memset(dest, 0, 2 * n * sizeof(double));
+ memset(src, 0, (1 + n) * (1 + stride) * sizeof(double));
+ err = TestVecPack2Double(n, stride, &avgTimeUser, &avgTimeMPI, dest, src);
+ errs += Report("VecPack2Double", "Pack", avgTimeMPI, avgTimeUser);
free(dest);
free(src);
-
+
if (errs == 0) {
- printf( " No Errors\n" );
+ printf(" No Errors\n");
}
else {
- printf( " Found %d performance problems\n", errs );
+ printf(" Found %d performance problems\n", errs);
}
fflush(stdout);
diff --git a/test/mpi/perf/indexperf.c b/test/mpi/perf/indexperf.c
index e05463b..b49128b 100644
--- a/test/mpi/perf/indexperf.c
+++ b/test/mpi/perf/indexperf.c
@@ -23,163 +23,164 @@
static int verbose = 0;
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- double *inbuf, *outbuf, *outbuf2;
- MPI_Aint lb, extent;
- int *index_displacement;
- int icount, errs=0;
- int i, packsize, position, inbufsize;
+ double *inbuf, *outbuf, *outbuf2;
+ MPI_Aint lb, extent;
+ int *index_displacement;
+ int icount, errs = 0;
+ int i, packsize, position, inbufsize;
MPI_Datatype itype1, stype1;
- double t0, t1;
- double tpack, tspack, tmanual;
- int ntry;
+ double t0, t1;
+ double tpack, tspack, tmanual;
+ int ntry;
- MPI_Init( &argc, &argv );
+ MPI_Init(&argc, &argv);
icount = 2014;
/* Create a simple block indexed datatype */
- index_displacement = (int *)malloc( icount * sizeof(int) );
+ index_displacement = (int *) malloc(icount * sizeof(int));
if (!index_displacement) {
- fprintf( stderr, "Unable to allocated index array of size %d\n",
- icount );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Unable to allocated index array of size %d\n", icount);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- for (i=0; i<icount; i++) {
- index_displacement[i] = (i * 3 + (i%3));
+ for (i = 0; i < icount; i++) {
+ index_displacement[i] = (i * 3 + (i % 3));
}
- MPI_Type_create_indexed_block( icount, 1, index_displacement, MPI_DOUBLE,
- &itype1 );
- MPI_Type_commit( &itype1 );
-
+ MPI_Type_create_indexed_block(icount, 1, index_displacement, MPI_DOUBLE, &itype1);
+ MPI_Type_commit(&itype1);
+
#if defined(MPICH) && defined(PRINT_DATATYPE_INTERNALS)
/* To use MPIDU_Datatype_debug to print the datatype internals,
- you must configure MPICH with --enable-g=log */
+ * you must configure MPICH with --enable-g=log */
if (verbose) {
- printf( "Block index datatype:\n" );
- MPIDU_Datatype_debug( itype1, 10 );
+ printf("Block index datatype:\n");
+ MPIDU_Datatype_debug(itype1, 10);
}
#endif
- MPI_Type_get_extent( itype1, &lb, &extent );
+ MPI_Type_get_extent(itype1, &lb, &extent);
- MPI_Pack_size( 1, itype1, MPI_COMM_WORLD, &packsize );
+ MPI_Pack_size(1, itype1, MPI_COMM_WORLD, &packsize);
inbufsize = extent / sizeof(double);
- inbuf = (double *)malloc( extent );
- outbuf = (double *)malloc( packsize );
- outbuf2 = (double *)malloc( icount * sizeof(double) );
+ inbuf = (double *) malloc(extent);
+ outbuf = (double *) malloc(packsize);
+ outbuf2 = (double *) malloc(icount * sizeof(double));
if (!inbuf) {
- fprintf( stderr, "Unable to allocate %ld for inbuf\n", (long)extent );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Unable to allocate %ld for inbuf\n", (long) extent);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
if (!outbuf) {
- fprintf( stderr, "Unable to allocate %ld for outbuf\n", (long)packsize );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Unable to allocate %ld for outbuf\n", (long) packsize);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
if (!outbuf2) {
- fprintf( stderr, "Unable to allocate %ld for outbuf2\n", (long)packsize );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Unable to allocate %ld for outbuf2\n", (long) packsize);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- for (i=0; i<inbufsize; i++) {
- inbuf[i] = (double)i;
+ for (i = 0; i < inbufsize; i++) {
+ inbuf[i] = (double) i;
}
position = 0;
/* Warm up the code and data */
- MPI_Pack( inbuf, 1, itype1, outbuf, packsize, &position, MPI_COMM_WORLD );
+ MPI_Pack(inbuf, 1, itype1, outbuf, packsize, &position, MPI_COMM_WORLD);
tpack = 1e12;
for (ntry = 0; ntry < 5; ntry++) {
- position = 0;
- t0 = MPI_Wtime();
- MPI_Pack( inbuf, 1, itype1, outbuf, packsize, &position,
- MPI_COMM_WORLD );
- t1 = MPI_Wtime() - t0;
- if (t1 < tpack) tpack = t1;
+ position = 0;
+ t0 = MPI_Wtime();
+ MPI_Pack(inbuf, 1, itype1, outbuf, packsize, &position, MPI_COMM_WORLD);
+ t1 = MPI_Wtime() - t0;
+ if (t1 < tpack)
+ tpack = t1;
}
- { int one = 1; MPI_Aint displ = (MPI_Aint) inbuf;
- MPI_Type_create_struct( 1, &one, &displ, &itype1, &stype1 );
- MPI_Type_commit( &stype1 );
+ {
+ int one = 1;
+ MPI_Aint displ = (MPI_Aint) inbuf;
+ MPI_Type_create_struct(1, &one, &displ, &itype1, &stype1);
+ MPI_Type_commit(&stype1);
}
position = 0;
/* Warm up the code and data */
- MPI_Pack( MPI_BOTTOM, 1, stype1, outbuf, packsize, &position, MPI_COMM_WORLD );
+ MPI_Pack(MPI_BOTTOM, 1, stype1, outbuf, packsize, &position, MPI_COMM_WORLD);
tspack = 1e12;
for (ntry = 0; ntry < 5; ntry++) {
- position = 0;
- t0 = MPI_Wtime();
- MPI_Pack( MPI_BOTTOM, 1, stype1, outbuf, packsize, &position,
- MPI_COMM_WORLD );
- t1 = MPI_Wtime() - t0;
- if (t1 < tspack) tspack = t1;
+ position = 0;
+ t0 = MPI_Wtime();
+ MPI_Pack(MPI_BOTTOM, 1, stype1, outbuf, packsize, &position, MPI_COMM_WORLD);
+ t1 = MPI_Wtime() - t0;
+ if (t1 < tspack)
+ tspack = t1;
}
- /*
- Simple manual pack (without explicitly unrolling the index block)
- */
+ /*
+ * Simple manual pack (without explicitly unrolling the index block)
+ */
tmanual = 1e12;
for (ntry = 0; ntry < 5; ntry++) {
- const double *ppe = (const double *)inbuf;
- const int *id = (const int *)index_displacement;
- int k, j;
- t0 = MPI_Wtime();
- position = 0;
- for (i=0; i<icount; i++) {
- outbuf2[position++] = ppe[id[i]];
- }
- t1 = MPI_Wtime() - t0;
- if (t1 < tmanual) tmanual = t1;
- /* Check on correctness */
+ const double *ppe = (const double *) inbuf;
+ const int *id = (const int *) index_displacement;
+ int k, j;
+ t0 = MPI_Wtime();
+ position = 0;
+ for (i = 0; i < icount; i++) {
+ outbuf2[position++] = ppe[id[i]];
+ }
+ t1 = MPI_Wtime() - t0;
+ if (t1 < tmanual)
+ tmanual = t1;
+ /* Check on correctness */
#ifdef PACK_IS_NATIVE
- if (memcmp( outbuf, outbuf2, position ) != 0) {
- printf( "Panic - pack buffers differ\n" );
- }
+ if (memcmp(outbuf, outbuf2, position) != 0) {
+ printf("Panic - pack buffers differ\n");
+ }
#endif
}
if (verbose) {
- printf( "Bytes packed = %d\n", position );
- printf( "MPI_Pack time = %e, manual pack time = %e\n",
- tpack, tmanual );
- printf( "Pack with struct = %e\n", tspack );
+ printf("Bytes packed = %d\n", position);
+ printf("MPI_Pack time = %e, manual pack time = %e\n", tpack, tmanual);
+ printf("Pack with struct = %e\n", tspack);
}
- /* The threshold here permits the MPI datatype to perform at up to
- only one half the performance of simple user code. Note that the
- example code above may be made faster through careful use of const,
- restrict, and unrolling if the compiler doesn't already do that. */
+ /* The threshold here permits the MPI datatype to perform at up to
+ * only one half the performance of simple user code. Note that the
+ * example code above may be made faster through careful use of const,
+ * restrict, and unrolling if the compiler doesn't already do that. */
if (2 * tmanual < tpack) {
- errs++;
- printf( "MPI_Pack (block index) time = %e, manual pack time = %e\n", tpack, tmanual );
- printf( "MPI_Pack time should be less than 2 times the manual time\n" );
- printf( "For most informative results, be sure to compile this test with optimization\n" );
+ errs++;
+ printf("MPI_Pack (block index) time = %e, manual pack time = %e\n", tpack, tmanual);
+ printf("MPI_Pack time should be less than 2 times the manual time\n");
+ printf("For most informative results, be sure to compile this test with optimization\n");
}
if (2 * tmanual < tspack) {
- errs++;
- printf( "MPI_Pack (struct of block index)) time = %e, manual pack time = %e\n", tspack, tmanual );
- printf( "MPI_Pack time should be less than 2 times the manual time\n" );
- printf( "For most informative results, be sure to compile this test with optimization\n" );
+ errs++;
+ printf("MPI_Pack (struct of block index)) time = %e, manual pack time = %e\n", tspack,
+ tmanual);
+ printf("MPI_Pack time should be less than 2 times the manual time\n");
+ printf("For most informative results, be sure to compile this test with optimization\n");
}
if (errs) {
- printf( " Found %d errors\n", errs );
+ printf(" Found %d errors\n", errs);
}
else {
- printf( " No Errors\n" );
- }
-
- MPI_Type_free( &itype1 );
- MPI_Type_free( &stype1 );
-
- free( inbuf );
- free( outbuf );
- free( outbuf2 );
- free( index_displacement );
+ printf(" No Errors\n");
+ }
+
+ MPI_Type_free(&itype1);
+ MPI_Type_free(&stype1);
+
+ free(inbuf);
+ free(outbuf);
+ free(outbuf2);
+ free(index_displacement);
MPI_Finalize();
return 0;
diff --git a/test/mpi/perf/manyrma.c b/test/mpi/perf/manyrma.c
index 618581d..c7eb0be 100644
--- a/test/mpi/perf/manyrma.c
+++ b/test/mpi/perf/manyrma.c
@@ -4,11 +4,11 @@
* See COPYRIGHT in top-level directory.
*/
-/* This test measures the performance of many rma operations to a single
+/* This test measures the performance of many rma operations to a single
target process.
It uses a number of operations (put or accumulate) to different
- locations in the target window
- This is one of the ways that RMA may be used, and is used in the
+ locations in the target window
+ This is one of the ways that RMA may be used, and is used in the
reference implementation of the graph500 benchmark.
*/
#include "mpi.h"
@@ -20,9 +20,10 @@
#define MAX_RMA_SIZE 16
#define MAX_RUNS 10
-typedef enum { SYNC_NONE=0,
- SYNC_ALL=-1, SYNC_FENCE=1, SYNC_LOCK=2, SYNC_PSCW=4 } sync_t;
-typedef enum { RMA_NONE=0, RMA_ALL=-1, RMA_PUT=1, RMA_ACC=2, RMA_GET=4 } rma_t;
+typedef enum { SYNC_NONE = 0,
+ SYNC_ALL = -1, SYNC_FENCE = 1, SYNC_LOCK = 2, SYNC_PSCW = 4
+} sync_t;
+typedef enum { RMA_NONE = 0, RMA_ALL = -1, RMA_PUT = 1, RMA_ACC = 2, RMA_GET = 4 } rma_t;
/* Note GET not yet implemented */
sync_t syncChoice = SYNC_ALL;
rma_t rmaChoice = RMA_ALL;
@@ -35,361 +36,370 @@ static int verbose = 1;
static int barrierSync = 0;
static double tickThreshold = 0.0;
-void PrintResults( int cnt, timing t[] );
-void RunAccFence( MPI_Win win, int destRank, int cnt, int sz, timing t[] );
-void RunAccLock( MPI_Win win, int destRank, int cnt, int sz, timing t[] );
-void RunPutFence( MPI_Win win, int destRank, int cnt, int sz, timing t[] );
-void RunPutLock( MPI_Win win, int destRank, int cnt, int sz, timing t[] );
-void RunAccPSCW( MPI_Win win, int destRank, int cnt, int sz,
- MPI_Group exposureGroup, MPI_Group accessGroup, timing t[] );
-void RunPutPSCW( MPI_Win win, int destRank, int cnt, int sz,
- MPI_Group exposureGroup, MPI_Group accessGroup, timing t[] );
-
-int main( int argc, char *argv[] )
+void PrintResults(int cnt, timing t[]);
+void RunAccFence(MPI_Win win, int destRank, int cnt, int sz, timing t[]);
+void RunAccLock(MPI_Win win, int destRank, int cnt, int sz, timing t[]);
+void RunPutFence(MPI_Win win, int destRank, int cnt, int sz, timing t[]);
+void RunPutLock(MPI_Win win, int destRank, int cnt, int sz, timing t[]);
+void RunAccPSCW(MPI_Win win, int destRank, int cnt, int sz,
+ MPI_Group exposureGroup, MPI_Group accessGroup, timing t[]);
+void RunPutPSCW(MPI_Win win, int destRank, int cnt, int sz,
+ MPI_Group exposureGroup, MPI_Group accessGroup, timing t[]);
+
+int main(int argc, char *argv[])
{
- int arraysize, i, cnt, sz, maxCount=MAX_COUNT, *arraybuffer;
+ int arraysize, i, cnt, sz, maxCount = MAX_COUNT, *arraybuffer;
int wrank, wsize, destRank, srcRank;
MPI_Win win;
MPI_Group wgroup, accessGroup, exposureGroup;
timing t[MAX_RUNS];
- int maxSz = MAX_RMA_SIZE;
+ int maxSz = MAX_RMA_SIZE;
- MPI_Init( &argc, &argv );
+ MPI_Init(&argc, &argv);
/* Determine clock accuracy */
tickThreshold = 10.0 * MPI_Wtick();
- MPI_Allreduce( MPI_IN_PLACE, &tickThreshold, 1, MPI_DOUBLE, MPI_MAX,
- MPI_COMM_WORLD );
-
- for (i=1; i<argc; i++) {
- if (strcmp( argv[i], "-put" ) == 0) {
- if (rmaChoice == RMA_ALL) rmaChoice = RMA_NONE;
- rmaChoice |= RMA_PUT;
- }
- else if (strcmp( argv[i], "-acc" ) == 0) {
- if (rmaChoice == RMA_ALL) rmaChoice = RMA_NONE;
- rmaChoice |= RMA_ACC;
- }
- else if (strcmp( argv[i], "-fence" ) == 0) {
- if (syncChoice == SYNC_ALL) syncChoice = SYNC_NONE;
- syncChoice |= SYNC_FENCE;
- }
- else if (strcmp( argv[i], "-lock" ) == 0) {
- if (syncChoice == SYNC_ALL) syncChoice = SYNC_NONE;
- syncChoice |= SYNC_LOCK;
- }
- else if (strcmp( argv[i], "-pscw" ) == 0) {
- if (syncChoice == SYNC_ALL) syncChoice = SYNC_NONE;
- syncChoice |= SYNC_PSCW;
- }
- else if (strcmp( argv[i], "-maxsz" ) == 0) {
- i++;
- maxSz = atoi( argv[i] );
- }
- else if (strcmp( argv[i], "-maxcount" ) == 0) {
- i++;
- maxCount = atoi( argv[i] );
- }
- else if (strcmp( argv[i], "-barrier" ) == 0) {
- barrierSync = 1;
- }
- else {
- fprintf( stderr, "Unrecognized argument %s\n", argv[i] );
- fprintf( stderr, "%s [ -put ] [ -acc ] [ -lock ] [ -fence ] [ -pscw ] [ -barrier ] [ -maxsz msgsize ]\n", argv[0] );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
+ MPI_Allreduce(MPI_IN_PLACE, &tickThreshold, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD);
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-put") == 0) {
+ if (rmaChoice == RMA_ALL)
+ rmaChoice = RMA_NONE;
+ rmaChoice |= RMA_PUT;
+ }
+ else if (strcmp(argv[i], "-acc") == 0) {
+ if (rmaChoice == RMA_ALL)
+ rmaChoice = RMA_NONE;
+ rmaChoice |= RMA_ACC;
+ }
+ else if (strcmp(argv[i], "-fence") == 0) {
+ if (syncChoice == SYNC_ALL)
+ syncChoice = SYNC_NONE;
+ syncChoice |= SYNC_FENCE;
+ }
+ else if (strcmp(argv[i], "-lock") == 0) {
+ if (syncChoice == SYNC_ALL)
+ syncChoice = SYNC_NONE;
+ syncChoice |= SYNC_LOCK;
+ }
+ else if (strcmp(argv[i], "-pscw") == 0) {
+ if (syncChoice == SYNC_ALL)
+ syncChoice = SYNC_NONE;
+ syncChoice |= SYNC_PSCW;
+ }
+ else if (strcmp(argv[i], "-maxsz") == 0) {
+ i++;
+ maxSz = atoi(argv[i]);
+ }
+ else if (strcmp(argv[i], "-maxcount") == 0) {
+ i++;
+ maxCount = atoi(argv[i]);
+ }
+ else if (strcmp(argv[i], "-barrier") == 0) {
+ barrierSync = 1;
+ }
+ else {
+ fprintf(stderr, "Unrecognized argument %s\n", argv[i]);
+ fprintf(stderr,
+ "%s [ -put ] [ -acc ] [ -lock ] [ -fence ] [ -pscw ] [ -barrier ] [ -maxsz msgsize ]\n",
+ argv[0]);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
}
-
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
- MPI_Comm_size( MPI_COMM_WORLD, &wsize );
+
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
+ MPI_Comm_size(MPI_COMM_WORLD, &wsize);
destRank = wrank + 1;
- while (destRank >= wsize) destRank = destRank - wsize;
+ while (destRank >= wsize)
+ destRank = destRank - wsize;
srcRank = wrank - 1;
- if (srcRank < 0) srcRank += wsize;
+ if (srcRank < 0)
+ srcRank += wsize;
/* Create groups for PSCW */
- MPI_Comm_group( MPI_COMM_WORLD, &wgroup );
- MPI_Group_incl( wgroup, 1, &destRank, &accessGroup );
- MPI_Group_incl( wgroup, 1, &srcRank, &exposureGroup );
- MPI_Group_free( &wgroup );
+ MPI_Comm_group(MPI_COMM_WORLD, &wgroup);
+ MPI_Group_incl(wgroup, 1, &destRank, &accessGroup);
+ MPI_Group_incl(wgroup, 1, &srcRank, &exposureGroup);
+ MPI_Group_free(&wgroup);
arraysize = maxSz * MAX_COUNT;
- arraybuffer = (int*)malloc( arraysize * sizeof(int) );
+ arraybuffer = (int *) malloc(arraysize * sizeof(int));
if (!arraybuffer) {
- fprintf( stderr, "Unable to allocate %d words\n", arraysize );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Unable to allocate %d words\n", arraysize);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- MPI_Win_create( arraybuffer, arraysize*sizeof(int), (int)sizeof(int),
- MPI_INFO_NULL, MPI_COMM_WORLD, &win );
+ MPI_Win_create(arraybuffer, arraysize * sizeof(int), (int) sizeof(int),
+ MPI_INFO_NULL, MPI_COMM_WORLD, &win);
/* FIXME: we need a test on performance consistency.
- The test needs to have both a relative growth limit and
- an absolute limit.
- */
+ * The test needs to have both a relative growth limit and
+ * an absolute limit.
+ */
if (maxCount > MAX_COUNT) {
- fprintf( stderr, "MaxCount must not exceed %d\n", MAX_COUNT );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "MaxCount must not exceed %d\n", MAX_COUNT);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
if ((syncChoice & SYNC_FENCE) && (rmaChoice & RMA_ACC)) {
- for (sz=1; sz<=maxSz; sz = sz + sz) {
- if (wrank == 0)
- printf( "Accumulate with fence, %d elements\n", sz );
- cnt = 1;
- while (cnt <= maxCount) {
- RunAccFence( win, destRank, cnt, sz, t );
- if (wrank == 0) {
- PrintResults( cnt, t );
- }
- cnt = 2 * cnt;
- }
- }
+ for (sz = 1; sz <= maxSz; sz = sz + sz) {
+ if (wrank == 0)
+ printf("Accumulate with fence, %d elements\n", sz);
+ cnt = 1;
+ while (cnt <= maxCount) {
+ RunAccFence(win, destRank, cnt, sz, t);
+ if (wrank == 0) {
+ PrintResults(cnt, t);
+ }
+ cnt = 2 * cnt;
+ }
+ }
}
if ((syncChoice & SYNC_LOCK) && (rmaChoice & RMA_ACC)) {
- for (sz=1; sz<=maxSz; sz = sz + sz) {
- if (wrank == 0)
- printf( "Accumulate with lock, %d elements\n", sz );
- cnt = 1;
- while (cnt <= maxCount) {
- RunAccLock( win, destRank, cnt, sz, t );
- if (wrank == 0) {
- PrintResults( cnt, t );
- }
- cnt = 2 * cnt;
- }
- }
+ for (sz = 1; sz <= maxSz; sz = sz + sz) {
+ if (wrank == 0)
+ printf("Accumulate with lock, %d elements\n", sz);
+ cnt = 1;
+ while (cnt <= maxCount) {
+ RunAccLock(win, destRank, cnt, sz, t);
+ if (wrank == 0) {
+ PrintResults(cnt, t);
+ }
+ cnt = 2 * cnt;
+ }
+ }
}
if ((syncChoice & SYNC_FENCE) && (rmaChoice & RMA_PUT)) {
- for (sz=1; sz<=maxSz; sz = sz + sz) {
- if (wrank == 0)
- printf( "Put with fence, %d elements\n", sz );
- cnt = 1;
- while (cnt <= maxCount) {
- RunPutFence( win, destRank, cnt, sz, t );
- if (wrank == 0) {
- PrintResults( cnt, t );
- }
- cnt = 2 * cnt;
- }
- }
+ for (sz = 1; sz <= maxSz; sz = sz + sz) {
+ if (wrank == 0)
+ printf("Put with fence, %d elements\n", sz);
+ cnt = 1;
+ while (cnt <= maxCount) {
+ RunPutFence(win, destRank, cnt, sz, t);
+ if (wrank == 0) {
+ PrintResults(cnt, t);
+ }
+ cnt = 2 * cnt;
+ }
+ }
}
if ((syncChoice & SYNC_LOCK) && (rmaChoice & RMA_PUT)) {
- for (sz=1; sz<=maxSz; sz = sz + sz) {
- if (wrank == 0)
- printf( "Put with lock, %d elements\n", sz );
- cnt = 1;
- while (cnt <= maxCount) {
- RunPutLock( win, destRank, cnt, sz, t );
- if (wrank == 0) {
- PrintResults( cnt, t );
- }
- cnt = 2 * cnt;
- }
- }
+ for (sz = 1; sz <= maxSz; sz = sz + sz) {
+ if (wrank == 0)
+ printf("Put with lock, %d elements\n", sz);
+ cnt = 1;
+ while (cnt <= maxCount) {
+ RunPutLock(win, destRank, cnt, sz, t);
+ if (wrank == 0) {
+ PrintResults(cnt, t);
+ }
+ cnt = 2 * cnt;
+ }
+ }
}
if ((syncChoice & SYNC_PSCW) && (rmaChoice & RMA_PUT)) {
- for (sz=1; sz<=maxSz; sz = sz + sz) {
- if (wrank == 0)
- printf( "Put with pscw, %d elements\n", sz );
- cnt = 1;
- while (cnt <= maxCount) {
- RunPutPSCW( win, destRank, cnt, sz,
- exposureGroup, accessGroup, t );
- if (wrank == 0) {
- PrintResults( cnt, t );
- }
- cnt = 2 * cnt;
- }
- }
+ for (sz = 1; sz <= maxSz; sz = sz + sz) {
+ if (wrank == 0)
+ printf("Put with pscw, %d elements\n", sz);
+ cnt = 1;
+ while (cnt <= maxCount) {
+ RunPutPSCW(win, destRank, cnt, sz, exposureGroup, accessGroup, t);
+ if (wrank == 0) {
+ PrintResults(cnt, t);
+ }
+ cnt = 2 * cnt;
+ }
+ }
}
if ((syncChoice & SYNC_PSCW) && (rmaChoice & RMA_ACC)) {
- for (sz=1; sz<=maxSz; sz = sz + sz) {
- if (wrank == 0)
- printf( "Accumulate with pscw, %d elements\n", sz );
- cnt = 1;
- while (cnt <= maxCount) {
- RunAccPSCW( win, destRank, cnt, sz,
- exposureGroup, accessGroup, t );
- if (wrank == 0) {
- PrintResults( cnt, t );
- }
- cnt = 2 * cnt;
- }
- }
+ for (sz = 1; sz <= maxSz; sz = sz + sz) {
+ if (wrank == 0)
+ printf("Accumulate with pscw, %d elements\n", sz);
+ cnt = 1;
+ while (cnt <= maxCount) {
+ RunAccPSCW(win, destRank, cnt, sz, exposureGroup, accessGroup, t);
+ if (wrank == 0) {
+ PrintResults(cnt, t);
+ }
+ cnt = 2 * cnt;
+ }
+ }
}
- MPI_Win_free( &win );
+ MPI_Win_free(&win);
+
+ MPI_Group_free(&accessGroup);
+ MPI_Group_free(&exposureGroup);
- MPI_Group_free( &accessGroup );
- MPI_Group_free( &exposureGroup );
-
MPI_Finalize();
return 0;
}
-void RunAccFence( MPI_Win win, int destRank, int cnt, int sz, timing t[] )
+void RunAccFence(MPI_Win win, int destRank, int cnt, int sz, timing t[])
{
int k, i, j, one = 1;
- for (k=0; k<MAX_RUNS; k++) {
- MPI_Barrier( MPI_COMM_WORLD );
- MPI_Win_fence( 0, win );
- j = 0;
- t[k].startOp = MPI_Wtime();
- for (i=0; i<cnt; i++) {
- MPI_Accumulate( &one, sz, MPI_INT, destRank,
- j, sz, MPI_INT, MPI_SUM, win );
- j += sz;
- }
- t[k].endOp = MPI_Wtime();
- if (barrierSync) MPI_Barrier( MPI_COMM_WORLD );
- MPI_Win_fence( 0, win );
- t[k].endSync = MPI_Wtime();
+ for (k = 0; k < MAX_RUNS; k++) {
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Win_fence(0, win);
+ j = 0;
+ t[k].startOp = MPI_Wtime();
+ for (i = 0; i < cnt; i++) {
+ MPI_Accumulate(&one, sz, MPI_INT, destRank, j, sz, MPI_INT, MPI_SUM, win);
+ j += sz;
+ }
+ t[k].endOp = MPI_Wtime();
+ if (barrierSync)
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Win_fence(0, win);
+ t[k].endSync = MPI_Wtime();
}
}
-void RunAccLock( MPI_Win win, int destRank, int cnt, int sz, timing t[] )
+void RunAccLock(MPI_Win win, int destRank, int cnt, int sz, timing t[])
{
int k, i, j, one = 1;
- for (k=0; k<MAX_RUNS; k++) {
- MPI_Barrier( MPI_COMM_WORLD );
- MPI_Win_lock( MPI_LOCK_SHARED, destRank, 0, win );
- j = 0;
- t[k].startOp = MPI_Wtime();
- for (i=0; i<cnt; i++) {
- MPI_Accumulate( &one, sz, MPI_INT, destRank,
- j, sz, MPI_INT, MPI_SUM, win );
- j += sz;
- }
- t[k].endOp = MPI_Wtime();
- if (barrierSync) MPI_Barrier( MPI_COMM_WORLD );
- MPI_Win_unlock( destRank, win );
- t[k].endSync = MPI_Wtime();
+ for (k = 0; k < MAX_RUNS; k++) {
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Win_lock(MPI_LOCK_SHARED, destRank, 0, win);
+ j = 0;
+ t[k].startOp = MPI_Wtime();
+ for (i = 0; i < cnt; i++) {
+ MPI_Accumulate(&one, sz, MPI_INT, destRank, j, sz, MPI_INT, MPI_SUM, win);
+ j += sz;
+ }
+ t[k].endOp = MPI_Wtime();
+ if (barrierSync)
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Win_unlock(destRank, win);
+ t[k].endSync = MPI_Wtime();
}
}
-void RunPutFence( MPI_Win win, int destRank, int cnt, int sz, timing t[] )
+void RunPutFence(MPI_Win win, int destRank, int cnt, int sz, timing t[])
{
int k, i, j, one = 1;
- for (k=0; k<MAX_RUNS; k++) {
- MPI_Barrier( MPI_COMM_WORLD );
- MPI_Win_fence( 0, win );
- j = 0;
- t[k].startOp = MPI_Wtime();
- for (i=0; i<cnt; i++) {
- MPI_Put( &one, sz, MPI_INT, destRank,
- j, sz, MPI_INT, win );
- j += sz;
- }
- t[k].endOp = MPI_Wtime();
- if (barrierSync) MPI_Barrier( MPI_COMM_WORLD );
- MPI_Win_fence( 0, win );
- t[k].endSync = MPI_Wtime();
+ for (k = 0; k < MAX_RUNS; k++) {
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Win_fence(0, win);
+ j = 0;
+ t[k].startOp = MPI_Wtime();
+ for (i = 0; i < cnt; i++) {
+ MPI_Put(&one, sz, MPI_INT, destRank, j, sz, MPI_INT, win);
+ j += sz;
+ }
+ t[k].endOp = MPI_Wtime();
+ if (barrierSync)
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Win_fence(0, win);
+ t[k].endSync = MPI_Wtime();
}
}
-void RunPutLock( MPI_Win win, int destRank, int cnt, int sz, timing t[] )
+void RunPutLock(MPI_Win win, int destRank, int cnt, int sz, timing t[])
{
int k, i, j, one = 1;
- for (k=0; k<MAX_RUNS; k++) {
- MPI_Barrier( MPI_COMM_WORLD );
- MPI_Win_lock( MPI_LOCK_SHARED, destRank, 0, win );
- j = 0;
- t[k].startOp = MPI_Wtime();
- for (i=0; i<cnt; i++) {
- MPI_Put( &one, sz, MPI_INT, destRank, j, sz, MPI_INT, win );
- j += sz;
- }
- t[k].endOp = MPI_Wtime();
- if (barrierSync) MPI_Barrier( MPI_COMM_WORLD );
- MPI_Win_unlock( destRank, win );
- t[k].endSync = MPI_Wtime();
+ for (k = 0; k < MAX_RUNS; k++) {
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Win_lock(MPI_LOCK_SHARED, destRank, 0, win);
+ j = 0;
+ t[k].startOp = MPI_Wtime();
+ for (i = 0; i < cnt; i++) {
+ MPI_Put(&one, sz, MPI_INT, destRank, j, sz, MPI_INT, win);
+ j += sz;
+ }
+ t[k].endOp = MPI_Wtime();
+ if (barrierSync)
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Win_unlock(destRank, win);
+ t[k].endSync = MPI_Wtime();
}
}
-void RunPutPSCW( MPI_Win win, int destRank, int cnt, int sz,
- MPI_Group exposureGroup, MPI_Group accessGroup, timing t[] )
+void RunPutPSCW(MPI_Win win, int destRank, int cnt, int sz,
+ MPI_Group exposureGroup, MPI_Group accessGroup, timing t[])
{
int k, i, j, one = 1;
- for (k=0; k<MAX_RUNS; k++) {
- MPI_Barrier( MPI_COMM_WORLD );
- MPI_Win_post( exposureGroup, 0, win );
- MPI_Win_start( accessGroup, 0, win );
- j = 0;
- t[k].startOp = MPI_Wtime();
- for (i=0; i<cnt; i++) {
- MPI_Put( &one, sz, MPI_INT, destRank, j, sz, MPI_INT, win );
- j += sz;
- }
- t[k].endOp = MPI_Wtime();
- if (barrierSync) MPI_Barrier( MPI_COMM_WORLD );
- MPI_Win_complete( win );
- MPI_Win_wait( win );
- t[k].endSync = MPI_Wtime();
+ for (k = 0; k < MAX_RUNS; k++) {
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Win_post(exposureGroup, 0, win);
+ MPI_Win_start(accessGroup, 0, win);
+ j = 0;
+ t[k].startOp = MPI_Wtime();
+ for (i = 0; i < cnt; i++) {
+ MPI_Put(&one, sz, MPI_INT, destRank, j, sz, MPI_INT, win);
+ j += sz;
+ }
+ t[k].endOp = MPI_Wtime();
+ if (barrierSync)
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Win_complete(win);
+ MPI_Win_wait(win);
+ t[k].endSync = MPI_Wtime();
}
}
-void RunAccPSCW( MPI_Win win, int destRank, int cnt, int sz,
- MPI_Group exposureGroup, MPI_Group accessGroup, timing t[] )
+void RunAccPSCW(MPI_Win win, int destRank, int cnt, int sz,
+ MPI_Group exposureGroup, MPI_Group accessGroup, timing t[])
{
int k, i, j, one = 1;
- for (k=0; k<MAX_RUNS; k++) {
- MPI_Barrier( MPI_COMM_WORLD );
- MPI_Win_post( exposureGroup, 0, win );
- MPI_Win_start( accessGroup, 0, win );
- j = 0;
- t[k].startOp = MPI_Wtime();
- for (i=0; i<cnt; i++) {
- MPI_Accumulate( &one, sz, MPI_INT, destRank,
- j, sz, MPI_INT, MPI_SUM, win );
- j += sz;
- }
- t[k].endOp = MPI_Wtime();
- if (barrierSync) MPI_Barrier( MPI_COMM_WORLD );
- MPI_Win_complete( win );
- MPI_Win_wait( win );
- t[k].endSync = MPI_Wtime();
+ for (k = 0; k < MAX_RUNS; k++) {
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Win_post(exposureGroup, 0, win);
+ MPI_Win_start(accessGroup, 0, win);
+ j = 0;
+ t[k].startOp = MPI_Wtime();
+ for (i = 0; i < cnt; i++) {
+ MPI_Accumulate(&one, sz, MPI_INT, destRank, j, sz, MPI_INT, MPI_SUM, win);
+ j += sz;
+ }
+ t[k].endOp = MPI_Wtime();
+ if (barrierSync)
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Win_complete(win);
+ MPI_Win_wait(win);
+ t[k].endSync = MPI_Wtime();
}
}
-void PrintResults( int cnt, timing t[] )
+void PrintResults(int cnt, timing t[])
{
int k;
- double d1=0, d2=0;
+ double d1 = 0, d2 = 0;
double minD1 = 1e10, minD2 = 1e10;
double tOp, tSync;
- for (k=0; k<MAX_RUNS; k++) {
- tOp = t[k].endOp - t[k].startOp;
- tSync = t[k].endSync - t[k].endOp;
- d1 += tOp;
- d2 += tSync;
- if (tOp < minD1) minD1 = tOp;
- if (tSync < minD2) minD2 = tSync;
+ for (k = 0; k < MAX_RUNS; k++) {
+ tOp = t[k].endOp - t[k].startOp;
+ tSync = t[k].endSync - t[k].endOp;
+ d1 += tOp;
+ d2 += tSync;
+ if (tOp < minD1)
+ minD1 = tOp;
+ if (tSync < minD2)
+ minD2 = tSync;
}
if (verbose) {
- long rate = 0;
- /* Use the minimum times because they are more stable - if timing
- accuracy is an issue, use the min over multiple trials */
- d1 = minD1;
- d2 = minD2;
- /* d1 = d1 / MAX_RUNS; d2 = d2 / MAX_RUNS); */
- if (d2 > 0) rate = (long)(cnt) / d2;
- /* count, op, sync, op/each, sync/each, rate */
- printf( "%d\t%e\t%e\t%e\t%e\t%ld\n", cnt,
- d1, d2,
- d1 / cnt, d2 / cnt, rate );
+ long rate = 0;
+ /* Use the minimum times because they are more stable - if timing
+ * accuracy is an issue, use the min over multiple trials */
+ d1 = minD1;
+ d2 = minD2;
+ /* d1 = d1 / MAX_RUNS; d2 = d2 / MAX_RUNS); */
+ if (d2 > 0)
+ rate = (long) (cnt) / d2;
+ /* count, op, sync, op/each, sync/each, rate */
+ printf("%d\t%e\t%e\t%e\t%e\t%ld\n", cnt, d1, d2, d1 / cnt, d2 / cnt, rate);
}
}
diff --git a/test/mpi/perf/nestvec.c b/test/mpi/perf/nestvec.c
index 494f847..6ee12f5 100644
--- a/test/mpi/perf/nestvec.c
+++ b/test/mpi/perf/nestvec.c
@@ -30,161 +30,161 @@
static int verbose = 0;
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- int vcount = 16, vblock = vcount*vcount/2, vstride=2*vcount*vblock;
- int v2stride, typesize, packsize, i, position, errs = 0;
- char *inbuf, *outbuf, *outbuf2;
+ int vcount = 16, vblock = vcount * vcount / 2, vstride = 2 * vcount * vblock;
+ int v2stride, typesize, packsize, i, position, errs = 0;
+ char *inbuf, *outbuf, *outbuf2;
MPI_Datatype ft1type, ft2type, ft3type;
MPI_Datatype ftopttype;
- MPI_Aint lb, extent;
- double t0, t1;
- double tpack, tmanual, tpackopt;
- int ntry;
-
- MPI_Init( &argc, &argv );
-
- MPI_Type_contiguous( 6, MPI_FLOAT, &ft1type );
- MPI_Type_size( ft1type, &typesize );
+ MPI_Aint lb, extent;
+ double t0, t1;
+ double tpack, tmanual, tpackopt;
+ int ntry;
+
+ MPI_Init(&argc, &argv);
+
+ MPI_Type_contiguous(6, MPI_FLOAT, &ft1type);
+ MPI_Type_size(ft1type, &typesize);
v2stride = vcount * vcount * vcount * vcount * typesize;
- MPI_Type_vector( vcount, vblock, vstride, ft1type, &ft2type );
- MPI_Type_create_hvector( 2, 1, v2stride, ft2type, &ft3type );
- MPI_Type_commit( &ft3type );
- MPI_Type_free( &ft1type );
- MPI_Type_free( &ft2type );
+ MPI_Type_vector(vcount, vblock, vstride, ft1type, &ft2type);
+ MPI_Type_create_hvector(2, 1, v2stride, ft2type, &ft3type);
+ MPI_Type_commit(&ft3type);
+ MPI_Type_free(&ft1type);
+ MPI_Type_free(&ft2type);
#if defined(MPICH) && defined(PRINT_DATATYPE_INTERNALS)
/* To use MPIDU_Datatype_debug to print the datatype internals,
- you must configure MPICH with --enable-g=log */
+ * you must configure MPICH with --enable-g=log */
if (verbose) {
- printf( "Original datatype:\n" );
- MPIDU_Datatype_debug( ft3type, 10 );
+ printf("Original datatype:\n");
+ MPIDU_Datatype_debug(ft3type, 10);
}
#endif
/* The same type, but without using the contiguous type */
- MPI_Type_vector( vcount, 6*vblock, 6*vstride, MPI_FLOAT, &ft2type );
- MPI_Type_create_hvector( 2, 1, v2stride, ft2type, &ftopttype );
- MPI_Type_commit( &ftopttype );
- MPI_Type_free( &ft2type );
+ MPI_Type_vector(vcount, 6 * vblock, 6 * vstride, MPI_FLOAT, &ft2type);
+ MPI_Type_create_hvector(2, 1, v2stride, ft2type, &ftopttype);
+ MPI_Type_commit(&ftopttype);
+ MPI_Type_free(&ft2type);
#if defined(MPICH) && defined(PRINT_DATATYPE_INTERNALS)
if (verbose) {
- printf( "\n\nMerged datatype:\n" );
- MPIDU_Datatype_debug( ftopttype, 10 );
+ printf("\n\nMerged datatype:\n");
+ MPIDU_Datatype_debug(ftopttype, 10);
}
#endif
- MPI_Type_get_extent( ft3type, &lb, &extent );
- MPI_Type_size( ft3type, &typesize );
+ MPI_Type_get_extent(ft3type, &lb, &extent);
+ MPI_Type_size(ft3type, &typesize);
- MPI_Pack_size( 1, ft3type, MPI_COMM_WORLD, &packsize );
+ MPI_Pack_size(1, ft3type, MPI_COMM_WORLD, &packsize);
- inbuf = (char *)malloc( extent );
- outbuf = (char *)malloc( packsize );
- outbuf2 = (char *)malloc( packsize );
+ inbuf = (char *) malloc(extent);
+ outbuf = (char *) malloc(packsize);
+ outbuf2 = (char *) malloc(packsize);
if (!inbuf) {
- fprintf( stderr, "Unable to allocate %ld for inbuf\n", (long)extent );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Unable to allocate %ld for inbuf\n", (long) extent);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
if (!outbuf) {
- fprintf( stderr, "Unable to allocate %ld for outbuf\n", (long)packsize );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Unable to allocate %ld for outbuf\n", (long) packsize);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
if (!outbuf2) {
- fprintf( stderr, "Unable to allocate %ld for outbuf2\n", (long)packsize );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Unable to allocate %ld for outbuf2\n", (long) packsize);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- for (i=0; i<extent; i++) {
- inbuf[i] = i & 0x7f;
+ for (i = 0; i < extent; i++) {
+ inbuf[i] = i & 0x7f;
}
position = 0;
/* Warm up the code and data */
- MPI_Pack( inbuf, 1, ft3type, outbuf, packsize, &position, MPI_COMM_WORLD );
+ MPI_Pack(inbuf, 1, ft3type, outbuf, packsize, &position, MPI_COMM_WORLD);
/* Pack using the vector of vector of contiguous */
tpack = 1e12;
for (ntry = 0; ntry < 5; ntry++) {
- position = 0;
- t0 = MPI_Wtime();
- MPI_Pack( inbuf, 1, ft3type, outbuf, packsize, &position,
- MPI_COMM_WORLD );
- t1 = MPI_Wtime() - t0;
- if (t1 < tpack) tpack = t1;
+ position = 0;
+ t0 = MPI_Wtime();
+ MPI_Pack(inbuf, 1, ft3type, outbuf, packsize, &position, MPI_COMM_WORLD);
+ t1 = MPI_Wtime() - t0;
+ if (t1 < tpack)
+ tpack = t1;
}
- MPI_Type_free( &ft3type );
+ MPI_Type_free(&ft3type);
/* Pack using vector of vector with big blocks (same type map) */
tpackopt = 1e12;
for (ntry = 0; ntry < 5; ntry++) {
- position = 0;
- t0 = MPI_Wtime();
- MPI_Pack( inbuf, 1, ftopttype, outbuf, packsize, &position,
- MPI_COMM_WORLD );
- t1 = MPI_Wtime() - t0;
- if (t1 < tpackopt) tpackopt = t1;
+ position = 0;
+ t0 = MPI_Wtime();
+ MPI_Pack(inbuf, 1, ftopttype, outbuf, packsize, &position, MPI_COMM_WORLD);
+ t1 = MPI_Wtime() - t0;
+ if (t1 < tpackopt)
+ tpackopt = t1;
}
- MPI_Type_free( &ftopttype );
+ MPI_Type_free(&ftopttype);
/* User (manual) packing code.
- Note that we exploit the fact that the vector type contains vblock
- instances of a contiguous type of size 24, or equivalently a
- single block of 24*vblock bytes.
- */
+ * Note that we exploit the fact that the vector type contains vblock
+ * instances of a contiguous type of size 24, or equivalently a
+ * single block of 24*vblock bytes.
+ */
tmanual = 1e12;
for (ntry = 0; ntry < 5; ntry++) {
- const char *ppe = (const char *)inbuf;
- int k, j;
- t0 = MPI_Wtime();
- position = 0;
- for (k=0; k<2; k++) { /* hvector count; blocksize is 1 */
- const char *ptr = ppe;
- for (j=0; j<vcount; j++) { /* vector count */
- memcpy( outbuf2 + position, ptr, 24*vblock );
- ptr += vstride * 24;
- position += 24*vblock;
- }
- ppe += v2stride;
- }
- t1 = MPI_Wtime() - t0;
- if (t1 < tmanual) tmanual = t1;
-
- /* Check on correctness */
+ const char *ppe = (const char *) inbuf;
+ int k, j;
+ t0 = MPI_Wtime();
+ position = 0;
+ for (k = 0; k < 2; k++) { /* hvector count; blocksize is 1 */
+ const char *ptr = ppe;
+ for (j = 0; j < vcount; j++) { /* vector count */
+ memcpy(outbuf2 + position, ptr, 24 * vblock);
+ ptr += vstride * 24;
+ position += 24 * vblock;
+ }
+ ppe += v2stride;
+ }
+ t1 = MPI_Wtime() - t0;
+ if (t1 < tmanual)
+ tmanual = t1;
+
+ /* Check on correctness */
#ifdef PACK_IS_NATIVE
- if (memcmp( outbuf, outbuf2, position ) != 0) {
- printf( "Panic - pack buffers differ\n" );
- }
+ if (memcmp(outbuf, outbuf2, position) != 0) {
+ printf("Panic - pack buffers differ\n");
+ }
#endif
}
if (verbose) {
- printf( "Bytes packed = %d\n", position );
- printf( "MPI_Pack time = %e, opt version = %e, manual pack time = %e\n",
- tpack, tpackopt, tmanual );
+ printf("Bytes packed = %d\n", position);
+ printf("MPI_Pack time = %e, opt version = %e, manual pack time = %e\n",
+ tpack, tpackopt, tmanual);
}
/* A factor of 4 is extremely generous, especially since the test suite
- no longer builds any of the tests with optimization */
+ * no longer builds any of the tests with optimization */
if (4 * tmanual < tpack) {
- errs++;
- printf( "MPI_Pack time = %e, manual pack time = %e\n", tpack, tmanual );
- printf( "MPI_Pack time should be less than 4 times the manual time\n" );
- printf( "For most informative results, be sure to compile this test with optimization\n" );
+ errs++;
+ printf("MPI_Pack time = %e, manual pack time = %e\n", tpack, tmanual);
+ printf("MPI_Pack time should be less than 4 times the manual time\n");
+ printf("For most informative results, be sure to compile this test with optimization\n");
}
if (4 * tmanual < tpackopt) {
- errs++;
- printf( "MPI_Pack with opt = %e, manual pack time = %e\n", tpackopt,
- tmanual );
- printf( "MPI_Pack time should be less than 4 times the manual time\n" );
- printf( "For most informative results, be sure to compile this test with optimization\n" );
+ errs++;
+ printf("MPI_Pack with opt = %e, manual pack time = %e\n", tpackopt, tmanual);
+ printf("MPI_Pack time should be less than 4 times the manual time\n");
+ printf("For most informative results, be sure to compile this test with optimization\n");
}
if (errs) {
- printf( " Found %d errors\n", errs );
+ printf(" Found %d errors\n", errs);
}
else {
- printf( " No Errors\n" );
- }
-
- free( inbuf );
- free( outbuf );
- free( outbuf2 );
+ printf(" No Errors\n");
+ }
+
+ free(inbuf);
+ free(outbuf);
+ free(outbuf2);
MPI_Finalize();
return 0;
diff --git a/test/mpi/perf/nestvec2.c b/test/mpi/perf/nestvec2.c
index c54400f..a9e1841 100644
--- a/test/mpi/perf/nestvec2.c
+++ b/test/mpi/perf/nestvec2.c
@@ -30,182 +30,182 @@
static int verbose = 0;
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
- int vcount, vstride;
- int32_t counts[2];
- int v2stride, typesize, packsize, i, position, errs = 0;
- double *outbuf, *outbuf2;
- double *vsource;
+ int vcount, vstride;
+ int32_t counts[2];
+ int v2stride, typesize, packsize, i, position, errs = 0;
+ double *outbuf, *outbuf2;
+ double *vsource;
MPI_Datatype vtype, stype;
- MPI_Aint lb, extent;
- double t0, t1;
- double tspack, tvpack, tmanual;
- int ntry;
- int blocklengths[2];
- MPI_Aint displacements[2];
+ MPI_Aint lb, extent;
+ double t0, t1;
+ double tspack, tvpack, tmanual;
+ int ntry;
+ int blocklengths[2];
+ MPI_Aint displacements[2];
MPI_Datatype typesArray[2];
- MPI_Init( &argc, &argv );
-
- /* Create a struct consisting of a two 32-bit ints, followed by a
- vector of stride 3 but count 128k (less than a few MB of data area) */
- vcount = 128000;
+ MPI_Init(&argc, &argv);
+
+ /* Create a struct consisting of a two 32-bit ints, followed by a
+ * vector of stride 3 but count 128k (less than a few MB of data area) */
+ vcount = 128000;
vstride = 3;
- MPI_Type_vector( vcount, 1, vstride, MPI_DOUBLE, &vtype );
+ MPI_Type_vector(vcount, 1, vstride, MPI_DOUBLE, &vtype);
- vsource = (double *)malloc( (vcount + 1) * (vstride + 1) * sizeof(double) );
+ vsource = (double *) malloc((vcount + 1) * (vstride + 1) * sizeof(double));
if (!vsource) {
- fprintf( stderr, "Unable to allocate vsource\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Unable to allocate vsource\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- for (i=0; i<vcount*vstride; i++) {
- vsource[i] = i;
+ for (i = 0; i < vcount * vstride; i++) {
+ vsource[i] = i;
}
- blocklengths[0] = 2; MPI_Get_address( &counts[0], &displacements[0] );
- blocklengths[1] = 1; MPI_Get_address( vsource, &displacements[1] );
+ blocklengths[0] = 2;
+ MPI_Get_address(&counts[0], &displacements[0]);
+ blocklengths[1] = 1;
+ MPI_Get_address(vsource, &displacements[1]);
if (verbose) {
- printf( "%p = %p?\n", vsource, (void *)displacements[1] );
+ printf("%p = %p?\n", vsource, (void *) displacements[1]);
}
typesArray[0] = MPI_INT32_T;
typesArray[1] = vtype;
- MPI_Type_create_struct( 2, blocklengths, displacements, typesArray,
- &stype );
- MPI_Type_commit( &stype );
- MPI_Type_commit( &vtype );
+ MPI_Type_create_struct(2, blocklengths, displacements, typesArray, &stype);
+ MPI_Type_commit(&stype);
+ MPI_Type_commit(&vtype);
#if defined(MPICH) && defined(PRINT_DATATYPE_INTERNALS)
/* To use MPIDU_Datatype_debug to print the datatype internals,
- you must configure MPICH with --enable-g=log */
+ * you must configure MPICH with --enable-g=log */
if (verbose) {
- printf( "Original struct datatype:\n" );
- MPIDU_Datatype_debug( stype, 10 );
+ printf("Original struct datatype:\n");
+ MPIDU_Datatype_debug(stype, 10);
}
#endif
- MPI_Pack_size( 1, stype, MPI_COMM_WORLD, &packsize );
- outbuf = (double *)malloc( packsize );
- outbuf2 = (double *)malloc( packsize );
+ MPI_Pack_size(1, stype, MPI_COMM_WORLD, &packsize);
+ outbuf = (double *) malloc(packsize);
+ outbuf2 = (double *) malloc(packsize);
if (!outbuf) {
- fprintf( stderr, "Unable to allocate %ld for outbuf\n", (long)packsize );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Unable to allocate %ld for outbuf\n", (long) packsize);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
if (!outbuf2) {
- fprintf( stderr, "Unable to allocate %ld for outbuf2\n", (long)packsize );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Unable to allocate %ld for outbuf2\n", (long) packsize);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
position = 0;
/* Warm up the code and data */
- MPI_Pack( MPI_BOTTOM, 1, stype, outbuf, packsize, &position,
- MPI_COMM_WORLD );
+ MPI_Pack(MPI_BOTTOM, 1, stype, outbuf, packsize, &position, MPI_COMM_WORLD);
tspack = 1e12;
for (ntry = 0; ntry < 5; ntry++) {
- position = 0;
- t0 = MPI_Wtime();
- MPI_Pack( MPI_BOTTOM, 1, stype, outbuf, packsize, &position,
- MPI_COMM_WORLD );
- t1 = MPI_Wtime() - t0;
- if (t1 < tspack) tspack = t1;
+ position = 0;
+ t0 = MPI_Wtime();
+ MPI_Pack(MPI_BOTTOM, 1, stype, outbuf, packsize, &position, MPI_COMM_WORLD);
+ t1 = MPI_Wtime() - t0;
+ if (t1 < tspack)
+ tspack = t1;
}
- MPI_Type_free( &stype );
+ MPI_Type_free(&stype);
/* An equivalent packing, using the 2 ints and the vector separately */
tvpack = 1e12;
for (ntry = 0; ntry < 5; ntry++) {
- position = 0;
- t0 = MPI_Wtime();
- MPI_Pack( counts, 2, MPI_INT32_T, outbuf, packsize, &position,
- MPI_COMM_WORLD );
- MPI_Pack( vsource, 1, vtype, outbuf, packsize, &position,
- MPI_COMM_WORLD );
- t1 = MPI_Wtime() - t0;
- if (t1 < tvpack) tvpack = t1;
+ position = 0;
+ t0 = MPI_Wtime();
+ MPI_Pack(counts, 2, MPI_INT32_T, outbuf, packsize, &position, MPI_COMM_WORLD);
+ MPI_Pack(vsource, 1, vtype, outbuf, packsize, &position, MPI_COMM_WORLD);
+ t1 = MPI_Wtime() - t0;
+ if (t1 < tvpack)
+ tvpack = t1;
}
- MPI_Type_free( &vtype );
+ MPI_Type_free(&vtype);
- /* Note that we exploit the fact that the vector type contains vblock
- instances of a contiguous type of size 24, or a single block of 24*vblock
- bytes.
- */
+ /* Note that we exploit the fact that the vector type contains vblock
+ * instances of a contiguous type of size 24, or a single block of 24*vblock
+ * bytes.
+ */
tmanual = 1e12;
for (ntry = 0; ntry < 5; ntry++) {
- const double * restrict ppe = (const double *)vsource;
- double * restrict ppo = outbuf2;
- int j;
- t0 = MPI_Wtime();
- position = 0;
- *(int32_t *)ppo = counts[0];
- *( ((int32_t *)ppo) + 1) = counts[1];
- ppo++;
- /* Some hand optimization because this file is not normally
- compiled with optimization by the test suite */
- j = vcount;
- while (j) {
- *ppo++ = *ppe;
- ppe += vstride;
- *ppo++ = *ppe;
- ppe += vstride;
- *ppo++ = *ppe;
- ppe += vstride;
- *ppo++ = *ppe;
- ppe += vstride;
- j -= 4;
- }
- position += (1 + vcount);
- position *= sizeof(double);
- t1 = MPI_Wtime() - t0;
- if (t1 < tmanual) tmanual = t1;
-
- /* Check on correctness */
+ const double *restrict ppe = (const double *) vsource;
+ double *restrict ppo = outbuf2;
+ int j;
+ t0 = MPI_Wtime();
+ position = 0;
+ *(int32_t *) ppo = counts[0];
+ *(((int32_t *) ppo) + 1) = counts[1];
+ ppo++;
+ /* Some hand optimization because this file is not normally
+ * compiled with optimization by the test suite */
+ j = vcount;
+ while (j) {
+ *ppo++ = *ppe;
+ ppe += vstride;
+ *ppo++ = *ppe;
+ ppe += vstride;
+ *ppo++ = *ppe;
+ ppe += vstride;
+ *ppo++ = *ppe;
+ ppe += vstride;
+ j -= 4;
+ }
+ position += (1 + vcount);
+ position *= sizeof(double);
+ t1 = MPI_Wtime() - t0;
+ if (t1 < tmanual)
+ tmanual = t1;
+
+ /* Check on correctness */
#ifdef PACK_IS_NATIVE
- if (memcmp( outbuf, outbuf2, position ) != 0) {
- printf( "Panic(manual) - pack buffers differ\n" );
- for (j=0; j<8; j++) {
- printf( "%d: %llx\t%llx\n", j, (long long unsigned)outbuf[j],
- (long long unsigned)outbuf2[j] );
- }
- }
+ if (memcmp(outbuf, outbuf2, position) != 0) {
+ printf("Panic(manual) - pack buffers differ\n");
+ for (j = 0; j < 8; j++) {
+ printf("%d: %llx\t%llx\n", j, (long long unsigned) outbuf[j],
+ (long long unsigned) outbuf2[j]);
+ }
+ }
#endif
}
if (verbose) {
- printf( "Bytes packed = %d\n", position );
- printf( "MPI_Pack time = %e (struct), = %e (vector), manual pack time = %e\n",
- tspack, tvpack, tmanual );
+ printf("Bytes packed = %d\n", position);
+ printf("MPI_Pack time = %e (struct), = %e (vector), manual pack time = %e\n",
+ tspack, tvpack, tmanual);
}
if (4 * tmanual < tspack) {
- errs++;
- printf( "MPI_Pack time using struct with vector = %e, manual pack time = %e\n", tspack, tmanual )
-;
- printf( "MPI_Pack time should be less than 4 times the manual time\n" );
- printf( "For most informative results, be sure to compile this test with optimization\n" );
+ errs++;
+ printf("MPI_Pack time using struct with vector = %e, manual pack time = %e\n", tspack,
+ tmanual);
+ printf("MPI_Pack time should be less than 4 times the manual time\n");
+ printf("For most informative results, be sure to compile this test with optimization\n");
}
if (4 * tmanual < tvpack) {
- errs++;
- printf( "MPI_Pack using vector = %e, manual pack time = %e\n", tvpack,
- tmanual );
- printf( "MPI_Pack time should be less than 4 times the manual time\n" );
- printf( "For most informative results, be sure to compile this test with optimization\n" );
+ errs++;
+ printf("MPI_Pack using vector = %e, manual pack time = %e\n", tvpack, tmanual);
+ printf("MPI_Pack time should be less than 4 times the manual time\n");
+ printf("For most informative results, be sure to compile this test with optimization\n");
}
if (4 * tvpack < tspack) {
- errs++;
- printf( "MPI_Pack using a vector = %e, using a struct with vector = %e\n", tvpack, tspack );
- printf( "MPI_Pack time using vector should be about the same as the struct containing the vector\n" );
- printf( "For most informative results, be sure to compile this test with optimization\n" );
+ errs++;
+ printf("MPI_Pack using a vector = %e, using a struct with vector = %e\n", tvpack, tspack);
+ printf
+ ("MPI_Pack time using vector should be about the same as the struct containing the vector\n");
+ printf("For most informative results, be sure to compile this test with optimization\n");
}
if (errs) {
- printf( " Found %d errors\n", errs );
+ printf(" Found %d errors\n", errs);
}
else {
- printf( " No Errors\n" );
- }
-
- free( vsource );
- free( outbuf );
- free( outbuf2 );
+ printf(" No Errors\n");
+ }
+
+ free(vsource);
+ free(outbuf);
+ free(outbuf2);
MPI_Finalize();
return 0;
diff --git a/test/mpi/perf/non_zero_root.c b/test/mpi/perf/non_zero_root.c
index 9384d6b..553c2db 100644
--- a/test/mpi/perf/non_zero_root.c
+++ b/test/mpi/perf/non_zero_root.c
@@ -15,63 +15,67 @@
static int verbose = 0;
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
- char *sbuf, *rbuf;
- int i, j;
- double t1, t2, t, ts;
- int rank, size;
- MPI_Status status;
+ char *sbuf, *rbuf;
+ int i, j;
+ double t1, t2, t, ts;
+ int rank, size;
+ MPI_Status status;
- MPI_Init(&argc,&argv);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
- MPI_Comm_size(MPI_COMM_WORLD, &size);
+ MPI_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
- if (getenv("MPITEST_VERBOSE")) verbose = 1;
+ if (getenv("MPITEST_VERBOSE"))
+ verbose = 1;
- /* Allocate memory regions to communicate */
- sbuf = (char*) malloc(SIZE);
- rbuf = (char*) malloc(size * SIZE);
+ /* Allocate memory regions to communicate */
+ sbuf = (char *) malloc(SIZE);
+ rbuf = (char *) malloc(size * SIZE);
- /* Touch the buffers to make sure they are allocated */
- for (i = 0; i < SIZE; i++) sbuf[i] = '0';
- for (i = 0; i < SIZE * size; i++) rbuf[i] = '0';
+ /* Touch the buffers to make sure they are allocated */
+ for (i = 0; i < SIZE; i++)
+ sbuf[i] = '0';
+ for (i = 0; i < SIZE * size; i++)
+ rbuf[i] = '0';
- /* Time when rank 0 gathers the data */
- MPI_Barrier(MPI_COMM_WORLD);
- t1 = MPI_Wtime();
- for (i = 0; i < ITER; i++) {
- MPI_Gather(sbuf, SIZE, MPI_BYTE, rbuf, SIZE, MPI_BYTE, 0, MPI_COMM_WORLD);
- MPI_Barrier(MPI_COMM_WORLD);
- }
- t2 = MPI_Wtime();
- t = (t2-t1)/ITER;
+ /* Time when rank 0 gathers the data */
+ MPI_Barrier(MPI_COMM_WORLD);
+ t1 = MPI_Wtime();
+ for (i = 0; i < ITER; i++) {
+ MPI_Gather(sbuf, SIZE, MPI_BYTE, rbuf, SIZE, MPI_BYTE, 0, MPI_COMM_WORLD);
+ MPI_Barrier(MPI_COMM_WORLD);
+ }
+ t2 = MPI_Wtime();
+ t = (t2 - t1) / ITER;
- /* Time when rank 1 gathers the data */
- MPI_Barrier(MPI_COMM_WORLD);
- t1 = MPI_Wtime();
- for (j = 0; j < ITER; j++) {
- MPI_Gather(sbuf, SIZE, MPI_BYTE, rbuf, SIZE, MPI_BYTE, 1, MPI_COMM_WORLD);
- MPI_Barrier(MPI_COMM_WORLD);
- }
- t2 = MPI_Wtime();
- ts = (t2-t1)/ITER;
+ /* Time when rank 1 gathers the data */
+ MPI_Barrier(MPI_COMM_WORLD);
+ t1 = MPI_Wtime();
+ for (j = 0; j < ITER; j++) {
+ MPI_Gather(sbuf, SIZE, MPI_BYTE, rbuf, SIZE, MPI_BYTE, 1, MPI_COMM_WORLD);
+ MPI_Barrier(MPI_COMM_WORLD);
+ }
+ t2 = MPI_Wtime();
+ ts = (t2 - t1) / ITER;
- if (rank == 1)
- MPI_Send(&ts, 1, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD);
- if (rank == 0)
- MPI_Recv(&ts, 1, MPI_DOUBLE, 1, 0, MPI_COMM_WORLD, &status);
+ if (rank == 1)
+ MPI_Send(&ts, 1, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD);
+ if (rank == 0)
+ MPI_Recv(&ts, 1, MPI_DOUBLE, 1, 0, MPI_COMM_WORLD, &status);
- /* Print out the results */
- if (!rank) {
- if ((ts / t) > (1 + ERROR_MARGIN)) { /* If the difference is more than 10%, it's an error */
- printf("%.3f\t%.3f\n", 1000000.0 * ts, 1000000.0 * t);
- printf("Too much difference in performance\n");
- }
- else printf(" No Errors\n");
- }
-
- MPI_Finalize();
+ /* Print out the results */
+ if (!rank) {
+ if ((ts / t) > (1 + ERROR_MARGIN)) { /* If the difference is more than 10%, it's an error */
+ printf("%.3f\t%.3f\n", 1000000.0 * ts, 1000000.0 * t);
+ printf("Too much difference in performance\n");
+ }
+ else
+ printf(" No Errors\n");
+ }
- return 0;
+ MPI_Finalize();
+
+ return 0;
}
diff --git a/test/mpi/perf/sendrecvl.c b/test/mpi/perf/sendrecvl.c
index f0d6843..1745eaf 100644
--- a/test/mpi/perf/sendrecvl.c
+++ b/test/mpi/perf/sendrecvl.c
@@ -14,11 +14,11 @@
#include <stdlib.h>
#define MAXTESTS 32
-#define ERROR_MARGIN 1.0 /* FIXME: This number is pretty much randomly chosen */
+#define ERROR_MARGIN 1.0 /* FIXME: This number is pretty much randomly chosen */
static int verbose = 0;
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int wsize, wrank, partner, len, maxlen, k, reps, repsleft;
double t1;
@@ -26,245 +26,240 @@ int main( int argc, char *argv[] )
char *rbuf, *sbuf;
double times[3][MAXTESTS];
- MPI_Init( &argc, &argv );
- if (getenv("MPITEST_VERBOSE")) verbose = 1;
+ MPI_Init(&argc, &argv);
+ if (getenv("MPITEST_VERBOSE"))
+ verbose = 1;
+
+ MPI_Comm_size(MPI_COMM_WORLD, &wsize);
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
- MPI_Comm_size( MPI_COMM_WORLD, &wsize );
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
-
if (wsize < 2) {
- fprintf( stderr, "This program requires at least 2 processes\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "This program requires at least 2 processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
/* Set partner based on whether rank is odd or even */
if (wrank & 0x1) {
- partner = wrank - 1;
+ partner = wrank - 1;
}
else if (wrank < wsize - 1) {
- partner = wrank + 1;
+ partner = wrank + 1;
}
- else
- /* Handle wsize odd */
- partner = MPI_PROC_NULL;
+ else
+ /* Handle wsize odd */
+ partner = MPI_PROC_NULL;
/* Allocate and initialize buffers */
- maxlen = 1024*1024;
- rbuf = (char *)malloc( maxlen );
- sbuf = (char *)malloc( maxlen );
+ maxlen = 1024 * 1024;
+ rbuf = (char *) malloc(maxlen);
+ sbuf = (char *) malloc(maxlen);
if (!rbuf || !sbuf) {
- fprintf( stderr, "Could not allocate %d byte buffers\n", maxlen );
- MPI_Abort( MPI_COMM_WORLD, 2 );
+ fprintf(stderr, "Could not allocate %d byte buffers\n", maxlen);
+ MPI_Abort(MPI_COMM_WORLD, 2);
}
- for (k=0; k<maxlen; k++) {
- rbuf[k] = 0;
- sbuf[k] = 0;
+ for (k = 0; k < maxlen; k++) {
+ rbuf[k] = 0;
+ sbuf[k] = 0;
}
-
- MPI_Barrier( MPI_COMM_WORLD );
+
+ MPI_Barrier(MPI_COMM_WORLD);
/* Test Irecv and send, head to head */
if (wrank == 0 && verbose) {
- printf( "Irecv-send\n" );
- printf( "len\ttime \trate\n" );
+ printf("Irecv-send\n");
+ printf("len\ttime \trate\n");
}
/* Send powers of 2 bytes */
len = 1;
- for (k=0; k<20; k++) {
- /* We use a simple linear form for the number of tests to
- reduce the impact of the granularity of the timer */
- reps = 50-k;
- repsleft = reps;
- /* Make sure that both processes are ready to start */
- MPI_Sendrecv( MPI_BOTTOM, 0, MPI_BYTE, partner, 0,
- MPI_BOTTOM, 0, MPI_BYTE, partner, 0, MPI_COMM_WORLD,
- MPI_STATUS_IGNORE );
- t1 = MPI_Wtime();
- while (repsleft--) {
- MPI_Irecv( rbuf, len, MPI_BYTE, partner, k, MPI_COMM_WORLD, &rreq );
- MPI_Send( sbuf, len, MPI_BYTE, partner, k, MPI_COMM_WORLD );
- MPI_Wait( &rreq, MPI_STATUS_IGNORE );
- }
- t1 = MPI_Wtime() - t1;
- times[0][k] = t1 / reps;
- if (wrank == 0) {
- t1 = t1 / reps;
- if (t1 > 0) {
- double rate;
- rate = (len / t1) / 1.e6;
- t1 = t1 * 1.e6;
- if (verbose)
- printf( "%d\t%g\t%g\n", len, t1, len/t1 );
- }
- else {
- t1 = t1 * 1.e6;
- if (verbose)
- printf( "%d\t%g\tINF\n", len, t1 );
- }
- if (verbose)
- fflush( stdout );
- }
+ for (k = 0; k < 20; k++) {
+ /* We use a simple linear form for the number of tests to
+ * reduce the impact of the granularity of the timer */
+ reps = 50 - k;
+ repsleft = reps;
+ /* Make sure that both processes are ready to start */
+ MPI_Sendrecv(MPI_BOTTOM, 0, MPI_BYTE, partner, 0,
+ MPI_BOTTOM, 0, MPI_BYTE, partner, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+ t1 = MPI_Wtime();
+ while (repsleft--) {
+ MPI_Irecv(rbuf, len, MPI_BYTE, partner, k, MPI_COMM_WORLD, &rreq);
+ MPI_Send(sbuf, len, MPI_BYTE, partner, k, MPI_COMM_WORLD);
+ MPI_Wait(&rreq, MPI_STATUS_IGNORE);
+ }
+ t1 = MPI_Wtime() - t1;
+ times[0][k] = t1 / reps;
+ if (wrank == 0) {
+ t1 = t1 / reps;
+ if (t1 > 0) {
+ double rate;
+ rate = (len / t1) / 1.e6;
+ t1 = t1 * 1.e6;
+ if (verbose)
+ printf("%d\t%g\t%g\n", len, t1, len / t1);
+ }
+ else {
+ t1 = t1 * 1.e6;
+ if (verbose)
+ printf("%d\t%g\tINF\n", len, t1);
+ }
+ if (verbose)
+ fflush(stdout);
+ }
- len *= 2;
+ len *= 2;
}
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
/* Test Sendrecv, head to head */
if (wrank == 0 && verbose) {
- printf( "Sendrecv\n" );
- printf( "len\ttime (usec)\trate (MB/s)\n" );
+ printf("Sendrecv\n");
+ printf("len\ttime (usec)\trate (MB/s)\n");
}
/* Send powers of 2 bytes */
len = 1;
- for (k=0; k<20; k++) {
- /* We use a simple linear form for the number of tests to
- reduce the impact of the granularity of the timer */
- reps = 50-k;
- repsleft = reps;
- /* Make sure that both processes are ready to start */
- MPI_Sendrecv( MPI_BOTTOM, 0, MPI_BYTE, partner, 0,
- MPI_BOTTOM, 0, MPI_BYTE, partner, 0, MPI_COMM_WORLD,
- MPI_STATUS_IGNORE );
- t1 = MPI_Wtime();
- while (repsleft--) {
- MPI_Sendrecv( sbuf, len, MPI_BYTE, partner, k,
- rbuf, len, MPI_BYTE, partner, k, MPI_COMM_WORLD,
- MPI_STATUS_IGNORE );
- }
- t1 = MPI_Wtime() - t1;
- times[1][k] = t1 / reps;
- if (wrank == 0) {
- t1 = t1 / reps;
- if (t1 > 0) {
- double rate;
- rate = (len / t1) / 1.e6;
- t1 = t1 * 1.e6;
- if (verbose)
- printf( "%d\t%g\t%g\n", len, t1, len/t1 );
- }
- else {
- t1 = t1 * 1.e6;
- if (verbose)
- printf( "%d\t%g\tINF\n", len, t1 );
- }
- if (verbose)
- fflush( stdout );
- }
+ for (k = 0; k < 20; k++) {
+ /* We use a simple linear form for the number of tests to
+ * reduce the impact of the granularity of the timer */
+ reps = 50 - k;
+ repsleft = reps;
+ /* Make sure that both processes are ready to start */
+ MPI_Sendrecv(MPI_BOTTOM, 0, MPI_BYTE, partner, 0,
+ MPI_BOTTOM, 0, MPI_BYTE, partner, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+ t1 = MPI_Wtime();
+ while (repsleft--) {
+ MPI_Sendrecv(sbuf, len, MPI_BYTE, partner, k,
+ rbuf, len, MPI_BYTE, partner, k, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+ }
+ t1 = MPI_Wtime() - t1;
+ times[1][k] = t1 / reps;
+ if (wrank == 0) {
+ t1 = t1 / reps;
+ if (t1 > 0) {
+ double rate;
+ rate = (len / t1) / 1.e6;
+ t1 = t1 * 1.e6;
+ if (verbose)
+ printf("%d\t%g\t%g\n", len, t1, len / t1);
+ }
+ else {
+ t1 = t1 * 1.e6;
+ if (verbose)
+ printf("%d\t%g\tINF\n", len, t1);
+ }
+ if (verbose)
+ fflush(stdout);
+ }
- len *= 2;
+ len *= 2;
}
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
/* Test Send/recv, ping-pong */
if (wrank == 0 && verbose) {
- printf( "Pingpong\n" );
- printf( "len\ttime (usec)\trate (MB/s)\n" );
+ printf("Pingpong\n");
+ printf("len\ttime (usec)\trate (MB/s)\n");
}
/* Send powers of 2 bytes */
len = 1;
- for (k=0; k<20; k++) {
- /* We use a simple linear form for the number of tests to
- reduce the impact of the granularity of the timer */
- reps = 50-k;
- repsleft = reps;
- /* Make sure that both processes are ready to start */
- MPI_Sendrecv( MPI_BOTTOM, 0, MPI_BYTE, partner, 0,
- MPI_BOTTOM, 0, MPI_BYTE, partner, 0, MPI_COMM_WORLD,
- MPI_STATUS_IGNORE );
- t1 = MPI_Wtime();
- while (repsleft--) {
- if (wrank & 0x1) {
- MPI_Send( sbuf, len, MPI_BYTE, partner, k, MPI_COMM_WORLD );
- MPI_Recv( rbuf, len, MPI_BYTE, partner, k, MPI_COMM_WORLD,
- MPI_STATUS_IGNORE );
- }
- else {
- MPI_Recv( rbuf, len, MPI_BYTE, partner, k, MPI_COMM_WORLD,
- MPI_STATUS_IGNORE );
- MPI_Send( sbuf, len, MPI_BYTE, partner, k, MPI_COMM_WORLD );
- }
- }
- t1 = MPI_Wtime() - t1;
- times[2][k] = t1 / reps;
- if (wrank == 0) {
- t1 = t1 / reps;
- if (t1 > 0) {
- double rate;
- rate = (len / t1) / 1.e6;
- t1 = t1 * 1.e6;
- if (verbose)
- printf( "%d\t%g\t%g\n", len, t1, len/t1 );
- }
- else {
- t1 = t1 * 1.e6;
- if (verbose)
- printf( "%d\t%g\tINF\n", len, t1 );
- }
- if (verbose)
- fflush( stdout );
- }
+ for (k = 0; k < 20; k++) {
+ /* We use a simple linear form for the number of tests to
+ * reduce the impact of the granularity of the timer */
+ reps = 50 - k;
+ repsleft = reps;
+ /* Make sure that both processes are ready to start */
+ MPI_Sendrecv(MPI_BOTTOM, 0, MPI_BYTE, partner, 0,
+ MPI_BOTTOM, 0, MPI_BYTE, partner, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+ t1 = MPI_Wtime();
+ while (repsleft--) {
+ if (wrank & 0x1) {
+ MPI_Send(sbuf, len, MPI_BYTE, partner, k, MPI_COMM_WORLD);
+ MPI_Recv(rbuf, len, MPI_BYTE, partner, k, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+ }
+ else {
+ MPI_Recv(rbuf, len, MPI_BYTE, partner, k, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+ MPI_Send(sbuf, len, MPI_BYTE, partner, k, MPI_COMM_WORLD);
+ }
+ }
+ t1 = MPI_Wtime() - t1;
+ times[2][k] = t1 / reps;
+ if (wrank == 0) {
+ t1 = t1 / reps;
+ if (t1 > 0) {
+ double rate;
+ rate = (len / t1) / 1.e6;
+ t1 = t1 * 1.e6;
+ if (verbose)
+ printf("%d\t%g\t%g\n", len, t1, len / t1);
+ }
+ else {
+ t1 = t1 * 1.e6;
+ if (verbose)
+ printf("%d\t%g\tINF\n", len, t1);
+ }
+ if (verbose)
+ fflush(stdout);
+ }
- len *= 2;
+ len *= 2;
}
-
-
+
+
/* At this point, we could optionally analyze the results and report
- success or failure based on some criteria, such as near monotone
- increases in bandwidth. This test was created because of a
- fall-off in performance noted in the ch3:sock device:channel */
+ * success or failure based on some criteria, such as near monotone
+ * increases in bandwidth. This test was created because of a
+ * fall-off in performance noted in the ch3:sock device:channel */
if (wrank == 0) {
- int nPerfErrors = 0;
- len = 1;
- for (k=0; k<20; k++) {
- double T0,T1,T2;
- T0 = times[0][k] * 1.e6;
- T1 = times[1][k] * 1.e6;
- T2 = times[2][k] * 1.e6;
- if (verbose)
- printf( "%d\t%12.2f\t%12.2f\t%12.2f\n", len, T0, T1, T2 );
- /* Lets look at long messages only */
- if (k > 10) {
- double T0Old, T1Old, T2Old;
- T0Old = times[0][k-1] * 1.0e6;
- T1Old = times[1][k-1] * 1.0e6;
- T2Old = times[2][k-1] * 1.0e6;
- if (T0 > (2+ERROR_MARGIN) * T0Old) {
- nPerfErrors++;
- if (verbose)
- printf( "Irecv-Send:\t%d\t%12.2f\t%12.2f\n", len, T0Old, T0 );
- }
- if (T1 > (2+ERROR_MARGIN) * T1Old) {
- nPerfErrors++;
- if (verbose)
- printf( "Sendrecv:\t%d\t%12.2f\t%12.2f\n", len, T1Old, T1 );
- }
- if (T2 > (2+ERROR_MARGIN) * T2Old) {
- nPerfErrors++;
- if (verbose)
- printf( "Pingpong:\t%d\t%12.2f\t%12.2f\n", len, T2Old, T2 );
- }
- }
- len *= 2;
- }
- if (nPerfErrors > 8) {
- /* Allow for 1-2 errors for eager-rendezvous shifting
- * point and cache effects. There should be a better way
- * of doing this. */
- printf( " Found %d performance errors\n", nPerfErrors );
- }
- else {
- printf( " No Errors\n" );
- }
- fflush( stdout );
+ int nPerfErrors = 0;
+ len = 1;
+ for (k = 0; k < 20; k++) {
+ double T0, T1, T2;
+ T0 = times[0][k] * 1.e6;
+ T1 = times[1][k] * 1.e6;
+ T2 = times[2][k] * 1.e6;
+ if (verbose)
+ printf("%d\t%12.2f\t%12.2f\t%12.2f\n", len, T0, T1, T2);
+ /* Lets look at long messages only */
+ if (k > 10) {
+ double T0Old, T1Old, T2Old;
+ T0Old = times[0][k - 1] * 1.0e6;
+ T1Old = times[1][k - 1] * 1.0e6;
+ T2Old = times[2][k - 1] * 1.0e6;
+ if (T0 > (2 + ERROR_MARGIN) * T0Old) {
+ nPerfErrors++;
+ if (verbose)
+ printf("Irecv-Send:\t%d\t%12.2f\t%12.2f\n", len, T0Old, T0);
+ }
+ if (T1 > (2 + ERROR_MARGIN) * T1Old) {
+ nPerfErrors++;
+ if (verbose)
+ printf("Sendrecv:\t%d\t%12.2f\t%12.2f\n", len, T1Old, T1);
+ }
+ if (T2 > (2 + ERROR_MARGIN) * T2Old) {
+ nPerfErrors++;
+ if (verbose)
+ printf("Pingpong:\t%d\t%12.2f\t%12.2f\n", len, T2Old, T2);
+ }
+ }
+ len *= 2;
+ }
+ if (nPerfErrors > 8) {
+ /* Allow for 1-2 errors for eager-rendezvous shifting
+ * point and cache effects. There should be a better way
+ * of doing this. */
+ printf(" Found %d performance errors\n", nPerfErrors);
+ }
+ else {
+ printf(" No Errors\n");
+ }
+ fflush(stdout);
}
- free( sbuf );
- free( rbuf );
+ free(sbuf);
+ free(rbuf);
MPI_Finalize();
diff --git a/test/mpi/perf/timer.c b/test/mpi/perf/timer.c
index 1a778c4..4a77d18 100644
--- a/test/mpi/perf/timer.c
+++ b/test/mpi/perf/timer.c
@@ -4,7 +4,7 @@
* See COPYRIGHT in top-level directory.
*/
-/*
+/*
* Check that the timer produces monotone nondecreasing times and that
* the Tick is reasonable
*/
@@ -17,51 +17,53 @@ static int verbose = 0;
#define MAX_TIMER_TEST 5000
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
double t1[MAX_TIMER_TEST], tick[MAX_TIMER_TEST], tickval;
double minDiff, maxDiff, diff;
int i, nZeros = 0;
int errs = 0;
- MTest_Init(&argc,&argv);
+ MTest_Init(&argc, &argv);
- for (i=0; i<MAX_TIMER_TEST; i++) {
- t1[i] = MPI_Wtime();
+ for (i = 0; i < MAX_TIMER_TEST; i++) {
+ t1[i] = MPI_Wtime();
}
- for (i=0; i<MAX_TIMER_TEST; i++) {
- tick[i] = MPI_Wtick();
+ for (i = 0; i < MAX_TIMER_TEST; i++) {
+ tick[i] = MPI_Wtick();
}
/* Look at the values */
/* Look at the tick */
tickval = MPI_Wtick();
- for (i=0; i<MAX_TIMER_TEST; i++) {
- if (tickval != tick[i]) {
- fprintf( stderr, "Nonconstant value for MPI_Wtick: %e != %e\n",
- tickval, tick[i] );
- errs ++;
- }
+ for (i = 0; i < MAX_TIMER_TEST; i++) {
+ if (tickval != tick[i]) {
+ fprintf(stderr, "Nonconstant value for MPI_Wtick: %e != %e\n", tickval, tick[i]);
+ errs++;
+ }
}
/* Look at the timer */
minDiff = 1.e20;
maxDiff = -1.0;
- nZeros = 0;
- for (i=1; i<MAX_TIMER_TEST; i++) {
- diff = t1[i] - t1[i-1];
- if (diff == 0.0) nZeros++;
- else if (diff < minDiff) minDiff = diff;
- if (diff > maxDiff) maxDiff = diff;
+ nZeros = 0;
+ for (i = 1; i < MAX_TIMER_TEST; i++) {
+ diff = t1[i] - t1[i - 1];
+ if (diff == 0.0)
+ nZeros++;
+ else if (diff < minDiff)
+ minDiff = diff;
+ if (diff > maxDiff)
+ maxDiff = diff;
}
/* Are the time diff values and tick values consistent */
if (verbose) {
- printf( "Tick = %e, timer range = [%e,%e]\n", tickval, minDiff,
- maxDiff );
- if (nZeros) printf( "Wtime difference was 0 %d times\n", nZeros );
- }
+ printf("Tick = %e, timer range = [%e,%e]\n", tickval, minDiff, maxDiff);
+ if (nZeros)
+ printf("Wtime difference was 0 %d times\n", nZeros);
+ }
MTest_Finalize(errs);
MPI_Finalize();
diff --git a/test/mpi/perf/transp-datatype.c b/test/mpi/perf/transp-datatype.c
index b7ebc27..430831b 100644
--- a/test/mpi/perf/transp-datatype.c
+++ b/test/mpi/perf/transp-datatype.c
@@ -21,11 +21,11 @@
#define SIZE 100
#define ITER 100
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
int i, j, k;
- static double a[SIZE][SIZE],b[SIZE][SIZE];
- double t1,t2,t,ts,tst;
+ static double a[SIZE][SIZE], b[SIZE][SIZE];
+ double t1, t2, t, ts, tst;
double temp;
int myrank, mysize, errs = 0;
MPI_Status status;
@@ -33,94 +33,92 @@ int main(int argc, char* argv[])
MPI_Datatype col, xpose;
- MTest_Init( &argc, &argv );
- MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
- MPI_Comm_size( MPI_COMM_WORLD, &mysize );
+ MTest_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
+ MPI_Comm_size(MPI_COMM_WORLD, &mysize);
if (mysize != 2) {
- fprintf( stderr, "This test must be run with 2 processes\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "This test must be run with 2 processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
MPI_Type_extent(MPI_DOUBLE, &sizeofreal);
-
+
MPI_Type_vector(SIZE, 1, SIZE, MPI_DOUBLE, &col);
MPI_Type_hvector(SIZE, 1, sizeofreal, col, &xpose);
MPI_Type_commit(&xpose);
/* Preset the arrays so that they're in memory */
- for (i=0; i<SIZE; i++)
- for (j=0; j<SIZE; j++) {
- a[i][j]=0;
- b[i][j]=0;
- }
- a[SIZE-1][0] = 1;
+ for (i = 0; i < SIZE; i++)
+ for (j = 0; j < SIZE; j++) {
+ a[i][j] = 0;
+ b[i][j] = 0;
+ }
+ a[SIZE - 1][0] = 1;
/* Time the transpose example */
MPI_Barrier(MPI_COMM_WORLD);
- t1=MPI_Wtime();
- for(i=0;i< ITER; i++)
- {
- if(myrank==0)
- MPI_Send(&a[0][0],SIZE*SIZE,MPI_DOUBLE,1,0,MPI_COMM_WORLD);
- else
- MPI_Recv(&b[0][0],1,xpose,0,0,MPI_COMM_WORLD,&status);
- }
- t2=MPI_Wtime();
- t=(t2-t1)/ITER;
+ t1 = MPI_Wtime();
+ for (i = 0; i < ITER; i++) {
+ if (myrank == 0)
+ MPI_Send(&a[0][0], SIZE * SIZE, MPI_DOUBLE, 1, 0, MPI_COMM_WORLD);
+ else
+ MPI_Recv(&b[0][0], 1, xpose, 0, 0, MPI_COMM_WORLD, &status);
+ }
+ t2 = MPI_Wtime();
+ t = (t2 - t1) / ITER;
/* Time sending the same amount of data, but without the transpose */
MPI_Barrier(MPI_COMM_WORLD);
- t1=MPI_Wtime();
- for(i=0; i< ITER; i++){
- if(myrank==0)
- {
- MPI_Send(&a[0][0],sizeof(a),MPI_BYTE,1,0,MPI_COMM_WORLD);
- }
- else {
- MPI_Recv(&b[0][0],sizeof(b),MPI_BYTE,0,0,MPI_COMM_WORLD,&status);
- }
+ t1 = MPI_Wtime();
+ for (i = 0; i < ITER; i++) {
+ if (myrank == 0) {
+ MPI_Send(&a[0][0], sizeof(a), MPI_BYTE, 1, 0, MPI_COMM_WORLD);
+ }
+ else {
+ MPI_Recv(&b[0][0], sizeof(b), MPI_BYTE, 0, 0, MPI_COMM_WORLD, &status);
+ }
}
- t2=MPI_Wtime();
- ts=(t2-t1)/ITER;
+ t2 = MPI_Wtime();
+ ts = (t2 - t1) / ITER;
/* Time sending the same amount of data, with the transpose done
- as a separate step */
+ * as a separate step */
MPI_Barrier(MPI_COMM_WORLD);
- t1=MPI_Wtime();
- for(k=0; k< ITER; k++){
- if(myrank==0)
- {
- MPI_Send(&a[0][0],sizeof(a),MPI_BYTE,1,0,MPI_COMM_WORLD);
- }
- else {
- MPI_Recv(&b[0][0],sizeof(b),MPI_BYTE,0,0,MPI_COMM_WORLD,&status);
- for(i=0;i<SIZE;i++)
- for(j=i;j<SIZE;j++) {
- temp=b[j][i];
- b[j][i]=b[i][j];
- b[i][j]=temp;
- }
- }
+ t1 = MPI_Wtime();
+ for (k = 0; k < ITER; k++) {
+ if (myrank == 0) {
+ MPI_Send(&a[0][0], sizeof(a), MPI_BYTE, 1, 0, MPI_COMM_WORLD);
+ }
+ else {
+ MPI_Recv(&b[0][0], sizeof(b), MPI_BYTE, 0, 0, MPI_COMM_WORLD, &status);
+ for (i = 0; i < SIZE; i++)
+ for (j = i; j < SIZE; j++) {
+ temp = b[j][i];
+ b[j][i] = b[i][j];
+ b[i][j] = temp;
+ }
+ }
}
- t2=MPI_Wtime();
- tst=(t2-t1)/ITER;
+ t2 = MPI_Wtime();
+ tst = (t2 - t1) / ITER;
/* Print out the results */
if (myrank == 1) {
- /* if t and tst are too different, then there is a performance
- problem in the handling of the datatypes */
-
- if (t > 2 * tst) {
- errs ++;
- fprintf( stderr, "Transpose time with datatypes is more than twice time without datatypes\n" );
- fprintf( stderr, "%f\t%f\t%f\n", t, ts, tst );
- }
+ /* if t and tst are too different, then there is a performance
+ * problem in the handling of the datatypes */
+
+ if (t > 2 * tst) {
+ errs++;
+ fprintf(stderr,
+ "Transpose time with datatypes is more than twice time without datatypes\n");
+ fprintf(stderr, "%f\t%f\t%f\n", t, ts, tst);
+ }
}
MPI_Type_free(&col);
MPI_Type_free(&xpose);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/perf/twovec.c b/test/mpi/perf/twovec.c
index 774693e..a9eba33 100644
--- a/test/mpi/perf/twovec.c
+++ b/test/mpi/perf/twovec.c
@@ -39,7 +39,7 @@ int main(int argc, char *argv[])
MPI_Init(&argc, &argv);
tmean = 0;
- size = 1;
+ size = 1;
for (i = -SKIP; i < NUM_SIZES; i++) {
nrows = ncols = size;
@@ -55,8 +55,8 @@ int main(int argc, char *argv[])
t[i] = MPI_Wtime() - ttmp;
if (t[i] < 100 * MPI_Wtick()) {
/* Time is too inaccurate to use. Set to zero.
- Consider increasing the LOOPS value to make this
- time large enough */
+ * Consider increasing the LOOPS value to make this
+ * time large enough */
t[i] = 0;
}
tmean += t[i];
@@ -73,31 +73,32 @@ int main(int argc, char *argv[])
tmean /= NUM_SIZES;
/* Now, analyze the times to see that they do not grow too fast
- as a function of size. As that is a vague criteria, we do the
- following as a simple test:
- Compute the mean of the first half and the second half of the
- data
- Compare the two means
- If the mean of the second half is more than FRACTION times the
- mean of the first half, then the time may be growing too fast.
+ * as a function of size. As that is a vague criteria, we do the
+ * following as a simple test:
+ * Compute the mean of the first half and the second half of the
+ * data
+ * Compare the two means
+ * If the mean of the second half is more than FRACTION times the
+ * mean of the first half, then the time may be growing too fast.
*/
tMeanLower = tMeanHigher = 0;
- for (i=0; i<NUM_SIZES/2; i++)
+ for (i = 0; i < NUM_SIZES / 2; i++)
tMeanLower += t[i];
- tMeanLower /= (NUM_SIZES/2);
- for (i=NUM_SIZES/2; i<NUM_SIZES; i++)
+ tMeanLower /= (NUM_SIZES / 2);
+ for (i = NUM_SIZES / 2; i < NUM_SIZES; i++)
tMeanHigher += t[i];
- tMeanHigher /= (NUM_SIZES - NUM_SIZES/2);
+ tMeanHigher /= (NUM_SIZES - NUM_SIZES / 2);
/* A large value (even 1 or greater) is a good choice for
- FRACTION here - the goal is to detect significant growth in
- execution time as the size increases, and there is no MPI
- standard requirement here to meet.
-
- If the times were too small, then the test also passes - the
- goal is to find implementation problems that lead to excessive
- time in these routines.
- */
- if (tMeanLower > 0 && tMeanHigher > (1 + FRACTION) * tMeanLower) errs++;
+ * FRACTION here - the goal is to detect significant growth in
+ * execution time as the size increases, and there is no MPI
+ * standard requirement here to meet.
+ *
+ * If the times were too small, then the test also passes - the
+ * goal is to find implementation problems that lead to excessive
+ * time in these routines.
+ */
+ if (tMeanLower > 0 && tMeanHigher > (1 + FRACTION) * tMeanLower)
+ errs++;
if (errs) {
fprintf(stderr, "too much difference in performance: ");
diff --git a/test/mpi/pt2pt/anyall.c b/test/mpi/pt2pt/anyall.c
index b54b13a..405c794 100644
--- a/test/mpi/pt2pt/anyall.c
+++ b/test/mpi/pt2pt/anyall.c
@@ -14,74 +14,73 @@
static char MTEST_Descrip[] = "One implementation delivered incorrect data when an MPI recieve uses both ANY_SOURCE and ANY_TAG";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
- int wrank, wsize, master, worker, i, j, idx, count;
- int errs = 0;
+ int wrank, wsize, master, worker, i, j, idx, count;
+ int errs = 0;
MPI_Request r[MAX_MSGS];
- int buf[MAX_MSGS][MAX_MSGS];
- MPI_Comm comm;
- MPI_Status status;
+ int buf[MAX_MSGS][MAX_MSGS];
+ MPI_Comm comm;
+ MPI_Status status;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
- MPI_Comm_size( MPI_COMM_WORLD, &wsize );
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
+ MPI_Comm_size(MPI_COMM_WORLD, &wsize);
comm = MPI_COMM_WORLD;
master = 0;
worker = 1;
- /* The test takes advantage of the ordering rules for messages*/
+ /* The test takes advantage of the ordering rules for messages */
if (wrank == master) {
- /* Initialize the send buffer */
- for (i=0; i<MAX_MSGS; i++) {
- for (j=0; j<MAX_MSGS; j++) {
- buf[i][j] = i*MAX_MSGS + j;
- }
- }
- MPI_Barrier( MPI_COMM_WORLD );
- for (i=0; i<MAX_MSGS; i++) {
- MPI_Send( buf[i], MAX_MSGS-i, MPI_INT, worker, 3, comm );
- }
+ /* Initialize the send buffer */
+ for (i = 0; i < MAX_MSGS; i++) {
+ for (j = 0; j < MAX_MSGS; j++) {
+ buf[i][j] = i * MAX_MSGS + j;
+ }
+ }
+ MPI_Barrier(MPI_COMM_WORLD);
+ for (i = 0; i < MAX_MSGS; i++) {
+ MPI_Send(buf[i], MAX_MSGS - i, MPI_INT, worker, 3, comm);
+ }
}
else if (wrank == worker) {
- /* Initialize the recv buffer */
- for (i=0; i<MAX_MSGS; i++) {
- for (j=0; j<MAX_MSGS; j++) {
- buf[i][j] = -1;
- }
- }
- for (i=0; i<MAX_MSGS; i++) {
- MPI_Irecv( buf[i], MAX_MSGS-i, MPI_INT, MPI_ANY_SOURCE,
- MPI_ANY_TAG, comm, &r[i] );
- }
- MPI_Barrier( MPI_COMM_WORLD );
- for (i=0; i<MAX_MSGS; i++) {
- MPI_Waitany( MAX_MSGS, r, &idx, &status );
- /* Message idx should have length MAX_MSGS-idx */
- MPI_Get_count( &status, MPI_INT, &count );
- if (count != MAX_MSGS-idx) {
- errs++;
- }
- else {
- /* Check for the correct answers */
- for (j=0; j < MAX_MSGS-idx; j++) {
- if (buf[idx][j] != idx * MAX_MSGS + j) {
- errs ++;
- printf( "Message %d [%d] is %d, should be %d\n",
- idx, j, buf[idx][j], idx * MAX_MSGS + j );
- }
- }
- }
- }
+ /* Initialize the recv buffer */
+ for (i = 0; i < MAX_MSGS; i++) {
+ for (j = 0; j < MAX_MSGS; j++) {
+ buf[i][j] = -1;
+ }
+ }
+ for (i = 0; i < MAX_MSGS; i++) {
+ MPI_Irecv(buf[i], MAX_MSGS - i, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, comm, &r[i]);
+ }
+ MPI_Barrier(MPI_COMM_WORLD);
+ for (i = 0; i < MAX_MSGS; i++) {
+ MPI_Waitany(MAX_MSGS, r, &idx, &status);
+ /* Message idx should have length MAX_MSGS-idx */
+ MPI_Get_count(&status, MPI_INT, &count);
+ if (count != MAX_MSGS - idx) {
+ errs++;
+ }
+ else {
+ /* Check for the correct answers */
+ for (j = 0; j < MAX_MSGS - idx; j++) {
+ if (buf[idx][j] != idx * MAX_MSGS + j) {
+ errs++;
+ printf("Message %d [%d] is %d, should be %d\n",
+ idx, j, buf[idx][j], idx * MAX_MSGS + j);
+ }
+ }
+ }
+ }
}
else {
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
}
-
- MTest_Finalize( errs );
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
diff --git a/test/mpi/pt2pt/big_count_status.c b/test/mpi/pt2pt/big_count_status.c
index 54410ed..2a9c5e2 100644
--- a/test/mpi/pt2pt/big_count_status.c
+++ b/test/mpi/pt2pt/big_count_status.c
@@ -24,7 +24,7 @@ int test_count(MPI_Count count)
MPI_Test_cancelled(&stat, &cancelled2);
if (bcount != bcount2) {
fprintf(stderr, "Count Error: expected %llx, got %llx\n",
- (long long int)bcount, (long long int)bcount2);
+ (long long int) bcount, (long long int) bcount2);
nerrs++;
}
if (cancelled != cancelled2) {
diff --git a/test/mpi/pt2pt/bottom.c b/test/mpi/pt2pt/bottom.c
index 3c085fd..ef8ae2f 100644
--- a/test/mpi/pt2pt/bottom.c
+++ b/test/mpi/pt2pt/bottom.c
@@ -12,69 +12,69 @@
static char MTEST_Descrip[] = "Use of MPI_BOTTOM in communication";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int rank, size, source, dest, len, ii;
- MPI_Comm comm;
- MPI_Status status;
- MPI_Datatype newtype, oldtype;
- MPI_Aint disp;
+ MPI_Comm comm;
+ MPI_Status status;
+ MPI_Datatype newtype, oldtype;
+ MPI_Aint disp;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Get_address( &ii, &disp );
+ MPI_Get_address(&ii, &disp);
- len = 1;
+ len = 1;
oldtype = MPI_INT;
- MPI_Type_create_struct( 1, &len, &disp, &oldtype, &newtype );
- MPI_Type_commit( &newtype );
+ MPI_Type_create_struct(1, &len, &disp, &oldtype, &newtype);
+ MPI_Type_commit(&newtype);
comm = MPI_COMM_WORLD;
- MPI_Comm_size( comm, &size );
- MPI_Comm_rank( comm, &rank );
+ MPI_Comm_size(comm, &size);
+ MPI_Comm_rank(comm, &rank);
if (size < 2) {
- errs++;
- fprintf( stderr, "This test requires at least two processes\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ errs++;
+ fprintf(stderr, "This test requires at least two processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
source = 0;
dest = 1;
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN);
if (rank == source) {
- ii = 2;
- err = MPI_Send( MPI_BOTTOM, 1, newtype, dest, 0, comm );
- if (err) {
- errs++;
- MTestPrintError( err );
- printf( "MPI_Send did not return MPI_SUCCESS\n" );
- }
+ ii = 2;
+ err = MPI_Send(MPI_BOTTOM, 1, newtype, dest, 0, comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ printf("MPI_Send did not return MPI_SUCCESS\n");
+ }
}
else if (rank == dest) {
- ii = -1;
- err = MPI_Recv( MPI_BOTTOM, 1, newtype, source, 0, comm, &status );
- if (err) {
- MTestPrintError( err );
- errs++;
- printf( "MPI_Recv did not return MPI_SUCCESS\n" );
- }
- if (ii != 2) {
- errs++;
- printf( "Received %d but expected %d\n", ii, 2 );
- }
+ ii = -1;
+ err = MPI_Recv(MPI_BOTTOM, 1, newtype, source, 0, comm, &status);
+ if (err) {
+ MTestPrintError(err);
+ errs++;
+ printf("MPI_Recv did not return MPI_SUCCESS\n");
+ }
+ if (ii != 2) {
+ errs++;
+ printf("Received %d but expected %d\n", ii, 2);
+ }
}
- MPI_Comm_set_errhandler( comm, MPI_ERRORS_ARE_FATAL );
+ MPI_Comm_set_errhandler(comm, MPI_ERRORS_ARE_FATAL);
- MPI_Type_free( &newtype );
+ MPI_Type_free(&newtype);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/pt2pt/bsend1.c b/test/mpi/pt2pt/bsend1.c
index 8ef0062..e813459 100644
--- a/test/mpi/pt2pt/bsend1.c
+++ b/test/mpi/pt2pt/bsend1.c
@@ -12,12 +12,12 @@
#include <string.h>
#endif
-/*
+/*
* This is a simple program that tests bsend. It may be run as a single
* process to simplify debugging; in addition, bsend allows send-to-self
* programs.
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Comm comm = MPI_COMM_WORLD;
int dest = 0, src = 0, tag = 1;
@@ -30,55 +30,56 @@ int main( int argc, char *argv[] )
int errs = 0, rank;
int bufsize, bsize;
- MTest_Init( &argc, &argv );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+ MTest_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
/* According to the standard, we must use the PACK_SIZE length of each
- message in the computation of the message buffer size */
- MPI_Pack_size( 7, MPI_CHAR, comm, &s1 );
- MPI_Pack_size( 2, MPI_DOUBLE, comm, &s2 );
- MPI_Pack_size( 17, MPI_CHAR, comm, &s3 );
+ * message in the computation of the message buffer size */
+ MPI_Pack_size(7, MPI_CHAR, comm, &s1);
+ MPI_Pack_size(2, MPI_DOUBLE, comm, &s2);
+ MPI_Pack_size(17, MPI_CHAR, comm, &s3);
bufsize = 3 * MPI_BSEND_OVERHEAD + s1 + s2 + s3;
- buf = (char *)malloc( bufsize );
- MPI_Buffer_attach( buf, bufsize );
+ buf = (char *) malloc(bufsize);
+ MPI_Buffer_attach(buf, bufsize);
- strncpy( msg1, "012345", 7 );
- strncpy( msg3, "0123401234012341", 17 );
- msg2[0] = 1.23; msg2[1] = 3.21;
+ strncpy(msg1, "012345", 7);
+ strncpy(msg3, "0123401234012341", 17);
+ msg2[0] = 1.23;
+ msg2[1] = 3.21;
if (rank == src) {
- /* These message sizes are chosen to expose any alignment problems */
- MPI_Bsend( msg1, 7, MPI_CHAR, dest, tag, comm );
- MPI_Bsend( msg2, 2, MPI_DOUBLE, dest, tag, comm );
- MPI_Bsend( msg3, 17, MPI_CHAR, dest, tag, comm );
+ /* These message sizes are chosen to expose any alignment problems */
+ MPI_Bsend(msg1, 7, MPI_CHAR, dest, tag, comm);
+ MPI_Bsend(msg2, 2, MPI_DOUBLE, dest, tag, comm);
+ MPI_Bsend(msg3, 17, MPI_CHAR, dest, tag, comm);
}
if (rank == dest) {
- MPI_Recv( rmsg1, 7, MPI_CHAR, src, tag, comm, MPI_STATUS_IGNORE );
- MPI_Recv( rmsg2, 10, MPI_DOUBLE, src, tag, comm, MPI_STATUS_IGNORE );
- MPI_Recv( rmsg3, 17, MPI_CHAR, src, tag, comm, MPI_STATUS_IGNORE );
+ MPI_Recv(rmsg1, 7, MPI_CHAR, src, tag, comm, MPI_STATUS_IGNORE);
+ MPI_Recv(rmsg2, 10, MPI_DOUBLE, src, tag, comm, MPI_STATUS_IGNORE);
+ MPI_Recv(rmsg3, 17, MPI_CHAR, src, tag, comm, MPI_STATUS_IGNORE);
- if (strcmp( rmsg1, msg1 ) != 0) {
- errs++;
- fprintf( stderr, "message 1 (%s) should be %s\n", rmsg1, msg1 );
- }
- if (rmsg2[0] != msg2[0] || rmsg2[1] != msg2[1]) {
- errs++;
- fprintf( stderr,
- "message 2 incorrect, values are (%f,%f) but should be (%f,%f)\n",
- rmsg2[0], rmsg2[1], msg2[0], msg2[1] );
- }
- if (strcmp( rmsg3, msg3 ) != 0) {
- errs++;
- fprintf( stderr, "message 3 (%s) should be %s\n", rmsg3, msg3 );
- }
+ if (strcmp(rmsg1, msg1) != 0) {
+ errs++;
+ fprintf(stderr, "message 1 (%s) should be %s\n", rmsg1, msg1);
+ }
+ if (rmsg2[0] != msg2[0] || rmsg2[1] != msg2[1]) {
+ errs++;
+ fprintf(stderr,
+ "message 2 incorrect, values are (%f,%f) but should be (%f,%f)\n",
+ rmsg2[0], rmsg2[1], msg2[0], msg2[1]);
+ }
+ if (strcmp(rmsg3, msg3) != 0) {
+ errs++;
+ fprintf(stderr, "message 3 (%s) should be %s\n", rmsg3, msg3);
+ }
}
/* We can't guarantee that messages arrive until the detach */
- MPI_Buffer_detach( &bbuf, &bsize );
+ MPI_Buffer_detach(&bbuf, &bsize);
+
+ MTest_Finalize(errs);
- MTest_Finalize( errs );
-
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/pt2pt/bsend2.c b/test/mpi/pt2pt/bsend2.c
index 4f6ad93..eb0aa4e 100644
--- a/test/mpi/pt2pt/bsend2.c
+++ b/test/mpi/pt2pt/bsend2.c
@@ -8,54 +8,53 @@
#include "mpitest.h"
#define BUFSIZE 2000
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Status status;
int a[10], b[10];
int buf[BUFSIZE], *bptr, bl, i, j, rank, size;
int errs = 0;
- MTest_Init( 0, 0 );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
- MPI_Buffer_attach( buf, BUFSIZE );
-
- for (j=0; j<10; j++) {
- for (i=0; i<10; i++) {
- a[i] = (rank + 10 * j) * size + i;
- }
- MPI_Bsend( a, 10, MPI_INT, 0, 27+j, MPI_COMM_WORLD );
+ MTest_Init(0, 0);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ MPI_Buffer_attach(buf, BUFSIZE);
+
+ for (j = 0; j < 10; j++) {
+ for (i = 0; i < 10; i++) {
+ a[i] = (rank + 10 * j) * size + i;
+ }
+ MPI_Bsend(a, 10, MPI_INT, 0, 27 + j, MPI_COMM_WORLD);
}
if (rank == 0) {
- for (i=0; i<size; i++) {
- for (j=0; j<10; j++) {
- int k;
- status.MPI_TAG = -10;
- status.MPI_SOURCE = -20;
- MPI_Recv( b, 10, MPI_INT, i, 27+j, MPI_COMM_WORLD, &status );
-
- if (status.MPI_TAG != 27+j) {
- errs ++;
- printf( "Wrong tag = %d\n", status.MPI_TAG );
- }
- if (status.MPI_SOURCE != i) {
- errs++;
- printf( "Wrong source = %d\n", status.MPI_SOURCE );
- }
- for (k=0; k<10; k++) {
- if (b[k] != (i + 10 * j) * size + k) {
- errs++;
- printf( "received b[%d] = %d from %d tag %d\n",
- k, b[k], i, 27+j );
- }
- }
- }
- }
+ for (i = 0; i < size; i++) {
+ for (j = 0; j < 10; j++) {
+ int k;
+ status.MPI_TAG = -10;
+ status.MPI_SOURCE = -20;
+ MPI_Recv(b, 10, MPI_INT, i, 27 + j, MPI_COMM_WORLD, &status);
+
+ if (status.MPI_TAG != 27 + j) {
+ errs++;
+ printf("Wrong tag = %d\n", status.MPI_TAG);
+ }
+ if (status.MPI_SOURCE != i) {
+ errs++;
+ printf("Wrong source = %d\n", status.MPI_SOURCE);
+ }
+ for (k = 0; k < 10; k++) {
+ if (b[k] != (i + 10 * j) * size + k) {
+ errs++;
+ printf("received b[%d] = %d from %d tag %d\n", k, b[k], i, 27 + j);
+ }
+ }
+ }
+ }
}
- MPI_Buffer_detach( &bptr, &bl );
-
- MTest_Finalize( errs );
+ MPI_Buffer_detach(&bptr, &bl);
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/pt2pt/bsend3.c b/test/mpi/pt2pt/bsend3.c
index 975b686..9415aeb 100644
--- a/test/mpi/pt2pt/bsend3.c
+++ b/test/mpi/pt2pt/bsend3.c
@@ -8,7 +8,7 @@
#include "mpitest.h"
#define BUFSIZE 2000
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Status status;
MPI_Request request;
@@ -16,50 +16,49 @@ int main( int argc, char *argv[] )
int buf[BUFSIZE], *bptr, bl, i, j, rank, size;
int errs = 0;
- MTest_Init( 0, 0 );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
- MPI_Buffer_attach( buf, BUFSIZE );
+ MTest_Init(0, 0);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ MPI_Buffer_attach(buf, BUFSIZE);
- for (j=0; j<10; j++) {
- MPI_Bsend_init( a, 10, MPI_INT, 0, 27+j, MPI_COMM_WORLD, &request );
- for (i=0; i<10; i++) {
- a[i] = (rank + 10 * j) * size + i;
- }
- MPI_Start( &request );
- MPI_Wait( &request, &status );
- MPI_Request_free( &request );
+ for (j = 0; j < 10; j++) {
+ MPI_Bsend_init(a, 10, MPI_INT, 0, 27 + j, MPI_COMM_WORLD, &request);
+ for (i = 0; i < 10; i++) {
+ a[i] = (rank + 10 * j) * size + i;
+ }
+ MPI_Start(&request);
+ MPI_Wait(&request, &status);
+ MPI_Request_free(&request);
}
if (rank == 0) {
- for (i=0; i<size; i++) {
- for (j=0; j<10; j++) {
- int k;
- status.MPI_TAG = -10;
- status.MPI_SOURCE = -20;
- MPI_Recv( b, 10, MPI_INT, i, 27+j, MPI_COMM_WORLD, &status );
-
- if (status.MPI_TAG != 27+j) {
- errs++;
- printf( "Wrong tag = %d\n", status.MPI_TAG );
- }
- if (status.MPI_SOURCE != i) {
- errs++;
- printf( "Wrong source = %d\n", status.MPI_SOURCE );
- }
- for (k=0; k<10; k++) {
- if (b[k] != (i + 10 * j) * size + k) {
- errs++;
- printf( "received b[%d] = %d from %d tag %d\n",
- k, b[k], i, 27+j );
- }
- }
- }
- }
+ for (i = 0; i < size; i++) {
+ for (j = 0; j < 10; j++) {
+ int k;
+ status.MPI_TAG = -10;
+ status.MPI_SOURCE = -20;
+ MPI_Recv(b, 10, MPI_INT, i, 27 + j, MPI_COMM_WORLD, &status);
+
+ if (status.MPI_TAG != 27 + j) {
+ errs++;
+ printf("Wrong tag = %d\n", status.MPI_TAG);
+ }
+ if (status.MPI_SOURCE != i) {
+ errs++;
+ printf("Wrong source = %d\n", status.MPI_SOURCE);
+ }
+ for (k = 0; k < 10; k++) {
+ if (b[k] != (i + 10 * j) * size + k) {
+ errs++;
+ printf("received b[%d] = %d from %d tag %d\n", k, b[k], i, 27 + j);
+ }
+ }
+ }
+ }
}
- MPI_Buffer_detach( &bptr, &bl );
-
- MTest_Finalize( errs );
+ MPI_Buffer_detach(&bptr, &bl);
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/pt2pt/bsend4.c b/test/mpi/pt2pt/bsend4.c
index c1ced9c..05d5611 100644
--- a/test/mpi/pt2pt/bsend4.c
+++ b/test/mpi/pt2pt/bsend4.c
@@ -5,58 +5,57 @@
*/
#include <stdio.h>
#include "mpi.h"
-#include "mpitest.h"
+#include "mpitest.h"
#define BUFSIZE 2000
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Status status;
MPI_Request request;
int a[10], b[10];
- int buf[BUFSIZE], *bptr, bl, i, j, rank, size, errs=0;
+ int buf[BUFSIZE], *bptr, bl, i, j, rank, size, errs = 0;
- MTest_Init( 0, 0 );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
- MPI_Buffer_attach( buf, BUFSIZE );
+ MTest_Init(0, 0);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ MPI_Buffer_attach(buf, BUFSIZE);
- for (j=0; j<10; j++) {
- for (i=0; i<10; i++) {
- a[i] = (rank + 10 * j) * size + i;
- }
- MPI_Ibsend( a, 10, MPI_INT, 0, 27+j, MPI_COMM_WORLD, &request );
- MPI_Wait( &request, &status );
+ for (j = 0; j < 10; j++) {
+ for (i = 0; i < 10; i++) {
+ a[i] = (rank + 10 * j) * size + i;
+ }
+ MPI_Ibsend(a, 10, MPI_INT, 0, 27 + j, MPI_COMM_WORLD, &request);
+ MPI_Wait(&request, &status);
}
if (rank == 0) {
- for (i=0; i<size; i++) {
- for (j=0; j<10; j++) {
- int k;
- status.MPI_TAG = -10;
- status.MPI_SOURCE = -20;
- MPI_Recv( b, 10, MPI_INT, i, 27+j, MPI_COMM_WORLD, &status );
-
- if (status.MPI_TAG != 27+j) {
- errs++;
- printf( "Wrong tag = %d\n", status.MPI_TAG );
- }
- if (status.MPI_SOURCE != i) {
- errs++;
- printf( "Wrong source = %d\n", status.MPI_SOURCE );
- }
- for (k=0; k<10; k++) {
- if (b[k] != (i + 10 * j) * size + k) {
- errs ++;
- printf( "received b[%d] = %d from %d tag %d\n",
- k, b[k], i, 27+j );
- }
- }
- }
- }
+ for (i = 0; i < size; i++) {
+ for (j = 0; j < 10; j++) {
+ int k;
+ status.MPI_TAG = -10;
+ status.MPI_SOURCE = -20;
+ MPI_Recv(b, 10, MPI_INT, i, 27 + j, MPI_COMM_WORLD, &status);
+
+ if (status.MPI_TAG != 27 + j) {
+ errs++;
+ printf("Wrong tag = %d\n", status.MPI_TAG);
+ }
+ if (status.MPI_SOURCE != i) {
+ errs++;
+ printf("Wrong source = %d\n", status.MPI_SOURCE);
+ }
+ for (k = 0; k < 10; k++) {
+ if (b[k] != (i + 10 * j) * size + k) {
+ errs++;
+ printf("received b[%d] = %d from %d tag %d\n", k, b[k], i, 27 + j);
+ }
+ }
+ }
+ }
}
- MPI_Buffer_detach( &bptr, &bl );
+ MPI_Buffer_detach(&bptr, &bl);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/pt2pt/bsend5.c b/test/mpi/pt2pt/bsend5.c
index 767a586..4462362 100644
--- a/test/mpi/pt2pt/bsend5.c
+++ b/test/mpi/pt2pt/bsend5.c
@@ -5,65 +5,64 @@
*/
#include <stdio.h>
#include "mpi.h"
-#include "mpitest.h"
+#include "mpitest.h"
#define BUFSIZE 2000
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Status status;
- MPI_Comm comm,scomm;
+ MPI_Comm comm, scomm;
int a[10], b[10];
- int buf[BUFSIZE], *bptr, bl, i, j, rank, size, color, errs=0;
+ int buf[BUFSIZE], *bptr, bl, i, j, rank, size, color, errs = 0;
- MTest_Init( 0, 0 );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+ MTest_Init(0, 0);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
color = rank % 2;
- MPI_Comm_split( MPI_COMM_WORLD, color, rank, &scomm );
- MPI_Intercomm_create( scomm, 0, MPI_COMM_WORLD, 1-color, 52, &comm);
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_remote_size( comm, &size );
- MPI_Buffer_attach( buf, BUFSIZE );
-
- for (j=0; j<10; j++) {
- for (i=0; i<10; i++) {
- a[i] = (rank + 10 * j) * size + i;
- }
- MPI_Bsend( a, 10, MPI_INT, 0, 27+j, comm );
+ MPI_Comm_split(MPI_COMM_WORLD, color, rank, &scomm);
+ MPI_Intercomm_create(scomm, 0, MPI_COMM_WORLD, 1 - color, 52, &comm);
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_remote_size(comm, &size);
+ MPI_Buffer_attach(buf, BUFSIZE);
+
+ for (j = 0; j < 10; j++) {
+ for (i = 0; i < 10; i++) {
+ a[i] = (rank + 10 * j) * size + i;
+ }
+ MPI_Bsend(a, 10, MPI_INT, 0, 27 + j, comm);
}
if (rank == 0) {
- for (i=0; i<size; i++) {
- for (j=0; j<10; j++) {
- int k;
- status.MPI_TAG = -10;
- status.MPI_SOURCE = -20;
- MPI_Recv( b, 10, MPI_INT, i, 27+j, comm, &status );
-
- if (status.MPI_TAG != 27+j) {
- errs++;
- printf( "Wrong tag = %d\n", status.MPI_TAG );
- }
- if (status.MPI_SOURCE != i) {
- errs++;
- printf( "Wrong source = %d\n", status.MPI_SOURCE );
- }
- for (k=0; k<10; k++) {
- if (b[k] != (i + 10 * j) * size + k) {
- errs++;
- printf( "received b[%d] = %d from %d tag %d\n",
- k, b[k], i, 27+j );
- }
- }
- }
- }
+ for (i = 0; i < size; i++) {
+ for (j = 0; j < 10; j++) {
+ int k;
+ status.MPI_TAG = -10;
+ status.MPI_SOURCE = -20;
+ MPI_Recv(b, 10, MPI_INT, i, 27 + j, comm, &status);
+
+ if (status.MPI_TAG != 27 + j) {
+ errs++;
+ printf("Wrong tag = %d\n", status.MPI_TAG);
+ }
+ if (status.MPI_SOURCE != i) {
+ errs++;
+ printf("Wrong source = %d\n", status.MPI_SOURCE);
+ }
+ for (k = 0; k < 10; k++) {
+ if (b[k] != (i + 10 * j) * size + k) {
+ errs++;
+ printf("received b[%d] = %d from %d tag %d\n", k, b[k], i, 27 + j);
+ }
+ }
+ }
+ }
}
- MPI_Buffer_detach( &bptr, &bl );
+ MPI_Buffer_detach(&bptr, &bl);
MPI_Comm_free(&scomm);
MPI_Comm_free(&comm);
- MTest_Finalize( errs );
-
+ MTest_Finalize(errs);
+
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/pt2pt/bsendalign.c b/test/mpi/pt2pt/bsendalign.c
index 9b900e3..ec358e6 100644
--- a/test/mpi/pt2pt/bsendalign.c
+++ b/test/mpi/pt2pt/bsendalign.c
@@ -10,62 +10,64 @@
/* Test bsend with a buffer with arbitray alignment */
#define BUFSIZE 2000*4
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Status status;
int a[10], b[10];
int align;
- char buf[BUFSIZE+8], *bptr;
+ char buf[BUFSIZE + 8], *bptr;
int bl, i, j, rank, size;
int errs = 0;
- MTest_Init( 0, 0 );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ MTest_Init(0, 0);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
for (align = 0; align < 7; align++) {
- MPI_Buffer_attach( buf+align, BUFSIZE);
-
- for (j=0; j<10; j++) {
- for (i=0; i<10; i++) {
- a[i] = (rank + 10 * j) * size + i;
- }
- MPI_Bsend( a, 10, MPI_INT, 0, 27+j, MPI_COMM_WORLD );
- }
- if (rank == 0) {
-
- for (i=0; i<size; i++) {
- for (j=0; j<10; j++) {
- int k;
- status.MPI_TAG = -10;
- status.MPI_SOURCE = -20;
- MPI_Recv( b, 10, MPI_INT, i, 27+j, MPI_COMM_WORLD, &status );
-
- if (status.MPI_TAG != 27+j) {
- errs ++;
- printf( "Wrong tag = %d\n", status.MPI_TAG );
- }
- if (status.MPI_SOURCE != i) {
- errs++;
- printf( "Wrong source = %d\n", status.MPI_SOURCE );
- }
- for (k=0; k<10; k++) {
- if (b[k] != (i + 10 * j) * size + k) {
- errs++;
- printf( "(Align=%d) received b[%d] = %d (expected %d) from %d tag %d\n",
- align, k, b[k], (i+10*j), i, 27+j );
- }
- }
- }
- }
- }
- MPI_Buffer_detach( &bptr, &bl );
- if (bptr != buf+align) {
- errs++;
- printf( "Did not recieve the same buffer on detach that was provided on init (%p vs %p)\n", bptr, buf );
- }
+ MPI_Buffer_attach(buf + align, BUFSIZE);
+
+ for (j = 0; j < 10; j++) {
+ for (i = 0; i < 10; i++) {
+ a[i] = (rank + 10 * j) * size + i;
+ }
+ MPI_Bsend(a, 10, MPI_INT, 0, 27 + j, MPI_COMM_WORLD);
+ }
+ if (rank == 0) {
+
+ for (i = 0; i < size; i++) {
+ for (j = 0; j < 10; j++) {
+ int k;
+ status.MPI_TAG = -10;
+ status.MPI_SOURCE = -20;
+ MPI_Recv(b, 10, MPI_INT, i, 27 + j, MPI_COMM_WORLD, &status);
+
+ if (status.MPI_TAG != 27 + j) {
+ errs++;
+ printf("Wrong tag = %d\n", status.MPI_TAG);
+ }
+ if (status.MPI_SOURCE != i) {
+ errs++;
+ printf("Wrong source = %d\n", status.MPI_SOURCE);
+ }
+ for (k = 0; k < 10; k++) {
+ if (b[k] != (i + 10 * j) * size + k) {
+ errs++;
+ printf("(Align=%d) received b[%d] = %d (expected %d) from %d tag %d\n",
+ align, k, b[k], (i + 10 * j), i, 27 + j);
+ }
+ }
+ }
+ }
+ }
+ MPI_Buffer_detach(&bptr, &bl);
+ if (bptr != buf + align) {
+ errs++;
+ printf
+ ("Did not recieve the same buffer on detach that was provided on init (%p vs %p)\n",
+ bptr, buf);
+ }
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/pt2pt/bsendfrag.c b/test/mpi/pt2pt/bsendfrag.c
index 8f22959..768e496 100644
--- a/test/mpi/pt2pt/bsendfrag.c
+++ b/test/mpi/pt2pt/bsendfrag.c
@@ -18,12 +18,12 @@ different messages are received in different orders";
* Notes on the test.
*
* To ensure that messages remain in the bsend buffer until received,
- * messages are sent with size MSG_SIZE (ints).
+ * messages are sent with size MSG_SIZE (ints).
*/
#define MSG_SIZE 17000
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int b1[MSG_SIZE], b2[MSG_SIZE], b3[MSG_SIZE], b4[MSG_SIZE];
@@ -31,91 +31,98 @@ int main( int argc, char *argv[] )
MPI_Comm comm;
MPI_Status status;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
if (size < 2) {
- errs++;
- fprintf( stderr, "At least 2 processes required\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ errs++;
+ fprintf(stderr, "At least 2 processes required\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- src = 0;
+ src = 0;
dest = 1;
if (rank == src) {
- int *buf, bufsize, bsize;
-
- bufsize = 4 * (MSG_SIZE * sizeof(int) + MPI_BSEND_OVERHEAD);
- buf = (int *)malloc( bufsize );
- if (!buf) {
- fprintf( stderr, "Could not allocate buffer of %d bytes\n",
- bufsize );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- MPI_Buffer_attach( buf, bufsize );
-
- /* Initialize data */
- for (i=0; i<MSG_SIZE; i++) {
- b1[i] = i;
- b2[i] = MSG_SIZE + i;
- b3[i] = 2 * MSG_SIZE + i;
- b4[i] = 3 * MSG_SIZE + i;
- }
- /* Send and reset buffers after bsend returns */
- MPI_Bsend( b1, MSG_SIZE, MPI_INT, dest, 0, comm );
- for (i=0; i<MSG_SIZE; i++) b1[i] = -b1[i];
- MPI_Bsend( b2, MSG_SIZE, MPI_INT, dest, 1, comm );
- for (i=0; i<MSG_SIZE; i++) b2[i] = -b2[i];
- MPI_Bsend( b3, MSG_SIZE, MPI_INT, dest, 2, comm );
- for (i=0; i<MSG_SIZE; i++) b3[i] = -b3[i];
- MPI_Bsend( b4, MSG_SIZE, MPI_INT, dest, 3, comm );
- for (i=0; i<MSG_SIZE; i++) b4[i] = -b4[i];
-
- MPI_Barrier( comm );
- /* Detach waits until all messages received */
- MPI_Buffer_detach( &buf, &bsize );
+ int *buf, bufsize, bsize;
+
+ bufsize = 4 * (MSG_SIZE * sizeof(int) + MPI_BSEND_OVERHEAD);
+ buf = (int *) malloc(bufsize);
+ if (!buf) {
+ fprintf(stderr, "Could not allocate buffer of %d bytes\n", bufsize);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ MPI_Buffer_attach(buf, bufsize);
+
+ /* Initialize data */
+ for (i = 0; i < MSG_SIZE; i++) {
+ b1[i] = i;
+ b2[i] = MSG_SIZE + i;
+ b3[i] = 2 * MSG_SIZE + i;
+ b4[i] = 3 * MSG_SIZE + i;
+ }
+ /* Send and reset buffers after bsend returns */
+ MPI_Bsend(b1, MSG_SIZE, MPI_INT, dest, 0, comm);
+ for (i = 0; i < MSG_SIZE; i++)
+ b1[i] = -b1[i];
+ MPI_Bsend(b2, MSG_SIZE, MPI_INT, dest, 1, comm);
+ for (i = 0; i < MSG_SIZE; i++)
+ b2[i] = -b2[i];
+ MPI_Bsend(b3, MSG_SIZE, MPI_INT, dest, 2, comm);
+ for (i = 0; i < MSG_SIZE; i++)
+ b3[i] = -b3[i];
+ MPI_Bsend(b4, MSG_SIZE, MPI_INT, dest, 3, comm);
+ for (i = 0; i < MSG_SIZE; i++)
+ b4[i] = -b4[i];
+
+ MPI_Barrier(comm);
+ /* Detach waits until all messages received */
+ MPI_Buffer_detach(&buf, &bsize);
}
else if (rank == dest) {
-
- MPI_Barrier( comm );
- MPI_Recv( b2, MSG_SIZE, MPI_INT, src, 1, comm, &status );
- MPI_Recv( b1, MSG_SIZE, MPI_INT, src, 0, comm, &status );
- MPI_Recv( b4, MSG_SIZE, MPI_INT, src, 3, comm, &status );
- MPI_Recv( b3, MSG_SIZE, MPI_INT, src, 2, comm, &status );
-
- /* Check received data */
- for (i=0; i<MSG_SIZE; i++) {
- if (b1[i] != i) {
- errs++;
- if (errs < 16) printf( "b1[%d] is %d\n", i, b1[i] );
- }
- if (b2[i] != MSG_SIZE + i) {
- errs++;
- if (errs < 16) printf( "b2[%d] is %d\n", i, b2[i] );
- }
- if (b3[i] != 2 * MSG_SIZE + i) {
- errs++;
- if (errs < 16) printf( "b3[%d] is %d\n", i, b3[i] );
- }
- if (b4[i] != 3 * MSG_SIZE + i) {
- errs++;
- if (errs < 16) printf( "b4[%d] is %d\n", i, b4[i] );
- }
- }
+
+ MPI_Barrier(comm);
+ MPI_Recv(b2, MSG_SIZE, MPI_INT, src, 1, comm, &status);
+ MPI_Recv(b1, MSG_SIZE, MPI_INT, src, 0, comm, &status);
+ MPI_Recv(b4, MSG_SIZE, MPI_INT, src, 3, comm, &status);
+ MPI_Recv(b3, MSG_SIZE, MPI_INT, src, 2, comm, &status);
+
+ /* Check received data */
+ for (i = 0; i < MSG_SIZE; i++) {
+ if (b1[i] != i) {
+ errs++;
+ if (errs < 16)
+ printf("b1[%d] is %d\n", i, b1[i]);
+ }
+ if (b2[i] != MSG_SIZE + i) {
+ errs++;
+ if (errs < 16)
+ printf("b2[%d] is %d\n", i, b2[i]);
+ }
+ if (b3[i] != 2 * MSG_SIZE + i) {
+ errs++;
+ if (errs < 16)
+ printf("b3[%d] is %d\n", i, b3[i]);
+ }
+ if (b4[i] != 3 * MSG_SIZE + i) {
+ errs++;
+ if (errs < 16)
+ printf("b4[%d] is %d\n", i, b4[i]);
+ }
+ }
}
else {
- MPI_Barrier( comm );
+ MPI_Barrier(comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/pt2pt/bsendpending.c b/test/mpi/pt2pt/bsendpending.c
index 246f950..7e42c20 100644
--- a/test/mpi/pt2pt/bsendpending.c
+++ b/test/mpi/pt2pt/bsendpending.c
@@ -13,130 +13,130 @@
static char MTEST_Descrip[] = "Test the handling of BSend operations when a detach occurs before the bsend data has been sent.";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size, source, dest;
unsigned char *buf, *bufp;
- int minsize = 2;
+ int minsize = 2;
int i, msgsize, bufsize, outsize;
unsigned char *msg1, *msg2, *msg3;
- MPI_Comm comm;
- MPI_Status status1, status2, status3;
+ MPI_Comm comm;
+ MPI_Status status1, status2, status3;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- /* The following illustrates the use of the routines to
- run through a selection of communicators and datatypes.
- Use subsets of these for tests that do not involve combinations
- of communicators, datatypes, and counts of datatypes */
+ /* The following illustrates the use of the routines to
+ * run through a selection of communicators and datatypes.
+ * Use subsets of these for tests that do not involve combinations
+ * of communicators, datatypes, and counts of datatypes */
msgsize = 128 * 1024;
- msg1 = (unsigned char *)malloc( 3 * msgsize );
+ msg1 = (unsigned char *) malloc(3 * msgsize);
msg2 = msg1 + msgsize;
msg3 = msg2 + msgsize;
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
- /* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
- source = 0;
- dest = size - 1;
-
- /* Here is the test: The sender */
- if (rank == source) {
- /* Get a bsend buffer. Make it large enough that the Bsend
- internals will (probably) not use a eager send for the data.
- Have three such messages */
- bufsize = 3 * (MPI_BSEND_OVERHEAD + msgsize);
- buf = (unsigned char *)malloc( bufsize );
- if (!buf) {
- fprintf( stderr, "Unable to allocate a buffer of %d bytes\n",
- bufsize );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
-
- MPI_Buffer_attach( buf, bufsize );
-
- /* Initialize the buffers */
- for (i=0; i<msgsize; i++) {
- msg1[i] = 0xff ^ (i & 0xff);
- msg2[i] = 0xff ^ (3*i & 0xff);
- msg3[i] = 0xff ^ (5*i & 0xff);
- }
-
- /* Initiate the bsends */
- MPI_Bsend( msg1, msgsize, MPI_UNSIGNED_CHAR, dest, 0, comm );
- MPI_Bsend( msg2, msgsize, MPI_UNSIGNED_CHAR, dest, 0, comm );
- MPI_Bsend( msg3, msgsize, MPI_UNSIGNED_CHAR, dest, 0, comm );
-
- /* Synchronize with our partner */
- MPI_Sendrecv( NULL, 0, MPI_UNSIGNED_CHAR, dest, 10,
- NULL, 0, MPI_UNSIGNED_CHAR, dest, 10, comm, MPI_STATUS_IGNORE );
-
- /* Detach the buffers. There should be pending operations */
- MPI_Buffer_detach ( &bufp, &outsize );
- if (bufp != buf) {
- fprintf( stderr, "Wrong buffer returned\n" );
- errs++;
- }
- if (outsize != bufsize) {
- fprintf( stderr, "Wrong buffer size returned\n" );
- errs++;
- }
- }
- else if (rank == dest) {
- double tstart;
-
- /* Clear the message buffers */
- for (i=0; i<msgsize; i++) {
- msg1[i] = 0;
- msg2[i] = 0;
- msg3[i] = 0;
- }
-
- /* Wait for the synchronize */
- MPI_Sendrecv( NULL, 0, MPI_UNSIGNED_CHAR, source, 10,
- NULL, 0, MPI_UNSIGNED_CHAR, source, 10, comm, MPI_STATUS_IGNORE );
-
- /* Wait 2 seconds */
- tstart = MPI_Wtime();
- while (MPI_Wtime() - tstart < 2.0) ;
-
- /* Now receive the messages */
- MPI_Recv( msg1, msgsize, MPI_UNSIGNED_CHAR, source, 0, comm, &status1 );
- MPI_Recv( msg2, msgsize, MPI_UNSIGNED_CHAR, source, 0, comm, &status2 );
- MPI_Recv( msg3, msgsize, MPI_UNSIGNED_CHAR, source, 0, comm, &status3 );
-
- /* Check that we have the correct data */
- for (i=0; i<msgsize; i++) {
- if (msg1[i] != (0xff ^ (i & 0xff))) {
- if (errs < 10) {
- fprintf( stderr, "msg1[%d] = %d\n", i, msg1[i] );
- }
- errs++;
- }
- if (msg2[i] != (0xff ^ (3*i & 0xff))) {
- if (errs < 10) {
- fprintf( stderr, "msg2[%d] = %d\n", i, msg2[i] );
- }
- errs++;
- }
- if (msg3[i] != (0xff ^ (5*i & 0xff))) {
- if (errs < 10) {
- fprintf( stderr, "msg2[%d] = %d\n", i, msg2[i] );
- }
- errs++;
- }
- }
-
- }
-
-
- MTestFreeComm( &comm );
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ /* Determine the sender and receiver */
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+ source = 0;
+ dest = size - 1;
+
+ /* Here is the test: The sender */
+ if (rank == source) {
+ /* Get a bsend buffer. Make it large enough that the Bsend
+ * internals will (probably) not use a eager send for the data.
+ * Have three such messages */
+ bufsize = 3 * (MPI_BSEND_OVERHEAD + msgsize);
+ buf = (unsigned char *) malloc(bufsize);
+ if (!buf) {
+ fprintf(stderr, "Unable to allocate a buffer of %d bytes\n", bufsize);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+
+ MPI_Buffer_attach(buf, bufsize);
+
+ /* Initialize the buffers */
+ for (i = 0; i < msgsize; i++) {
+ msg1[i] = 0xff ^ (i & 0xff);
+ msg2[i] = 0xff ^ (3 * i & 0xff);
+ msg3[i] = 0xff ^ (5 * i & 0xff);
+ }
+
+ /* Initiate the bsends */
+ MPI_Bsend(msg1, msgsize, MPI_UNSIGNED_CHAR, dest, 0, comm);
+ MPI_Bsend(msg2, msgsize, MPI_UNSIGNED_CHAR, dest, 0, comm);
+ MPI_Bsend(msg3, msgsize, MPI_UNSIGNED_CHAR, dest, 0, comm);
+
+ /* Synchronize with our partner */
+ MPI_Sendrecv(NULL, 0, MPI_UNSIGNED_CHAR, dest, 10,
+ NULL, 0, MPI_UNSIGNED_CHAR, dest, 10, comm, MPI_STATUS_IGNORE);
+
+ /* Detach the buffers. There should be pending operations */
+ MPI_Buffer_detach(&bufp, &outsize);
+ if (bufp != buf) {
+ fprintf(stderr, "Wrong buffer returned\n");
+ errs++;
+ }
+ if (outsize != bufsize) {
+ fprintf(stderr, "Wrong buffer size returned\n");
+ errs++;
+ }
+ }
+ else if (rank == dest) {
+ double tstart;
+
+ /* Clear the message buffers */
+ for (i = 0; i < msgsize; i++) {
+ msg1[i] = 0;
+ msg2[i] = 0;
+ msg3[i] = 0;
+ }
+
+ /* Wait for the synchronize */
+ MPI_Sendrecv(NULL, 0, MPI_UNSIGNED_CHAR, source, 10,
+ NULL, 0, MPI_UNSIGNED_CHAR, source, 10, comm, MPI_STATUS_IGNORE);
+
+ /* Wait 2 seconds */
+ tstart = MPI_Wtime();
+ while (MPI_Wtime() - tstart < 2.0);
+
+ /* Now receive the messages */
+ MPI_Recv(msg1, msgsize, MPI_UNSIGNED_CHAR, source, 0, comm, &status1);
+ MPI_Recv(msg2, msgsize, MPI_UNSIGNED_CHAR, source, 0, comm, &status2);
+ MPI_Recv(msg3, msgsize, MPI_UNSIGNED_CHAR, source, 0, comm, &status3);
+
+ /* Check that we have the correct data */
+ for (i = 0; i < msgsize; i++) {
+ if (msg1[i] != (0xff ^ (i & 0xff))) {
+ if (errs < 10) {
+ fprintf(stderr, "msg1[%d] = %d\n", i, msg1[i]);
+ }
+ errs++;
+ }
+ if (msg2[i] != (0xff ^ (3 * i & 0xff))) {
+ if (errs < 10) {
+ fprintf(stderr, "msg2[%d] = %d\n", i, msg2[i]);
+ }
+ errs++;
+ }
+ if (msg3[i] != (0xff ^ (5 * i & 0xff))) {
+ if (errs < 10) {
+ fprintf(stderr, "msg2[%d] = %d\n", i, msg2[i]);
+ }
+ errs++;
+ }
+ }
+
+ }
+
+
+ MTestFreeComm(&comm);
}
- free( msg1 );
+ free(msg1);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/pt2pt/cancelanysrc.c b/test/mpi/pt2pt/cancelanysrc.c
index 09cd64f..e0ba2c5 100644
--- a/test/mpi/pt2pt/cancelanysrc.c
+++ b/test/mpi/pt2pt/cancelanysrc.c
@@ -8,7 +8,8 @@
#include <assert.h>
#include "mpi.h"
-int main(int argc, char **argv) {
+int main(int argc, char **argv)
+{
int size, rank, msg, cancelled;
MPI_Request request;
MPI_Status status;
@@ -18,7 +19,7 @@ int main(int argc, char **argv) {
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (size != 2) {
- fprintf(stderr,"ERROR: must be run with 2 processes");
+ fprintf(stderr, "ERROR: must be run with 2 processes");
MPI_Abort(MPI_COMM_WORLD, 1);
}
@@ -35,7 +36,8 @@ int main(int argc, char **argv) {
MPI_Irecv(&msg, 1, MPI_INT, MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, &request);
MPI_Wait(&request, &status);
assert(msg == 42);
- } else {
+ }
+ else {
MPI_Barrier(MPI_COMM_WORLD);
msg = 42;
MPI_Send(&msg, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
diff --git a/test/mpi/pt2pt/cancelrecv.c b/test/mpi/pt2pt/cancelrecv.c
index 2744748..d78a4d9 100644
--- a/test/mpi/pt2pt/cancelrecv.c
+++ b/test/mpi/pt2pt/cancelrecv.c
@@ -7,131 +7,128 @@
#include <stdio.h>
#include <stdlib.h>
#include "mpitest.h"
-#include <string.h> /* For memset */
+#include <string.h> /* For memset */
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Request r[3];
- MPI_Status s[3];
+ MPI_Status s[3];
int *buf0, *buf1, *buf2;
int rank, size, src, dest, flag, errs = 0;
int n0, n1, n2;
MPI_Comm comm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
if (size < 2) {
- fprintf( stderr, "Must run with at least 2 processes\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Must run with at least 2 processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
dest = 0;
- src = 1;
+ src = 1;
comm = MPI_COMM_WORLD;
n0 = n1 = n2 = 65536;
- buf0 = (int *)malloc( n0 * sizeof(int) );
- buf1 = (int *)malloc( n1 * sizeof(int) );
- buf2 = (int *)malloc( n2 * sizeof(int) );
+ buf0 = (int *) malloc(n0 * sizeof(int));
+ buf1 = (int *) malloc(n1 * sizeof(int));
+ buf2 = (int *) malloc(n2 * sizeof(int));
if (!buf0 || !buf1 || !buf2) {
- fprintf( stderr, "Unable to allocate buffers of size %d\n",
- n0 * (int)sizeof(int) );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Unable to allocate buffers of size %d\n", n0 * (int) sizeof(int));
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- memset( buf0, -1, n0 * sizeof(int) );
- memset( buf1, -1, n0 * sizeof(int) );
- memset( buf2, -1, n0 * sizeof(int) );
+ memset(buf0, -1, n0 * sizeof(int));
+ memset(buf1, -1, n0 * sizeof(int));
+ memset(buf2, -1, n0 * sizeof(int));
if (rank == dest) {
- MPI_Irecv( buf0, n0, MPI_INT, src, 0, comm, &r[0] );
- MPI_Irecv( buf1, n1, MPI_INT, src, 1, comm, &r[1] );
- MPI_Irecv( buf2, n2, MPI_INT, src, 2, comm, &r[2] );
-
- MPI_Barrier( comm );
+ MPI_Irecv(buf0, n0, MPI_INT, src, 0, comm, &r[0]);
+ MPI_Irecv(buf1, n1, MPI_INT, src, 1, comm, &r[1]);
+ MPI_Irecv(buf2, n2, MPI_INT, src, 2, comm, &r[2]);
- MPI_Cancel( &r[1] );
- MPI_Barrier( comm );
- memset( s, -1, sizeof(s) );
- MPI_Waitall( 3, r, s );
- MPI_Test_cancelled( &s[0], &flag );
+ MPI_Barrier(comm);
+
+ MPI_Cancel(&r[1]);
+ MPI_Barrier(comm);
+ memset(s, -1, sizeof(s));
+ MPI_Waitall(3, r, s);
+ MPI_Test_cancelled(&s[0], &flag);
if (flag) {
- errs++;
- printf( "request 0 was cancelled!\n" );
- }
- MPI_Test_cancelled( &s[1], &flag );
+ errs++;
+ printf("request 0 was cancelled!\n");
+ }
+ MPI_Test_cancelled(&s[1], &flag);
if (!flag) {
- errs++;
- printf( "request 1 was not cancelled!\n" );
- }
- MPI_Test_cancelled( &s[2], &flag );
+ errs++;
+ printf("request 1 was not cancelled!\n");
+ }
+ MPI_Test_cancelled(&s[2], &flag);
if (flag) {
- errs++;
- printf( "request 2 was cancelled!\n" );
- }
- MPI_Barrier( comm );
+ errs++;
+ printf("request 2 was cancelled!\n");
+ }
+ MPI_Barrier(comm);
}
if (rank == src) {
- int tflag;
- MPI_Barrier( comm );
- MPI_Barrier( comm );
- MPI_Send( buf0, n0, MPI_INT, dest, 0, comm );
- MPI_Isend( buf2, n2, MPI_INT, dest, 2, comm, &r[1] );
- MPI_Isend( buf1, n1, MPI_INT, dest, 4, comm, &r[0] );
- MPI_Cancel( &r[0] );
- memset( s, -3, sizeof(s) );
- s[0].MPI_ERROR = -3;
- s[1].MPI_ERROR = -3;
- MPI_Testall( 2, r, &tflag, s );
- if (tflag) {
- MPI_Test_cancelled( &s[0], &flag );
- if (!flag) {
- errs++;
- printf( "send request 0 was not cancelled!\n" );
- }
- MPI_Test_cancelled( &s[1], &flag );
- if (flag) {
- errs++;
- printf( "send request 1 was cancelled!\n" );
- }
- }
- else {
- /* If all requests are not complete, then neither r nor s
- may be changed */
- if ( (s[0].MPI_ERROR) != -3) {
- errs++;
- printf( "Send request status 0 modified. s[0].MPI_ERROR = %x\n",
- s[0].MPI_ERROR );
- }
- if ( (s[1].MPI_ERROR) != -3) {
- errs++;
- printf( "Send request status 1 modified. s[1].MPI_ERROR = %x\n",
- s[1].MPI_ERROR );
- }
- }
- MPI_Barrier( comm );
- while (!tflag) {
- MPI_Testall( 2, r, &tflag, s );
- }
- MPI_Test_cancelled( &s[0], &flag );
- if (!flag) {
- errs++;
- printf( "send request 0 was not cancelled!\n" );
- }
- MPI_Test_cancelled( &s[1], &flag );
- if (flag) {
- errs++;
- printf( "send request 1 was cancelled!\n" );
- }
+ int tflag;
+ MPI_Barrier(comm);
+ MPI_Barrier(comm);
+ MPI_Send(buf0, n0, MPI_INT, dest, 0, comm);
+ MPI_Isend(buf2, n2, MPI_INT, dest, 2, comm, &r[1]);
+ MPI_Isend(buf1, n1, MPI_INT, dest, 4, comm, &r[0]);
+ MPI_Cancel(&r[0]);
+ memset(s, -3, sizeof(s));
+ s[0].MPI_ERROR = -3;
+ s[1].MPI_ERROR = -3;
+ MPI_Testall(2, r, &tflag, s);
+ if (tflag) {
+ MPI_Test_cancelled(&s[0], &flag);
+ if (!flag) {
+ errs++;
+ printf("send request 0 was not cancelled!\n");
+ }
+ MPI_Test_cancelled(&s[1], &flag);
+ if (flag) {
+ errs++;
+ printf("send request 1 was cancelled!\n");
+ }
+ }
+ else {
+ /* If all requests are not complete, then neither r nor s
+ * may be changed */
+ if ((s[0].MPI_ERROR) != -3) {
+ errs++;
+ printf("Send request status 0 modified. s[0].MPI_ERROR = %x\n", s[0].MPI_ERROR);
+ }
+ if ((s[1].MPI_ERROR) != -3) {
+ errs++;
+ printf("Send request status 1 modified. s[1].MPI_ERROR = %x\n", s[1].MPI_ERROR);
+ }
+ }
+ MPI_Barrier(comm);
+ while (!tflag) {
+ MPI_Testall(2, r, &tflag, s);
+ }
+ MPI_Test_cancelled(&s[0], &flag);
+ if (!flag) {
+ errs++;
+ printf("send request 0 was not cancelled!\n");
+ }
+ MPI_Test_cancelled(&s[1], &flag);
+ if (flag) {
+ errs++;
+ printf("send request 1 was cancelled!\n");
+ }
}
if (rank != src && rank != dest) {
- MPI_Barrier( comm );
- MPI_Barrier( comm );
- MPI_Barrier( comm );
+ MPI_Barrier(comm);
+ MPI_Barrier(comm);
+ MPI_Barrier(comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
diff --git a/test/mpi/pt2pt/eagerdt.c b/test/mpi/pt2pt/eagerdt.c
index 4adc26c..dc3b1c5 100644
--- a/test/mpi/pt2pt/eagerdt.c
+++ b/test/mpi/pt2pt/eagerdt.c
@@ -14,64 +14,62 @@ static char MTEST_Descrip[] = "Test of a large number of derived-datatype messag
#define MAX_MSGS 30
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size, dest, source;
int i, indices[40];
MPI_Aint extent;
int *buf, *bufs[MAX_MSGS];
- MPI_Comm comm;
- MPI_Datatype dtype;
- MPI_Request req[MAX_MSGS];
+ MPI_Comm comm;
+ MPI_Datatype dtype;
+ MPI_Request req[MAX_MSGS];
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
source = 0;
- dest = size - 1;
-
+ dest = size - 1;
+
/* Setup by creating a blocked datatype that is likely to be processed
- in a piecemeal fashion */
- for (i=0; i<30; i++) {
- indices[i] = i*40;
+ * in a piecemeal fashion */
+ for (i = 0; i < 30; i++) {
+ indices[i] = i * 40;
}
/* 30 blocks of size 10 */
- MPI_Type_create_indexed_block( 30, 10, indices, MPI_INT, &dtype );
- MPI_Type_commit( &dtype );
-
+ MPI_Type_create_indexed_block(30, 10, indices, MPI_INT, &dtype);
+ MPI_Type_commit(&dtype);
+
/* Create the corresponding message buffers */
- MPI_Type_extent( dtype, &extent );
- for (i=0; i<MAX_MSGS; i++) {
- bufs[i] = (int *)malloc( extent );
- if (!bufs[i]) {
- fprintf( stderr, "Unable to allocate buffer %d of size %ld\n",
- i, (long)extent );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
+ MPI_Type_extent(dtype, &extent);
+ for (i = 0; i < MAX_MSGS; i++) {
+ bufs[i] = (int *) malloc(extent);
+ if (!bufs[i]) {
+ fprintf(stderr, "Unable to allocate buffer %d of size %ld\n", i, (long) extent);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
}
- buf = (int *)malloc( 10 * 30 * sizeof(int) );
-
- MPI_Barrier( MPI_COMM_WORLD );
+ buf = (int *) malloc(10 * 30 * sizeof(int));
+
+ MPI_Barrier(MPI_COMM_WORLD);
if (rank == dest) {
- MTestSleep( 2 );
- for (i=0; i<MAX_MSGS; i++) {
- MPI_Recv( buf, 10*30, MPI_INT, source, i, comm,
- MPI_STATUS_IGNORE );
- }
+ MTestSleep(2);
+ for (i = 0; i < MAX_MSGS; i++) {
+ MPI_Recv(buf, 10 * 30, MPI_INT, source, i, comm, MPI_STATUS_IGNORE);
+ }
}
- else if (rank == source ) {
- for (i=0; i<MAX_MSGS; i++) {
- MPI_Isend( bufs[i], 1, dtype, dest, i, comm, &req[i] );
- }
- MPI_Waitall( MAX_MSGS, req, MPI_STATUSES_IGNORE );
+ else if (rank == source) {
+ for (i = 0; i < MAX_MSGS; i++) {
+ MPI_Isend(bufs[i], 1, dtype, dest, i, comm, &req[i]);
+ }
+ MPI_Waitall(MAX_MSGS, req, MPI_STATUSES_IGNORE);
}
- MPI_Type_free( &dtype );
- MTest_Finalize( errs );
+ MPI_Type_free(&dtype);
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/pt2pt/greq1.c b/test/mpi/pt2pt/greq1.c
index 675f072..48ee44b 100644
--- a/test/mpi/pt2pt/greq1.c
+++ b/test/mpi/pt2pt/greq1.c
@@ -13,27 +13,30 @@ static char MTEST_Descrip[] = "Simple test of generalized requests";
*/
-int query_fn( void *extra_state, MPI_Status *status );
-int query_fn( void *extra_state, MPI_Status *status )
+int query_fn(void *extra_state, MPI_Status * status);
+int query_fn(void *extra_state, MPI_Status * status)
{
/* Set a default status */
status->MPI_SOURCE = MPI_UNDEFINED;
- status->MPI_TAG = MPI_UNDEFINED;
- MPI_Status_set_cancelled( status, 0 );
- MPI_Status_set_elements( status, MPI_BYTE, 0 );
+ status->MPI_TAG = MPI_UNDEFINED;
+ MPI_Status_set_cancelled(status, 0);
+ MPI_Status_set_elements(status, MPI_BYTE, 0);
return 0;
}
-int free_fn( void *extra_state );
-int free_fn( void *extra_state )
+
+int free_fn(void *extra_state);
+int free_fn(void *extra_state)
{
- int *b = (int *)extra_state;
- if (b) *b = *b - 1;
+ int *b = (int *) extra_state;
+ if (b)
+ *b = *b - 1;
/* The value returned by the free function is the error code
- returned by the wait/test function */
+ * returned by the wait/test function */
return 0;
}
-int cancel_fn( void *extra_state, int complete );
-int cancel_fn( void *extra_state, int complete )
+
+int cancel_fn(void *extra_state, int complete);
+int cancel_fn(void *extra_state, int complete)
{
return 0;
}
@@ -43,44 +46,44 @@ int cancel_fn( void *extra_state, int complete )
* MPI_Grequest_complete function would be called from another routine,
* often running in a separate thread. This simple code allows us to
* check that requests can be created, tested, and waited on in the
- * case where the request is complete before the wait is called.
+ * case where the request is complete before the wait is called.
*
* Note that MPI did *not* define a routine that can be called within
- * test or wait to advance the state of a generalized request.
+ * test or wait to advance the state of a generalized request.
* Most uses of generalized requests will need to use a separate thread.
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int counter, flag;
- MPI_Status status;
- MPI_Request request;
+ MPI_Status status;
+ MPI_Request request;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Grequest_start( query_fn, free_fn, cancel_fn, NULL, &request );
-
- MPI_Test( &request, &flag, &status );
+ MPI_Grequest_start(query_fn, free_fn, cancel_fn, NULL, &request);
+
+ MPI_Test(&request, &flag, &status);
if (flag) {
- errs++;
- fprintf( stderr, "Generalized request marked as complete\n" );
+ errs++;
+ fprintf(stderr, "Generalized request marked as complete\n");
}
- MPI_Grequest_complete( request );
+ MPI_Grequest_complete(request);
- MPI_Wait( &request, &status );
+ MPI_Wait(&request, &status);
counter = 1;
- MPI_Grequest_start( query_fn, free_fn, cancel_fn, &counter, &request );
- MPI_Grequest_complete( request );
- MPI_Wait( &request, MPI_STATUS_IGNORE );
-
+ MPI_Grequest_start(query_fn, free_fn, cancel_fn, &counter, &request);
+ MPI_Grequest_complete(request);
+ MPI_Wait(&request, MPI_STATUS_IGNORE);
+
if (counter) {
- errs++;
- fprintf( stderr, "Free routine not called, or not called with extra_data" );
+ errs++;
+ fprintf(stderr, "Free routine not called, or not called with extra_data");
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/pt2pt/icsend.c b/test/mpi/pt2pt/icsend.c
index ae196ef..9981846 100644
--- a/test/mpi/pt2pt/icsend.c
+++ b/test/mpi/pt2pt/icsend.c
@@ -12,61 +12,62 @@
static char MTEST_Descrip[] = "Simple test of intercommunicator send and receive";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int leftGroup, buf, rank, remote_size, i;
MPI_Comm comm;
MPI_Status status;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- while (MTestGetIntercomm( &comm, &leftGroup, 4 )) {
- if (comm == MPI_COMM_NULL) continue;
+ while (MTestGetIntercomm(&comm, &leftGroup, 4)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
- if (leftGroup) {
- MPI_Comm_rank( comm, &rank );
- buf = rank;
- MPI_Send( &buf, 1, MPI_INT, 0, 0, comm );
- }
- else {
- MPI_Comm_remote_size( comm, &remote_size );
- MPI_Comm_rank( comm, &rank );
- if (rank == 0) {
- for (i=0; i<remote_size; i++) {
- buf = -1;
- MPI_Recv( &buf, 1, MPI_INT, i, 0, comm, &status );
- if (buf != i) {
- errs++;
- fprintf( stderr, "buf = %d, should be %d\n", buf, i );
- }
- }
- }
- }
- /* Now, reverse it and send back */
- if (!leftGroup) {
- MPI_Comm_rank( comm, &rank );
- buf = rank;
- MPI_Send( &buf, 1, MPI_INT, 0, 0, comm );
- }
- else {
- MPI_Comm_remote_size( comm, &remote_size );
- MPI_Comm_rank( comm, &rank );
- if (rank == 0) {
- for (i=0; i<remote_size; i++) {
- buf = -1;
- MPI_Recv( &buf, 1, MPI_INT, i, 0, comm, &status );
- if (buf != i) {
- errs++;
- fprintf( stderr, "buf = %d, should be %d\n", buf, i );
- }
- }
- }
- }
+ if (leftGroup) {
+ MPI_Comm_rank(comm, &rank);
+ buf = rank;
+ MPI_Send(&buf, 1, MPI_INT, 0, 0, comm);
+ }
+ else {
+ MPI_Comm_remote_size(comm, &remote_size);
+ MPI_Comm_rank(comm, &rank);
+ if (rank == 0) {
+ for (i = 0; i < remote_size; i++) {
+ buf = -1;
+ MPI_Recv(&buf, 1, MPI_INT, i, 0, comm, &status);
+ if (buf != i) {
+ errs++;
+ fprintf(stderr, "buf = %d, should be %d\n", buf, i);
+ }
+ }
+ }
+ }
+ /* Now, reverse it and send back */
+ if (!leftGroup) {
+ MPI_Comm_rank(comm, &rank);
+ buf = rank;
+ MPI_Send(&buf, 1, MPI_INT, 0, 0, comm);
+ }
+ else {
+ MPI_Comm_remote_size(comm, &remote_size);
+ MPI_Comm_rank(comm, &rank);
+ if (rank == 0) {
+ for (i = 0; i < remote_size; i++) {
+ buf = -1;
+ MPI_Recv(&buf, 1, MPI_INT, i, 0, comm, &status);
+ if (buf != i) {
+ errs++;
+ fprintf(stderr, "buf = %d, should be %d\n", buf, i);
+ }
+ }
+ }
+ }
MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/pt2pt/inactivereq.c b/test/mpi/pt2pt/inactivereq.c
index 1f4b6af..6531b44 100644
--- a/test/mpi/pt2pt/inactivereq.c
+++ b/test/mpi/pt2pt/inactivereq.c
@@ -9,32 +9,32 @@
#include "mpitest.h"
/* This test program checks that the point-to-point completion routines
- can be applied to an inactive persistent request, as required by the
- MPI-1 standard. See section 3.7.3, for example,
+ can be applied to an inactive persistent request, as required by the
+ MPI-1 standard. See section 3.7.3, for example,
- One is allowed to call MPI TEST with a null or inactive request argument.
+ One is allowed to call MPI TEST with a null or inactive request argument.
In such a case the operation returns with flag = true and empty status.
*/
-int StatusEmpty( MPI_Status *s );
-int StatusEmpty( MPI_Status *s )
+int StatusEmpty(MPI_Status * s);
+int StatusEmpty(MPI_Status * s)
{
int errs = 0;
int count = 10;
if (s->MPI_TAG != MPI_ANY_TAG) {
- errs++;
- printf( "MPI_TAG not MPI_ANY_TAG in status\n" );
+ errs++;
+ printf("MPI_TAG not MPI_ANY_TAG in status\n");
}
if (s->MPI_SOURCE != MPI_ANY_SOURCE) {
- errs++;
- printf( "MPI_SOURCE not MPI_ANY_SOURCE in status\n" );
+ errs++;
+ printf("MPI_SOURCE not MPI_ANY_SOURCE in status\n");
}
- MPI_Get_count( s, MPI_INT, &count );
+ MPI_Get_count(s, MPI_INT, &count);
if (count != 0) {
- errs++;
- printf( "count in status is not 0\n" );
+ errs++;
+ printf("count in status is not 0\n");
}
/* Return true only if status passed all tests */
return errs ? 0 : 1;
@@ -43,7 +43,7 @@ int StatusEmpty( MPI_Status *s )
int main(int argc, char *argv[])
{
MPI_Request r;
- MPI_Status s;
+ MPI_Status s;
int errs = 0;
int flag;
int buf[10];
@@ -52,115 +52,115 @@ int main(int argc, char *argv[])
int dest = 0;
int rank, size;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Comm_size( MPI_COMM_WORLD, &size );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
/* Create a persistent send request */
- MPI_Send_init( buf, 10, MPI_INT, dest, tag, MPI_COMM_WORLD, &r );
+ MPI_Send_init(buf, 10, MPI_INT, dest, tag, MPI_COMM_WORLD, &r);
flag = 0;
s.MPI_TAG = 10;
s.MPI_SOURCE = 10;
- MPI_Test( &r, &flag, &s );
+ MPI_Test(&r, &flag, &s);
if (!flag) {
- errs++;
- printf( "Flag not true after MPI_Test (send)\n" );
- printf( "Aborting further tests to avoid hanging in MPI_Wait\n" );
- MTest_Finalize( errs );
- MPI_Finalize();
- return 0;
+ errs++;
+ printf("Flag not true after MPI_Test (send)\n");
+ printf("Aborting further tests to avoid hanging in MPI_Wait\n");
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
}
- if (!StatusEmpty( &s )) {
- errs++;
- printf( "Status not empty after MPI_Test (send)\n" );
+ if (!StatusEmpty(&s)) {
+ errs++;
+ printf("Status not empty after MPI_Test (send)\n");
}
s.MPI_TAG = 10;
s.MPI_SOURCE = 10;
- MPI_Wait( &r, &s );
- if (!StatusEmpty( &s )) {
- errs++;
- printf( "Status not empty after MPI_Wait (send)\n" );
+ MPI_Wait(&r, &s);
+ if (!StatusEmpty(&s)) {
+ errs++;
+ printf("Status not empty after MPI_Wait (send)\n");
}
/* Now try to use that request, then check again */
if (rank == 0) {
- int i;
- MPI_Request *rr = (MPI_Request *)malloc(size * sizeof(MPI_Request));
- for (i=0; i<size; i++) {
- MPI_Irecv( rbuf, 10, MPI_INT, i, tag, MPI_COMM_WORLD, &rr[i] );
- }
- MPI_Start( &r );
- MPI_Wait( &r, &s );
- MPI_Waitall( size, rr, MPI_STATUSES_IGNORE );
+ int i;
+ MPI_Request *rr = (MPI_Request *) malloc(size * sizeof(MPI_Request));
+ for (i = 0; i < size; i++) {
+ MPI_Irecv(rbuf, 10, MPI_INT, i, tag, MPI_COMM_WORLD, &rr[i]);
+ }
+ MPI_Start(&r);
+ MPI_Wait(&r, &s);
+ MPI_Waitall(size, rr, MPI_STATUSES_IGNORE);
}
else {
- MPI_Start( &r );
- MPI_Wait( &r, &s );
+ MPI_Start(&r);
+ MPI_Wait(&r, &s);
}
flag = 0;
s.MPI_TAG = 10;
s.MPI_SOURCE = 10;
- MPI_Test( &r, &flag, &s );
+ MPI_Test(&r, &flag, &s);
if (!flag) {
- errs++;
- printf( "Flag not true after MPI_Test (send)\n" );
- printf( "Aborting further tests to avoid hanging in MPI_Wait\n" );
- MTest_Finalize( errs );
- MPI_Finalize();
- return 0;
+ errs++;
+ printf("Flag not true after MPI_Test (send)\n");
+ printf("Aborting further tests to avoid hanging in MPI_Wait\n");
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
}
- if (!StatusEmpty( &s )) {
- errs++;
- printf( "Status not empty after MPI_Test (send)\n" );
+ if (!StatusEmpty(&s)) {
+ errs++;
+ printf("Status not empty after MPI_Test (send)\n");
}
s.MPI_TAG = 10;
s.MPI_SOURCE = 10;
- MPI_Wait( &r, &s );
- if (!StatusEmpty( &s )) {
- errs++;
- printf( "Status not empty after MPI_Wait (send)\n" );
+ MPI_Wait(&r, &s);
+ if (!StatusEmpty(&s)) {
+ errs++;
+ printf("Status not empty after MPI_Wait (send)\n");
}
-
- MPI_Request_free( &r );
+
+ MPI_Request_free(&r);
/* Create a persistent receive request */
- MPI_Recv_init( buf, 10, MPI_INT, dest, tag, MPI_COMM_WORLD, &r );
+ MPI_Recv_init(buf, 10, MPI_INT, dest, tag, MPI_COMM_WORLD, &r);
flag = 0;
s.MPI_TAG = 10;
s.MPI_SOURCE = 10;
- MPI_Test( &r, &flag, &s );
+ MPI_Test(&r, &flag, &s);
if (!flag) {
- errs++;
- printf( "Flag not true after MPI_Test (recv)\n" );
- printf( "Aborting further tests to avoid hanging in MPI_Wait\n" );
- MTest_Finalize( errs );
- MPI_Finalize();
- return 0;
+ errs++;
+ printf("Flag not true after MPI_Test (recv)\n");
+ printf("Aborting further tests to avoid hanging in MPI_Wait\n");
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
}
- if (!StatusEmpty( &s )) {
- errs++;
- printf( "Status not empty after MPI_Test (recv)\n" );
+ if (!StatusEmpty(&s)) {
+ errs++;
+ printf("Status not empty after MPI_Test (recv)\n");
}
s.MPI_TAG = 10;
s.MPI_SOURCE = 10;
- MPI_Wait( &r, &s );
- if (!StatusEmpty( &s )) {
- errs++;
- printf( "Status not empty after MPI_Wait (recv)\n" );
+ MPI_Wait(&r, &s);
+ if (!StatusEmpty(&s)) {
+ errs++;
+ printf("Status not empty after MPI_Wait (recv)\n");
}
- MPI_Request_free( &r );
-
- MTest_Finalize( errs );
+ MPI_Request_free(&r);
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/pt2pt/isendirecv.c b/test/mpi/pt2pt/isendirecv.c
index e2fccf6..6980f92 100644
--- a/test/mpi/pt2pt/isendirecv.c
+++ b/test/mpi/pt2pt/isendirecv.c
@@ -16,7 +16,7 @@ int main(int argc, char *argv[])
int elems = 20;
int rank, nproc, dest, i;
float *in_buf, *out_buf;
- MPI_Comm comm;
+ MPI_Comm comm;
MPI_Request *reqs;
MTest_Init(&argc, &argv);
@@ -25,21 +25,19 @@ int main(int argc, char *argv[])
MPI_Comm_rank(comm, &rank);
MPI_Comm_size(comm, &nproc);
- reqs = (MPI_Request *)malloc(2 * nproc * sizeof(MPI_Request));
- in_buf = (float *)malloc(elems * nproc * sizeof(float));
- out_buf = (float *)malloc(elems * nproc * sizeof(float));
+ reqs = (MPI_Request *) malloc(2 * nproc * sizeof(MPI_Request));
+ in_buf = (float *) malloc(elems * nproc * sizeof(float));
+ out_buf = (float *) malloc(elems * nproc * sizeof(float));
- for (i=0; i<nproc; i++) {
- MPI_Irecv(&in_buf[elems*i], elems, MPI_FLOAT, i,
- 0, comm, &reqs[i]);
- }
+ for (i = 0; i < nproc; i++) {
+ MPI_Irecv(&in_buf[elems * i], elems, MPI_FLOAT, i, 0, comm, &reqs[i]);
+ }
- for (i=0; i<nproc; i++) {
- MPI_Isend(&out_buf[elems*i], elems, MPI_FLOAT, i, 0,
- comm, &reqs[i+nproc]);
- }
+ for (i = 0; i < nproc; i++) {
+ MPI_Isend(&out_buf[elems * i], elems, MPI_FLOAT, i, 0, comm, &reqs[i + nproc]);
+ }
- MPI_Waitall(nproc*2,reqs, MPI_STATUSES_IGNORE);
+ MPI_Waitall(nproc * 2, reqs, MPI_STATUSES_IGNORE);
MTest_Finalize(errors);
MPI_Finalize();
diff --git a/test/mpi/pt2pt/isendself.c b/test/mpi/pt2pt/isendself.c
index 2e6527a..3d337be 100644
--- a/test/mpi/pt2pt/isendself.c
+++ b/test/mpi/pt2pt/isendself.c
@@ -7,52 +7,45 @@
#include "mpi.h"
#include "mpitest.h"
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int a[10], b[10], i;
MPI_Status status;
MPI_Request request;
int rank, count;
int errs = 0;
-
- MTest_Init( 0, 0 );
+
+ MTest_Init(0, 0);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
-
- for (i=0; i<10; i++) a[i] = i+1;
+
+ for (i = 0; i < 10; i++)
+ a[i] = i + 1;
status.MPI_ERROR = 0;
- MPI_Isend( a, 0, MPI_INT, rank, 0, MPI_COMM_WORLD, &request );
- MPI_Recv( b, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD,
- &status );
- MPI_Get_count( &status, MPI_INT, &count );
- if (status.MPI_SOURCE != rank ||
- status.MPI_TAG != 0 ||
- status.MPI_ERROR != 0 ||
- count != 0) {
- errs++;
- printf ("1 status = %d %d %d %d\n", status.MPI_SOURCE, status.MPI_TAG,
- status.MPI_ERROR, count );
+ MPI_Isend(a, 0, MPI_INT, rank, 0, MPI_COMM_WORLD, &request);
+ MPI_Recv(b, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
+ MPI_Get_count(&status, MPI_INT, &count);
+ if (status.MPI_SOURCE != rank || status.MPI_TAG != 0 || status.MPI_ERROR != 0 || count != 0) {
+ errs++;
+ printf("1 status = %d %d %d %d\n", status.MPI_SOURCE, status.MPI_TAG,
+ status.MPI_ERROR, count);
}
- /* printf( "b[0] = %d\n", b[0] );*/
- MPI_Wait( &request, &status );
-
- MPI_Isend( NULL, 0, MPI_INT, rank, 0, MPI_COMM_WORLD, &request );
- MPI_Recv( NULL, 0, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD,
- &status );
- MPI_Get_count( &status, MPI_INT, &count );
- if (status.MPI_SOURCE != rank ||
- status.MPI_TAG != 0 ||
- status.MPI_ERROR != 0 ||
- count != 0) {
- errs++;
- printf ("2 status = %d %d %d %d\n", status.MPI_SOURCE, status.MPI_TAG,
- status.MPI_ERROR, count );
+ /* printf("b[0] = %d\n", b[0]); */
+ MPI_Wait(&request, &status);
+
+ MPI_Isend(NULL, 0, MPI_INT, rank, 0, MPI_COMM_WORLD, &request);
+ MPI_Recv(NULL, 0, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
+ MPI_Get_count(&status, MPI_INT, &count);
+ if (status.MPI_SOURCE != rank || status.MPI_TAG != 0 || status.MPI_ERROR != 0 || count != 0) {
+ errs++;
+ printf("2 status = %d %d %d %d\n", status.MPI_SOURCE, status.MPI_TAG,
+ status.MPI_ERROR, count);
}
- MPI_Wait( &request, &status );
+ MPI_Wait(&request, &status);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/pt2pt/isendselfprobe.c b/test/mpi/pt2pt/isendselfprobe.c
index d371ff6..4d65ea6 100644
--- a/test/mpi/pt2pt/isendselfprobe.c
+++ b/test/mpi/pt2pt/isendselfprobe.c
@@ -7,7 +7,7 @@
#include "mpi.h"
#include "mpitest.h"
-int main( int argc, char * argv[] )
+int main(int argc, char *argv[])
{
int rank;
int sendMsg = 123;
@@ -18,30 +18,26 @@ int main( int argc, char * argv[] )
MPI_Request request;
int errs = 0;
- MTest_Init( 0, 0 );
+ MTest_Init(0, 0);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- if(rank == 0)
- {
- MPI_Isend( &sendMsg, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &request );
- while(!flag)
- {
- MPI_Iprobe( 0, 0, MPI_COMM_WORLD, &flag, &status );
- }
- MPI_Get_count( &status, MPI_INT, &count );
- if(count != 1)
- {
- errs++;
- }
- MPI_Recv( &recvMsg, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &status );
- if(recvMsg != 123)
- {
- errs++;
- }
- MPI_Wait( &request, &status );
+ if (rank == 0) {
+ MPI_Isend(&sendMsg, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &request);
+ while (!flag) {
+ MPI_Iprobe(0, 0, MPI_COMM_WORLD, &flag, &status);
+ }
+ MPI_Get_count(&status, MPI_INT, &count);
+ if (count != 1) {
+ errs++;
+ }
+ MPI_Recv(&recvMsg, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &status);
+ if (recvMsg != 123) {
+ errs++;
+ }
+ MPI_Wait(&request, &status);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/pt2pt/large_message.c b/test/mpi/pt2pt/large_message.c
index f895936..8c343e5 100644
--- a/test/mpi/pt2pt/large_message.c
+++ b/test/mpi/pt2pt/large_message.c
@@ -8,62 +8,65 @@
#include <stdlib.h>
#include "mpitest.h"
-/* tests send/recv of a message > 2GB. count=270M, type=long long
+/* tests send/recv of a message > 2GB. count=270M, type=long long
run with 3 processes to exercise both shared memory and TCP in Nemesis tests*/
-int main(int argc, char *argv[])
+int main(int argc, char *argv[])
{
- int ierr,i,size,rank;
- int cnt = 270000000;
- MPI_Status status;
- long long *cols;
- int errs = 0;
+ int ierr, i, size, rank;
+ int cnt = 270000000;
+ MPI_Status status;
+ long long *cols;
+ int errs = 0;
- MTest_Init(&argc,&argv);
+ MTest_Init(&argc, &argv);
/* need large memory */
- if (sizeof(void *) < 8) {
- MTest_Finalize(errs);
- MPI_Finalize();
- return 0;
- }
+ if (sizeof(void *) < 8) {
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
+ }
- ierr = MPI_Comm_size(MPI_COMM_WORLD,&size);
- ierr = MPI_Comm_rank(MPI_COMM_WORLD,&rank);
- if (size != 3) {
- fprintf(stderr,"[%d] usage: mpiexec -n 3 %s\n",rank,argv[0]);
- MPI_Abort(MPI_COMM_WORLD,1);
- }
+ ierr = MPI_Comm_size(MPI_COMM_WORLD, &size);
+ ierr = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ if (size != 3) {
+ fprintf(stderr, "[%d] usage: mpiexec -n 3 %s\n", rank, argv[0]);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
- cols = malloc(cnt*sizeof(long long));
- if (cols == NULL) {
- printf("malloc of >2GB array failed\n");
- errs++;
- MTest_Finalize(errs);
- MPI_Finalize();
- return 0;
- }
+ cols = malloc(cnt * sizeof(long long));
+ if (cols == NULL) {
+ printf("malloc of >2GB array failed\n");
+ errs++;
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
+ }
- if (rank == 0) {
- for (i=0; i<cnt; i++) cols[i] = i;
- /* printf("[%d] sending...\n",rank);*/
- ierr = MPI_Send(cols,cnt,MPI_LONG_LONG_INT,1,0,MPI_COMM_WORLD);
- ierr = MPI_Send(cols,cnt,MPI_LONG_LONG_INT,2,0,MPI_COMM_WORLD);
- } else {
- /* printf("[%d] receiving...\n",rank); */
- for (i=0; i<cnt; i++) cols[i] = -1;
- ierr = MPI_Recv(cols,cnt,MPI_LONG_LONG_INT,0,0,MPI_COMM_WORLD,&status);
- /* ierr = MPI_Get_count(&status,MPI_LONG_LONG_INT,&cnt);
- Get_count still fails because count is not 64 bit */
- for (i=0; i<cnt; i++) {
- if (cols[i] != i) {
- /*printf("Rank %d, cols[i]=%lld, should be %d\n", rank, cols[i], i);*/
- errs++;
+ if (rank == 0) {
+ for (i = 0; i < cnt; i++)
+ cols[i] = i;
+ /* printf("[%d] sending...\n",rank); */
+ ierr = MPI_Send(cols, cnt, MPI_LONG_LONG_INT, 1, 0, MPI_COMM_WORLD);
+ ierr = MPI_Send(cols, cnt, MPI_LONG_LONG_INT, 2, 0, MPI_COMM_WORLD);
+ }
+ else {
+ /* printf("[%d] receiving...\n",rank); */
+ for (i = 0; i < cnt; i++)
+ cols[i] = -1;
+ ierr = MPI_Recv(cols, cnt, MPI_LONG_LONG_INT, 0, 0, MPI_COMM_WORLD, &status);
+ /* ierr = MPI_Get_count(&status,MPI_LONG_LONG_INT,&cnt);
+ * Get_count still fails because count is not 64 bit */
+ for (i = 0; i < cnt; i++) {
+ if (cols[i] != i) {
+ /*printf("Rank %d, cols[i]=%lld, should be %d\n", rank, cols[i], i); */
+ errs++;
+ }
}
}
- }
- MTest_Finalize(errs);
- MPI_Finalize();
- return 0;
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
}
diff --git a/test/mpi/pt2pt/mprobe.c b/test/mpi/pt2pt/mprobe.c
index bc87d31..5804b18 100644
--- a/test/mpi/pt2pt/mprobe.c
+++ b/test/mpi/pt2pt/mprobe.c
@@ -277,7 +277,7 @@ int main(int argc, char **argv)
MPI_Imrecv(recvbuf, count, MPI_INT, &msg, &rreq);
check(rreq != MPI_REQUEST_NULL);
completed = 0;
- MPI_Test(&rreq, &completed, &s2); /* single test should always succeed */
+ MPI_Test(&rreq, &completed, &s2); /* single test should always succeed */
check(completed);
/* recvbuf should remain unmodified */
check(recvbuf[0] == 0x01234567);
@@ -351,7 +351,7 @@ int main(int argc, char **argv)
MPI_Imrecv(recvbuf, count, MPI_INT, &msg, &rreq);
check(rreq != MPI_REQUEST_NULL);
completed = 0;
- MPI_Test(&rreq, &completed, &s2); /* single test should always succeed */
+ MPI_Test(&rreq, &completed, &s2); /* single test should always succeed */
check(completed);
/* recvbuf should remain unmodified */
check(recvbuf[0] == 0x01234567);
@@ -531,9 +531,9 @@ int main(int argc, char **argv)
sendbuf[3] = 0xfeedface;
sendbuf[4] = 0xdeadbeef;
sendbuf[5] = 0xfeedface;
- MPI_Isend(&sendbuf[0], 4, MPI_INT, 1, 6, MPI_COMM_WORLD,&lrequest[0]);
- MPI_Isend(&sendbuf[4], 2, MPI_INT, 1, 6, MPI_COMM_WORLD,&lrequest[1]);
- MPI_Waitall(2, &lrequest[0],MPI_STATUSES_IGNORE);
+ MPI_Isend(&sendbuf[0], 4, MPI_INT, 1, 6, MPI_COMM_WORLD, &lrequest[0]);
+ MPI_Isend(&sendbuf[4], 2, MPI_INT, 1, 6, MPI_COMM_WORLD, &lrequest[1]);
+ MPI_Waitall(2, &lrequest[0], MPI_STATUSES_IGNORE);
}
else {
memset(&s1, 0xab, sizeof(MPI_Status));
@@ -561,10 +561,10 @@ int main(int argc, char **argv)
check(recvbuf[0] == 0xdeadbeef);
check(recvbuf[1] == 0xfeedface);
- recvbuf[0] = 0x01234567;
- recvbuf[1] = 0x89abcdef;
- recvbuf[2] = 0x01234567;
- recvbuf[3] = 0x89abcdef;
+ recvbuf[0] = 0x01234567;
+ recvbuf[1] = 0x89abcdef;
+ recvbuf[2] = 0x01234567;
+ recvbuf[3] = 0x89abcdef;
s2.MPI_ERROR = MPI_ERR_TOPOLOGY;
MPI_Mrecv(recvbuf, count, MPI_INT, &msg, &s2);
@@ -605,7 +605,7 @@ int main(int argc, char **argv)
#endif /* TEST_MPROBE_ROUTINES */
-epilogue:
+ epilogue:
MPI_Reduce((rank == 0 ? MPI_IN_PLACE : &errs), &errs, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
if (rank == 0) {
if (errs) {
@@ -620,4 +620,3 @@ epilogue:
return 0;
}
-
diff --git a/test/mpi/pt2pt/pingping.c b/test/mpi/pt2pt/pingping.c
index d8646f7..6331557 100644
--- a/test/mpi/pt2pt/pingping.c
+++ b/test/mpi/pt2pt/pingping.c
@@ -14,105 +14,104 @@ static char MTEST_Descrip[] = "Send flood test";
#define MAX_MSG_SIZE 40000000
#define MAX_COUNT 4000
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int rank, size, source, dest;
- int minsize = 2, count, nmsg, maxmsg;
- MPI_Comm comm;
+ int minsize = 2, count, nmsg, maxmsg;
+ MPI_Comm comm;
MTestDatatype sendtype, recvtype;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- /* The following illustrates the use of the routines to
- run through a selection of communicators and datatypes.
- Use subsets of these for tests that do not involve combinations
- of communicators, datatypes, and counts of datatypes */
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
- /* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
- source = 0;
- dest = size - 1;
-
- /* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN );
+ /* The following illustrates the use of the routines to
+ * run through a selection of communicators and datatypes.
+ * Use subsets of these for tests that do not involve combinations
+ * of communicators, datatypes, and counts of datatypes */
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ /* Determine the sender and receiver */
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+ source = 0;
+ dest = size - 1;
- for (count = 1; count < MAX_COUNT; count = count * 2) {
+ /* To improve reporting of problems about operations, we
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN);
- /* To shorten test time, only run the default version of datatype tests
- * for comm world and run the minimum version for other communicators. */
- if (comm != MPI_COMM_WORLD) {
- MTestInitMinDatatypes();
- }
+ for (count = 1; count < MAX_COUNT; count = count * 2) {
+
+ /* To shorten test time, only run the default version of datatype tests
+ * for comm world and run the minimum version for other communicators. */
+ if (comm != MPI_COMM_WORLD) {
+ MTestInitMinDatatypes();
+ }
- while (MTestGetDatatypes( &sendtype, &recvtype, count )) {
- int nbytes;
- MPI_Type_size( sendtype.datatype, &nbytes );
+ while (MTestGetDatatypes(&sendtype, &recvtype, count)) {
+ int nbytes;
+ MPI_Type_size(sendtype.datatype, &nbytes);
- /* We may want to limit the total message size sent */
- if (nbytes > MAX_MSG_SIZE) {
- /* We do not need to free, as we haven't
- initialized any of the buffers (?) */
- continue;
- }
- maxmsg = MAX_COUNT - count;
- MTestPrintfMsg( 1, "Sending count = %d of sendtype %s of total size %d bytes\n",
- count, MTestGetDatatypeName( &sendtype ),
- nbytes*count );
- /* Make sure that everyone has a recv buffer */
- recvtype.InitBuf( &recvtype );
+ /* We may want to limit the total message size sent */
+ if (nbytes > MAX_MSG_SIZE) {
+ /* We do not need to free, as we haven't
+ * initialized any of the buffers (?) */
+ continue;
+ }
+ maxmsg = MAX_COUNT - count;
+ MTestPrintfMsg(1, "Sending count = %d of sendtype %s of total size %d bytes\n",
+ count, MTestGetDatatypeName(&sendtype), nbytes * count);
+ /* Make sure that everyone has a recv buffer */
+ recvtype.InitBuf(&recvtype);
- if (rank == source) {
- sendtype.InitBuf( &sendtype );
-
- for (nmsg=1; nmsg<maxmsg; nmsg++) {
- err = MPI_Send( sendtype.buf, sendtype.count,
- sendtype.datatype, dest, 0, comm);
- if (err) {
- errs++;
- if (errs < 10) {
- MTestPrintError( err );
- }
- }
- }
- }
- else if (rank == dest) {
- for (nmsg=1; nmsg<maxmsg; nmsg++) {
- err = MPI_Recv( recvtype.buf, recvtype.count,
- recvtype.datatype, source, 0,
- comm, MPI_STATUS_IGNORE);
- if (err) {
- errs++;
- if (errs < 10) {
- MTestPrintError( err );
- }
- }
+ if (rank == source) {
+ sendtype.InitBuf(&sendtype);
- err = MTestCheckRecv( 0, &recvtype );
- if (err) {
- if (errs < 10) {
- printf( "Data in target buffer did not match for destination datatype %s and source datatype %s, count = %d, message iteration %d of %d\n",
- MTestGetDatatypeName( &recvtype ),
- MTestGetDatatypeName( &sendtype ),
- count, nmsg, maxmsg );
- recvtype.printErrors = 1;
- (void)MTestCheckRecv( 0, &recvtype );
- }
- errs += err;
- }
- }
- }
- MTestFreeDatatype( &recvtype );
- MTestFreeDatatype( &sendtype );
- }
- }
- MTestFreeComm( &comm );
+ for (nmsg = 1; nmsg < maxmsg; nmsg++) {
+ err = MPI_Send(sendtype.buf, sendtype.count,
+ sendtype.datatype, dest, 0, comm);
+ if (err) {
+ errs++;
+ if (errs < 10) {
+ MTestPrintError(err);
+ }
+ }
+ }
+ }
+ else if (rank == dest) {
+ for (nmsg = 1; nmsg < maxmsg; nmsg++) {
+ err = MPI_Recv(recvtype.buf, recvtype.count,
+ recvtype.datatype, source, 0, comm, MPI_STATUS_IGNORE);
+ if (err) {
+ errs++;
+ if (errs < 10) {
+ MTestPrintError(err);
+ }
+ }
+
+ err = MTestCheckRecv(0, &recvtype);
+ if (err) {
+ if (errs < 10) {
+ printf
+ ("Data in target buffer did not match for destination datatype %s and source datatype %s, count = %d, message iteration %d of %d\n",
+ MTestGetDatatypeName(&recvtype),
+ MTestGetDatatypeName(&sendtype), count, nmsg, maxmsg);
+ recvtype.printErrors = 1;
+ (void) MTestCheckRecv(0, &recvtype);
+ }
+ errs += err;
+ }
+ }
+ }
+ MTestFreeDatatype(&recvtype);
+ MTestFreeDatatype(&sendtype);
+ }
+ }
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/pt2pt/probe-unexp.c b/test/mpi/pt2pt/probe-unexp.c
index 43e2ed8..358d67c 100644
--- a/test/mpi/pt2pt/probe-unexp.c
+++ b/test/mpi/pt2pt/probe-unexp.c
@@ -11,7 +11,7 @@
#define NUM_MSGS_PER_BUF_SIZE 5
char buf[1 << MAX_BUF_SIZE_LG];
-/*
+/*
* This program verifies that MPI_Probe() is operating properly in the face of
* unexpected messages arriving after MPI_Probe() has
* been called. This program may hang if MPI_Probe() does not return when the
@@ -24,137 +24,123 @@ int main(int argc, char **argv)
int msg_size_lg;
int errs = 0;
int mpi_errno;
-
+
MTest_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &p_size);
MPI_Comm_rank(MPI_COMM_WORLD, &p_rank);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
-
-
- for (msg_size_lg = 0; msg_size_lg <= MAX_BUF_SIZE_LG; msg_size_lg++)
- {
- const int msg_size = 1 << msg_size_lg;
- int msg_cnt;
-
- MTestPrintfMsg( 2, "testing messages of size %d\n", msg_size );
- for (msg_cnt = 0; msg_cnt < NUM_MSGS_PER_BUF_SIZE; msg_cnt++)
- {
- MPI_Status status;
- const int tag = msg_size_lg * NUM_MSGS_PER_BUF_SIZE + msg_cnt;
-
- MTestPrintfMsg( 2, "Message count %d\n", msg_cnt );
- if (p_rank == 0)
- {
- int p;
-
- for (p = 1; p < p_size; p ++)
- {
- /* Wait for synchronization message */
- mpi_errno = MPI_Recv(NULL, 0, MPI_BYTE, MPI_ANY_SOURCE,
- tag, MPI_COMM_WORLD, &status);
- if (mpi_errno != MPI_SUCCESS && errs++ < 10)
- {
- MTestPrintError(mpi_errno);
- }
-
- if (status.MPI_TAG != tag && errs++ < 10)
- {
- printf("ERROR: unexpected message tag from MPI_Recv(): lp=0, rp=%d, expected=%d, actual=%d, count=%d\n",
- status.MPI_SOURCE, status.MPI_TAG, tag, msg_cnt);
- }
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+
+
+ for (msg_size_lg = 0; msg_size_lg <= MAX_BUF_SIZE_LG; msg_size_lg++) {
+ const int msg_size = 1 << msg_size_lg;
+ int msg_cnt;
+
+ MTestPrintfMsg(2, "testing messages of size %d\n", msg_size);
+ for (msg_cnt = 0; msg_cnt < NUM_MSGS_PER_BUF_SIZE; msg_cnt++) {
+ MPI_Status status;
+ const int tag = msg_size_lg * NUM_MSGS_PER_BUF_SIZE + msg_cnt;
+
+ MTestPrintfMsg(2, "Message count %d\n", msg_cnt);
+ if (p_rank == 0) {
+ int p;
+
+ for (p = 1; p < p_size; p++) {
+ /* Wait for synchronization message */
+ mpi_errno = MPI_Recv(NULL, 0, MPI_BYTE, MPI_ANY_SOURCE,
+ tag, MPI_COMM_WORLD, &status);
+ if (mpi_errno != MPI_SUCCESS && errs++ < 10) {
+ MTestPrintError(mpi_errno);
+ }
+
+ if (status.MPI_TAG != tag && errs++ < 10) {
+ printf
+ ("ERROR: unexpected message tag from MPI_Recv(): lp=0, rp=%d, expected=%d, actual=%d, count=%d\n",
+ status.MPI_SOURCE, status.MPI_TAG, tag, msg_cnt);
+ }
# if defined(VERBOSE)
- {
- printf("sending message: p=%d s=%d c=%d\n",
- status.MPI_SOURCE, msg_size, msg_cnt);
- }
+ {
+ printf("sending message: p=%d s=%d c=%d\n",
+ status.MPI_SOURCE, msg_size, msg_cnt);
+ }
# endif
-
- /* Send unexpected message which hopefully MPI_Probe() is
- already waiting for at the remote process */
- mpi_errno = MPI_Send (buf, msg_size, MPI_BYTE,
- status.MPI_SOURCE, status.MPI_TAG, MPI_COMM_WORLD);
- if (mpi_errno != MPI_SUCCESS && errs++ < 10)
- {
- MTestPrintError(mpi_errno);
- }
- }
- }
- else
- {
- int incoming_msg_size;
-
- /* Send synchronization message */
- mpi_errno = MPI_Send(NULL, 0, MPI_BYTE, 0, tag, MPI_COMM_WORLD);
- if (mpi_errno != MPI_SUCCESS && errs++ < 10)
- {
- MTestPrintError(mpi_errno);
- }
-
- /* Perform probe, hopefully before the master process can
- send its reply */
- mpi_errno = MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG,
- MPI_COMM_WORLD, &status);
- if (mpi_errno != MPI_SUCCESS && errs++ < 10)
- {
- MTestPrintError(mpi_errno);
- }
- mpi_errno = MPI_Get_count(&status, MPI_BYTE, &incoming_msg_size);
- if (mpi_errno != MPI_SUCCESS && errs++ < 10)
- {
- MTestPrintError(mpi_errno);
- }
- if (status.MPI_SOURCE != 0 && errs++ < 10)
- {
- printf("ERROR: unexpected message source from MPI_Probe(): p=%d, expected=0, actual=%d, count=%d\n",
- p_rank, status.MPI_SOURCE, msg_cnt);
- }
- if (status.MPI_TAG != tag && errs++ < 10)
- {
- printf("ERROR: unexpected message tag from MPI_Probe(): p=%d, expected=%d, actual=%d, count=%d\n",
- p_rank, tag, status.MPI_TAG, msg_cnt);
- }
- if (incoming_msg_size != msg_size && errs++ < 10)
- {
- printf("ERROR: unexpected message size from MPI_Probe(): p=%d, expected=%d, actual=%d, count=%d\n",
- p_rank, msg_size, incoming_msg_size, msg_cnt);
- }
-
- /* Receive the probed message from the master process */
- mpi_errno = MPI_Recv(buf, msg_size, MPI_BYTE, 0, tag,
- MPI_COMM_WORLD, &status);
- if (mpi_errno != MPI_SUCCESS && errs++ < 10)
- {
- MTestPrintError(mpi_errno);
- }
- mpi_errno = MPI_Get_count(&status, MPI_BYTE, &incoming_msg_size);
- if (mpi_errno != MPI_SUCCESS && errs++ < 10)
- {
- MTestPrintError(mpi_errno);
- }
- if (status.MPI_SOURCE != 0 && errs++ < 10)
- {
- printf("ERROR: unexpected message source from MPI_Recv(): p=%d, expected=0, actual=%d, count=%d\n",
- p_rank, status.MPI_SOURCE, msg_cnt);
- }
- if (status.MPI_TAG != tag && errs++ < 10)
- {
- printf("ERROR: unexpected message tag from MPI_Recv(): p=%d, expected=%d, actual=%d, count=%d\n",
- p_rank, tag, status.MPI_TAG, msg_cnt);
- }
- if (incoming_msg_size != msg_size && errs++ < 10)
- {
- printf("ERROR: unexpected message size from MPI_Recv(): p=%d, expected=%d, actual=%d, count=%d\n",
- p_rank, msg_size, incoming_msg_size, msg_cnt);
- }
- }
- }
+
+ /* Send unexpected message which hopefully MPI_Probe() is
+ * already waiting for at the remote process */
+ mpi_errno = MPI_Send(buf, msg_size, MPI_BYTE,
+ status.MPI_SOURCE, status.MPI_TAG, MPI_COMM_WORLD);
+ if (mpi_errno != MPI_SUCCESS && errs++ < 10) {
+ MTestPrintError(mpi_errno);
+ }
+ }
+ }
+ else {
+ int incoming_msg_size;
+
+ /* Send synchronization message */
+ mpi_errno = MPI_Send(NULL, 0, MPI_BYTE, 0, tag, MPI_COMM_WORLD);
+ if (mpi_errno != MPI_SUCCESS && errs++ < 10) {
+ MTestPrintError(mpi_errno);
+ }
+
+ /* Perform probe, hopefully before the master process can
+ * send its reply */
+ mpi_errno = MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
+ if (mpi_errno != MPI_SUCCESS && errs++ < 10) {
+ MTestPrintError(mpi_errno);
+ }
+ mpi_errno = MPI_Get_count(&status, MPI_BYTE, &incoming_msg_size);
+ if (mpi_errno != MPI_SUCCESS && errs++ < 10) {
+ MTestPrintError(mpi_errno);
+ }
+ if (status.MPI_SOURCE != 0 && errs++ < 10) {
+ printf
+ ("ERROR: unexpected message source from MPI_Probe(): p=%d, expected=0, actual=%d, count=%d\n",
+ p_rank, status.MPI_SOURCE, msg_cnt);
+ }
+ if (status.MPI_TAG != tag && errs++ < 10) {
+ printf
+ ("ERROR: unexpected message tag from MPI_Probe(): p=%d, expected=%d, actual=%d, count=%d\n",
+ p_rank, tag, status.MPI_TAG, msg_cnt);
+ }
+ if (incoming_msg_size != msg_size && errs++ < 10) {
+ printf
+ ("ERROR: unexpected message size from MPI_Probe(): p=%d, expected=%d, actual=%d, count=%d\n",
+ p_rank, msg_size, incoming_msg_size, msg_cnt);
+ }
+
+ /* Receive the probed message from the master process */
+ mpi_errno = MPI_Recv(buf, msg_size, MPI_BYTE, 0, tag, MPI_COMM_WORLD, &status);
+ if (mpi_errno != MPI_SUCCESS && errs++ < 10) {
+ MTestPrintError(mpi_errno);
+ }
+ mpi_errno = MPI_Get_count(&status, MPI_BYTE, &incoming_msg_size);
+ if (mpi_errno != MPI_SUCCESS && errs++ < 10) {
+ MTestPrintError(mpi_errno);
+ }
+ if (status.MPI_SOURCE != 0 && errs++ < 10) {
+ printf
+ ("ERROR: unexpected message source from MPI_Recv(): p=%d, expected=0, actual=%d, count=%d\n",
+ p_rank, status.MPI_SOURCE, msg_cnt);
+ }
+ if (status.MPI_TAG != tag && errs++ < 10) {
+ printf
+ ("ERROR: unexpected message tag from MPI_Recv(): p=%d, expected=%d, actual=%d, count=%d\n",
+ p_rank, tag, status.MPI_TAG, msg_cnt);
+ }
+ if (incoming_msg_size != msg_size && errs++ < 10) {
+ printf
+ ("ERROR: unexpected message size from MPI_Recv(): p=%d, expected=%d, actual=%d, count=%d\n",
+ p_rank, msg_size, incoming_msg_size, msg_cnt);
+ }
+ }
+ }
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/pt2pt/probenull.c b/test/mpi/pt2pt/probenull.c
index 5479605..6ff8799 100644
--- a/test/mpi/pt2pt/probenull.c
+++ b/test/mpi/pt2pt/probenull.c
@@ -7,7 +7,7 @@
#include "mpi.h"
#include "mpitest.h"
-/*
+/*
* This program checks that MPI_Iprobe and MPI_Probe correctly handle
* a source of MPI_PROC_NULL
*/
@@ -20,40 +20,36 @@ int main(int argc, char **argv)
MTest_Init(&argc, &argv);
- MPI_Iprobe( MPI_PROC_NULL, 10, MPI_COMM_WORLD, &flag, &status );
+ MPI_Iprobe(MPI_PROC_NULL, 10, MPI_COMM_WORLD, &flag, &status);
if (!flag) {
- errs++;
- printf( "Iprobe of source=MPI_PROC_NULL returned flag=false\n" );
+ errs++;
+ printf("Iprobe of source=MPI_PROC_NULL returned flag=false\n");
}
else {
- if (status.MPI_SOURCE != MPI_PROC_NULL) {
- printf( "Status.MPI_SOURCE was %d, should be MPI_PROC_NULL\n",
- status.MPI_SOURCE );
- errs++;
- }
- if (status.MPI_TAG != MPI_ANY_TAG) {
- printf( "Status.MPI_TAG was %d, should be MPI_ANY_TAGL\n",
- status.MPI_TAG );
- errs++;
- }
+ if (status.MPI_SOURCE != MPI_PROC_NULL) {
+ printf("Status.MPI_SOURCE was %d, should be MPI_PROC_NULL\n", status.MPI_SOURCE);
+ errs++;
+ }
+ if (status.MPI_TAG != MPI_ANY_TAG) {
+ printf("Status.MPI_TAG was %d, should be MPI_ANY_TAGL\n", status.MPI_TAG);
+ errs++;
+ }
}
- /* If Iprobe failed, probe is likely to as well. Avoid a possible hang
- by testing Probe only if Iprobe test passed */
+ /* If Iprobe failed, probe is likely to as well. Avoid a possible hang
+ * by testing Probe only if Iprobe test passed */
if (errs == 0) {
- MPI_Probe( MPI_PROC_NULL, 10, MPI_COMM_WORLD, &status );
- if (status.MPI_SOURCE != MPI_PROC_NULL) {
- printf( "Status.MPI_SOURCE was %d, should be MPI_PROC_NULL\n",
- status.MPI_SOURCE );
- errs++;
- }
- if (status.MPI_TAG != MPI_ANY_TAG) {
- printf( "Status.MPI_TAG was %d, should be MPI_ANY_TAGL\n",
- status.MPI_TAG );
- errs++;
- }
+ MPI_Probe(MPI_PROC_NULL, 10, MPI_COMM_WORLD, &status);
+ if (status.MPI_SOURCE != MPI_PROC_NULL) {
+ printf("Status.MPI_SOURCE was %d, should be MPI_PROC_NULL\n", status.MPI_SOURCE);
+ errs++;
+ }
+ if (status.MPI_TAG != MPI_ANY_TAG) {
+ printf("Status.MPI_TAG was %d, should be MPI_ANY_TAGL\n", status.MPI_TAG);
+ errs++;
+ }
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/pt2pt/pscancel.c b/test/mpi/pt2pt/pscancel.c
index 49714c9..1938dad 100644
--- a/test/mpi/pt2pt/pscancel.c
+++ b/test/mpi/pt2pt/pscancel.c
@@ -12,262 +12,246 @@
static char MTEST_Descrip[] = "Test of various send cancel calls";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size, source, dest;
- MPI_Comm comm;
- MPI_Status status;
- MPI_Request req;
+ MPI_Comm comm;
+ MPI_Status status;
+ MPI_Request req;
static int bufsizes[4] = { 1, 100, 10000, 1000000 };
char *buf;
- int cs, flag, n;
+ int cs, flag, n;
#ifdef TEST_IRSEND
- int veryPicky = 0; /* Set to 1 to test "quality of implementation" in
- a tricky part of cancel */
+ int veryPicky = 0; /* Set to 1 to test "quality of implementation" in
+ * a tricky part of cancel */
#endif
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
source = 0;
- dest = size - 1;
+ dest = size - 1;
- for (cs=0; cs<4; cs++) {
- if (rank == 0) {
- n = bufsizes[cs];
- buf = (char *)malloc( n );
- if (!buf) {
- fprintf( stderr, "Unable to allocate %d bytes\n", n );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- MPI_Send_init( buf, n, MPI_CHAR, dest, cs+n+1, comm, &req );
- MPI_Start( &req );
- MPI_Cancel( &req );
- MPI_Wait( &req, &status );
- MPI_Test_cancelled( &status, &flag );
- if (!flag) {
- errs ++;
- printf( "Failed to cancel a persistent send request\n" );
- fflush(stdout);
- }
- else
- {
- n = 0;
- }
- MPI_Request_free( &req );
- /* Send the size, zero for successfully cancelled */
- MPI_Send( &n, 1, MPI_INT, dest, 123, comm );
- /* Send the tag so the message can be received */
- n = cs+n+1;
- MPI_Send( &n, 1, MPI_INT, dest, 123, comm );
- free( buf );
- }
- else if (rank == dest)
- {
- int nn, tag;
- char *btemp;
- MPI_Recv( &nn, 1, MPI_INT, 0, 123, comm, &status );
- MPI_Recv( &tag, 1, MPI_INT, 0, 123, comm, &status );
- if (nn > 0)
- {
- /* If the message was not cancelled, receive it here */
- btemp = (char*)malloc( nn );
- if (!btemp)
- {
- fprintf( stderr, "Unable to allocate %d bytes\n", nn);
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- MPI_Recv( btemp, nn, MPI_CHAR, 0, tag, comm, &status );
- free(btemp);
- }
- }
- MPI_Barrier( comm );
+ for (cs = 0; cs < 4; cs++) {
+ if (rank == 0) {
+ n = bufsizes[cs];
+ buf = (char *) malloc(n);
+ if (!buf) {
+ fprintf(stderr, "Unable to allocate %d bytes\n", n);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ MPI_Send_init(buf, n, MPI_CHAR, dest, cs + n + 1, comm, &req);
+ MPI_Start(&req);
+ MPI_Cancel(&req);
+ MPI_Wait(&req, &status);
+ MPI_Test_cancelled(&status, &flag);
+ if (!flag) {
+ errs++;
+ printf("Failed to cancel a persistent send request\n");
+ fflush(stdout);
+ }
+ else {
+ n = 0;
+ }
+ MPI_Request_free(&req);
+ /* Send the size, zero for successfully cancelled */
+ MPI_Send(&n, 1, MPI_INT, dest, 123, comm);
+ /* Send the tag so the message can be received */
+ n = cs + n + 1;
+ MPI_Send(&n, 1, MPI_INT, dest, 123, comm);
+ free(buf);
+ }
+ else if (rank == dest) {
+ int nn, tag;
+ char *btemp;
+ MPI_Recv(&nn, 1, MPI_INT, 0, 123, comm, &status);
+ MPI_Recv(&tag, 1, MPI_INT, 0, 123, comm, &status);
+ if (nn > 0) {
+ /* If the message was not cancelled, receive it here */
+ btemp = (char *) malloc(nn);
+ if (!btemp) {
+ fprintf(stderr, "Unable to allocate %d bytes\n", nn);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ MPI_Recv(btemp, nn, MPI_CHAR, 0, tag, comm, &status);
+ free(btemp);
+ }
+ }
+ MPI_Barrier(comm);
- if (rank == 0) {
- char *bsendbuf;
- int bsendbufsize;
- int bf, bs;
- n = bufsizes[cs];
- buf = (char *)malloc( n );
- if (!buf) {
- fprintf( stderr, "Unable to allocate %d bytes\n", n );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- bsendbufsize = n + MPI_BSEND_OVERHEAD;
- bsendbuf = (char *)malloc( bsendbufsize );
- if (!bsendbuf) {
- fprintf( stderr, "Unable to allocate %d bytes for bsend\n", n );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- MPI_Buffer_attach( bsendbuf, bsendbufsize );
- MPI_Bsend_init( buf, n, MPI_CHAR, dest, cs+n+2, comm, &req );
- MPI_Start( &req );
- MPI_Cancel( &req );
- MPI_Wait( &req, &status );
- MPI_Test_cancelled( &status, &flag );
- if (!flag) {
- errs ++;
- printf( "Failed to cancel a persistent bsend request\n" );
- fflush(stdout);
- }
- else
- {
- n = 0;
- }
- MPI_Request_free( &req );
- /* Send the size, zero for successfully cancelled */
- MPI_Send( &n, 1, MPI_INT, dest, 123, comm );
- /* Send the tag so the message can be received */
- n = cs+n+2;
- MPI_Send( &n, 1, MPI_INT, dest, 123, comm );
- free( buf );
- MPI_Buffer_detach( &bf, &bs );
- free( bsendbuf );
- }
- else if (rank == dest)
- {
- int nn, tag;
- char *btemp;
- MPI_Recv( &nn, 1, MPI_INT, 0, 123, comm, &status );
- MPI_Recv( &tag, 1, MPI_INT, 0, 123, comm, &status );
- if (nn > 0)
- {
- /* If the message was not cancelled, receive it here */
- btemp = (char*)malloc( nn );
- if (!btemp)
- {
- fprintf( stderr, "Unable to allocate %d bytes\n", nn);
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- MPI_Recv( btemp, nn, MPI_CHAR, 0, tag, comm, &status );
- free(btemp);
- }
- }
- MPI_Barrier( comm );
+ if (rank == 0) {
+ char *bsendbuf;
+ int bsendbufsize;
+ int bf, bs;
+ n = bufsizes[cs];
+ buf = (char *) malloc(n);
+ if (!buf) {
+ fprintf(stderr, "Unable to allocate %d bytes\n", n);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ bsendbufsize = n + MPI_BSEND_OVERHEAD;
+ bsendbuf = (char *) malloc(bsendbufsize);
+ if (!bsendbuf) {
+ fprintf(stderr, "Unable to allocate %d bytes for bsend\n", n);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ MPI_Buffer_attach(bsendbuf, bsendbufsize);
+ MPI_Bsend_init(buf, n, MPI_CHAR, dest, cs + n + 2, comm, &req);
+ MPI_Start(&req);
+ MPI_Cancel(&req);
+ MPI_Wait(&req, &status);
+ MPI_Test_cancelled(&status, &flag);
+ if (!flag) {
+ errs++;
+ printf("Failed to cancel a persistent bsend request\n");
+ fflush(stdout);
+ }
+ else {
+ n = 0;
+ }
+ MPI_Request_free(&req);
+ /* Send the size, zero for successfully cancelled */
+ MPI_Send(&n, 1, MPI_INT, dest, 123, comm);
+ /* Send the tag so the message can be received */
+ n = cs + n + 2;
+ MPI_Send(&n, 1, MPI_INT, dest, 123, comm);
+ free(buf);
+ MPI_Buffer_detach(&bf, &bs);
+ free(bsendbuf);
+ }
+ else if (rank == dest) {
+ int nn, tag;
+ char *btemp;
+ MPI_Recv(&nn, 1, MPI_INT, 0, 123, comm, &status);
+ MPI_Recv(&tag, 1, MPI_INT, 0, 123, comm, &status);
+ if (nn > 0) {
+ /* If the message was not cancelled, receive it here */
+ btemp = (char *) malloc(nn);
+ if (!btemp) {
+ fprintf(stderr, "Unable to allocate %d bytes\n", nn);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ MPI_Recv(btemp, nn, MPI_CHAR, 0, tag, comm, &status);
+ free(btemp);
+ }
+ }
+ MPI_Barrier(comm);
- /* Because this test is erroneous, we do not perform it unless
- TEST_IRSEND is defined. */
+ /* Because this test is erroneous, we do not perform it unless
+ * TEST_IRSEND is defined. */
#ifdef TEST_IRSEND
- /* We avoid ready send to self because an implementation
- is free to detect the error in delivering a message to
- itself without a pending receive; we could also check
- for an error return from the MPI_Irsend */
- if (rank == 0 && dest != rank) {
- n = bufsizes[cs];
- buf = (char *)malloc( n );
- if (!buf) {
- fprintf( stderr, "Unable to allocate %d bytes\n", n );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- MPI_Rsend_init( buf, n, MPI_CHAR, dest, cs+n+3, comm, &req );
- MPI_Start( &req );
- MPI_Cancel( &req );
- MPI_Wait( &req, &status );
- MPI_Test_cancelled( &status, &flag );
- /* This can be pretty ugly. The standard is clear (Section 3.8)
- that either a sent message is received or the
- sent message is successfully cancelled. Since this message
- can never be received, the cancel must complete
- successfully.
-
- However, since there is no matching receive, this
- program is erroneous. In this case, we can't really
- flag this as an error */
- if (!flag && veryPicky) {
- errs ++;
- printf( "Failed to cancel a persistent rsend request\n" );
- fflush(stdout);
- }
- if (flag)
- {
- n = 0;
- }
- MPI_Request_free( &req );
- /* Send the size, zero for successfully cancelled */
- MPI_Send( &n, 1, MPI_INT, dest, 123, comm );
- /* Send the tag so the message can be received */
- n = cs+n+3;
- MPI_Send( &n, 1, MPI_INT, dest, 123, comm );
- free( buf );
- }
- else if (rank == dest)
- {
- int n, tag;
- char *btemp;
- MPI_Recv( &n, 1, MPI_INT, 0, 123, comm, &status );
- MPI_Recv( &tag, 1, MPI_INT, 0, 123, comm, &status );
- if (n > 0)
- {
- /* If the message was not cancelled, receive it here */
- btemp = (char*)malloc( n );
- if (!btemp)
- {
- fprintf( stderr, "Unable to allocate %d bytes\n", n);
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- MPI_Recv( btemp, n, MPI_CHAR, 0, tag, comm, &status );
- free(btemp);
- }
- }
- MPI_Barrier( comm );
+ /* We avoid ready send to self because an implementation
+ * is free to detect the error in delivering a message to
+ * itself without a pending receive; we could also check
+ * for an error return from the MPI_Irsend */
+ if (rank == 0 && dest != rank) {
+ n = bufsizes[cs];
+ buf = (char *) malloc(n);
+ if (!buf) {
+ fprintf(stderr, "Unable to allocate %d bytes\n", n);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ MPI_Rsend_init(buf, n, MPI_CHAR, dest, cs + n + 3, comm, &req);
+ MPI_Start(&req);
+ MPI_Cancel(&req);
+ MPI_Wait(&req, &status);
+ MPI_Test_cancelled(&status, &flag);
+ /* This can be pretty ugly. The standard is clear (Section 3.8)
+ * that either a sent message is received or the
+ * sent message is successfully cancelled. Since this message
+ * can never be received, the cancel must complete
+ * successfully.
+ *
+ * However, since there is no matching receive, this
+ * program is erroneous. In this case, we can't really
+ * flag this as an error */
+ if (!flag && veryPicky) {
+ errs++;
+ printf("Failed to cancel a persistent rsend request\n");
+ fflush(stdout);
+ }
+ if (flag) {
+ n = 0;
+ }
+ MPI_Request_free(&req);
+ /* Send the size, zero for successfully cancelled */
+ MPI_Send(&n, 1, MPI_INT, dest, 123, comm);
+ /* Send the tag so the message can be received */
+ n = cs + n + 3;
+ MPI_Send(&n, 1, MPI_INT, dest, 123, comm);
+ free(buf);
+ }
+ else if (rank == dest) {
+ int n, tag;
+ char *btemp;
+ MPI_Recv(&n, 1, MPI_INT, 0, 123, comm, &status);
+ MPI_Recv(&tag, 1, MPI_INT, 0, 123, comm, &status);
+ if (n > 0) {
+ /* If the message was not cancelled, receive it here */
+ btemp = (char *) malloc(n);
+ if (!btemp) {
+ fprintf(stderr, "Unable to allocate %d bytes\n", n);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ MPI_Recv(btemp, n, MPI_CHAR, 0, tag, comm, &status);
+ free(btemp);
+ }
+ }
+ MPI_Barrier(comm);
#endif
- if (rank == 0) {
- n = bufsizes[cs];
- buf = (char *)malloc( n );
- if (!buf) {
- fprintf( stderr, "Unable to allocate %d bytes\n", n );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- MPI_Ssend_init( buf, n, MPI_CHAR, dest, cs+n+4, comm, &req );
- MPI_Start( &req );
- MPI_Cancel( &req );
- MPI_Wait( &req, &status );
- MPI_Test_cancelled( &status, &flag );
- if (!flag) {
- errs ++;
- printf( "Failed to cancel a persistent ssend request\n" );
- fflush(stdout);
- }
- else
- {
- n = 0;
- }
- MPI_Request_free( &req );
- /* Send the size, zero for successfully cancelled */
- MPI_Send( &n, 1, MPI_INT, dest, 123, comm );
- /* Send the tag so the message can be received */
- n = cs+n+4;
- MPI_Send( &n, 1, MPI_INT, dest, 123, comm );
- free( buf );
- }
- else if (rank == dest)
- {
- int nn, tag;
- char *btemp;
- MPI_Recv( &nn, 1, MPI_INT, 0, 123, comm, &status );
- MPI_Recv( &tag, 1, MPI_INT, 0, 123, comm, &status );
- if (nn > 0)
- {
- /* If the message was not cancelled, receive it here */
- btemp = (char*)malloc( nn );
- if (!btemp)
- {
- fprintf( stderr, "Unable to allocate %d bytes\n", nn);
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- MPI_Recv( btemp, nn, MPI_CHAR, 0, tag, comm, &status );
- free(btemp);
- }
- }
- MPI_Barrier( comm );
+ if (rank == 0) {
+ n = bufsizes[cs];
+ buf = (char *) malloc(n);
+ if (!buf) {
+ fprintf(stderr, "Unable to allocate %d bytes\n", n);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ MPI_Ssend_init(buf, n, MPI_CHAR, dest, cs + n + 4, comm, &req);
+ MPI_Start(&req);
+ MPI_Cancel(&req);
+ MPI_Wait(&req, &status);
+ MPI_Test_cancelled(&status, &flag);
+ if (!flag) {
+ errs++;
+ printf("Failed to cancel a persistent ssend request\n");
+ fflush(stdout);
+ }
+ else {
+ n = 0;
+ }
+ MPI_Request_free(&req);
+ /* Send the size, zero for successfully cancelled */
+ MPI_Send(&n, 1, MPI_INT, dest, 123, comm);
+ /* Send the tag so the message can be received */
+ n = cs + n + 4;
+ MPI_Send(&n, 1, MPI_INT, dest, 123, comm);
+ free(buf);
+ }
+ else if (rank == dest) {
+ int nn, tag;
+ char *btemp;
+ MPI_Recv(&nn, 1, MPI_INT, 0, 123, comm, &status);
+ MPI_Recv(&tag, 1, MPI_INT, 0, 123, comm, &status);
+ if (nn > 0) {
+ /* If the message was not cancelled, receive it here */
+ btemp = (char *) malloc(nn);
+ if (!btemp) {
+ fprintf(stderr, "Unable to allocate %d bytes\n", nn);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ MPI_Recv(btemp, nn, MPI_CHAR, 0, tag, comm, &status);
+ free(btemp);
+ }
+ }
+ MPI_Barrier(comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/pt2pt/rcancel.c b/test/mpi/pt2pt/rcancel.c
index 398ed9a..98122d5 100644
--- a/test/mpi/pt2pt/rcancel.c
+++ b/test/mpi/pt2pt/rcancel.c
@@ -12,75 +12,75 @@
static char MTEST_Descrip[] = "Test of various receive cancel calls, with multiple requests to cancel";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size, source, dest;
- MPI_Comm comm;
- MPI_Status status;
- MPI_Request req[4];
+ MPI_Comm comm;
+ MPI_Status status;
+ MPI_Request req[4];
static int bufsizes[4] = { 1, 100, 10000, 1000000 };
char *bufs[4];
- int flag, i;
+ int flag, i;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
source = 0;
- dest = size - 1;
+ dest = size - 1;
if (rank == source) {
- MPI_Send( MPI_BOTTOM, 0, MPI_CHAR, dest, 1, MPI_COMM_WORLD );
+ MPI_Send(MPI_BOTTOM, 0, MPI_CHAR, dest, 1, MPI_COMM_WORLD);
}
else if (rank == dest) {
- /* Create 3 requests to cancel, plus one to use.
- Then receive one message and exit */
- for (i=0; i<4; i++) {
- bufs[i] = (char *) malloc( bufsizes[i] );
- MPI_Irecv( bufs[i], bufsizes[i], MPI_CHAR, source,
- i, MPI_COMM_WORLD, &req[i] );
- }
- /* Now, cancel them in a more interesting order, to ensure that the
- queue operation work properly */
- MPI_Cancel( &req[2] );
- MPI_Wait( &req[2], &status );
- MTestPrintfMsg( 1, "Completed wait on irecv[2]\n" );
- MPI_Test_cancelled( &status, &flag );
- if (!flag) {
- errs ++;
- printf( "Failed to cancel a Irecv[2] request\n" );
- fflush(stdout);
- }
- MPI_Cancel( &req[3] );
- MPI_Wait( &req[3], &status );
- MTestPrintfMsg( 1, "Completed wait on irecv[3]\n" );
- MPI_Test_cancelled( &status, &flag );
- if (!flag) {
- errs ++;
- printf( "Failed to cancel a Irecv[3] request\n" );
- fflush(stdout);
- }
- MPI_Cancel( &req[0] );
- MPI_Wait( &req[0], &status );
- MTestPrintfMsg( 1, "Completed wait on irecv[0]\n" );
- MPI_Test_cancelled( &status, &flag );
- if (!flag) {
- errs ++;
- printf( "Failed to cancel a Irecv[0] request\n" );
- fflush(stdout);
- }
- MPI_Wait( &req[1], &status );
- MPI_Test_cancelled( &status, &flag );
- if (flag) {
- errs ++;
- printf( "Incorrectly cancelled Irecv[1]\n" ); fflush(stdout);
- }
+ /* Create 3 requests to cancel, plus one to use.
+ * Then receive one message and exit */
+ for (i = 0; i < 4; i++) {
+ bufs[i] = (char *) malloc(bufsizes[i]);
+ MPI_Irecv(bufs[i], bufsizes[i], MPI_CHAR, source, i, MPI_COMM_WORLD, &req[i]);
+ }
+ /* Now, cancel them in a more interesting order, to ensure that the
+ * queue operation work properly */
+ MPI_Cancel(&req[2]);
+ MPI_Wait(&req[2], &status);
+ MTestPrintfMsg(1, "Completed wait on irecv[2]\n");
+ MPI_Test_cancelled(&status, &flag);
+ if (!flag) {
+ errs++;
+ printf("Failed to cancel a Irecv[2] request\n");
+ fflush(stdout);
+ }
+ MPI_Cancel(&req[3]);
+ MPI_Wait(&req[3], &status);
+ MTestPrintfMsg(1, "Completed wait on irecv[3]\n");
+ MPI_Test_cancelled(&status, &flag);
+ if (!flag) {
+ errs++;
+ printf("Failed to cancel a Irecv[3] request\n");
+ fflush(stdout);
+ }
+ MPI_Cancel(&req[0]);
+ MPI_Wait(&req[0], &status);
+ MTestPrintfMsg(1, "Completed wait on irecv[0]\n");
+ MPI_Test_cancelled(&status, &flag);
+ if (!flag) {
+ errs++;
+ printf("Failed to cancel a Irecv[0] request\n");
+ fflush(stdout);
+ }
+ MPI_Wait(&req[1], &status);
+ MPI_Test_cancelled(&status, &flag);
+ if (flag) {
+ errs++;
+ printf("Incorrectly cancelled Irecv[1]\n");
+ fflush(stdout);
+ }
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/pt2pt/rqfreeb.c b/test/mpi/pt2pt/rqfreeb.c
index 1a6eab1..1c4f6a0 100644
--- a/test/mpi/pt2pt/rqfreeb.c
+++ b/test/mpi/pt2pt/rqfreeb.c
@@ -9,7 +9,7 @@
#include "mpitest.h"
/* Test Ibsend and Request_free */
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Comm comm = MPI_COMM_WORLD;
int dest = 1, src = 0, tag = 1;
@@ -19,103 +19,104 @@ int main( int argc, char *argv[] )
int errs = 0, rank, size;
int bufsize, bsize;
- MTest_Init( &argc, &argv );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ MTest_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
if (src >= size || dest >= size) {
- int r = src;
- if (dest > r) r = dest;
- fprintf( stderr, "This program requires %d processes\n", r-1 );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ int r = src;
+ if (dest > r)
+ r = dest;
+ fprintf(stderr, "This program requires %d processes\n", r - 1);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
if (rank == src) {
- MPI_Request r;
+ MPI_Request r;
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
- /* According to the standard, we must use the PACK_SIZE length of each
- message in the computation of the message buffer size */
- MPI_Pack_size( 5, MPI_INT, comm, &s1 );
- bufsize = MPI_BSEND_OVERHEAD + s1 + 2000;
- buf = (char *)malloc( bufsize );
- MPI_Buffer_attach( buf, bufsize );
+ /* According to the standard, we must use the PACK_SIZE length of each
+ * message in the computation of the message buffer size */
+ MPI_Pack_size(5, MPI_INT, comm, &s1);
+ bufsize = MPI_BSEND_OVERHEAD + s1 + 2000;
+ buf = (char *) malloc(bufsize);
+ MPI_Buffer_attach(buf, bufsize);
- MTestPrintfMsg( 10, "About create and free Isend request\n" );
- smsg[0] = 10;
- MPI_Isend( &smsg[0], 1, MPI_INT, dest, tag, comm, &r );
- MPI_Request_free( &r );
- if (r != MPI_REQUEST_NULL) {
- errs++;
- fprintf( stderr, "Request not set to NULL after request free\n" );
- }
- MTestPrintfMsg( 10, "About create and free Ibsend request\n" );
- smsg[1] = 11;
- MPI_Ibsend( &smsg[1], 1, MPI_INT, dest, tag+1, comm, &r );
- MPI_Request_free( &r );
- if (r != MPI_REQUEST_NULL) {
- errs++;
- fprintf( stderr, "Request not set to NULL after request free\n" );
- }
- MTestPrintfMsg( 10, "About create and free Issend request\n" );
- smsg[2] = 12;
- MPI_Issend( &smsg[2], 1, MPI_INT, dest, tag+2, comm, &r );
- MPI_Request_free( &r );
- if (r != MPI_REQUEST_NULL) {
- errs++;
- fprintf( stderr, "Request not set to NULL after request free\n" );
- }
- MTestPrintfMsg( 10, "About create and free Irsend request\n" );
- smsg[3] = 13;
- MPI_Irsend( &smsg[3], 1, MPI_INT, dest, tag+3, comm, &r );
- MPI_Request_free( &r );
- if (r != MPI_REQUEST_NULL) {
- errs++;
- fprintf( stderr, "Request not set to NULL after request free\n" );
- }
- smsg[4] = 14;
- MPI_Isend( &smsg[4], 1, MPI_INT, dest, tag+4, comm, &r );
- MPI_Wait( &r, MPI_STATUS_IGNORE );
+ MTestPrintfMsg(10, "About create and free Isend request\n");
+ smsg[0] = 10;
+ MPI_Isend(&smsg[0], 1, MPI_INT, dest, tag, comm, &r);
+ MPI_Request_free(&r);
+ if (r != MPI_REQUEST_NULL) {
+ errs++;
+ fprintf(stderr, "Request not set to NULL after request free\n");
+ }
+ MTestPrintfMsg(10, "About create and free Ibsend request\n");
+ smsg[1] = 11;
+ MPI_Ibsend(&smsg[1], 1, MPI_INT, dest, tag + 1, comm, &r);
+ MPI_Request_free(&r);
+ if (r != MPI_REQUEST_NULL) {
+ errs++;
+ fprintf(stderr, "Request not set to NULL after request free\n");
+ }
+ MTestPrintfMsg(10, "About create and free Issend request\n");
+ smsg[2] = 12;
+ MPI_Issend(&smsg[2], 1, MPI_INT, dest, tag + 2, comm, &r);
+ MPI_Request_free(&r);
+ if (r != MPI_REQUEST_NULL) {
+ errs++;
+ fprintf(stderr, "Request not set to NULL after request free\n");
+ }
+ MTestPrintfMsg(10, "About create and free Irsend request\n");
+ smsg[3] = 13;
+ MPI_Irsend(&smsg[3], 1, MPI_INT, dest, tag + 3, comm, &r);
+ MPI_Request_free(&r);
+ if (r != MPI_REQUEST_NULL) {
+ errs++;
+ fprintf(stderr, "Request not set to NULL after request free\n");
+ }
+ smsg[4] = 14;
+ MPI_Isend(&smsg[4], 1, MPI_INT, dest, tag + 4, comm, &r);
+ MPI_Wait(&r, MPI_STATUS_IGNORE);
- /* We can't guarantee that messages arrive until the detach */
- MPI_Buffer_detach( &bbuf, &bsize );
+ /* We can't guarantee that messages arrive until the detach */
+ MPI_Buffer_detach(&bbuf, &bsize);
}
if (rank == dest) {
- MPI_Request r[5];
- int i;
+ MPI_Request r[5];
+ int i;
- for (i=0; i<5; i++) {
- MPI_Irecv( &rmsg[i], 1, MPI_INT, src, tag+i, comm, &r[i] );
- }
- if (rank != src) /* Just in case rank == src */
- MPI_Barrier( MPI_COMM_WORLD );
+ for (i = 0; i < 5; i++) {
+ MPI_Irecv(&rmsg[i], 1, MPI_INT, src, tag + i, comm, &r[i]);
+ }
+ if (rank != src) /* Just in case rank == src */
+ MPI_Barrier(MPI_COMM_WORLD);
- for (i=0; i<4; i++) {
- MPI_Wait( &r[i], MPI_STATUS_IGNORE );
- if (rmsg[i] != 10+i) {
- errs++;
- fprintf( stderr, "message %d (%d) should be %d\n", i, rmsg[i], 10+i );
- }
- }
- /* The MPI standard says that there is no way to use MPI_Request_free
- safely with receive requests. A strict MPI implementation may
- choose to consider these erroreous (an IBM MPI implementation
- does so) */
+ for (i = 0; i < 4; i++) {
+ MPI_Wait(&r[i], MPI_STATUS_IGNORE);
+ if (rmsg[i] != 10 + i) {
+ errs++;
+ fprintf(stderr, "message %d (%d) should be %d\n", i, rmsg[i], 10 + i);
+ }
+ }
+ /* The MPI standard says that there is no way to use MPI_Request_free
+ * safely with receive requests. A strict MPI implementation may
+ * choose to consider these erroreous (an IBM MPI implementation
+ * does so) */
#ifdef USE_STRICT_MPI
- MPI_Wait( &r[4], MPI_STATUS_IGNORE );
+ MPI_Wait(&r[4], MPI_STATUS_IGNORE);
#else
- MTestPrintfMsg( 10, "About free Irecv request\n" );
- MPI_Request_free( &r[4] );
+ MTestPrintfMsg(10, "About free Irecv request\n");
+ MPI_Request_free(&r[4]);
#endif
}
if (rank != dest && rank != src) {
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
diff --git a/test/mpi/pt2pt/rqstatus.c b/test/mpi/pt2pt/rqstatus.c
index 102e9f8..304fcff 100644
--- a/test/mpi/pt2pt/rqstatus.c
+++ b/test/mpi/pt2pt/rqstatus.c
@@ -12,103 +12,102 @@
static char MTEST_Descrip[] = "Test Request_get_status";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size, source, dest;
int buf[2], flag, count;
- MPI_Comm comm;
- MPI_Status status, status2;
- MPI_Request req;
+ MPI_Comm comm;
+ MPI_Status status, status2;
+ MPI_Request req;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
/* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
source = 0;
- dest = size - 1;
+ dest = size - 1;
/* Handling MPI_REQUEST_NULL in MPI_Request_get_status was only required
- starting with MPI-2.2. */
+ * starting with MPI-2.2. */
#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
- MPI_Request_get_status( MPI_REQUEST_NULL, &flag, &status );
+ MPI_Request_get_status(MPI_REQUEST_NULL, &flag, &status);
if (!flag) {
errs++;
- fprintf( stderr, "flag not true for MPI_REQUEST_NULL, flag=%d\n", flag );
+ fprintf(stderr, "flag not true for MPI_REQUEST_NULL, flag=%d\n", flag);
}
if ((status.MPI_SOURCE != MPI_ANY_SOURCE) ||
- (status.MPI_TAG != MPI_ANY_TAG) ||
- (status.MPI_ERROR != MPI_SUCCESS))
- {
+ (status.MPI_TAG != MPI_ANY_TAG) || (status.MPI_ERROR != MPI_SUCCESS)) {
errs++;
- fprintf( stderr, "non-empty MPI_Status returned for MPI_REQUEST_NULL\n" );
+ fprintf(stderr, "non-empty MPI_Status returned for MPI_REQUEST_NULL\n");
}
/* also pass MPI_STATUS_IGNORE to make sure the implementation doesn't
* blow up when it is passed as the status argument */
- MPI_Request_get_status( MPI_REQUEST_NULL, &flag, MPI_STATUS_IGNORE );
+ MPI_Request_get_status(MPI_REQUEST_NULL, &flag, MPI_STATUS_IGNORE);
if (!flag) {
errs++;
- fprintf( stderr, "flag not true for MPI_REQUEST_NULL with MPI_STATUS_IGNORE, flag=%d\n", flag );
+ fprintf(stderr, "flag not true for MPI_REQUEST_NULL with MPI_STATUS_IGNORE, flag=%d\n",
+ flag);
}
#endif
if (rank == source) {
- buf[0] = size;
- buf[1] = 3;
- MPI_Ssend( buf, 2, MPI_INT, dest, 10, comm );
+ buf[0] = size;
+ buf[1] = 3;
+ MPI_Ssend(buf, 2, MPI_INT, dest, 10, comm);
}
if (rank == dest) {
- MPI_Irecv( buf, 2, MPI_INT, source, 10, comm, &req );
+ MPI_Irecv(buf, 2, MPI_INT, source, 10, comm, &req);
}
- MPI_Barrier( comm );
+ MPI_Barrier(comm);
/* At this point, we know that the receive has at least started,
- because of the Ssend. Check the status on the request */
+ * because of the Ssend. Check the status on the request */
if (rank == dest) {
- status.MPI_SOURCE = -1;
- status.MPI_TAG = -1;
- MPI_Request_get_status( req, &flag, &status );
- if (flag) {
- if (status.MPI_TAG != 10) {
- errs++;
- fprintf( stderr, "Tag value %d should be 10\n", status.MPI_TAG );
- }
- if (status.MPI_SOURCE != source) {
- errs++;
- fprintf( stderr, "Source value %d should be %d\n", status.MPI_SOURCE, source );
- }
- MPI_Get_count( &status, MPI_INT, &count );
- if (count != 2) {
- errs++;
- fprintf( stderr, "Count value %d should be 2\n", count );
- }
- }
- else {
- errs++;
- fprintf( stderr, "Unexpected flag value from get_status\n" );
- }
- /* Now, complete the request */
- MPI_Wait( &req, &status2 );
- /* Check that the status is correct */
- if (status2.MPI_TAG != 10) {
- errs++;
- fprintf( stderr, "(wait)Tag value %d should be 10\n", status2.MPI_TAG );
- }
- if (status2.MPI_SOURCE != source) {
- errs++;
- fprintf( stderr, "(wait)Source value %d should be %d\n", status2.MPI_SOURCE, source );
- }
- MPI_Get_count( &status2, MPI_INT, &count );
- if (count != 2) {
- errs++;
- fprintf( stderr, "(wait)Count value %d should be 2\n", count );
- }
+ status.MPI_SOURCE = -1;
+ status.MPI_TAG = -1;
+ MPI_Request_get_status(req, &flag, &status);
+ if (flag) {
+ if (status.MPI_TAG != 10) {
+ errs++;
+ fprintf(stderr, "Tag value %d should be 10\n", status.MPI_TAG);
+ }
+ if (status.MPI_SOURCE != source) {
+ errs++;
+ fprintf(stderr, "Source value %d should be %d\n", status.MPI_SOURCE, source);
+ }
+ MPI_Get_count(&status, MPI_INT, &count);
+ if (count != 2) {
+ errs++;
+ fprintf(stderr, "Count value %d should be 2\n", count);
+ }
+ }
+ else {
+ errs++;
+ fprintf(stderr, "Unexpected flag value from get_status\n");
+ }
+ /* Now, complete the request */
+ MPI_Wait(&req, &status2);
+ /* Check that the status is correct */
+ if (status2.MPI_TAG != 10) {
+ errs++;
+ fprintf(stderr, "(wait)Tag value %d should be 10\n", status2.MPI_TAG);
+ }
+ if (status2.MPI_SOURCE != source) {
+ errs++;
+ fprintf(stderr, "(wait)Source value %d should be %d\n", status2.MPI_SOURCE, source);
+ }
+ MPI_Get_count(&status2, MPI_INT, &count);
+ if (count != 2) {
+ errs++;
+ fprintf(stderr, "(wait)Count value %d should be 2\n", count);
+ }
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/pt2pt/scancel.c b/test/mpi/pt2pt/scancel.c
index c78b122..23e1bb4 100644
--- a/test/mpi/pt2pt/scancel.c
+++ b/test/mpi/pt2pt/scancel.c
@@ -12,260 +12,244 @@
static char MTEST_Descrip[] = "Test of various send cancel calls";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size, source, dest;
- MPI_Comm comm;
- MPI_Status status;
- MPI_Request req;
+ MPI_Comm comm;
+ MPI_Status status;
+ MPI_Request req;
static int bufsizes[4] = { 1, 100, 10000, 1000000 };
char *buf;
#ifdef TEST_IRSEND
- int veryPicky = 0; /* Set to 1 to test "quality of implementation" in
- a tricky part of cancel */
+ int veryPicky = 0; /* Set to 1 to test "quality of implementation" in
+ * a tricky part of cancel */
#endif
- int cs, flag, n;
+ int cs, flag, n;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
source = 0;
- dest = size - 1;
+ dest = size - 1;
- MTestPrintfMsg( 1, "Starting scancel test\n" );
- for (cs=0; cs<4; cs++) {
- if (rank == 0) {
- n = bufsizes[cs];
- buf = (char *)malloc( n );
- if (!buf) {
- fprintf( stderr, "Unable to allocate %d bytes\n", n );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- MTestPrintfMsg( 1, "(%d) About to create isend and cancel\n",cs );
- MPI_Isend( buf, n, MPI_CHAR, dest, cs+n+1, comm, &req );
- MPI_Cancel( &req );
- MPI_Wait( &req, &status );
- MTestPrintfMsg( 1, "Completed wait on isend\n" );
- MPI_Test_cancelled( &status, &flag );
- if (!flag) {
- errs ++;
- printf( "Failed to cancel an Isend request\n" );
- fflush(stdout);
- }
- else
- {
- n = 0;
- }
- /* Send the size, zero for successfully cancelled */
- MPI_Send( &n, 1, MPI_INT, dest, 123, comm );
- /* Send the tag so the message can be received */
- n = cs+n+1;
- MPI_Send( &n, 1, MPI_INT, dest, 123, comm );
- free( buf );
- }
- else if (rank == dest)
- {
- int nn, tag;
- char *btemp;
- MPI_Recv( &nn, 1, MPI_INT, 0, 123, comm, &status );
- MPI_Recv( &tag, 1, MPI_INT, 0, 123, comm, &status );
- if (nn > 0)
- {
- /* If the message was not cancelled, receive it here */
- btemp = (char*)malloc( nn );
- if (!btemp)
- {
- fprintf( stderr, "Unable to allocate %d bytes\n", nn );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- MPI_Recv( btemp, nn, MPI_CHAR, 0, tag, comm, &status );
- free(btemp);
- }
- }
- MPI_Barrier( comm );
+ MTestPrintfMsg(1, "Starting scancel test\n");
+ for (cs = 0; cs < 4; cs++) {
+ if (rank == 0) {
+ n = bufsizes[cs];
+ buf = (char *) malloc(n);
+ if (!buf) {
+ fprintf(stderr, "Unable to allocate %d bytes\n", n);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ MTestPrintfMsg(1, "(%d) About to create isend and cancel\n", cs);
+ MPI_Isend(buf, n, MPI_CHAR, dest, cs + n + 1, comm, &req);
+ MPI_Cancel(&req);
+ MPI_Wait(&req, &status);
+ MTestPrintfMsg(1, "Completed wait on isend\n");
+ MPI_Test_cancelled(&status, &flag);
+ if (!flag) {
+ errs++;
+ printf("Failed to cancel an Isend request\n");
+ fflush(stdout);
+ }
+ else {
+ n = 0;
+ }
+ /* Send the size, zero for successfully cancelled */
+ MPI_Send(&n, 1, MPI_INT, dest, 123, comm);
+ /* Send the tag so the message can be received */
+ n = cs + n + 1;
+ MPI_Send(&n, 1, MPI_INT, dest, 123, comm);
+ free(buf);
+ }
+ else if (rank == dest) {
+ int nn, tag;
+ char *btemp;
+ MPI_Recv(&nn, 1, MPI_INT, 0, 123, comm, &status);
+ MPI_Recv(&tag, 1, MPI_INT, 0, 123, comm, &status);
+ if (nn > 0) {
+ /* If the message was not cancelled, receive it here */
+ btemp = (char *) malloc(nn);
+ if (!btemp) {
+ fprintf(stderr, "Unable to allocate %d bytes\n", nn);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ MPI_Recv(btemp, nn, MPI_CHAR, 0, tag, comm, &status);
+ free(btemp);
+ }
+ }
+ MPI_Barrier(comm);
- if (rank == 0) {
- char *bsendbuf;
- int bsendbufsize;
- int bf, bs;
- n = bufsizes[cs];
- buf = (char *)malloc( n );
- if (!buf) {
- fprintf( stderr, "Unable to allocate %d bytes\n", n );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- bsendbufsize = n + MPI_BSEND_OVERHEAD;
- bsendbuf = (char *)malloc( bsendbufsize );
- if (!bsendbuf) {
- fprintf( stderr, "Unable to allocate %d bytes for bsend\n", n );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- MPI_Buffer_attach( bsendbuf, bsendbufsize );
- MTestPrintfMsg( 1, "About to create and cancel ibsend\n" );
- MPI_Ibsend( buf, n, MPI_CHAR, dest, cs+n+2, comm, &req );
- MPI_Cancel( &req );
- MPI_Wait( &req, &status );
- MPI_Test_cancelled( &status, &flag );
- if (!flag) {
- errs ++;
- printf( "Failed to cancel an Ibsend request\n" );
- fflush(stdout);
- }
- else
- {
- n = 0;
- }
- /* Send the size, zero for successfully cancelled */
- MPI_Send( &n, 1, MPI_INT, dest, 123, comm );
- /* Send the tag so the message can be received */
- n = cs+n+2;
- MPI_Send( &n, 1, MPI_INT, dest, 123, comm );
- free( buf );
- MPI_Buffer_detach( &bf, &bs );
- free( bsendbuf );
- }
- else if (rank == dest)
- {
- int nn, tag;
- char *btemp;
- MPI_Recv( &nn, 1, MPI_INT, 0, 123, comm, &status );
- MPI_Recv( &tag, 1, MPI_INT, 0, 123, comm, &status );
- if (nn > 0)
- {
- /* If the message was not cancelled, receive it here */
- btemp = (char*)malloc( nn );
- if (!btemp)
- {
- fprintf( stderr, "Unable to allocate %d bytes\n", nn);
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- MPI_Recv( btemp, nn, MPI_CHAR, 0, tag, comm, &status );
- free(btemp);
- }
- }
- MPI_Barrier( comm );
+ if (rank == 0) {
+ char *bsendbuf;
+ int bsendbufsize;
+ int bf, bs;
+ n = bufsizes[cs];
+ buf = (char *) malloc(n);
+ if (!buf) {
+ fprintf(stderr, "Unable to allocate %d bytes\n", n);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ bsendbufsize = n + MPI_BSEND_OVERHEAD;
+ bsendbuf = (char *) malloc(bsendbufsize);
+ if (!bsendbuf) {
+ fprintf(stderr, "Unable to allocate %d bytes for bsend\n", n);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ MPI_Buffer_attach(bsendbuf, bsendbufsize);
+ MTestPrintfMsg(1, "About to create and cancel ibsend\n");
+ MPI_Ibsend(buf, n, MPI_CHAR, dest, cs + n + 2, comm, &req);
+ MPI_Cancel(&req);
+ MPI_Wait(&req, &status);
+ MPI_Test_cancelled(&status, &flag);
+ if (!flag) {
+ errs++;
+ printf("Failed to cancel an Ibsend request\n");
+ fflush(stdout);
+ }
+ else {
+ n = 0;
+ }
+ /* Send the size, zero for successfully cancelled */
+ MPI_Send(&n, 1, MPI_INT, dest, 123, comm);
+ /* Send the tag so the message can be received */
+ n = cs + n + 2;
+ MPI_Send(&n, 1, MPI_INT, dest, 123, comm);
+ free(buf);
+ MPI_Buffer_detach(&bf, &bs);
+ free(bsendbuf);
+ }
+ else if (rank == dest) {
+ int nn, tag;
+ char *btemp;
+ MPI_Recv(&nn, 1, MPI_INT, 0, 123, comm, &status);
+ MPI_Recv(&tag, 1, MPI_INT, 0, 123, comm, &status);
+ if (nn > 0) {
+ /* If the message was not cancelled, receive it here */
+ btemp = (char *) malloc(nn);
+ if (!btemp) {
+ fprintf(stderr, "Unable to allocate %d bytes\n", nn);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ MPI_Recv(btemp, nn, MPI_CHAR, 0, tag, comm, &status);
+ free(btemp);
+ }
+ }
+ MPI_Barrier(comm);
- /* Because this test is erroneous, we do not perform it unless
- TEST_IRSEND is defined. */
+ /* Because this test is erroneous, we do not perform it unless
+ * TEST_IRSEND is defined. */
#ifdef TEST_IRSEND
- /* We avoid ready send to self because an implementation
- is free to detect the error in delivering a message to
- itself without a pending receive; we could also check
- for an error return from the MPI_Irsend */
- if (rank == 0 && dest != rank) {
- n = bufsizes[cs];
- buf = (char *)malloc( n );
- if (!buf) {
- fprintf( stderr, "Unable to allocate %d bytes\n", n );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- MTestPrintfMsg( 1, "About to create and cancel irsend\n" );
- MPI_Irsend( buf, n, MPI_CHAR, dest, cs+n+3, comm, &req );
- MPI_Cancel( &req );
- MPI_Wait( &req, &status );
- MPI_Test_cancelled( &status, &flag );
- /* This can be pretty ugly. The standard is clear (Section 3.8)
- that either a sent message is received or the
- sent message is successfully cancelled. Since this message
- can never be received, the cancel must complete
- successfully.
-
- However, since there is no matching receive, this
- program is erroneous. In this case, we can't really
- flag this as an error */
- if (!flag && veryPicky) {
- errs ++;
- printf( "Failed to cancel an Irsend request\n" );
- fflush(stdout);
- }
- if (flag)
- {
- n = 0;
- }
- /* Send the size, zero for successfully cancelled */
- MPI_Send( &n, 1, MPI_INT, dest, 123, comm );
- /* Send the tag so the message can be received */
- n = cs+n+3;
- MPI_Send( &n, 1, MPI_INT, dest, 123, comm );
- free( buf );
- }
- else if (rank == dest)
- {
- int n, tag;
- char *btemp;
- MPI_Recv( &n, 1, MPI_INT, 0, 123, comm, &status );
- MPI_Recv( &tag, 1, MPI_INT, 0, 123, comm, &status );
- if (n > 0)
- {
- /* If the message was not cancelled, receive it here */
- btemp = (char*)malloc( n );
- if (!btemp)
- {
- fprintf( stderr, "Unable to allocate %d bytes\n", n);
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- MPI_Recv( btemp, n, MPI_CHAR, 0, tag, comm, &status );
- free(btemp);
- }
- }
- MPI_Barrier( comm );
+ /* We avoid ready send to self because an implementation
+ * is free to detect the error in delivering a message to
+ * itself without a pending receive; we could also check
+ * for an error return from the MPI_Irsend */
+ if (rank == 0 && dest != rank) {
+ n = bufsizes[cs];
+ buf = (char *) malloc(n);
+ if (!buf) {
+ fprintf(stderr, "Unable to allocate %d bytes\n", n);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ MTestPrintfMsg(1, "About to create and cancel irsend\n");
+ MPI_Irsend(buf, n, MPI_CHAR, dest, cs + n + 3, comm, &req);
+ MPI_Cancel(&req);
+ MPI_Wait(&req, &status);
+ MPI_Test_cancelled(&status, &flag);
+ /* This can be pretty ugly. The standard is clear (Section 3.8)
+ * that either a sent message is received or the
+ * sent message is successfully cancelled. Since this message
+ * can never be received, the cancel must complete
+ * successfully.
+ *
+ * However, since there is no matching receive, this
+ * program is erroneous. In this case, we can't really
+ * flag this as an error */
+ if (!flag && veryPicky) {
+ errs++;
+ printf("Failed to cancel an Irsend request\n");
+ fflush(stdout);
+ }
+ if (flag) {
+ n = 0;
+ }
+ /* Send the size, zero for successfully cancelled */
+ MPI_Send(&n, 1, MPI_INT, dest, 123, comm);
+ /* Send the tag so the message can be received */
+ n = cs + n + 3;
+ MPI_Send(&n, 1, MPI_INT, dest, 123, comm);
+ free(buf);
+ }
+ else if (rank == dest) {
+ int n, tag;
+ char *btemp;
+ MPI_Recv(&n, 1, MPI_INT, 0, 123, comm, &status);
+ MPI_Recv(&tag, 1, MPI_INT, 0, 123, comm, &status);
+ if (n > 0) {
+ /* If the message was not cancelled, receive it here */
+ btemp = (char *) malloc(n);
+ if (!btemp) {
+ fprintf(stderr, "Unable to allocate %d bytes\n", n);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ MPI_Recv(btemp, n, MPI_CHAR, 0, tag, comm, &status);
+ free(btemp);
+ }
+ }
+ MPI_Barrier(comm);
#endif
- if (rank == 0) {
- n = bufsizes[cs];
- buf = (char *)malloc( n );
- if (!buf) {
- fprintf( stderr, "Unable to allocate %d bytes\n", n );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- MTestPrintfMsg( 1, "About to create and cancel issend\n" );
- MPI_Issend( buf, n, MPI_CHAR, dest, cs+n+4, comm, &req );
- MPI_Cancel( &req );
- MPI_Wait( &req, &status );
- MPI_Test_cancelled( &status, &flag );
- if (!flag) {
- errs ++;
- printf( "Failed to cancel an Issend request\n" );
- fflush(stdout);
- }
- else
- {
- n = 0;
- }
- /* Send the size, zero for successfully cancelled */
- MPI_Send( &n, 1, MPI_INT, dest, 123, comm );
- /* Send the tag so the message can be received */
- n = cs+n+4;
- MPI_Send( &n, 1, MPI_INT, dest, 123, comm );
- free( buf );
- }
- else if (rank == dest)
- {
- int nn, tag;
- char *btemp;
- MPI_Recv( &nn, 1, MPI_INT, 0, 123, comm, &status );
- MPI_Recv( &tag, 1, MPI_INT, 0, 123, comm, &status );
- if (nn > 0)
- {
- /* If the message was not cancelled, receive it here */
- btemp = (char*)malloc( nn );
- if (!btemp)
- {
- fprintf( stderr, "Unable to allocate %d bytes\n", nn);
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- MPI_Recv( btemp, nn, MPI_CHAR, 0, tag, comm, &status );
- free(btemp);
- }
- }
- MPI_Barrier( comm );
+ if (rank == 0) {
+ n = bufsizes[cs];
+ buf = (char *) malloc(n);
+ if (!buf) {
+ fprintf(stderr, "Unable to allocate %d bytes\n", n);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ MTestPrintfMsg(1, "About to create and cancel issend\n");
+ MPI_Issend(buf, n, MPI_CHAR, dest, cs + n + 4, comm, &req);
+ MPI_Cancel(&req);
+ MPI_Wait(&req, &status);
+ MPI_Test_cancelled(&status, &flag);
+ if (!flag) {
+ errs++;
+ printf("Failed to cancel an Issend request\n");
+ fflush(stdout);
+ }
+ else {
+ n = 0;
+ }
+ /* Send the size, zero for successfully cancelled */
+ MPI_Send(&n, 1, MPI_INT, dest, 123, comm);
+ /* Send the tag so the message can be received */
+ n = cs + n + 4;
+ MPI_Send(&n, 1, MPI_INT, dest, 123, comm);
+ free(buf);
+ }
+ else if (rank == dest) {
+ int nn, tag;
+ char *btemp;
+ MPI_Recv(&nn, 1, MPI_INT, 0, 123, comm, &status);
+ MPI_Recv(&tag, 1, MPI_INT, 0, 123, comm, &status);
+ if (nn > 0) {
+ /* If the message was not cancelled, receive it here */
+ btemp = (char *) malloc(nn);
+ if (!btemp) {
+ fprintf(stderr, "Unable to allocate %d bytes\n", nn);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ MPI_Recv(btemp, nn, MPI_CHAR, 0, tag, comm, &status);
+ free(btemp);
+ }
+ }
+ MPI_Barrier(comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/pt2pt/scancel2.c b/test/mpi/pt2pt/scancel2.c
index b027f0b..2ecee0f 100644
--- a/test/mpi/pt2pt/scancel2.c
+++ b/test/mpi/pt2pt/scancel2.c
@@ -12,72 +12,69 @@
static char MTEST_Descrip[] = "Test of send cancel (failure) calls";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size, source, dest;
- MPI_Comm comm;
- MPI_Status status;
- MPI_Request req;
+ MPI_Comm comm;
+ MPI_Status status;
+ MPI_Request req;
static int bufsizes[4] = { 1, 100, 10000, 1000000 };
char *buf;
- int cs, flag, n;
+ int cs, flag, n;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
source = 0;
- dest = size - 1;
+ dest = size - 1;
- MTestPrintfMsg( 1, "Starting scancel test\n" );
+ MTestPrintfMsg(1, "Starting scancel test\n");
- for (cs=0; cs<4; cs++) {
- n = bufsizes[cs];
- buf = (char *)malloc( n );
- if (!buf) {
- fprintf( stderr, "Unable to allocate %d bytes\n", n );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
+ for (cs = 0; cs < 4; cs++) {
+ n = bufsizes[cs];
+ buf = (char *) malloc(n);
+ if (!buf) {
+ fprintf(stderr, "Unable to allocate %d bytes\n", n);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
- if (rank == source) {
- MTestPrintfMsg( 1, "(%d) About to create isend and cancel\n",cs );
- MPI_Isend( buf, n, MPI_CHAR, dest, cs+n+1, comm, &req );
- MPI_Barrier( comm );
- MPI_Cancel( &req );
- MPI_Wait( &req, &status );
- MTestPrintfMsg( 1, "Completed wait on isend\n" );
- MPI_Test_cancelled( &status, &flag );
- if (flag) {
- errs ++;
- printf( "Cancelled a matched Isend request (msg size = %d)!\n",
- n );
- fflush(stdout);
- }
- else
- {
- n = 0;
- }
- /* Send the size, zero for not cancelled (success) */
- MPI_Send( &n, 1, MPI_INT, dest, 123, comm );
- }
- else if (rank == dest)
- {
- MPI_Recv( buf, n, MPI_CHAR, source, cs+n+1, comm, &status );
- MPI_Barrier( comm );
- MPI_Recv( &n, 1, MPI_INT, source, 123, comm, &status );
- }
- else {
- MPI_Barrier( comm );
- }
+ if (rank == source) {
+ MTestPrintfMsg(1, "(%d) About to create isend and cancel\n", cs);
+ MPI_Isend(buf, n, MPI_CHAR, dest, cs + n + 1, comm, &req);
+ MPI_Barrier(comm);
+ MPI_Cancel(&req);
+ MPI_Wait(&req, &status);
+ MTestPrintfMsg(1, "Completed wait on isend\n");
+ MPI_Test_cancelled(&status, &flag);
+ if (flag) {
+ errs++;
+ printf("Cancelled a matched Isend request (msg size = %d)!\n", n);
+ fflush(stdout);
+ }
+ else {
+ n = 0;
+ }
+ /* Send the size, zero for not cancelled (success) */
+ MPI_Send(&n, 1, MPI_INT, dest, 123, comm);
+ }
+ else if (rank == dest) {
+ MPI_Recv(buf, n, MPI_CHAR, source, cs + n + 1, comm, &status);
+ MPI_Barrier(comm);
+ MPI_Recv(&n, 1, MPI_INT, source, 123, comm, &status);
+ }
+ else {
+ MPI_Barrier(comm);
+ }
- MPI_Barrier( comm );
- free( buf );
+ MPI_Barrier(comm);
+ free(buf);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/pt2pt/sendall.c b/test/mpi/pt2pt/sendall.c
index eba48e6..5e67916 100644
--- a/test/mpi/pt2pt/sendall.c
+++ b/test/mpi/pt2pt/sendall.c
@@ -10,9 +10,9 @@
#include "mpi.h"
#include "mpitest.h"
-/*
+/*
* This test makes sure that each process can send to each other process.
- * If there are bugs in the handling of request completions or in
+ * If there are bugs in the handling of request completions or in
* queue operations, then this test may fail on them (it did with
* early EagerShort handling).
*/
@@ -23,60 +23,59 @@ static int buffer[MAXPES][MYBUFSIZE];
#define NUM_RUNS 10
-int main ( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
- int i;
- int count, size;
- int self, npes;
- double secs;
- MPI_Request request[MAXPES];
- MPI_Status status;
-
- MTest_Init (&argc, &argv);
- MPI_Comm_rank (MPI_COMM_WORLD, &self);
- MPI_Comm_size (MPI_COMM_WORLD, &npes);
-
- if (npes > MAXPES) {
- fprintf( stderr, "This program requires a comm_world no larger than %d",
- MAXPES );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
-
- for (size = 1; size <= MYBUFSIZE ; size += size) {
- secs = -MPI_Wtime ();
- for (count = 0; count < NUM_RUNS; count++) {
- MPI_Barrier (MPI_COMM_WORLD);
-
- for (i = 0; i < npes; i++) {
- if (i != self)
- MPI_Irecv (buffer[i], size, MPI_INT, i,
- MPI_ANY_TAG, MPI_COMM_WORLD, &request[i]);
- }
-
- for (i = 0; i < npes; i++) {
- if (i != self)
- MPI_Send (buffer[self], size, MPI_INT, i, 0, MPI_COMM_WORLD);
- }
-
- for (i = 0; i < npes; i++) {
- if (i != self)
- MPI_Wait (&request[i], &status);
- }
-
- }
- MPI_Barrier (MPI_COMM_WORLD);
- secs += MPI_Wtime ();
-
- if (self == 0) {
- secs = secs / (double) NUM_RUNS;
- MTestPrintfMsg( 1, "length = %d ints\n", size );
- }
+ int i;
+ int count, size;
+ int self, npes;
+ double secs;
+ MPI_Request request[MAXPES];
+ MPI_Status status;
+
+ MTest_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &self);
+ MPI_Comm_size(MPI_COMM_WORLD, &npes);
+
+ if (npes > MAXPES) {
+ fprintf(stderr, "This program requires a comm_world no larger than %d", MAXPES);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+
+ for (size = 1; size <= MYBUFSIZE; size += size) {
+ secs = -MPI_Wtime();
+ for (count = 0; count < NUM_RUNS; count++) {
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ for (i = 0; i < npes; i++) {
+ if (i != self)
+ MPI_Irecv(buffer[i], size, MPI_INT, i,
+ MPI_ANY_TAG, MPI_COMM_WORLD, &request[i]);
+ }
+
+ for (i = 0; i < npes; i++) {
+ if (i != self)
+ MPI_Send(buffer[self], size, MPI_INT, i, 0, MPI_COMM_WORLD);
+ }
+
+ for (i = 0; i < npes; i++) {
+ if (i != self)
+ MPI_Wait(&request[i], &status);
+ }
+
+ }
+ MPI_Barrier(MPI_COMM_WORLD);
+ secs += MPI_Wtime();
+
+ if (self == 0) {
+ secs = secs / (double) NUM_RUNS;
+ MTestPrintfMsg(1, "length = %d ints\n", size);
+ }
}
- /* Simple completion is all that we normally ask of this program */
+ /* Simple completion is all that we normally ask of this program */
- MTest_Finalize( 0 );
+ MTest_Finalize(0);
- MPI_Finalize();
- return 0;
+ MPI_Finalize();
+ return 0;
}
diff --git a/test/mpi/pt2pt/sendflood.c b/test/mpi/pt2pt/sendflood.c
index ffcc1a5..b4c2c5c 100644
--- a/test/mpi/pt2pt/sendflood.c
+++ b/test/mpi/pt2pt/sendflood.c
@@ -10,8 +10,8 @@
/*
* Run this test with 8 processes. This test was submitted by xxx
- * as a result of problems seen with the ch3:shm device on a Solaris
- * system. The symptom is that the test hangs; this is due to losing
+ * as a result of problems seen with the ch3:shm device on a Solaris
+ * system. The symptom is that the test hangs; this is due to losing
* a message, probably due to a race condition in a message-queue update.
* As a test for race conditions, it may need to be run multiple times
* to expose a problem if a problem does exist.
@@ -25,132 +25,128 @@
static int verbose = 0;
static int loopProgress = 0;
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
- int nProc, rank ;
- int i, j, status ;
- FILE *pf=0 ;
+ int nProc, rank;
+ int i, j, status;
+ FILE *pf = 0;
- MPI_Init( &argc, &argv ) ;
- MPI_Comm_size( MPI_COMM_WORLD, &nProc ) ;
- MPI_Comm_rank( MPI_COMM_WORLD, &rank ) ;
+ MPI_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nProc);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- for (i=1; i<argc; i++) {
- if (strcmp(argv[i],"-v") == 0 ||
- strcmp(argv[i],"--verbose") == 0) verbose = 1;
- else if (strcmp(argv[i],"-p") == 0 ||
- strcmp(argv[i],"--progress") == 0) loopProgress = 1;
- else {
- if (rank == 0) {
- fprintf( stderr, "%s: [ -v | --verbose ] [ -p | --progress ]\n",
- argv[0] );
- fflush(stderr);
- }
- }
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0)
+ verbose = 1;
+ else if (strcmp(argv[i], "-p") == 0 || strcmp(argv[i], "--progress") == 0)
+ loopProgress = 1;
+ else {
+ if (rank == 0) {
+ fprintf(stderr, "%s: [ -v | --verbose ] [ -p | --progress ]\n", argv[0]);
+ fflush(stderr);
+ }
+ }
}
if (verbose) {
- char buf[ 128 ] ;
- sprintf( buf, "fast_mpi_%d.dmp", rank ) ;
- pf = fopen( buf, "w" ) ;
+ char buf[128];
+ sprintf(buf, "fast_mpi_%d.dmp", rank);
+ pf = fopen(buf, "w");
}
else if (loopProgress) {
- pf = stdout;
+ pf = stdout;
}
- if( !rank ) {
- int **psend ;
- int **precv ;
- psend = (int**)calloc( nProc, sizeof( int *) ) ;
- precv = (int**)calloc( nProc, sizeof( int *) ) ;
- for( i = 0 ; i < nProc ; i++ ) {
- psend[ i ] = (int*)calloc( DATA_SIZE, sizeof( int ) ) ;
- precv[ i ] = (int*)calloc( DATA_SIZE, sizeof( int ) ) ;
- }
- for( i = 0 ; i < LOOP_COUNT ; i++ ) {
- if (verbose) {
- fprintf( pf, "Master : loop %d\n", i ) ;
- fflush( pf ) ;
- }
- else if (loopProgress && (i & PROGRESS_COUNT) == 0) {
- fprintf( pf, "Master: loop %d\n", i ); fflush( pf );
- }
- for( j = 1 ; j < nProc ; j++ ) {
- if (verbose) {
- fprintf( pf, " read from child %d\n", j ) ;
- fflush( pf ) ;
- }
- status = MPI_Recv( precv[ j ], DATA_SIZE, MPI_INT, j, MP_TAG,
- MPI_COMM_WORLD, MPI_STATUS_IGNORE ) ;
- if (verbose) {
- fprintf( pf, " read from child %d done, status = %d\n", j,
- status ) ;
- fflush( pf ) ;
- }
- }
- for( j = 1 ; j < nProc ; j++ ) {
- if (verbose) {
- fprintf( pf, " send to child %d\n", j ) ;
- fflush( pf ) ;
- }
- status = MPI_Send( psend[ j ], DATA_SIZE - 1, MPI_INT, j,
- MP_TAG, MPI_COMM_WORLD ) ;
- if (verbose) {
- fprintf( pf, " send to child %d done, status = %d\n", j,
- status ) ;
- fflush( pf ) ;
- }
- }
- }
- for( i = 0 ; i < nProc ; i++ ) {
- free( psend[ i ] );
- free( precv[ i ] );
- }
- free( psend );
- free( precv );
- } else {
- int *psend ;
- int *precv ;
- psend = (int*)calloc( DATA_SIZE, sizeof( int ) ) ;
- precv = (int*)calloc( DATA_SIZE, sizeof( int ) ) ;
- for( i = 0 ; i < LOOP_COUNT ; i++ ) {
- if (verbose) {
- fprintf( pf, " send to master\n" ) ;
- fflush( pf ) ;
- }
- /*
- else if (loopProgress && (i & PROGRESS_COUNT) == 0) {
- fprintf( pf, "Slave: loop %d\n", i ); fflush( pf );
- }
- */
- status = MPI_Send( psend, DATA_SIZE - 1, MPI_INT, 0, MP_TAG,
- MPI_COMM_WORLD ) ;
- if (verbose) {
- fprintf( pf, " send to master done, status = %d\n", status ) ;
- fflush( pf ) ;
- fprintf( pf, " read from master\n" ) ;
- fflush( pf ) ;
- }
- status = MPI_Recv( precv, DATA_SIZE, MPI_INT, 0, MP_TAG,
- MPI_COMM_WORLD, MPI_STATUS_IGNORE ) ;
- if (verbose) {
- fprintf( pf, " read from master done, status = %d\n", status ) ;
- fflush( pf ) ;
- }
- }
- free( psend );
- free( precv );
+ if (!rank) {
+ int **psend;
+ int **precv;
+ psend = (int **) calloc(nProc, sizeof(int *));
+ precv = (int **) calloc(nProc, sizeof(int *));
+ for (i = 0; i < nProc; i++) {
+ psend[i] = (int *) calloc(DATA_SIZE, sizeof(int));
+ precv[i] = (int *) calloc(DATA_SIZE, sizeof(int));
+ }
+ for (i = 0; i < LOOP_COUNT; i++) {
+ if (verbose) {
+ fprintf(pf, "Master : loop %d\n", i);
+ fflush(pf);
+ }
+ else if (loopProgress && (i & PROGRESS_COUNT) == 0) {
+ fprintf(pf, "Master: loop %d\n", i);
+ fflush(pf);
+ }
+ for (j = 1; j < nProc; j++) {
+ if (verbose) {
+ fprintf(pf, " read from child %d\n", j);
+ fflush(pf);
+ }
+ status = MPI_Recv(precv[j], DATA_SIZE, MPI_INT, j, MP_TAG,
+ MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+ if (verbose) {
+ fprintf(pf, " read from child %d done, status = %d\n", j, status);
+ fflush(pf);
+ }
+ }
+ for (j = 1; j < nProc; j++) {
+ if (verbose) {
+ fprintf(pf, " send to child %d\n", j);
+ fflush(pf);
+ }
+ status = MPI_Send(psend[j], DATA_SIZE - 1, MPI_INT, j, MP_TAG, MPI_COMM_WORLD);
+ if (verbose) {
+ fprintf(pf, " send to child %d done, status = %d\n", j, status);
+ fflush(pf);
+ }
+ }
+ }
+ for (i = 0; i < nProc; i++) {
+ free(psend[i]);
+ free(precv[i]);
+ }
+ free(psend);
+ free(precv);
+ }
+ else {
+ int *psend;
+ int *precv;
+ psend = (int *) calloc(DATA_SIZE, sizeof(int));
+ precv = (int *) calloc(DATA_SIZE, sizeof(int));
+ for (i = 0; i < LOOP_COUNT; i++) {
+ if (verbose) {
+ fprintf(pf, " send to master\n");
+ fflush(pf);
+ }
+ /*
+ * else if (loopProgress && (i & PROGRESS_COUNT) == 0) {
+ * fprintf(pf, "Slave: loop %d\n", i); fflush(pf);
+ * }
+ */
+ status = MPI_Send(psend, DATA_SIZE - 1, MPI_INT, 0, MP_TAG, MPI_COMM_WORLD);
+ if (verbose) {
+ fprintf(pf, " send to master done, status = %d\n", status);
+ fflush(pf);
+ fprintf(pf, " read from master\n");
+ fflush(pf);
+ }
+ status = MPI_Recv(precv, DATA_SIZE, MPI_INT, 0, MP_TAG,
+ MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+ if (verbose) {
+ fprintf(pf, " read from master done, status = %d\n", status);
+ fflush(pf);
+ }
+ }
+ free(psend);
+ free(precv);
}
if (verbose) {
- fclose( pf ) ;
+ fclose(pf);
}
- MPI_Finalize() ;
+ MPI_Finalize();
/* This test fails if it hangs */
if (rank == 0) {
- printf( " No Errors\n" );
+ printf(" No Errors\n");
}
return 0;
}
-
diff --git a/test/mpi/pt2pt/sendrecv1.c b/test/mpi/pt2pt/sendrecv1.c
index 57059eb..a75b86c 100644
--- a/test/mpi/pt2pt/sendrecv1.c
+++ b/test/mpi/pt2pt/sendrecv1.c
@@ -12,81 +12,81 @@
static char MTEST_Descrip[] = "Send-Recv";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int rank, size, source, dest;
- int minsize = 2, count;
- MPI_Comm comm;
+ int minsize = 2, count;
+ MPI_Comm comm;
MTestDatatype sendtype, recvtype;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- /* The following illustrates the use of the routines to
- run through a selection of communicators and datatypes.
- Use subsets of these for tests that do not involve combinations
- of communicators, datatypes, and counts of datatypes */
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
+ /* The following illustrates the use of the routines to
+ * run through a selection of communicators and datatypes.
+ * Use subsets of these for tests that do not involve combinations
+ * of communicators, datatypes, and counts of datatypes */
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
- /* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
- source = 0;
- dest = size - 1;
+ /* Determine the sender and receiver */
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+ source = 0;
+ dest = size - 1;
- /* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN );
+ /* To improve reporting of problems about operations, we
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN);
- MTEST_DATATYPE_FOR_EACH_COUNT(count) {
- while (MTestGetDatatypes( &sendtype, &recvtype, count )) {
- /* Make sure that everyone has a recv buffer */
- recvtype.InitBuf( &recvtype );
+ MTEST_DATATYPE_FOR_EACH_COUNT(count) {
+ while (MTestGetDatatypes(&sendtype, &recvtype, count)) {
+ /* Make sure that everyone has a recv buffer */
+ recvtype.InitBuf(&recvtype);
- if (rank == source) {
- sendtype.InitBuf( &sendtype );
-
- err = MPI_Send( sendtype.buf, sendtype.count,
- sendtype.datatype, dest, 0, comm);
- if (err) {
- errs++;
- if (errs < 10) {
- MTestPrintError( err );
- }
- }
- }
- else if (rank == dest) {
- err = MPI_Recv( recvtype.buf, recvtype.count,
- recvtype.datatype, source, 0, comm, MPI_STATUS_IGNORE);
- if (err) {
- errs++;
- if (errs < 10) {
- MTestPrintError( err );
- }
- }
+ if (rank == source) {
+ sendtype.InitBuf(&sendtype);
- err = MTestCheckRecv( 0, &recvtype );
- if (err) {
- if (errs < 10) {
- printf( "Data in target buffer did not match for destination datatype %s and source datatype %s, count = %d\n",
- MTestGetDatatypeName( &recvtype ),
- MTestGetDatatypeName( &sendtype ),
- count );
- recvtype.printErrors = 1;
- (void)MTestCheckRecv( 0, &recvtype );
- }
- errs += err;
- }
- }
- MTestFreeDatatype( &sendtype );
- MTestFreeDatatype( &recvtype );
- }
- }
- MTestFreeComm( &comm );
+ err = MPI_Send(sendtype.buf, sendtype.count, sendtype.datatype, dest, 0, comm);
+ if (err) {
+ errs++;
+ if (errs < 10) {
+ MTestPrintError(err);
+ }
+ }
+ }
+ else if (rank == dest) {
+ err = MPI_Recv(recvtype.buf, recvtype.count,
+ recvtype.datatype, source, 0, comm, MPI_STATUS_IGNORE);
+ if (err) {
+ errs++;
+ if (errs < 10) {
+ MTestPrintError(err);
+ }
+ }
+
+ err = MTestCheckRecv(0, &recvtype);
+ if (err) {
+ if (errs < 10) {
+ printf
+ ("Data in target buffer did not match for destination datatype %s and source datatype %s, count = %d\n",
+ MTestGetDatatypeName(&recvtype), MTestGetDatatypeName(&sendtype),
+ count);
+ recvtype.printErrors = 1;
+ (void) MTestCheckRecv(0, &recvtype);
+ }
+ errs += err;
+ }
+ }
+ MTestFreeDatatype(&sendtype);
+ MTestFreeDatatype(&recvtype);
+ }
+ }
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/pt2pt/sendrecv2.c b/test/mpi/pt2pt/sendrecv2.c
index f4845c6..866af3b 100644
--- a/test/mpi/pt2pt/sendrecv2.c
+++ b/test/mpi/pt2pt/sendrecv2.c
@@ -16,7 +16,7 @@ static int verbose = 0;
static int parse_args(int argc, char **argv);
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int i, j, errs = 0;
int rank, size;
@@ -30,87 +30,92 @@ int main( int argc, char *argv[] )
MPI_Comm_size(MPI_COMM_WORLD, &size);
if (size < 2) {
- if (verbose) fprintf(stderr, "comm size must be > 1\n");
- errs++;
- goto fn_exit;
+ if (verbose)
+ fprintf(stderr, "comm size must be > 1\n");
+ errs++;
+ goto fn_exit;
}
buf = malloc(64 * 129);
if (buf == NULL) {
- if (verbose) fprintf(stderr, "error allocating buffer\n");
- errs++;
- goto fn_exit;
+ if (verbose)
+ fprintf(stderr, "error allocating buffer\n");
+ errs++;
+ goto fn_exit;
}
for (i = 8; i < 64; i += 4) {
- MPI_Type_vector(i, 128, 129, MPI_CHAR, &newtype);
-
- MPI_Type_commit(&newtype);
- memset(buf, 0, 64*129);
-
- if (rank == 0) {
- /* init buffer */
- for (j=0; j < i; j++) {
- int k;
- for (k=0; k < 129; k++) {
- buf[129*j + k] = (char) j;
- }
- }
-
- /* send */
- MPI_Send(buf, 1, newtype, 1, i, MPI_COMM_WORLD);
- }
- else if (rank == 1) {
- /* recv */
- MPI_Recv(buf, 1, newtype, 0, i, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
-
- /* check buffer */
- for (j=0; j < i; j++) {
- int k;
- for (k=0; k < 129; k++) {
- if (k < 128 && buf[129*j + k] != (char) j) {
- if (verbose) fprintf(stderr,
- "(i=%d, pos=%d) should be %d but is %d\n",
- i, 129*j + k, j, (int) buf[129*j + k]);
- errs++;
- }
- else if (k == 128 && buf[129*j + k] != (char) 0) {
- if (verbose) fprintf(stderr,
- "(i=%d, pos=%d) should be %d but is %d\n",
- i, 129*j + k, 0, (int) buf[129*j + k]);
- errs++;
- }
- }
- }
- }
-
- MPI_Type_free(&newtype);
+ MPI_Type_vector(i, 128, 129, MPI_CHAR, &newtype);
+
+ MPI_Type_commit(&newtype);
+ memset(buf, 0, 64 * 129);
+
+ if (rank == 0) {
+ /* init buffer */
+ for (j = 0; j < i; j++) {
+ int k;
+ for (k = 0; k < 129; k++) {
+ buf[129 * j + k] = (char) j;
+ }
+ }
+
+ /* send */
+ MPI_Send(buf, 1, newtype, 1, i, MPI_COMM_WORLD);
+ }
+ else if (rank == 1) {
+ /* recv */
+ MPI_Recv(buf, 1, newtype, 0, i, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+
+ /* check buffer */
+ for (j = 0; j < i; j++) {
+ int k;
+ for (k = 0; k < 129; k++) {
+ if (k < 128 && buf[129 * j + k] != (char) j) {
+ if (verbose)
+ fprintf(stderr,
+ "(i=%d, pos=%d) should be %d but is %d\n",
+ i, 129 * j + k, j, (int) buf[129 * j + k]);
+ errs++;
+ }
+ else if (k == 128 && buf[129 * j + k] != (char) 0) {
+ if (verbose)
+ fprintf(stderr,
+ "(i=%d, pos=%d) should be %d but is %d\n",
+ i, 129 * j + k, 0, (int) buf[129 * j + k]);
+ errs++;
+ }
+ }
+ }
+ }
+
+ MPI_Type_free(&newtype);
}
if (rank == 0) {
- int recv_errs = 0;
-
- MPI_Recv(&recv_errs, 1, MPI_INT, 1, 0, MPI_COMM_WORLD,
- MPI_STATUS_IGNORE);
- if (recv_errs) {
- if (verbose) fprintf(stderr, "%d errors reported from receiver\n",
- recv_errs);
- errs += recv_errs;
- }
+ int recv_errs = 0;
+
+ MPI_Recv(&recv_errs, 1, MPI_INT, 1, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+ if (recv_errs) {
+ if (verbose)
+ fprintf(stderr, "%d errors reported from receiver\n", recv_errs);
+ errs += recv_errs;
+ }
}
else if (rank == 1) {
- MPI_Send(&errs, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+ MPI_Send(&errs, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
}
-
- fn_exit:
+
+ fn_exit:
free(buf);
/* print message and exit */
if (errs) {
- if (rank == 0) fprintf(stderr, "Found %d errors\n", errs);
+ if (rank == 0)
+ fprintf(stderr, "Found %d errors\n", errs);
}
else {
- if (rank == 0) printf(" No Errors\n");
+ if (rank == 0)
+ printf(" No Errors\n");
}
MPI_Finalize();
return 0;
@@ -119,18 +124,18 @@ int main( int argc, char *argv[] )
static int parse_args(int argc, char **argv)
{
/*
- int ret;
-
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
- }
- */
+ * int ret;
+ *
+ * while ((ret = getopt(argc, argv, "v")) >= 0)
+ * {
+ * switch (ret) {
+ * case 'v':
+ * verbose = 1;
+ * break;
+ * }
+ * }
+ */
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
return 0;
}
diff --git a/test/mpi/pt2pt/sendrecv3.c b/test/mpi/pt2pt/sendrecv3.c
index adce6db..4cabf99 100644
--- a/test/mpi/pt2pt/sendrecv3.c
+++ b/test/mpi/pt2pt/sendrecv3.c
@@ -14,92 +14,86 @@ static char MTEST_Descrip[] = "Head to head send-recv to test backoff in device
*/
#define MAX_NMSGS 100
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size, source, dest, partner;
- int i, testnum;
+ int i, testnum;
double tsend;
static int msgsizes[] = { 100, 1000, 10000, 100000, -1 };
- static int nmsgs[] = { 100, 10, 10, 4 };
- MPI_Comm comm;
+ static int nmsgs[] = { 100, 10, 10, 4 };
+ MPI_Comm comm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
source = 0;
- dest = 1;
+ dest = 1;
if (size < 2) {
- printf( "This test requires at least 2 processes\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ printf("This test requires at least 2 processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- for (testnum=0; msgsizes[testnum] > 0; testnum++) {
- if (rank == source || rank == dest) {
- int nmsg = nmsgs[testnum];
- int msgSize = msgsizes[testnum];
- MPI_Request r[MAX_NMSGS];
- int *buf[MAX_NMSGS];
+ for (testnum = 0; msgsizes[testnum] > 0; testnum++) {
+ if (rank == source || rank == dest) {
+ int nmsg = nmsgs[testnum];
+ int msgSize = msgsizes[testnum];
+ MPI_Request r[MAX_NMSGS];
+ int *buf[MAX_NMSGS];
- for (i=0; i<nmsg; i++) {
- buf[i] = (int *)malloc( msgSize * sizeof(int) );
- if (!buf[i]) {
- fprintf( stderr, "Unable to allocate %d bytes\n",
- msgSize );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- }
- partner = (rank + 1) % size;
+ for (i = 0; i < nmsg; i++) {
+ buf[i] = (int *) malloc(msgSize * sizeof(int));
+ if (!buf[i]) {
+ fprintf(stderr, "Unable to allocate %d bytes\n", msgSize);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ }
+ partner = (rank + 1) % size;
- MPI_Sendrecv( MPI_BOTTOM, 0, MPI_INT, partner, 10,
- MPI_BOTTOM, 0, MPI_INT, partner, 10, comm,
- MPI_STATUS_IGNORE );
- /* Try to fill up the outgoing message buffers */
- for (i=0; i<nmsg; i++) {
- MPI_Isend( buf[i], msgSize, MPI_INT, partner, testnum, comm,
- &r[i] );
- }
- for (i=0; i<nmsg; i++) {
- MPI_Recv( buf[i], msgSize, MPI_INT, partner, testnum, comm,
- MPI_STATUS_IGNORE );
- }
- MPI_Waitall( nmsg, r, MPI_STATUSES_IGNORE );
+ MPI_Sendrecv(MPI_BOTTOM, 0, MPI_INT, partner, 10,
+ MPI_BOTTOM, 0, MPI_INT, partner, 10, comm, MPI_STATUS_IGNORE);
+ /* Try to fill up the outgoing message buffers */
+ for (i = 0; i < nmsg; i++) {
+ MPI_Isend(buf[i], msgSize, MPI_INT, partner, testnum, comm, &r[i]);
+ }
+ for (i = 0; i < nmsg; i++) {
+ MPI_Recv(buf[i], msgSize, MPI_INT, partner, testnum, comm, MPI_STATUS_IGNORE);
+ }
+ MPI_Waitall(nmsg, r, MPI_STATUSES_IGNORE);
- /* Repeat the test, but make one of the processes sleep */
- MPI_Sendrecv( MPI_BOTTOM, 0, MPI_INT, partner, 10,
- MPI_BOTTOM, 0, MPI_INT, partner, 10, comm,
- MPI_STATUS_IGNORE );
- if (rank == dest) MTestSleep( 1 );
- /* Try to fill up the outgoing message buffers */
- tsend = MPI_Wtime();
- for (i=0; i<nmsg; i++) {
- MPI_Isend( buf[i], msgSize, MPI_INT, partner, testnum, comm,
- &r[i] );
- }
- tsend = MPI_Wtime() - tsend;
- for (i=0; i<nmsg; i++) {
- MPI_Recv( buf[i], msgSize, MPI_INT, partner, testnum, comm,
- MPI_STATUS_IGNORE );
- }
- MPI_Waitall( nmsg, r, MPI_STATUSES_IGNORE );
+ /* Repeat the test, but make one of the processes sleep */
+ MPI_Sendrecv(MPI_BOTTOM, 0, MPI_INT, partner, 10,
+ MPI_BOTTOM, 0, MPI_INT, partner, 10, comm, MPI_STATUS_IGNORE);
+ if (rank == dest)
+ MTestSleep(1);
+ /* Try to fill up the outgoing message buffers */
+ tsend = MPI_Wtime();
+ for (i = 0; i < nmsg; i++) {
+ MPI_Isend(buf[i], msgSize, MPI_INT, partner, testnum, comm, &r[i]);
+ }
+ tsend = MPI_Wtime() - tsend;
+ for (i = 0; i < nmsg; i++) {
+ MPI_Recv(buf[i], msgSize, MPI_INT, partner, testnum, comm, MPI_STATUS_IGNORE);
+ }
+ MPI_Waitall(nmsg, r, MPI_STATUSES_IGNORE);
- if (tsend > 0.5) {
- printf( "Isends for %d messages of size %d took too long (%f seconds)\n", nmsg, msgSize, tsend );
- errs++;
- }
- MTestPrintfMsg( 1, "%d Isends for size = %d took %f seconds\n",
- nmsg, msgSize, tsend );
+ if (tsend > 0.5) {
+ printf("Isends for %d messages of size %d took too long (%f seconds)\n", nmsg,
+ msgSize, tsend);
+ errs++;
+ }
+ MTestPrintfMsg(1, "%d Isends for size = %d took %f seconds\n", nmsg, msgSize, tsend);
- for (i=0; i<nmsg; i++) {
- free( buf[i] );
- }
- }
+ for (i = 0; i < nmsg; i++) {
+ free(buf[i]);
+ }
+ }
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/pt2pt/sendself.c b/test/mpi/pt2pt/sendself.c
index 6b1e261..5803f9c 100644
--- a/test/mpi/pt2pt/sendself.c
+++ b/test/mpi/pt2pt/sendself.c
@@ -12,130 +12,121 @@
static char MTEST_Descrip[] = "Test of sending to self (with a preposted receive)";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int rank, size;
int count;
- MPI_Comm comm;
- MPI_Request req;
+ MPI_Comm comm;
+ MPI_Request req;
MTestDatatype sendtype, recvtype;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN );
-
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN);
+
MTEST_DATATYPE_FOR_EACH_COUNT(count) {
- while (MTestGetDatatypes( &sendtype, &recvtype, count )) {
-
- sendtype.InitBuf( &sendtype );
- recvtype.InitBuf( &recvtype );
-
- err = MPI_Irecv( recvtype.buf, recvtype.count,
- recvtype.datatype, rank, 0, comm, &req );
- if (err) {
- errs++;
- if (errs < 10) {
- MTestPrintError( err );
- }
- }
-
- err = MPI_Send( sendtype.buf, sendtype.count,
- sendtype.datatype, rank, 0, comm);
- if (err) {
- errs++;
- if (errs < 10) {
- MTestPrintError( err );
- }
- }
- err = MPI_Wait( &req, MPI_STATUS_IGNORE );
- err = MTestCheckRecv( 0, &recvtype );
- if (err) {
- if (errs < 10) {
- printf( "Data in target buffer did not match for destination datatype %s and source datatype %s, count = %d\n",
- MTestGetDatatypeName( &recvtype ),
- MTestGetDatatypeName( &sendtype ),
- count );
- recvtype.printErrors = 1;
- (void)MTestCheckRecv( 0, &recvtype );
- }
- errs += err;
- }
+ while (MTestGetDatatypes(&sendtype, &recvtype, count)) {
+
+ sendtype.InitBuf(&sendtype);
+ recvtype.InitBuf(&recvtype);
+
+ err = MPI_Irecv(recvtype.buf, recvtype.count, recvtype.datatype, rank, 0, comm, &req);
+ if (err) {
+ errs++;
+ if (errs < 10) {
+ MTestPrintError(err);
+ }
+ }
+
+ err = MPI_Send(sendtype.buf, sendtype.count, sendtype.datatype, rank, 0, comm);
+ if (err) {
+ errs++;
+ if (errs < 10) {
+ MTestPrintError(err);
+ }
+ }
+ err = MPI_Wait(&req, MPI_STATUS_IGNORE);
+ err = MTestCheckRecv(0, &recvtype);
+ if (err) {
+ if (errs < 10) {
+ printf
+ ("Data in target buffer did not match for destination datatype %s and source datatype %s, count = %d\n",
+ MTestGetDatatypeName(&recvtype), MTestGetDatatypeName(&sendtype), count);
+ recvtype.printErrors = 1;
+ (void) MTestCheckRecv(0, &recvtype);
+ }
+ errs += err;
+ }
+
+ err = MPI_Irecv(recvtype.buf, recvtype.count, recvtype.datatype, rank, 0, comm, &req);
+ if (err) {
+ errs++;
+ if (errs < 10) {
+ MTestPrintError(err);
+ }
+ }
+
+ err = MPI_Ssend(sendtype.buf, sendtype.count, sendtype.datatype, rank, 0, comm);
+ if (err) {
+ errs++;
+ if (errs < 10) {
+ MTestPrintError(err);
+ }
+ }
+ err = MPI_Wait(&req, MPI_STATUS_IGNORE);
+ err = MTestCheckRecv(0, &recvtype);
+ if (err) {
+ if (errs < 10) {
+ printf
+ ("Data in target buffer did not match for destination datatype %s and source datatype %s, count = %d\n",
+ MTestGetDatatypeName(&recvtype), MTestGetDatatypeName(&sendtype), count);
+ recvtype.printErrors = 1;
+ (void) MTestCheckRecv(0, &recvtype);
+ }
+ errs += err;
+ }
- err = MPI_Irecv( recvtype.buf, recvtype.count,
- recvtype.datatype, rank, 0, comm, &req );
- if (err) {
- errs++;
- if (errs < 10) {
- MTestPrintError( err );
- }
- }
-
- err = MPI_Ssend( sendtype.buf, sendtype.count,
- sendtype.datatype, rank, 0, comm);
- if (err) {
- errs++;
- if (errs < 10) {
- MTestPrintError( err );
- }
- }
- err = MPI_Wait( &req, MPI_STATUS_IGNORE );
- err = MTestCheckRecv( 0, &recvtype );
- if (err) {
- if (errs < 10) {
- printf( "Data in target buffer did not match for destination datatype %s and source datatype %s, count = %d\n",
- MTestGetDatatypeName( &recvtype ),
- MTestGetDatatypeName( &sendtype ),
- count );
- recvtype.printErrors = 1;
- (void)MTestCheckRecv( 0, &recvtype );
- }
- errs += err;
- }
+ err = MPI_Irecv(recvtype.buf, recvtype.count, recvtype.datatype, rank, 0, comm, &req);
+ if (err) {
+ errs++;
+ if (errs < 10) {
+ MTestPrintError(err);
+ }
+ }
- err = MPI_Irecv( recvtype.buf, recvtype.count,
- recvtype.datatype, rank, 0, comm, &req );
- if (err) {
- errs++;
- if (errs < 10) {
- MTestPrintError( err );
- }
- }
-
- err = MPI_Rsend( sendtype.buf, sendtype.count,
- sendtype.datatype, rank, 0, comm);
- if (err) {
- errs++;
- if (errs < 10) {
- MTestPrintError( err );
- }
- }
- err = MPI_Wait( &req, MPI_STATUS_IGNORE );
- err = MTestCheckRecv( 0, &recvtype );
- if (err) {
- if (errs < 10) {
- printf( "Data in target buffer did not match for destination datatype %s and source datatype %s, count = %d\n",
- MTestGetDatatypeName( &recvtype ),
- MTestGetDatatypeName( &sendtype ),
- count );
- recvtype.printErrors = 1;
- (void)MTestCheckRecv( 0, &recvtype );
- }
- errs += err;
- }
+ err = MPI_Rsend(sendtype.buf, sendtype.count, sendtype.datatype, rank, 0, comm);
+ if (err) {
+ errs++;
+ if (errs < 10) {
+ MTestPrintError(err);
+ }
+ }
+ err = MPI_Wait(&req, MPI_STATUS_IGNORE);
+ err = MTestCheckRecv(0, &recvtype);
+ if (err) {
+ if (errs < 10) {
+ printf
+ ("Data in target buffer did not match for destination datatype %s and source datatype %s, count = %d\n",
+ MTestGetDatatypeName(&recvtype), MTestGetDatatypeName(&sendtype), count);
+ recvtype.printErrors = 1;
+ (void) MTestCheckRecv(0, &recvtype);
+ }
+ errs += err;
+ }
- MTestFreeDatatype( &sendtype );
- MTestFreeDatatype( &recvtype );
- }
+ MTestFreeDatatype(&sendtype);
+ MTestFreeDatatype(&recvtype);
+ }
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/pt2pt/waitany-null.c b/test/mpi/pt2pt/waitany-null.c
index 9ba1eef..2cae007 100644
--- a/test/mpi/pt2pt/waitany-null.c
+++ b/test/mpi/pt2pt/waitany-null.c
@@ -20,46 +20,46 @@ int main(int argc, char *argv[])
{
int i, err, errs = 0, rank, toterrs;
- int index;
+ int index;
MPI_Request requests[10];
- MPI_Status statuses[10];
+ MPI_Status statuses[10];
MPI_Init(&argc, &argv);
parse_args(argc, argv);
- for (i=0; i < 10; i++) {
- requests[i] = MPI_REQUEST_NULL;
+ for (i = 0; i < 10; i++) {
+ requests[i] = MPI_REQUEST_NULL;
}
/* begin testing */
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
err = MPI_Waitany(10, requests, &index, statuses);
if (err != MPI_SUCCESS) {
- errs++;
- fprintf(stderr, "MPI_Waitany did not return MPI_SUCCESS\n");
+ errs++;
+ fprintf(stderr, "MPI_Waitany did not return MPI_SUCCESS\n");
}
if (index != MPI_UNDEFINED) {
- errs++;
- fprintf(stderr, "MPI_Waitany did not set index to MPI_UNDEFINED\n");
+ errs++;
+ fprintf(stderr, "MPI_Waitany did not set index to MPI_UNDEFINED\n");
}
/* end testing */
-
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL );
- MPI_Comm_rank( MPI_COMM_WORLD, & rank );
- MPI_Allreduce( &errs, &toterrs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD );
+
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Allreduce(&errs, &toterrs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
if (rank == 0) {
- if (toterrs) {
- fprintf(stderr, " Found %d errors\n", toterrs);
- }
- else {
- printf(" No Errors\n");
- }
+ if (toterrs) {
+ fprintf(stderr, " Found %d errors\n", toterrs);
+ }
+ else {
+ printf(" No Errors\n");
+ }
}
MPI_Finalize();
return 0;
@@ -68,18 +68,18 @@ int main(int argc, char *argv[])
int parse_args(int argc, char **argv)
{
/*
- int ret;
-
- while ((ret = getopt(argc, argv, "v")) >= 0)
- {
- switch (ret) {
- case 'v':
- verbose = 1;
- break;
- }
- }
- */
+ * int ret;
+ *
+ * while ((ret = getopt(argc, argv, "v")) >= 0)
+ * {
+ * switch (ret) {
+ * case 'v':
+ * verbose = 1;
+ * break;
+ * }
+ * }
+ */
if (argc > 1 && strcmp(argv[1], "-v") == 0)
- verbose = 1;
+ verbose = 1;
return 0;
}
diff --git a/test/mpi/pt2pt/waittestnull.c b/test/mpi/pt2pt/waittestnull.c
index d23c91d..6de71e3 100644
--- a/test/mpi/pt2pt/waittestnull.c
+++ b/test/mpi/pt2pt/waittestnull.c
@@ -7,8 +7,8 @@
#include "mpi.h"
#include "mpitest.h"
-/*
- * This program checks that the various MPI_Test and MPI_Wait routines
+/*
+ * This program checks that the various MPI_Test and MPI_Wait routines
* allow both null requests and in the multiple completion cases, empty
* lists of requests.
*/
@@ -17,65 +17,65 @@ int main(int argc, char **argv)
{
int errs = 0;
MPI_Status status, *status_array = 0;
- int count = 0, flag, idx, rc, errlen, *indices=0, outcnt;
+ int count = 0, flag, idx, rc, errlen, *indices = 0, outcnt;
MPI_Request *reqs = 0;
char errmsg[MPI_MAX_ERROR_STRING];
MTest_Init(&argc, &argv);
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
- rc = MPI_Testall( count, reqs, &flag, status_array );
+ rc = MPI_Testall(count, reqs, &flag, status_array);
if (rc != MPI_SUCCESS) {
- MPI_Error_string( rc, errmsg, &errlen );
- printf( "MPI_Testall returned failure: %s\n", errmsg );
- errs ++;
+ MPI_Error_string(rc, errmsg, &errlen);
+ printf("MPI_Testall returned failure: %s\n", errmsg);
+ errs++;
}
else if (!flag) {
- printf( "MPI_Testall( 0, ... ) did not return a true flag\n") ;
- errs++;
+ printf("MPI_Testall(0, ...) did not return a true flag\n");
+ errs++;
}
- rc = MPI_Waitall( count, reqs, status_array );
+ rc = MPI_Waitall(count, reqs, status_array);
if (rc != MPI_SUCCESS) {
- MPI_Error_string( rc, errmsg, &errlen );
- printf( "MPI_Waitall returned failure: %s\n", errmsg );
- errs ++;
+ MPI_Error_string(rc, errmsg, &errlen);
+ printf("MPI_Waitall returned failure: %s\n", errmsg);
+ errs++;
}
- rc = MPI_Testany( count, reqs, &idx, &flag, &status );
+ rc = MPI_Testany(count, reqs, &idx, &flag, &status);
if (rc != MPI_SUCCESS) {
- MPI_Error_string( rc, errmsg, &errlen );
- printf( "MPI_Testany returned failure: %s\n", errmsg );
- errs ++;
+ MPI_Error_string(rc, errmsg, &errlen);
+ printf("MPI_Testany returned failure: %s\n", errmsg);
+ errs++;
}
else if (!flag) {
- printf( "MPI_Testany( 0, ... ) did not return a true flag\n") ;
- errs++;
+ printf("MPI_Testany(0, ...) did not return a true flag\n");
+ errs++;
}
- rc = MPI_Waitany( count, reqs, &idx, &status );
+ rc = MPI_Waitany(count, reqs, &idx, &status);
if (rc != MPI_SUCCESS) {
- MPI_Error_string( rc, errmsg, &errlen );
- printf( "MPI_Waitany returned failure: %s\n", errmsg );
- errs ++;
+ MPI_Error_string(rc, errmsg, &errlen);
+ printf("MPI_Waitany returned failure: %s\n", errmsg);
+ errs++;
}
- rc = MPI_Testsome( count, reqs, &outcnt, indices, status_array );
+ rc = MPI_Testsome(count, reqs, &outcnt, indices, status_array);
if (rc != MPI_SUCCESS) {
- MPI_Error_string( rc, errmsg, &errlen );
- printf( "MPI_Testsome returned failure: %s\n", errmsg );
- errs ++;
+ MPI_Error_string(rc, errmsg, &errlen);
+ printf("MPI_Testsome returned failure: %s\n", errmsg);
+ errs++;
}
- rc = MPI_Waitsome( count, reqs, &outcnt, indices, status_array );
+ rc = MPI_Waitsome(count, reqs, &outcnt, indices, status_array);
if (rc != MPI_SUCCESS) {
- MPI_Error_string( rc, errmsg, &errlen );
- printf( "MPI_Waitsome returned failure: %s\n", errmsg );
- errs ++;
+ MPI_Error_string(rc, errmsg, &errlen);
+ printf("MPI_Waitsome returned failure: %s\n", errmsg);
+ errs++;
}
-
- MTest_Finalize( errs );
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/rma/acc-loc.c b/test/mpi/rma/acc-loc.c
index 18c3e3a..6e76970 100644
--- a/test/mpi/rma/acc-loc.c
+++ b/test/mpi/rma/acc-loc.c
@@ -20,7 +20,8 @@ typedef struct {
static int errors = 0;
-int main(int argc, char **argv) {
+int main(int argc, char **argv)
+{
int me, nproc;
twoint_t *data = NULL;
twoint_t mine;
@@ -76,10 +77,10 @@ int main(int argc, char **argv) {
MPI_Accumulate(&mine, 1, MPI_2INT, 0, 0, 1, MPI_2INT, MPI_MINLOC, win);
MPI_Win_fence(0, win);
- if (me == 0 && (data->loc != nproc-1 || data->val != 1)) {
+ if (me == 0 && (data->loc != nproc - 1 || data->val != 1)) {
errors++;
printf("Expected: { loc = %d, val = %d } Actual: { loc = %d, val = %d }\n",
- nproc-1, 1, data->loc, data->val);
+ nproc - 1, 1, data->loc, data->val);
}
/* All processes perform MAXLOC and MINLOC operations on a 2INT on rank 0.
diff --git a/test/mpi/rma/accfence1.c b/test/mpi/rma/accfence1.c
index 0ede7ab..1b1a40b 100644
--- a/test/mpi/rma/accfence1.c
+++ b/test/mpi/rma/accfence1.c
@@ -12,92 +12,92 @@
static char MTEST_Descrip[] = "Accumulate/Replace with Fence";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int rank, size, source, dest;
- int minsize = 2, count;
- MPI_Comm comm;
- MPI_Win win;
- MPI_Aint extent;
+ int minsize = 2, count;
+ MPI_Comm comm;
+ MPI_Win win;
+ MPI_Aint extent;
MTestDatatype sendtype, recvtype;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- /* The following illustrates the use of the routines to
- run through a selection of communicators and datatypes.
- Use subsets of these for tests that do not involve combinations
- of communicators, datatypes, and counts of datatypes */
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
- /* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
- source = 0;
- dest = size - 1;
-
- MTEST_DATATYPE_FOR_EACH_COUNT(count) {
- while (MTestGetDatatypes( &sendtype, &recvtype, count )) {
- /* Make sure that everyone has a recv buffer */
- recvtype.InitBuf( &recvtype );
+ /* The following illustrates the use of the routines to
+ * run through a selection of communicators and datatypes.
+ * Use subsets of these for tests that do not involve combinations
+ * of communicators, datatypes, and counts of datatypes */
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ /* Determine the sender and receiver */
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+ source = 0;
+ dest = size - 1;
- MPI_Type_extent( recvtype.datatype, &extent );
- MPI_Win_create( recvtype.buf, recvtype.count * extent,
- (int)extent, MPI_INFO_NULL, comm, &win );
- MPI_Win_fence( 0, win );
- if (rank == source) {
- sendtype.InitBuf( &sendtype );
+ MTEST_DATATYPE_FOR_EACH_COUNT(count) {
+ while (MTestGetDatatypes(&sendtype, &recvtype, count)) {
+ /* Make sure that everyone has a recv buffer */
+ recvtype.InitBuf(&recvtype);
- /* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Win_set_errhandler( win, MPI_ERRORS_RETURN );
-
- /* MPI_REPLACE on accumulate is almost the same
- as MPI_Put; the only difference is in the
- handling of overlapping accumulate operations,
- which are not tested here */
- err = MPI_Accumulate( sendtype.buf, sendtype.count,
- sendtype.datatype, dest, 0,
- recvtype.count, recvtype.datatype,
- MPI_REPLACE, win );
- if (err) {
- errs++;
- if (errs < 10) {
- printf( "Accumulate types: send %s, recv %s\n",
- MTestGetDatatypeName( &sendtype ),
- MTestGetDatatypeName( &recvtype ) );
- MTestPrintError( err );
- }
- }
- err = MPI_Win_fence( 0, win );
- if (err) {
- errs++;
- if (errs < 10) {
- MTestPrintError( err );
- }
- }
- }
- else if (rank == dest) {
- MPI_Win_fence( 0, win );
- /* This should have the same effect, in terms of
- transfering data, as a send/recv pair */
- err = MTestCheckRecv( 0, &recvtype );
- if (err) {
- errs += err;
- }
- }
- else {
- MPI_Win_fence( 0, win );
- }
- MPI_Win_free( &win );
- MTestFreeDatatype( &sendtype );
- MTestFreeDatatype( &recvtype );
- }
- }
+ MPI_Type_extent(recvtype.datatype, &extent);
+ MPI_Win_create(recvtype.buf, recvtype.count * extent,
+ (int) extent, MPI_INFO_NULL, comm, &win);
+ MPI_Win_fence(0, win);
+ if (rank == source) {
+ sendtype.InitBuf(&sendtype);
+
+ /* To improve reporting of problems about operations, we
+ * change the error handler to errors return */
+ MPI_Win_set_errhandler(win, MPI_ERRORS_RETURN);
+
+ /* MPI_REPLACE on accumulate is almost the same
+ * as MPI_Put; the only difference is in the
+ * handling of overlapping accumulate operations,
+ * which are not tested here */
+ err = MPI_Accumulate(sendtype.buf, sendtype.count,
+ sendtype.datatype, dest, 0,
+ recvtype.count, recvtype.datatype, MPI_REPLACE, win);
+ if (err) {
+ errs++;
+ if (errs < 10) {
+ printf("Accumulate types: send %s, recv %s\n",
+ MTestGetDatatypeName(&sendtype),
+ MTestGetDatatypeName(&recvtype));
+ MTestPrintError(err);
+ }
+ }
+ err = MPI_Win_fence(0, win);
+ if (err) {
+ errs++;
+ if (errs < 10) {
+ MTestPrintError(err);
+ }
+ }
+ }
+ else if (rank == dest) {
+ MPI_Win_fence(0, win);
+ /* This should have the same effect, in terms of
+ * transfering data, as a send/recv pair */
+ err = MTestCheckRecv(0, &recvtype);
+ if (err) {
+ errs += err;
+ }
+ }
+ else {
+ MPI_Win_fence(0, win);
+ }
+ MPI_Win_free(&win);
+ MTestFreeDatatype(&sendtype);
+ MTestFreeDatatype(&recvtype);
+ }
+ }
MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/rma/accfence2.c b/test/mpi/rma/accfence2.c
index 4366e10..b0bf958 100644
--- a/test/mpi/rma/accfence2.c
+++ b/test/mpi/rma/accfence2.c
@@ -17,72 +17,75 @@
static char MTEST_Descrip[] = "Test MPI_Accumulate with fence";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size, source;
- int minsize = 2, count, i;
- MPI_Comm comm;
- MPI_Win win;
- int *winbuf, *sbuf;
+ int minsize = 2, count, i;
+ MPI_Comm comm;
+ MPI_Win win;
+ int *winbuf, *sbuf;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- /* The following illustrates the use of the routines to
- run through a selection of communicators and datatypes.
- Use subsets of these for tests that do not involve combinations
- of communicators, datatypes, and counts of datatypes */
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
- /* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
- source = 0;
-
- for (count = 1; count < 65000; count = count * 2) {
- /* We compare with an integer value that can be as large as
- size * (count * count + (1/2)*(size-1))
- For large machines (size large), this can exceed the
- maximum integer for some large values of count. We check
- that in advance and break this loop if the above value
- would exceed MAX_INT. Specifically,
+ /* The following illustrates the use of the routines to
+ * run through a selection of communicators and datatypes.
+ * Use subsets of these for tests that do not involve combinations
+ * of communicators, datatypes, and counts of datatypes */
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ /* Determine the sender and receiver */
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+ source = 0;
- size*count*count + (1/2)*size*(size-1) > MAX_INT
- count*count > (MAX_INT/size - (1/2)*(size-1))
- */
- if (count * count > (MAX_INT/size - (size-1)/2)) break;
- winbuf = (int *)malloc( count * sizeof(int) );
- sbuf = (int *)malloc( count * sizeof(int) );
+ for (count = 1; count < 65000; count = count * 2) {
+ /* We compare with an integer value that can be as large as
+ * size * (count * count + (1/2)*(size-1))
+ * For large machines (size large), this can exceed the
+ * maximum integer for some large values of count. We check
+ * that in advance and break this loop if the above value
+ * would exceed MAX_INT. Specifically,
+ *
+ * size*count*count + (1/2)*size*(size-1) > MAX_INT
+ * count*count > (MAX_INT/size - (1/2)*(size-1))
+ */
+ if (count * count > (MAX_INT / size - (size - 1) / 2))
+ break;
+ winbuf = (int *) malloc(count * sizeof(int));
+ sbuf = (int *) malloc(count * sizeof(int));
- for (i=0; i<count; i++) winbuf[i] = 0;
- for (i=0; i<count; i++) sbuf[i] = rank + i * count;
- MPI_Win_create( winbuf, count * sizeof(int), sizeof(int),
- MPI_INFO_NULL, comm, &win );
- MPI_Win_fence( 0, win );
- MPI_Accumulate( sbuf, count, MPI_INT, source, 0, count, MPI_INT,
- MPI_SUM, win );
- MPI_Win_fence( 0, win );
- if (rank == source) {
- /* Check the results */
- for (i=0; i<count; i++) {
- int result = i * count * size + (size*(size-1))/2;
- if (winbuf[i] != result) {
- if (errs < 10) {
- fprintf( stderr, "Winbuf[%d] = %d, expected %d (count = %d, size = %d)\n",
- i, winbuf[i], result, count, size );
- }
- errs++;
- }
- }
- }
- free( winbuf );
- free( sbuf );
- MPI_Win_free( &win );
- }
+ for (i = 0; i < count; i++)
+ winbuf[i] = 0;
+ for (i = 0; i < count; i++)
+ sbuf[i] = rank + i * count;
+ MPI_Win_create(winbuf, count * sizeof(int), sizeof(int), MPI_INFO_NULL, comm, &win);
+ MPI_Win_fence(0, win);
+ MPI_Accumulate(sbuf, count, MPI_INT, source, 0, count, MPI_INT, MPI_SUM, win);
+ MPI_Win_fence(0, win);
+ if (rank == source) {
+ /* Check the results */
+ for (i = 0; i < count; i++) {
+ int result = i * count * size + (size * (size - 1)) / 2;
+ if (winbuf[i] != result) {
+ if (errs < 10) {
+ fprintf(stderr,
+ "Winbuf[%d] = %d, expected %d (count = %d, size = %d)\n", i,
+ winbuf[i], result, count, size);
+ }
+ errs++;
+ }
+ }
+ }
+ free(winbuf);
+ free(sbuf);
+ MPI_Win_free(&win);
+ }
MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/rma/accfence2_am.c b/test/mpi/rma/accfence2_am.c
index b081b2c..0d11fb4 100644
--- a/test/mpi/rma/accfence2_am.c
+++ b/test/mpi/rma/accfence2_am.c
@@ -19,76 +19,79 @@ static char MTEST_Descrip[] = "Test MPI_Accumulate with fence";
/* same as accfence2.c, but uses alloc_mem */
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size, source;
- int minsize = 2, count, i;
- MPI_Comm comm;
- MPI_Win win;
- int *winbuf, *sbuf;
+ int minsize = 2, count, i;
+ MPI_Comm comm;
+ MPI_Win win;
+ int *winbuf, *sbuf;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- /* The following illustrates the use of the routines to
- run through a selection of communicators and datatypes.
- Use subsets of these for tests that do not involve combinations
- of communicators, datatypes, and counts of datatypes */
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
- /* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
- source = 0;
-
- for (count = 32768; count < 65000; count = count * 2) {
+ /* The following illustrates the use of the routines to
+ * run through a selection of communicators and datatypes.
+ * Use subsets of these for tests that do not involve combinations
+ * of communicators, datatypes, and counts of datatypes */
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ /* Determine the sender and receiver */
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+ source = 0;
- /* We compare with an integer value that can be as large as
- size * (count * count + (1/2)*(size-1))
- For large machines (size large), this can exceed the
- maximum integer for some large values of count. We check
- that in advance and break this loop if the above value
- would exceed MAX_INT. Specifically,
+ for (count = 32768; count < 65000; count = count * 2) {
- size*count*count + (1/2)*size*(size-1) > MAX_INT
- count*count > (MAX_INT/size - (1/2)*(size-1))
- */
- if (count * count > (MAX_INT/size - (size-1)/2)) break;
+ /* We compare with an integer value that can be as large as
+ * size * (count * count + (1/2)*(size-1))
+ * For large machines (size large), this can exceed the
+ * maximum integer for some large values of count. We check
+ * that in advance and break this loop if the above value
+ * would exceed MAX_INT. Specifically,
+ *
+ * size*count*count + (1/2)*size*(size-1) > MAX_INT
+ * count*count > (MAX_INT/size - (1/2)*(size-1))
+ */
+ if (count * count > (MAX_INT / size - (size - 1) / 2))
+ break;
- MPI_Alloc_mem( count * sizeof(int), MPI_INFO_NULL, &winbuf );
- MPI_Alloc_mem( count * sizeof(int), MPI_INFO_NULL, &sbuf );
+ MPI_Alloc_mem(count * sizeof(int), MPI_INFO_NULL, &winbuf);
+ MPI_Alloc_mem(count * sizeof(int), MPI_INFO_NULL, &sbuf);
- for (i=0; i<count; i++) winbuf[i] = 0;
- for (i=0; i<count; i++) sbuf[i] = rank + i * count;
- MPI_Win_create( winbuf, count * sizeof(int), sizeof(int),
- MPI_INFO_NULL, comm, &win );
- MPI_Win_fence( 0, win );
- MPI_Accumulate( sbuf, count, MPI_INT, source, 0, count, MPI_INT,
- MPI_SUM, win );
- MPI_Win_fence( 0, win );
- if (rank == source) {
- /* Check the results */
- for (i=0; i<count; i++) {
- int result = i * count * size + (size*(size-1))/2;
- if (winbuf[i] != result) {
- if (errs < 10) {
- fprintf( stderr, "Winbuf[%d] = %d, expected %d (count = %d, size = %d)\n",
- i, winbuf[i], result, count, size );
- }
- errs++;
- }
- }
- }
+ for (i = 0; i < count; i++)
+ winbuf[i] = 0;
+ for (i = 0; i < count; i++)
+ sbuf[i] = rank + i * count;
+ MPI_Win_create(winbuf, count * sizeof(int), sizeof(int), MPI_INFO_NULL, comm, &win);
+ MPI_Win_fence(0, win);
+ MPI_Accumulate(sbuf, count, MPI_INT, source, 0, count, MPI_INT, MPI_SUM, win);
+ MPI_Win_fence(0, win);
+ if (rank == source) {
+ /* Check the results */
+ for (i = 0; i < count; i++) {
+ int result = i * count * size + (size * (size - 1)) / 2;
+ if (winbuf[i] != result) {
+ if (errs < 10) {
+ fprintf(stderr,
+ "Winbuf[%d] = %d, expected %d (count = %d, size = %d)\n", i,
+ winbuf[i], result, count, size);
+ }
+ errs++;
+ }
+ }
+ }
- MPI_Win_free( &win );
+ MPI_Win_free(&win);
MPI_Free_mem(winbuf);
MPI_Free_mem(sbuf);
- }
+ }
MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/rma/accpscw1.c b/test/mpi/rma/accpscw1.c
index 893a577..de6e4fa 100644
--- a/test/mpi/rma/accpscw1.c
+++ b/test/mpi/rma/accpscw1.c
@@ -12,99 +12,99 @@
static char MTEST_Descrip[] = "Accumulate/replace with Post/Start/Complete/Wait";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int rank, size, source, dest;
- int minsize = 2, count;
- MPI_Comm comm;
- MPI_Win win;
- MPI_Aint extent;
- MPI_Group wingroup, neighbors;
+ int minsize = 2, count;
+ MPI_Comm comm;
+ MPI_Win win;
+ MPI_Aint extent;
+ MPI_Group wingroup, neighbors;
MTestDatatype sendtype, recvtype;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- /* The following illustrates the use of the routines to
- run through a selection of communicators and datatypes.
- Use subsets of these for tests that do not involve combinations
- of communicators, datatypes, and counts of datatypes */
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
- /* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
- source = 0;
- dest = size - 1;
-
- MTEST_DATATYPE_FOR_EACH_COUNT(count) {
- while (MTestGetDatatypes( &sendtype, &recvtype, count )) {
- /* Make sure that everyone has a recv buffer */
- recvtype.InitBuf( &recvtype );
+ /* The following illustrates the use of the routines to
+ * run through a selection of communicators and datatypes.
+ * Use subsets of these for tests that do not involve combinations
+ * of communicators, datatypes, and counts of datatypes */
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ /* Determine the sender and receiver */
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+ source = 0;
+ dest = size - 1;
- MPI_Type_extent( recvtype.datatype, &extent );
- MPI_Win_create( recvtype.buf, recvtype.count * extent,
- (int)extent, MPI_INFO_NULL, comm, &win );
- MPI_Win_get_group( win, &wingroup );
- if (rank == source) {
- /* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Win_set_errhandler( win, MPI_ERRORS_RETURN );
- sendtype.InitBuf( &sendtype );
-
- /* Neighbor is dest only */
- MPI_Group_incl( wingroup, 1, &dest, &neighbors );
- err = MPI_Win_start( neighbors, 0, win );
- if (err) {
- errs++;
- if (errs < 10) {
- MTestPrintError( err );
- }
- }
- MPI_Group_free( &neighbors );
- err = MPI_Accumulate( sendtype.buf, sendtype.count,
- sendtype.datatype, dest, 0,
- recvtype.count, recvtype.datatype,
- MPI_REPLACE, win );
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- err = MPI_Win_complete( win );
- if (err) {
- errs++;
- if (errs < 10) {
- MTestPrintError( err );
- }
- }
- }
- else if (rank == dest) {
- MPI_Group_incl( wingroup, 1, &source, &neighbors );
- MPI_Win_post( neighbors, 0, win );
- MPI_Group_free( &neighbors );
- MPI_Win_wait( win );
- /* This should have the same effect, in terms of
- transfering data, as a send/recv pair */
- err = MTestCheckRecv( 0, &recvtype );
- if (err) {
- errs += errs;
- }
- }
- else {
- /* Nothing; the other processes need not call any
- MPI routines */
- ;
- }
- MPI_Win_free( &win );
- MTestFreeDatatype( &sendtype );
- MTestFreeDatatype( &recvtype );
- MPI_Group_free( &wingroup );
- }
- }
- MTestFreeComm( &comm );
+ MTEST_DATATYPE_FOR_EACH_COUNT(count) {
+ while (MTestGetDatatypes(&sendtype, &recvtype, count)) {
+ /* Make sure that everyone has a recv buffer */
+ recvtype.InitBuf(&recvtype);
+
+ MPI_Type_extent(recvtype.datatype, &extent);
+ MPI_Win_create(recvtype.buf, recvtype.count * extent,
+ (int) extent, MPI_INFO_NULL, comm, &win);
+ MPI_Win_get_group(win, &wingroup);
+ if (rank == source) {
+ /* To improve reporting of problems about operations, we
+ * change the error handler to errors return */
+ MPI_Win_set_errhandler(win, MPI_ERRORS_RETURN);
+ sendtype.InitBuf(&sendtype);
+
+ /* Neighbor is dest only */
+ MPI_Group_incl(wingroup, 1, &dest, &neighbors);
+ err = MPI_Win_start(neighbors, 0, win);
+ if (err) {
+ errs++;
+ if (errs < 10) {
+ MTestPrintError(err);
+ }
+ }
+ MPI_Group_free(&neighbors);
+ err = MPI_Accumulate(sendtype.buf, sendtype.count,
+ sendtype.datatype, dest, 0,
+ recvtype.count, recvtype.datatype, MPI_REPLACE, win);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ err = MPI_Win_complete(win);
+ if (err) {
+ errs++;
+ if (errs < 10) {
+ MTestPrintError(err);
+ }
+ }
+ }
+ else if (rank == dest) {
+ MPI_Group_incl(wingroup, 1, &source, &neighbors);
+ MPI_Win_post(neighbors, 0, win);
+ MPI_Group_free(&neighbors);
+ MPI_Win_wait(win);
+ /* This should have the same effect, in terms of
+ * transfering data, as a send/recv pair */
+ err = MTestCheckRecv(0, &recvtype);
+ if (err) {
+ errs += errs;
+ }
+ }
+ else {
+ /* Nothing; the other processes need not call any
+ * MPI routines */
+ ;
+ }
+ MPI_Win_free(&win);
+ MTestFreeDatatype(&sendtype);
+ MTestFreeDatatype(&recvtype);
+ MPI_Group_free(&wingroup);
+ }
+ }
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/rma/adlb_mimic1.c b/test/mpi/rma/adlb_mimic1.c
index 22767fb..661f72f 100644
--- a/test/mpi/rma/adlb_mimic1.c
+++ b/test/mpi/rma/adlb_mimic1.c
@@ -12,8 +12,8 @@
#include "mpitest.h"
#define NUM_TIMES 500
-#define MAX_BUF_SIZE (400 * 1024 * 1024) /* 400 MB */
-#define PUT_SIZE (1024 * 1024) /* 1MB */
+#define MAX_BUF_SIZE (400 * 1024 * 1024) /* 400 MB */
+#define PUT_SIZE (1024 * 1024) /* 1MB */
/*
static char MTEST_Descrip[] = "ADLB mimic test";
@@ -61,36 +61,34 @@ int main(int argc, char **argv)
MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
if (comm_size <= 2) {
- fprintf( stderr, "This test requires at least 3 processes\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "This test requires at least 3 processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
max_buf_size = comm_size * put_size;
if (max_buf_size > MAX_BUF_SIZE) {
- fprintf( stderr, "Too many processes in COMM_WORLD (max is %d)\n",
- MAX_BUF_SIZE / put_size );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Too many processes in COMM_WORLD (max is %d)\n", MAX_BUF_SIZE / put_size);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
/* If alloc mem returns an error (because too much memory is requested */
- MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
rc = MPI_Alloc_mem(max_buf_size, MPI_INFO_NULL, (void *) &rma_win_addr);
if (rc) {
- MTestPrintErrorMsg( "Unable to MPI_Alloc_mem space (not an error)", rc );
- MPI_Abort( MPI_COMM_WORLD, 0 );
+ MTestPrintErrorMsg("Unable to MPI_Alloc_mem space (not an error)", rc);
+ MPI_Abort(MPI_COMM_WORLD, 0);
}
memset(rma_win_addr, 0, max_buf_size);
- MPI_Win_create((void *) rma_win_addr, max_buf_size, 1, MPI_INFO_NULL,
- MPI_COMM_WORLD, &win);
+ MPI_Win_create((void *) rma_win_addr, max_buf_size, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &win);
/* Note that it is not necessary to use MPI_Alloc_mem for the memory that
- is not part of the MPI_Win. */
+ * is not part of the MPI_Win. */
rc = MPI_Alloc_mem(put_size, MPI_INFO_NULL, (void *) &local_buf);
if (rc) {
- MTestPrintErrorMsg( "Unable to MPI_Alloc_mem space (not an error)", rc );
- MPI_Abort( MPI_COMM_WORLD, 0 );
+ MTestPrintErrorMsg("Unable to MPI_Alloc_mem space (not an error)", rc);
+ MPI_Abort(MPI_COMM_WORLD, 0);
}
for (i = 0; i < put_size; i++)
@@ -98,7 +96,7 @@ int main(int argc, char **argv)
MPI_Barrier(MPI_COMM_WORLD);
- if (comm_rank == 0) { /* target */
+ if (comm_rank == 0) { /* target */
for (i = 0; i < (NUM_TIMES * (comm_size - 2)); i++) {
/* Wait for a message from the server to notify me that
* someone put some data in my window */
@@ -108,9 +106,8 @@ int main(int argc, char **argv)
* data in my local window. Check the last byte to make
* sure we got it correctly. */
MPI_Win_lock(MPI_LOCK_SHARED, 0, 0, win);
- MPI_Get((void *) &check, 1, MPI_CHAR, 0,
- ((by_rank + 1) * put_size) - 1, 1,
- MPI_CHAR, win);
+ MPI_Get((void *) &check, 1, MPI_CHAR, 0,
+ ((by_rank + 1) * put_size) - 1, 1, MPI_CHAR, win);
MPI_Win_unlock(0, win);
/* If this is not the value I expect, count it as an error */
@@ -125,13 +122,12 @@ int main(int argc, char **argv)
}
}
- else if (comm_rank == 1) { /* server */
+ else if (comm_rank == 1) { /* server */
for (i = 0; i < (NUM_TIMES * (comm_size - 2)); i++) {
/* Wait for a message from any of the origin processes
* informing me that it has put data to the target
* process */
- MPI_Recv(NULL, 0, MPI_INT, MPI_ANY_SOURCE, 0, MPI_COMM_WORLD,
- &status);
+ MPI_Recv(NULL, 0, MPI_INT, MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, &status);
by_rank = status.MPI_SOURCE;
/* Tell the target process that it should be seeing some
@@ -140,12 +136,12 @@ int main(int argc, char **argv)
}
}
- else { /* origin */
+ else { /* origin */
for (i = 0; i < NUM_TIMES; i++) {
/* Put some data in the target window */
MPI_Win_lock(MPI_LOCK_SHARED, 0, 0, win);
- MPI_Put(local_buf, put_size, MPI_CHAR, 0, comm_rank * put_size,
- put_size, MPI_CHAR, win);
+ MPI_Put(local_buf, put_size, MPI_CHAR, 0, comm_rank * put_size,
+ put_size, MPI_CHAR, win);
MPI_Win_unlock(0, win);
/* Tell the server that the put has completed */
diff --git a/test/mpi/rma/aint.c b/test/mpi/rma/aint.c
index 888ecb4..72c10d2 100644
--- a/test/mpi/rma/aint.c
+++ b/test/mpi/rma/aint.c
@@ -24,7 +24,7 @@ int main(int argc, char **argv)
int target_rank;
MPI_Aint bases[2];
MPI_Aint disp, offset;
- MPI_Win win;
+ MPI_Win win;
MTest_Init(&argc, &argv);
@@ -40,7 +40,8 @@ int main(int argc, char **argv)
target_rank = 1;
array[0] = 1234;
MPI_Get_address(&array[512], &bases[0]);
- } else if (rank == 1) {
+ }
+ else if (rank == 1) {
target_rank = 0;
array[1023] = 1234;
MPI_Get_address(&array[512], &bases[1]);
@@ -50,14 +51,15 @@ int main(int argc, char **argv)
MPI_Allgather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, bases, 1, MPI_AINT, MPI_COMM_WORLD);
MPI_Win_create_dynamic(MPI_INFO_NULL, MPI_COMM_WORLD, &win);
- MPI_Win_attach(win, array, sizeof(int)*1024);
+ MPI_Win_attach(win, array, sizeof(int) * 1024);
/* Do MPI_Aint addressing arithmetic */
if (rank == 0) {
- disp = sizeof(int)*511;
- offset = MPI_Aint_add(bases[1], disp); /* offset points to array[1023]*/
- } else if (rank == 1) {
- disp = sizeof(int)*512;
+ disp = sizeof(int) * 511;
+ offset = MPI_Aint_add(bases[1], disp); /* offset points to array[1023] */
+ }
+ else if (rank == 1) {
+ disp = sizeof(int) * 512;
offset = MPI_Aint_diff(bases[0], disp); /* offset points to array[0] */
}
diff --git a/test/mpi/rma/allocmem.c b/test/mpi/rma/allocmem.c
index 1969941..1255628 100644
--- a/test/mpi/rma/allocmem.c
+++ b/test/mpi/rma/allocmem.c
@@ -12,38 +12,38 @@
static char MTEST_Descrip[] = "Simple test that alloc_mem and free_mem work together";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int j, count;
char *ap;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Errhandler_set( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
- for (count=1; count < 128000; count *= 2) {
-
- err = MPI_Alloc_mem( count, MPI_INFO_NULL, &ap );
- if (err) {
- int errclass;
- /* An error of MPI_ERR_NO_MEM is allowed */
- MPI_Error_class( err, &errclass );
- if (errclass != MPI_ERR_NO_MEM) {
- errs++;
- MTestPrintError( err );
- }
-
- }
- else {
- /* Access all of this memory */
- for (j=0; j<count; j++) {
- ap[j] = (char)(j & 0x7f);
- }
- MPI_Free_mem( ap );
- }
+ MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+ for (count = 1; count < 128000; count *= 2) {
+
+ err = MPI_Alloc_mem(count, MPI_INFO_NULL, &ap);
+ if (err) {
+ int errclass;
+ /* An error of MPI_ERR_NO_MEM is allowed */
+ MPI_Error_class(err, &errclass);
+ if (errclass != MPI_ERR_NO_MEM) {
+ errs++;
+ MTestPrintError(err);
+ }
+
+ }
+ else {
+ /* Access all of this memory */
+ for (j = 0; j < count; j++) {
+ ap[j] = (char) (j & 0x7f);
+ }
+ MPI_Free_mem(ap);
+ }
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/rma/at_complete.c b/test/mpi/rma/at_complete.c
index 9ba38a3..f389a30 100644
--- a/test/mpi/rma/at_complete.c
+++ b/test/mpi/rma/at_complete.c
@@ -12,7 +12,8 @@
#define WIN_SIZE (PUT_SIZE+GET_SIZE)
#define LOOP 100
-int main (int argc, char **argv) {
+int main(int argc, char **argv)
+{
MPI_Win win;
int i, k, rank, nproc;
int win_buf[WIN_SIZE], orig_get_buf[GET_SIZE], orig_put_buf[PUT_SIZE];
@@ -29,9 +30,12 @@ int main (int argc, char **argv) {
MPI_Group_incl(comm_group, 1, &orig_rank, &orig_group);
MPI_Group_incl(comm_group, 1, &dest_rank, &dest_group);
- for (i = 0; i < PUT_SIZE; i++) orig_put_buf[i] = 1;
- for (i = 0; i < GET_SIZE; i++) orig_get_buf[i] = 0;
- for (i = 0; i < WIN_SIZE; i++) win_buf[i] = 1;
+ for (i = 0; i < PUT_SIZE; i++)
+ orig_put_buf[i] = 1;
+ for (i = 0; i < GET_SIZE; i++)
+ orig_get_buf[i] = 0;
+ for (i = 0; i < WIN_SIZE; i++)
+ win_buf[i] = 1;
MPI_Win_create(win_buf, sizeof(int) * WIN_SIZE, sizeof(int), MPI_INFO_NULL,
MPI_COMM_WORLD, &win);
@@ -43,9 +47,9 @@ int main (int argc, char **argv) {
if (rank == orig_rank) {
MPI_Win_fence(MPI_MODE_NOPRECEDE, win);
MPI_Get(orig_get_buf, GET_SIZE, MPI_INT,
- dest_rank, PUT_SIZE/*disp*/, GET_SIZE, MPI_INT, win);
+ dest_rank, PUT_SIZE /*disp */ , GET_SIZE, MPI_INT, win);
MPI_Put(orig_put_buf, PUT_SIZE, MPI_INT,
- dest_rank, 0/*disp*/, PUT_SIZE, MPI_INT, win);
+ dest_rank, 0 /*disp */ , PUT_SIZE, MPI_INT, win);
MPI_Win_fence(MPI_MODE_NOSUCCEED, win);
/* check GET result values */
@@ -56,22 +60,26 @@ int main (int argc, char **argv) {
errors++;
}
}
- } else if (rank == dest_rank) {
+ }
+ else if (rank == dest_rank) {
MPI_Win_fence(MPI_MODE_NOPRECEDE, win);
MPI_Win_fence(MPI_MODE_NOSUCCEED, win);
/* modify the last element in window */
MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, win);
- win_buf[WIN_SIZE-1] = 2;
+ win_buf[WIN_SIZE - 1] = 2;
MPI_Win_unlock(rank, win);
}
MPI_Barrier(MPI_COMM_WORLD);
/* reset buffers */
- for (i = 0; i < PUT_SIZE; i++) orig_put_buf[i] = 1;
- for (i = 0; i < GET_SIZE; i++) orig_get_buf[i] = 0;
+ for (i = 0; i < PUT_SIZE; i++)
+ orig_put_buf[i] = 1;
+ for (i = 0; i < GET_SIZE; i++)
+ orig_get_buf[i] = 0;
MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, win);
- for (i = 0; i < WIN_SIZE; i++) win_buf[i] = 1;
+ for (i = 0; i < WIN_SIZE; i++)
+ win_buf[i] = 1;
MPI_Win_unlock(rank, win);
MPI_Barrier(MPI_COMM_WORLD);
@@ -80,9 +88,9 @@ int main (int argc, char **argv) {
if (rank == orig_rank) {
MPI_Win_start(dest_group, 0, win);
MPI_Get(orig_get_buf, GET_SIZE, MPI_INT,
- dest_rank, PUT_SIZE/*disp*/, GET_SIZE, MPI_INT, win);
+ dest_rank, PUT_SIZE /*disp */ , GET_SIZE, MPI_INT, win);
MPI_Put(orig_put_buf, PUT_SIZE, MPI_INT,
- dest_rank, 0/*disp*/, PUT_SIZE, MPI_INT, win);
+ dest_rank, 0 /*disp */ , PUT_SIZE, MPI_INT, win);
MPI_Win_complete(win);
/* check GET result values */
@@ -100,16 +108,19 @@ int main (int argc, char **argv) {
/* modify the last element in window */
MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, win);
- win_buf[WIN_SIZE-1] = 2;
+ win_buf[WIN_SIZE - 1] = 2;
MPI_Win_unlock(rank, win);
}
MPI_Barrier(MPI_COMM_WORLD);
/* reset buffers */
- for (i = 0; i < PUT_SIZE; i++) orig_put_buf[i] = 1;
- for (i = 0; i < GET_SIZE; i++) orig_get_buf[i] = 0;
+ for (i = 0; i < PUT_SIZE; i++)
+ orig_put_buf[i] = 1;
+ for (i = 0; i < GET_SIZE; i++)
+ orig_get_buf[i] = 0;
MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, win);
- for (i = 0; i < WIN_SIZE; i++) win_buf[i] = 1;
+ for (i = 0; i < WIN_SIZE; i++)
+ win_buf[i] = 1;
MPI_Win_unlock(rank, win);
MPI_Barrier(MPI_COMM_WORLD);
}
diff --git a/test/mpi/rma/attrorderwin.c b/test/mpi/rma/attrorderwin.c
index 972dda7..9d6ef87 100644
--- a/test/mpi/rma/attrorderwin.c
+++ b/test/mpi/rma/attrorderwin.c
@@ -13,117 +13,113 @@ static char MTestDescrip[] = "Test creating and inserting attributes in \
different orders to ensure that the list management code handles all cases.";
*/
-int checkAttrs( MPI_Win win, int n, int key[], int attrval[] );
-int checkNoAttrs( MPI_Win win, int n, int key[] );
+int checkAttrs(MPI_Win win, int n, int key[], int attrval[]);
+int checkNoAttrs(MPI_Win win, int n, int key[]);
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int key[3], attrval[3];
int i;
int buf[1];
MPI_Comm comm;
- MPI_Win win;
+ MPI_Win win;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
{
- comm = MPI_COMM_WORLD;
- MPI_Win_create( buf, sizeof(int), sizeof(int), MPI_INFO_NULL,
- comm, &win );
-
- /* Create key values */
- for (i=0; i<3; i++) {
- MPI_Win_create_keyval( MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN,
- &key[i], (void *)0 );
- attrval[i] = 1024 * i;
- }
-
- /* Insert attribute in several orders. Test after put with get,
- then delete, then confirm delete with get. */
-
- MPI_Win_set_attr( win, key[2], &attrval[2] );
- MPI_Win_set_attr( win, key[1], &attrval[1] );
- MPI_Win_set_attr( win, key[0], &attrval[0] );
-
- errs += checkAttrs( win, 3, key, attrval );
-
- MPI_Win_delete_attr( win, key[0] );
- MPI_Win_delete_attr( win, key[1] );
- MPI_Win_delete_attr( win, key[2] );
-
- errs += checkNoAttrs( win, 3, key );
-
- MPI_Win_set_attr( win, key[1], &attrval[1] );
- MPI_Win_set_attr( win, key[2], &attrval[2] );
- MPI_Win_set_attr( win, key[0], &attrval[0] );
-
- errs += checkAttrs( win, 3, key, attrval );
-
- MPI_Win_delete_attr( win, key[2] );
- MPI_Win_delete_attr( win, key[1] );
- MPI_Win_delete_attr( win, key[0] );
-
- errs += checkNoAttrs( win, 3, key );
-
- MPI_Win_set_attr( win, key[0], &attrval[0] );
- MPI_Win_set_attr( win, key[1], &attrval[1] );
- MPI_Win_set_attr( win, key[2], &attrval[2] );
-
- errs += checkAttrs( win, 3, key, attrval );
-
- MPI_Win_delete_attr( win, key[1] );
- MPI_Win_delete_attr( win, key[2] );
- MPI_Win_delete_attr( win, key[0] );
-
- errs += checkNoAttrs( win, 3, key );
-
- for (i=0; i<3; i++) {
- MPI_Win_free_keyval( &key[i] );
- }
- MPI_Win_free( &win );
+ comm = MPI_COMM_WORLD;
+ MPI_Win_create(buf, sizeof(int), sizeof(int), MPI_INFO_NULL, comm, &win);
+
+ /* Create key values */
+ for (i = 0; i < 3; i++) {
+ MPI_Win_create_keyval(MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN, &key[i], (void *) 0);
+ attrval[i] = 1024 * i;
+ }
+
+ /* Insert attribute in several orders. Test after put with get,
+ * then delete, then confirm delete with get. */
+
+ MPI_Win_set_attr(win, key[2], &attrval[2]);
+ MPI_Win_set_attr(win, key[1], &attrval[1]);
+ MPI_Win_set_attr(win, key[0], &attrval[0]);
+
+ errs += checkAttrs(win, 3, key, attrval);
+
+ MPI_Win_delete_attr(win, key[0]);
+ MPI_Win_delete_attr(win, key[1]);
+ MPI_Win_delete_attr(win, key[2]);
+
+ errs += checkNoAttrs(win, 3, key);
+
+ MPI_Win_set_attr(win, key[1], &attrval[1]);
+ MPI_Win_set_attr(win, key[2], &attrval[2]);
+ MPI_Win_set_attr(win, key[0], &attrval[0]);
+
+ errs += checkAttrs(win, 3, key, attrval);
+
+ MPI_Win_delete_attr(win, key[2]);
+ MPI_Win_delete_attr(win, key[1]);
+ MPI_Win_delete_attr(win, key[0]);
+
+ errs += checkNoAttrs(win, 3, key);
+
+ MPI_Win_set_attr(win, key[0], &attrval[0]);
+ MPI_Win_set_attr(win, key[1], &attrval[1]);
+ MPI_Win_set_attr(win, key[2], &attrval[2]);
+
+ errs += checkAttrs(win, 3, key, attrval);
+
+ MPI_Win_delete_attr(win, key[1]);
+ MPI_Win_delete_attr(win, key[2]);
+ MPI_Win_delete_attr(win, key[0]);
+
+ errs += checkNoAttrs(win, 3, key);
+
+ for (i = 0; i < 3; i++) {
+ MPI_Win_free_keyval(&key[i]);
+ }
+ MPI_Win_free(&win);
}
-
- MTest_Finalize( errs );
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
-int checkAttrs( MPI_Win win, int n, int key[], int attrval[] )
+int checkAttrs(MPI_Win win, int n, int key[], int attrval[])
{
int errs = 0;
int i, flag, *val_p;
- for (i=0; i<n; i++) {
- MPI_Win_get_attr( win, key[i], &val_p, &flag );
- if (!flag) {
- errs++;
- fprintf( stderr, "Attribute for key %d not set\n", i );
- }
- else if (val_p != &attrval[i]) {
- errs++;
- fprintf( stderr, "Atribute value for key %d not correct\n",
- i );
- }
+ for (i = 0; i < n; i++) {
+ MPI_Win_get_attr(win, key[i], &val_p, &flag);
+ if (!flag) {
+ errs++;
+ fprintf(stderr, "Attribute for key %d not set\n", i);
+ }
+ else if (val_p != &attrval[i]) {
+ errs++;
+ fprintf(stderr, "Atribute value for key %d not correct\n", i);
+ }
}
return errs;
}
-int checkNoAttrs( MPI_Win win, int n, int key[] )
+int checkNoAttrs(MPI_Win win, int n, int key[])
{
int errs = 0;
int i, flag, *val_p;
- for (i=0; i<n; i++) {
- MPI_Win_get_attr( win, key[i], &val_p, &flag );
- if (flag) {
- errs++;
- fprintf( stderr, "Attribute for key %d set but should be deleted\n", i );
- }
+ for (i = 0; i < n; i++) {
+ MPI_Win_get_attr(win, key[i], &val_p, &flag);
+ if (flag) {
+ errs++;
+ fprintf(stderr, "Attribute for key %d set but should be deleted\n", i);
+ }
}
return errs;
}
-
diff --git a/test/mpi/rma/baseattrwin.c b/test/mpi/rma/baseattrwin.c
index fc1ccc9..1ecda21 100644
--- a/test/mpi/rma/baseattrwin.c
+++ b/test/mpi/rma/baseattrwin.c
@@ -8,73 +8,71 @@
#include "mpi.h"
#include "mpitest.h"
-int main( int argc, char **argv)
+int main(int argc, char **argv)
{
- int errs = 0;
+ int errs = 0;
void *v;
- int flag;
- int rank, size;
+ int flag;
+ int rank, size;
int base[1024];
MPI_Aint n;
- int disp;
+ int disp;
MPI_Win win;
- MTest_Init( &argc, &argv );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
/* Create a window; then extract the values */
- n = 1024;
+ n = 1024;
disp = 4;
- MPI_Win_create( base, n, disp, MPI_INFO_NULL, MPI_COMM_WORLD, &win );
+ MPI_Win_create(base, n, disp, MPI_INFO_NULL, MPI_COMM_WORLD, &win);
- MPI_Win_get_attr( win, MPI_WIN_BASE, &v, &flag );
+ MPI_Win_get_attr(win, MPI_WIN_BASE, &v, &flag);
if (!flag) {
- errs++;
- fprintf( stderr, "Could not get WIN_BASE\n" );
+ errs++;
+ fprintf(stderr, "Could not get WIN_BASE\n");
}
else {
- /* MPI 2.1, section 11.2.2. v must be a pointer to the start of the
- window. It is not a pointer to a pointer to the start of the window.
- */
- if ((int*)v != base) {
- errs++;
- fprintf( stderr, "Got incorrect value for WIN_BASE (%p, should be %p)",
- v, base );
- }
+ /* MPI 2.1, section 11.2.2. v must be a pointer to the start of the
+ * window. It is not a pointer to a pointer to the start of the window.
+ */
+ if ((int *) v != base) {
+ errs++;
+ fprintf(stderr, "Got incorrect value for WIN_BASE (%p, should be %p)", v, base);
+ }
}
- MPI_Win_get_attr( win, MPI_WIN_SIZE, &v, &flag );
+ MPI_Win_get_attr(win, MPI_WIN_SIZE, &v, &flag);
if (!flag) {
- errs++;
- fprintf( stderr, "Could not get WIN_SIZE\n" );
+ errs++;
+ fprintf(stderr, "Could not get WIN_SIZE\n");
}
else {
- MPI_Aint vval = *(MPI_Aint*)v;
- if (vval != n) {
- errs++;
- fprintf( stderr, "Got wrong value for WIN_SIZE (%ld, should be %ld)\n",
- (long) vval, (long) n );
- }
+ MPI_Aint vval = *(MPI_Aint *) v;
+ if (vval != n) {
+ errs++;
+ fprintf(stderr, "Got wrong value for WIN_SIZE (%ld, should be %ld)\n",
+ (long) vval, (long) n);
+ }
}
- MPI_Win_get_attr( win, MPI_WIN_DISP_UNIT, &v, &flag );
+ MPI_Win_get_attr(win, MPI_WIN_DISP_UNIT, &v, &flag);
if (!flag) {
- errs++;
- fprintf( stderr, "Could not get WIN_DISP_UNIT\n" );
+ errs++;
+ fprintf(stderr, "Could not get WIN_DISP_UNIT\n");
}
else {
- int vval = *(int*)v;
- if (vval != disp) {
- errs++;
- fprintf( stderr, "Got wrong value for WIN_DISP_UNIT (%d, should be %d)\n",
- vval, disp );
- }
+ int vval = *(int *) v;
+ if (vval != disp) {
+ errs++;
+ fprintf(stderr, "Got wrong value for WIN_DISP_UNIT (%d, should be %d)\n", vval, disp);
+ }
}
MPI_Win_free(&win);
- MTest_Finalize( errs );
- MPI_Finalize( );
-
+ MTest_Finalize(errs);
+ MPI_Finalize();
+
return 0;
}
diff --git a/test/mpi/rma/compare_and_swap.c b/test/mpi/rma/compare_and_swap.c
index 2a678a5..c9f1696 100644
--- a/test/mpi/rma/compare_and_swap.c
+++ b/test/mpi/rma/compare_and_swap.c
@@ -14,11 +14,12 @@
#define ITER 100
-int main(int argc, char **argv) {
- int i, rank, nproc;
- int errors = 0, all_errors = 0;
- int *val_ptr;
- MPI_Win win;
+int main(int argc, char **argv)
+{
+ int i, rank, nproc;
+ int errors = 0, all_errors = 0;
+ int *val_ptr;
+ MPI_Win win;
MPI_Init(&argc, &argv);
@@ -39,8 +40,8 @@ int main(int argc, char **argv) {
MPI_Compare_and_swap(&next, &i, &result, MPI_INT, rank, 0, win);
MPI_Win_unlock(rank, win);
if (result != i) {
- SQUELCH( printf("%d->%d -- Error: next=%d compare=%d result=%d val=%d\n", rank,
- rank, next, i, result, *val_ptr); );
+ SQUELCH(printf("%d->%d -- Error: next=%d compare=%d result=%d val=%d\n", rank,
+ rank, next, i, result, *val_ptr););
errors++;
}
}
@@ -55,12 +56,12 @@ int main(int argc, char **argv) {
for (i = 0; i < ITER; i++) {
int next = i + 1, result = -1;
- MPI_Win_lock(MPI_LOCK_EXCLUSIVE, (rank+1)%nproc, 0, win);
- MPI_Compare_and_swap(&next, &i, &result, MPI_INT, (rank+1)%nproc, 0, win);
- MPI_Win_unlock((rank+1)%nproc, win);
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, (rank + 1) % nproc, 0, win);
+ MPI_Compare_and_swap(&next, &i, &result, MPI_INT, (rank + 1) % nproc, 0, win);
+ MPI_Win_unlock((rank + 1) % nproc, win);
if (result != i) {
- SQUELCH( printf("%d->%d -- Error: next=%d compare=%d result=%d val=%d\n", rank,
- (rank+1)%nproc, next, i, result, *val_ptr); );
+ SQUELCH(printf("%d->%d -- Error: next=%d compare=%d result=%d val=%d\n", rank,
+ (rank + 1) % nproc, next, i, result, *val_ptr););
errors++;
}
}
@@ -89,7 +90,7 @@ int main(int argc, char **argv) {
if (rank == 0 && nproc > 1) {
if (*val_ptr != ITER) {
- SQUELCH( printf("%d - Error: expected=%d val=%d\n", rank, ITER, *val_ptr); );
+ SQUELCH(printf("%d - Error: expected=%d val=%d\n", rank, ITER, *val_ptr););
errors++;
}
}
diff --git a/test/mpi/rma/contention_put.c b/test/mpi/rma/contention_put.c
index 2b2be30..b549c9b 100644
--- a/test/mpi/rma/contention_put.c
+++ b/test/mpi/rma/contention_put.c
@@ -26,80 +26,82 @@ int test_put(void);
int test_put(void)
{
- MPI_Win dst_win;
- double *dst_buf;
- double src_buf[MAXELEMS];
- int i, j;
- int errs = 0;
+ MPI_Win dst_win;
+ double *dst_buf;
+ double src_buf[MAXELEMS];
+ int i, j;
+ int errs = 0;
- MPI_Alloc_mem(sizeof(double)*nproc*MAXELEMS, MPI_INFO_NULL, &dst_buf);
- MPI_Win_create(dst_buf, sizeof(double)*nproc*MAXELEMS, 1, MPI_INFO_NULL,
- MPI_COMM_WORLD, &dst_win);
+ MPI_Alloc_mem(sizeof(double) * nproc * MAXELEMS, MPI_INFO_NULL, &dst_buf);
+ MPI_Win_create(dst_buf, sizeof(double) * nproc * MAXELEMS, 1, MPI_INFO_NULL,
+ MPI_COMM_WORLD, &dst_win);
- for (i = 0; i < MAXELEMS; i++)
- src_buf[i] = me + 1.0;
+ for (i = 0; i < MAXELEMS; i++)
+ src_buf[i] = me + 1.0;
- MPI_Win_lock(MPI_LOCK_EXCLUSIVE, me, 0, dst_win);
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, me, 0, dst_win);
- for (i = 0; i < nproc*MAXELEMS; i++)
- dst_buf[i] = 0.0;
+ for (i = 0; i < nproc * MAXELEMS; i++)
+ dst_buf[i] = 0.0;
- MPI_Win_unlock(me, dst_win);
+ MPI_Win_unlock(me, dst_win);
- MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Barrier(MPI_COMM_WORLD);
- for(i = 0; i < nproc; i++) {
- /* int target = (me + i) % nproc; */
- int target = i;
- for(j = 0; j < COUNT; j++) {
- if (verbose) printf("%2d -> %2d [%2d]\n", me, target, j);
- MPI_Win_lock(MPI_LOCK_EXCLUSIVE, target, 0, dst_win);
- MPI_Put(&src_buf[j], sizeof(double), MPI_BYTE, target,
- (me*MAXELEMS+j)*sizeof(double), sizeof(double), MPI_BYTE, dst_win);
- MPI_Win_unlock(target, dst_win);
+ for (i = 0; i < nproc; i++) {
+ /* int target = (me + i) % nproc; */
+ int target = i;
+ for (j = 0; j < COUNT; j++) {
+ if (verbose)
+ printf("%2d -> %2d [%2d]\n", me, target, j);
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, target, 0, dst_win);
+ MPI_Put(&src_buf[j], sizeof(double), MPI_BYTE, target,
+ (me * MAXELEMS + j) * sizeof(double), sizeof(double), MPI_BYTE, dst_win);
+ MPI_Win_unlock(target, dst_win);
+ }
}
- }
-
- MPI_Barrier(MPI_COMM_WORLD);
-
- /* Check that the correct data was returned. This assumes that the
- systems have the same data representations */
- for (i=0; i<nproc; i++) {
- for (j=0; j<COUNT; j++) {
- if (dst_buf[i*MAXELEMS+j] != 1.0 + i) {
- errs++;
- printf( "dst_buf[%d] = %e, expected %e\n",
- i*MAXELEMS+j, dst_buf[i*MAXELEMS+j], 1.0 + i );
- }
- }
- }
-
- MPI_Win_free(&dst_win);
- MPI_Free_mem(dst_buf);
-
- return errs;
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ /* Check that the correct data was returned. This assumes that the
+ * systems have the same data representations */
+ for (i = 0; i < nproc; i++) {
+ for (j = 0; j < COUNT; j++) {
+ if (dst_buf[i * MAXELEMS + j] != 1.0 + i) {
+ errs++;
+ printf("dst_buf[%d] = %e, expected %e\n",
+ i * MAXELEMS + j, dst_buf[i * MAXELEMS + j], 1.0 + i);
+ }
+ }
+ }
+
+ MPI_Win_free(&dst_win);
+ MPI_Free_mem(dst_buf);
+
+ return errs;
}
-int main(int argc, char* argv[]) {
+int main(int argc, char *argv[])
+{
int errs = 0;
MTest_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &nproc);
MPI_Comm_rank(MPI_COMM_WORLD, &me);
-
+
assert(COUNT <= MAXELEMS);
-
+
if (me == 0 && verbose) {
- printf("Test starting on %d processes\n", nproc);
- fflush(stdout);
+ printf("Test starting on %d processes\n", nproc);
+ fflush(stdout);
}
-
+
errs = test_put();
-
+
MPI_Barrier(MPI_COMM_WORLD);
-
- MTest_Finalize( errs );
+
+ MTest_Finalize(errs);
MPI_Finalize();
- return MTestReturnValue( errs );
+ return MTestReturnValue(errs);
}
diff --git a/test/mpi/rma/contention_putget.c b/test/mpi/rma/contention_putget.c
index 6a539a0..312cf31 100644
--- a/test/mpi/rma/contention_putget.c
+++ b/test/mpi/rma/contention_putget.c
@@ -24,76 +24,82 @@ static const int verbose = 0;
void test_put(void);
void test_put(void)
{
- MPI_Win dst_win;
- double *dst_buf;
- double src_buf[MAXELEMS];
- int i, j;
-
- MPI_Alloc_mem(sizeof(double)*nproc*MAXELEMS, MPI_INFO_NULL, &dst_buf);
- MPI_Win_create(dst_buf, sizeof(double)*nproc*MAXELEMS, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &dst_win);
-
- for (i = 0; i < MAXELEMS; i++)
- src_buf[i] = me + 1.0;
-
- MPI_Win_lock(MPI_LOCK_EXCLUSIVE, me, 0, dst_win);
-
- for (i = 0; i < nproc*MAXELEMS; i++)
- dst_buf[i] = 0.0;
-
- MPI_Win_unlock(me, dst_win);
-
- MPI_Barrier(MPI_COMM_WORLD);
-
- for(i = 0; i < nproc; i++) {
- int target = i;
-
- for(j = 0; j < COUNT; j++) {
- if (verbose) printf("%2d -> %2d [%2d]\n", me, target, j);
- MPI_Win_lock(MPI_LOCK_EXCLUSIVE, target, 0, dst_win);
- MPI_Put(&src_buf[j], sizeof(double), MPI_BYTE, target, (me*MAXELEMS+j)*sizeof(double), sizeof(double), MPI_BYTE, dst_win);
- MPI_Win_unlock(target, dst_win);
- }
-
- for(j = 0; j < COUNT; j++) {
- if (verbose) printf("%2d <- %2d [%2d]\n", me, target, j);
- MPI_Win_lock(MPI_LOCK_EXCLUSIVE, target, 0, dst_win);
- MPI_Get(&src_buf[j], sizeof(double), MPI_BYTE, target, (me*MAXELEMS+j)*sizeof(double), sizeof(double), MPI_BYTE, dst_win);
- MPI_Win_unlock(target, dst_win);
+ MPI_Win dst_win;
+ double *dst_buf;
+ double src_buf[MAXELEMS];
+ int i, j;
+
+ MPI_Alloc_mem(sizeof(double) * nproc * MAXELEMS, MPI_INFO_NULL, &dst_buf);
+ MPI_Win_create(dst_buf, sizeof(double) * nproc * MAXELEMS, 1, MPI_INFO_NULL, MPI_COMM_WORLD,
+ &dst_win);
+
+ for (i = 0; i < MAXELEMS; i++)
+ src_buf[i] = me + 1.0;
+
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, me, 0, dst_win);
+
+ for (i = 0; i < nproc * MAXELEMS; i++)
+ dst_buf[i] = 0.0;
+
+ MPI_Win_unlock(me, dst_win);
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ for (i = 0; i < nproc; i++) {
+ int target = i;
+
+ for (j = 0; j < COUNT; j++) {
+ if (verbose)
+ printf("%2d -> %2d [%2d]\n", me, target, j);
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, target, 0, dst_win);
+ MPI_Put(&src_buf[j], sizeof(double), MPI_BYTE, target,
+ (me * MAXELEMS + j) * sizeof(double), sizeof(double), MPI_BYTE, dst_win);
+ MPI_Win_unlock(target, dst_win);
+ }
+
+ for (j = 0; j < COUNT; j++) {
+ if (verbose)
+ printf("%2d <- %2d [%2d]\n", me, target, j);
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, target, 0, dst_win);
+ MPI_Get(&src_buf[j], sizeof(double), MPI_BYTE, target,
+ (me * MAXELEMS + j) * sizeof(double), sizeof(double), MPI_BYTE, dst_win);
+ MPI_Win_unlock(target, dst_win);
+ }
}
- }
- MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Barrier(MPI_COMM_WORLD);
- MPI_Win_free(&dst_win);
- MPI_Free_mem(dst_buf);
+ MPI_Win_free(&dst_win);
+ MPI_Free_mem(dst_buf);
}
-int main(int argc, char* argv[]) {
- MPI_Init(&argc, &argv);
- MPI_Comm_size(MPI_COMM_WORLD, &nproc);
- MPI_Comm_rank(MPI_COMM_WORLD, &me);
+int main(int argc, char *argv[])
+{
+ MPI_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nproc);
+ MPI_Comm_rank(MPI_COMM_WORLD, &me);
- assert(COUNT <= MAXELEMS);
+ assert(COUNT <= MAXELEMS);
- if (me == 0 && verbose) {
- printf("Test starting on %d processes\n", nproc);
- fflush(stdout);
- }
+ if (me == 0 && verbose) {
+ printf("Test starting on %d processes\n", nproc);
+ fflush(stdout);
+ }
- test_put();
+ test_put();
- MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Barrier(MPI_COMM_WORLD);
- MPI_Finalize();
+ MPI_Finalize();
- if (me == 0 && verbose) {
- printf("Test completed.\n");
- fflush(stdout);
- }
+ if (me == 0 && verbose) {
+ printf("Test completed.\n");
+ fflush(stdout);
+ }
- if (me == 0)
- printf(" No Errors\n");
+ if (me == 0)
+ printf(" No Errors\n");
- return 0;
+ return 0;
}
diff --git a/test/mpi/rma/contig_displ.c b/test/mpi/rma/contig_displ.c
index 9d37da6..459c8b6 100644
--- a/test/mpi/rma/contig_displ.c
+++ b/test/mpi/rma/contig_displ.c
@@ -11,72 +11,80 @@
/* Run with 1 process.
This program does an MPI_Get with an indexed datatype. The datatype
- comprises a single integer at an initial displacement of 1 integer.
+ comprises a single integer at an initial displacement of 1 integer.
That is, the first integer in the array is to be skipped.
This program found a bug in IBM's MPI in which MPI_Get ignored the
- displacement and got the first integer instead of the second.
+ displacement and got the first integer instead of the second.
*/
int main(int argc, char **argv)
{
int rank, nprocs, mpi_err, *array;
- int getval, disp, errs=0;
+ int getval, disp, errs = 0;
MPI_Win win;
MPI_Datatype type;
-
- MTest_Init(&argc,&argv);
+
+ MTest_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
if (rank == 0) {
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_SELF, MPI_ERRORS_RETURN );
-
- /* create an indexed datatype that points to the second integer
- in an array (the first integer is skipped). */
- disp = 1;
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_SELF, MPI_ERRORS_RETURN);
+
+ /* create an indexed datatype that points to the second integer
+ * in an array (the first integer is skipped). */
+ disp = 1;
mpi_err = MPI_Type_create_indexed_block(1, 1, &disp, MPI_INT, &type);
- if (mpi_err != MPI_SUCCESS) goto err_return;
+ if (mpi_err != MPI_SUCCESS)
+ goto err_return;
mpi_err = MPI_Type_commit(&type);
- if (mpi_err != MPI_SUCCESS) goto err_return;
-
- /* allocate window of size 2 integers*/
- mpi_err = MPI_Alloc_mem(2*sizeof(int), MPI_INFO_NULL, &array);
- if (mpi_err != MPI_SUCCESS) goto err_return;
-
+ if (mpi_err != MPI_SUCCESS)
+ goto err_return;
+
+ /* allocate window of size 2 integers */
+ mpi_err = MPI_Alloc_mem(2 * sizeof(int), MPI_INFO_NULL, &array);
+ if (mpi_err != MPI_SUCCESS)
+ goto err_return;
+
/* create window object */
- mpi_err = MPI_Win_create(array, 2*sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_SELF, &win);
- if (mpi_err != MPI_SUCCESS) goto err_return;
-
+ mpi_err =
+ MPI_Win_create(array, 2 * sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_SELF, &win);
+ if (mpi_err != MPI_SUCCESS)
+ goto err_return;
+
/* initialize array */
array[0] = 100;
array[1] = 200;
-
+
getval = 0;
-
+
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Win_set_errhandler( win, MPI_ERRORS_RETURN );
-
+ * change the error handler to errors return */
+ MPI_Win_set_errhandler(win, MPI_ERRORS_RETURN);
+
mpi_err = MPI_Win_lock(MPI_LOCK_EXCLUSIVE, 0, 0, win);
- if (mpi_err != MPI_SUCCESS) goto err_return;
-
+ if (mpi_err != MPI_SUCCESS)
+ goto err_return;
+
/* get the current value of element array[1] */
mpi_err = MPI_Get(&getval, 1, MPI_INT, 0, 0, 1, type, win);
- if (mpi_err != MPI_SUCCESS) goto err_return;
-
+ if (mpi_err != MPI_SUCCESS)
+ goto err_return;
+
mpi_err = MPI_Win_unlock(0, win);
- if (mpi_err != MPI_SUCCESS) goto err_return;
-
+ if (mpi_err != MPI_SUCCESS)
+ goto err_return;
+
/* getval should contain the value of array[1] */
if (getval != array[1]) {
errs++;
printf("getval=%d, should be %d\n", getval, array[1]);
}
-
+
MPI_Free_mem(array);
MPI_Win_free(&win);
MPI_Type_free(&type);
@@ -86,13 +94,11 @@ int main(int argc, char **argv)
MPI_Finalize();
return 0;
- err_return:
+ err_return:
printf("MPI function error returned an error\n");
- MTestPrintError( mpi_err );
+ MTestPrintError(mpi_err);
errs++;
MTest_Finalize(errs);
MPI_Finalize();
return 1;
}
-
-
diff --git a/test/mpi/rma/epochtest.c b/test/mpi/rma/epochtest.c
index 4504454..69cfdcb 100644
--- a/test/mpi/rma/epochtest.c
+++ b/test/mpi/rma/epochtest.c
@@ -6,7 +6,7 @@
*/
/*
- * This test looks at the behavior of MPI_Win_fence and epochs. Each
+ * This test looks at the behavior of MPI_Win_fence and epochs. Each
* MPI_Win_fence may both begin and end both the exposure and access epochs.
* Thus, it is not necessary to use MPI_Win_fence in pairs.
*
@@ -32,160 +32,191 @@ static char MTEST_Descrip[] = "Put with Fences used to separate epochs";
#define MAX_PERR 10
-int PrintRecvedError( const char *, MTestDatatype *, MTestDatatype * );
+int PrintRecvedError(const char *, MTestDatatype *, MTestDatatype *);
-int main( int argc, char **argv )
+int main(int argc, char **argv)
{
int errs = 0, err;
int rank, size, source, dest;
- int minsize = 2, count;
- MPI_Comm comm;
- MPI_Win win;
- MPI_Aint extent;
+ int minsize = 2, count;
+ MPI_Comm comm;
+ MPI_Win win;
+ MPI_Aint extent;
MTestDatatype sendtype, recvtype;
- int onlyInt = 0;
+ int onlyInt = 0;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
/* Check for a simple choice of communicator and datatypes */
- if (getenv( "MTEST_SIMPLE" )) onlyInt = 1;
-
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
- /* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
- source = 0;
- dest = size - 1;
-
- MTEST_DATATYPE_FOR_EACH_COUNT(count) {
- while (MTestGetDatatypes( &sendtype, &recvtype, count )) {
-
- MTestPrintfMsg( 1,
- "Putting count = %d of sendtype %s receive type %s\n",
- count, MTestGetDatatypeName( &sendtype ),
- MTestGetDatatypeName( &recvtype ) );
-
- /* Make sure that everyone has a recv buffer */
- recvtype.InitBuf( &recvtype );
-
- MPI_Type_extent( recvtype.datatype, &extent );
- MPI_Win_create( recvtype.buf, recvtype.count * extent,
- extent, MPI_INFO_NULL, comm, &win );
- /* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Win_set_errhandler( win, MPI_ERRORS_RETURN );
-
- /* At this point, we have all of the elements that we
- need to begin the multiple fence and put tests */
- /* Fence 1 */
- err = MPI_Win_fence( MPI_MODE_NOPRECEDE, win );
- if (err) { if (errs++ < MAX_PERR) MTestPrintError(err); }
- /* Source puts */
- if (rank == source) {
- sendtype.InitBuf( &sendtype );
-
- err = MPI_Put( sendtype.buf, sendtype.count,
- sendtype.datatype, dest, 0,
- recvtype.count, recvtype.datatype, win );
- if (err) { if (errs++ < MAX_PERR) MTestPrintError(err); }
- }
-
- /* Fence 2 */
- err = MPI_Win_fence( 0, win );
- if (err) { if (errs++ < MAX_PERR) MTestPrintError(err); }
- /* dest checks data, then Dest puts */
- if (rank == dest) {
- err = MTestCheckRecv( 0, &recvtype );
- if (err) { if (errs++ < MAX_PERR) {
- PrintRecvedError( "fence 2", &sendtype, &recvtype );
- }
- }
- sendtype.InitBuf( &sendtype );
-
- err = MPI_Put( sendtype.buf, sendtype.count,
- sendtype.datatype, source, 0,
- recvtype.count, recvtype.datatype, win );
- if (err) { if (errs++ < MAX_PERR) MTestPrintError(err); }
- }
-
- /* Fence 3 */
- err = MPI_Win_fence( 0, win );
- if (err) { if (errs++ < MAX_PERR) MTestPrintError(err); }
- /* src checks data, then Src and dest puts*/
- if (rank == source) {
- err = MTestCheckRecv( 0, &recvtype );
- if (err) { if (errs++ < MAX_PERR) {
- PrintRecvedError( "fence 3", &sendtype, &recvtype );
- }
- }
- sendtype.InitBuf( &sendtype );
-
- err = MPI_Put( sendtype.buf, sendtype.count,
- sendtype.datatype, dest, 0,
- recvtype.count, recvtype.datatype, win );
- if (err) { if (errs++ < MAX_PERR) MTestPrintError(err); }
- }
- if (rank == dest) {
- sendtype.InitBuf( &sendtype );
-
- err = MPI_Put( sendtype.buf, sendtype.count,
- sendtype.datatype, source, 0,
- recvtype.count, recvtype.datatype, win );
- if (err) { if (errs++ < MAX_PERR) MTestPrintError(err); }
- }
-
- /* Fence 4 */
- err = MPI_Win_fence( MPI_MODE_NOSUCCEED, win );
- if (err) { if (errs++ < MAX_PERR) MTestPrintError(err); }
- /* src and dest checks data */
- if (rank == source) {
- err = MTestCheckRecv( 0, &recvtype );
- if (err) { if (errs++ < MAX_PERR) {
- PrintRecvedError( "src fence4", &sendtype, &recvtype );
- }
- }
- }
- if (rank == dest) {
- err = MTestCheckRecv( 0, &recvtype );
- if (err) { if (errs++ < MAX_PERR) {
- PrintRecvedError( "dest fence4", &sendtype, &recvtype );
- }
- }
- }
-
- MPI_Win_free( &win );
- MTestFreeDatatype( &sendtype );
- MTestFreeDatatype( &recvtype );
-
- /* Only do one datatype in the simple case */
- if (onlyInt) break;
- }
- /* Only do one count in the simple case */
- if (onlyInt) break;
- }
+ if (getenv("MTEST_SIMPLE"))
+ onlyInt = 1;
+
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ /* Determine the sender and receiver */
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+ source = 0;
+ dest = size - 1;
+
+ MTEST_DATATYPE_FOR_EACH_COUNT(count) {
+ while (MTestGetDatatypes(&sendtype, &recvtype, count)) {
+
+ MTestPrintfMsg(1,
+ "Putting count = %d of sendtype %s receive type %s\n",
+ count, MTestGetDatatypeName(&sendtype),
+ MTestGetDatatypeName(&recvtype));
+
+ /* Make sure that everyone has a recv buffer */
+ recvtype.InitBuf(&recvtype);
+
+ MPI_Type_extent(recvtype.datatype, &extent);
+ MPI_Win_create(recvtype.buf, recvtype.count * extent,
+ extent, MPI_INFO_NULL, comm, &win);
+ /* To improve reporting of problems about operations, we
+ * change the error handler to errors return */
+ MPI_Win_set_errhandler(win, MPI_ERRORS_RETURN);
+
+ /* At this point, we have all of the elements that we
+ * need to begin the multiple fence and put tests */
+ /* Fence 1 */
+ err = MPI_Win_fence(MPI_MODE_NOPRECEDE, win);
+ if (err) {
+ if (errs++ < MAX_PERR)
+ MTestPrintError(err);
+ }
+ /* Source puts */
+ if (rank == source) {
+ sendtype.InitBuf(&sendtype);
+
+ err = MPI_Put(sendtype.buf, sendtype.count,
+ sendtype.datatype, dest, 0,
+ recvtype.count, recvtype.datatype, win);
+ if (err) {
+ if (errs++ < MAX_PERR)
+ MTestPrintError(err);
+ }
+ }
+
+ /* Fence 2 */
+ err = MPI_Win_fence(0, win);
+ if (err) {
+ if (errs++ < MAX_PERR)
+ MTestPrintError(err);
+ }
+ /* dest checks data, then Dest puts */
+ if (rank == dest) {
+ err = MTestCheckRecv(0, &recvtype);
+ if (err) {
+ if (errs++ < MAX_PERR) {
+ PrintRecvedError("fence 2", &sendtype, &recvtype);
+ }
+ }
+ sendtype.InitBuf(&sendtype);
+
+ err = MPI_Put(sendtype.buf, sendtype.count,
+ sendtype.datatype, source, 0,
+ recvtype.count, recvtype.datatype, win);
+ if (err) {
+ if (errs++ < MAX_PERR)
+ MTestPrintError(err);
+ }
+ }
+
+ /* Fence 3 */
+ err = MPI_Win_fence(0, win);
+ if (err) {
+ if (errs++ < MAX_PERR)
+ MTestPrintError(err);
+ }
+ /* src checks data, then Src and dest puts */
+ if (rank == source) {
+ err = MTestCheckRecv(0, &recvtype);
+ if (err) {
+ if (errs++ < MAX_PERR) {
+ PrintRecvedError("fence 3", &sendtype, &recvtype);
+ }
+ }
+ sendtype.InitBuf(&sendtype);
+
+ err = MPI_Put(sendtype.buf, sendtype.count,
+ sendtype.datatype, dest, 0,
+ recvtype.count, recvtype.datatype, win);
+ if (err) {
+ if (errs++ < MAX_PERR)
+ MTestPrintError(err);
+ }
+ }
+ if (rank == dest) {
+ sendtype.InitBuf(&sendtype);
+
+ err = MPI_Put(sendtype.buf, sendtype.count,
+ sendtype.datatype, source, 0,
+ recvtype.count, recvtype.datatype, win);
+ if (err) {
+ if (errs++ < MAX_PERR)
+ MTestPrintError(err);
+ }
+ }
+
+ /* Fence 4 */
+ err = MPI_Win_fence(MPI_MODE_NOSUCCEED, win);
+ if (err) {
+ if (errs++ < MAX_PERR)
+ MTestPrintError(err);
+ }
+ /* src and dest checks data */
+ if (rank == source) {
+ err = MTestCheckRecv(0, &recvtype);
+ if (err) {
+ if (errs++ < MAX_PERR) {
+ PrintRecvedError("src fence4", &sendtype, &recvtype);
+ }
+ }
+ }
+ if (rank == dest) {
+ err = MTestCheckRecv(0, &recvtype);
+ if (err) {
+ if (errs++ < MAX_PERR) {
+ PrintRecvedError("dest fence4", &sendtype, &recvtype);
+ }
+ }
+ }
+
+ MPI_Win_free(&win);
+ MTestFreeDatatype(&sendtype);
+ MTestFreeDatatype(&recvtype);
+
+ /* Only do one datatype in the simple case */
+ if (onlyInt)
+ break;
+ }
+ /* Only do one count in the simple case */
+ if (onlyInt)
+ break;
+ }
MTestFreeComm(&comm);
- /* Only do one communicator in the simple case */
- if (onlyInt) break;
+ /* Only do one communicator in the simple case */
+ if (onlyInt)
+ break;
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
+
+
-
-
MPI_Finalize();
return 0;
}
-int PrintRecvedError( const char *msg,
- MTestDatatype *sendtypePtr, MTestDatatype *recvtypePtr )
+int PrintRecvedError(const char *msg, MTestDatatype * sendtypePtr, MTestDatatype * recvtypePtr)
{
- printf( "At step %s, Data in target buffer did not match for destination datatype %s (put with source datatype %s)\n",
- msg,
- MTestGetDatatypeName( recvtypePtr ),
- MTestGetDatatypeName( sendtypePtr ) );
+ printf
+ ("At step %s, Data in target buffer did not match for destination datatype %s (put with source datatype %s)\n",
+ msg, MTestGetDatatypeName(recvtypePtr), MTestGetDatatypeName(sendtypePtr));
/* Redo the test, with the errors printed */
recvtypePtr->printErrors = 1;
- (void)MTestCheckRecv( 0, recvtypePtr );
+ (void) MTestCheckRecv(0, recvtypePtr);
return 0;
}
diff --git a/test/mpi/rma/fence_shm.c b/test/mpi/rma/fence_shm.c
index d3f53c0..ac50128 100644
--- a/test/mpi/rma/fence_shm.c
+++ b/test/mpi/rma/fence_shm.c
@@ -78,8 +78,7 @@ int main(int argc, char *argv[])
if (result_data != one) {
errors++;
- printf("Expected: result_data = %d Actual: result_data = %d\n",
- one, result_data);
+ printf("Expected: result_data = %d Actual: result_data = %d\n", one, result_data);
}
}
diff --git a/test/mpi/rma/fetch_and_op.c b/test/mpi/rma/fetch_and_op.c
index f8b7fb2..13ab278 100644
--- a/test/mpi/rma/fetch_and_op.c
+++ b/test/mpi/rma/fetch_and_op.c
@@ -42,7 +42,8 @@
#define CMP(x, y) ((x - ((TYPE_C) (y))) > 1.0e-9)
-void reset_vars(TYPE_C *val_ptr, TYPE_C *res_ptr, MPI_Win win) {
+void reset_vars(TYPE_C * val_ptr, TYPE_C * res_ptr, MPI_Win win)
+{
int i, rank, nproc;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
@@ -58,24 +59,26 @@ void reset_vars(TYPE_C *val_ptr, TYPE_C *res_ptr, MPI_Win win) {
MPI_Barrier(MPI_COMM_WORLD);
}
-int main(int argc, char **argv) {
- int i, rank, nproc, mpi_type_size;
- int errors = 0, all_errors = 0;
- TYPE_C *val_ptr, *res_ptr;
- MPI_Win win;
+int main(int argc, char **argv)
+{
+ int i, rank, nproc, mpi_type_size;
+ int errors = 0, all_errors = 0;
+ TYPE_C *val_ptr, *res_ptr;
+ MPI_Win win;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &nproc);
-
+
MPI_Type_size(TYPE_MPI, &mpi_type_size);
assert(mpi_type_size == sizeof(TYPE_C));
- val_ptr = malloc(sizeof(TYPE_C)*nproc);
- res_ptr = malloc(sizeof(TYPE_C)*nproc);
+ val_ptr = malloc(sizeof(TYPE_C) * nproc);
+ res_ptr = malloc(sizeof(TYPE_C) * nproc);
- MPI_Win_create(val_ptr, sizeof(TYPE_C)*nproc, sizeof(TYPE_C), MPI_INFO_NULL, MPI_COMM_WORLD, &win);
+ MPI_Win_create(val_ptr, sizeof(TYPE_C) * nproc, sizeof(TYPE_C), MPI_INFO_NULL, MPI_COMM_WORLD,
+ &win);
/* Test self communication */
@@ -89,8 +92,10 @@ int main(int argc, char **argv) {
}
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, win);
- if ( CMP(val_ptr[0], ITER) ) {
- SQUELCH( printf("%d->%d -- SELF: expected "TYPE_FMT", got "TYPE_FMT"\n", rank, rank, (TYPE_C) ITER, val_ptr[0]); );
+ if (CMP(val_ptr[0], ITER)) {
+ SQUELCH(printf
+ ("%d->%d -- SELF: expected " TYPE_FMT ", got " TYPE_FMT "\n", rank, rank,
+ (TYPE_C) ITER, val_ptr[0]););
errors++;
}
MPI_Win_unlock(rank, win);
@@ -101,11 +106,13 @@ int main(int argc, char **argv) {
for (i = 0; i < ITER; i++) {
TYPE_C one = 1, result = -1;
- MPI_Win_lock(MPI_LOCK_EXCLUSIVE, (rank+1)%nproc, 0, win);
- MPI_Fetch_and_op(&one, &result, TYPE_MPI, (rank+1)%nproc, 0, MPI_SUM, win);
- MPI_Win_unlock((rank+1)%nproc, win);
- if ( CMP(result, i) ) {
- SQUELCH( printf("%d->%d -- NEIGHBOR[%d]: expected result "TYPE_FMT", got "TYPE_FMT"\n", (rank+1)%nproc, rank, i, (TYPE_C) i, result); );
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, (rank + 1) % nproc, 0, win);
+ MPI_Fetch_and_op(&one, &result, TYPE_MPI, (rank + 1) % nproc, 0, MPI_SUM, win);
+ MPI_Win_unlock((rank + 1) % nproc, win);
+ if (CMP(result, i)) {
+ SQUELCH(printf
+ ("%d->%d -- NEIGHBOR[%d]: expected result " TYPE_FMT ", got " TYPE_FMT "\n",
+ (rank + 1) % nproc, rank, i, (TYPE_C) i, result););
errors++;
}
}
@@ -113,8 +120,10 @@ int main(int argc, char **argv) {
MPI_Barrier(MPI_COMM_WORLD);
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, win);
- if ( CMP(val_ptr[0], ITER) ) {
- SQUELCH( printf("%d->%d -- NEIGHBOR: expected "TYPE_FMT", got "TYPE_FMT"\n", (rank+1)%nproc, rank, (TYPE_C) ITER, val_ptr[0]); );
+ if (CMP(val_ptr[0], ITER)) {
+ SQUELCH(printf
+ ("%d->%d -- NEIGHBOR: expected " TYPE_FMT ", got " TYPE_FMT "\n",
+ (rank + 1) % nproc, rank, (TYPE_C) ITER, val_ptr[0]););
errors++;
}
MPI_Win_unlock(rank, win);
@@ -136,8 +145,10 @@ int main(int argc, char **argv) {
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, win);
if (rank == 0 && nproc > 1) {
- if ( CMP(val_ptr[0], ITER*(nproc-1)) ) {
- SQUELCH( printf("*->%d - CONTENTION: expected="TYPE_FMT" val="TYPE_FMT"\n", rank, (TYPE_C) ITER*(nproc-1), val_ptr[0]); );
+ if (CMP(val_ptr[0], ITER * (nproc - 1))) {
+ SQUELCH(printf
+ ("*->%d - CONTENTION: expected=" TYPE_FMT " val=" TYPE_FMT "\n", rank,
+ (TYPE_C) ITER * (nproc - 1), val_ptr[0]););
errors++;
}
}
@@ -159,8 +170,10 @@ int main(int argc, char **argv) {
MPI_Barrier(MPI_COMM_WORLD);
for (j = 0; j < nproc; j++) {
- if ( CMP(res_ptr[j], i*rank) ) {
- SQUELCH( printf("%d->%d -- ALL-TO-ALL (FENCE) [%d]: expected result "TYPE_FMT", got "TYPE_FMT"\n", rank, j, i, (TYPE_C) i*rank, res_ptr[j]); );
+ if (CMP(res_ptr[j], i * rank)) {
+ SQUELCH(printf
+ ("%d->%d -- ALL-TO-ALL (FENCE) [%d]: expected result " TYPE_FMT ", got "
+ TYPE_FMT "\n", rank, j, i, (TYPE_C) i * rank, res_ptr[j]););
errors++;
}
}
@@ -169,8 +182,10 @@ int main(int argc, char **argv) {
MPI_Barrier(MPI_COMM_WORLD);
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, win);
for (i = 0; i < nproc; i++) {
- if ( CMP(val_ptr[i], ITER*i) ) {
- SQUELCH( printf("%d->%d -- ALL-TO-ALL (FENCE): expected "TYPE_FMT", got "TYPE_FMT"\n", i, rank, (TYPE_C) ITER*i, val_ptr[i]); );
+ if (CMP(val_ptr[i], ITER * i)) {
+ SQUELCH(printf
+ ("%d->%d -- ALL-TO-ALL (FENCE): expected " TYPE_FMT ", got " TYPE_FMT "\n", i,
+ rank, (TYPE_C) ITER * i, val_ptr[i]););
errors++;
}
}
@@ -192,8 +207,10 @@ int main(int argc, char **argv) {
MPI_Barrier(MPI_COMM_WORLD);
for (j = 0; j < nproc; j++) {
- if ( CMP(res_ptr[j], i*rank) ) {
- SQUELCH( printf("%d->%d -- ALL-TO-ALL (LOCK-ALL) [%d]: expected result "TYPE_FMT", got "TYPE_FMT"\n", rank, j, i, (TYPE_C) i*rank, res_ptr[j]); );
+ if (CMP(res_ptr[j], i * rank)) {
+ SQUELCH(printf
+ ("%d->%d -- ALL-TO-ALL (LOCK-ALL) [%d]: expected result " TYPE_FMT ", got "
+ TYPE_FMT "\n", rank, j, i, (TYPE_C) i * rank, res_ptr[j]););
errors++;
}
}
@@ -202,8 +219,10 @@ int main(int argc, char **argv) {
MPI_Barrier(MPI_COMM_WORLD);
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, win);
for (i = 0; i < nproc; i++) {
- if ( CMP(val_ptr[i], ITER*i) ) {
- SQUELCH( printf("%d->%d -- ALL-TO-ALL (LOCK-ALL): expected "TYPE_FMT", got "TYPE_FMT"\n", i, rank, (TYPE_C) ITER*i, val_ptr[i]); );
+ if (CMP(val_ptr[i], ITER * i)) {
+ SQUELCH(printf
+ ("%d->%d -- ALL-TO-ALL (LOCK-ALL): expected " TYPE_FMT ", got " TYPE_FMT "\n",
+ i, rank, (TYPE_C) ITER * i, val_ptr[i]););
errors++;
}
}
@@ -226,8 +245,10 @@ int main(int argc, char **argv) {
MPI_Barrier(MPI_COMM_WORLD);
for (j = 0; j < nproc; j++) {
- if ( CMP(res_ptr[j], i*rank) ) {
- SQUELCH( printf("%d->%d -- ALL-TO-ALL (LOCK-ALL+FLUSH) [%d]: expected result "TYPE_FMT", got "TYPE_FMT"\n", rank, j, i, (TYPE_C) i*rank, res_ptr[j]); );
+ if (CMP(res_ptr[j], i * rank)) {
+ SQUELCH(printf
+ ("%d->%d -- ALL-TO-ALL (LOCK-ALL+FLUSH) [%d]: expected result " TYPE_FMT
+ ", got " TYPE_FMT "\n", rank, j, i, (TYPE_C) i * rank, res_ptr[j]););
errors++;
}
}
@@ -236,8 +257,10 @@ int main(int argc, char **argv) {
MPI_Barrier(MPI_COMM_WORLD);
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, win);
for (i = 0; i < nproc; i++) {
- if ( CMP(val_ptr[i], ITER*i) ) {
- SQUELCH( printf("%d->%d -- ALL-TO-ALL (LOCK-ALL+FLUSH): expected "TYPE_FMT", got "TYPE_FMT"\n", i, rank, (TYPE_C) ITER*i, val_ptr[i]); );
+ if (CMP(val_ptr[i], ITER * i)) {
+ SQUELCH(printf
+ ("%d->%d -- ALL-TO-ALL (LOCK-ALL+FLUSH): expected " TYPE_FMT ", got " TYPE_FMT
+ "\n", i, rank, (TYPE_C) ITER * i, val_ptr[i]););
errors++;
}
}
@@ -255,15 +278,15 @@ int main(int argc, char **argv) {
MPI_Barrier(MPI_COMM_WORLD);
for (i = 0; i < ITER; i++) {
- int target = (rank+1) % nproc;
+ int target = (rank + 1) % nproc;
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, target, 0, win);
MPI_Fetch_and_op(NULL, res_ptr, TYPE_MPI, target, 0, MPI_NO_OP, win);
MPI_Win_unlock(target, win);
if (res_ptr[0] != (TYPE_C) target) {
- SQUELCH( printf("%d->%d -- NOP[%d]: expected "TYPE_FMT", got "TYPE_FMT"\n",
- target, rank, i, (TYPE_C) target, res_ptr[0]); );
+ SQUELCH(printf("%d->%d -- NOP[%d]: expected " TYPE_FMT ", got " TYPE_FMT "\n",
+ target, rank, i, (TYPE_C) target, res_ptr[0]););
errors++;
}
}
@@ -287,8 +310,8 @@ int main(int argc, char **argv) {
MPI_Win_unlock(target, win);
if (res_ptr[0] != (TYPE_C) target) {
- SQUELCH( printf("%d->%d -- NOP_SELF[%d]: expected "TYPE_FMT", got "TYPE_FMT"\n",
- target, rank, i, (TYPE_C) target, res_ptr[0]); );
+ SQUELCH(printf("%d->%d -- NOP_SELF[%d]: expected " TYPE_FMT ", got " TYPE_FMT "\n",
+ target, rank, i, (TYPE_C) target, res_ptr[0]););
errors++;
}
}
diff --git a/test/mpi/rma/fetchandadd.c b/test/mpi/rma/fetchandadd.c
index dd12a4c..493e158 100644
--- a/test/mpi/rma/fetchandadd.c
+++ b/test/mpi/rma/fetchandadd.c
@@ -3,64 +3,62 @@
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include "stdio.h"
#include "stdlib.h"
#include "mpitest.h"
/* Fetch and add example from Using MPI-2 (the non-scalable version,
- Fig. 6.12). */
+ Fig. 6.12). */
-#define NTIMES 20 /* no of times each process calls the counter
- routine */
+#define NTIMES 20 /* no of times each process calls the counter
+ * routine */
-int localvalue=0; /* contribution of this process to the counter. We
- define it as a global variable because attribute
- caching on the window is not enabled yet. */
+int localvalue = 0; /* contribution of this process to the counter. We
+ * define it as a global variable because attribute
+ * caching on the window is not enabled yet. */
void Get_nextval(MPI_Win win, int *val_array, MPI_Datatype get_type,
int rank, int nprocs, int *value);
int compar(const void *a, const void *b);
-int main(int argc, char *argv[])
-{
- int rank, nprocs, i, blens[2], disps[2], *counter_mem, *val_array,
- *results, *counter_vals;
+int main(int argc, char *argv[])
+{
+ int rank, nprocs, i, blens[2], disps[2], *counter_mem, *val_array, *results, *counter_vals;
MPI_Datatype get_type;
MPI_Win win;
int errs = 0;
-
- MTest_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank == 0) {
/* allocate counter memory and initialize to 0 */
counter_mem = (int *) calloc(nprocs, sizeof(int));
- MPI_Win_create(counter_mem, nprocs*sizeof(int), sizeof(int),
+ MPI_Win_create(counter_mem, nprocs * sizeof(int), sizeof(int),
MPI_INFO_NULL, MPI_COMM_WORLD, &win);
- MPI_Win_free(&win);
+ MPI_Win_free(&win);
free(counter_mem);
- /* gather the results from other processes, sort them, and check
- whether they represent a counter being incremented by 1 */
+ /* gather the results from other processes, sort them, and check
+ * whether they represent a counter being incremented by 1 */
- results = (int *) malloc(NTIMES*nprocs*sizeof(int));
- for (i=0; i<NTIMES*nprocs; i++)
+ results = (int *) malloc(NTIMES * nprocs * sizeof(int));
+ for (i = 0; i < NTIMES * nprocs; i++)
results[i] = -1;
- MPI_Gather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, results, NTIMES, MPI_INT,
- 0, MPI_COMM_WORLD);
+ MPI_Gather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, results, NTIMES, MPI_INT, 0, MPI_COMM_WORLD);
- qsort(results+NTIMES, NTIMES*(nprocs-1), sizeof(int), compar);
+ qsort(results + NTIMES, NTIMES * (nprocs - 1), sizeof(int), compar);
- for (i=NTIMES+1; i<(NTIMES*nprocs); i++)
- if (results[i] != results[i-1] + 1)
+ for (i = NTIMES + 1; i < (NTIMES * nprocs); i++)
+ if (results[i] != results[i - 1] + 1)
errs++;
-
+
free(results);
}
else {
@@ -74,14 +72,14 @@ int main(int argc, char *argv[])
val_array = (int *) malloc(nprocs * sizeof(int));
- /* allocate array to store the values obtained from the
- fetch-and-add counter */
+ /* allocate array to store the values obtained from the
+ * fetch-and-add counter */
counter_vals = (int *) malloc(NTIMES * sizeof(int));
- MPI_Win_create(NULL, 0, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &win);
+ MPI_Win_create(NULL, 0, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &win);
- for (i=0; i<NTIMES; i++) {
- Get_nextval(win, val_array, get_type, rank, nprocs, counter_vals+i);
+ for (i = 0; i < NTIMES; i++) {
+ Get_nextval(win, val_array, get_type, rank, nprocs, counter_vals + i);
/* printf("Rank %d, counter %d\n", rank, value); */
}
@@ -91,30 +89,29 @@ int main(int argc, char *argv[])
MPI_Type_free(&get_type);
/* gather the results to the root */
- MPI_Gather(counter_vals, NTIMES, MPI_INT, NULL, 0, MPI_DATATYPE_NULL,
- 0, MPI_COMM_WORLD);
+ MPI_Gather(counter_vals, NTIMES, MPI_INT, NULL, 0, MPI_DATATYPE_NULL, 0, MPI_COMM_WORLD);
free(counter_vals);
}
MTest_Finalize(errs);
- MPI_Finalize();
- return 0;
-}
+ MPI_Finalize();
+ return 0;
+}
void Get_nextval(MPI_Win win, int *val_array, MPI_Datatype get_type,
- int rank, int nprocs, int *value)
+ int rank, int nprocs, int *value)
{
- int one=1, i;
+ int one = 1, i;
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, 0, 0, win);
MPI_Accumulate(&one, 1, MPI_INT, 0, rank, 1, MPI_INT, MPI_SUM, win);
- MPI_Get(val_array, 1, get_type, 0, 0, 1, get_type, win);
+ MPI_Get(val_array, 1, get_type, 0, 0, 1, get_type, win);
MPI_Win_unlock(0, win);
*value = 0;
val_array[rank] = localvalue;
- for (i=0; i<nprocs; i++)
+ for (i = 0; i < nprocs; i++)
*value = *value + val_array[i];
localvalue++;
@@ -122,6 +119,5 @@ void Get_nextval(MPI_Win win, int *val_array, MPI_Datatype get_type,
int compar(const void *a, const void *b)
{
- return (*((int *)a) - *((int *)b));
+ return (*((int *) a) - *((int *) b));
}
-
diff --git a/test/mpi/rma/fetchandadd_am.c b/test/mpi/rma/fetchandadd_am.c
index 0ecde99..0a70155 100644
--- a/test/mpi/rma/fetchandadd_am.c
+++ b/test/mpi/rma/fetchandadd_am.c
@@ -3,74 +3,73 @@
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include "stdio.h"
#include "stdlib.h"
#include "mpitest.h"
/* Fetch and add example from Using MPI-2 (the non-scalable version,
- Fig. 6.12). */
+ Fig. 6.12). */
/* same as fetchandadd.c but uses alloc_mem */
-#define NTIMES 20 /* no of times each process calls the counter
- routine */
+#define NTIMES 20 /* no of times each process calls the counter
+ * routine */
-int localvalue=0; /* contribution of this process to the counter. We
- define it as a global variable because attribute
- caching on the window is not enabled yet. */
+int localvalue = 0; /* contribution of this process to the counter. We
+ * define it as a global variable because attribute
+ * caching on the window is not enabled yet. */
void Get_nextval(MPI_Win win, int *val_array, MPI_Datatype get_type,
int rank, int nprocs, int *value);
int compar(const void *a, const void *b);
-int main(int argc, char *argv[])
-{
- int rank, nprocs, i, blens[2], disps[2], *counter_mem, *val_array,
- *results, *counter_vals;
+int main(int argc, char *argv[])
+{
+ int rank, nprocs, i, blens[2], disps[2], *counter_mem, *val_array, *results, *counter_vals;
MPI_Datatype get_type;
MPI_Win win;
int errs = 0;
-
- MTest_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank == 0) {
/* allocate counter memory and initialize to 0 */
/* counter_mem = (int *) calloc(nprocs, sizeof(int)); */
- i = MPI_Alloc_mem(nprocs*sizeof(int), MPI_INFO_NULL, &counter_mem);
+ i = MPI_Alloc_mem(nprocs * sizeof(int), MPI_INFO_NULL, &counter_mem);
if (i) {
printf("Can't allocate memory in test program\n");
MPI_Abort(MPI_COMM_WORLD, 1);
}
- for (i=0; i<nprocs; i++) counter_mem[i] = 0;
+ for (i = 0; i < nprocs; i++)
+ counter_mem[i] = 0;
- MPI_Win_create(counter_mem, nprocs*sizeof(int), sizeof(int),
+ MPI_Win_create(counter_mem, nprocs * sizeof(int), sizeof(int),
MPI_INFO_NULL, MPI_COMM_WORLD, &win);
- MPI_Win_free(&win);
+ MPI_Win_free(&win);
MPI_Free_mem(counter_mem);
- /* gather the results from other processes, sort them, and check
- whether they represent a counter being incremented by 1 */
+ /* gather the results from other processes, sort them, and check
+ * whether they represent a counter being incremented by 1 */
- results = (int *) malloc(NTIMES*nprocs*sizeof(int));
- for (i=0; i<NTIMES*nprocs; i++)
+ results = (int *) malloc(NTIMES * nprocs * sizeof(int));
+ for (i = 0; i < NTIMES * nprocs; i++)
results[i] = -1;
- MPI_Gather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, results, NTIMES, MPI_INT,
- 0, MPI_COMM_WORLD);
+ MPI_Gather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, results, NTIMES, MPI_INT, 0, MPI_COMM_WORLD);
- qsort(results+NTIMES, NTIMES*(nprocs-1), sizeof(int), compar);
+ qsort(results + NTIMES, NTIMES * (nprocs - 1), sizeof(int), compar);
- for (i=NTIMES+1; i<(NTIMES*nprocs); i++)
- if (results[i] != results[i-1] + 1)
+ for (i = NTIMES + 1; i < (NTIMES * nprocs); i++)
+ if (results[i] != results[i - 1] + 1)
errs++;
-
+
free(results);
}
else {
@@ -84,14 +83,14 @@ int main(int argc, char *argv[])
val_array = (int *) malloc(nprocs * sizeof(int));
- /* allocate array to store the values obtained from the
- fetch-and-add counter */
+ /* allocate array to store the values obtained from the
+ * fetch-and-add counter */
counter_vals = (int *) malloc(NTIMES * sizeof(int));
- MPI_Win_create(NULL, 0, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &win);
+ MPI_Win_create(NULL, 0, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &win);
- for (i=0; i<NTIMES; i++) {
- Get_nextval(win, val_array, get_type, rank, nprocs, counter_vals+i);
+ for (i = 0; i < NTIMES; i++) {
+ Get_nextval(win, val_array, get_type, rank, nprocs, counter_vals + i);
/* printf("Rank %d, counter %d\n", rank, value); */
}
@@ -101,30 +100,29 @@ int main(int argc, char *argv[])
MPI_Type_free(&get_type);
/* gather the results to the root */
- MPI_Gather(counter_vals, NTIMES, MPI_INT, NULL, 0, MPI_DATATYPE_NULL,
- 0, MPI_COMM_WORLD);
+ MPI_Gather(counter_vals, NTIMES, MPI_INT, NULL, 0, MPI_DATATYPE_NULL, 0, MPI_COMM_WORLD);
free(counter_vals);
}
MTest_Finalize(errs);
- MPI_Finalize();
- return 0;
-}
+ MPI_Finalize();
+ return 0;
+}
void Get_nextval(MPI_Win win, int *val_array, MPI_Datatype get_type,
- int rank, int nprocs, int *value)
+ int rank, int nprocs, int *value)
{
- int one=1, i;
+ int one = 1, i;
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, 0, 0, win);
MPI_Accumulate(&one, 1, MPI_INT, 0, rank, 1, MPI_INT, MPI_SUM, win);
- MPI_Get(val_array, 1, get_type, 0, 0, 1, get_type, win);
+ MPI_Get(val_array, 1, get_type, 0, 0, 1, get_type, win);
MPI_Win_unlock(0, win);
*value = 0;
val_array[rank] = localvalue;
- for (i=0; i<nprocs; i++)
+ for (i = 0; i < nprocs; i++)
*value = *value + val_array[i];
localvalue++;
@@ -132,6 +130,5 @@ void Get_nextval(MPI_Win win, int *val_array, MPI_Datatype get_type,
int compar(const void *a, const void *b)
{
- return (*((int *)a) - *((int *)b));
+ return (*((int *) a) - *((int *) b));
}
-
diff --git a/test/mpi/rma/fetchandadd_tree.c b/test/mpi/rma/fetchandadd_tree.c
index 8b3c8f3..4229a9e 100644
--- a/test/mpi/rma/fetchandadd_tree.c
+++ b/test/mpi/rma/fetchandadd_tree.c
@@ -3,78 +3,78 @@
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include "stdio.h"
#include "stdlib.h"
#include "mpitest.h"
/* This is the tree-based scalable version of the fetch-and-add
example from Using MPI-2, pg 206-207. The code in the book (Fig
- 6.16) has bugs that are fixed below. */
+ 6.16) has bugs that are fixed below. */
-#define NTIMES 20 /* no of times each process calls the counter
- routine */
+#define NTIMES 20 /* no of times each process calls the counter
+ * routine */
-int localvalue=0; /* contribution of this process to the counter. We
- define it as a global variable because attribute
- caching on the window is not enabled yet. */
+int localvalue = 0; /* contribution of this process to the counter. We
+ * define it as a global variable because attribute
+ * caching on the window is not enabled yet. */
void Get_nextval_tree(MPI_Win win, int *get_array, MPI_Datatype get_type,
- MPI_Datatype acc_type, int nlevels, int *value);
+ MPI_Datatype acc_type, int nlevels, int *value);
int compar(const void *a, const void *b);
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[])
+{
int rank, nprocs, i, *counter_mem, *get_array, *get_idx, *acc_idx,
mask, nlevels, level, idx, tmp_rank, pof2;
MPI_Datatype get_type, acc_type;
MPI_Win win;
int errs = 0, *results, *counter_vals;
-
- MTest_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank == 0) {
/* allocate counter memory and initialize to 0 */
/* find the next power-of-two >= nprocs */
pof2 = 1;
- while (pof2 < nprocs) pof2 *= 2;
+ while (pof2 < nprocs)
+ pof2 *= 2;
- counter_mem = (int *) calloc(pof2*2, sizeof(int));
- MPI_Win_create(counter_mem, pof2*2*sizeof(int), sizeof(int),
+ counter_mem = (int *) calloc(pof2 * 2, sizeof(int));
+ MPI_Win_create(counter_mem, pof2 * 2 * sizeof(int), sizeof(int),
MPI_INFO_NULL, MPI_COMM_WORLD, &win);
- MPI_Win_free(&win);
+ MPI_Win_free(&win);
free(counter_mem);
- /* gather the results from other processes, sort them, and check
- whether they represent a counter being incremented by 1 */
+ /* gather the results from other processes, sort them, and check
+ * whether they represent a counter being incremented by 1 */
- results = (int *) malloc(NTIMES*nprocs*sizeof(int));
- for (i=0; i<NTIMES*nprocs; i++)
+ results = (int *) malloc(NTIMES * nprocs * sizeof(int));
+ for (i = 0; i < NTIMES * nprocs; i++)
results[i] = -1;
- MPI_Gather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, results, NTIMES, MPI_INT,
- 0, MPI_COMM_WORLD);
+ MPI_Gather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, results, NTIMES, MPI_INT, 0, MPI_COMM_WORLD);
- qsort(results+NTIMES, NTIMES*(nprocs-1), sizeof(int), compar);
+ qsort(results + NTIMES, NTIMES * (nprocs - 1), sizeof(int), compar);
- for (i=NTIMES+1; i<(NTIMES*nprocs); i++)
- if (results[i] != results[i-1] + 1)
+ for (i = NTIMES + 1; i < (NTIMES * nprocs); i++)
+ if (results[i] != results[i - 1] + 1)
errs++;
-
+
free(results);
}
else {
- /* Get the largest power of two smaller than nprocs */
- mask = 1;
+ /* Get the largest power of two smaller than nprocs */
+ mask = 1;
nlevels = 0;
while (mask < nprocs) {
- mask <<= 1;
+ mask <<= 1;
nlevels++;
}
mask >>= 1;
@@ -83,28 +83,28 @@ int main(int argc, char *argv[])
get_idx = (int *) malloc(nlevels * sizeof(int));
acc_idx = (int *) malloc(nlevels * sizeof(int));
- level = 0;
- idx = 0;
+ level = 0;
+ idx = 0;
tmp_rank = rank;
- while (mask >= 1) {
- if (tmp_rank < mask) {
+ while (mask >= 1) {
+ if (tmp_rank < mask) {
/* go to left for acc_idx, go to right for
- get_idx. set idx=acc_idx for next iteration */
- acc_idx[level] = idx + 1;
- get_idx[level] = idx + mask*2;
- idx = idx + 1;
- }
- else {
+ * get_idx. set idx=acc_idx for next iteration */
+ acc_idx[level] = idx + 1;
+ get_idx[level] = idx + mask * 2;
+ idx = idx + 1;
+ }
+ else {
/* go to right for acc_idx, go to left for
- get_idx. set idx=acc_idx for next iteration */
- acc_idx[level] = idx + mask*2;
- get_idx[level] = idx + 1;
- idx = idx + mask*2;
- }
+ * get_idx. set idx=acc_idx for next iteration */
+ acc_idx[level] = idx + mask * 2;
+ get_idx[level] = idx + 1;
+ idx = idx + mask * 2;
+ }
level++;
tmp_rank = tmp_rank % mask;
- mask >>= 1;
- }
+ mask >>= 1;
+ }
/* for (i=0; i<nlevels; i++)
printf("Rank %d, acc_idx[%d]=%d, get_idx[%d]=%d\n", rank,
@@ -116,15 +116,14 @@ int main(int argc, char *argv[])
MPI_Type_commit(&get_type);
MPI_Type_commit(&acc_type);
- /* allocate array to store the values obtained from the
- fetch-and-add counter */
+ /* allocate array to store the values obtained from the
+ * fetch-and-add counter */
counter_vals = (int *) malloc(NTIMES * sizeof(int));
- MPI_Win_create(NULL, 0, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &win);
+ MPI_Win_create(NULL, 0, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &win);
- for (i=0; i<NTIMES; i++) {
- Get_nextval_tree(win, get_array, get_type, acc_type,
- nlevels, counter_vals+i);
+ for (i = 0; i < NTIMES; i++) {
+ Get_nextval_tree(win, get_array, get_type, acc_type, nlevels, counter_vals + i);
/* printf("Rank %d, counter %d\n", rank, value); */
}
@@ -135,16 +134,15 @@ int main(int argc, char *argv[])
MPI_Type_free(&get_type);
MPI_Type_free(&acc_type);
- /* gather the results to the root */
- MPI_Gather(counter_vals, NTIMES, MPI_INT, NULL, 0, MPI_DATATYPE_NULL,
- 0, MPI_COMM_WORLD);
+ /* gather the results to the root */
+ MPI_Gather(counter_vals, NTIMES, MPI_INT, NULL, 0, MPI_DATATYPE_NULL, 0, MPI_COMM_WORLD);
free(counter_vals);
- }
+ }
MTest_Finalize(errs);
- MPI_Finalize();
- return MTestReturnValue( errs );
-}
+ MPI_Finalize();
+ return MTestReturnValue(errs);
+}
void Get_nextval_tree(MPI_Win win, int *get_array, MPI_Datatype get_type,
@@ -152,17 +150,17 @@ void Get_nextval_tree(MPI_Win win, int *get_array, MPI_Datatype get_type,
{
int *one, i;
- one = (int *) malloc(nlevels*sizeof(int));
- for (i=0; i<nlevels; i++) one[i] = 1;
+ one = (int *) malloc(nlevels * sizeof(int));
+ for (i = 0; i < nlevels; i++)
+ one[i] = 1;
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, 0, 0, win);
- MPI_Accumulate(one, nlevels, MPI_INT, 0, 0, 1, acc_type,
- MPI_SUM, win);
+ MPI_Accumulate(one, nlevels, MPI_INT, 0, 0, 1, acc_type, MPI_SUM, win);
MPI_Get(get_array, nlevels, MPI_INT, 0, 0, 1, get_type, win);
MPI_Win_unlock(0, win);
*value = localvalue;
- for (i=0; i<nlevels; i++)
+ for (i = 0; i < nlevels; i++)
*value = *value + get_array[i];
localvalue++;
@@ -172,5 +170,5 @@ void Get_nextval_tree(MPI_Win win, int *get_array, MPI_Datatype get_type,
int compar(const void *a, const void *b)
{
- return (*((int *)a) - *((int *)b));
+ return (*((int *) a) - *((int *) b));
}
diff --git a/test/mpi/rma/fetchandadd_tree_am.c b/test/mpi/rma/fetchandadd_tree_am.c
index f5ca1e0..1205bdd 100644
--- a/test/mpi/rma/fetchandadd_tree_am.c
+++ b/test/mpi/rma/fetchandadd_tree_am.c
@@ -3,90 +3,91 @@
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include "stdio.h"
#include "stdlib.h"
#include "mpitest.h"
/* This is the tree-based scalable version of the fetch-and-add
example from Using MPI-2, pg 206-207. The code in the book (Fig
- 6.16) has bugs that are fixed below. */
+ 6.16) has bugs that are fixed below. */
/* same as fetchandadd_tree.c but uses alloc_mem */
-#define NTIMES 20 /* no of times each process calls the counter
- routine */
+#define NTIMES 20 /* no of times each process calls the counter
+ * routine */
-int localvalue=0; /* contribution of this process to the counter. We
- define it as a global variable because attribute
- caching on the window is not enabled yet. */
+int localvalue = 0; /* contribution of this process to the counter. We
+ * define it as a global variable because attribute
+ * caching on the window is not enabled yet. */
void Get_nextval_tree(MPI_Win win, int *get_array, MPI_Datatype get_type,
- MPI_Datatype acc_type, int nlevels, int *value);
+ MPI_Datatype acc_type, int nlevels, int *value);
int compar(const void *a, const void *b);
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[])
+{
int rank, nprocs, i, *counter_mem, *get_array, *get_idx, *acc_idx,
mask, nlevels, level, idx, tmp_rank, pof2;
MPI_Datatype get_type, acc_type;
MPI_Win win;
int errs = 0, *results, *counter_vals;
-
- MTest_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank == 0) {
/* allocate counter memory and initialize to 0 */
/* find the next power-of-two >= nprocs */
pof2 = 1;
- while (pof2 < nprocs) pof2 *= 2;
+ while (pof2 < nprocs)
+ pof2 *= 2;
/* counter_mem = (int *) calloc(pof2*2, sizeof(int)); */
- i = MPI_Alloc_mem(pof2*2*sizeof(int), MPI_INFO_NULL, &counter_mem);
+ i = MPI_Alloc_mem(pof2 * 2 * sizeof(int), MPI_INFO_NULL, &counter_mem);
if (i) {
printf("Can't allocate memory in test program\n");
MPI_Abort(MPI_COMM_WORLD, 1);
}
- for (i=0; i<(pof2*2); i++) counter_mem[i] = 0;
+ for (i = 0; i < (pof2 * 2); i++)
+ counter_mem[i] = 0;
- MPI_Win_create(counter_mem, pof2*2*sizeof(int), sizeof(int),
+ MPI_Win_create(counter_mem, pof2 * 2 * sizeof(int), sizeof(int),
MPI_INFO_NULL, MPI_COMM_WORLD, &win);
- MPI_Win_free(&win);
+ MPI_Win_free(&win);
/* free(counter_mem) */
MPI_Free_mem(counter_mem);
- /* gather the results from other processes, sort them, and check
- whether they represent a counter being incremented by 1 */
+ /* gather the results from other processes, sort them, and check
+ * whether they represent a counter being incremented by 1 */
- results = (int *) malloc(NTIMES*nprocs*sizeof(int));
- for (i=0; i<NTIMES*nprocs; i++)
+ results = (int *) malloc(NTIMES * nprocs * sizeof(int));
+ for (i = 0; i < NTIMES * nprocs; i++)
results[i] = -1;
- MPI_Gather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, results, NTIMES, MPI_INT,
- 0, MPI_COMM_WORLD);
+ MPI_Gather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, results, NTIMES, MPI_INT, 0, MPI_COMM_WORLD);
- qsort(results+NTIMES, NTIMES*(nprocs-1), sizeof(int), compar);
+ qsort(results + NTIMES, NTIMES * (nprocs - 1), sizeof(int), compar);
- for (i=NTIMES+1; i<(NTIMES*nprocs); i++)
- if (results[i] != results[i-1] + 1)
+ for (i = NTIMES + 1; i < (NTIMES * nprocs); i++)
+ if (results[i] != results[i - 1] + 1)
errs++;
-
+
free(results);
}
else {
- /* Get the largest power of two smaller than nprocs */
- mask = 1;
+ /* Get the largest power of two smaller than nprocs */
+ mask = 1;
nlevels = 0;
while (mask < nprocs) {
- mask <<= 1;
+ mask <<= 1;
nlevels++;
}
mask >>= 1;
@@ -95,28 +96,28 @@ int main(int argc, char *argv[])
get_idx = (int *) malloc(nlevels * sizeof(int));
acc_idx = (int *) malloc(nlevels * sizeof(int));
- level = 0;
- idx = 0;
+ level = 0;
+ idx = 0;
tmp_rank = rank;
- while (mask >= 1) {
- if (tmp_rank < mask) {
+ while (mask >= 1) {
+ if (tmp_rank < mask) {
/* go to left for acc_idx, go to right for
- get_idx. set idx=acc_idx for next iteration */
- acc_idx[level] = idx + 1;
- get_idx[level] = idx + mask*2;
- idx = idx + 1;
- }
- else {
+ * get_idx. set idx=acc_idx for next iteration */
+ acc_idx[level] = idx + 1;
+ get_idx[level] = idx + mask * 2;
+ idx = idx + 1;
+ }
+ else {
/* go to right for acc_idx, go to left for
- get_idx. set idx=acc_idx for next iteration */
- acc_idx[level] = idx + mask*2;
- get_idx[level] = idx + 1;
- idx = idx + mask*2;
- }
+ * get_idx. set idx=acc_idx for next iteration */
+ acc_idx[level] = idx + mask * 2;
+ get_idx[level] = idx + 1;
+ idx = idx + mask * 2;
+ }
level++;
tmp_rank = tmp_rank % mask;
- mask >>= 1;
- }
+ mask >>= 1;
+ }
/* for (i=0; i<nlevels; i++)
printf("Rank %d, acc_idx[%d]=%d, get_idx[%d]=%d\n", rank,
@@ -128,15 +129,14 @@ int main(int argc, char *argv[])
MPI_Type_commit(&get_type);
MPI_Type_commit(&acc_type);
- /* allocate array to store the values obtained from the
- fetch-and-add counter */
+ /* allocate array to store the values obtained from the
+ * fetch-and-add counter */
counter_vals = (int *) malloc(NTIMES * sizeof(int));
- MPI_Win_create(NULL, 0, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &win);
+ MPI_Win_create(NULL, 0, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &win);
- for (i=0; i<NTIMES; i++) {
- Get_nextval_tree(win, get_array, get_type, acc_type,
- nlevels, counter_vals+i);
+ for (i = 0; i < NTIMES; i++) {
+ Get_nextval_tree(win, get_array, get_type, acc_type, nlevels, counter_vals + i);
/* printf("Rank %d, counter %d\n", rank, value); */
}
@@ -147,16 +147,15 @@ int main(int argc, char *argv[])
MPI_Type_free(&get_type);
MPI_Type_free(&acc_type);
- /* gather the results to the root */
- MPI_Gather(counter_vals, NTIMES, MPI_INT, NULL, 0, MPI_DATATYPE_NULL,
- 0, MPI_COMM_WORLD);
+ /* gather the results to the root */
+ MPI_Gather(counter_vals, NTIMES, MPI_INT, NULL, 0, MPI_DATATYPE_NULL, 0, MPI_COMM_WORLD);
free(counter_vals);
- }
+ }
MTest_Finalize(errs);
- MPI_Finalize();
- return MTestReturnValue( errs );
-}
+ MPI_Finalize();
+ return MTestReturnValue(errs);
+}
void Get_nextval_tree(MPI_Win win, int *get_array, MPI_Datatype get_type,
@@ -164,17 +163,17 @@ void Get_nextval_tree(MPI_Win win, int *get_array, MPI_Datatype get_type,
{
int *one, i;
- one = (int *) malloc(nlevels*sizeof(int));
- for (i=0; i<nlevels; i++) one[i] = 1;
+ one = (int *) malloc(nlevels * sizeof(int));
+ for (i = 0; i < nlevels; i++)
+ one[i] = 1;
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, 0, 0, win);
- MPI_Accumulate(one, nlevels, MPI_INT, 0, 0, 1, acc_type,
- MPI_SUM, win);
+ MPI_Accumulate(one, nlevels, MPI_INT, 0, 0, 1, acc_type, MPI_SUM, win);
MPI_Get(get_array, nlevels, MPI_INT, 0, 0, 1, get_type, win);
MPI_Win_unlock(0, win);
*value = localvalue;
- for (i=0; i<nlevels; i++)
+ for (i = 0; i < nlevels; i++)
*value = *value + get_array[i];
localvalue++;
@@ -184,5 +183,5 @@ void Get_nextval_tree(MPI_Win win, int *get_array, MPI_Datatype get_type,
int compar(const void *a, const void *b)
{
- return (*((int *)a) - *((int *)b));
+ return (*((int *) a) - *((int *) b));
}
diff --git a/test/mpi/rma/fkeyvalwin.c b/test/mpi/rma/fkeyvalwin.c
index d2dd967..620eb61 100644
--- a/test/mpi/rma/fkeyvalwin.c
+++ b/test/mpi/rma/fkeyvalwin.c
@@ -21,71 +21,66 @@ executed";
/* Copy increments the attribute value */
/* Note that we can really ignore this because there is no win dup */
-int copy_fn( MPI_Win oldwin, int keyval, void *extra_state,
- void *attribute_val_in, void *attribute_val_out,
- int *flag);
-int copy_fn( MPI_Win oldwin, int keyval, void *extra_state,
- void *attribute_val_in, void *attribute_val_out,
- int *flag)
+int copy_fn(MPI_Win oldwin, int keyval, void *extra_state,
+ void *attribute_val_in, void *attribute_val_out, int *flag);
+int copy_fn(MPI_Win oldwin, int keyval, void *extra_state,
+ void *attribute_val_in, void *attribute_val_out, int *flag)
{
/* Copy the address of the attribute */
- *(void **)attribute_val_out = attribute_val_in;
+ *(void **) attribute_val_out = attribute_val_in;
/* Change the value */
- *(int *)attribute_val_in = *(int *)attribute_val_in + 1;
+ *(int *) attribute_val_in = *(int *) attribute_val_in + 1;
*flag = 1;
return MPI_SUCCESS;
}
/* Delete decrements the attribute value */
-int delete_fn( MPI_Win win, int keyval, void *attribute_val,
- void *extra_state);
-int delete_fn( MPI_Win win, int keyval, void *attribute_val,
- void *extra_state)
+int delete_fn(MPI_Win win, int keyval, void *attribute_val, void *extra_state);
+int delete_fn(MPI_Win win, int keyval, void *attribute_val, void *extra_state)
{
- *(int *)attribute_val = *(int *)attribute_val - 1;
+ *(int *) attribute_val = *(int *) attribute_val - 1;
return MPI_SUCCESS;
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int attrval;
int i, key[32], keyval;
MPI_Win win;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- while (MTestGetWin( &win, 0 )) {
- if (win == MPI_WIN_NULL) continue;
+ while (MTestGetWin(&win, 0)) {
+ if (win == MPI_WIN_NULL)
+ continue;
- MPI_Win_create_keyval( copy_fn, delete_fn, &keyval, (void *)0 );
- attrval = 1;
- MPI_Win_set_attr( win, keyval, (void*)&attrval );
- /* See MPI-1, 5.7.1. Freeing the keyval does not remove it if it
- is in use in an attribute */
- MPI_Win_free_keyval( &keyval );
-
- /* We create some dummy keyvals here in case the same keyval
- is reused */
- for (i=0; i<32; i++) {
- MPI_Win_create_keyval( MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN,
- &key[i], (void *)0 );
- }
+ MPI_Win_create_keyval(copy_fn, delete_fn, &keyval, (void *) 0);
+ attrval = 1;
+ MPI_Win_set_attr(win, keyval, (void *) &attrval);
+ /* See MPI-1, 5.7.1. Freeing the keyval does not remove it if it
+ * is in use in an attribute */
+ MPI_Win_free_keyval(&keyval);
+
+ /* We create some dummy keyvals here in case the same keyval
+ * is reused */
+ for (i = 0; i < 32; i++) {
+ MPI_Win_create_keyval(MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN, &key[i], (void *) 0);
+ }
MTestFreeWin(&win);
- /* Check that the original attribute was freed */
- if (attrval != 0) {
- errs++;
- printf( "Attribute not decremented when win %s freed\n",
- MTestGetWinName() );
- }
- /* Free those other keyvals */
- for (i=0; i<32; i++) {
- MPI_Win_free_keyval( &key[i] );
- }
+ /* Check that the original attribute was freed */
+ if (attrval != 0) {
+ errs++;
+ printf("Attribute not decremented when win %s freed\n", MTestGetWinName());
+ }
+ /* Free those other keyvals */
+ for (i = 0; i < 32; i++) {
+ MPI_Win_free_keyval(&key[i]);
+ }
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
diff --git a/test/mpi/rma/flush.c b/test/mpi/rma/flush.c
index 1f21470..502db11 100644
--- a/test/mpi/rma/flush.c
+++ b/test/mpi/rma/flush.c
@@ -10,7 +10,7 @@
#define ITER 100
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int rank, nproc, i;
int errors = 0, all_errors = 0;
@@ -22,19 +22,21 @@ int main( int argc, char *argv[] )
MPI_Comm_size(MPI_COMM_WORLD, &nproc);
if (nproc < 2) {
- if (rank == 0) printf("Error: must be run with two or more processes\n");
+ if (rank == 0)
+ printf("Error: must be run with two or more processes\n");
MPI_Abort(MPI_COMM_WORLD, 1);
}
/** Create using MPI_Win_create() **/
if (rank == 0) {
- MPI_Alloc_mem(sizeof(int), MPI_INFO_NULL, &buf);
- *buf = nproc-1;
- } else
- buf = NULL;
+ MPI_Alloc_mem(sizeof(int), MPI_INFO_NULL, &buf);
+ *buf = nproc - 1;
+ }
+ else
+ buf = NULL;
- MPI_Win_create(buf, sizeof(int)*(rank == 0), 1, MPI_INFO_NULL, MPI_COMM_WORLD, &window);
+ MPI_Win_create(buf, sizeof(int) * (rank == 0), 1, MPI_INFO_NULL, MPI_COMM_WORLD, &window);
/* Test flush of an empty epoch */
MPI_Win_lock(MPI_LOCK_SHARED, 0, 0, window);
@@ -53,21 +55,22 @@ int main( int argc, char *argv[] )
* to the right. Each process, in turn, performs third-party
* communication via process 0's window. */
if (rank > 0) {
- MPI_Recv(NULL, 0, MPI_BYTE, rank-1, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+ MPI_Recv(NULL, 0, MPI_BYTE, rank - 1, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
}
- MPI_Get_accumulate(&rank, 1, MPI_INT, &val, 1, MPI_INT, 0, 0, 1, MPI_INT, MPI_REPLACE, window);
+ MPI_Get_accumulate(&rank, 1, MPI_INT, &val, 1, MPI_INT, 0, 0, 1, MPI_INT, MPI_REPLACE,
+ window);
MPI_Win_flush(0, window);
- exp = (rank + nproc-1) % nproc;
+ exp = (rank + nproc - 1) % nproc;
if (val != exp) {
printf("%d - Got %d, expected %d\n", rank, val, exp);
errors++;
}
- if (rank < nproc-1) {
- MPI_Send(NULL, 0, MPI_BYTE, rank+1, 0, MPI_COMM_WORLD);
+ if (rank < nproc - 1) {
+ MPI_Send(NULL, 0, MPI_BYTE, rank + 1, 0, MPI_COMM_WORLD);
}
MPI_Barrier(MPI_COMM_WORLD);
@@ -76,7 +79,8 @@ int main( int argc, char *argv[] )
MPI_Win_unlock(0, window);
MPI_Win_free(&window);
- if (buf) MPI_Free_mem(buf);
+ if (buf)
+ MPI_Free_mem(buf);
MPI_Reduce(&errors, &all_errors, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
diff --git a/test/mpi/rma/get-struct.c b/test/mpi/rma/get-struct.c
index 8a91e5f..b85cfe5 100644
--- a/test/mpi/rma/get-struct.c
+++ b/test/mpi/rma/get-struct.c
@@ -20,14 +20,14 @@
#define MAX_VALUE_SIZE 256
typedef struct {
MPI_Aint disp;
- int rank;
- void *lptr;
+ int rank;
+ void *lptr;
} Rptr;
typedef struct {
- Rptr next;
- char key[MAX_KEY_SIZE], value[MAX_VALUE_SIZE];
+ Rptr next;
+ char key[MAX_KEY_SIZE], value[MAX_VALUE_SIZE];
} ListElm;
-Rptr nullDptr = {0,-1,0};
+Rptr nullDptr = { 0, -1, 0 };
int testCases = -1;
#define BYTE_ONLY 0x1
@@ -36,17 +36,17 @@ int isOneLevel = 0;
int main(int argc, char **argv)
{
- int errors=0;
- Rptr headDptr;
- ListElm *headLptr=0;
- int i, wrank;
+ int errors = 0;
+ Rptr headDptr;
+ ListElm *headLptr = 0;
+ int i, wrank;
MPI_Datatype dptrType, listelmType;
- MPI_Win listwin;
+ MPI_Win listwin;
MTest_Init(&argc, &argv);
- MPI_Comm_rank(MPI_COMM_WORLD,&wrank);
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
- for (i=1; i<argc; i++) {
+ for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-byteonly") == 0) {
testCases = BYTE_ONLY;
}
@@ -57,115 +57,117 @@ int main(int argc, char **argv)
isOneLevel = 1;
}
else {
- printf("Unrecognized argument %s\n", argv[i] );
+ printf("Unrecognized argument %s\n", argv[i]);
}
}
/* Create the datatypes that we will use to move the data */
{
- int blens[3];
- MPI_Aint displ[3];
- MPI_Datatype dtypes[3];
- ListElm sampleElm;
-
- blens[0] = 1; blens[1] = 1;
- MPI_Get_address( &nullDptr.disp, &displ[0] );
- MPI_Get_address( &nullDptr.rank, &displ[1] );
- displ[1] = displ[1] - displ[0];
- displ[0] = 0;
- dtypes[0] = MPI_AINT;
- dtypes[1] = MPI_INT;
- MPI_Type_create_struct(2, blens, displ, dtypes, &dptrType);
- MPI_Type_commit(&dptrType);
+ int blens[3];
+ MPI_Aint displ[3];
+ MPI_Datatype dtypes[3];
+ ListElm sampleElm;
+
+ blens[0] = 1;
+ blens[1] = 1;
+ MPI_Get_address(&nullDptr.disp, &displ[0]);
+ MPI_Get_address(&nullDptr.rank, &displ[1]);
+ displ[1] = displ[1] - displ[0];
+ displ[0] = 0;
+ dtypes[0] = MPI_AINT;
+ dtypes[1] = MPI_INT;
+ MPI_Type_create_struct(2, blens, displ, dtypes, &dptrType);
+ MPI_Type_commit(&dptrType);
if (isOneLevel) {
- blens[0] = sizeof(nullDptr); dtypes[0] = MPI_BYTE;
+ blens[0] = sizeof(nullDptr);
+ dtypes[0] = MPI_BYTE;
}
else {
- blens[0] = 1; dtypes[0] = dptrType;
+ blens[0] = 1;
+ dtypes[0] = dptrType;
}
- blens[1] = MAX_KEY_SIZE; dtypes[1] = MPI_CHAR;
- blens[2] = MAX_VALUE_SIZE; dtypes[2] = MPI_CHAR;
- MPI_Get_address(&sampleElm.next,&displ[0]);
- MPI_Get_address(&sampleElm.key[0],&displ[1]);
- MPI_Get_address(&sampleElm.value[0],&displ[2]);
- displ[2] -= displ[0];
- displ[1] -= displ[0];
- displ[0] = 0;
- for (i=0; i<3; i++) {
- MTestPrintfMsg(0,"%d:count=%d,disp=%ld\n",i, blens[i], displ[i]);
+ blens[1] = MAX_KEY_SIZE;
+ dtypes[1] = MPI_CHAR;
+ blens[2] = MAX_VALUE_SIZE;
+ dtypes[2] = MPI_CHAR;
+ MPI_Get_address(&sampleElm.next, &displ[0]);
+ MPI_Get_address(&sampleElm.key[0], &displ[1]);
+ MPI_Get_address(&sampleElm.value[0], &displ[2]);
+ displ[2] -= displ[0];
+ displ[1] -= displ[0];
+ displ[0] = 0;
+ for (i = 0; i < 3; i++) {
+ MTestPrintfMsg(0, "%d:count=%d,disp=%ld\n", i, blens[i], displ[i]);
}
- MPI_Type_create_struct(3, blens, displ, dtypes, &listelmType);
- MPI_Type_commit(&listelmType);
+ MPI_Type_create_struct(3, blens, displ, dtypes, &listelmType);
+ MPI_Type_commit(&listelmType);
}
MPI_Win_create_dynamic(MPI_INFO_NULL, MPI_COMM_WORLD, &listwin);
headDptr.rank = 0;
if (wrank == 0) {
- /* Create 1 list element (the head) and initialize it */
- MPI_Alloc_mem(sizeof(ListElm), MPI_INFO_NULL, &headLptr);
- MPI_Get_address(headLptr, &headDptr.disp);
- headLptr->next.rank = -1;
- headLptr->next.disp = (MPI_Aint)MPI_BOTTOM;
- headLptr->next.lptr = 0;
- strncpy(headLptr->key,"key1",MAX_KEY_SIZE);
- strncpy(headLptr->value,"value1",MAX_VALUE_SIZE);
- MPI_Win_attach(listwin, headLptr, sizeof(ListElm));
+ /* Create 1 list element (the head) and initialize it */
+ MPI_Alloc_mem(sizeof(ListElm), MPI_INFO_NULL, &headLptr);
+ MPI_Get_address(headLptr, &headDptr.disp);
+ headLptr->next.rank = -1;
+ headLptr->next.disp = (MPI_Aint) MPI_BOTTOM;
+ headLptr->next.lptr = 0;
+ strncpy(headLptr->key, "key1", MAX_KEY_SIZE);
+ strncpy(headLptr->value, "value1", MAX_VALUE_SIZE);
+ MPI_Win_attach(listwin, headLptr, sizeof(ListElm));
}
MPI_Bcast(&headDptr.disp, 1, MPI_AINT, 0, MPI_COMM_WORLD);
MPI_Barrier(MPI_COMM_WORLD);
if (wrank == 1) {
- ListElm headcopy;
+ ListElm headcopy;
- MPI_Win_lock_all(0, listwin);
- /* Get head element with simple get of BYTES */
+ MPI_Win_lock_all(0, listwin);
+ /* Get head element with simple get of BYTES */
if (testCases & BYTE_ONLY) {
- headcopy.next.rank=100;
- headcopy.next.disp=0xefefefef;
+ headcopy.next.rank = 100;
+ headcopy.next.disp = 0xefefefef;
MPI_Get(&headcopy, sizeof(ListElm), MPI_BYTE,
- headDptr.rank, headDptr.disp,
- sizeof(ListElm), MPI_BYTE, listwin);
+ headDptr.rank, headDptr.disp, sizeof(ListElm), MPI_BYTE, listwin);
MPI_Win_flush(headDptr.rank, listwin);
- if (headcopy.next.rank != -1 &&
- headcopy.next.disp != (MPI_Aint)MPI_BOTTOM) {
+ if (headcopy.next.rank != -1 && headcopy.next.disp != (MPI_Aint) MPI_BOTTOM) {
errors++;
printf("MPI_BYTE: headcopy contains incorrect next:<%d,%ld>\n",
- headcopy.next.rank, (long)headcopy.next.disp);
+ headcopy.next.rank, (long) headcopy.next.disp);
}
}
if (testCases & TWO_STRUCT) {
- headcopy.next.rank=100;
- headcopy.next.disp=0xefefefef;
+ headcopy.next.rank = 100;
+ headcopy.next.disp = 0xefefefef;
/* Get head element using struct of struct type. This is
- not an identical get to the simple BYTE one above but should
- work */
+ * not an identical get to the simple BYTE one above but should
+ * work */
MPI_Get(&headcopy, 1, listelmType, headDptr.rank, headDptr.disp,
1, listelmType, listwin);
MPI_Win_flush(headDptr.rank, listwin);
- if (headcopy.next.rank != -1 &&
- headcopy.next.disp != (MPI_Aint)MPI_BOTTOM) {
+ if (headcopy.next.rank != -1 && headcopy.next.disp != (MPI_Aint) MPI_BOTTOM) {
errors++;
printf("ListelmType: headcopy contains incorrect next:<%d,%ld>\n",
- headcopy.next.rank, (long)headcopy.next.disp);
+ headcopy.next.rank, (long) headcopy.next.disp);
}
}
- MPI_Win_unlock_all(listwin);
+ MPI_Win_unlock_all(listwin);
}
MPI_Barrier(MPI_COMM_WORLD);
if (wrank == 0) {
- MPI_Win_detach(listwin,headLptr);
- MPI_Free_mem(headLptr);
+ MPI_Win_detach(listwin, headLptr);
+ MPI_Free_mem(headLptr);
}
MPI_Win_free(&listwin);
MPI_Type_free(&dptrType);
MPI_Type_free(&listelmType);
- MTest_Finalize( errors );
+ MTest_Finalize(errors);
MPI_Finalize();
- return MTestReturnValue( errors );
+ return MTestReturnValue(errors);
}
diff --git a/test/mpi/rma/get_acc_local.c b/test/mpi/rma/get_acc_local.c
index ecf3258..c1a38db 100644
--- a/test/mpi/rma/get_acc_local.c
+++ b/test/mpi/rma/get_acc_local.c
@@ -10,33 +10,32 @@
#include "mpitest.h"
-int errors = 0;
-const int NITER = 1000;
+int errors = 0;
+const int NITER = 1000;
const int acc_val = 3;
int main(int argc, char **argv)
{
- int rank, nproc;
- int out_val, i, counter = 0;
- MPI_Win win;
+ int rank, nproc;
+ int out_val, i, counter = 0;
+ MPI_Win win;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &nproc);
- MPI_Win_create(&counter, sizeof(int), sizeof(int), MPI_INFO_NULL,
- MPI_COMM_WORLD, &win);
+ MPI_Win_create(&counter, sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win);
for (i = 0; i < NITER; i++) {
MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, win);
MPI_Get_accumulate(&acc_val, 1, MPI_INT, &out_val, 1, MPI_INT,
- rank, 0, 1, MPI_INT, MPI_SUM, win);
+ rank, 0, 1, MPI_INT, MPI_SUM, win);
MPI_Win_unlock(rank, win);
- if (out_val != acc_val*i) {
+ if (out_val != acc_val * i) {
errors++;
- printf("Error: got %d, expected %d at iter %d\n", out_val, acc_val*i, i);
+ printf("Error: got %d, expected %d at iter %d\n", out_val, acc_val * i, i);
break;
}
}
diff --git a/test/mpi/rma/get_accumulate.c b/test/mpi/rma/get_accumulate.c
index 5a533fe..142ae38 100644
--- a/test/mpi/rma/get_accumulate.c
+++ b/test/mpi/rma/get_accumulate.c
@@ -39,7 +39,8 @@
# define TYPE_MPI TYPE_MPI_BASE
#endif
-void reset_bufs(TYPE_C *win_ptr, TYPE_C *res_ptr, TYPE_C *val_ptr, TYPE_C value, MPI_Win win) {
+void reset_bufs(TYPE_C * win_ptr, TYPE_C * res_ptr, TYPE_C * val_ptr, TYPE_C value, MPI_Win win)
+{
int rank, nproc, i;
MPI_Barrier(MPI_COMM_WORLD);
@@ -48,10 +49,10 @@ void reset_bufs(TYPE_C *win_ptr, TYPE_C *res_ptr, TYPE_C *val_ptr, TYPE_C value,
MPI_Comm_size(MPI_COMM_WORLD, &nproc);
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, win);
- memset(win_ptr, 0, sizeof(TYPE_C)*nproc*COUNT);
+ memset(win_ptr, 0, sizeof(TYPE_C) * nproc * COUNT);
MPI_Win_unlock(rank, win);
- memset(res_ptr, -1, sizeof(TYPE_C)*nproc*COUNT);
+ memset(res_ptr, -1, sizeof(TYPE_C) * nproc * COUNT);
for (i = 0; i < COUNT; i++)
val_ptr[i] = value;
@@ -59,11 +60,12 @@ void reset_bufs(TYPE_C *win_ptr, TYPE_C *res_ptr, TYPE_C *val_ptr, TYPE_C value,
MPI_Barrier(MPI_COMM_WORLD);
}
-int main(int argc, char **argv) {
- int i, rank, nproc;
- int errors = 0, all_errors = 0;
- TYPE_C *win_ptr, *res_ptr, *val_ptr;
- MPI_Win win;
+int main(int argc, char **argv)
+{
+ int i, rank, nproc;
+ int errors = 0, all_errors = 0;
+ TYPE_C *win_ptr, *res_ptr, *val_ptr;
+ MPI_Win win;
#if defined (GACC_TYPE_DERIVED)
MPI_Datatype derived_type;
#endif
@@ -73,16 +75,16 @@ int main(int argc, char **argv) {
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &nproc);
- win_ptr = malloc(sizeof(TYPE_C)*nproc*COUNT);
- res_ptr = malloc(sizeof(TYPE_C)*nproc*COUNT);
- val_ptr = malloc(sizeof(TYPE_C)*COUNT);
+ win_ptr = malloc(sizeof(TYPE_C) * nproc * COUNT);
+ res_ptr = malloc(sizeof(TYPE_C) * nproc * COUNT);
+ val_ptr = malloc(sizeof(TYPE_C) * COUNT);
#if defined (GACC_TYPE_DERIVED)
MPI_Type_contiguous(1, TYPE_MPI_BASE, &derived_type);
MPI_Type_commit(&derived_type);
#endif
- MPI_Win_create(win_ptr, sizeof(TYPE_C)*nproc*COUNT, sizeof(TYPE_C),
+ MPI_Win_create(win_ptr, sizeof(TYPE_C) * nproc * COUNT, sizeof(TYPE_C),
MPI_INFO_NULL, MPI_COMM_WORLD, &win);
/* Test self communication */
@@ -91,16 +93,16 @@ int main(int argc, char **argv) {
for (i = 0; i < ITER; i++) {
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, win);
- MPI_Get_accumulate(val_ptr, COUNT, TYPE_MPI, res_ptr, COUNT, TYPE_MPI,
- rank, 0, COUNT, TYPE_MPI, MPI_SUM, win);
+ MPI_Get_accumulate(val_ptr, COUNT, TYPE_MPI, res_ptr, COUNT, TYPE_MPI,
+ rank, 0, COUNT, TYPE_MPI, MPI_SUM, win);
MPI_Win_unlock(rank, win);
}
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, win);
for (i = 0; i < COUNT; i++) {
if (win_ptr[i] != ITER) {
- SQUELCH( printf("%d->%d -- SELF[%d]: expected "TYPE_FMT", got "TYPE_FMT"\n",
- rank, rank, i, (TYPE_C) ITER, win_ptr[i]); );
+ SQUELCH(printf("%d->%d -- SELF[%d]: expected " TYPE_FMT ", got " TYPE_FMT "\n",
+ rank, rank, i, (TYPE_C) ITER, win_ptr[i]););
errors++;
}
}
@@ -111,10 +113,10 @@ int main(int argc, char **argv) {
reset_bufs(win_ptr, res_ptr, val_ptr, 1, win);
for (i = 0; i < ITER; i++) {
- MPI_Win_lock(MPI_LOCK_EXCLUSIVE, (rank+1)%nproc, 0, win);
- MPI_Get_accumulate(val_ptr, COUNT, TYPE_MPI, res_ptr, COUNT, TYPE_MPI,
- (rank+1)%nproc, 0, COUNT, TYPE_MPI, MPI_SUM, win);
- MPI_Win_unlock((rank+1)%nproc, win);
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, (rank + 1) % nproc, 0, win);
+ MPI_Get_accumulate(val_ptr, COUNT, TYPE_MPI, res_ptr, COUNT, TYPE_MPI,
+ (rank + 1) % nproc, 0, COUNT, TYPE_MPI, MPI_SUM, win);
+ MPI_Win_unlock((rank + 1) % nproc, win);
}
MPI_Barrier(MPI_COMM_WORLD);
@@ -122,8 +124,8 @@ int main(int argc, char **argv) {
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, win);
for (i = 0; i < COUNT; i++) {
if (win_ptr[i] != ITER) {
- SQUELCH( printf("%d->%d -- NEIGHBOR[%d]: expected "TYPE_FMT", got "TYPE_FMT"\n",
- (rank+1)%nproc, rank, i, (TYPE_C) ITER, win_ptr[i]); );
+ SQUELCH(printf("%d->%d -- NEIGHBOR[%d]: expected " TYPE_FMT ", got " TYPE_FMT "\n",
+ (rank + 1) % nproc, rank, i, (TYPE_C) ITER, win_ptr[i]););
errors++;
}
}
@@ -136,8 +138,8 @@ int main(int argc, char **argv) {
if (rank != 0) {
for (i = 0; i < ITER; i++) {
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, 0, 0, win);
- MPI_Get_accumulate(val_ptr, COUNT, TYPE_MPI, res_ptr, COUNT, TYPE_MPI,
- 0, 0, COUNT, TYPE_MPI, MPI_SUM, win);
+ MPI_Get_accumulate(val_ptr, COUNT, TYPE_MPI, res_ptr, COUNT, TYPE_MPI,
+ 0, 0, COUNT, TYPE_MPI, MPI_SUM, win);
MPI_Win_unlock(0, win);
}
}
@@ -147,9 +149,9 @@ int main(int argc, char **argv) {
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, win);
if (rank == 0 && nproc > 1) {
for (i = 0; i < COUNT; i++) {
- if (win_ptr[i] != ITER*(nproc-1)) {
- SQUELCH( printf("*->%d - CONTENTION[%d]: expected="TYPE_FMT" val="TYPE_FMT"\n",
- rank, i, (TYPE_C) ITER*(nproc-1), win_ptr[i]); );
+ if (win_ptr[i] != ITER * (nproc - 1)) {
+ SQUELCH(printf("*->%d - CONTENTION[%d]: expected=" TYPE_FMT " val=" TYPE_FMT "\n",
+ rank, i, (TYPE_C) ITER * (nproc - 1), win_ptr[i]););
errors++;
}
}
@@ -165,8 +167,8 @@ int main(int argc, char **argv) {
MPI_Win_fence(MPI_MODE_NOPRECEDE, win);
for (j = 0; j < nproc; j++) {
- MPI_Get_accumulate(val_ptr, COUNT, TYPE_MPI, &res_ptr[j*COUNT], COUNT, TYPE_MPI,
- j, rank*COUNT, COUNT, TYPE_MPI, MPI_SUM, win);
+ MPI_Get_accumulate(val_ptr, COUNT, TYPE_MPI, &res_ptr[j * COUNT], COUNT, TYPE_MPI,
+ j, rank * COUNT, COUNT, TYPE_MPI, MPI_SUM, win);
}
MPI_Win_fence(MPI_MODE_NOSUCCEED, win);
MPI_Barrier(MPI_COMM_WORLD);
@@ -174,9 +176,11 @@ int main(int argc, char **argv) {
for (j = 0; j < nproc; j++) {
int c;
for (c = 0; c < COUNT; c++) {
- if (res_ptr[j*COUNT+c] != i*rank) {
- SQUELCH( printf("%d->%d -- ALL-TO-ALL (FENCE) [%d]: iter %d, expected result "TYPE_FMT", got "TYPE_FMT"\n",
- rank, j, c, i, (TYPE_C) i*rank, res_ptr[j*COUNT+c]); );
+ if (res_ptr[j * COUNT + c] != i * rank) {
+ SQUELCH(printf
+ ("%d->%d -- ALL-TO-ALL (FENCE) [%d]: iter %d, expected result " TYPE_FMT
+ ", got " TYPE_FMT "\n", rank, j, c, i, (TYPE_C) i * rank,
+ res_ptr[j * COUNT + c]););
errors++;
}
}
@@ -188,9 +192,10 @@ int main(int argc, char **argv) {
for (i = 0; i < nproc; i++) {
int c;
for (c = 0; c < COUNT; c++) {
- if (win_ptr[i*COUNT+c] != ITER*i) {
- SQUELCH( printf("%d->%d -- ALL-TO-ALL (FENCE): expected "TYPE_FMT", got "TYPE_FMT"\n",
- i, rank, (TYPE_C) ITER*i, win_ptr[i*COUNT+c]); );
+ if (win_ptr[i * COUNT + c] != ITER * i) {
+ SQUELCH(printf
+ ("%d->%d -- ALL-TO-ALL (FENCE): expected " TYPE_FMT ", got " TYPE_FMT "\n",
+ i, rank, (TYPE_C) ITER * i, win_ptr[i * COUNT + c]););
errors++;
}
}
@@ -206,8 +211,8 @@ int main(int argc, char **argv) {
MPI_Win_lock_all(0, win);
for (j = 0; j < nproc; j++) {
- MPI_Get_accumulate(val_ptr, COUNT, TYPE_MPI, &res_ptr[j*COUNT], COUNT, TYPE_MPI,
- j, rank*COUNT, COUNT, TYPE_MPI, MPI_SUM, win);
+ MPI_Get_accumulate(val_ptr, COUNT, TYPE_MPI, &res_ptr[j * COUNT], COUNT, TYPE_MPI,
+ j, rank * COUNT, COUNT, TYPE_MPI, MPI_SUM, win);
}
MPI_Win_unlock_all(win);
MPI_Barrier(MPI_COMM_WORLD);
@@ -215,9 +220,11 @@ int main(int argc, char **argv) {
for (j = 0; j < nproc; j++) {
int c;
for (c = 0; c < COUNT; c++) {
- if (res_ptr[j*COUNT+c] != i*rank) {
- SQUELCH( printf("%d->%d -- ALL-TO-ALL (LOCK-ALL) [%d]: iter %d, expected result "TYPE_FMT", got "TYPE_FMT"\n",
- rank, j, c, i, (TYPE_C) i*rank, res_ptr[j*COUNT+c]); );
+ if (res_ptr[j * COUNT + c] != i * rank) {
+ SQUELCH(printf
+ ("%d->%d -- ALL-TO-ALL (LOCK-ALL) [%d]: iter %d, expected result "
+ TYPE_FMT ", got " TYPE_FMT "\n", rank, j, c, i, (TYPE_C) i * rank,
+ res_ptr[j * COUNT + c]););
errors++;
}
}
@@ -229,9 +236,10 @@ int main(int argc, char **argv) {
for (i = 0; i < nproc; i++) {
int c;
for (c = 0; c < COUNT; c++) {
- if (win_ptr[i*COUNT+c] != ITER*i) {
- SQUELCH( printf("%d->%d -- ALL-TO-ALL (LOCK-ALL): expected "TYPE_FMT", got "TYPE_FMT"\n",
- i, rank, (TYPE_C) ITER*i, win_ptr[i*COUNT+c]); );
+ if (win_ptr[i * COUNT + c] != ITER * i) {
+ SQUELCH(printf
+ ("%d->%d -- ALL-TO-ALL (LOCK-ALL): expected " TYPE_FMT ", got " TYPE_FMT
+ "\n", i, rank, (TYPE_C) ITER * i, win_ptr[i * COUNT + c]););
errors++;
}
}
@@ -247,8 +255,8 @@ int main(int argc, char **argv) {
MPI_Win_lock_all(0, win);
for (j = 0; j < nproc; j++) {
- MPI_Get_accumulate(val_ptr, COUNT, TYPE_MPI, &res_ptr[j*COUNT], COUNT, TYPE_MPI,
- j, rank*COUNT, COUNT, TYPE_MPI, MPI_SUM, win);
+ MPI_Get_accumulate(val_ptr, COUNT, TYPE_MPI, &res_ptr[j * COUNT], COUNT, TYPE_MPI,
+ j, rank * COUNT, COUNT, TYPE_MPI, MPI_SUM, win);
MPI_Win_flush(j, win);
}
MPI_Win_unlock_all(win);
@@ -257,9 +265,11 @@ int main(int argc, char **argv) {
for (j = 0; j < nproc; j++) {
int c;
for (c = 0; c < COUNT; c++) {
- if (res_ptr[j*COUNT+c] != i*rank) {
- SQUELCH( printf("%d->%d -- ALL-TO-ALL (LOCK-ALL+FLUSH) [%d]: iter %d, expected result "TYPE_FMT", got "TYPE_FMT"\n",
- rank, j, c, i, (TYPE_C) i*rank, res_ptr[j*COUNT+c]); );
+ if (res_ptr[j * COUNT + c] != i * rank) {
+ SQUELCH(printf
+ ("%d->%d -- ALL-TO-ALL (LOCK-ALL+FLUSH) [%d]: iter %d, expected result "
+ TYPE_FMT ", got " TYPE_FMT "\n", rank, j, c, i, (TYPE_C) i * rank,
+ res_ptr[j * COUNT + c]););
errors++;
}
}
@@ -271,9 +281,10 @@ int main(int argc, char **argv) {
for (i = 0; i < nproc; i++) {
int c;
for (c = 0; c < COUNT; c++) {
- if (win_ptr[i*COUNT+c] != ITER*i) {
- SQUELCH( printf("%d->%d -- ALL-TO-ALL (LOCK-ALL+FLUSH): expected "TYPE_FMT", got "TYPE_FMT"\n",
- i, rank, (TYPE_C) ITER*i, win_ptr[i*COUNT+c]); );
+ if (win_ptr[i * COUNT + c] != ITER * i) {
+ SQUELCH(printf
+ ("%d->%d -- ALL-TO-ALL (LOCK-ALL+FLUSH): expected " TYPE_FMT ", got "
+ TYPE_FMT "\n", i, rank, (TYPE_C) ITER * i, win_ptr[i * COUNT + c]););
errors++;
}
}
@@ -285,24 +296,24 @@ int main(int argc, char **argv) {
reset_bufs(win_ptr, res_ptr, val_ptr, 1, win);
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, win);
- for (i = 0; i < COUNT*nproc; i++)
+ for (i = 0; i < COUNT * nproc; i++)
win_ptr[i] = (TYPE_C) rank;
MPI_Win_unlock(rank, win);
MPI_Barrier(MPI_COMM_WORLD);
for (i = 0; i < ITER; i++) {
- int j, target = (rank+1) % nproc;
+ int j, target = (rank + 1) % nproc;
/* Test: origin_buf = NULL */
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, target, 0, win);
MPI_Get_accumulate(NULL, COUNT, TYPE_MPI, res_ptr, COUNT, TYPE_MPI,
- target, 0, COUNT, TYPE_MPI, MPI_NO_OP, win);
+ target, 0, COUNT, TYPE_MPI, MPI_NO_OP, win);
MPI_Win_unlock(target, win);
for (j = 0; j < COUNT; j++) {
if (res_ptr[j] != (TYPE_C) target) {
- SQUELCH( printf("%d->%d -- NOP(1)[%d]: expected "TYPE_FMT", got "TYPE_FMT"\n",
- target, rank, i, (TYPE_C) target, res_ptr[i]); );
+ SQUELCH(printf("%d->%d -- NOP(1)[%d]: expected " TYPE_FMT ", got " TYPE_FMT "\n",
+ target, rank, i, (TYPE_C) target, res_ptr[i]););
errors++;
}
}
@@ -310,13 +321,13 @@ int main(int argc, char **argv) {
/* Test: origin_buf = NULL, origin_count = 0 */
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, target, 0, win);
MPI_Get_accumulate(NULL, 0, TYPE_MPI, res_ptr, COUNT, TYPE_MPI,
- target, 0, COUNT, TYPE_MPI, MPI_NO_OP, win);
+ target, 0, COUNT, TYPE_MPI, MPI_NO_OP, win);
MPI_Win_unlock(target, win);
for (j = 0; j < COUNT; j++) {
if (res_ptr[j] != (TYPE_C) target) {
- SQUELCH( printf("%d->%d -- NOP(2)[%d]: expected "TYPE_FMT", got "TYPE_FMT"\n",
- target, rank, i, (TYPE_C) target, res_ptr[i]); );
+ SQUELCH(printf("%d->%d -- NOP(2)[%d]: expected " TYPE_FMT ", got " TYPE_FMT "\n",
+ target, rank, i, (TYPE_C) target, res_ptr[i]););
errors++;
}
}
@@ -324,13 +335,13 @@ int main(int argc, char **argv) {
/* Test: origin_buf = NULL, origin_count = 0, origin_dtype = NULL */
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, target, 0, win);
MPI_Get_accumulate(NULL, 0, MPI_DATATYPE_NULL, res_ptr, COUNT, TYPE_MPI,
- target, 0, COUNT, TYPE_MPI, MPI_NO_OP, win);
+ target, 0, COUNT, TYPE_MPI, MPI_NO_OP, win);
MPI_Win_unlock(target, win);
for (j = 0; j < COUNT; j++) {
if (res_ptr[j] != (TYPE_C) target) {
- SQUELCH( printf("%d->%d -- NOP(2)[%d]: expected "TYPE_FMT", got "TYPE_FMT"\n",
- target, rank, i, (TYPE_C) target, res_ptr[i]); );
+ SQUELCH(printf("%d->%d -- NOP(2)[%d]: expected " TYPE_FMT ", got " TYPE_FMT "\n",
+ target, rank, i, (TYPE_C) target, res_ptr[i]););
errors++;
}
}
@@ -341,7 +352,7 @@ int main(int argc, char **argv) {
reset_bufs(win_ptr, res_ptr, val_ptr, 1, win);
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, win);
- for (i = 0; i < COUNT*nproc; i++)
+ for (i = 0; i < COUNT * nproc; i++)
win_ptr[i] = (TYPE_C) rank;
MPI_Win_unlock(rank, win);
MPI_Barrier(MPI_COMM_WORLD);
@@ -352,13 +363,14 @@ int main(int argc, char **argv) {
/* Test: origin_buf = NULL */
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, target, 0, win);
MPI_Get_accumulate(NULL, COUNT, TYPE_MPI, res_ptr, COUNT, TYPE_MPI,
- target, 0, COUNT, TYPE_MPI, MPI_NO_OP, win);
+ target, 0, COUNT, TYPE_MPI, MPI_NO_OP, win);
MPI_Win_unlock(target, win);
for (j = 0; j < COUNT; j++) {
if (res_ptr[j] != (TYPE_C) target) {
- SQUELCH( printf("%d->%d -- NOP_SELF(1)[%d]: expected "TYPE_FMT", got "TYPE_FMT"\n",
- target, rank, i, (TYPE_C) target, res_ptr[i]); );
+ SQUELCH(printf
+ ("%d->%d -- NOP_SELF(1)[%d]: expected " TYPE_FMT ", got " TYPE_FMT "\n",
+ target, rank, i, (TYPE_C) target, res_ptr[i]););
errors++;
}
}
@@ -366,13 +378,14 @@ int main(int argc, char **argv) {
/* Test: origin_buf = NULL, origin_count = 0 */
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, target, 0, win);
MPI_Get_accumulate(NULL, 0, TYPE_MPI, res_ptr, COUNT, TYPE_MPI,
- target, 0, COUNT, TYPE_MPI, MPI_NO_OP, win);
+ target, 0, COUNT, TYPE_MPI, MPI_NO_OP, win);
MPI_Win_unlock(target, win);
for (j = 0; j < COUNT; j++) {
if (res_ptr[j] != (TYPE_C) target) {
- SQUELCH( printf("%d->%d -- NOP_SELF(2)[%d]: expected "TYPE_FMT", got "TYPE_FMT"\n",
- target, rank, i, (TYPE_C) target, res_ptr[i]); );
+ SQUELCH(printf
+ ("%d->%d -- NOP_SELF(2)[%d]: expected " TYPE_FMT ", got " TYPE_FMT "\n",
+ target, rank, i, (TYPE_C) target, res_ptr[i]););
errors++;
}
}
@@ -380,13 +393,14 @@ int main(int argc, char **argv) {
/* Test: origin_buf = NULL, origin_count = 0, origin_dtype = NULL */
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, target, 0, win);
MPI_Get_accumulate(NULL, 0, MPI_DATATYPE_NULL, res_ptr, COUNT, TYPE_MPI,
- target, 0, COUNT, TYPE_MPI, MPI_NO_OP, win);
+ target, 0, COUNT, TYPE_MPI, MPI_NO_OP, win);
MPI_Win_unlock(target, win);
for (j = 0; j < COUNT; j++) {
if (res_ptr[j] != (TYPE_C) target) {
- SQUELCH( printf("%d->%d -- NOP_SELF(2)[%d]: expected "TYPE_FMT", got "TYPE_FMT"\n",
- target, rank, i, (TYPE_C) target, res_ptr[i]); );
+ SQUELCH(printf
+ ("%d->%d -- NOP_SELF(2)[%d]: expected " TYPE_FMT ", got " TYPE_FMT "\n",
+ target, rank, i, (TYPE_C) target, res_ptr[i]););
errors++;
}
}
diff --git a/test/mpi/rma/getfence1.c b/test/mpi/rma/getfence1.c
index 80034df..342ba67 100644
--- a/test/mpi/rma/getfence1.c
+++ b/test/mpi/rma/getfence1.c
@@ -18,109 +18,108 @@ static char MTEST_Descrip[] = "Get with Fence";
*/
static inline int test(MPI_Comm comm, int rank, int source, int dest,
- MTestDatatype *sendtype, MTestDatatype *recvtype)
+ MTestDatatype * sendtype, MTestDatatype * recvtype)
{
int errs = 0, err;
int disp_unit;
- MPI_Aint extent;
- MPI_Win win;
+ MPI_Aint extent;
+ MPI_Win win;
- MTestPrintfMsg( 1,
- "Getting count = %ld of sendtype %s - count = %ld receive type %s\n",
- sendtype->count, MTestGetDatatypeName( sendtype ), recvtype->count,
- MTestGetDatatypeName( recvtype ) );
+ MTestPrintfMsg(1,
+ "Getting count = %ld of sendtype %s - count = %ld receive type %s\n",
+ sendtype->count, MTestGetDatatypeName(sendtype), recvtype->count,
+ MTestGetDatatypeName(recvtype));
/* Make sure that everyone has a recv buffer */
- recvtype->InitBuf( recvtype );
- sendtype->InitBuf( sendtype );
+ recvtype->InitBuf(recvtype);
+ sendtype->InitBuf(sendtype);
/* By default, print information about errors */
recvtype->printErrors = 1;
sendtype->printErrors = 1;
- MPI_Type_extent( sendtype->datatype, &extent );
+ MPI_Type_extent(sendtype->datatype, &extent);
disp_unit = extent < INT_MAX ? extent : 1;
- MPI_Win_create( sendtype->buf, sendtype->count * extent,
- disp_unit, MPI_INFO_NULL, comm, &win );
- MPI_Win_fence( 0, win );
+ MPI_Win_create(sendtype->buf, sendtype->count * extent, disp_unit, MPI_INFO_NULL, comm, &win);
+ MPI_Win_fence(0, win);
if (rank == source) {
/* The source does not need to do anything besides the
- fence */
- MPI_Win_fence( 0, win );
+ * fence */
+ MPI_Win_fence(0, win);
}
else if (rank == dest) {
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Win_set_errhandler( win, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Win_set_errhandler(win, MPI_ERRORS_RETURN);
/* This should have the same effect, in terms of
- transfering data, as a send/recv pair */
- err = MPI_Get( recvtype->buf, recvtype->count,
- recvtype->datatype, source, 0,
- sendtype->count, sendtype->datatype, win );
+ * transfering data, as a send/recv pair */
+ err = MPI_Get(recvtype->buf, recvtype->count,
+ recvtype->datatype, source, 0, sendtype->count, sendtype->datatype, win);
if (err) {
errs++;
if (errs < 10) {
- MTestPrintError( err );
+ MTestPrintError(err);
}
}
- err = MPI_Win_fence( 0, win );
+ err = MPI_Win_fence(0, win);
if (err) {
errs++;
if (errs < 10) {
- MTestPrintError( err );
+ MTestPrintError(err);
}
}
- err = MTestCheckRecv( 0, recvtype );
+ err = MTestCheckRecv(0, recvtype);
if (err) {
errs += err;
}
}
else {
- MPI_Win_fence( 0, win );
+ MPI_Win_fence(0, win);
}
- MPI_Win_free( &win );
+ MPI_Win_free(&win);
return errs;
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size, source, dest;
- int minsize = 2, count;
- MPI_Comm comm;
+ int minsize = 2, count;
+ MPI_Comm comm;
MTestDatatype sendtype, recvtype;
- MTest_Init( &argc, &argv );
-
- /* The following illustrates the use of the routines to
- run through a selection of communicators and datatypes.
- Use subsets of these for tests that do not involve combinations
- of communicators, datatypes, and counts of datatypes */
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
- /* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
- source = 0;
- dest = size - 1;
-
- MTEST_DATATYPE_FOR_EACH_COUNT(count) {
- while (MTestGetDatatypes( &sendtype, &recvtype, count )) {
+ MTest_Init(&argc, &argv);
+
+ /* The following illustrates the use of the routines to
+ * run through a selection of communicators and datatypes.
+ * Use subsets of these for tests that do not involve combinations
+ * of communicators, datatypes, and counts of datatypes */
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ /* Determine the sender and receiver */
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+ source = 0;
+ dest = size - 1;
+
+ MTEST_DATATYPE_FOR_EACH_COUNT(count) {
+ while (MTestGetDatatypes(&sendtype, &recvtype, count)) {
errs += test(comm, rank, source, dest, &sendtype, &recvtype);
MTestFreeDatatype(&sendtype);
MTestFreeDatatype(&recvtype);
- }
- }
+ }
+ }
MTestFreeComm(&comm);
}
/* Part #2: simple large size test - contiguous and noncontiguous */
- if (sizeof(void *) > 4) { /* Only if > 32-bit architecture */
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ if (sizeof(void *) > 4) { /* Only if > 32-bit architecture */
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
source = 0;
- dest = size - 1;
+ dest = size - 1;
MTestGetDatatypes(&sendtype, &recvtype, LARGE_CNT_CONTIG);
errs += test(MPI_COMM_WORLD, rank, source, dest, &sendtype, &recvtype);
@@ -135,7 +134,7 @@ int main( int argc, char *argv[] )
MTestFreeDatatype(&recvtype);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/rma/getgroup.c b/test/mpi/rma/getgroup.c
index 4dd0c0d..051bb5f 100644
--- a/test/mpi/rma/getgroup.c
+++ b/test/mpi/rma/getgroup.c
@@ -12,41 +12,41 @@
static char MTEST_Descrip[] = "Test of Win_get_group";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int result;
int buf[10];
- MPI_Win win;
+ MPI_Win win;
MPI_Group group, wingroup;
int minsize = 2;
- MPI_Comm comm;
+ MPI_Comm comm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- /* The following illustrates the use of the routines to
- run through a selection of communicators and datatypes.
- Use subsets of these for tests that do not involve combinations
- of communicators, datatypes, and counts of datatypes */
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
+ /* The following illustrates the use of the routines to
+ * run through a selection of communicators and datatypes.
+ * Use subsets of these for tests that do not involve combinations
+ * of communicators, datatypes, and counts of datatypes */
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
- MPI_Win_create( buf, sizeof(int) * 10, sizeof(int),
- MPI_INFO_NULL, comm, &win );
- MPI_Win_get_group( win, &wingroup );
- MPI_Comm_group( comm, &group );
- MPI_Group_compare( group, wingroup, &result );
- if (result != MPI_IDENT) {
- errs++;
- fprintf( stderr, "Group returned by Win_get_group not the same as the input group\n" );
- }
- MPI_Group_free( &wingroup );
- MPI_Group_free( &group );
- MPI_Win_free( &win );
+ MPI_Win_create(buf, sizeof(int) * 10, sizeof(int), MPI_INFO_NULL, comm, &win);
+ MPI_Win_get_group(win, &wingroup);
+ MPI_Comm_group(comm, &group);
+ MPI_Group_compare(group, wingroup, &result);
+ if (result != MPI_IDENT) {
+ errs++;
+ fprintf(stderr, "Group returned by Win_get_group not the same as the input group\n");
+ }
+ MPI_Group_free(&wingroup);
+ MPI_Group_free(&group);
+ MPI_Win_free(&win);
MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/rma/linked_list.c b/test/mpi/rma/linked_list.c
index c0dc769..126ab62 100644
--- a/test/mpi/rma/linked_list.c
+++ b/test/mpi/rma/linked_list.c
@@ -7,7 +7,7 @@
/* MPI-3 distributed linked list construction example
* --------------------------------------------------
- *
+ *
* Construct a distributed shared linked list using proposed MPI-3 dynamic
* windows. Initially process 0 creates the head of the list, attaches it to
* the window, and broadcasts the pointer to all processes. All processes then
@@ -33,7 +33,7 @@
/* Linked list pointer */
typedef struct {
- int rank;
+ int rank;
MPI_Aint disp;
} llist_ptr_t;
@@ -44,28 +44,30 @@ typedef struct {
} llist_elem_t;
static const llist_ptr_t nil = { -1, (MPI_Aint) MPI_BOTTOM };
+
static const int verbose = 0;
/* List of locally allocated list elements. */
static llist_elem_t **my_elems = NULL;
-static int my_elems_size = 0;
+static int my_elems_size = 0;
static int my_elems_count = 0;
/* Allocate a new shared linked list element */
-MPI_Aint alloc_elem(int value, MPI_Win win) {
+MPI_Aint alloc_elem(int value, MPI_Win win)
+{
MPI_Aint disp;
llist_elem_t *elem_ptr;
/* Allocate the new element and register it with the window */
MPI_Alloc_mem(sizeof(llist_elem_t), MPI_INFO_NULL, &elem_ptr);
elem_ptr->value = value;
- elem_ptr->next = nil;
+ elem_ptr->next = nil;
MPI_Win_attach(win, elem_ptr, sizeof(llist_elem_t));
/* Add the element to the list of local elements so we can free it later. */
if (my_elems_size == my_elems_count) {
my_elems_size += 100;
- my_elems = realloc(my_elems, my_elems_size*sizeof(void*));
+ my_elems = realloc(my_elems, my_elems_size * sizeof(void *));
}
my_elems[my_elems_count] = elem_ptr;
my_elems_count++;
@@ -74,10 +76,11 @@ MPI_Aint alloc_elem(int value, MPI_Win win) {
return disp;
}
-int main(int argc, char **argv) {
- int procid, nproc, i;
- MPI_Win llist_win;
- llist_ptr_t head_ptr, tail_ptr;
+int main(int argc, char **argv)
+{
+ int procid, nproc, i;
+ MPI_Win llist_win;
+ llist_ptr_t head_ptr, tail_ptr;
MPI_Init(&argc, &argv);
@@ -105,15 +108,16 @@ int main(int argc, char **argv) {
new_elem_ptr.disp = alloc_elem(procid, llist_win);
/* Append the new node to the list. This might take multiple attempts if
- others have already appended and our tail pointer is stale. */
+ * others have already appended and our tail pointer is stale. */
do {
llist_ptr_t next_tail_ptr = nil;
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, tail_ptr.rank, 0, llist_win);
- MPI_Compare_and_swap((void*) &new_elem_ptr.rank, (void*) &nil.rank,
- (void*) &next_tail_ptr.rank, MPI_INT, tail_ptr.rank,
- (MPI_Aint) &(((llist_elem_t*)tail_ptr.disp)->next.rank), llist_win);
+ MPI_Compare_and_swap((void *) &new_elem_ptr.rank, (void *) &nil.rank,
+ (void *) &next_tail_ptr.rank, MPI_INT, tail_ptr.rank,
+ (MPI_Aint) & (((llist_elem_t *) tail_ptr.disp)->next.rank),
+ llist_win);
MPI_Win_unlock(tail_ptr.rank, llist_win);
success = (next_tail_ptr.rank == nil.rank);
@@ -124,26 +128,28 @@ int main(int argc, char **argv) {
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, tail_ptr.rank, 0, llist_win);
MPI_Put(&new_elem_ptr.disp, 1, MPI_AINT, tail_ptr.rank,
- (MPI_Aint) &(((llist_elem_t*)tail_ptr.disp)->next.disp), 1,
+ (MPI_Aint) & (((llist_elem_t *) tail_ptr.disp)->next.disp), 1,
MPI_AINT, llist_win);
MPI_Win_unlock(tail_ptr.rank, llist_win);
tail_ptr = new_elem_ptr;
/* For implementations that use pt-to-pt messaging, force progress for other threads'
- RMA operations. */
+ * RMA operations. */
for (i = 0; i < NPROBE; i++)
- MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag, MPI_STATUS_IGNORE);
+ MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag,
+ MPI_STATUS_IGNORE);
- } else {
+ }
+ else {
/* Tail pointer is stale, fetch the displacement. May take multiple tries
- if it is being updated. */
+ * if it is being updated. */
do {
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, tail_ptr.rank, 0, llist_win);
- MPI_Get( &next_tail_ptr.disp, 1, MPI_AINT, tail_ptr.rank,
- (MPI_Aint) &(((llist_elem_t*)tail_ptr.disp)->next.disp),
- 1, MPI_AINT, llist_win);
+ MPI_Get(&next_tail_ptr.disp, 1, MPI_AINT, tail_ptr.rank,
+ (MPI_Aint) & (((llist_elem_t *) tail_ptr.disp)->next.disp),
+ 1, MPI_AINT, llist_win);
MPI_Win_unlock(tail_ptr.rank, llist_win);
} while (next_tail_ptr.disp == nil.disp);
@@ -155,13 +161,13 @@ int main(int argc, char **argv) {
MPI_Barrier(MPI_COMM_WORLD);
/* Traverse the list and verify that all processes inserted exactly the correct
- number of elements. */
+ * number of elements. */
if (procid == 0) {
- int have_root = 0;
- int errors = 0;
+ int have_root = 0;
+ int errors = 0;
int *counts, count = 0;
- counts = (int*) malloc(sizeof(int) * nproc);
+ counts = (int *) malloc(sizeof(int) * nproc);
assert(counts != NULL);
for (i = 0; i < nproc; i++)
@@ -204,14 +210,15 @@ int main(int argc, char **argv) {
}
if (verbose)
- printf("\n\n");
+ printf("\n\n");
/* Verify the counts we collected */
for (i = 0; i < nproc; i++) {
int expected = NUM_ELEMS;
if (counts[i] != expected) {
- printf("Error: Rank %d inserted %d elements, expected %d\n", i, counts[i], expected);
+ printf("Error: Rank %d inserted %d elements, expected %d\n", i, counts[i],
+ expected);
errors++;
}
}
@@ -223,8 +230,8 @@ int main(int argc, char **argv) {
MPI_Win_free(&llist_win);
/* Free all the elements in the list */
- for ( ; my_elems_count > 0; my_elems_count--)
- MPI_Free_mem(my_elems[my_elems_count-1]);
+ for (; my_elems_count > 0; my_elems_count--)
+ MPI_Free_mem(my_elems[my_elems_count - 1]);
MPI_Finalize();
return 0;
diff --git a/test/mpi/rma/linked_list_bench_lock_all.c b/test/mpi/rma/linked_list_bench_lock_all.c
index ef67050..cf84edf 100644
--- a/test/mpi/rma/linked_list_bench_lock_all.c
+++ b/test/mpi/rma/linked_list_bench_lock_all.c
@@ -33,7 +33,7 @@
/* Linked list pointer */
typedef struct {
- int rank;
+ int rank;
MPI_Aint disp;
} llist_ptr_t;
@@ -44,29 +44,31 @@ typedef struct {
} llist_elem_t;
static const llist_ptr_t nil = { -1, (MPI_Aint) MPI_BOTTOM };
+
static const int verbose = 0;
static const int print_perf = 0;
/* List of locally allocated list elements. */
static llist_elem_t **my_elems = NULL;
-static int my_elems_size = 0;
+static int my_elems_size = 0;
static int my_elems_count = 0;
/* Allocate a new shared linked list element */
-MPI_Aint alloc_elem(int value, MPI_Win win) {
+MPI_Aint alloc_elem(int value, MPI_Win win)
+{
MPI_Aint disp;
llist_elem_t *elem_ptr;
/* Allocate the new element and register it with the window */
MPI_Alloc_mem(sizeof(llist_elem_t), MPI_INFO_NULL, &elem_ptr);
elem_ptr->value = value;
- elem_ptr->next = nil;
+ elem_ptr->next = nil;
MPI_Win_attach(win, elem_ptr, sizeof(llist_elem_t));
/* Add the element to the list of local elements so we can free it later. */
if (my_elems_size == my_elems_count) {
my_elems_size += 100;
- my_elems = realloc(my_elems, my_elems_size*sizeof(void*));
+ my_elems = realloc(my_elems, my_elems_size * sizeof(void *));
}
my_elems[my_elems_count] = elem_ptr;
my_elems_count++;
@@ -75,12 +77,13 @@ MPI_Aint alloc_elem(int value, MPI_Win win) {
return disp;
}
-int main(int argc, char **argv) {
- int procid, nproc, i, j, my_nelem;
- int pollint = 0;
- double time;
- MPI_Win llist_win;
- llist_ptr_t head_ptr, tail_ptr;
+int main(int argc, char **argv)
+{
+ int procid, nproc, i, j, my_nelem;
+ int pollint = 0;
+ double time;
+ MPI_Win llist_win;
+ llist_ptr_t head_ptr, tail_ptr;
MPI_Init(&argc, &argv);
@@ -105,7 +108,7 @@ int main(int argc, char **argv) {
else
i = 0;
- my_nelem = NUM_ELEMS/nproc;
+ my_nelem = NUM_ELEMS / nproc;
if (procid < NUM_ELEMS % nproc)
my_nelem++;
@@ -115,7 +118,7 @@ int main(int argc, char **argv) {
/* Lock the window for shared access to all targets */
MPI_Win_lock_all(0, llist_win);
- for ( ; i < my_nelem; i++) {
+ for (; i < my_nelem; i++) {
llist_ptr_t new_elem_ptr;
int success = 0;
@@ -124,22 +127,22 @@ int main(int argc, char **argv) {
new_elem_ptr.disp = alloc_elem(procid, llist_win);
/* Append the new node to the list. This might take multiple attempts if
- others have already appended and our tail pointer is stale. */
+ * others have already appended and our tail pointer is stale. */
do {
int flag;
/* The tail is at my left neighbor, append my element. */
- if (tail_ptr.rank == (procid + nproc-1) % nproc)
- {
+ if (tail_ptr.rank == (procid + nproc - 1) % nproc) {
if (verbose)
- printf("%d: Appending to <%d, %p>\n", procid, tail_ptr.rank, (void*) tail_ptr.disp);
+ printf("%d: Appending to <%d, %p>\n", procid, tail_ptr.rank,
+ (void *) tail_ptr.disp);
#if 1
MPI_Accumulate(&new_elem_ptr, sizeof(llist_ptr_t), MPI_BYTE, tail_ptr.rank,
- (MPI_Aint) &(((llist_elem_t*)tail_ptr.disp)->next), sizeof(llist_ptr_t),
- MPI_BYTE, MPI_REPLACE, llist_win);
+ (MPI_Aint) & (((llist_elem_t *) tail_ptr.disp)->next),
+ sizeof(llist_ptr_t), MPI_BYTE, MPI_REPLACE, llist_win);
#else
MPI_Put(&new_elem_ptr, sizeof(llist_ptr_t), MPI_BYTE, tail_ptr.rank,
- (MPI_Aint) &(((llist_elem_t*)tail_ptr.disp)->next), sizeof(llist_ptr_t),
+ (MPI_Aint) & (((llist_elem_t *) tail_ptr.disp)->next), sizeof(llist_ptr_t),
MPI_BYTE, llist_win);
#endif
MPI_Win_flush(tail_ptr.rank, llist_win);
@@ -149,28 +152,29 @@ int main(int argc, char **argv) {
}
/* Otherwise, chase the tail. */
- else
- {
+ else {
llist_ptr_t next_tail_ptr;
- MPI_Get_accumulate( NULL, 0, MPI_DATATYPE_NULL, &next_tail_ptr,
- sizeof(llist_ptr_t), MPI_BYTE, tail_ptr.rank,
- (MPI_Aint) &(((llist_elem_t*)tail_ptr.disp)->next),
- sizeof(llist_ptr_t), MPI_BYTE, MPI_NO_OP, llist_win);
+ MPI_Get_accumulate(NULL, 0, MPI_DATATYPE_NULL, &next_tail_ptr,
+ sizeof(llist_ptr_t), MPI_BYTE, tail_ptr.rank,
+ (MPI_Aint) & (((llist_elem_t *) tail_ptr.disp)->next),
+ sizeof(llist_ptr_t), MPI_BYTE, MPI_NO_OP, llist_win);
MPI_Win_flush(tail_ptr.rank, llist_win);
if (next_tail_ptr.rank != nil.rank) {
if (verbose)
- printf("%d: Chasing to <%d, %p>\n", procid, next_tail_ptr.rank, (void*) next_tail_ptr.disp);
+ printf("%d: Chasing to <%d, %p>\n", procid, next_tail_ptr.rank,
+ (void *) next_tail_ptr.disp);
tail_ptr = next_tail_ptr;
- pollint = MAX(MIN_NPROBE, pollint/2);
+ pollint = MAX(MIN_NPROBE, pollint / 2);
}
else {
for (j = 0; j < pollint; j++)
- MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag, MPI_STATUS_IGNORE);
+ MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag,
+ MPI_STATUS_IGNORE);
- pollint = MIN(MAX_NPROBE, pollint*2);
+ pollint = MIN(MAX_NPROBE, pollint * 2);
}
}
} while (!success);
@@ -181,12 +185,12 @@ int main(int argc, char **argv) {
time = MPI_Wtime() - time;
/* Traverse the list and verify that all processes inserted exactly the correct
- number of elements. */
+ * number of elements. */
if (procid == 0) {
- int errors = 0;
+ int errors = 0;
int *counts, count = 0;
- counts = (int*) malloc(sizeof(int) * nproc);
+ counts = (int *) malloc(sizeof(int) * nproc);
assert(counts != NULL);
for (i = 0; i < nproc; i++)
@@ -222,18 +226,19 @@ int main(int argc, char **argv) {
MPI_Win_unlock_all(llist_win);
if (verbose)
- printf("\n\n");
+ printf("\n\n");
/* Verify the counts we collected */
for (i = 0; i < nproc; i++) {
int expected;
- expected = NUM_ELEMS/nproc;
+ expected = NUM_ELEMS / nproc;
if (i < NUM_ELEMS % nproc)
expected++;
if (counts[i] != expected) {
- printf("Error: Rank %d inserted %d elements, expected %d\n", i, counts[i], expected);
+ printf("Error: Rank %d inserted %d elements, expected %d\n", i, counts[i],
+ expected);
errors++;
}
}
@@ -248,15 +253,16 @@ int main(int argc, char **argv) {
MPI_Reduce(&time, &max_time, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);
if (procid == 0) {
- printf("Total time = %0.2f sec, elem/sec = %0.2f, sec/elem = %0.2f usec\n", max_time, NUM_ELEMS/max_time, max_time/NUM_ELEMS*1.0e6);
+ printf("Total time = %0.2f sec, elem/sec = %0.2f, sec/elem = %0.2f usec\n", max_time,
+ NUM_ELEMS / max_time, max_time / NUM_ELEMS * 1.0e6);
}
}
MPI_Win_free(&llist_win);
/* Free all the elements in the list */
- for ( ; my_elems_count > 0; my_elems_count--)
- MPI_Free_mem(my_elems[my_elems_count-1]);
+ for (; my_elems_count > 0; my_elems_count--)
+ MPI_Free_mem(my_elems[my_elems_count - 1]);
MPI_Finalize();
return 0;
diff --git a/test/mpi/rma/linked_list_bench_lock_excl.c b/test/mpi/rma/linked_list_bench_lock_excl.c
index 8bf5427..d2bd702 100644
--- a/test/mpi/rma/linked_list_bench_lock_excl.c
+++ b/test/mpi/rma/linked_list_bench_lock_excl.c
@@ -33,7 +33,7 @@
/* Linked list pointer */
typedef struct {
- int rank;
+ int rank;
MPI_Aint disp;
} llist_ptr_t;
@@ -44,29 +44,31 @@ typedef struct {
} llist_elem_t;
static const llist_ptr_t nil = { -1, (MPI_Aint) MPI_BOTTOM };
+
static const int verbose = 0;
static const int print_perf = 0;
/* List of locally allocated list elements. */
static llist_elem_t **my_elems = NULL;
-static int my_elems_size = 0;
+static int my_elems_size = 0;
static int my_elems_count = 0;
/* Allocate a new shared linked list element */
-MPI_Aint alloc_elem(int value, MPI_Win win) {
+MPI_Aint alloc_elem(int value, MPI_Win win)
+{
MPI_Aint disp;
llist_elem_t *elem_ptr;
/* Allocate the new element and register it with the window */
MPI_Alloc_mem(sizeof(llist_elem_t), MPI_INFO_NULL, &elem_ptr);
elem_ptr->value = value;
- elem_ptr->next = nil;
+ elem_ptr->next = nil;
MPI_Win_attach(win, elem_ptr, sizeof(llist_elem_t));
/* Add the element to the list of local elements so we can free it later. */
if (my_elems_size == my_elems_count) {
my_elems_size += 100;
- my_elems = realloc(my_elems, my_elems_size*sizeof(void*));
+ my_elems = realloc(my_elems, my_elems_size * sizeof(void *));
}
my_elems[my_elems_count] = elem_ptr;
my_elems_count++;
@@ -75,12 +77,13 @@ MPI_Aint alloc_elem(int value, MPI_Win win) {
return disp;
}
-int main(int argc, char **argv) {
- int procid, nproc, i, j, my_nelem;
- int pollint = 0;
- double time;
- MPI_Win llist_win;
- llist_ptr_t head_ptr, tail_ptr;
+int main(int argc, char **argv)
+{
+ int procid, nproc, i, j, my_nelem;
+ int pollint = 0;
+ double time;
+ MPI_Win llist_win;
+ llist_ptr_t head_ptr, tail_ptr;
MPI_Init(&argc, &argv);
@@ -104,14 +107,14 @@ int main(int argc, char **argv) {
i = 1;
else
i = 0;
- my_nelem = NUM_ELEMS/nproc;
+ my_nelem = NUM_ELEMS / nproc;
if (procid < NUM_ELEMS % nproc)
my_nelem++;
MPI_Barrier(MPI_COMM_WORLD);
time = MPI_Wtime();
- for ( ; i < my_nelem; i++) {
+ for (; i < my_nelem; i++) {
llist_ptr_t new_elem_ptr;
int success = 0;
@@ -120,24 +123,24 @@ int main(int argc, char **argv) {
new_elem_ptr.disp = alloc_elem(procid, llist_win);
/* Append the new node to the list. This might take multiple attempts if
- others have already appended and our tail pointer is stale. */
+ * others have already appended and our tail pointer is stale. */
do {
int flag;
/* The tail is at my left neighbor, append my element. */
- if (tail_ptr.rank == (procid + nproc-1) % nproc)
- {
+ if (tail_ptr.rank == (procid + nproc - 1) % nproc) {
if (verbose)
- printf("%d: Appending to <%d, %p>\n", procid, tail_ptr.rank, (void*) tail_ptr.disp);
+ printf("%d: Appending to <%d, %p>\n", procid, tail_ptr.rank,
+ (void *) tail_ptr.disp);
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, tail_ptr.rank, 0, llist_win);
#if USE_ACC
MPI_Accumulate(&new_elem_ptr, sizeof(llist_ptr_t), MPI_BYTE, tail_ptr.rank,
- (MPI_Aint) &(((llist_elem_t*)tail_ptr.disp)->next), sizeof(llist_ptr_t),
- MPI_BYTE, MPI_REPLACE, llist_win);
+ (MPI_Aint) & (((llist_elem_t *) tail_ptr.disp)->next),
+ sizeof(llist_ptr_t), MPI_BYTE, MPI_REPLACE, llist_win);
#else
MPI_Put(&new_elem_ptr, sizeof(llist_ptr_t), MPI_BYTE, tail_ptr.rank,
- (MPI_Aint) &(((llist_elem_t*)tail_ptr.disp)->next), sizeof(llist_ptr_t),
+ (MPI_Aint) & (((llist_elem_t *) tail_ptr.disp)->next), sizeof(llist_ptr_t),
MPI_BYTE, llist_win);
#endif
MPI_Win_unlock(tail_ptr.rank, llist_win);
@@ -147,34 +150,35 @@ int main(int argc, char **argv) {
}
/* Otherwise, chase the tail. */
- else
- {
+ else {
llist_ptr_t next_tail_ptr;
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, tail_ptr.rank, 0, llist_win);
#if USE_ACC
- MPI_Get_accumulate( NULL, 0, MPI_DATATYPE_NULL, &next_tail_ptr,
- sizeof(llist_ptr_t), MPI_BYTE, tail_ptr.rank,
- (MPI_Aint) &(((llist_elem_t*)tail_ptr.disp)->next),
- sizeof(llist_ptr_t), MPI_BYTE, MPI_NO_OP, llist_win);
+ MPI_Get_accumulate(NULL, 0, MPI_DATATYPE_NULL, &next_tail_ptr,
+ sizeof(llist_ptr_t), MPI_BYTE, tail_ptr.rank,
+ (MPI_Aint) & (((llist_elem_t *) tail_ptr.disp)->next),
+ sizeof(llist_ptr_t), MPI_BYTE, MPI_NO_OP, llist_win);
#else
MPI_Get(&next_tail_ptr, sizeof(llist_ptr_t), MPI_BYTE, tail_ptr.rank,
- (MPI_Aint) &(((llist_elem_t*)tail_ptr.disp)->next),
+ (MPI_Aint) & (((llist_elem_t *) tail_ptr.disp)->next),
sizeof(llist_ptr_t), MPI_BYTE, llist_win);
#endif
MPI_Win_unlock(tail_ptr.rank, llist_win);
if (next_tail_ptr.rank != nil.rank) {
if (verbose)
- printf("%d: Chasing to <%d, %p>\n", procid, next_tail_ptr.rank, (void*) next_tail_ptr.disp);
+ printf("%d: Chasing to <%d, %p>\n", procid, next_tail_ptr.rank,
+ (void *) next_tail_ptr.disp);
tail_ptr = next_tail_ptr;
- pollint = MAX(MIN_NPROBE, pollint/2);
+ pollint = MAX(MIN_NPROBE, pollint / 2);
}
else {
for (j = 0; j < pollint; j++)
- MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag, MPI_STATUS_IGNORE);
+ MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag,
+ MPI_STATUS_IGNORE);
- pollint = MIN(MAX_NPROBE, pollint*2);
+ pollint = MIN(MAX_NPROBE, pollint * 2);
}
}
} while (!success);
@@ -184,12 +188,12 @@ int main(int argc, char **argv) {
time = MPI_Wtime() - time;
/* Traverse the list and verify that all processes inserted exactly the correct
- number of elements. */
+ * number of elements. */
if (procid == 0) {
- int errors = 0;
+ int errors = 0;
int *counts, count = 0;
- counts = (int*) malloc(sizeof(int) * nproc);
+ counts = (int *) malloc(sizeof(int) * nproc);
assert(counts != NULL);
for (i = 0; i < nproc; i++)
@@ -225,18 +229,19 @@ int main(int argc, char **argv) {
MPI_Win_unlock_all(llist_win);
if (verbose)
- printf("\n\n");
+ printf("\n\n");
/* Verify the counts we collected */
for (i = 0; i < nproc; i++) {
int expected;
- expected = NUM_ELEMS/nproc;
+ expected = NUM_ELEMS / nproc;
if (i < NUM_ELEMS % nproc)
expected++;
if (counts[i] != expected) {
- printf("Error: Rank %d inserted %d elements, expected %d\n", i, counts[i], expected);
+ printf("Error: Rank %d inserted %d elements, expected %d\n", i, counts[i],
+ expected);
errors++;
}
}
@@ -251,15 +256,16 @@ int main(int argc, char **argv) {
MPI_Reduce(&time, &max_time, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);
if (procid == 0) {
- printf("Total time = %0.2f sec, elem/sec = %0.2f, sec/elem = %0.2f usec\n", max_time, NUM_ELEMS/max_time, max_time/NUM_ELEMS*1.0e6);
+ printf("Total time = %0.2f sec, elem/sec = %0.2f, sec/elem = %0.2f usec\n", max_time,
+ NUM_ELEMS / max_time, max_time / NUM_ELEMS * 1.0e6);
}
}
MPI_Win_free(&llist_win);
/* Free all the elements in the list */
- for ( ; my_elems_count > 0; my_elems_count--)
- MPI_Free_mem(my_elems[my_elems_count-1]);
+ for (; my_elems_count > 0; my_elems_count--)
+ MPI_Free_mem(my_elems[my_elems_count - 1]);
MPI_Finalize();
return 0;
diff --git a/test/mpi/rma/linked_list_bench_lock_shr.c b/test/mpi/rma/linked_list_bench_lock_shr.c
index 62315ed..6973a22 100644
--- a/test/mpi/rma/linked_list_bench_lock_shr.c
+++ b/test/mpi/rma/linked_list_bench_lock_shr.c
@@ -33,7 +33,7 @@
/* Linked list pointer */
typedef struct {
- int rank;
+ int rank;
MPI_Aint disp;
} llist_ptr_t;
@@ -44,29 +44,31 @@ typedef struct {
} llist_elem_t;
static const llist_ptr_t nil = { -1, (MPI_Aint) MPI_BOTTOM };
+
static const int verbose = 0;
static const int print_perf = 0;
/* List of locally allocated list elements. */
static llist_elem_t **my_elems = NULL;
-static int my_elems_size = 0;
+static int my_elems_size = 0;
static int my_elems_count = 0;
/* Allocate a new shared linked list element */
-MPI_Aint alloc_elem(int value, MPI_Win win) {
+MPI_Aint alloc_elem(int value, MPI_Win win)
+{
MPI_Aint disp;
llist_elem_t *elem_ptr;
/* Allocate the new element and register it with the window */
MPI_Alloc_mem(sizeof(llist_elem_t), MPI_INFO_NULL, &elem_ptr);
elem_ptr->value = value;
- elem_ptr->next = nil;
+ elem_ptr->next = nil;
MPI_Win_attach(win, elem_ptr, sizeof(llist_elem_t));
/* Add the element to the list of local elements so we can free it later. */
if (my_elems_size == my_elems_count) {
my_elems_size += 100;
- my_elems = realloc(my_elems, my_elems_size*sizeof(void*));
+ my_elems = realloc(my_elems, my_elems_size * sizeof(void *));
}
my_elems[my_elems_count] = elem_ptr;
my_elems_count++;
@@ -75,12 +77,13 @@ MPI_Aint alloc_elem(int value, MPI_Win win) {
return disp;
}
-int main(int argc, char **argv) {
- int procid, nproc, i, j, my_nelem;
- int pollint = 0;
- double time;
- MPI_Win llist_win;
- llist_ptr_t head_ptr, tail_ptr;
+int main(int argc, char **argv)
+{
+ int procid, nproc, i, j, my_nelem;
+ int pollint = 0;
+ double time;
+ MPI_Win llist_win;
+ llist_ptr_t head_ptr, tail_ptr;
MPI_Init(&argc, &argv);
@@ -105,14 +108,14 @@ int main(int argc, char **argv) {
else
i = 0;
- my_nelem = NUM_ELEMS/nproc;
+ my_nelem = NUM_ELEMS / nproc;
if (procid < NUM_ELEMS % nproc)
my_nelem++;
MPI_Barrier(MPI_COMM_WORLD);
time = MPI_Wtime();
- for ( ; i < my_nelem; i++) {
+ for (; i < my_nelem; i++) {
llist_ptr_t new_elem_ptr;
int success = 0;
@@ -121,15 +124,15 @@ int main(int argc, char **argv) {
new_elem_ptr.disp = alloc_elem(procid, llist_win);
/* Append the new node to the list. This might take multiple attempts if
- others have already appended and our tail pointer is stale. */
+ * others have already appended and our tail pointer is stale. */
do {
int flag;
/* The tail is at my left neighbor, append my element. */
- if (tail_ptr.rank == (procid + nproc-1) % nproc)
- {
+ if (tail_ptr.rank == (procid + nproc - 1) % nproc) {
if (verbose)
- printf("%d: Appending to <%d, %p>\n", procid, tail_ptr.rank, (void*) tail_ptr.disp);
+ printf("%d: Appending to <%d, %p>\n", procid, tail_ptr.rank,
+ (void *) tail_ptr.disp);
#ifdef USE_MODE_NOCHECK
MPI_Win_lock(MPI_LOCK_SHARED, tail_ptr.rank, MPI_MODE_NOCHECK, llist_win);
@@ -137,8 +140,8 @@ int main(int argc, char **argv) {
MPI_Win_lock(MPI_LOCK_SHARED, tail_ptr.rank, 0, llist_win);
#endif
MPI_Accumulate(&new_elem_ptr, sizeof(llist_ptr_t), MPI_BYTE, tail_ptr.rank,
- (MPI_Aint) &(((llist_elem_t*)tail_ptr.disp)->next), sizeof(llist_ptr_t),
- MPI_BYTE, MPI_REPLACE, llist_win);
+ (MPI_Aint) & (((llist_elem_t *) tail_ptr.disp)->next),
+ sizeof(llist_ptr_t), MPI_BYTE, MPI_REPLACE, llist_win);
MPI_Win_unlock(tail_ptr.rank, llist_win);
success = 1;
@@ -146,8 +149,7 @@ int main(int argc, char **argv) {
}
/* Otherwise, chase the tail. */
- else
- {
+ else {
llist_ptr_t next_tail_ptr;
#ifdef USE_MODE_NOCHECK
@@ -155,23 +157,25 @@ int main(int argc, char **argv) {
#else
MPI_Win_lock(MPI_LOCK_SHARED, tail_ptr.rank, 0, llist_win);
#endif
- MPI_Get_accumulate( NULL, 0, MPI_DATATYPE_NULL, &next_tail_ptr,
- sizeof(llist_ptr_t), MPI_BYTE, tail_ptr.rank,
- (MPI_Aint) &(((llist_elem_t*)tail_ptr.disp)->next),
- sizeof(llist_ptr_t), MPI_BYTE, MPI_NO_OP, llist_win);
+ MPI_Get_accumulate(NULL, 0, MPI_DATATYPE_NULL, &next_tail_ptr,
+ sizeof(llist_ptr_t), MPI_BYTE, tail_ptr.rank,
+ (MPI_Aint) & (((llist_elem_t *) tail_ptr.disp)->next),
+ sizeof(llist_ptr_t), MPI_BYTE, MPI_NO_OP, llist_win);
MPI_Win_unlock(tail_ptr.rank, llist_win);
if (next_tail_ptr.rank != nil.rank) {
if (verbose)
- printf("%d: Chasing to <%d, %p>\n", procid, next_tail_ptr.rank, (void*) next_tail_ptr.disp);
+ printf("%d: Chasing to <%d, %p>\n", procid, next_tail_ptr.rank,
+ (void *) next_tail_ptr.disp);
tail_ptr = next_tail_ptr;
- pollint = MAX(MIN_NPROBE, pollint/2);
+ pollint = MAX(MIN_NPROBE, pollint / 2);
}
else {
for (j = 0; j < pollint; j++)
- MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag, MPI_STATUS_IGNORE);
+ MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag,
+ MPI_STATUS_IGNORE);
- pollint = MIN(MAX_NPROBE, pollint*2);
+ pollint = MIN(MAX_NPROBE, pollint * 2);
}
}
} while (!success);
@@ -181,12 +185,12 @@ int main(int argc, char **argv) {
time = MPI_Wtime() - time;
/* Traverse the list and verify that all processes inserted exactly the correct
- number of elements. */
+ * number of elements. */
if (procid == 0) {
- int errors = 0;
+ int errors = 0;
int *counts, count = 0;
- counts = (int*) malloc(sizeof(int) * nproc);
+ counts = (int *) malloc(sizeof(int) * nproc);
assert(counts != NULL);
for (i = 0; i < nproc; i++)
@@ -222,18 +226,19 @@ int main(int argc, char **argv) {
MPI_Win_unlock_all(llist_win);
if (verbose)
- printf("\n\n");
+ printf("\n\n");
/* Verify the counts we collected */
for (i = 0; i < nproc; i++) {
int expected;
- expected = NUM_ELEMS/nproc;
+ expected = NUM_ELEMS / nproc;
if (i < NUM_ELEMS % nproc)
expected++;
if (counts[i] != expected) {
- printf("Error: Rank %d inserted %d elements, expected %d\n", i, counts[i], expected);
+ printf("Error: Rank %d inserted %d elements, expected %d\n", i, counts[i],
+ expected);
errors++;
}
}
@@ -248,15 +253,16 @@ int main(int argc, char **argv) {
MPI_Reduce(&time, &max_time, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);
if (procid == 0) {
- printf("Total time = %0.2f sec, elem/sec = %0.2f, sec/elem = %0.2f usec\n", max_time, NUM_ELEMS/max_time, max_time/NUM_ELEMS*1.0e6);
+ printf("Total time = %0.2f sec, elem/sec = %0.2f, sec/elem = %0.2f usec\n", max_time,
+ NUM_ELEMS / max_time, max_time / NUM_ELEMS * 1.0e6);
}
}
MPI_Win_free(&llist_win);
/* Free all the elements in the list */
- for ( ; my_elems_count > 0; my_elems_count--)
- MPI_Free_mem(my_elems[my_elems_count-1]);
+ for (; my_elems_count > 0; my_elems_count--)
+ MPI_Free_mem(my_elems[my_elems_count - 1]);
MPI_Finalize();
return 0;
diff --git a/test/mpi/rma/linked_list_fop.c b/test/mpi/rma/linked_list_fop.c
index 7df6e35..61b7618 100644
--- a/test/mpi/rma/linked_list_fop.c
+++ b/test/mpi/rma/linked_list_fop.c
@@ -7,7 +7,7 @@
/* MPI-3 distributed linked list construction example
* --------------------------------------------------
- *
+ *
* Construct a distributed shared linked list using proposed MPI-3 dynamic
* windows. Initially process 0 creates the head of the list, attaches it to
* the window, and broadcasts the pointer to all processes. All processes then
@@ -33,7 +33,7 @@
/* Linked list pointer */
typedef struct {
- int rank;
+ int rank;
MPI_Aint disp;
} llist_ptr_t;
@@ -44,28 +44,30 @@ typedef struct {
} llist_elem_t;
static const llist_ptr_t nil = { -1, (MPI_Aint) MPI_BOTTOM };
+
static const int verbose = 0;
/* List of locally allocated list elements. */
static llist_elem_t **my_elems = NULL;
-static int my_elems_size = 0;
+static int my_elems_size = 0;
static int my_elems_count = 0;
/* Allocate a new shared linked list element */
-MPI_Aint alloc_elem(int value, MPI_Win win) {
+MPI_Aint alloc_elem(int value, MPI_Win win)
+{
MPI_Aint disp;
llist_elem_t *elem_ptr;
/* Allocate the new element and register it with the window */
MPI_Alloc_mem(sizeof(llist_elem_t), MPI_INFO_NULL, &elem_ptr);
elem_ptr->value = value;
- elem_ptr->next = nil;
+ elem_ptr->next = nil;
MPI_Win_attach(win, elem_ptr, sizeof(llist_elem_t));
/* Add the element to the list of local elements so we can free it later. */
if (my_elems_size == my_elems_count) {
my_elems_size += 100;
- my_elems = realloc(my_elems, my_elems_size*sizeof(void*));
+ my_elems = realloc(my_elems, my_elems_size * sizeof(void *));
}
my_elems[my_elems_count] = elem_ptr;
my_elems_count++;
@@ -74,10 +76,11 @@ MPI_Aint alloc_elem(int value, MPI_Win win) {
return disp;
}
-int main(int argc, char **argv) {
- int procid, nproc, i;
- MPI_Win llist_win;
- llist_ptr_t head_ptr, tail_ptr;
+int main(int argc, char **argv)
+{
+ int procid, nproc, i;
+ MPI_Win llist_win;
+ llist_ptr_t head_ptr, tail_ptr;
MPI_Init(&argc, &argv);
@@ -105,15 +108,16 @@ int main(int argc, char **argv) {
new_elem_ptr.disp = alloc_elem(procid, llist_win);
/* Append the new node to the list. This might take multiple attempts if
- others have already appended and our tail pointer is stale. */
+ * others have already appended and our tail pointer is stale. */
do {
llist_ptr_t next_tail_ptr = nil;
MPI_Win_lock(MPI_LOCK_SHARED, tail_ptr.rank, MPI_MODE_NOCHECK, llist_win);
- MPI_Compare_and_swap((void*) &new_elem_ptr.rank, (void*) &nil.rank,
- (void*) &next_tail_ptr.rank, MPI_INT, tail_ptr.rank,
- (MPI_Aint) &(((llist_elem_t*)tail_ptr.disp)->next.rank), llist_win);
+ MPI_Compare_and_swap((void *) &new_elem_ptr.rank, (void *) &nil.rank,
+ (void *) &next_tail_ptr.rank, MPI_INT, tail_ptr.rank,
+ (MPI_Aint) & (((llist_elem_t *) tail_ptr.disp)->next.rank),
+ llist_win);
MPI_Win_unlock(tail_ptr.rank, llist_win);
success = (next_tail_ptr.rank == nil.rank);
@@ -125,34 +129,36 @@ int main(int argc, char **argv) {
MPI_Win_lock(MPI_LOCK_SHARED, tail_ptr.rank, MPI_MODE_NOCHECK, llist_win);
MPI_Fetch_and_op(&new_elem_ptr.disp, &result, MPI_AINT, tail_ptr.rank,
- (MPI_Aint) &(((llist_elem_t*)tail_ptr.disp)->next.disp),
- MPI_REPLACE, llist_win);
+ (MPI_Aint) & (((llist_elem_t *) tail_ptr.disp)->next.disp),
+ MPI_REPLACE, llist_win);
/* Note: accumulate is faster, since we don't need the result. Replacing with
- Fetch_and_op to create a more complete test case. */
+ * Fetch_and_op to create a more complete test case. */
/*
- MPI_Accumulate(&new_elem_ptr.disp, 1, MPI_AINT, tail_ptr.rank,
- (MPI_Aint) &(((llist_elem_t*)tail_ptr.disp)->next.disp), 1,
- MPI_AINT, MPI_REPLACE, llist_win);
- */
+ * MPI_Accumulate(&new_elem_ptr.disp, 1, MPI_AINT, tail_ptr.rank,
+ * (MPI_Aint) &(((llist_elem_t*)tail_ptr.disp)->next.disp), 1,
+ * MPI_AINT, MPI_REPLACE, llist_win);
+ */
MPI_Win_unlock(tail_ptr.rank, llist_win);
tail_ptr = new_elem_ptr;
/* For implementations that use pt-to-pt messaging, force progress for other threads'
- RMA operations. */
+ * RMA operations. */
for (i = 0; i < NPROBE; i++)
- MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag, MPI_STATUS_IGNORE);
+ MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag,
+ MPI_STATUS_IGNORE);
- } else {
+ }
+ else {
/* Tail pointer is stale, fetch the displacement. May take multiple tries
- if it is being updated. */
+ * if it is being updated. */
do {
MPI_Win_lock(MPI_LOCK_SHARED, tail_ptr.rank, MPI_MODE_NOCHECK, llist_win);
MPI_Fetch_and_op(NULL, &next_tail_ptr.disp, MPI_AINT, tail_ptr.rank,
- (MPI_Aint) &(((llist_elem_t*)tail_ptr.disp)->next.disp),
- MPI_NO_OP, llist_win);
+ (MPI_Aint) & (((llist_elem_t *) tail_ptr.disp)->next.disp),
+ MPI_NO_OP, llist_win);
MPI_Win_unlock(tail_ptr.rank, llist_win);
} while (next_tail_ptr.disp == nil.disp);
@@ -164,13 +170,13 @@ int main(int argc, char **argv) {
MPI_Barrier(MPI_COMM_WORLD);
/* Traverse the list and verify that all processes inserted exactly the correct
- number of elements. */
+ * number of elements. */
if (procid == 0) {
- int have_root = 0;
- int errors = 0;
+ int have_root = 0;
+ int errors = 0;
int *counts, count = 0;
- counts = (int*) malloc(sizeof(int) * nproc);
+ counts = (int *) malloc(sizeof(int) * nproc);
assert(counts != NULL);
for (i = 0; i < nproc; i++)
@@ -213,14 +219,15 @@ int main(int argc, char **argv) {
}
if (verbose)
- printf("\n\n");
+ printf("\n\n");
/* Verify the counts we collected */
for (i = 0; i < nproc; i++) {
int expected = NUM_ELEMS;
if (counts[i] != expected) {
- printf("Error: Rank %d inserted %d elements, expected %d\n", i, counts[i], expected);
+ printf("Error: Rank %d inserted %d elements, expected %d\n", i, counts[i],
+ expected);
errors++;
}
}
@@ -232,8 +239,8 @@ int main(int argc, char **argv) {
MPI_Win_free(&llist_win);
/* Free all the elements in the list */
- for ( ; my_elems_count > 0; my_elems_count--)
- MPI_Free_mem(my_elems[my_elems_count-1]);
+ for (; my_elems_count > 0; my_elems_count--)
+ MPI_Free_mem(my_elems[my_elems_count - 1]);
MPI_Finalize();
return 0;
diff --git a/test/mpi/rma/linked_list_lockall.c b/test/mpi/rma/linked_list_lockall.c
index f1373fb..699623c 100644
--- a/test/mpi/rma/linked_list_lockall.c
+++ b/test/mpi/rma/linked_list_lockall.c
@@ -33,7 +33,7 @@
/* Linked list pointer */
typedef struct {
- int rank;
+ int rank;
MPI_Aint disp;
} llist_ptr_t;
@@ -44,28 +44,30 @@ typedef struct {
} llist_elem_t;
static const llist_ptr_t nil = { -1, (MPI_Aint) MPI_BOTTOM };
+
static const int verbose = 0;
/* List of locally allocated list elements. */
static llist_elem_t **my_elems = NULL;
-static int my_elems_size = 0;
+static int my_elems_size = 0;
static int my_elems_count = 0;
/* Allocate a new shared linked list element */
-MPI_Aint alloc_elem(int value, MPI_Win win) {
+MPI_Aint alloc_elem(int value, MPI_Win win)
+{
MPI_Aint disp;
llist_elem_t *elem_ptr;
/* Allocate the new element and register it with the window */
MPI_Alloc_mem(sizeof(llist_elem_t), MPI_INFO_NULL, &elem_ptr);
elem_ptr->value = value;
- elem_ptr->next = nil;
+ elem_ptr->next = nil;
MPI_Win_attach(win, elem_ptr, sizeof(llist_elem_t));
/* Add the element to the list of local elements so we can free it later. */
if (my_elems_size == my_elems_count) {
my_elems_size += 100;
- my_elems = realloc(my_elems, my_elems_size*sizeof(void*));
+ my_elems = realloc(my_elems, my_elems_size * sizeof(void *));
}
my_elems[my_elems_count] = elem_ptr;
my_elems_count++;
@@ -74,10 +76,11 @@ MPI_Aint alloc_elem(int value, MPI_Win win) {
return disp;
}
-int main(int argc, char **argv) {
- int procid, nproc, i;
- MPI_Win llist_win;
- llist_ptr_t head_ptr, tail_ptr;
+int main(int argc, char **argv)
+{
+ int procid, nproc, i;
+ MPI_Win llist_win;
+ llist_ptr_t head_ptr, tail_ptr;
MPI_Init(&argc, &argv);
@@ -108,13 +111,14 @@ int main(int argc, char **argv) {
new_elem_ptr.disp = alloc_elem(procid, llist_win);
/* Append the new node to the list. This might take multiple attempts if
- others have already appended and our tail pointer is stale. */
+ * others have already appended and our tail pointer is stale. */
do {
llist_ptr_t next_tail_ptr = nil;
- MPI_Compare_and_swap((void*) &new_elem_ptr.rank, (void*) &nil.rank,
- (void*) &next_tail_ptr.rank, MPI_INT, tail_ptr.rank,
- (MPI_Aint) &(((llist_elem_t*)tail_ptr.disp)->next.rank), llist_win);
+ MPI_Compare_and_swap((void *) &new_elem_ptr.rank, (void *) &nil.rank,
+ (void *) &next_tail_ptr.rank, MPI_INT, tail_ptr.rank,
+ (MPI_Aint) & (((llist_elem_t *) tail_ptr.disp)->next.rank),
+ llist_win);
MPI_Win_flush(tail_ptr.rank, llist_win);
success = (next_tail_ptr.rank == nil.rank);
@@ -123,25 +127,27 @@ int main(int argc, char **argv) {
int i, flag;
MPI_Accumulate(&new_elem_ptr.disp, 1, MPI_AINT, tail_ptr.rank,
- (MPI_Aint) &(((llist_elem_t*)tail_ptr.disp)->next.disp), 1,
+ (MPI_Aint) & (((llist_elem_t *) tail_ptr.disp)->next.disp), 1,
MPI_AINT, MPI_REPLACE, llist_win);
MPI_Win_flush(tail_ptr.rank, llist_win);
tail_ptr = new_elem_ptr;
/* For implementations that use pt-to-pt messaging, force progress for other threads'
- RMA operations. */
+ * RMA operations. */
for (i = 0; i < NPROBE; i++)
- MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag, MPI_STATUS_IGNORE);
+ MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag,
+ MPI_STATUS_IGNORE);
- } else {
+ }
+ else {
/* Tail pointer is stale, fetch the displacement. May take multiple tries
- if it is being updated. */
+ * if it is being updated. */
do {
- MPI_Get_accumulate( NULL, 0, MPI_DATATYPE_NULL, &next_tail_ptr.disp,
- 1, MPI_AINT, tail_ptr.rank,
- (MPI_Aint) &(((llist_elem_t*)tail_ptr.disp)->next.disp),
- 1, MPI_AINT, MPI_NO_OP, llist_win);
+ MPI_Get_accumulate(NULL, 0, MPI_DATATYPE_NULL, &next_tail_ptr.disp,
+ 1, MPI_AINT, tail_ptr.rank,
+ (MPI_Aint) & (((llist_elem_t *) tail_ptr.disp)->next.disp),
+ 1, MPI_AINT, MPI_NO_OP, llist_win);
MPI_Win_flush(tail_ptr.rank, llist_win);
} while (next_tail_ptr.disp == nil.disp);
tail_ptr = next_tail_ptr;
@@ -153,13 +159,13 @@ int main(int argc, char **argv) {
MPI_Barrier(MPI_COMM_WORLD);
/* Traverse the list and verify that all processes inserted exactly the correct
- number of elements. */
+ * number of elements. */
if (procid == 0) {
- int have_root = 0;
- int errors = 0;
+ int have_root = 0;
+ int errors = 0;
int *counts, count = 0;
- counts = (int*) malloc(sizeof(int) * nproc);
+ counts = (int *) malloc(sizeof(int) * nproc);
assert(counts != NULL);
for (i = 0; i < nproc; i++)
@@ -204,14 +210,15 @@ int main(int argc, char **argv) {
MPI_Win_unlock_all(llist_win);
if (verbose)
- printf("\n\n");
+ printf("\n\n");
/* Verify the counts we collected */
for (i = 0; i < nproc; i++) {
int expected = NUM_ELEMS;
if (counts[i] != expected) {
- printf("Error: Rank %d inserted %d elements, expected %d\n", i, counts[i], expected);
+ printf("Error: Rank %d inserted %d elements, expected %d\n", i, counts[i],
+ expected);
errors++;
}
}
@@ -223,8 +230,8 @@ int main(int argc, char **argv) {
MPI_Win_free(&llist_win);
/* Free all the elements in the list */
- for ( ; my_elems_count > 0; my_elems_count--)
- MPI_Free_mem(my_elems[my_elems_count-1]);
+ for (; my_elems_count > 0; my_elems_count--)
+ MPI_Free_mem(my_elems[my_elems_count - 1]);
MPI_Finalize();
return 0;
diff --git a/test/mpi/rma/lockcontention.c b/test/mpi/rma/lockcontention.c
index 8fbce4b..8165119 100644
--- a/test/mpi/rma/lockcontention.c
+++ b/test/mpi/rma/lockcontention.c
@@ -25,9 +25,9 @@ int main(int argc, char *argv[])
int errs = 0;
int trank = 1;
- MTest_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (nprocs < 3) {
fprintf(stderr, "Run this program with 3 or more processes\n");
@@ -38,54 +38,54 @@ int main(int argc, char *argv[])
if (rank < 3) {
if (rank == 0) {
- for (i=0; i<SIZE2; i++) {
+ for (i = 0; i < SIZE2; i++) {
A[i] = B[i] = i;
}
}
else if (rank == 2) {
- for (i=0; i<SIZE2; i++) {
+ for (i = 0; i < SIZE2; i++) {
A[i] = B[i] = -1;
}
}
else if (rank == 1) {
- for (i=0; i<SIZE2; i++) {
- B[i] = (-4)*i;
+ for (i = 0; i < SIZE2; i++) {
+ B[i] = (-4) * i;
}
}
- MPI_Win_create(B, SIZE2*sizeof(int), sizeof(int), MPI_INFO_NULL, CommThree, &win);
+ MPI_Win_create(B, SIZE2 * sizeof(int), sizeof(int), MPI_INFO_NULL, CommThree, &win);
if (rank == 0) {
- for (i=0; i<SIZE1; i++) {
+ for (i = 0; i < SIZE1; i++) {
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, trank, 0, win);
- MPI_Put(A+i, 1, MPI_INT, trank, i, 1, MPI_INT, win);
+ MPI_Put(A + i, 1, MPI_INT, trank, i, 1, MPI_INT, win);
/* MPI_Put(A+i, 1, MPI_INT, trank, i, 1, MPI_INT, win);
- MPI_Put(A+i, 1, MPI_INT, trank, i, 1, MPI_INT, win); */
+ * MPI_Put(A+i, 1, MPI_INT, trank, i, 1, MPI_INT, win); */
MPI_Win_unlock(trank, win);
}
MPI_Win_free(&win);
}
else if (rank == 2) {
- for (i=0; i<SIZE1; i++) {
+ for (i = 0; i < SIZE1; i++) {
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, trank, 0, win);
- MPI_Get(A+i, 1, MPI_INT, trank, SIZE1+i, 1, MPI_INT, win);
+ MPI_Get(A + i, 1, MPI_INT, trank, SIZE1 + i, 1, MPI_INT, win);
MPI_Win_unlock(trank, win);
}
MPI_Win_free(&win);
- for (i=0; i<SIZE1; i++)
- if (A[i] != (-4)*(i+SIZE1)) {
- printf("Get Error: A[%d] is %d, should be %d\n", i, A[i], (-4)*(i+SIZE1));
+ for (i = 0; i < SIZE1; i++)
+ if (A[i] != (-4) * (i + SIZE1)) {
+ printf("Get Error: A[%d] is %d, should be %d\n", i, A[i], (-4) * (i + SIZE1));
errs++;
}
}
- else if (rank == 1) { /*target*/
+ else if (rank == 1) { /*target */
MPI_Win_free(&win);
- for (i=0; i<SIZE1; i++) {
+ for (i = 0; i < SIZE1; i++) {
if (B[i] != i) {
printf("Put Error: B[%d] is %d, should be %d\n", i, B[i], i);
errs++;
diff --git a/test/mpi/rma/lockcontention2.c b/test/mpi/rma/lockcontention2.c
index bae541f..9374980 100644
--- a/test/mpi/rma/lockcontention2.c
+++ b/test/mpi/rma/lockcontention2.c
@@ -3,13 +3,13 @@
* (C) 2010 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include "stdio.h"
#include "stdlib.h"
#include "mpitest.h"
-/*
- * Tests for lock contention, including special cases within the MPICH code
+/*
+ * Tests for lock contention, including special cases within the MPICH code
* (any MPI implementation should pass these tests; in the MPICH case, our
* coverage analysis showed that the lockcontention.c test was not covering
* all cases, and in fact, this test revealed a bug in the code).
@@ -26,279 +26,261 @@
#define NBLOCK 10
#define MAX_ERRS_REPORT 10
-/*
+/*
* Each process writes data into the rmabuf on the process with target rank
* trank. The final result in rmabuf are the consecutive integers starting
- * from 0. Each process, however, does not write a consecutive block.
+ * from 0. Each process, however, does not write a consecutive block.
* Instead, they write these locations:
*
* for i=0,...,NELM-1
* for j=0,...,NBLOCK-1
* j + NBLOCK * (rank + i * wsize)
- *
+ *
* The value written is the location.
*
* In many cases, multiple RMA operations are needed. Where these must not
* overlap, the above pattern is replicated at NBLOCK*NELM*wsize.
- * (NBLOCK is either 1 or NBLOCK in the code below, depending on use)
+ * (NBLOCK is either 1 or NBLOCK in the code below, depending on use)
*/
static int toterrs = 0;
-int testValues( int, int, int, int *, const char * );
+int testValues(int, int, int, int *, const char *);
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[])
+{
int rank, wsize, i, j, cnt;
int *rmabuf, *localbuf, *localbuf2, *vals;
MPI_Win win;
int trank = 0;
int windowsize;
- MTest_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&wsize);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &wsize);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (wsize < 2) {
fprintf(stderr, "Run this program with at least 2 processes\n");
- MPI_Abort(MPI_COMM_WORLD,1);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- windowsize = (2*NBLOCK + 2) * NELM * wsize;
- rmabuf = (int *)malloc( windowsize * sizeof(int) );
- localbuf = (int *)malloc( NELM * sizeof(int) );
- localbuf2 = (int *)malloc( NELM * NBLOCK * sizeof(int) );
- vals = (int *)malloc( NELM*sizeof(int) );
+ windowsize = (2 * NBLOCK + 2) * NELM * wsize;
+ rmabuf = (int *) malloc(windowsize * sizeof(int));
+ localbuf = (int *) malloc(NELM * sizeof(int));
+ localbuf2 = (int *) malloc(NELM * NBLOCK * sizeof(int));
+ vals = (int *) malloc(NELM * sizeof(int));
- /*
+ /*
* Initialize the buffers
*/
- for (i=0; i<NELM; i++) {
- localbuf[i] = rank + i*wsize;
+ for (i = 0; i < NELM; i++) {
+ localbuf[i] = rank + i * wsize;
}
cnt = 0;
- for (i=0; i<NELM; i++) {
- for (j=0; j<NBLOCK; j++) {
- localbuf2[cnt++] = j + NBLOCK * (rank + i*wsize);
- }
+ for (i = 0; i < NELM; i++) {
+ for (j = 0; j < NBLOCK; j++) {
+ localbuf2[cnt++] = j + NBLOCK * (rank + i * wsize);
+ }
}
- for (i=0; i<windowsize; i++) {
- rmabuf[i] = -1;
+ for (i = 0; i < windowsize; i++) {
+ rmabuf[i] = -1;
}
/* Create the window */
- MPI_Win_create(rmabuf, windowsize*sizeof(int), sizeof(int), MPI_INFO_NULL,
- MPI_COMM_WORLD, &win);
+ MPI_Win_create(rmabuf, windowsize * sizeof(int), sizeof(int), MPI_INFO_NULL,
+ MPI_COMM_WORLD, &win);
/* Multiple puts, with contention at trank */
- MPI_Barrier( MPI_COMM_WORLD );
- for (i=0; i<NELM; i++) {
- MPI_Win_lock( MPI_LOCK_EXCLUSIVE, trank, 0, win );
- MPI_Put( &localbuf[i], 1, MPI_INT, trank,
- rank + i*wsize, 1, MPI_INT, win );
- MPI_Put( &localbuf[i], 1, MPI_INT, trank,
- rank + (i+NELM)*wsize, 1, MPI_INT, win );
- MPI_Win_unlock( trank, win );
+ MPI_Barrier(MPI_COMM_WORLD);
+ for (i = 0; i < NELM; i++) {
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, trank, 0, win);
+ MPI_Put(&localbuf[i], 1, MPI_INT, trank, rank + i * wsize, 1, MPI_INT, win);
+ MPI_Put(&localbuf[i], 1, MPI_INT, trank, rank + (i + NELM) * wsize, 1, MPI_INT, win);
+ MPI_Win_unlock(trank, win);
}
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
if (rank == trank) {
- MPI_Win_lock( MPI_LOCK_EXCLUSIVE, trank, 0, win );
- toterrs += testValues( 1, NELM, wsize, rmabuf, "Multiple puts (1)" );
- toterrs += testValues( 1, NELM, wsize, rmabuf + wsize*NELM,
- "Multiple puts (2)" );
- MPI_Win_unlock( trank, win );
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, trank, 0, win);
+ toterrs += testValues(1, NELM, wsize, rmabuf, "Multiple puts (1)");
+ toterrs += testValues(1, NELM, wsize, rmabuf + wsize * NELM, "Multiple puts (2)");
+ MPI_Win_unlock(trank, win);
}
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
/* Reinit the rmabuf */
- for (i=0; i<windowsize; i++) {
- rmabuf[i] = -1;
+ for (i = 0; i < windowsize; i++) {
+ rmabuf[i] = -1;
}
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
/* Single put with contention */
trank = 0;
- for (i=0; i<NELM; i++) {
- MPI_Win_lock( MPI_LOCK_EXCLUSIVE, trank, 0, win );
- MPI_Put( &localbuf[i], 1, MPI_INT, trank, rank + i*wsize, 1, MPI_INT,
- win );
- MPI_Win_unlock( trank, win );
+ for (i = 0; i < NELM; i++) {
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, trank, 0, win);
+ MPI_Put(&localbuf[i], 1, MPI_INT, trank, rank + i * wsize, 1, MPI_INT, win);
+ MPI_Win_unlock(trank, win);
}
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
if (rank == trank) {
- MPI_Win_lock( MPI_LOCK_EXCLUSIVE, trank, 0, win );
- toterrs += testValues( 1, NELM, wsize, rmabuf, "Single put" );
- MPI_Win_unlock( trank, win );
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, trank, 0, win);
+ toterrs += testValues(1, NELM, wsize, rmabuf, "Single put");
+ MPI_Win_unlock(trank, win);
}
/* Reinit the rmabuf */
- for (i=0; i<windowsize; i++) {
- rmabuf[i] = -1;
+ for (i = 0; i < windowsize; i++) {
+ rmabuf[i] = -1;
}
/* Longer puts with contention at trank */
- MPI_Barrier( MPI_COMM_WORLD );
- for (i=0; i<NELM; i++) {
- MPI_Win_lock( MPI_LOCK_EXCLUSIVE, trank, 0, win );
- if (rank != trank) {
- MPI_Put( &localbuf2[i*NBLOCK], NBLOCK, MPI_INT, trank,
- NELM * wsize + NBLOCK*(rank+i*wsize), NBLOCK,
- MPI_INT, win );
- MPI_Put( &localbuf2[i*NBLOCK], NBLOCK, MPI_INT, trank,
- NELM * wsize + NBLOCK*(rank+(i+NELM)*wsize), NBLOCK,
- MPI_INT, win );
- }
- MPI_Put( &localbuf[i], 1, MPI_INT, trank, rank+i*wsize, 1, MPI_INT,
- win );
- MPI_Win_unlock( trank, win );
+ MPI_Barrier(MPI_COMM_WORLD);
+ for (i = 0; i < NELM; i++) {
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, trank, 0, win);
+ if (rank != trank) {
+ MPI_Put(&localbuf2[i * NBLOCK], NBLOCK, MPI_INT, trank,
+ NELM * wsize + NBLOCK * (rank + i * wsize), NBLOCK, MPI_INT, win);
+ MPI_Put(&localbuf2[i * NBLOCK], NBLOCK, MPI_INT, trank,
+ NELM * wsize + NBLOCK * (rank + (i + NELM) * wsize), NBLOCK, MPI_INT, win);
+ }
+ MPI_Put(&localbuf[i], 1, MPI_INT, trank, rank + i * wsize, 1, MPI_INT, win);
+ MPI_Win_unlock(trank, win);
}
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
if (rank == trank) {
- /* For simplicity in testing, set the values that rank==trank
- would have set. */
- for (i=0; i<NELM; i++) {
- for (j=0; j<NBLOCK; j++) {
- rmabuf[NELM*wsize + NBLOCK*(trank+i*wsize) + j] =
- j + NBLOCK*(trank +i*wsize);
- rmabuf[NELM*wsize + NBLOCK*(trank+(i+NELM)*wsize) + j] =
- j + NBLOCK*(trank + i*wsize);
- }
- }
- MPI_Win_lock( MPI_LOCK_EXCLUSIVE, trank, 0, win );
- toterrs += testValues( 1, NELM, wsize, rmabuf, "Long puts (1)" );
- toterrs += testValues( NBLOCK, NELM, wsize, rmabuf + NELM * wsize,
- "Long puts(2)" );
- toterrs += testValues( NBLOCK, NELM, wsize,
- rmabuf + NELM * wsize * (1 + NBLOCK),
- "Long puts(3)" );
- MPI_Win_unlock( trank, win );
+ /* For simplicity in testing, set the values that rank==trank
+ * would have set. */
+ for (i = 0; i < NELM; i++) {
+ for (j = 0; j < NBLOCK; j++) {
+ rmabuf[NELM * wsize + NBLOCK * (trank + i * wsize) + j] =
+ j + NBLOCK * (trank + i * wsize);
+ rmabuf[NELM * wsize + NBLOCK * (trank + (i + NELM) * wsize) + j] =
+ j + NBLOCK * (trank + i * wsize);
+ }
+ }
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, trank, 0, win);
+ toterrs += testValues(1, NELM, wsize, rmabuf, "Long puts (1)");
+ toterrs += testValues(NBLOCK, NELM, wsize, rmabuf + NELM * wsize, "Long puts(2)");
+ toterrs += testValues(NBLOCK, NELM, wsize,
+ rmabuf + NELM * wsize * (1 + NBLOCK), "Long puts(3)");
+ MPI_Win_unlock(trank, win);
}
-
+
/* Reinit the rmabuf */
- for (i=0; i<windowsize; i++) {
- rmabuf[i] = -1;
+ for (i = 0; i < windowsize; i++) {
+ rmabuf[i] = -1;
}
- for (i=0; i< NELM; i++)
- vals[i] = -2;
-
+ for (i = 0; i < NELM; i++)
+ vals[i] = -2;
+
/* Put mixed with Get */
- MPI_Barrier( MPI_COMM_WORLD );
- for (i=0; i<NELM; i++) {
- MPI_Win_lock( MPI_LOCK_EXCLUSIVE, trank, 0, win );
- if (rank != trank) {
- MPI_Put( &localbuf2[i], NBLOCK, MPI_INT, trank,
- NELM*wsize + NBLOCK*(rank + i*wsize), NBLOCK, MPI_INT,
- win );
- MPI_Put( &localbuf[i], 1, MPI_INT, trank,
- rank + i*wsize, 1, MPI_INT, win );
- }
- else {
- MPI_Get( &vals[i], 1, MPI_INT, trank, i, 1, MPI_INT, win );
- }
- MPI_Win_unlock( trank, win );
+ MPI_Barrier(MPI_COMM_WORLD);
+ for (i = 0; i < NELM; i++) {
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, trank, 0, win);
+ if (rank != trank) {
+ MPI_Put(&localbuf2[i], NBLOCK, MPI_INT, trank,
+ NELM * wsize + NBLOCK * (rank + i * wsize), NBLOCK, MPI_INT, win);
+ MPI_Put(&localbuf[i], 1, MPI_INT, trank, rank + i * wsize, 1, MPI_INT, win);
+ }
+ else {
+ MPI_Get(&vals[i], 1, MPI_INT, trank, i, 1, MPI_INT, win);
+ }
+ MPI_Win_unlock(trank, win);
}
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
if (rank == trank) {
- /* Just test the Get */
- for (i=0; i<wsize; i++) {
- if (i == trank) {
- if (vals[i] != -1) {
- toterrs++;
- if (toterrs < MAX_ERRS_REPORT) {
- printf( "put/get: vals[%d] = %d, expected -1\n",
- i, vals[i] );
- }
- }
- }
- else if (vals[i] != i && vals[i] != -1) {
- toterrs++;
- if (toterrs < MAX_ERRS_REPORT) {
- printf( "put/get: vals[%d] = %d, expected -1 or %d\n",
- i, vals[i], i );
- }
- }
- }
+ /* Just test the Get */
+ for (i = 0; i < wsize; i++) {
+ if (i == trank) {
+ if (vals[i] != -1) {
+ toterrs++;
+ if (toterrs < MAX_ERRS_REPORT) {
+ printf("put/get: vals[%d] = %d, expected -1\n", i, vals[i]);
+ }
+ }
+ }
+ else if (vals[i] != i && vals[i] != -1) {
+ toterrs++;
+ if (toterrs < MAX_ERRS_REPORT) {
+ printf("put/get: vals[%d] = %d, expected -1 or %d\n", i, vals[i], i);
+ }
+ }
+ }
}
/* Contention only with get */
- for (i=0; i<windowsize; i++) {
- rmabuf[i] = -i;
+ for (i = 0; i < windowsize; i++) {
+ rmabuf[i] = -i;
}
- for (i=0; i<NELM; i++)
- vals[i] = -2;
+ for (i = 0; i < NELM; i++)
+ vals[i] = -2;
- MPI_Barrier( MPI_COMM_WORLD );
- for (i=0; i<NELM; i++) {
- MPI_Win_lock( MPI_LOCK_EXCLUSIVE, trank, 0, win );
- MPI_Get( &vals[i], 1, MPI_INT, trank, i, 1, MPI_INT, win );
- MPI_Win_unlock( trank, win );
+ MPI_Barrier(MPI_COMM_WORLD);
+ for (i = 0; i < NELM; i++) {
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, trank, 0, win);
+ MPI_Get(&vals[i], 1, MPI_INT, trank, i, 1, MPI_INT, win);
+ MPI_Win_unlock(trank, win);
}
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
if (rank == trank) {
- for (i=0; i<NELM; i++) {
- if (vals[i] != -i) {
- toterrs++;
- if (toterrs < MAX_ERRS_REPORT) {
- printf( "single get: vals[%d] = %d, expected %d\n",
- i, vals[i], -i );
- }
- }
- }
+ for (i = 0; i < NELM; i++) {
+ if (vals[i] != -i) {
+ toterrs++;
+ if (toterrs < MAX_ERRS_REPORT) {
+ printf("single get: vals[%d] = %d, expected %d\n", i, vals[i], -i);
+ }
+ }
+ }
}
/* Contention with accumulate */
- MPI_Barrier( MPI_COMM_WORLD );
- for (i=0; i<NELM*wsize; i++) {
- rmabuf[i] = 0;
+ MPI_Barrier(MPI_COMM_WORLD);
+ for (i = 0; i < NELM * wsize; i++) {
+ rmabuf[i] = 0;
}
- MPI_Barrier( MPI_COMM_WORLD );
- for (i=0; i<NELM; i++) {
- MPI_Win_lock( MPI_LOCK_EXCLUSIVE, trank, 0, win );
- MPI_Accumulate( &localbuf[i], 1, MPI_INT, trank, rank+i*wsize,
- 1, MPI_INT, MPI_SUM, win );
- MPI_Accumulate( &localbuf[i], 1, MPI_INT, trank, rank+i*wsize,
- 1, MPI_INT, MPI_SUM, win );
- MPI_Win_unlock( trank, win );
+ MPI_Barrier(MPI_COMM_WORLD);
+ for (i = 0; i < NELM; i++) {
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, trank, 0, win);
+ MPI_Accumulate(&localbuf[i], 1, MPI_INT, trank, rank + i * wsize, 1, MPI_INT, MPI_SUM, win);
+ MPI_Accumulate(&localbuf[i], 1, MPI_INT, trank, rank + i * wsize, 1, MPI_INT, MPI_SUM, win);
+ MPI_Win_unlock(trank, win);
}
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
if (rank == trank) {
- MPI_Win_lock( MPI_LOCK_EXCLUSIVE, trank, 0, win );
- for (i=0; i<NELM * wsize; i++) {
- if (rmabuf[i] != 2*i) {
- toterrs++;
- if (toterrs < MAX_ERRS_REPORT) {
- printf( "2 accumulate: rmabuf[%d] = %d, expected %d\n",
- i, rmabuf[i], 2*i );
- }
- }
- }
- MPI_Win_unlock( trank, win );
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, trank, 0, win);
+ for (i = 0; i < NELM * wsize; i++) {
+ if (rmabuf[i] != 2 * i) {
+ toterrs++;
+ if (toterrs < MAX_ERRS_REPORT) {
+ printf("2 accumulate: rmabuf[%d] = %d, expected %d\n", i, rmabuf[i], 2 * i);
+ }
+ }
+ }
+ MPI_Win_unlock(trank, win);
}
- MPI_Win_free( &win );
+ MPI_Win_free(&win);
+
+ free(rmabuf);
+ free(localbuf);
+ free(localbuf2);
+ free(vals);
- free( rmabuf );
- free( localbuf );
- free( localbuf2 );
- free( vals );
-
MTest_Finalize(toterrs);
- MPI_Finalize();
- return 0;
-}
+ MPI_Finalize();
+ return 0;
+}
-/* Test the values in the rmabuf against the expected values. Return the
+/* Test the values in the rmabuf against the expected values. Return the
number of errors */
-int testValues( int nb, int nelm, int wsize, int *rmabuf, const char *msg )
+int testValues(int nb, int nelm, int wsize, int *rmabuf, const char *msg)
{
int i, errs = 0;
-
- for (i=0; i<nb * nelm * wsize; i++) {
- if (rmabuf[i] != i) {
- if (toterrs + errs < MAX_ERRS_REPORT) {
- printf( "%s:rmabuf[%d] = %d expected %d\n",
- msg, i, rmabuf[i], i );
- }
- errs++;
- }
+
+ for (i = 0; i < nb * nelm * wsize; i++) {
+ if (rmabuf[i] != i) {
+ if (toterrs + errs < MAX_ERRS_REPORT) {
+ printf("%s:rmabuf[%d] = %d expected %d\n", msg, i, rmabuf[i], i);
+ }
+ errs++;
+ }
}
return errs;
diff --git a/test/mpi/rma/lockcontention3.c b/test/mpi/rma/lockcontention3.c
index 015eed6..bc3fa79 100644
--- a/test/mpi/rma/lockcontention3.c
+++ b/test/mpi/rma/lockcontention3.c
@@ -3,7 +3,7 @@
* (C) 2012 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include "stdio.h"
#include "stdlib.h"
#include "mpitest.h"
@@ -19,7 +19,7 @@
#define PUT_VAL 0xdcba97
#define ACC_VAL 10771134
-/*
+/*
* Additional tests for lock contention. These are designed to exercise
* some of the optimizations within MPICH, but all are valid MPI programs.
* Tests structure includes
@@ -36,9 +36,9 @@
* lock // Note: this may block
* rma operations (see below)
* unlock
- *
+ *
* unlock send back to partner
- * receive from partner
+ * receive from partner
* check for correct data
*
* The delay may be implemented as a ring of message communication; this
@@ -46,442 +46,428 @@
*/
/* Define a datatype to be used with */
-int stride = 11;
-int veccount = 7;
-MPI_Datatype vectype;
+int stride = 11;
+int veccount = 7;
+MPI_Datatype vectype;
/* Define long RMA ops size */
int longcount = 512;
-int medcount = 127;
-int mednum = 4;
+int medcount = 127;
+int mednum = 4;
-void RMATest( int i, MPI_Win win, int master, int *srcbuf, int srcbufsize, int *getbuf, int getbufsize );
-int RMACheck( int i, int *buf, MPI_Aint bufsize );
-int RMACheckGet( int i, MPI_Win win, int *getbuf, MPI_Aint getsize);
-void RMATestInit( int i, int *buf, MPI_Aint bufsize );
+void RMATest(int i, MPI_Win win, int master, int *srcbuf, int srcbufsize, int *getbuf,
+ int getbufsize);
+int RMACheck(int i, int *buf, MPI_Aint bufsize);
+int RMACheckGet(int i, MPI_Win win, int *getbuf, MPI_Aint getsize);
+void RMATestInit(int i, int *buf, MPI_Aint bufsize);
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
- int errs = 0;
- MPI_Win win;
- int *rmabuffer=0, *getbuf=0;
- MPI_Aint bufsize=0, getbufsize=0;
- int master, partner, next, wrank, wsize, i;
- int ntest = LAST_TEST;
+ int errs = 0;
+ MPI_Win win;
+ int *rmabuffer = 0, *getbuf = 0;
+ MPI_Aint bufsize = 0, getbufsize = 0;
+ int master, partner, next, wrank, wsize, i;
+ int ntest = LAST_TEST;
int *srcbuf;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
/* Determine who is responsible for each part of the test */
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
- MPI_Comm_size( MPI_COMM_WORLD, &wsize );
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
+ MPI_Comm_size(MPI_COMM_WORLD, &wsize);
if (wsize < 3) {
- fprintf( stderr, "This test requires at least 3 processes\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "This test requires at least 3 processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- master = 0;
+ master = 0;
partner = 1;
next = wrank + 1;
- if (next == partner) next++;
+ if (next == partner)
+ next++;
if (next >= wsize) {
- next = 0;
- if (next == partner) next++;
+ next = 0;
+ if (next == partner)
+ next++;
}
/* Determine the last test to run (by default, run them all) */
- for (i=1; i<argc; i++) {
- if (strcmp( "-ntest", argv[i] ) == 0) {
- i++;
- if (i < argc) {
- ntest = atoi( argv[i] );
- }
- else {
- fprintf( stderr, "Missing value for -ntest\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- }
+ for (i = 1; i < argc; i++) {
+ if (strcmp("-ntest", argv[i]) == 0) {
+ i++;
+ if (i < argc) {
+ ntest = atoi(argv[i]);
+ }
+ else {
+ fprintf(stderr, "Missing value for -ntest\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ }
}
- MPI_Type_vector( veccount, 1, stride, MPI_INT, &vectype );
- MPI_Type_commit( &vectype );
+ MPI_Type_vector(veccount, 1, stride, MPI_INT, &vectype);
+ MPI_Type_commit(&vectype);
/* Create the RMA window */
bufsize = 0;
if (wrank == master) {
- bufsize = RMA_SIZE;
- MPI_Alloc_mem( bufsize*sizeof(int), MPI_INFO_NULL, &rmabuffer );
+ bufsize = RMA_SIZE;
+ MPI_Alloc_mem(bufsize * sizeof(int), MPI_INFO_NULL, &rmabuffer);
}
else if (wrank == partner) {
- getbufsize = RMA_SIZE;
- getbuf = (int *)malloc( getbufsize*sizeof(int) );
- if (!getbuf) {
- fprintf( stderr, "Unable to allocated %d bytes for getbuf\n",
- (int)getbufsize );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
+ getbufsize = RMA_SIZE;
+ getbuf = (int *) malloc(getbufsize * sizeof(int));
+ if (!getbuf) {
+ fprintf(stderr, "Unable to allocated %d bytes for getbuf\n", (int) getbufsize);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
}
- srcbuf = malloc(RMA_SIZE*sizeof(*srcbuf));
+ srcbuf = malloc(RMA_SIZE * sizeof(*srcbuf));
assert(srcbuf);
- MPI_Win_create( rmabuffer, bufsize * sizeof(int), sizeof(int), MPI_INFO_NULL,
- MPI_COMM_WORLD, &win );
-
+ MPI_Win_create(rmabuffer, bufsize * sizeof(int), sizeof(int), MPI_INFO_NULL,
+ MPI_COMM_WORLD, &win);
+
/* Run a sequence of tests */
- for (i=0; i<=ntest; i++) {
- if (wrank == master) {
- MTestPrintfMsg( 0, "Test %d\n", i );
- /* Because this lock is local, it must return only when the
- lock is acquired */
- MPI_Win_lock( MPI_LOCK_EXCLUSIVE, 0, master, win );
- RMATestInit( i, rmabuffer, bufsize );
- MPI_Send( MPI_BOTTOM, 0, MPI_INT, partner, i, MPI_COMM_WORLD );
- MPI_Send( MPI_BOTTOM, 0, MPI_INT, next, i, MPI_COMM_WORLD );
- MPI_Recv( MPI_BOTTOM, 0, MPI_INT, MPI_ANY_SOURCE, i,
- MPI_COMM_WORLD, MPI_STATUS_IGNORE );
- MPI_Win_unlock( master, win );
- MPI_Recv( MPI_BOTTOM, 0, MPI_INT, partner, i, MPI_COMM_WORLD,
- MPI_STATUS_IGNORE );
- errs += RMACheck( i, rmabuffer, bufsize );
- }
- else if (wrank == partner) {
- MPI_Recv( MPI_BOTTOM, 0, MPI_INT, master, i, MPI_COMM_WORLD,
- MPI_STATUS_IGNORE );
- MPI_Win_lock( MPI_LOCK_EXCLUSIVE, 0, master, win );
- RMATest( i, win, master, srcbuf, RMA_SIZE, getbuf, getbufsize );
- MPI_Win_unlock( master, win );
- errs += RMACheckGet( i, win, getbuf, getbufsize );
- MPI_Send( MPI_BOTTOM, 0, MPI_INT, master, i, MPI_COMM_WORLD );
- }
- else {
- MPI_Recv( MPI_BOTTOM, 0, MPI_INT, MPI_ANY_SOURCE, i,
- MPI_COMM_WORLD, MPI_STATUS_IGNORE );
- MPI_Send( MPI_BOTTOM, 0, MPI_INT, next, i, MPI_COMM_WORLD );
- }
+ for (i = 0; i <= ntest; i++) {
+ if (wrank == master) {
+ MTestPrintfMsg(0, "Test %d\n", i);
+ /* Because this lock is local, it must return only when the
+ * lock is acquired */
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, 0, master, win);
+ RMATestInit(i, rmabuffer, bufsize);
+ MPI_Send(MPI_BOTTOM, 0, MPI_INT, partner, i, MPI_COMM_WORLD);
+ MPI_Send(MPI_BOTTOM, 0, MPI_INT, next, i, MPI_COMM_WORLD);
+ MPI_Recv(MPI_BOTTOM, 0, MPI_INT, MPI_ANY_SOURCE, i, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+ MPI_Win_unlock(master, win);
+ MPI_Recv(MPI_BOTTOM, 0, MPI_INT, partner, i, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+ errs += RMACheck(i, rmabuffer, bufsize);
+ }
+ else if (wrank == partner) {
+ MPI_Recv(MPI_BOTTOM, 0, MPI_INT, master, i, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, 0, master, win);
+ RMATest(i, win, master, srcbuf, RMA_SIZE, getbuf, getbufsize);
+ MPI_Win_unlock(master, win);
+ errs += RMACheckGet(i, win, getbuf, getbufsize);
+ MPI_Send(MPI_BOTTOM, 0, MPI_INT, master, i, MPI_COMM_WORLD);
+ }
+ else {
+ MPI_Recv(MPI_BOTTOM, 0, MPI_INT, MPI_ANY_SOURCE, i, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+ MPI_Send(MPI_BOTTOM, 0, MPI_INT, next, i, MPI_COMM_WORLD);
+ }
}
if (rmabuffer) {
- MPI_Free_mem( rmabuffer );
+ MPI_Free_mem(rmabuffer);
}
if (getbuf) {
- free( getbuf );
+ free(getbuf);
}
- MPI_Win_free( &win );
- MPI_Type_free( &vectype );
+ MPI_Win_free(&win);
+ MPI_Type_free(&vectype);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
- return MTestReturnValue( errs );
+ return MTestReturnValue(errs);
}
/* Perform the tests.
*
* The srcbuf must be passed in because the buffer must remain valid
* until the subsequent unlock call. */
-void RMATest( int i, MPI_Win win, int master, int *srcbuf, int srcbufsize, int *getbuf, int getbufsize )
+void RMATest(int i, MPI_Win win, int master, int *srcbuf, int srcbufsize, int *getbuf,
+ int getbufsize)
{
int j, k;
int *source = srcbuf;
assert(srcbufsize == RMA_SIZE);
- for (j=0; j<srcbufsize; j++) source[j] = -j;
+ for (j = 0; j < srcbufsize; j++)
+ source[j] = -j;
switch (i) {
- case 0: /* Single short put (1 word at OFFSET_1) */
- source[0] = PUT_VAL;
- MPI_Put( source, 1, MPI_INT, master, OFFSET_1, 1, MPI_INT, win );
- break;
- case 1: /* Single short accumulate (1 word of value 17 at OFFSET_2) */
- source[0] = ACC_VAL;
- MPI_Accumulate( source, 1, MPI_INT, master,
- OFFSET_2, 1, MPI_INT, MPI_SUM, win );
- break;
- case 2: /* Single short get (1 word at OFFSET_3) */
- getbuf[0] = -1;
- MPI_Get( getbuf, 1, MPI_INT, master, OFFSET_3, 1, MPI_INT, win );
- break;
- case 3: /* Datatype single put (strided put) */
- for (j=0; j<veccount; j++) {
- source[j*stride] = PUT_VAL + j;
- }
- MPI_Put( source, 1, vectype, master, OFFSET_1, 1, vectype, win );
- break;
- case 4: /* Datatype single accumulate (strided acc) */
- for (j=0; j<veccount; j++) {
- source[j*stride] = ACC_VAL + j;
- }
- MPI_Accumulate( source, 1, vectype, master,
- OFFSET_2, 1, vectype, MPI_SUM, win );
- break;
- case 5: /* Datatype single get (strided get) */
- for (j=0; j<veccount; j++) {
- getbuf[j] = -j;
- }
- MPI_Get( getbuf, 1, vectype, master,
- OFFSET_3, 1, vectype, win );
- break;
- case 6: /* a few small puts (like strided put, but 1 word at a time) */
- for (j=0; j<veccount; j++) {
- source[j*stride] = PUT_VAL + j;
- }
- for (j=0; j<veccount; j++) {
- MPI_Put( source + j*stride, 1, MPI_INT, master,
- OFFSET_1+j*stride, 1, MPI_INT, win );
- }
- break;
- case 7: /* a few small accumulates (like strided acc, but 1 word at a time )*/
- for (j=0; j<veccount; j++) {
- source[j*stride] = ACC_VAL + j;
- }
- for (j=0; j<veccount; j++) {
- MPI_Accumulate( source + j*stride, 1, MPI_INT, master,
- OFFSET_2+j*stride, 1, MPI_INT, MPI_SUM, win );
- }
- break;
- case 8: /* a few small gets (like strided get, but 1 word at a time) */
- for (j=0; j<veccount; j++) {
- getbuf[j*stride] = -j;
- }
- for (j=0; j<veccount; j++) {
- MPI_Get( getbuf + j*stride, 1, MPI_INT, master,
- OFFSET_3+j*stride, 1, MPI_INT, win );
- }
- break;
- case 9: /* Single long put (OFFSET_1) */
- for (j=0; j<longcount; j++) source[j] = j;
- MPI_Put( source, longcount, MPI_INT, master,
- OFFSET_1, longcount, MPI_INT, win );
- break;
- case 10: /* Single long accumulate (OFFSET_2) */
- for (j=0; j<longcount; j++) source[j] = j;
- MPI_Accumulate( source, longcount, MPI_INT, master,
- OFFSET_2, longcount, MPI_INT, MPI_SUM, win );
- break;
- case 11: /* Single long get (OFFSET_3) */
- for (j=0; j<longcount; j++) getbuf[j] = -j;
- MPI_Get( getbuf, longcount, MPI_INT, master,
- OFFSET_3, longcount, MPI_INT, win );
- break;
- case 12: /* a few long puts (start at OFFSET_1, medcount ) */
- for (j=0; j<mednum; j++) {
- for (k=0; k<medcount; k++) {
- source[j*medcount+k] = j*2*medcount+k;
- }
- MPI_Put( source + j*medcount, medcount, MPI_INT, master,
- OFFSET_1 + j*2*medcount, medcount, MPI_INT, win );
- }
- break;
- case 13: /* a few long accumulates (start at OFFSET_2, medcount) */
- for (j=0; j<mednum; j++) {
- for (k=0; k<medcount; k++) {
- source[j*medcount+k] = ACC_VAL + j*2*medcount+k;
- }
- MPI_Accumulate( source + j*medcount, medcount, MPI_INT, master,
- OFFSET_2 + j*2*medcount, medcount, MPI_INT,
- MPI_SUM, win );
- }
- break;
- case 14: /* a few long gets (start at OFFSET_3, medcount) */
- for (j=0; j<mednum; j++) {
- for (k=0; k<medcount; k++) {
- getbuf[j*medcount+k] = -(j*medcount+k);
- }
- MPI_Get( getbuf + j*medcount, medcount, MPI_INT, master,
- OFFSET_3 + j*2*medcount, medcount, MPI_INT, win );
- }
- break;
+ case 0: /* Single short put (1 word at OFFSET_1) */
+ source[0] = PUT_VAL;
+ MPI_Put(source, 1, MPI_INT, master, OFFSET_1, 1, MPI_INT, win);
+ break;
+ case 1: /* Single short accumulate (1 word of value 17 at OFFSET_2) */
+ source[0] = ACC_VAL;
+ MPI_Accumulate(source, 1, MPI_INT, master, OFFSET_2, 1, MPI_INT, MPI_SUM, win);
+ break;
+ case 2: /* Single short get (1 word at OFFSET_3) */
+ getbuf[0] = -1;
+ MPI_Get(getbuf, 1, MPI_INT, master, OFFSET_3, 1, MPI_INT, win);
+ break;
+ case 3: /* Datatype single put (strided put) */
+ for (j = 0; j < veccount; j++) {
+ source[j * stride] = PUT_VAL + j;
+ }
+ MPI_Put(source, 1, vectype, master, OFFSET_1, 1, vectype, win);
+ break;
+ case 4: /* Datatype single accumulate (strided acc) */
+ for (j = 0; j < veccount; j++) {
+ source[j * stride] = ACC_VAL + j;
+ }
+ MPI_Accumulate(source, 1, vectype, master, OFFSET_2, 1, vectype, MPI_SUM, win);
+ break;
+ case 5: /* Datatype single get (strided get) */
+ for (j = 0; j < veccount; j++) {
+ getbuf[j] = -j;
+ }
+ MPI_Get(getbuf, 1, vectype, master, OFFSET_3, 1, vectype, win);
+ break;
+ case 6: /* a few small puts (like strided put, but 1 word at a time) */
+ for (j = 0; j < veccount; j++) {
+ source[j * stride] = PUT_VAL + j;
+ }
+ for (j = 0; j < veccount; j++) {
+ MPI_Put(source + j * stride, 1, MPI_INT, master,
+ OFFSET_1 + j * stride, 1, MPI_INT, win);
+ }
+ break;
+ case 7: /* a few small accumulates (like strided acc, but 1 word at a time) */
+ for (j = 0; j < veccount; j++) {
+ source[j * stride] = ACC_VAL + j;
+ }
+ for (j = 0; j < veccount; j++) {
+ MPI_Accumulate(source + j * stride, 1, MPI_INT, master,
+ OFFSET_2 + j * stride, 1, MPI_INT, MPI_SUM, win);
+ }
+ break;
+ case 8: /* a few small gets (like strided get, but 1 word at a time) */
+ for (j = 0; j < veccount; j++) {
+ getbuf[j * stride] = -j;
+ }
+ for (j = 0; j < veccount; j++) {
+ MPI_Get(getbuf + j * stride, 1, MPI_INT, master,
+ OFFSET_3 + j * stride, 1, MPI_INT, win);
+ }
+ break;
+ case 9: /* Single long put (OFFSET_1) */
+ for (j = 0; j < longcount; j++)
+ source[j] = j;
+ MPI_Put(source, longcount, MPI_INT, master, OFFSET_1, longcount, MPI_INT, win);
+ break;
+ case 10: /* Single long accumulate (OFFSET_2) */
+ for (j = 0; j < longcount; j++)
+ source[j] = j;
+ MPI_Accumulate(source, longcount, MPI_INT, master,
+ OFFSET_2, longcount, MPI_INT, MPI_SUM, win);
+ break;
+ case 11: /* Single long get (OFFSET_3) */
+ for (j = 0; j < longcount; j++)
+ getbuf[j] = -j;
+ MPI_Get(getbuf, longcount, MPI_INT, master, OFFSET_3, longcount, MPI_INT, win);
+ break;
+ case 12: /* a few long puts (start at OFFSET_1, medcount) */
+ for (j = 0; j < mednum; j++) {
+ for (k = 0; k < medcount; k++) {
+ source[j * medcount + k] = j * 2 * medcount + k;
+ }
+ MPI_Put(source + j * medcount, medcount, MPI_INT, master,
+ OFFSET_1 + j * 2 * medcount, medcount, MPI_INT, win);
+ }
+ break;
+ case 13: /* a few long accumulates (start at OFFSET_2, medcount) */
+ for (j = 0; j < mednum; j++) {
+ for (k = 0; k < medcount; k++) {
+ source[j * medcount + k] = ACC_VAL + j * 2 * medcount + k;
+ }
+ MPI_Accumulate(source + j * medcount, medcount, MPI_INT, master,
+ OFFSET_2 + j * 2 * medcount, medcount, MPI_INT, MPI_SUM, win);
+ }
+ break;
+ case 14: /* a few long gets (start at OFFSET_3, medcount) */
+ for (j = 0; j < mednum; j++) {
+ for (k = 0; k < medcount; k++) {
+ getbuf[j * medcount + k] = -(j * medcount + k);
+ }
+ MPI_Get(getbuf + j * medcount, medcount, MPI_INT, master,
+ OFFSET_3 + j * 2 * medcount, medcount, MPI_INT, win);
+ }
+ break;
}
}
-int RMACheck( int i, int *buf, MPI_Aint bufsize )
+int RMACheck(int i, int *buf, MPI_Aint bufsize)
{
int j, k;
int errs = 0;
switch (i) {
- case 0: /* Single short put (1 word at OFFSET_1) */
- if (buf[OFFSET_1] != PUT_VAL) {
- errs++;
- printf( "case 0: value is %d should be %d\n",
- buf[OFFSET_1], PUT_VAL );
- }
- break;
- case 1: /* Single short accumulate (1 word of value 17 at OFFSET_2) */
- if (buf[OFFSET_2] != ACC_VAL + OFFSET_2) {
- errs++;
- printf( "case 1: value is %d should be %d\n",
- buf[OFFSET_2], ACC_VAL + OFFSET_2 );
- }
- break;
- case 2: /* Single short get (1 word at OFFSET_3) */
- /* See RMACheckGet */
- break;
- case 3: /* Datatype single put (strided put) */
- case 6: /* a few small puts (like strided put, but 1 word at a time) */
+ case 0: /* Single short put (1 word at OFFSET_1) */
+ if (buf[OFFSET_1] != PUT_VAL) {
+ errs++;
+ printf("case 0: value is %d should be %d\n", buf[OFFSET_1], PUT_VAL);
+ }
+ break;
+ case 1: /* Single short accumulate (1 word of value 17 at OFFSET_2) */
+ if (buf[OFFSET_2] != ACC_VAL + OFFSET_2) {
+ errs++;
+ printf("case 1: value is %d should be %d\n", buf[OFFSET_2], ACC_VAL + OFFSET_2);
+ }
+ break;
+ case 2: /* Single short get (1 word at OFFSET_3) */
+ /* See RMACheckGet */
+ break;
+ case 3: /* Datatype single put (strided put) */
+ case 6: /* a few small puts (like strided put, but 1 word at a time) */
/* FIXME: The conditional and increment are reversed below. This looks
* like a bug, and currently prevents the following test from running. */
- for (j=0; j++; j<veccount) {
- if (buf[j*stride] != PUT_VAL + j) {
- errs++;
- printf( "case %d: value is %d should be %d\n", i,
- buf[j*stride], PUT_VAL+j );
- }
- }
- break;
- case 4: /* Datatype single accumulate (strided acc) */
- case 7: /* a few small accumulates (like strided acc, but 1 word at a time )*/
+ for (j = 0; j++; j < veccount) {
+ if (buf[j * stride] != PUT_VAL + j) {
+ errs++;
+ printf("case %d: value is %d should be %d\n", i, buf[j * stride], PUT_VAL + j);
+ }
+ }
+ break;
+ case 4: /* Datatype single accumulate (strided acc) */
+ case 7: /* a few small accumulates (like strided acc, but 1 word at a time) */
/* FIXME: The conditional and increment are reversed below. This looks
* like a bug, and currently prevents the following test from running. */
- for (j=0; j++; j<veccount) {
- if (buf[j*stride] != ACC_VAL + j + OFFSET_2 + j*stride) {
- errs++;
- printf( "case %d: value is %d should be %d\n", i,
- buf[j*stride], ACC_VAL+j+OFFSET_2+j*stride );
- }
- }
- break;
- case 5: /* Datatype single get (strided get) */
- case 8: /* a few small gets (like strided get, but 1 word at a time) */
- /* See RMACheckGet */
- break;
- case 9: /* Single long put (OFFSET_1) */
- for (j=0; j<longcount; j++) {
- if (buf[OFFSET_1+j] != j) {
- errs++;
- printf( "case 9: value is %d should be %d\n",
- buf[OFFSET_1+j], OFFSET_1 + j );
- }
- }
- break;
- case 10: /* Single long accumulate (OFFSET_2) */
- for (j=0; j<longcount; j++) {
- if (buf[OFFSET_2+j] != OFFSET_2 + j + j) {
- errs++;
- printf( "case 10: value is %d should be %d\n",
- buf[OFFSET_2+j], OFFSET_2 + j + j );
- }
- }
- break;
- case 11: /* Single long get (OFFSET_3) */
- /* See RMACheckGet */
- break;
- case 12: /* a few long puts (start at OFFSET_1, medcount ) */
- for (j=0; j<mednum; j++) {
- for (k=0; k<medcount; k++) {
- if (buf[OFFSET_1 + j*2*medcount + k] !=
- j*2*medcount+k ) {
- errs++;
- printf( "case 12: value is %d should be %d\n",
- buf[OFFSET_1+j*2*medcount + k], j*2*medcount + k );
- }
- }
- }
- break;
- case 13: /* a few long accumulates (start at OFFSET_2, medcount) */
- for (j=0; j<mednum; j++) {
- for (k=0; k<medcount; k++) {
- if (buf[OFFSET_2 + j*2*medcount + k] !=
- OFFSET_2 + 2*j*2*medcount+2*k + ACC_VAL ) {
- errs++;
- printf( "case 13: value is %d should be %d\n",
- buf[OFFSET_2+j*2*medcount + k],
- OFFSET_2 + 2*j*2*medcount + k +ACC_VAL);
- }
- }
- }
- break;
- case 14: /* a few long gets (start at OFFSET_3, medcount) */
- /* See RMACheckGet */
- break;
+ for (j = 0; j++; j < veccount) {
+ if (buf[j * stride] != ACC_VAL + j + OFFSET_2 + j * stride) {
+ errs++;
+ printf("case %d: value is %d should be %d\n", i,
+ buf[j * stride], ACC_VAL + j + OFFSET_2 + j * stride);
+ }
+ }
+ break;
+ case 5: /* Datatype single get (strided get) */
+ case 8: /* a few small gets (like strided get, but 1 word at a time) */
+ /* See RMACheckGet */
+ break;
+ case 9: /* Single long put (OFFSET_1) */
+ for (j = 0; j < longcount; j++) {
+ if (buf[OFFSET_1 + j] != j) {
+ errs++;
+ printf("case 9: value is %d should be %d\n", buf[OFFSET_1 + j], OFFSET_1 + j);
+ }
+ }
+ break;
+ case 10: /* Single long accumulate (OFFSET_2) */
+ for (j = 0; j < longcount; j++) {
+ if (buf[OFFSET_2 + j] != OFFSET_2 + j + j) {
+ errs++;
+ printf("case 10: value is %d should be %d\n", buf[OFFSET_2 + j], OFFSET_2 + j + j);
+ }
+ }
+ break;
+ case 11: /* Single long get (OFFSET_3) */
+ /* See RMACheckGet */
+ break;
+ case 12: /* a few long puts (start at OFFSET_1, medcount) */
+ for (j = 0; j < mednum; j++) {
+ for (k = 0; k < medcount; k++) {
+ if (buf[OFFSET_1 + j * 2 * medcount + k] != j * 2 * medcount + k) {
+ errs++;
+ printf("case 12: value is %d should be %d\n",
+ buf[OFFSET_1 + j * 2 * medcount + k], j * 2 * medcount + k);
+ }
+ }
+ }
+ break;
+ case 13: /* a few long accumulates (start at OFFSET_2, medcount) */
+ for (j = 0; j < mednum; j++) {
+ for (k = 0; k < medcount; k++) {
+ if (buf[OFFSET_2 + j * 2 * medcount + k] !=
+ OFFSET_2 + 2 * j * 2 * medcount + 2 * k + ACC_VAL) {
+ errs++;
+ printf("case 13: value is %d should be %d\n",
+ buf[OFFSET_2 + j * 2 * medcount + k],
+ OFFSET_2 + 2 * j * 2 * medcount + k + ACC_VAL);
+ }
+ }
+ }
+ break;
+ case 14: /* a few long gets (start at OFFSET_3, medcount) */
+ /* See RMACheckGet */
+ break;
default:
- fprintf( stderr, "Unrecognized case %d\n", i );
- errs++;
- break;
+ fprintf(stderr, "Unrecognized case %d\n", i);
+ errs++;
+ break;
}
return errs;
}
-int RMACheckGet( int i, MPI_Win win, int *getbuf, MPI_Aint getsize)
+int RMACheckGet(int i, MPI_Win win, int *getbuf, MPI_Aint getsize)
{
int errs = 0;
int j, k;
/* */
switch (i) {
- case 0: /* Single short put (1 word at OFFSET_1) */
- break;
- case 1: /* Single short accumulate (1 word of value 17 at OFFSET_2) */
- break;
- case 2: /* Single short get (1 word at OFFSET_3) */
- if (getbuf[0] != OFFSET_3) {
- errs++;
- printf( "case 2: value is %d should be %d\n",
- getbuf[0], OFFSET_3 );
- }
- break;
- case 3: /* Datatype single put (strided put) */
- break;
- case 4: /* Datatype single accumulate (strided acc) */
- break;
- case 5: /* Datatype single get (strided get) */
- case 8: /* a few small gets (like strided get, but 1 word at a time) */
- for (j=0; j<veccount; j++) {
- if (getbuf[j*stride] != OFFSET_3 + j*stride) {
- errs++;
- printf( "case %d: value is %d should be %d\n", i,
- getbuf[j*stride], OFFSET_3 + j*stride );
- }
- }
-
- break;
- case 6: /* a few small puts (like strided put, but 1 word at a time) */
- break;
- case 7: /* a few small accumulates (like strided acc, but 1 word at a time )*/
- break;
- case 9: /* Single long put (OFFSET_1) */
- break;
- case 10: /* Single long accumulate (OFFSET_2) */
- break;
- case 11: /* Single long get (OFFSET_3) */
- for (j=0; j<longcount; j++) {
- if (getbuf[j] != OFFSET_3 + j) {
- errs++;
- printf( "case 11: value is %d should be %d\n",
- getbuf[j], OFFSET_3 + j );
- }
- }
- break;
- case 12: /* a few long puts (start at OFFSET_1, medcount ) */
- break;
- case 13: /* a few long accumulates (start at OFFSET_2, medcount) */
- break;
- case 14: /* a few long gets (start at OFFSET_3, medcount) */
- for (j=0; j<mednum; j++) {
- for (k=0; k<medcount; k++) {
- if (getbuf[j*medcount + k] !=
- OFFSET_3 + j*2*medcount+k ) {
- errs++;
- printf( "case 14: buf[%d] value is %d should be %d\n",
- j*medcount + k,
- getbuf[j*medcount + k],
- OFFSET_3 + j*2*medcount + k );
- }
- }
- }
- break;
+ case 0: /* Single short put (1 word at OFFSET_1) */
+ break;
+ case 1: /* Single short accumulate (1 word of value 17 at OFFSET_2) */
+ break;
+ case 2: /* Single short get (1 word at OFFSET_3) */
+ if (getbuf[0] != OFFSET_3) {
+ errs++;
+ printf("case 2: value is %d should be %d\n", getbuf[0], OFFSET_3);
+ }
+ break;
+ case 3: /* Datatype single put (strided put) */
+ break;
+ case 4: /* Datatype single accumulate (strided acc) */
+ break;
+ case 5: /* Datatype single get (strided get) */
+ case 8: /* a few small gets (like strided get, but 1 word at a time) */
+ for (j = 0; j < veccount; j++) {
+ if (getbuf[j * stride] != OFFSET_3 + j * stride) {
+ errs++;
+ printf("case %d: value is %d should be %d\n", i,
+ getbuf[j * stride], OFFSET_3 + j * stride);
+ }
+ }
+
+ break;
+ case 6: /* a few small puts (like strided put, but 1 word at a time) */
+ break;
+ case 7: /* a few small accumulates (like strided acc, but 1 word at a time) */
+ break;
+ case 9: /* Single long put (OFFSET_1) */
+ break;
+ case 10: /* Single long accumulate (OFFSET_2) */
+ break;
+ case 11: /* Single long get (OFFSET_3) */
+ for (j = 0; j < longcount; j++) {
+ if (getbuf[j] != OFFSET_3 + j) {
+ errs++;
+ printf("case 11: value is %d should be %d\n", getbuf[j], OFFSET_3 + j);
+ }
+ }
+ break;
+ case 12: /* a few long puts (start at OFFSET_1, medcount) */
+ break;
+ case 13: /* a few long accumulates (start at OFFSET_2, medcount) */
+ break;
+ case 14: /* a few long gets (start at OFFSET_3, medcount) */
+ for (j = 0; j < mednum; j++) {
+ for (k = 0; k < medcount; k++) {
+ if (getbuf[j * medcount + k] != OFFSET_3 + j * 2 * medcount + k) {
+ errs++;
+ printf("case 14: buf[%d] value is %d should be %d\n",
+ j * medcount + k,
+ getbuf[j * medcount + k], OFFSET_3 + j * 2 * medcount + k);
+ }
+ }
+ }
+ break;
default:
- fprintf( stderr, "Unrecognized case %d\n", i );
- errs++;
- break;
+ fprintf(stderr, "Unrecognized case %d\n", i);
+ errs++;
+ break;
}
return errs;
}
-void RMATestInit( int i, int *buf, MPI_Aint bufsize )
+void RMATestInit(int i, int *buf, MPI_Aint bufsize)
{
int j;
- for (j=0; j<bufsize; j++) {
- buf[j] = j;
+ for (j = 0; j < bufsize; j++) {
+ buf[j] = j;
}
}
-
diff --git a/test/mpi/rma/locknull.c b/test/mpi/rma/locknull.c
index 8b04ce6..bf79d0c 100644
--- a/test/mpi/rma/locknull.c
+++ b/test/mpi/rma/locknull.c
@@ -14,52 +14,51 @@
static char MTEST_Descrip[] = "Locks with no RMA operations";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size, i;
- MPI_Comm comm;
- MPI_Win win;
- int *winbuf, count;
+ MPI_Comm comm;
+ MPI_Win win;
+ int *winbuf, count;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
/* Allocate and initialize buf */
- count = 1000;
+ count = 1000;
- MPI_Alloc_mem( count*sizeof(int), MPI_INFO_NULL, &winbuf );
+ MPI_Alloc_mem(count * sizeof(int), MPI_INFO_NULL, &winbuf);
- MPI_Win_create( winbuf, count * sizeof(int), sizeof(int), MPI_INFO_NULL,
- comm, &win );
+ MPI_Win_create(winbuf, count * sizeof(int), sizeof(int), MPI_INFO_NULL, comm, &win);
/* Clear winbuf */
- memset( winbuf, 0, count*sizeof(int) );
+ memset(winbuf, 0, count * sizeof(int));
- /* Note that for i == rank, this is a useful operation - it allows
- the programmer to use direct loads and stores, rather than
- put/get/accumulate, to access the local memory window. */
- for (i=0; i<size; i++) {
- MPI_Win_lock( MPI_LOCK_EXCLUSIVE, i, 0, win );
- MPI_Win_unlock( i, win );
+ /* Note that for i == rank, this is a useful operation - it allows
+ * the programmer to use direct loads and stores, rather than
+ * put/get/accumulate, to access the local memory window. */
+ for (i = 0; i < size; i++) {
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, i, 0, win);
+ MPI_Win_unlock(i, win);
}
- for (i=0; i<size; i++) {
- MPI_Win_lock( MPI_LOCK_SHARED, i, 0, win );
- MPI_Win_unlock( i, win );
+ for (i = 0; i < size; i++) {
+ MPI_Win_lock(MPI_LOCK_SHARED, i, 0, win);
+ MPI_Win_unlock(i, win);
}
- MPI_Win_free( &win );
- MPI_Free_mem( winbuf );
+ MPI_Win_free(&win);
+ MPI_Free_mem(winbuf);
/* If this test completes, no error has been found */
/* A more complete test may ensure that local locks in fact block
- remote, exclusive locks */
- MTest_Finalize( errs );
+ * remote, exclusive locks */
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
diff --git a/test/mpi/rma/lockopts.c b/test/mpi/rma/lockopts.c
index 6f962e3..2259505 100644
--- a/test/mpi/rma/lockopts.c
+++ b/test/mpi/rma/lockopts.c
@@ -3,28 +3,28 @@
* (C) 2012 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include "stdio.h"
#include "stdlib.h"
#include "mpitest.h"
-/* tests passive target RMA on 2 processes. tests the lock-single_op-unlock
+/* tests passive target RMA on 2 processes. tests the lock-single_op-unlock
optimization for less common cases:
origin datatype derived, target datatype predefined
*/
-int main(int argc, char *argv[])
-{
- int wrank, nprocs, *srcbuf, *rmabuf, i;
- int memsize;
+int main(int argc, char *argv[])
+{
+ int wrank, nprocs, *srcbuf, *rmabuf, i;
+ int memsize;
MPI_Datatype vectype;
- MPI_Win win;
- int errs = 0;
+ MPI_Win win;
+ int errs = 0;
- MTest_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
- MPI_Comm_rank(MPI_COMM_WORLD,&wrank);
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
if (nprocs < 2) {
printf("Run this program with 2 or more processes\n");
@@ -33,179 +33,169 @@ int main(int argc, char *argv[])
memsize = 10 * 4 * nprocs;
/* Create and initialize data areas */
- srcbuf = (int *)malloc( sizeof(int) * memsize );
- MPI_Alloc_mem( sizeof(int) * memsize, MPI_INFO_NULL, &rmabuf );
+ srcbuf = (int *) malloc(sizeof(int) * memsize);
+ MPI_Alloc_mem(sizeof(int) * memsize, MPI_INFO_NULL, &rmabuf);
if (!srcbuf || !rmabuf) {
- printf( "Unable to allocate srcbuf and rmabuf of size %d\n", memsize );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ printf("Unable to allocate srcbuf and rmabuf of size %d\n", memsize);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- for (i=0; i<memsize; i++) {
- rmabuf[i] = -i;
- srcbuf[i] = i;
+ for (i = 0; i < memsize; i++) {
+ rmabuf[i] = -i;
+ srcbuf[i] = i;
}
- MPI_Win_create( rmabuf, memsize*sizeof(int), sizeof(int), MPI_INFO_NULL,
- MPI_COMM_WORLD, &win );
+ MPI_Win_create(rmabuf, memsize * sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win);
/* Vector of 10 elements, separated by 4 */
- MPI_Type_vector( 10, 1, 4, MPI_INT, &vectype );
- MPI_Type_commit( &vectype );
+ MPI_Type_vector(10, 1, 4, MPI_INT, &vectype);
+ MPI_Type_commit(&vectype);
- /* Accumulate with a derived origin type and target predefined type*/
+ /* Accumulate with a derived origin type and target predefined type */
if (wrank == 0) {
- MPI_Barrier( MPI_COMM_WORLD );
- MPI_Win_lock( MPI_LOCK_EXCLUSIVE, 0, 0, win );
- for (i=0; i<10; i++) {
- if (rmabuf[i] != -i + 4*i) {
- errs++;
- printf( "Acc: expected rmabuf[%d] = %d but saw %d\n",
- i, -i + 4*i, rmabuf[i] );
- }
- rmabuf[i] = -i;
- }
- for (i=10; i<memsize; i++) {
- if (rmabuf[i] != -i) {
- errs++;
- printf( "Acc: expected rmabuf[%d] = %d but saw %d\n",
- i, -i, rmabuf[i] );
- rmabuf[i] = -i;
- }
- }
- MPI_Win_unlock( 0, win );
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, 0, 0, win);
+ for (i = 0; i < 10; i++) {
+ if (rmabuf[i] != -i + 4 * i) {
+ errs++;
+ printf("Acc: expected rmabuf[%d] = %d but saw %d\n", i, -i + 4 * i, rmabuf[i]);
+ }
+ rmabuf[i] = -i;
+ }
+ for (i = 10; i < memsize; i++) {
+ if (rmabuf[i] != -i) {
+ errs++;
+ printf("Acc: expected rmabuf[%d] = %d but saw %d\n", i, -i, rmabuf[i]);
+ rmabuf[i] = -i;
+ }
+ }
+ MPI_Win_unlock(0, win);
}
else if (wrank == 1) {
- MPI_Win_lock( MPI_LOCK_SHARED, 0, 0, win );
- MPI_Accumulate( srcbuf, 1, vectype, 0, 0, 10, MPI_INT, MPI_SUM, win );
- MPI_Win_unlock( 0, win );
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Win_lock(MPI_LOCK_SHARED, 0, 0, win);
+ MPI_Accumulate(srcbuf, 1, vectype, 0, 0, 10, MPI_INT, MPI_SUM, win);
+ MPI_Win_unlock(0, win);
+ MPI_Barrier(MPI_COMM_WORLD);
}
else {
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
}
MPI_Barrier(MPI_COMM_WORLD);
- /* Put with a derived origin type and target predefined type*/
+ /* Put with a derived origin type and target predefined type */
if (wrank == 0) {
- MPI_Barrier( MPI_COMM_WORLD );
- MPI_Win_lock( MPI_LOCK_EXCLUSIVE, 0, 0, win );
- for (i=0; i<10; i++) {
- if (rmabuf[i] != 4*i) {
- errs++;
- printf( "Put: expected rmabuf[%d] = %d but saw %d\n",
- i, 4*i, rmabuf[i] );
- }
- rmabuf[i] = -i;
- }
- for (i=10; i<memsize; i++) {
- if (rmabuf[i] != -i) {
- errs++;
- printf( "Put: expected rmabuf[%d] = %d but saw %d\n",
- i, -i, rmabuf[i] );
- rmabuf[i] = -i;
- }
- }
- MPI_Win_unlock( 0, win );
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, 0, 0, win);
+ for (i = 0; i < 10; i++) {
+ if (rmabuf[i] != 4 * i) {
+ errs++;
+ printf("Put: expected rmabuf[%d] = %d but saw %d\n", i, 4 * i, rmabuf[i]);
+ }
+ rmabuf[i] = -i;
+ }
+ for (i = 10; i < memsize; i++) {
+ if (rmabuf[i] != -i) {
+ errs++;
+ printf("Put: expected rmabuf[%d] = %d but saw %d\n", i, -i, rmabuf[i]);
+ rmabuf[i] = -i;
+ }
+ }
+ MPI_Win_unlock(0, win);
}
else if (wrank == 1) {
- MPI_Win_lock( MPI_LOCK_SHARED, 0, 0, win );
- MPI_Put( srcbuf, 1, vectype, 0, 0, 10, MPI_INT, win );
- MPI_Win_unlock( 0, win );
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Win_lock(MPI_LOCK_SHARED, 0, 0, win);
+ MPI_Put(srcbuf, 1, vectype, 0, 0, 10, MPI_INT, win);
+ MPI_Win_unlock(0, win);
+ MPI_Barrier(MPI_COMM_WORLD);
}
else {
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
}
MPI_Barrier(MPI_COMM_WORLD);
- /* Put with a derived origin type and target predefined type, with
- a get (see the move-to-end optimization) */
+ /* Put with a derived origin type and target predefined type, with
+ * a get (see the move-to-end optimization) */
if (wrank == 0) {
- MPI_Barrier( MPI_COMM_WORLD );
- MPI_Win_lock( MPI_LOCK_EXCLUSIVE, 0, 0, win );
- for (i=0; i<10; i++) {
- if (rmabuf[i] != 4*i) {
- errs++;
- printf( "Put: expected rmabuf[%d] = %d but saw %d\n",
- i, 4*i, rmabuf[i] );
- }
- rmabuf[i] = -i;
- }
- for (i=10; i<memsize; i++) {
- if (rmabuf[i] != -i) {
- errs++;
- printf( "Put: expected rmabuf[%d] = %d but saw %d\n",
- i, -i, rmabuf[i] );
- rmabuf[i] = -i;
- }
- }
- MPI_Win_unlock( 0, win );
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, 0, 0, win);
+ for (i = 0; i < 10; i++) {
+ if (rmabuf[i] != 4 * i) {
+ errs++;
+ printf("Put: expected rmabuf[%d] = %d but saw %d\n", i, 4 * i, rmabuf[i]);
+ }
+ rmabuf[i] = -i;
+ }
+ for (i = 10; i < memsize; i++) {
+ if (rmabuf[i] != -i) {
+ errs++;
+ printf("Put: expected rmabuf[%d] = %d but saw %d\n", i, -i, rmabuf[i]);
+ rmabuf[i] = -i;
+ }
+ }
+ MPI_Win_unlock(0, win);
}
else if (wrank == 1) {
- int val;
- MPI_Win_lock( MPI_LOCK_SHARED, 0, 0, win );
- MPI_Get( &val, 1, MPI_INT, 0, 10, 1, MPI_INT, win );
- MPI_Put( srcbuf, 1, vectype, 0, 0, 10, MPI_INT, win );
- MPI_Win_unlock( 0, win );
- MPI_Barrier( MPI_COMM_WORLD );
- if (val != -10) {
- errs++;
- printf( "Get: Expected -10, got %d\n", val );
- }
+ int val;
+ MPI_Win_lock(MPI_LOCK_SHARED, 0, 0, win);
+ MPI_Get(&val, 1, MPI_INT, 0, 10, 1, MPI_INT, win);
+ MPI_Put(srcbuf, 1, vectype, 0, 0, 10, MPI_INT, win);
+ MPI_Win_unlock(0, win);
+ MPI_Barrier(MPI_COMM_WORLD);
+ if (val != -10) {
+ errs++;
+ printf("Get: Expected -10, got %d\n", val);
+ }
}
else {
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
}
MPI_Barrier(MPI_COMM_WORLD);
- /* Put with a derived origin type and target predefined type, with
- a get already at the end (see the move-to-end optimization) */
+ /* Put with a derived origin type and target predefined type, with
+ * a get already at the end (see the move-to-end optimization) */
if (wrank == 0) {
- MPI_Barrier( MPI_COMM_WORLD );
- MPI_Win_lock( MPI_LOCK_EXCLUSIVE, 0, 0, win );
- for (i=0; i<10; i++) {
- if (rmabuf[i] != 4*i) {
- errs++;
- printf( "Put: expected rmabuf[%d] = %d but saw %d\n",
- i, 4*i, rmabuf[i] );
- }
- rmabuf[i] = -i;
- }
- for (i=10; i<memsize; i++) {
- if (rmabuf[i] != -i) {
- errs++;
- printf( "Put: expected rmabuf[%d] = %d but saw %d\n",
- i, -i, rmabuf[i] );
- rmabuf[i] = -i;
- }
- }
- MPI_Win_unlock( 0, win );
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, 0, 0, win);
+ for (i = 0; i < 10; i++) {
+ if (rmabuf[i] != 4 * i) {
+ errs++;
+ printf("Put: expected rmabuf[%d] = %d but saw %d\n", i, 4 * i, rmabuf[i]);
+ }
+ rmabuf[i] = -i;
+ }
+ for (i = 10; i < memsize; i++) {
+ if (rmabuf[i] != -i) {
+ errs++;
+ printf("Put: expected rmabuf[%d] = %d but saw %d\n", i, -i, rmabuf[i]);
+ rmabuf[i] = -i;
+ }
+ }
+ MPI_Win_unlock(0, win);
}
else if (wrank == 1) {
- int val;
- MPI_Win_lock( MPI_LOCK_SHARED, 0, 0, win );
- MPI_Put( srcbuf, 1, vectype, 0, 0, 10, MPI_INT, win );
- MPI_Get( &val, 1, MPI_INT, 0, 10, 1, MPI_INT, win );
- MPI_Win_unlock( 0, win );
- MPI_Barrier( MPI_COMM_WORLD );
- if (val != -10) {
- errs++;
- printf( "Get: Expected -10, got %d\n", val );
- }
+ int val;
+ MPI_Win_lock(MPI_LOCK_SHARED, 0, 0, win);
+ MPI_Put(srcbuf, 1, vectype, 0, 0, 10, MPI_INT, win);
+ MPI_Get(&val, 1, MPI_INT, 0, 10, 1, MPI_INT, win);
+ MPI_Win_unlock(0, win);
+ MPI_Barrier(MPI_COMM_WORLD);
+ if (val != -10) {
+ errs++;
+ printf("Get: Expected -10, got %d\n", val);
+ }
}
else {
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
}
- MPI_Win_free( &win );
- MPI_Free_mem( rmabuf );
- free( srcbuf );
- MPI_Type_free( &vectype );
+ MPI_Win_free(&win);
+ MPI_Free_mem(rmabuf);
+ free(srcbuf);
+ MPI_Type_free(&vectype);
MTest_Finalize(errs);
- MPI_Finalize();
- return 0;
-}
-
+ MPI_Finalize();
+ return 0;
+}
diff --git a/test/mpi/rma/manyget.c b/test/mpi/rma/manyget.c
index bf482e5..f498fcf 100644
--- a/test/mpi/rma/manyget.c
+++ b/test/mpi/rma/manyget.c
@@ -34,8 +34,7 @@ int main(int argc, char *argv[])
}
if (rank == 0)
- MPI_Win_create(buf, BUFSIZE, sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD,
- &win);
+ MPI_Win_create(buf, BUFSIZE, sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win);
else
MPI_Win_create(MPI_BOTTOM, 0, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &win);
diff --git a/test/mpi/rma/mcs-mutex.c b/test/mpi/rma/mcs-mutex.c
index 52a3bbf..a972a55 100644
--- a/test/mpi/rma/mcs-mutex.c
+++ b/test/mpi/rma/mcs-mutex.c
@@ -39,7 +39,7 @@ int MCS_Mutex_create(int tail_rank, MPI_Comm comm, MCS_Mutex * hdl_out)
hdl->tail_rank = tail_rank;
#ifdef USE_WIN_SHARED
- MPI_Win_allocate_shared(2*sizeof(int), sizeof(int), MPI_INFO_NULL,
+ MPI_Win_allocate_shared(2 * sizeof(int), sizeof(int), MPI_INFO_NULL,
hdl->comm, &hdl->base, &hdl->window);
#else
#ifdef USE_WIN_ALLOC_SHM
@@ -49,7 +49,7 @@ int MCS_Mutex_create(int tail_rank, MPI_Comm comm, MCS_Mutex * hdl_out)
MPI_Info_create(&hdl->win_info);
MPI_Info_set(hdl->win_info, "alloc_shm", "false");
#endif
- MPI_Win_allocate(2*sizeof(int), sizeof(int), hdl->win_info, hdl->comm,
+ MPI_Win_allocate(2 * sizeof(int), sizeof(int), hdl->win_info, hdl->comm,
&hdl->base, &hdl->window);
#endif
@@ -119,7 +119,8 @@ int MCS_Mutex_lock(MCS_Mutex hdl)
/* Wait for notification */
MPI_Status status;
- MPI_Accumulate(&rank, 1, MPI_INT, prev, MCS_MTX_ELEM_DISP, 1, MPI_INT, MPI_REPLACE, hdl->window);
+ MPI_Accumulate(&rank, 1, MPI_INT, prev, MCS_MTX_ELEM_DISP, 1, MPI_INT, MPI_REPLACE,
+ hdl->window);
MPI_Win_flush(prev, hdl->window);
debug_print("%2d: LOCK - waiting for notification from %d\n", rank, prev);
@@ -181,11 +182,10 @@ int MCS_Mutex_unlock(MCS_Mutex hdl)
/* Read my next pointer. FOP is used since another process may write to
* this location concurrent with this read. */
- MPI_Fetch_and_op(NULL, &next, MPI_INT, rank, MCS_MTX_ELEM_DISP, MPI_NO_OP,
- hdl->window);
+ MPI_Fetch_and_op(NULL, &next, MPI_INT, rank, MCS_MTX_ELEM_DISP, MPI_NO_OP, hdl->window);
MPI_Win_flush(rank, hdl->window);
- if ( next == MPI_PROC_NULL) {
+ if (next == MPI_PROC_NULL) {
int tail;
int nil = MPI_PROC_NULL;
@@ -206,10 +206,10 @@ int MCS_Mutex_unlock(MCS_Mutex hdl)
MPI_NO_OP, hdl->window);
MPI_Win_flush(rank, hdl->window);
- if (next != MPI_PROC_NULL) break;
+ if (next != MPI_PROC_NULL)
+ break;
- MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag,
- MPI_STATUS_IGNORE);
+ MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag, MPI_STATUS_IGNORE);
}
}
}
diff --git a/test/mpi/rma/mcs-mutex.h b/test/mpi/rma/mcs-mutex.h
index e67fc5d..ebdbffa 100644
--- a/test/mpi/rma/mcs-mutex.h
+++ b/test/mpi/rma/mcs-mutex.h
@@ -25,7 +25,7 @@ struct mcs_mutex_s {
MPI_Info win_info;
};
-typedef struct mcs_mutex_s * MCS_Mutex;
+typedef struct mcs_mutex_s *MCS_Mutex;
#define MCS_MTX_ELEM_DISP 0
#define MCS_MTX_TAIL_DISP 1
diff --git a/test/mpi/rma/mixedsync.c b/test/mpi/rma/mixedsync.c
index c558516..0bf63c3 100644
--- a/test/mpi/rma/mixedsync.c
+++ b/test/mpi/rma/mixedsync.c
@@ -14,24 +14,24 @@
static char MTEST_Descrip[] = "Mix synchronization types";
*/
-void delay( double time );
-void delay( double time )
+void delay(double time);
+void delay(double time)
{
double t1;
t1 = MPI_Wtime();
- while (MPI_Wtime() - t1 < time) ;
+ while (MPI_Wtime() - t1 < time);
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
- int errs = 0;
- int crank, csize, source, dest, loop;
- int *buf0, *buf1, *buf2, *inbuf2, count0, count1, count2, count, i;
+ int errs = 0;
+ int crank, csize, source, dest, loop;
+ int *buf0, *buf1, *buf2, *inbuf2, count0, count1, count2, count, i;
MPI_Comm comm;
- MPI_Win win;
- int *winbuf;
+ MPI_Win win;
+ int *winbuf;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
@@ -40,205 +40,189 @@ int main( int argc, char *argv[] )
count2 = 100;
count = count0 + count1 + count2 + 2;
-
+
/* Allocate and initialize the local buffers */
- buf0 = (int *)malloc( count0 * sizeof(int) );
- buf1 = (int *)malloc( count1 * sizeof(int) );
- buf2 = (int *)malloc( count2 * sizeof(int) );
- inbuf2 = (int *)malloc( count2 * sizeof(int) );
+ buf0 = (int *) malloc(count0 * sizeof(int));
+ buf1 = (int *) malloc(count1 * sizeof(int));
+ buf2 = (int *) malloc(count2 * sizeof(int));
+ inbuf2 = (int *) malloc(count2 * sizeof(int));
if (!buf0 || !buf1 || !buf2 || !inbuf2) {
- fprintf( stderr, "Unable to allocated buf0-2\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Unable to allocated buf0-2\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- for (i=0; i<count0; i++) buf0[i] = i;
- for (i=0; i<count1; i++) buf1[i] = i + count0;
- for (i=0; i<count2; i++) buf2[i] = i + count0 + count1;
+ for (i = 0; i < count0; i++)
+ buf0[i] = i;
+ for (i = 0; i < count1; i++)
+ buf1[i] = i + count0;
+ for (i = 0; i < count2; i++)
+ buf2[i] = i + count0 + count1;
/* Allocate the window buffer and create the memory window. */
- MPI_Alloc_mem( count*sizeof(int), MPI_INFO_NULL, &winbuf );
+ MPI_Alloc_mem(count * sizeof(int), MPI_INFO_NULL, &winbuf);
if (!winbuf) {
- fprintf( stderr, "Unable to allocate %d words\n", count );
- MPI_Abort( MPI_COMM_WORLD, 0 );
+ fprintf(stderr, "Unable to allocate %d words\n", count);
+ MPI_Abort(MPI_COMM_WORLD, 0);
}
- MPI_Win_create( winbuf, count*sizeof(int), sizeof(int), MPI_INFO_NULL,
- comm, &win );
+ MPI_Win_create(winbuf, count * sizeof(int), sizeof(int), MPI_INFO_NULL, comm, &win);
- MPI_Comm_size( comm, &csize );
- MPI_Comm_rank( comm, &crank );
- dest = 0;
+ MPI_Comm_size(comm, &csize);
+ MPI_Comm_rank(comm, &crank);
+ dest = 0;
source = 1;
- for (loop=0; loop<2; loop++) {
- /* Perform several communication operations, mixing synchronization
- types. Use multiple communication to avoid the single-operation
- optimization that may be present. */
- MTestPrintfMsg( 3, "Beginning loop %d of mixed sync put operations\n",
- loop );
- MPI_Barrier( comm );
- if (crank == source) {
- MTestPrintfMsg( 3, "About to perform exclusive lock\n" );
- MPI_Win_lock( MPI_LOCK_EXCLUSIVE, dest, 0, win );
- MPI_Put( buf0, count0, MPI_INT, dest, 0, count0, MPI_INT, win );
- MPI_Put( buf1, count1, MPI_INT, dest, count0, count1, MPI_INT,
- win );
- MPI_Put( buf2, count2, MPI_INT, dest, count0+count1, count2,
- MPI_INT, win );
- MPI_Win_unlock( dest, win );
- MTestPrintfMsg( 3, "Released exclusive lock\n" );
- }
- else if (crank == dest) {
- /* Just delay a bit */
- delay( 0.0001 );
- }
-
- /* The synchronization mode can only be changed when the process
- memory and public copy are guaranteed to have the same values
- (See 11.7, Semantics and Correctness). This barrier ensures that
- the lock/unlock completes before the fence call. */
- MPI_Barrier( comm );
-
- MTestPrintfMsg( 3, "About to start fence\n" );
- MPI_Win_fence( 0, win );
- if (crank == source) {
- MPI_Put( buf0, count0, MPI_INT, dest, 1, count0, MPI_INT, win );
- MPI_Put( buf1, count1, MPI_INT, dest, 1+count0, count1, MPI_INT,
- win );
- MPI_Put( buf2, count2, MPI_INT, dest, 1+count0+count1, count2,
- MPI_INT, win );
- }
- MPI_Win_fence( 0, win );
- MTestPrintfMsg( 3, "Finished with fence sync\n" );
-
- /* Check results */
- if (crank == dest) {
- for (i=0; i<count0+count1+count2; i++) {
- if (winbuf[1+i] != i) {
- errs++;
- if (errs < 10) {
- fprintf( stderr, "winbuf[%d] = %d, expected %d\n",
- 1+i, winbuf[1+i], i ); fflush(stderr);
- }
- }
- }
- }
-
- /* End of test loop */
+ for (loop = 0; loop < 2; loop++) {
+ /* Perform several communication operations, mixing synchronization
+ * types. Use multiple communication to avoid the single-operation
+ * optimization that may be present. */
+ MTestPrintfMsg(3, "Beginning loop %d of mixed sync put operations\n", loop);
+ MPI_Barrier(comm);
+ if (crank == source) {
+ MTestPrintfMsg(3, "About to perform exclusive lock\n");
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, dest, 0, win);
+ MPI_Put(buf0, count0, MPI_INT, dest, 0, count0, MPI_INT, win);
+ MPI_Put(buf1, count1, MPI_INT, dest, count0, count1, MPI_INT, win);
+ MPI_Put(buf2, count2, MPI_INT, dest, count0 + count1, count2, MPI_INT, win);
+ MPI_Win_unlock(dest, win);
+ MTestPrintfMsg(3, "Released exclusive lock\n");
+ }
+ else if (crank == dest) {
+ /* Just delay a bit */
+ delay(0.0001);
+ }
+
+ /* The synchronization mode can only be changed when the process
+ * memory and public copy are guaranteed to have the same values
+ * (See 11.7, Semantics and Correctness). This barrier ensures that
+ * the lock/unlock completes before the fence call. */
+ MPI_Barrier(comm);
+
+ MTestPrintfMsg(3, "About to start fence\n");
+ MPI_Win_fence(0, win);
+ if (crank == source) {
+ MPI_Put(buf0, count0, MPI_INT, dest, 1, count0, MPI_INT, win);
+ MPI_Put(buf1, count1, MPI_INT, dest, 1 + count0, count1, MPI_INT, win);
+ MPI_Put(buf2, count2, MPI_INT, dest, 1 + count0 + count1, count2, MPI_INT, win);
+ }
+ MPI_Win_fence(0, win);
+ MTestPrintfMsg(3, "Finished with fence sync\n");
+
+ /* Check results */
+ if (crank == dest) {
+ for (i = 0; i < count0 + count1 + count2; i++) {
+ if (winbuf[1 + i] != i) {
+ errs++;
+ if (errs < 10) {
+ fprintf(stderr, "winbuf[%d] = %d, expected %d\n", 1 + i, winbuf[1 + i], i);
+ fflush(stderr);
+ }
+ }
+ }
+ }
+
+ /* End of test loop */
}
/* Use mixed put and accumulate */
- for (loop=0; loop<2; loop++) {
- /* Perform several communication operations, mixing synchronization
- types. Use multiple communication to avoid the single-operation
- optimization that may be present. */
- MTestPrintfMsg( 3, "Begining loop %d of mixed sync put/acc operations\n",
- loop );
- memset( winbuf, 0, count*sizeof(int) );
- MPI_Barrier( comm );
- if (crank == source) {
- MPI_Win_lock( MPI_LOCK_EXCLUSIVE, dest, 0, win );
- MPI_Accumulate( buf0, count0, MPI_INT, dest, 0, count0, MPI_INT,
- MPI_SUM, win );
- MPI_Accumulate( buf1, count1, MPI_INT, dest, count0, count1,
- MPI_INT, MPI_SUM, win );
- MPI_Put( buf2, count2, MPI_INT, dest, count0+count1, count2,
- MPI_INT, win );
- MPI_Win_unlock( dest, win );
- }
- else if (crank == dest) {
- /* Just delay a bit */
- delay( 0.0001 );
- }
- /* See above - the fence should not start until the unlock completes */
- MPI_Barrier( comm );
- MPI_Win_fence( 0, win );
- if (crank == source) {
- MPI_Accumulate( buf0, count0, MPI_INT, dest, 1, count0, MPI_INT,
- MPI_REPLACE, win );
- MPI_Accumulate( buf1, count1, MPI_INT, dest, 1+count0, count1,
- MPI_INT, MPI_REPLACE, win );
- MPI_Put( buf2, count2, MPI_INT, dest, 1+count0+count1, count2,
- MPI_INT, win );
- }
- MPI_Win_fence( 0, win );
-
- /* Check results */
- if (crank == dest) {
- for (i=0; i<count0+count1+count2; i++) {
- if (winbuf[1+i] != i) {
- errs++;
- if (errs < 10) {
- fprintf( stderr, "winbuf[%d] = %d, expected %d\n",
- 1+i, winbuf[1+i], i ); fflush(stderr);
- }
- }
- }
- }
-
- /* End of test loop */
+ for (loop = 0; loop < 2; loop++) {
+ /* Perform several communication operations, mixing synchronization
+ * types. Use multiple communication to avoid the single-operation
+ * optimization that may be present. */
+ MTestPrintfMsg(3, "Begining loop %d of mixed sync put/acc operations\n", loop);
+ memset(winbuf, 0, count * sizeof(int));
+ MPI_Barrier(comm);
+ if (crank == source) {
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, dest, 0, win);
+ MPI_Accumulate(buf0, count0, MPI_INT, dest, 0, count0, MPI_INT, MPI_SUM, win);
+ MPI_Accumulate(buf1, count1, MPI_INT, dest, count0, count1, MPI_INT, MPI_SUM, win);
+ MPI_Put(buf2, count2, MPI_INT, dest, count0 + count1, count2, MPI_INT, win);
+ MPI_Win_unlock(dest, win);
+ }
+ else if (crank == dest) {
+ /* Just delay a bit */
+ delay(0.0001);
+ }
+ /* See above - the fence should not start until the unlock completes */
+ MPI_Barrier(comm);
+ MPI_Win_fence(0, win);
+ if (crank == source) {
+ MPI_Accumulate(buf0, count0, MPI_INT, dest, 1, count0, MPI_INT, MPI_REPLACE, win);
+ MPI_Accumulate(buf1, count1, MPI_INT, dest, 1 + count0, count1,
+ MPI_INT, MPI_REPLACE, win);
+ MPI_Put(buf2, count2, MPI_INT, dest, 1 + count0 + count1, count2, MPI_INT, win);
+ }
+ MPI_Win_fence(0, win);
+
+ /* Check results */
+ if (crank == dest) {
+ for (i = 0; i < count0 + count1 + count2; i++) {
+ if (winbuf[1 + i] != i) {
+ errs++;
+ if (errs < 10) {
+ fprintf(stderr, "winbuf[%d] = %d, expected %d\n", 1 + i, winbuf[1 + i], i);
+ fflush(stderr);
+ }
+ }
+ }
+ }
+
+ /* End of test loop */
}
/* Use mixed accumulate and get */
- for (loop=0; loop<2; loop++) {
- /* Perform several communication operations, mixing synchronization
- types. Use multiple communication to avoid the single-operation
- optimization that may be present. */
- MTestPrintfMsg( 3, "Begining loop %d of mixed sync put/get/acc operations\n",
- loop );
- MPI_Barrier( comm );
- if (crank == source) {
- MPI_Win_lock( MPI_LOCK_EXCLUSIVE, dest, 0, win );
- MPI_Accumulate( buf0, count0, MPI_INT, dest, 0, count0, MPI_INT,
- MPI_REPLACE, win );
- MPI_Put( buf1, count1, MPI_INT, dest, count0, count1, MPI_INT,
- win );
- MPI_Get( inbuf2, count2, MPI_INT, dest, count0+count1, count2,
- MPI_INT, win );
- MPI_Win_unlock( dest, win );
- }
- else if (crank == dest) {
- /* Just delay a bit */
- delay( 0.0001 );
- }
- /* See above - the fence should not start until the unlock completes */
- MPI_Barrier( comm );
- MPI_Win_fence( 0, win );
- if (crank == source) {
- MPI_Accumulate( buf0, count0, MPI_INT, dest, 1, count0, MPI_INT,
- MPI_REPLACE, win );
- MPI_Put( buf1, count1, MPI_INT, dest, 1+count0, count1, MPI_INT,
- win );
- MPI_Get( inbuf2, count2, MPI_INT, dest, 1+count0+count1, count2,
- MPI_INT, win );
- }
- MPI_Win_fence( 0, win );
-
- /* Check results */
- if (crank == dest) {
- /* Do the put/accumulate parts */
- for (i=0; i<count0+count1; i++) {
- if (winbuf[1+i] != i) {
- errs++;
- if (errs < 10) {
- fprintf( stderr, "winbuf[%d] = %d, expected %d\n",
- 1+i, winbuf[1+i], i ); fflush(stderr);
- }
- }
- }
- }
-
- /* End of test loop */
+ for (loop = 0; loop < 2; loop++) {
+ /* Perform several communication operations, mixing synchronization
+ * types. Use multiple communication to avoid the single-operation
+ * optimization that may be present. */
+ MTestPrintfMsg(3, "Begining loop %d of mixed sync put/get/acc operations\n", loop);
+ MPI_Barrier(comm);
+ if (crank == source) {
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, dest, 0, win);
+ MPI_Accumulate(buf0, count0, MPI_INT, dest, 0, count0, MPI_INT, MPI_REPLACE, win);
+ MPI_Put(buf1, count1, MPI_INT, dest, count0, count1, MPI_INT, win);
+ MPI_Get(inbuf2, count2, MPI_INT, dest, count0 + count1, count2, MPI_INT, win);
+ MPI_Win_unlock(dest, win);
+ }
+ else if (crank == dest) {
+ /* Just delay a bit */
+ delay(0.0001);
+ }
+ /* See above - the fence should not start until the unlock completes */
+ MPI_Barrier(comm);
+ MPI_Win_fence(0, win);
+ if (crank == source) {
+ MPI_Accumulate(buf0, count0, MPI_INT, dest, 1, count0, MPI_INT, MPI_REPLACE, win);
+ MPI_Put(buf1, count1, MPI_INT, dest, 1 + count0, count1, MPI_INT, win);
+ MPI_Get(inbuf2, count2, MPI_INT, dest, 1 + count0 + count1, count2, MPI_INT, win);
+ }
+ MPI_Win_fence(0, win);
+
+ /* Check results */
+ if (crank == dest) {
+ /* Do the put/accumulate parts */
+ for (i = 0; i < count0 + count1; i++) {
+ if (winbuf[1 + i] != i) {
+ errs++;
+ if (errs < 10) {
+ fprintf(stderr, "winbuf[%d] = %d, expected %d\n", 1 + i, winbuf[1 + i], i);
+ fflush(stderr);
+ }
+ }
+ }
+ }
+
+ /* End of test loop */
}
- MTestPrintfMsg( 3, "Freeing the window\n" );
- MPI_Barrier( comm );
- MPI_Win_free( &win );
- MPI_Free_mem( winbuf );
- free( buf0 );
- free( buf1 );
- free( buf2 );
- free( inbuf2 );
+ MTestPrintfMsg(3, "Freeing the window\n");
+ MPI_Barrier(comm);
+ MPI_Win_free(&win);
+ MPI_Free_mem(winbuf);
+ free(buf0);
+ free(buf1);
+ free(buf2);
+ free(inbuf2);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
diff --git a/test/mpi/rma/mutex_bench.c b/test/mpi/rma/mutex_bench.c
index 3bd955f..a5cf508 100644
--- a/test/mpi/rma/mutex_bench.c
+++ b/test/mpi/rma/mutex_bench.c
@@ -19,64 +19,64 @@
const int verbose = 0;
double delay_ctr = 0.0;
-int main(int argc, char ** argv) {
- int rank, nproc, i;
- double t_mcs_mtx;
- MPI_Comm mtx_comm;
- MCS_Mutex mcs_mtx;
+int main(int argc, char **argv)
+{
+ int rank, nproc, i;
+ double t_mcs_mtx;
+ MPI_Comm mtx_comm;
+ MCS_Mutex mcs_mtx;
- MPI_Init(&argc, &argv);
+ MPI_Init(&argc, &argv);
- MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- MPI_Comm_size(MPI_COMM_WORLD, &nproc);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &nproc);
#ifdef USE_WIN_SHARED
- MPI_Comm_split_type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, rank,
- MPI_INFO_NULL, &mtx_comm);
+ MPI_Comm_split_type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, rank, MPI_INFO_NULL, &mtx_comm);
#else
- mtx_comm = MPI_COMM_WORLD;
+ mtx_comm = MPI_COMM_WORLD;
#endif
- MCS_Mutex_create(0, mtx_comm, &mcs_mtx);
+ MCS_Mutex_create(0, mtx_comm, &mcs_mtx);
- MPI_Barrier(MPI_COMM_WORLD);
- t_mcs_mtx = MPI_Wtime();
+ MPI_Barrier(MPI_COMM_WORLD);
+ t_mcs_mtx = MPI_Wtime();
- for (i = 0; i < NUM_ITER; i++) {
- /* Combining trylock and lock here is helpful for testing because it makes
- * CAS and Fetch-and-op contend for the tail pointer. */
+ for (i = 0; i < NUM_ITER; i++) {
+ /* Combining trylock and lock here is helpful for testing because it makes
+ * CAS and Fetch-and-op contend for the tail pointer. */
#ifdef USE_CONTIGUOUS_RANK
- if (rank < nproc / 2) {
+ if (rank < nproc / 2) {
#else
- if (rank % 2) {
+ if (rank % 2) {
#endif
- int success = 0;
- while (!success) {
- MCS_Mutex_trylock(mcs_mtx, &success);
- }
+ int success = 0;
+ while (!success) {
+ MCS_Mutex_trylock(mcs_mtx, &success);
+ }
+ }
+ else {
+ MCS_Mutex_lock(mcs_mtx);
+ }
+ MCS_Mutex_unlock(mcs_mtx);
}
- else {
- MCS_Mutex_lock(mcs_mtx);
- }
- MCS_Mutex_unlock(mcs_mtx);
- }
- MPI_Barrier(MPI_COMM_WORLD);
- t_mcs_mtx = MPI_Wtime() - t_mcs_mtx;
+ MPI_Barrier(MPI_COMM_WORLD);
+ t_mcs_mtx = MPI_Wtime() - t_mcs_mtx;
- MCS_Mutex_free(&mcs_mtx);
+ MCS_Mutex_free(&mcs_mtx);
- if (rank == 0) {
- if (verbose) {
- printf("Nproc %d, MCS Mtx = %f us\n", nproc, t_mcs_mtx/NUM_ITER*1.0e6);
- }
- }
+ if (rank == 0) {
+ if (verbose) {
+ printf("Nproc %d, MCS Mtx = %f us\n", nproc, t_mcs_mtx / NUM_ITER * 1.0e6);
+ }
+ }
- if (mtx_comm != MPI_COMM_WORLD)
- MPI_Comm_free(&mtx_comm);
+ if (mtx_comm != MPI_COMM_WORLD)
+ MPI_Comm_free(&mtx_comm);
- MTest_Finalize(0);
- MPI_Finalize();
+ MTest_Finalize(0);
+ MPI_Finalize();
- return 0;
+ return 0;
}
diff --git a/test/mpi/rma/nb_test.c b/test/mpi/rma/nb_test.c
index 0fae2da..5cebc68 100644
--- a/test/mpi/rma/nb_test.c
+++ b/test/mpi/rma/nb_test.c
@@ -14,7 +14,7 @@ int main(int argc, char *argv[])
int base[1024], errs = 0;
MPI_Request req;
- MTest_Init(&argc,&argv);
+ MTest_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Win_create(base, 1024 * sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win);
diff --git a/test/mpi/rma/nullpscw.c b/test/mpi/rma/nullpscw.c
index 38d9472..fa87000 100644
--- a/test/mpi/rma/nullpscw.c
+++ b/test/mpi/rma/nullpscw.c
@@ -7,33 +7,33 @@
#include <mpi.h>
#include "mpitest.h"
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
- MPI_Win win;
- MPI_Group group;
- int errs = 0;
+ MPI_Win win;
+ MPI_Group group;
+ int errs = 0;
- MTest_Init(&argc,&argv);
+ MTest_Init(&argc, &argv);
#ifdef USE_WIN_ALLOCATE
- char *baseptr;
- MPI_Win_allocate(0, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &baseptr, &win);
+ char *baseptr;
+ MPI_Win_allocate(0, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &baseptr, &win);
#else
- MPI_Win_create(NULL, 0, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &win);
+ MPI_Win_create(NULL, 0, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &win);
#endif
- MPI_Win_get_group(win, &group);
-
- MPI_Win_post(group, 0, win);
- MPI_Win_start(group, 0, win);
-
- MPI_Win_complete(win);
-
- MPI_Win_wait(win);
-
- MPI_Group_free( &group );
- MPI_Win_free(&win);
-
- MTest_Finalize(errs);
- MPI_Finalize();
- return 0;
+ MPI_Win_get_group(win, &group);
+
+ MPI_Win_post(group, 0, win);
+ MPI_Win_start(group, 0, win);
+
+ MPI_Win_complete(win);
+
+ MPI_Win_wait(win);
+
+ MPI_Group_free(&group);
+ MPI_Win_free(&win);
+
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
}
diff --git a/test/mpi/rma/pscw_ordering.c b/test/mpi/rma/pscw_ordering.c
index caa15e6..5df4126 100644
--- a/test/mpi/rma/pscw_ordering.c
+++ b/test/mpi/rma/pscw_ordering.c
@@ -18,7 +18,8 @@
#include "mpitest.h"
#include "squelch.h"
-int main(int argc, char **argv) {
+int main(int argc, char **argv)
+{
int i, rank, nproc, errors = 0;
int *win_buf;
@@ -42,16 +43,16 @@ int main(int argc, char **argv) {
/* Set up odd/even groups and buffers */
odd_nproc = nproc / 2;
- even_nproc = nproc / 2 + ( (nproc % 2 == 0) ? 0 : 1 );
+ even_nproc = nproc / 2 + ((nproc % 2 == 0) ? 0 : 1);
odd_ranks = malloc(sizeof(int) * odd_nproc);
even_ranks = malloc(sizeof(int) * even_nproc);
for (i = 0; i < even_nproc; i++)
- even_ranks[i] = i*2;
+ even_ranks[i] = i * 2;
for (i = 0; i < odd_nproc; i++)
- odd_ranks[i] = i*2+1;
+ odd_ranks[i] = i * 2 + 1;
MPI_Comm_group(MPI_COMM_WORLD, &world_group);
MPI_Group_incl(world_group, odd_nproc, odd_ranks, &odd_group);
@@ -60,12 +61,11 @@ int main(int argc, char **argv) {
/* Create the window */
#ifdef USE_WIN_ALLOCATE
- MPI_Win_allocate(nproc*sizeof(int), sizeof(int), MPI_INFO_NULL,
+ MPI_Win_allocate(nproc * sizeof(int), sizeof(int), MPI_INFO_NULL,
MPI_COMM_WORLD, &win_buf, &win);
#else
- MPI_Alloc_mem(nproc*sizeof(int), MPI_INFO_NULL, &win_buf);
- MPI_Win_create(win_buf, nproc*sizeof(int), sizeof(int), MPI_INFO_NULL,
- MPI_COMM_WORLD, &win);
+ MPI_Alloc_mem(nproc * sizeof(int), MPI_INFO_NULL, &win_buf);
+ MPI_Win_create(win_buf, nproc * sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win);
#endif
MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, win);
for (i = 0; i < nproc; i++)
@@ -75,16 +75,16 @@ int main(int argc, char **argv) {
/* Perform PSCW communication: Odd/even matchup */
if (rank % 2 == 0) {
- MPI_Win_start(odd_group, 0, win); /* Even-numbered procs target odd procs */
- MPI_Win_post(odd_group, 0, win); /* Even procs are targeted by odd procs */
+ MPI_Win_start(odd_group, 0, win); /* Even-numbered procs target odd procs */
+ MPI_Win_post(odd_group, 0, win); /* Even procs are targeted by odd procs */
/* Write to my slot at each target */
for (i = 0; i < odd_nproc; i++)
MPI_Put(&rank, 1, MPI_INT, odd_ranks[i], rank, 1, MPI_INT, win);
}
else {
- MPI_Win_post(even_group, 0, win); /* Odd procs are targeted by even procs */
- MPI_Win_start(even_group, 0, win); /* Odd-numbered procs target even procs */
+ MPI_Win_post(even_group, 0, win); /* Odd procs are targeted by even procs */
+ MPI_Win_start(even_group, 0, win); /* Odd-numbered procs target even procs */
/* Write to my slot at each target */
for (i = 0; i < even_nproc; i++)
@@ -98,16 +98,16 @@ int main(int argc, char **argv) {
/* Perform PSCW communication: Odd/odd and even/even matchup */
if (rank % 2 == 0) {
- MPI_Win_post(even_group, 0, win); /* Even procs are targeted by even procs */
- MPI_Win_start(even_group, 0, win); /* Even-numbered procs target even procs */
+ MPI_Win_post(even_group, 0, win); /* Even procs are targeted by even procs */
+ MPI_Win_start(even_group, 0, win); /* Even-numbered procs target even procs */
/* Write to my slot at each target */
for (i = 0; i < even_nproc; i++)
MPI_Put(&rank, 1, MPI_INT, even_ranks[i], rank, 1, MPI_INT, win);
}
else {
- MPI_Win_post(odd_group, 0, win); /* Odd procs are targeted by odd procs */
- MPI_Win_start(odd_group, 0, win); /* Odd-numbered procs target odd procs */
+ MPI_Win_post(odd_group, 0, win); /* Odd procs are targeted by odd procs */
+ MPI_Win_start(odd_group, 0, win); /* Odd-numbered procs target odd procs */
/* Write to my slot at each target */
for (i = 0; i < odd_nproc; i++)
@@ -122,9 +122,8 @@ int main(int argc, char **argv) {
if (win_buf[i] != i) {
errors++;
- SQUELCH( printf("%d: Error -- win_buf[%d] = %d, expected %d\n",
- rank, i, win_buf[i], i);
- );
+ SQUELCH(printf("%d: Error -- win_buf[%d] = %d, expected %d\n", rank, i, win_buf[i], i);
+);
}
}
@@ -140,7 +139,7 @@ int main(int argc, char **argv) {
free(odd_ranks);
free(even_ranks);
- MTest_Finalize( errors );
+ MTest_Finalize(errors);
MPI_Finalize();
- return MTestReturnValue( errors );
+ return MTestReturnValue(errors);
}
diff --git a/test/mpi/rma/put_base.c b/test/mpi/rma/put_base.c
index ba95a1c..1c5c3d5 100644
--- a/test/mpi/rma/put_base.c
+++ b/test/mpi/rma/put_base.c
@@ -6,7 +6,7 @@
/* One-Sided MPI 2-D Strided Put Test
*
- * Author: James Dinan <dinan at mcs.anl.gov>
+ * Author: James Dinan <dinan at mcs.anl.gov>
* Date : March, 2011
*
* This code performs N strided put operations into a 2d patch of a shared
@@ -32,9 +32,10 @@
#define SUB_YDIM 1024
#define ITERATIONS 10
-int main(int argc, char **argv) {
+int main(int argc, char **argv)
+{
int i, j, rank, nranks, peer, bufsize, errors;
- double *win_buf, *src_buf, *dst_buf;
+ double *win_buf, *src_buf, *dst_buf;
MPI_Win buf_win;
MTest_Init(&argc, &argv);
@@ -44,52 +45,53 @@ int main(int argc, char **argv) {
bufsize = XDIM * YDIM * sizeof(double);
MPI_Alloc_mem(bufsize, MPI_INFO_NULL, &win_buf);
- /* Alloc_mem is not required for the origin buffers for RMA operations -
- just for the Win_create memory */
+ /* Alloc_mem is not required for the origin buffers for RMA operations -
+ * just for the Win_create memory */
MPI_Alloc_mem(bufsize, MPI_INFO_NULL, &src_buf);
MPI_Alloc_mem(bufsize, MPI_INFO_NULL, &dst_buf);
- for (i = 0; i < XDIM*YDIM; i++) {
- *(win_buf + i) = 1.0 + rank;
+ for (i = 0; i < XDIM * YDIM; i++) {
+ *(win_buf + i) = 1.0 + rank;
*(src_buf + i) = 1.0 + rank;
}
MPI_Win_create(win_buf, bufsize, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &buf_win);
- peer = (rank+1) % nranks;
+ peer = (rank + 1) % nranks;
/* Perform ITERATIONS strided put operations */
for (i = 0; i < ITERATIONS; i++) {
- MPI_Aint idx_loc[SUB_YDIM];
- int idx_rem[SUB_YDIM];
- int blk_len[SUB_YDIM];
- MPI_Datatype src_type, dst_type;
+ MPI_Aint idx_loc[SUB_YDIM];
+ int idx_rem[SUB_YDIM];
+ int blk_len[SUB_YDIM];
+ MPI_Datatype src_type, dst_type;
- void *base_ptr = dst_buf;
- MPI_Aint base_int;
+ void *base_ptr = dst_buf;
+ MPI_Aint base_int;
- MPI_Get_address(base_ptr, &base_int);
+ MPI_Get_address(base_ptr, &base_int);
- for (j = 0; j < SUB_YDIM; j++) {
- MPI_Get_address(&src_buf[j*XDIM], &idx_loc[j]);
- idx_loc[j] = idx_loc[j] - base_int;
- idx_rem[j] = j*XDIM*sizeof(double);
- blk_len[j] = SUB_XDIM*sizeof(double);
- }
+ for (j = 0; j < SUB_YDIM; j++) {
+ MPI_Get_address(&src_buf[j * XDIM], &idx_loc[j]);
+ idx_loc[j] = idx_loc[j] - base_int;
+ idx_rem[j] = j * XDIM * sizeof(double);
+ blk_len[j] = SUB_XDIM * sizeof(double);
+ }
- MPI_Type_create_hindexed(SUB_YDIM, blk_len, idx_loc, MPI_BYTE, &src_type);
- MPI_Type_create_indexed_block(SUB_YDIM, SUB_XDIM*sizeof(double), idx_rem, MPI_BYTE, &dst_type);
+ MPI_Type_create_hindexed(SUB_YDIM, blk_len, idx_loc, MPI_BYTE, &src_type);
+ MPI_Type_create_indexed_block(SUB_YDIM, SUB_XDIM * sizeof(double), idx_rem, MPI_BYTE,
+ &dst_type);
- MPI_Type_commit(&src_type);
- MPI_Type_commit(&dst_type);
+ MPI_Type_commit(&src_type);
+ MPI_Type_commit(&dst_type);
- MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
- MPI_Put(base_ptr, 1, src_type, peer, 0, 1, dst_type, buf_win);
- MPI_Win_unlock(peer, buf_win);
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
+ MPI_Put(base_ptr, 1, src_type, peer, 0, 1, dst_type, buf_win);
+ MPI_Win_unlock(peer, buf_win);
- MPI_Type_free(&src_type);
- MPI_Type_free(&dst_type);
+ MPI_Type_free(&src_type);
+ MPI_Type_free(&dst_type);
}
MPI_Barrier(MPI_COMM_WORLD);
@@ -99,40 +101,40 @@ int main(int argc, char **argv) {
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, buf_win);
errors = 0;
for (i = 0; i < SUB_XDIM; i++) {
- for (j = 0; j < SUB_YDIM; j++) {
- const double actual = *(win_buf + i + j*XDIM);
- const double expected = (1.0 + ((rank+nranks-1)%nranks));
- if (actual - expected > 1e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = 0; j < SUB_YDIM; j++) {
+ const double actual = *(win_buf + i + j * XDIM);
+ const double expected = (1.0 + ((rank + nranks - 1) % nranks));
+ if (actual - expected > 1e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
for (i = SUB_XDIM; i < XDIM; i++) {
- for (j = 0; j < SUB_YDIM; j++) {
- const double actual = *(win_buf + i + j*XDIM);
- const double expected = 1.0 + rank;
- if (actual - expected > 1e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = 0; j < SUB_YDIM; j++) {
+ const double actual = *(win_buf + i + j * XDIM);
+ const double expected = 1.0 + rank;
+ if (actual - expected > 1e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
for (i = 0; i < XDIM; i++) {
- for (j = SUB_YDIM; j < YDIM; j++) {
- const double actual = *(win_buf + i + j*XDIM);
- const double expected = 1.0 + rank;
- if (actual - expected > 1e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = SUB_YDIM; j < YDIM; j++) {
+ const double actual = *(win_buf + i + j * XDIM);
+ const double expected = 1.0 + rank;
+ if (actual - expected > 1e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
MPI_Win_unlock(rank, buf_win);
@@ -141,7 +143,7 @@ int main(int argc, char **argv) {
MPI_Free_mem(src_buf);
MPI_Free_mem(dst_buf);
- MTest_Finalize( errors );
+ MTest_Finalize(errors);
MPI_Finalize();
return 0;
diff --git a/test/mpi/rma/put_bottom.c b/test/mpi/rma/put_bottom.c
index 6634ea0..7d67bfd 100644
--- a/test/mpi/rma/put_bottom.c
+++ b/test/mpi/rma/put_bottom.c
@@ -6,7 +6,7 @@
/* One-Sided MPI 2-D Strided Put Test
*
- * Author: James Dinan <dinan at mcs.anl.gov>
+ * Author: James Dinan <dinan at mcs.anl.gov>
* Date : March, 2011
*
* This code performs N strided put operations into a 2d patch of a shared
@@ -30,7 +30,8 @@
#define SUB_YDIM 1024
#define ITERATIONS 10
-int main(int argc, char **argv) {
+int main(int argc, char **argv)
+{
int i, j, rank, nranks, peer, bufsize, errors;
double *win_buf, *src_buf, *dst_buf;
MPI_Win buf_win;
@@ -45,41 +46,42 @@ int main(int argc, char **argv) {
MPI_Alloc_mem(bufsize, MPI_INFO_NULL, &src_buf);
MPI_Alloc_mem(bufsize, MPI_INFO_NULL, &dst_buf);
- for (i = 0; i < XDIM*YDIM; i++) {
- *(win_buf + i) = 1.0 + rank;
+ for (i = 0; i < XDIM * YDIM; i++) {
+ *(win_buf + i) = 1.0 + rank;
*(src_buf + i) = 1.0 + rank;
}
MPI_Win_create(win_buf, bufsize, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &buf_win);
- peer = (rank+1) % nranks;
+ peer = (rank + 1) % nranks;
/* Perform ITERATIONS strided put operations */
for (i = 0; i < ITERATIONS; i++) {
- MPI_Aint idx_loc[SUB_YDIM];
- int idx_rem[SUB_YDIM];
- int blk_len[SUB_YDIM];
- MPI_Datatype src_type, dst_type;
-
- for (j = 0; j < SUB_YDIM; j++) {
- MPI_Get_address(&src_buf[j*XDIM], &idx_loc[j]);
- idx_rem[j] = j*XDIM*sizeof(double);
- blk_len[j] = SUB_XDIM*sizeof(double);
- }
+ MPI_Aint idx_loc[SUB_YDIM];
+ int idx_rem[SUB_YDIM];
+ int blk_len[SUB_YDIM];
+ MPI_Datatype src_type, dst_type;
+
+ for (j = 0; j < SUB_YDIM; j++) {
+ MPI_Get_address(&src_buf[j * XDIM], &idx_loc[j]);
+ idx_rem[j] = j * XDIM * sizeof(double);
+ blk_len[j] = SUB_XDIM * sizeof(double);
+ }
- MPI_Type_create_hindexed(SUB_YDIM, blk_len, idx_loc, MPI_BYTE, &src_type);
- MPI_Type_create_indexed_block(SUB_YDIM, SUB_XDIM*sizeof(double), idx_rem, MPI_BYTE, &dst_type);
+ MPI_Type_create_hindexed(SUB_YDIM, blk_len, idx_loc, MPI_BYTE, &src_type);
+ MPI_Type_create_indexed_block(SUB_YDIM, SUB_XDIM * sizeof(double), idx_rem, MPI_BYTE,
+ &dst_type);
- MPI_Type_commit(&src_type);
- MPI_Type_commit(&dst_type);
+ MPI_Type_commit(&src_type);
+ MPI_Type_commit(&dst_type);
- MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
- MPI_Put(MPI_BOTTOM, 1, src_type, peer, 0, 1, dst_type, buf_win);
- MPI_Win_unlock(peer, buf_win);
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
+ MPI_Put(MPI_BOTTOM, 1, src_type, peer, 0, 1, dst_type, buf_win);
+ MPI_Win_unlock(peer, buf_win);
- MPI_Type_free(&src_type);
- MPI_Type_free(&dst_type);
+ MPI_Type_free(&src_type);
+ MPI_Type_free(&dst_type);
}
MPI_Barrier(MPI_COMM_WORLD);
@@ -89,40 +91,40 @@ int main(int argc, char **argv) {
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, buf_win);
errors = 0;
for (i = 0; i < SUB_XDIM; i++) {
- for (j = 0; j < SUB_YDIM; j++) {
- const double actual = *(win_buf + i + j*XDIM);
- const double expected = (1.0 + ((rank+nranks-1)%nranks));
- if (actual - expected > 1e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = 0; j < SUB_YDIM; j++) {
+ const double actual = *(win_buf + i + j * XDIM);
+ const double expected = (1.0 + ((rank + nranks - 1) % nranks));
+ if (actual - expected > 1e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
for (i = SUB_XDIM; i < XDIM; i++) {
- for (j = 0; j < SUB_YDIM; j++) {
- const double actual = *(win_buf + i + j*XDIM);
- const double expected = 1.0 + rank;
- if (actual - expected > 1e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = 0; j < SUB_YDIM; j++) {
+ const double actual = *(win_buf + i + j * XDIM);
+ const double expected = 1.0 + rank;
+ if (actual - expected > 1e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
for (i = 0; i < XDIM; i++) {
- for (j = SUB_YDIM; j < YDIM; j++) {
- const double actual = *(win_buf + i + j*XDIM);
- const double expected = 1.0 + rank;
- if (actual - expected > 1e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = SUB_YDIM; j < YDIM; j++) {
+ const double actual = *(win_buf + i + j * XDIM);
+ const double expected = 1.0 + rank;
+ if (actual - expected > 1e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
MPI_Win_unlock(rank, buf_win);
@@ -131,7 +133,7 @@ int main(int argc, char **argv) {
MPI_Free_mem(src_buf);
MPI_Free_mem(dst_buf);
- MTest_Finalize( errors );
+ MTest_Finalize(errors);
MPI_Finalize();
return 0;
diff --git a/test/mpi/rma/putfence1.c b/test/mpi/rma/putfence1.c
index de13720..103ce77 100644
--- a/test/mpi/rma/putfence1.c
+++ b/test/mpi/rma/putfence1.c
@@ -18,110 +18,109 @@ static char MTEST_Descrip[] = "Put with Fence";
*/
static inline int test(MPI_Comm comm, int rank, int source, int dest,
- MTestDatatype *sendtype, MTestDatatype *recvtype)
+ MTestDatatype * sendtype, MTestDatatype * recvtype)
{
int errs = 0, err;
MPI_Aint extent;
- MPI_Win win;
+ MPI_Win win;
- MTestPrintfMsg( 1,
- "Putting count = %ld of sendtype %s - count = %ld receive type %s\n",
- sendtype->count, MTestGetDatatypeName( sendtype ), recvtype->count,
- MTestGetDatatypeName( recvtype ) );
+ MTestPrintfMsg(1,
+ "Putting count = %ld of sendtype %s - count = %ld receive type %s\n",
+ sendtype->count, MTestGetDatatypeName(sendtype), recvtype->count,
+ MTestGetDatatypeName(recvtype));
/* Make sure that everyone has a recv buffer */
- recvtype->InitBuf( recvtype );
- MPI_Type_extent( recvtype->datatype, &extent );
- MPI_Win_create( recvtype->buf, recvtype->count * extent,
- extent, MPI_INFO_NULL, comm, &win );
- MPI_Win_fence( 0, win );
+ recvtype->InitBuf(recvtype);
+ MPI_Type_extent(recvtype->datatype, &extent);
+ MPI_Win_create(recvtype->buf, recvtype->count * extent, extent, MPI_INFO_NULL, comm, &win);
+ MPI_Win_fence(0, win);
if (rank == source) {
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Win_set_errhandler( win, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Win_set_errhandler(win, MPI_ERRORS_RETURN);
- sendtype->InitBuf( sendtype );
+ sendtype->InitBuf(sendtype);
- err = MPI_Put( sendtype->buf, sendtype->count,
- sendtype->datatype, dest, 0,
- recvtype->count, recvtype->datatype, win );
+ err = MPI_Put(sendtype->buf, sendtype->count,
+ sendtype->datatype, dest, 0, recvtype->count, recvtype->datatype, win);
if (err) {
errs++;
if (errs < 10) {
- MTestPrintError( err );
+ MTestPrintError(err);
}
}
- err = MPI_Win_fence( 0, win );
+ err = MPI_Win_fence(0, win);
if (err) {
errs++;
if (errs < 10) {
- MTestPrintError( err );
+ MTestPrintError(err);
}
}
}
else if (rank == dest) {
- MPI_Win_fence( 0, win );
+ MPI_Win_fence(0, win);
/* This should have the same effect, in terms of
- transfering data, as a send/recv pair */
- err = MTestCheckRecv( 0, recvtype );
+ * transfering data, as a send/recv pair */
+ err = MTestCheckRecv(0, recvtype);
if (err) {
if (errs < 10) {
- printf( "Data in target buffer did not match for destination datatype %s (put with source datatype %s)\n",
- MTestGetDatatypeName( recvtype ),
- MTestGetDatatypeName( sendtype ) );
+ printf
+ ("Data in target buffer did not match for destination datatype %s (put with source datatype %s)\n",
+ MTestGetDatatypeName(recvtype), MTestGetDatatypeName(sendtype));
/* Redo the test, with the errors printed */
recvtype->printErrors = 1;
- (void)MTestCheckRecv( 0, recvtype );
+ (void) MTestCheckRecv(0, recvtype);
}
errs += err;
}
}
else {
- MPI_Win_fence( 0, win );
+ MPI_Win_fence(0, win);
}
- MPI_Win_free( &win );
+ MPI_Win_free(&win);
return errs;
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size, source, dest;
- int minsize = 2, count;
- MPI_Comm comm;
+ int minsize = 2, count;
+ MPI_Comm comm;
MTestDatatype sendtype, recvtype;
- MTest_Init( &argc, &argv );
- /* The following illustrates the use of the routines to
- run through a selection of communicators and datatypes.
- Use subsets of these for tests that do not involve combinations
- of communicators, datatypes, and counts of datatypes */
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
- /* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
- source = 0;
- dest = size - 1;
-
- MTEST_DATATYPE_FOR_EACH_COUNT(count) {
- while (MTestGetDatatypes( &sendtype, &recvtype, count )) {
+ MTest_Init(&argc, &argv);
+ /* The following illustrates the use of the routines to
+ * run through a selection of communicators and datatypes.
+ * Use subsets of these for tests that do not involve combinations
+ * of communicators, datatypes, and counts of datatypes */
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ /* Determine the sender and receiver */
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+ source = 0;
+ dest = size - 1;
+
+ MTEST_DATATYPE_FOR_EACH_COUNT(count) {
+ while (MTestGetDatatypes(&sendtype, &recvtype, count)) {
errs += test(comm, rank, source, dest, &sendtype, &recvtype);
MTestFreeDatatype(&sendtype);
MTestFreeDatatype(&recvtype);
- }
- }
+ }
+ }
MTestFreeComm(&comm);
}
/* Part #2: simple large size test - contiguous and noncontiguous */
- if (sizeof(void *) > 4) { /* Only if > 32-bit architecture */
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ if (sizeof(void *) > 4) { /* Only if > 32-bit architecture */
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
source = 0;
- dest = size - 1;
+ dest = size - 1;
MTestGetDatatypes(&sendtype, &recvtype, LARGE_CNT_CONTIG);
errs += test(MPI_COMM_WORLD, rank, source, dest, &sendtype, &recvtype);
@@ -136,7 +135,7 @@ int main( int argc, char *argv[] )
MTestFreeDatatype(&recvtype);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/rma/putfidx.c b/test/mpi/rma/putfidx.c
index 6a23eb2..8064d4a 100644
--- a/test/mpi/rma/putfidx.c
+++ b/test/mpi/rma/putfidx.c
@@ -15,111 +15,108 @@
static char MTEST_Descrip[] = "Put with Fence for an indexed datatype";
*/
-int CheckMPIErr( int err );
+int CheckMPIErr(int err);
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
- int errs = 0, err;
- int i, rank, size, source, dest;
- int blksize, totsize;
- int *recvBuf = 0, *srcBuf = 0;
- MPI_Comm comm;
- MPI_Win win;
- MPI_Aint extent;
- MPI_Datatype originType;
- int counts[2];
- int displs[2];
-
- MTest_Init( &argc, &argv );
+ int errs = 0, err;
+ int i, rank, size, source, dest;
+ int blksize, totsize;
+ int *recvBuf = 0, *srcBuf = 0;
+ MPI_Comm comm;
+ MPI_Win win;
+ MPI_Aint extent;
+ MPI_Datatype originType;
+ int counts[2];
+ int displs[2];
+
+ MTest_Init(&argc, &argv);
/* Select the communicator and datatypes */
comm = MPI_COMM_WORLD;
/* Create the datatype */
- /* One MPI Implementation fails this test with sufficiently large
- values of blksize - it appears to convert this type to an
- incorrect contiguous move */
+ /* One MPI Implementation fails this test with sufficiently large
+ * values of blksize - it appears to convert this type to an
+ * incorrect contiguous move */
blksize = 2048;
counts[0] = blksize;
counts[1] = blksize;
displs[0] = 0;
displs[1] = blksize + 1;
- MPI_Type_indexed( 2, counts, displs, MPI_INT, &originType );
- MPI_Type_commit( &originType );
+ MPI_Type_indexed(2, counts, displs, MPI_INT, &originType);
+ MPI_Type_commit(&originType);
totsize = 2 * blksize;
/* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
source = 0;
- dest = size - 1;
-
- recvBuf = (int *) malloc( totsize * sizeof(int) );
- srcBuf = (int *) malloc( (totsize + 1) * sizeof(int) ) ;
-
+ dest = size - 1;
+
+ recvBuf = (int *) malloc(totsize * sizeof(int));
+ srcBuf = (int *) malloc((totsize + 1) * sizeof(int));
+
if (!recvBuf || !srcBuf) {
- fprintf( stderr, "Could not allocate buffers\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Could not allocate buffers\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
-
+
/* Initialize the send and recv buffers */
- for (i=0; i<totsize; i++) {
- recvBuf[i] = -1;
+ for (i = 0; i < totsize; i++) {
+ recvBuf[i] = -1;
}
- for (i=0; i<blksize; i++) {
- srcBuf[i] = i;
- srcBuf[blksize+1+i] = blksize+i;
+ for (i = 0; i < blksize; i++) {
+ srcBuf[i] = i;
+ srcBuf[blksize + 1 + i] = blksize + i;
}
srcBuf[blksize] = -1;
- MPI_Type_extent( MPI_INT, &extent );
- MPI_Win_create( recvBuf, totsize * extent, extent,
- MPI_INFO_NULL, comm, &win );
- MPI_Win_fence( 0, win );
+ MPI_Type_extent(MPI_INT, &extent);
+ MPI_Win_create(recvBuf, totsize * extent, extent, MPI_INFO_NULL, comm, &win);
+ MPI_Win_fence(0, win);
if (rank == source) {
- /* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Win_set_errhandler( win, MPI_ERRORS_RETURN );
-
- err = MPI_Put( srcBuf, 1, originType, dest, 0,
- totsize, MPI_INT, win );
- errs += CheckMPIErr( err );
- err = MPI_Win_fence( 0, win );
- errs += CheckMPIErr( err );
+ /* To improve reporting of problems about operations, we
+ * change the error handler to errors return */
+ MPI_Win_set_errhandler(win, MPI_ERRORS_RETURN);
+
+ err = MPI_Put(srcBuf, 1, originType, dest, 0, totsize, MPI_INT, win);
+ errs += CheckMPIErr(err);
+ err = MPI_Win_fence(0, win);
+ errs += CheckMPIErr(err);
}
else if (rank == dest) {
- MPI_Win_fence( 0, win );
- for (i=0; i<totsize; i++) {
- if (recvBuf[i] != i) {
- errs++;
- if (errs < 10) {
- printf( "recvBuf[%d] = %d should = %d\n",
- i, recvBuf[i], i );
- }
- }
- }
+ MPI_Win_fence(0, win);
+ for (i = 0; i < totsize; i++) {
+ if (recvBuf[i] != i) {
+ errs++;
+ if (errs < 10) {
+ printf("recvBuf[%d] = %d should = %d\n", i, recvBuf[i], i);
+ }
+ }
+ }
}
else {
- MPI_Win_fence( 0, win );
+ MPI_Win_fence(0, win);
}
-
- MPI_Type_free( &originType );
- MPI_Win_free( &win );
- free( recvBuf );
- free( srcBuf );
- MTest_Finalize( errs );
+ MPI_Type_free(&originType);
+ MPI_Win_free(&win);
+ free(recvBuf);
+ free(srcBuf);
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
-int CheckMPIErr( int err )
+int CheckMPIErr(int err)
{
int rc = 0;
- if (err != MPI_SUCCESS) {
- MTestPrintError( err );
- rc = 1;
+ if (err != MPI_SUCCESS) {
+ MTestPrintError(err);
+ rc = 1;
}
return rc;
}
diff --git a/test/mpi/rma/putpscw1.c b/test/mpi/rma/putpscw1.c
index fb05df5..b642695 100644
--- a/test/mpi/rma/putpscw1.c
+++ b/test/mpi/rma/putpscw1.c
@@ -12,98 +12,99 @@
static char MTEST_Descrip[] = "Put with Post/Start/Complete/Wait";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int rank, size, source, dest;
- int minsize = 2, count;
- MPI_Comm comm;
- MPI_Win win;
- MPI_Aint extent;
- MPI_Group wingroup, neighbors;
+ int minsize = 2, count;
+ MPI_Comm comm;
+ MPI_Win win;
+ MPI_Aint extent;
+ MPI_Group wingroup, neighbors;
MTestDatatype sendtype, recvtype;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- /* The following illustrates the use of the routines to
- run through a selection of communicators and datatypes.
- Use subsets of these for tests that do not involve combinations
- of communicators, datatypes, and counts of datatypes */
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
- /* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
- source = 0;
- dest = size - 1;
-
- MTEST_DATATYPE_FOR_EACH_COUNT(count) {
- while (MTestGetDatatypes( &sendtype, &recvtype, count )) {
- /* Make sure that everyone has a recv buffer */
- recvtype.InitBuf( &recvtype );
+ /* The following illustrates the use of the routines to
+ * run through a selection of communicators and datatypes.
+ * Use subsets of these for tests that do not involve combinations
+ * of communicators, datatypes, and counts of datatypes */
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ /* Determine the sender and receiver */
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+ source = 0;
+ dest = size - 1;
- MPI_Type_extent( recvtype.datatype, &extent );
- MPI_Win_create( recvtype.buf, recvtype.count * extent,
- (int)extent, MPI_INFO_NULL, comm, &win );
- MPI_Win_get_group( win, &wingroup );
- if (rank == source) {
- /* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Win_set_errhandler( win, MPI_ERRORS_RETURN );
- sendtype.InitBuf( &sendtype );
-
- /* Neighbor is dest only */
- MPI_Group_incl( wingroup, 1, &dest, &neighbors );
- err = MPI_Win_start( neighbors, 0, win );
- if (err) {
- errs++;
- if (errs < 10) {
- MTestPrintError( err );
- }
- }
- MPI_Group_free( &neighbors );
- err = MPI_Put( sendtype.buf, sendtype.count,
- sendtype.datatype, dest, 0,
- recvtype.count, recvtype.datatype, win );
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- err = MPI_Win_complete( win );
- if (err) {
- errs++;
- if (errs < 10) {
- MTestPrintError( err );
- }
- }
- }
- else if (rank == dest) {
- MPI_Group_incl( wingroup, 1, &source, &neighbors );
- MPI_Win_post( neighbors, 0, win );
- MPI_Group_free( &neighbors );
- MPI_Win_wait( win );
- /* This should have the same effect, in terms of
- transfering data, as a send/recv pair */
- err = MTestCheckRecv( 0, &recvtype );
- if (err) {
- errs += errs;
- }
- }
- else {
- /* Nothing; the other processes need not call any
- MPI routines */
- ;
- }
- MPI_Win_free( &win );
- MTestFreeDatatype( &sendtype );
- MTestFreeDatatype( &recvtype );
- MPI_Group_free( &wingroup );
- }
- }
- MTestFreeComm( &comm );
+ MTEST_DATATYPE_FOR_EACH_COUNT(count) {
+ while (MTestGetDatatypes(&sendtype, &recvtype, count)) {
+ /* Make sure that everyone has a recv buffer */
+ recvtype.InitBuf(&recvtype);
+
+ MPI_Type_extent(recvtype.datatype, &extent);
+ MPI_Win_create(recvtype.buf, recvtype.count * extent,
+ (int) extent, MPI_INFO_NULL, comm, &win);
+ MPI_Win_get_group(win, &wingroup);
+ if (rank == source) {
+ /* To improve reporting of problems about operations, we
+ * change the error handler to errors return */
+ MPI_Win_set_errhandler(win, MPI_ERRORS_RETURN);
+ sendtype.InitBuf(&sendtype);
+
+ /* Neighbor is dest only */
+ MPI_Group_incl(wingroup, 1, &dest, &neighbors);
+ err = MPI_Win_start(neighbors, 0, win);
+ if (err) {
+ errs++;
+ if (errs < 10) {
+ MTestPrintError(err);
+ }
+ }
+ MPI_Group_free(&neighbors);
+ err = MPI_Put(sendtype.buf, sendtype.count,
+ sendtype.datatype, dest, 0,
+ recvtype.count, recvtype.datatype, win);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ err = MPI_Win_complete(win);
+ if (err) {
+ errs++;
+ if (errs < 10) {
+ MTestPrintError(err);
+ }
+ }
+ }
+ else if (rank == dest) {
+ MPI_Group_incl(wingroup, 1, &source, &neighbors);
+ MPI_Win_post(neighbors, 0, win);
+ MPI_Group_free(&neighbors);
+ MPI_Win_wait(win);
+ /* This should have the same effect, in terms of
+ * transfering data, as a send/recv pair */
+ err = MTestCheckRecv(0, &recvtype);
+ if (err) {
+ errs += errs;
+ }
+ }
+ else {
+ /* Nothing; the other processes need not call any
+ * MPI routines */
+ ;
+ }
+ MPI_Win_free(&win);
+ MTestFreeDatatype(&sendtype);
+ MTestFreeDatatype(&recvtype);
+ MPI_Group_free(&wingroup);
+ }
+ }
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/rma/req_example.c b/test/mpi/rma/req_example.c
index 5788972..38549fd 100644
--- a/test/mpi/rma/req_example.c
+++ b/test/mpi/rma/req_example.c
@@ -26,14 +26,15 @@
* function. */
double junk = 0.0;
-void compute(int step, double *data) {
+void compute(int step, double *data)
+{
int i;
for (i = 0; i < N; i++)
junk += data[i] * (double) step;
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int i, rank, nproc;
int errors = 0, all_errors = 0;
@@ -41,7 +42,7 @@ int main( int argc, char *argv[] )
MPI_Request put_req[M] = { MPI_REQUEST_NULL };
MPI_Request get_req;
double *baseptr;
- double data[M][N]; /* M buffers of length N */
+ double data[M][N]; /* M buffers of length N */
MPI_Info win_info;
MPI_Init(&argc, &argv);
@@ -58,29 +59,28 @@ int main( int argc, char *argv[] )
MPI_Info_set(win_info, "alloc_shm", "false");
#endif
- MPI_Win_allocate(NSTEPS*N*sizeof(double), sizeof(double), win_info,
+ MPI_Win_allocate(NSTEPS * N * sizeof(double), sizeof(double), win_info,
MPI_COMM_WORLD, &baseptr, &win);
MPI_Win_lock_all(0, win);
for (i = 0; i < NSTEPS; i++) {
- int target = (rank+1) % nproc;
+ int target = (rank + 1) % nproc;
int j;
/* Find a free put request */
if (i < M) {
j = i;
- } else {
+ }
+ else {
MPI_Waitany(M, put_req, &j, MPI_STATUS_IGNORE);
}
- MPI_Rget(data[j], N, MPI_DOUBLE, target, i*N, N, MPI_DOUBLE, win,
- &get_req);
- MPI_Wait(&get_req,MPI_STATUS_IGNORE);
+ MPI_Rget(data[j], N, MPI_DOUBLE, target, i * N, N, MPI_DOUBLE, win, &get_req);
+ MPI_Wait(&get_req, MPI_STATUS_IGNORE);
compute(i, data[j]);
- MPI_Rput(data[j], N, MPI_DOUBLE, target, i*N, N, MPI_DOUBLE, win,
- &put_req[j]);
+ MPI_Rput(data[j], N, MPI_DOUBLE, target, i * N, N, MPI_DOUBLE, win, &put_req[j]);
}
diff --git a/test/mpi/rma/reqops.c b/test/mpi/rma/reqops.c
index 36ef18e..0c84bcd 100644
--- a/test/mpi/rma/reqops.c
+++ b/test/mpi/rma/reqops.c
@@ -11,7 +11,7 @@
#define ITER 100
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int rank, nproc, i;
int errors = 0, all_errors = 0;
@@ -23,19 +23,21 @@ int main( int argc, char *argv[] )
MPI_Comm_size(MPI_COMM_WORLD, &nproc);
if (nproc < 2) {
- if (rank == 0) printf("Error: must be run with two or more processes\n");
+ if (rank == 0)
+ printf("Error: must be run with two or more processes\n");
MPI_Abort(MPI_COMM_WORLD, 1);
}
/** Create using MPI_Win_create() **/
if (rank == 0) {
- MPI_Alloc_mem(4*sizeof(int), MPI_INFO_NULL, &buf);
- *buf = nproc-1;
- } else
- buf = NULL;
+ MPI_Alloc_mem(4 * sizeof(int), MPI_INFO_NULL, &buf);
+ *buf = nproc - 1;
+ }
+ else
+ buf = NULL;
- MPI_Win_create(buf, 4*sizeof(int)*(rank == 0), 1, MPI_INFO_NULL, MPI_COMM_WORLD, &window);
+ MPI_Win_create(buf, 4 * sizeof(int) * (rank == 0), 1, MPI_INFO_NULL, MPI_COMM_WORLD, &window);
/* PROC_NULL Communication */
{
@@ -44,10 +46,12 @@ int main( int argc, char *argv[] )
MPI_Win_lock_all(0, window);
- MPI_Rget_accumulate(&val[0], 1, MPI_INT, &res, 1, MPI_INT, MPI_PROC_NULL, 0, 1, MPI_INT, MPI_REPLACE, window, &pn_req[0]);
+ MPI_Rget_accumulate(&val[0], 1, MPI_INT, &res, 1, MPI_INT, MPI_PROC_NULL, 0, 1, MPI_INT,
+ MPI_REPLACE, window, &pn_req[0]);
MPI_Rget(&val[1], 1, MPI_INT, MPI_PROC_NULL, 1, 1, MPI_INT, window, &pn_req[1]);
MPI_Rput(&val[2], 1, MPI_INT, MPI_PROC_NULL, 2, 1, MPI_INT, window, &pn_req[2]);
- MPI_Raccumulate(&val[3], 1, MPI_INT, MPI_PROC_NULL, 3, 1, MPI_INT, MPI_REPLACE, window, &pn_req[3]);
+ MPI_Raccumulate(&val[3], 1, MPI_INT, MPI_PROC_NULL, 3, 1, MPI_INT, MPI_REPLACE, window,
+ &pn_req[3]);
assert(pn_req[0] != MPI_REQUEST_NULL);
assert(pn_req[1] != MPI_REQUEST_NULL);
@@ -72,22 +76,23 @@ int main( int argc, char *argv[] )
* to the right. Each process, in turn, performs third-party
* communication via process 0's window. */
if (rank > 0) {
- MPI_Recv(NULL, 0, MPI_BYTE, rank-1, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+ MPI_Recv(NULL, 0, MPI_BYTE, rank - 1, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
}
- MPI_Rget_accumulate(&rank, 1, MPI_INT, &val, 1, MPI_INT, 0, 0, 1, MPI_INT, MPI_REPLACE, window, &gacc_req);
+ MPI_Rget_accumulate(&rank, 1, MPI_INT, &val, 1, MPI_INT, 0, 0, 1, MPI_INT, MPI_REPLACE,
+ window, &gacc_req);
assert(gacc_req != MPI_REQUEST_NULL);
MPI_Wait(&gacc_req, MPI_STATUS_IGNORE);
- exp = (rank + nproc-1) % nproc;
+ exp = (rank + nproc - 1) % nproc;
if (val != exp) {
printf("%d - Got %d, expected %d\n", rank, val, exp);
errors++;
}
- if (rank < nproc-1) {
- MPI_Send(NULL, 0, MPI_BYTE, rank+1, 0, MPI_COMM_WORLD);
+ if (rank < nproc - 1) {
+ MPI_Send(NULL, 0, MPI_BYTE, rank + 1, 0, MPI_COMM_WORLD);
}
MPI_Barrier(MPI_COMM_WORLD);
@@ -95,7 +100,8 @@ int main( int argc, char *argv[] )
MPI_Barrier(MPI_COMM_WORLD);
- if (rank == 0) *buf = nproc-1;
+ if (rank == 0)
+ *buf = nproc - 1;
MPI_Win_sync(window);
/* GET+PUT: Test third-party communication, through rank 0. */
@@ -107,7 +113,7 @@ int main( int argc, char *argv[] )
* to the right. Each process, in turn, performs third-party
* communication via process 0's window. */
if (rank > 0) {
- MPI_Recv(NULL, 0, MPI_BYTE, rank-1, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+ MPI_Recv(NULL, 0, MPI_BYTE, rank - 1, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
}
MPI_Rget(&val, 1, MPI_INT, 0, 0, 1, MPI_INT, window, &req);
@@ -118,15 +124,15 @@ int main( int argc, char *argv[] )
MPI_Put(&rank, 1, MPI_INT, 0, 0, 1, MPI_INT, window);
MPI_Win_flush(0, window);
- exp = (rank + nproc-1) % nproc;
+ exp = (rank + nproc - 1) % nproc;
if (val != exp) {
printf("%d - Got %d, expected %d\n", rank, val, exp);
errors++;
}
- if (rank < nproc-1) {
- MPI_Send(NULL, 0, MPI_BYTE, rank+1, 0, MPI_COMM_WORLD);
+ if (rank < nproc - 1) {
+ MPI_Send(NULL, 0, MPI_BYTE, rank + 1, 0, MPI_COMM_WORLD);
}
MPI_Barrier(MPI_COMM_WORLD);
@@ -134,7 +140,8 @@ int main( int argc, char *argv[] )
MPI_Barrier(MPI_COMM_WORLD);
- if (rank == 0) *buf = nproc-1;
+ if (rank == 0)
+ *buf = nproc - 1;
MPI_Win_sync(window);
/* GET+ACC: Test third-party communication, through rank 0. */
@@ -146,7 +153,7 @@ int main( int argc, char *argv[] )
* to the right. Each process, in turn, performs third-party
* communication via process 0's window. */
if (rank > 0) {
- MPI_Recv(NULL, 0, MPI_BYTE, rank-1, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+ MPI_Recv(NULL, 0, MPI_BYTE, rank - 1, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
}
MPI_Rget(&val, 1, MPI_INT, 0, 0, 1, MPI_INT, window, &req);
@@ -157,15 +164,15 @@ int main( int argc, char *argv[] )
MPI_Accumulate(&rank, 1, MPI_INT, 0, 0, 1, MPI_INT, MPI_REPLACE, window);
MPI_Win_flush(0, window);
- exp = (rank + nproc-1) % nproc;
+ exp = (rank + nproc - 1) % nproc;
if (val != exp) {
printf("%d - Got %d, expected %d\n", rank, val, exp);
errors++;
}
- if (rank < nproc-1) {
- MPI_Send(NULL, 0, MPI_BYTE, rank+1, 0, MPI_COMM_WORLD);
+ if (rank < nproc - 1) {
+ MPI_Send(NULL, 0, MPI_BYTE, rank + 1, 0, MPI_COMM_WORLD);
}
MPI_Barrier(MPI_COMM_WORLD);
@@ -182,10 +189,12 @@ int main( int argc, char *argv[] )
MPI_Win_lock_all(0, window);
- MPI_Rget_accumulate(&val[0], 1, MPI_INT, &res, 1, MPI_INT, target, 0, 1, MPI_INT, MPI_REPLACE, window, &pn_req[0]);
+ MPI_Rget_accumulate(&val[0], 1, MPI_INT, &res, 1, MPI_INT, target, 0, 1, MPI_INT,
+ MPI_REPLACE, window, &pn_req[0]);
MPI_Rget(&val[1], 1, MPI_INT, target, 1, 1, MPI_INT, window, &pn_req[1]);
MPI_Rput(&val[2], 1, MPI_INT, target, 2, 1, MPI_INT, window, &pn_req[2]);
- MPI_Raccumulate(&val[3], 1, MPI_INT, target, 3, 1, MPI_INT, MPI_REPLACE, window, &pn_req[3]);
+ MPI_Raccumulate(&val[3], 1, MPI_INT, target, 3, 1, MPI_INT, MPI_REPLACE, window,
+ &pn_req[3]);
assert(pn_req[0] != MPI_REQUEST_NULL);
assert(pn_req[1] != MPI_REQUEST_NULL);
@@ -207,10 +216,12 @@ int main( int argc, char *argv[] )
MPI_Win_lock_all(0, window);
- MPI_Rget_accumulate(&val[0], 1, MPI_INT, &res, 1, MPI_INT, target, 0, 1, MPI_INT, MPI_REPLACE, window, &pn_req[0]);
+ MPI_Rget_accumulate(&val[0], 1, MPI_INT, &res, 1, MPI_INT, target, 0, 1, MPI_INT,
+ MPI_REPLACE, window, &pn_req[0]);
MPI_Rget(&val[1], 1, MPI_INT, target, 1, 1, MPI_INT, window, &pn_req[1]);
MPI_Rput(&val[2], 1, MPI_INT, target, 2, 1, MPI_INT, window, &pn_req[2]);
- MPI_Raccumulate(&val[3], 1, MPI_INT, target, 3, 1, MPI_INT, MPI_REPLACE, window, &pn_req[3]);
+ MPI_Raccumulate(&val[3], 1, MPI_INT, target, 3, 1, MPI_INT, MPI_REPLACE, window,
+ &pn_req[3]);
assert(pn_req[0] != MPI_REQUEST_NULL);
assert(pn_req[1] != MPI_REQUEST_NULL);
@@ -230,10 +241,12 @@ int main( int argc, char *argv[] )
MPI_Win_lock_all(0, window);
- MPI_Rget_accumulate(&val[0], 1, MPI_INT, &res, 1, MPI_INT, target, 0, 1, MPI_INT, MPI_REPLACE, window, &pn_req[0]);
+ MPI_Rget_accumulate(&val[0], 1, MPI_INT, &res, 1, MPI_INT, target, 0, 1, MPI_INT,
+ MPI_REPLACE, window, &pn_req[0]);
MPI_Rget(&val[1], 1, MPI_INT, target, 1, 1, MPI_INT, window, &pn_req[1]);
MPI_Rput(&val[2], 1, MPI_INT, target, 2, 1, MPI_INT, window, &pn_req[2]);
- MPI_Raccumulate(&val[3], 1, MPI_INT, target, 3, 1, MPI_INT, MPI_REPLACE, window, &pn_req[3]);
+ MPI_Raccumulate(&val[3], 1, MPI_INT, target, 3, 1, MPI_INT, MPI_REPLACE, window,
+ &pn_req[3]);
assert(pn_req[0] != MPI_REQUEST_NULL);
assert(pn_req[1] != MPI_REQUEST_NULL);
@@ -255,10 +268,12 @@ int main( int argc, char *argv[] )
MPI_Win_lock_all(0, window);
- MPI_Rget_accumulate(&val[0], 1, MPI_INT, &res, 1, MPI_INT, target, 0, 1, MPI_INT, MPI_REPLACE, window, &pn_req[0]);
+ MPI_Rget_accumulate(&val[0], 1, MPI_INT, &res, 1, MPI_INT, target, 0, 1, MPI_INT,
+ MPI_REPLACE, window, &pn_req[0]);
MPI_Rget(&val[1], 1, MPI_INT, target, 1, 1, MPI_INT, window, &pn_req[1]);
MPI_Rput(&val[2], 1, MPI_INT, target, 2, 1, MPI_INT, window, &pn_req[2]);
- MPI_Raccumulate(&val[3], 1, MPI_INT, target, 3, 1, MPI_INT, MPI_REPLACE, window, &pn_req[3]);
+ MPI_Raccumulate(&val[3], 1, MPI_INT, target, 3, 1, MPI_INT, MPI_REPLACE, window,
+ &pn_req[3]);
assert(pn_req[0] != MPI_REQUEST_NULL);
assert(pn_req[1] != MPI_REQUEST_NULL);
@@ -273,7 +288,8 @@ int main( int argc, char *argv[] )
}
MPI_Win_free(&window);
- if (buf) MPI_Free_mem(buf);
+ if (buf)
+ MPI_Free_mem(buf);
MPI_Reduce(&errors, &all_errors, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
diff --git a/test/mpi/rma/rmanull.c b/test/mpi/rma/rmanull.c
index cb228f3..70d092a 100644
--- a/test/mpi/rma/rmanull.c
+++ b/test/mpi/rma/rmanull.c
@@ -16,14 +16,14 @@
if (err) { \
errs++; \
if (errs < 10) { \
- MTestPrintErrorMsg( "PROC_NULL to " op_name_, err ); \
+ MTestPrintErrorMsg("PROC_NULL to " op_name_, err); \
} \
} \
- err = MPI_Win_fence( 0, win ); \
+ err = MPI_Win_fence(0, win); \
if (err) { \
errs++; \
if (errs < 10) { \
- MTestPrintErrorMsg( "Fence after " op_name_, err ); \
+ MTestPrintErrorMsg("Fence after " op_name_, err); \
} \
} \
} while (0)
@@ -36,21 +36,21 @@
if (err) { \
errs++; \
if (errs < 10) { \
- MTestPrintErrorMsg( "Lock before" op_name_, err ); \
+ MTestPrintErrorMsg("Lock before" op_name_, err); \
} \
} \
err = fcn_call_ \
if (err) { \
errs++; \
if (errs < 10) { \
- MTestPrintErrorMsg( "PROC_NULL to " op_name_, err ); \
+ MTestPrintErrorMsg("PROC_NULL to " op_name_, err); \
} \
} \
- err = MPI_Win_unlock( MPI_PROC_NULL, win ); \
+ err = MPI_Win_unlock(MPI_PROC_NULL, win); \
if (err) { \
errs++; \
if (errs < 10) { \
- MTestPrintErrorMsg( "Unlock after " op_name_, err ); \
+ MTestPrintErrorMsg("Unlock after " op_name_, err); \
} \
} \
} while (0)
@@ -63,28 +63,28 @@
if (err) { \
errs++; \
if (errs < 10) { \
- MTestPrintErrorMsg( "Lock before" op_name_, err ); \
+ MTestPrintErrorMsg("Lock before" op_name_, err); \
} \
} \
err = fcn_call_ \
if (err) { \
errs++; \
if (errs < 10) { \
- MTestPrintErrorMsg( "PROC_NULL to " op_name_, err ); \
+ MTestPrintErrorMsg("PROC_NULL to " op_name_, err); \
} \
} \
- err = MPI_Win_unlock( MPI_PROC_NULL, win ); \
+ err = MPI_Win_unlock(MPI_PROC_NULL, win); \
if (err) { \
errs++; \
if (errs < 10) { \
- MTestPrintErrorMsg( "Unlock after " op_name_, err ); \
+ MTestPrintErrorMsg("Unlock after " op_name_, err); \
} \
} \
- err = MPI_Wait( &req_, MPI_STATUS_IGNORE ); \
+ err = MPI_Wait(&req_, MPI_STATUS_IGNORE); \
if (err) { \
errs++; \
if (errs < 10) { \
- MTestPrintErrorMsg( "Wait after " op_name_, err ); \
+ MTestPrintErrorMsg("Wait after " op_name_, err); \
} \
} \
} while (0)
@@ -93,139 +93,127 @@
static char MTEST_Descrip[] = "Test the MPI_PROC_NULL is a valid target";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
- int errs = 0, err;
- int rank, size;
- int *buf, bufsize;
- int *result;
- int *rmabuf, rsize, rcount;
- MPI_Comm comm;
- MPI_Win win;
- MPI_Request req;
+ int errs = 0, err;
+ int rank, size;
+ int *buf, bufsize;
+ int *result;
+ int *rmabuf, rsize, rcount;
+ MPI_Comm comm;
+ MPI_Win win;
+ MPI_Request req;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
bufsize = 256 * sizeof(int);
- buf = (int *)malloc( bufsize );
+ buf = (int *) malloc(bufsize);
if (!buf) {
- fprintf( stderr, "Unable to allocated %d bytes\n", bufsize );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Unable to allocated %d bytes\n", bufsize);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- result = (int *)malloc( bufsize );
+ result = (int *) malloc(bufsize);
if (!result) {
- fprintf( stderr, "Unable to allocated %d bytes\n", bufsize );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Unable to allocated %d bytes\n", bufsize);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- rcount = 16;
- rsize = rcount * sizeof(int);
- rmabuf = (int *)malloc( rsize );
+ rcount = 16;
+ rsize = rcount * sizeof(int);
+ rmabuf = (int *) malloc(rsize);
if (!rmabuf) {
- fprintf( stderr, "Unable to allocated %d bytes\n", rsize );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Unable to allocated %d bytes\n", rsize);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
-
- /* The following illustrates the use of the routines to
- run through a selection of communicators and datatypes.
- Use subsets of these for tests that do not involve combinations
- of communicators, datatypes, and counts of datatypes */
- while (MTestGetIntracommGeneral( &comm, 1, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
- /* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
-
- MPI_Win_create( buf, bufsize, sizeof(int), MPI_INFO_NULL, comm, &win );
- /* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Win_set_errhandler( win, MPI_ERRORS_RETURN );
+
+ /* The following illustrates the use of the routines to
+ * run through a selection of communicators and datatypes.
+ * Use subsets of these for tests that do not involve combinations
+ * of communicators, datatypes, and counts of datatypes */
+ while (MTestGetIntracommGeneral(&comm, 1, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ /* Determine the sender and receiver */
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+
+ MPI_Win_create(buf, bufsize, sizeof(int), MPI_INFO_NULL, comm, &win);
+ /* To improve reporting of problems about operations, we
+ * change the error handler to errors return */
+ MPI_Win_set_errhandler(win, MPI_ERRORS_RETURN);
/** TEST OPERATIONS USING ACTIVE TARGET (FENCE) SYNCHRONIZATION **/
- MPI_Win_fence( 0, win );
+ MPI_Win_fence(0, win);
TEST_FENCE_OP("Put",
- MPI_Put( rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0,
- rcount, MPI_INT, win );
- );
+ MPI_Put(rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0, rcount, MPI_INT, win);
+);
TEST_FENCE_OP("Get",
- MPI_Get( rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0,
- rcount, MPI_INT, win );
- );
+ MPI_Get(rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0, rcount, MPI_INT, win);
+);
TEST_FENCE_OP("Accumulate",
- MPI_Accumulate( rmabuf, rcount, MPI_INT, MPI_PROC_NULL,
- 0, rcount, MPI_INT, MPI_SUM, win );
- );
+ MPI_Accumulate(rmabuf, rcount, MPI_INT, MPI_PROC_NULL,
+ 0, rcount, MPI_INT, MPI_SUM, win);
+);
TEST_FENCE_OP("Get accumulate",
- MPI_Get_accumulate( rmabuf, rcount, MPI_INT, result,
- rcount, MPI_INT, MPI_PROC_NULL, 0,
- rcount, MPI_INT, MPI_SUM, win );
- );
+ MPI_Get_accumulate(rmabuf, rcount, MPI_INT, result,
+ rcount, MPI_INT, MPI_PROC_NULL, 0,
+ rcount, MPI_INT, MPI_SUM, win);
+);
TEST_FENCE_OP("Fetch and op",
- MPI_Fetch_and_op( rmabuf, result, MPI_INT, MPI_PROC_NULL,
- 0, MPI_SUM, win );
- );
+ MPI_Fetch_and_op(rmabuf, result, MPI_INT, MPI_PROC_NULL, 0, MPI_SUM, win);
+);
TEST_FENCE_OP("Compare and swap",
- MPI_Compare_and_swap( rmabuf, &rank, result, MPI_INT,
- MPI_PROC_NULL, 0, win );
- );
+ MPI_Compare_and_swap(rmabuf, &rank, result, MPI_INT, MPI_PROC_NULL, 0, win);
+);
/** TEST OPERATIONS USING PASSIVE TARGET SYNCHRONIZATION **/
- TEST_PT_OP("Put",
- MPI_Put( rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0, rcount,
- MPI_INT, win );
- );
- TEST_PT_OP("Get",
- MPI_Get( rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0, rcount,
- MPI_INT, win );
- );
+ TEST_PT_OP("Put", MPI_Put(rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0, rcount, MPI_INT, win);
+);
+ TEST_PT_OP("Get", MPI_Get(rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0, rcount, MPI_INT, win);
+);
TEST_PT_OP("Accumulate",
- MPI_Accumulate( rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0,
- rcount, MPI_INT, MPI_SUM, win );
- );
+ MPI_Accumulate(rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0,
+ rcount, MPI_INT, MPI_SUM, win);
+);
TEST_PT_OP("Get accumulate",
- MPI_Get_accumulate( rmabuf, rcount, MPI_INT, result, rcount,
- MPI_INT, MPI_PROC_NULL, 0, rcount,
- MPI_INT, MPI_SUM, win );
- );
+ MPI_Get_accumulate(rmabuf, rcount, MPI_INT, result, rcount,
+ MPI_INT, MPI_PROC_NULL, 0, rcount, MPI_INT, MPI_SUM, win);
+);
TEST_PT_OP("Fetch and op",
- MPI_Fetch_and_op( rmabuf, result, MPI_INT, MPI_PROC_NULL, 0,
- MPI_SUM, win );
- );
+ MPI_Fetch_and_op(rmabuf, result, MPI_INT, MPI_PROC_NULL, 0, MPI_SUM, win);
+);
TEST_PT_OP("Compare and swap",
- MPI_Compare_and_swap( rmabuf, &rank, result, MPI_INT,
- MPI_PROC_NULL, 0, win );
- );
+ MPI_Compare_and_swap(rmabuf, &rank, result, MPI_INT, MPI_PROC_NULL, 0, win);
+);
/** TEST REQUEST-BASED OPERATIONS (PASSIVE TARGET ONLY) **/
TEST_REQ_OP("Rput", req,
- MPI_Rput( rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0, rcount,
- MPI_INT, win, &req );
- );
+ MPI_Rput(rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0, rcount, MPI_INT, win, &req);
+);
TEST_REQ_OP("Rget", req,
- MPI_Rget( rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0, rcount,
- MPI_INT, win, &req );
- );
+ MPI_Rget(rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0, rcount, MPI_INT, win, &req);
+);
TEST_REQ_OP("Raccumulate", req,
- MPI_Raccumulate( rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0,
- rcount, MPI_INT, MPI_SUM, win, &req );
- );
+ MPI_Raccumulate(rmabuf, rcount, MPI_INT, MPI_PROC_NULL, 0,
+ rcount, MPI_INT, MPI_SUM, win, &req);
+);
TEST_REQ_OP("Rget_accumulate", req,
- MPI_Rget_accumulate( rmabuf, rcount, MPI_INT, result,
- rcount, MPI_INT, MPI_PROC_NULL, 0,
- rcount, MPI_INT, MPI_SUM, win, &req );
- );
+ MPI_Rget_accumulate(rmabuf, rcount, MPI_INT, result,
+ rcount, MPI_INT, MPI_PROC_NULL, 0,
+ rcount, MPI_INT, MPI_SUM, win, &req);
+);
- MPI_Win_free( &win );
+ MPI_Win_free(&win);
MTestFreeComm(&comm);
}
- free( result );
- free( buf );
- free( rmabuf );
- MTest_Finalize( errs );
+ free(result);
+ free(buf);
+ free(rmabuf);
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/rma/rmazero.c b/test/mpi/rma/rmazero.c
index 9e27b77..78bbbe3 100644
--- a/test/mpi/rma/rmazero.c
+++ b/test/mpi/rma/rmazero.c
@@ -18,14 +18,14 @@
if (err) { \
errs++; \
if (errs < 10) { \
- MTestPrintErrorMsg( "Zero-byte op " op_name_, err ); \
+ MTestPrintErrorMsg("Zero-byte op " op_name_, err); \
} \
} \
- err = MPI_Win_fence( 0, win ); \
+ err = MPI_Win_fence(0, win); \
if (err) { \
errs++; \
if (errs < 10) { \
- MTestPrintErrorMsg( "Fence after " op_name_, err ); \
+ MTestPrintErrorMsg("Fence after " op_name_, err); \
} \
} \
} while (0)
@@ -38,21 +38,21 @@
if (err) { \
errs++; \
if (errs < 10) { \
- MTestPrintErrorMsg( "Lock before" op_name_, err ); \
+ MTestPrintErrorMsg("Lock before" op_name_, err); \
} \
} \
err = fcn_call_ \
if (err) { \
errs++; \
if (errs < 10) { \
- MTestPrintErrorMsg( "Zero-byte op " op_name_, err ); \
+ MTestPrintErrorMsg("Zero-byte op " op_name_, err); \
} \
} \
- err = MPI_Win_unlock( TARGET, win ); \
+ err = MPI_Win_unlock(TARGET, win); \
if (err) { \
errs++; \
if (errs < 10) { \
- MTestPrintErrorMsg( "Unlock after " op_name_, err ); \
+ MTestPrintErrorMsg("Unlock after " op_name_, err); \
} \
} \
} while (0)
@@ -65,28 +65,28 @@
if (err) { \
errs++; \
if (errs < 10) { \
- MTestPrintErrorMsg( "Lock before" op_name_, err ); \
+ MTestPrintErrorMsg("Lock before" op_name_, err); \
} \
} \
err = fcn_call_ \
if (err) { \
errs++; \
if (errs < 10) { \
- MTestPrintErrorMsg( "Zero-byte op " op_name_, err ); \
+ MTestPrintErrorMsg("Zero-byte op " op_name_, err); \
} \
} \
- err = MPI_Win_unlock( TARGET, win ); \
+ err = MPI_Win_unlock(TARGET, win); \
if (err) { \
errs++; \
if (errs < 10) { \
- MTestPrintErrorMsg( "Unlock after " op_name_, err ); \
+ MTestPrintErrorMsg("Unlock after " op_name_, err); \
} \
} \
- err = MPI_Wait( &req_, MPI_STATUS_IGNORE ); \
+ err = MPI_Wait(&req_, MPI_STATUS_IGNORE); \
if (err) { \
errs++; \
if (errs < 10) { \
- MTestPrintErrorMsg( "Wait after " op_name_, err ); \
+ MTestPrintErrorMsg("Wait after " op_name_, err); \
} \
} \
} while (0)
@@ -95,37 +95,37 @@
static char MTEST_Descrip[] = "Test handling of zero-byte transfers";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
- int errs = 0, err;
- int rank, size;
- int *buf, bufsize;
- int *result;
- int *rmabuf, rsize, rcount;
- MPI_Comm comm;
- MPI_Win win;
- MPI_Request req;
- MPI_Datatype derived_dtp;
-
- MTest_Init( &argc, &argv );
+ int errs = 0, err;
+ int rank, size;
+ int *buf, bufsize;
+ int *result;
+ int *rmabuf, rsize, rcount;
+ MPI_Comm comm;
+ MPI_Win win;
+ MPI_Request req;
+ MPI_Datatype derived_dtp;
+
+ MTest_Init(&argc, &argv);
bufsize = 256 * sizeof(int);
- buf = (int *)malloc( bufsize );
+ buf = (int *) malloc(bufsize);
if (!buf) {
- fprintf( stderr, "Unable to allocated %d bytes\n", bufsize );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Unable to allocated %d bytes\n", bufsize);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- result = (int *)malloc( bufsize );
+ result = (int *) malloc(bufsize);
if (!result) {
- fprintf( stderr, "Unable to allocated %d bytes\n", bufsize );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Unable to allocated %d bytes\n", bufsize);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- rcount = 16;
- rsize = rcount * sizeof(int);
- rmabuf = (int *)malloc( rsize );
+ rcount = 16;
+ rsize = rcount * sizeof(int);
+ rmabuf = (int *) malloc(rsize);
if (!rmabuf) {
- fprintf( stderr, "Unable to allocated %d bytes\n", rsize );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Unable to allocated %d bytes\n", rsize);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
MPI_Type_contiguous(2, MPI_INT, &derived_dtp);
@@ -133,106 +133,94 @@ int main( int argc, char *argv[] )
/* The following loop is used to run through a series of communicators
* that are subsets of MPI_COMM_WORLD, of size 1 or greater. */
- while (MTestGetIntracommGeneral( &comm, 1, 1 )) {
+ while (MTestGetIntracommGeneral(&comm, 1, 1)) {
int count = 0;
- if (comm == MPI_COMM_NULL) continue;
+ if (comm == MPI_COMM_NULL)
+ continue;
/* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
- MPI_Win_create( buf, bufsize, 2*sizeof(int), MPI_INFO_NULL, comm, &win );
+ MPI_Win_create(buf, bufsize, 2 * sizeof(int), MPI_INFO_NULL, comm, &win);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Win_set_errhandler( win, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Win_set_errhandler(win, MPI_ERRORS_RETURN);
/** TEST OPERATIONS USING ACTIVE TARGET (FENCE) SYNCHRONIZATION **/
- MPI_Win_fence( 0, win );
+ MPI_Win_fence(0, win);
- TEST_FENCE_OP("Put",
- MPI_Put( rmabuf, count, MPI_INT, TARGET, 0,
- count, MPI_INT, win );
- );
+ TEST_FENCE_OP("Put", MPI_Put(rmabuf, count, MPI_INT, TARGET, 0, count, MPI_INT, win);
+);
- TEST_FENCE_OP("Get",
- MPI_Get( rmabuf, count, MPI_INT, TARGET, 0,
- count, MPI_INT, win );
- );
+ TEST_FENCE_OP("Get", MPI_Get(rmabuf, count, MPI_INT, TARGET, 0, count, MPI_INT, win);
+);
TEST_FENCE_OP("Accumulate",
- MPI_Accumulate( rmabuf, count, MPI_INT, TARGET,
- 0, count, MPI_INT, MPI_SUM, win );
- );
+ MPI_Accumulate(rmabuf, count, MPI_INT, TARGET,
+ 0, count, MPI_INT, MPI_SUM, win);
+);
TEST_FENCE_OP("Accumulate_derived",
- MPI_Accumulate( rmabuf, count, derived_dtp, TARGET,
- 0, count, derived_dtp, MPI_SUM, win );
- );
+ MPI_Accumulate(rmabuf, count, derived_dtp, TARGET,
+ 0, count, derived_dtp, MPI_SUM, win);
+);
TEST_FENCE_OP("Get accumulate",
- MPI_Get_accumulate( rmabuf, count, MPI_INT, result,
- count, MPI_INT, TARGET, 0,
- count, MPI_INT, MPI_SUM, win );
- );
+ MPI_Get_accumulate(rmabuf, count, MPI_INT, result,
+ count, MPI_INT, TARGET, 0, count, MPI_INT, MPI_SUM, win);
+);
/* Note: It's not possible to generate a zero-byte FOP or CAS */
/** TEST OPERATIONS USING PASSIVE TARGET SYNCHRONIZATION **/
- TEST_PT_OP("Put",
- MPI_Put( rmabuf, count, MPI_INT, TARGET, 0, count,
- MPI_INT, win );
- );
- TEST_PT_OP("Get",
- MPI_Get( rmabuf, count, MPI_INT, TARGET, 0, count,
- MPI_INT, win );
- );
+ TEST_PT_OP("Put", MPI_Put(rmabuf, count, MPI_INT, TARGET, 0, count, MPI_INT, win);
+);
+ TEST_PT_OP("Get", MPI_Get(rmabuf, count, MPI_INT, TARGET, 0, count, MPI_INT, win);
+);
TEST_PT_OP("Accumulate",
- MPI_Accumulate( rmabuf, count, MPI_INT, TARGET, 0,
- count, MPI_INT, MPI_SUM, win );
- );
+ MPI_Accumulate(rmabuf, count, MPI_INT, TARGET, 0, count, MPI_INT, MPI_SUM, win);
+);
TEST_PT_OP("Accumulate_derived",
- MPI_Accumulate( rmabuf, count, derived_dtp, TARGET, 0,
- count, derived_dtp, MPI_SUM, win );
- );
+ MPI_Accumulate(rmabuf, count, derived_dtp, TARGET, 0,
+ count, derived_dtp, MPI_SUM, win);
+);
TEST_PT_OP("Get accumulate",
- MPI_Get_accumulate( rmabuf, count, MPI_INT, result, count,
- MPI_INT, TARGET, 0, count,
- MPI_INT, MPI_SUM, win );
- );
+ MPI_Get_accumulate(rmabuf, count, MPI_INT, result, count,
+ MPI_INT, TARGET, 0, count, MPI_INT, MPI_SUM, win);
+);
/* Note: It's not possible to generate a zero-byte FOP or CAS */
/** TEST REQUEST-BASED OPERATIONS (PASSIVE TARGET ONLY) **/
TEST_REQ_OP("Rput", req,
- MPI_Rput( rmabuf, count, MPI_INT, TARGET, 0, count,
- MPI_INT, win, &req );
- );
+ MPI_Rput(rmabuf, count, MPI_INT, TARGET, 0, count, MPI_INT, win, &req);
+);
TEST_REQ_OP("Rget", req,
- MPI_Rget( rmabuf, count, MPI_INT, TARGET, 0, count,
- MPI_INT, win, &req );
- );
+ MPI_Rget(rmabuf, count, MPI_INT, TARGET, 0, count, MPI_INT, win, &req);
+);
TEST_REQ_OP("Raccumulate", req,
- MPI_Raccumulate( rmabuf, count, MPI_INT, TARGET, 0,
- count, MPI_INT, MPI_SUM, win, &req );
- );
+ MPI_Raccumulate(rmabuf, count, MPI_INT, TARGET, 0,
+ count, MPI_INT, MPI_SUM, win, &req);
+);
TEST_REQ_OP("Raccumulate_derived", req,
- MPI_Raccumulate( rmabuf, count, derived_dtp, TARGET, 0,
- count, derived_dtp, MPI_SUM, win, &req );
- );
+ MPI_Raccumulate(rmabuf, count, derived_dtp, TARGET, 0,
+ count, derived_dtp, MPI_SUM, win, &req);
+);
TEST_REQ_OP("Rget_accumulate", req,
- MPI_Rget_accumulate( rmabuf, count, MPI_INT, result,
- count, MPI_INT, TARGET, 0,
- count, MPI_INT, MPI_SUM, win, &req );
- );
+ MPI_Rget_accumulate(rmabuf, count, MPI_INT, result,
+ count, MPI_INT, TARGET, 0,
+ count, MPI_INT, MPI_SUM, win, &req);
+);
- MPI_Win_free( &win );
+ MPI_Win_free(&win);
MTestFreeComm(&comm);
}
MPI_Type_free(&derived_dtp);
- free( result );
- free( buf );
- free( rmabuf );
- MTest_Finalize( errs );
+ free(result);
+ free(buf);
+ free(rmabuf);
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/rma/selfrma.c b/test/mpi/rma/selfrma.c
index ca8ae4b..701fcea 100644
--- a/test/mpi/rma/selfrma.c
+++ b/test/mpi/rma/selfrma.c
@@ -14,99 +14,95 @@
static char MTEST_Descrip[] = "RMA to self";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int rank, size, i, j;
- MPI_Comm comm;
- MPI_Win win;
- int *winbuf, count;
- int *sbuf, scount, vcount;
- MPI_Datatype vectype;
+ MPI_Comm comm;
+ MPI_Win win;
+ int *winbuf, count;
+ int *sbuf, scount, vcount;
+ MPI_Datatype vectype;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
/* Allocate and initialize sbuf */
scount = 1000;
- count = 1000;
- sbuf = (int *)malloc( scount * sizeof(int) );
+ count = 1000;
+ sbuf = (int *) malloc(scount * sizeof(int));
if (!sbuf) {
- fprintf( stderr, "Could not allocate send buffer f size %d\n",
- scount );
- MPI_Abort( MPI_COMM_WORLD, 0 );
+ fprintf(stderr, "Could not allocate send buffer f size %d\n", scount);
+ MPI_Abort(MPI_COMM_WORLD, 0);
}
- for (i=0; i<scount; i++) sbuf[i] = i;
+ for (i = 0; i < scount; i++)
+ sbuf[i] = i;
- MPI_Alloc_mem( count*sizeof(int), MPI_INFO_NULL, &winbuf );
+ MPI_Alloc_mem(count * sizeof(int), MPI_INFO_NULL, &winbuf);
/* This is a simple vector type */
vcount = count / 4;
- MPI_Type_vector( vcount, 1, 2, MPI_INT, &vectype );
- MPI_Type_commit( &vectype );
- MPI_Win_create( winbuf, count * sizeof(int), sizeof(int), MPI_INFO_NULL,
- comm, &win );
+ MPI_Type_vector(vcount, 1, 2, MPI_INT, &vectype);
+ MPI_Type_commit(&vectype);
+ MPI_Win_create(winbuf, count * sizeof(int), sizeof(int), MPI_INFO_NULL, comm, &win);
+
+ /* Check with different combination of types, including non-contig on
+ * both sides */
- /* Check with different combination of types, including non-contig on
- both sides */
-
/* Clear winbuf */
- memset( winbuf, 0, count*sizeof(int) );
- MPI_Win_lock( MPI_LOCK_EXCLUSIVE, rank, 0, win );
- MPI_Put( sbuf, 1, vectype, rank, 0, 1, vectype, win );
- MPI_Win_unlock( rank, win );
+ memset(winbuf, 0, count * sizeof(int));
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, win);
+ MPI_Put(sbuf, 1, vectype, rank, 0, 1, vectype, win);
+ MPI_Win_unlock(rank, win);
/* Check results */
j = 0;
- for (i=0; i<vcount; i++) {
- if (winbuf[j] != sbuf[j]) {
- errs ++;
- fprintf( stderr, "VecPut: winbuf[%d] = %d, should = %d\n",
- winbuf[j], j, sbuf[j] );
- }
- j += 2;
+ for (i = 0; i < vcount; i++) {
+ if (winbuf[j] != sbuf[j]) {
+ errs++;
+ fprintf(stderr, "VecPut: winbuf[%d] = %d, should = %d\n", winbuf[j], j, sbuf[j]);
+ }
+ j += 2;
}
- memset( winbuf, 0, count*sizeof(int) );
- MPI_Win_lock( MPI_LOCK_SHARED, rank, 0, win );
- MPI_Accumulate( sbuf, 1, vectype, rank, 0, 1, vectype, MPI_SUM, win );
- MPI_Win_unlock( rank, win );
+ memset(winbuf, 0, count * sizeof(int));
+ MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, win);
+ MPI_Accumulate(sbuf, 1, vectype, rank, 0, 1, vectype, MPI_SUM, win);
+ MPI_Win_unlock(rank, win);
/* Check results */
j = 0;
- for (i=0; i<vcount; i++) {
- if (winbuf[j] != sbuf[j]) {
- errs ++;
- fprintf( stderr, "VecAcc: winbuf[%d] = %d, should = %d\n",
- winbuf[j], j, sbuf[j] );
- }
- j += 2;
+ for (i = 0; i < vcount; i++) {
+ if (winbuf[j] != sbuf[j]) {
+ errs++;
+ fprintf(stderr, "VecAcc: winbuf[%d] = %d, should = %d\n", winbuf[j], j, sbuf[j]);
+ }
+ j += 2;
}
/* Now, use get to fetch back the results that we just wrote */
- memset( sbuf, 0, count*sizeof(int) );
- MPI_Win_lock( MPI_LOCK_SHARED, rank, 0, win );
- MPI_Get( sbuf, 1, vectype, rank, 0, 1, vectype, win );
- MPI_Win_unlock( rank, win );
+ memset(sbuf, 0, count * sizeof(int));
+ MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, win);
+ MPI_Get(sbuf, 1, vectype, rank, 0, 1, vectype, win);
+ MPI_Win_unlock(rank, win);
/* Check results */
j = 0;
- for (i=0; i<vcount; i++) {
- if (winbuf[j] != sbuf[j]) {
- errs ++;
- fprintf( stderr, "VecAcc: winbuf[%d] = %d, should = %d\n",
- winbuf[j], j, sbuf[j] );
- }
- j += 2;
+ for (i = 0; i < vcount; i++) {
+ if (winbuf[j] != sbuf[j]) {
+ errs++;
+ fprintf(stderr, "VecAcc: winbuf[%d] = %d, should = %d\n", winbuf[j], j, sbuf[j]);
+ }
+ j += 2;
}
- MPI_Win_free( &win );
- MPI_Free_mem( winbuf );
- free( sbuf );
- MPI_Type_free( &vectype );
+ MPI_Win_free(&win);
+ MPI_Free_mem(winbuf);
+ free(sbuf);
+ MPI_Type_free(&vectype);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
diff --git a/test/mpi/rma/squelch.h b/test/mpi/rma/squelch.h
index 2e469d3..e8515fb 100644
--- a/test/mpi/rma/squelch.h
+++ b/test/mpi/rma/squelch.h
@@ -1,9 +1,9 @@
#ifndef SQUELCH_H_INCLUDED
#define SQUELCH_H_INCLUDED
-static const int SQ_LIMIT = 10;
-static int SQ_COUNT = 0;
-static int SQ_VERBOSE = 0;
+static const int SQ_LIMIT = 10;
+static int SQ_COUNT = 0;
+static int SQ_VERBOSE = 0;
#define SQUELCH(X) \
do { \
diff --git a/test/mpi/rma/strided_acc_indexed.c b/test/mpi/rma/strided_acc_indexed.c
index ac54f52..e16ac1f 100644
--- a/test/mpi/rma/strided_acc_indexed.c
+++ b/test/mpi/rma/strided_acc_indexed.c
@@ -6,7 +6,7 @@
/* One-Sided MPI 2-D Strided Accumulate Test
*
- * Author: James Dinan <dinan at mcs.anl.gov>
+ * Author: James Dinan <dinan at mcs.anl.gov>
* Date : December, 2010
*
* This code performs N accumulates into a 2d patch of a shared array. The
@@ -28,7 +28,8 @@
#define SUB_YDIM 8
#define ITERATIONS 1
-int main(int argc, char **argv) {
+int main(int argc, char **argv)
+{
int itr, i, j, rank, nranks, peer, bufsize, errors;
double *win_buf, *src_buf;
MPI_Win buf_win;
@@ -42,51 +43,51 @@ int main(int argc, char **argv) {
MPI_Alloc_mem(bufsize, MPI_INFO_NULL, &win_buf);
MPI_Alloc_mem(bufsize, MPI_INFO_NULL, &src_buf);
- for (i = 0; i < XDIM*YDIM; i++) {
+ for (i = 0; i < XDIM * YDIM; i++) {
*(win_buf + i) = -1.0;
*(src_buf + i) = 1.0 + rank;
}
MPI_Win_create(win_buf, bufsize, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &buf_win);
- peer = (rank+1) % nranks;
+ peer = (rank + 1) % nranks;
/* Perform ITERATIONS strided accumulate operations */
for (itr = 0; itr < ITERATIONS; itr++) {
- MPI_Aint idx_loc[SUB_YDIM];
- int idx_rem[SUB_YDIM];
- int blk_len[SUB_YDIM];
- MPI_Datatype src_type, dst_type;
-
- for (i = 0; i < SUB_YDIM; i++) {
- MPI_Get_address(&src_buf[i*XDIM], &idx_loc[i]);
- idx_rem[i] = i*XDIM;
- blk_len[i] = SUB_XDIM;
- }
+ MPI_Aint idx_loc[SUB_YDIM];
+ int idx_rem[SUB_YDIM];
+ int blk_len[SUB_YDIM];
+ MPI_Datatype src_type, dst_type;
+
+ for (i = 0; i < SUB_YDIM; i++) {
+ MPI_Get_address(&src_buf[i * XDIM], &idx_loc[i]);
+ idx_rem[i] = i * XDIM;
+ blk_len[i] = SUB_XDIM;
+ }
#ifdef ABSOLUTE
- MPI_Type_hindexed(SUB_YDIM, blk_len, idx_loc, MPI_DOUBLE, &src_type);
+ MPI_Type_hindexed(SUB_YDIM, blk_len, idx_loc, MPI_DOUBLE, &src_type);
#else
- MPI_Type_indexed(SUB_YDIM, blk_len, idx_rem, MPI_DOUBLE, &src_type);
+ MPI_Type_indexed(SUB_YDIM, blk_len, idx_rem, MPI_DOUBLE, &src_type);
#endif
- MPI_Type_indexed(SUB_YDIM, blk_len, idx_rem, MPI_DOUBLE, &dst_type);
+ MPI_Type_indexed(SUB_YDIM, blk_len, idx_rem, MPI_DOUBLE, &dst_type);
- MPI_Type_commit(&src_type);
- MPI_Type_commit(&dst_type);
+ MPI_Type_commit(&src_type);
+ MPI_Type_commit(&dst_type);
- MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
#ifdef ABSOLUTE
- MPI_Accumulate(MPI_BOTTOM, 1, src_type, peer, 0, 1, dst_type, MPI_SUM, buf_win);
+ MPI_Accumulate(MPI_BOTTOM, 1, src_type, peer, 0, 1, dst_type, MPI_SUM, buf_win);
#else
- MPI_Accumulate(src_buf, 1, src_type, peer, 0, 1, dst_type, MPI_SUM, buf_win);
+ MPI_Accumulate(src_buf, 1, src_type, peer, 0, 1, dst_type, MPI_SUM, buf_win);
#endif
- MPI_Win_unlock(peer, buf_win);
+ MPI_Win_unlock(peer, buf_win);
- MPI_Type_free(&src_type);
- MPI_Type_free(&dst_type);
+ MPI_Type_free(&src_type);
+ MPI_Type_free(&dst_type);
}
MPI_Barrier(MPI_COMM_WORLD);
@@ -96,40 +97,40 @@ int main(int argc, char **argv) {
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, buf_win);
errors = 0;
for (i = 0; i < SUB_XDIM; i++) {
- for (j = 0; j < SUB_YDIM; j++) {
- const double actual = *(win_buf + i + j*XDIM);
- const double expected = -1.0 + (1.0 + ((rank+nranks-1)%nranks)) * (ITERATIONS);
- if (fabs(actual - expected) > 1.0e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = 0; j < SUB_YDIM; j++) {
+ const double actual = *(win_buf + i + j * XDIM);
+ const double expected = -1.0 + (1.0 + ((rank + nranks - 1) % nranks)) * (ITERATIONS);
+ if (fabs(actual - expected) > 1.0e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
for (i = SUB_XDIM; i < XDIM; i++) {
- for (j = 0; j < SUB_YDIM; j++) {
- const double actual = *(win_buf + i + j*XDIM);
- const double expected = -1.0;
- if (fabs(actual - expected) > 1.0e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = 0; j < SUB_YDIM; j++) {
+ const double actual = *(win_buf + i + j * XDIM);
+ const double expected = -1.0;
+ if (fabs(actual - expected) > 1.0e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
for (i = 0; i < XDIM; i++) {
- for (j = SUB_YDIM; j < YDIM; j++) {
- const double actual = *(win_buf + i + j*XDIM);
- const double expected = -1.0;
- if (fabs(actual - expected) > 1.0e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = SUB_YDIM; j < YDIM; j++) {
+ const double actual = *(win_buf + i + j * XDIM);
+ const double expected = -1.0;
+ if (fabs(actual - expected) > 1.0e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
MPI_Win_unlock(rank, buf_win);
@@ -137,7 +138,7 @@ int main(int argc, char **argv) {
MPI_Free_mem(win_buf);
MPI_Free_mem(src_buf);
- MTest_Finalize( errors );
+ MTest_Finalize(errors);
MPI_Finalize();
- return MTestReturnValue( errors );
+ return MTestReturnValue(errors);
}
diff --git a/test/mpi/rma/strided_acc_onelock.c b/test/mpi/rma/strided_acc_onelock.c
index 55ecde2..529d628 100644
--- a/test/mpi/rma/strided_acc_onelock.c
+++ b/test/mpi/rma/strided_acc_onelock.c
@@ -6,7 +6,7 @@
/* One-Sided MPI 2-D Strided Accumulate Test
*
- * Author: James Dinan <dinan at mcs.anl.gov>
+ * Author: James Dinan <dinan at mcs.anl.gov>
* Date : December, 2010
*
* This code performs one-sided accumulate into a 2d patch of a shared array.
@@ -19,11 +19,12 @@
#include "mpitest.h"
#include "squelch.h"
-#define XDIM 1024
+#define XDIM 1024
#define YDIM 1024
#define ITERATIONS 10
-int main(int argc, char **argv) {
+int main(int argc, char **argv)
+{
int i, j, rank, nranks, peer, bufsize, errors;
double *buffer, *src_buf;
MPI_Win buf_win;
@@ -37,41 +38,42 @@ int main(int argc, char **argv) {
MPI_Alloc_mem(bufsize, MPI_INFO_NULL, &buffer);
MPI_Alloc_mem(bufsize, MPI_INFO_NULL, &src_buf);
- for (i = 0; i < XDIM*YDIM; i++) {
- *(buffer + i) = 1.0 + rank;
+ for (i = 0; i < XDIM * YDIM; i++) {
+ *(buffer + i) = 1.0 + rank;
*(src_buf + i) = 1.0 + rank;
}
MPI_Win_create(buffer, bufsize, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &buf_win);
- peer = (rank+1) % nranks;
+ peer = (rank + 1) % nranks;
for (i = 0; i < ITERATIONS; i++) {
- MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
- for (j = 0; j < YDIM; j++) {
- MPI_Accumulate(src_buf + j*XDIM, XDIM, MPI_DOUBLE, peer,
- j*XDIM*sizeof(double), XDIM, MPI_DOUBLE, MPI_SUM, buf_win);
- }
+ for (j = 0; j < YDIM; j++) {
+ MPI_Accumulate(src_buf + j * XDIM, XDIM, MPI_DOUBLE, peer,
+ j * XDIM * sizeof(double), XDIM, MPI_DOUBLE, MPI_SUM, buf_win);
+ }
- MPI_Win_unlock(peer, buf_win);
+ MPI_Win_unlock(peer, buf_win);
}
MPI_Barrier(MPI_COMM_WORLD);
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, buf_win);
for (i = errors = 0; i < XDIM; i++) {
- for (j = 0; j < YDIM; j++) {
- const double actual = *(buffer + i + j*XDIM);
- const double expected = (1.0 + rank) + (1.0 + ((rank+nranks-1)%nranks)) * (ITERATIONS);
- if (fabs(actual - expected) > 1.0e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = 0; j < YDIM; j++) {
+ const double actual = *(buffer + i + j * XDIM);
+ const double expected =
+ (1.0 + rank) + (1.0 + ((rank + nranks - 1) % nranks)) * (ITERATIONS);
+ if (fabs(actual - expected) > 1.0e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
MPI_Win_unlock(rank, buf_win);
@@ -79,7 +81,7 @@ int main(int argc, char **argv) {
MPI_Free_mem(buffer);
MPI_Free_mem(src_buf);
- MTest_Finalize( errors );
+ MTest_Finalize(errors);
MPI_Finalize();
- return MTestReturnValue( errors );
+ return MTestReturnValue(errors);
}
diff --git a/test/mpi/rma/strided_acc_subarray.c b/test/mpi/rma/strided_acc_subarray.c
index c8f850c..b1c667c 100644
--- a/test/mpi/rma/strided_acc_subarray.c
+++ b/test/mpi/rma/strided_acc_subarray.c
@@ -6,7 +6,7 @@
/* One-Sided MPI 2-D Strided Accumulate Test
*
- * Author: James Dinan <dinan at mcs.anl.gov>
+ * Author: James Dinan <dinan at mcs.anl.gov>
* Date : December, 2010
*
* This code performs N accumulates into a 2d patch of a shared array. The
@@ -22,13 +22,14 @@
#include "mpitest.h"
#include "squelch.h"
-#define XDIM 1024
+#define XDIM 1024
#define YDIM 1024
#define SUB_XDIM 512
#define SUB_YDIM 512
#define ITERATIONS 10
-int main(int argc, char **argv) {
+int main(int argc, char **argv)
+{
int i, j, rank, nranks, peer, bufsize, errors;
double *win_buf, *src_buf;
MPI_Win buf_win;
@@ -42,44 +43,44 @@ int main(int argc, char **argv) {
MPI_Alloc_mem(bufsize, MPI_INFO_NULL, &win_buf);
MPI_Alloc_mem(bufsize, MPI_INFO_NULL, &src_buf);
- for (i = 0; i < XDIM*YDIM; i++) {
+ for (i = 0; i < XDIM * YDIM; i++) {
*(win_buf + i) = -1.0;
*(src_buf + i) = 1.0 + rank;
}
MPI_Win_create(win_buf, bufsize, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &buf_win);
- peer = (rank+1) % nranks;
+ peer = (rank + 1) % nranks;
/* Perform ITERATIONS strided accumulate operations */
for (i = 0; i < ITERATIONS; i++) {
- int ndims = 2;
- int src_arr_sizes[2] = { XDIM, YDIM };
- int src_arr_subsizes[2] = { SUB_XDIM, SUB_YDIM };
- int src_arr_starts[2] = { 0, 0 };
- int dst_arr_sizes[2] = { XDIM, YDIM };
- int dst_arr_subsizes[2] = { SUB_XDIM, SUB_YDIM };
- int dst_arr_starts[2] = { 0, 0 };
- MPI_Datatype src_type, dst_type;
+ int ndims = 2;
+ int src_arr_sizes[2] = { XDIM, YDIM };
+ int src_arr_subsizes[2] = { SUB_XDIM, SUB_YDIM };
+ int src_arr_starts[2] = { 0, 0 };
+ int dst_arr_sizes[2] = { XDIM, YDIM };
+ int dst_arr_subsizes[2] = { SUB_XDIM, SUB_YDIM };
+ int dst_arr_starts[2] = { 0, 0 };
+ MPI_Datatype src_type, dst_type;
- MPI_Type_create_subarray(ndims, src_arr_sizes, src_arr_subsizes, src_arr_starts,
- MPI_ORDER_C, MPI_DOUBLE, &src_type);
+ MPI_Type_create_subarray(ndims, src_arr_sizes, src_arr_subsizes, src_arr_starts,
+ MPI_ORDER_C, MPI_DOUBLE, &src_type);
- MPI_Type_create_subarray(ndims, dst_arr_sizes, dst_arr_subsizes, dst_arr_starts,
- MPI_ORDER_C, MPI_DOUBLE, &dst_type);
+ MPI_Type_create_subarray(ndims, dst_arr_sizes, dst_arr_subsizes, dst_arr_starts,
+ MPI_ORDER_C, MPI_DOUBLE, &dst_type);
- MPI_Type_commit(&src_type);
- MPI_Type_commit(&dst_type);
+ MPI_Type_commit(&src_type);
+ MPI_Type_commit(&dst_type);
- MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
- MPI_Accumulate(src_buf, 1, src_type, peer, 0, 1, dst_type, MPI_SUM, buf_win);
+ MPI_Accumulate(src_buf, 1, src_type, peer, 0, 1, dst_type, MPI_SUM, buf_win);
- MPI_Win_unlock(peer, buf_win);
+ MPI_Win_unlock(peer, buf_win);
- MPI_Type_free(&src_type);
- MPI_Type_free(&dst_type);
+ MPI_Type_free(&src_type);
+ MPI_Type_free(&dst_type);
}
MPI_Barrier(MPI_COMM_WORLD);
@@ -89,40 +90,40 @@ int main(int argc, char **argv) {
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, buf_win);
errors = 0;
for (i = 0; i < SUB_XDIM; i++) {
- for (j = 0; j < SUB_YDIM; j++) {
- const double actual = *(win_buf + i + j*XDIM);
- const double expected = -1.0 + (1.0 + ((rank+nranks-1)%nranks)) * (ITERATIONS);
- if (fabs(actual - expected) > 1.0e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = 0; j < SUB_YDIM; j++) {
+ const double actual = *(win_buf + i + j * XDIM);
+ const double expected = -1.0 + (1.0 + ((rank + nranks - 1) % nranks)) * (ITERATIONS);
+ if (fabs(actual - expected) > 1.0e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
for (i = SUB_XDIM; i < XDIM; i++) {
- for (j = 0; j < SUB_YDIM; j++) {
- const double actual = *(win_buf + i + j*XDIM);
- const double expected = -1.0;
- if (fabs(actual - expected) > 1.0e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = 0; j < SUB_YDIM; j++) {
+ const double actual = *(win_buf + i + j * XDIM);
+ const double expected = -1.0;
+ if (fabs(actual - expected) > 1.0e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
for (i = 0; i < XDIM; i++) {
- for (j = SUB_YDIM; j < YDIM; j++) {
- const double actual = *(win_buf + i + j*XDIM);
- const double expected = -1.0;
- if (fabs(actual - expected) > 1.0e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = SUB_YDIM; j < YDIM; j++) {
+ const double actual = *(win_buf + i + j * XDIM);
+ const double expected = -1.0;
+ if (fabs(actual - expected) > 1.0e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
MPI_Win_unlock(rank, buf_win);
@@ -130,7 +131,7 @@ int main(int argc, char **argv) {
MPI_Free_mem(win_buf);
MPI_Free_mem(src_buf);
- MTest_Finalize( errors );
+ MTest_Finalize(errors);
MPI_Finalize();
- return MTestReturnValue( errors );
+ return MTestReturnValue(errors);
}
diff --git a/test/mpi/rma/strided_get_indexed.c b/test/mpi/rma/strided_get_indexed.c
index 3a98d29..c0c1406 100644
--- a/test/mpi/rma/strided_get_indexed.c
+++ b/test/mpi/rma/strided_get_indexed.c
@@ -6,7 +6,7 @@
/* One-Sided MPI 2-D Strided Get Test
*
- * Author: James Dinan <dinan at mcs.anl.gov>
+ * Author: James Dinan <dinan at mcs.anl.gov>
* Date : December, 2010
*
* This code performs N strided get operations from a 2d patch of a shared
@@ -27,7 +27,8 @@
#define SUB_XDIM 8
#define SUB_YDIM 256
-int main(int argc, char **argv) {
+int main(int argc, char **argv)
+{
int i, j, rank, nranks, peer, bufsize, errors;
double *win_buf, *loc_buf;
MPI_Win buf_win;
@@ -45,20 +46,20 @@ int main(int argc, char **argv) {
MPI_Alloc_mem(bufsize, MPI_INFO_NULL, &win_buf);
MPI_Alloc_mem(bufsize, MPI_INFO_NULL, &loc_buf);
- for (i = 0; i < XDIM*YDIM; i++) {
- *(win_buf + i) = 1.0 + rank;
+ for (i = 0; i < XDIM * YDIM; i++) {
+ *(win_buf + i) = 1.0 + rank;
*(loc_buf + i) = -1.0;
}
MPI_Win_create(win_buf, bufsize, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &buf_win);
- peer = (rank+1) % nranks;
+ peer = (rank + 1) % nranks;
/* Build the datatype */
for (i = 0; i < SUB_YDIM; i++) {
- idx_rem[i] = i*XDIM;
- blk_len[i] = SUB_XDIM;
+ idx_rem[i] = i * XDIM;
+ blk_len[i] = SUB_XDIM;
}
MPI_Type_indexed(SUB_YDIM, blk_len, idx_rem, MPI_DOUBLE, &loc_type);
@@ -87,47 +88,47 @@ int main(int argc, char **argv) {
errors = 0;
for (i = 0; i < SUB_XDIM; i++) {
- for (j = 0; j < SUB_YDIM; j++) {
- const double actual = *(loc_buf + i + j*XDIM);
- const double expected = (1.0 + peer);
- if (fabs(actual - expected) > 1.0e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = 0; j < SUB_YDIM; j++) {
+ const double actual = *(loc_buf + i + j * XDIM);
+ const double expected = (1.0 + peer);
+ if (fabs(actual - expected) > 1.0e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
for (i = SUB_XDIM; i < XDIM; i++) {
- for (j = 0; j < SUB_YDIM; j++) {
- const double actual = *(loc_buf + i + j*XDIM);
- const double expected = -1.0;
- if (fabs(actual - expected) > 1.0e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = 0; j < SUB_YDIM; j++) {
+ const double actual = *(loc_buf + i + j * XDIM);
+ const double expected = -1.0;
+ if (fabs(actual - expected) > 1.0e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
for (i = 0; i < XDIM; i++) {
- for (j = SUB_YDIM; j < YDIM; j++) {
- const double actual = *(loc_buf + i + j*XDIM);
- const double expected = -1.0;
- if (fabs(actual - expected) > 1.0e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = SUB_YDIM; j < YDIM; j++) {
+ const double actual = *(loc_buf + i + j * XDIM);
+ const double expected = -1.0;
+ if (fabs(actual - expected) > 1.0e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
MPI_Win_free(&buf_win);
MPI_Free_mem(win_buf);
MPI_Free_mem(loc_buf);
- MTest_Finalize( errors );
+ MTest_Finalize(errors);
MPI_Finalize();
- return MTestReturnValue( errors );
+ return MTestReturnValue(errors);
}
diff --git a/test/mpi/rma/strided_getacc_indexed.c b/test/mpi/rma/strided_getacc_indexed.c
index e3293a1..88a08ad 100644
--- a/test/mpi/rma/strided_getacc_indexed.c
+++ b/test/mpi/rma/strided_getacc_indexed.c
@@ -6,7 +6,7 @@
/* One-Sided MPI 2-D Strided Accumulate Test
*
- * Author: James Dinan <dinan at mcs.anl.gov>
+ * Author: James Dinan <dinan at mcs.anl.gov>
* Date : December, 2010
*
* This code performs N strided put operations followed by get operations into
@@ -28,7 +28,8 @@
#define SUB_YDIM 2
#define ITERATIONS 10
-int main(int argc, char **argv) {
+int main(int argc, char **argv)
+{
int i, j, rank, nranks, peer, bufsize, errors;
double *win_buf, *src_buf, *dst_buf;
MPI_Win buf_win;
@@ -43,47 +44,47 @@ int main(int argc, char **argv) {
MPI_Alloc_mem(bufsize, MPI_INFO_NULL, &src_buf);
MPI_Alloc_mem(bufsize, MPI_INFO_NULL, &dst_buf);
- for (i = 0; i < XDIM*YDIM; i++) {
+ for (i = 0; i < XDIM * YDIM; i++) {
*(win_buf + i) = -1.0;
- *(src_buf + i) = 1.0 + rank;
+ *(src_buf + i) = 1.0 + rank;
}
MPI_Win_create(win_buf, bufsize, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &buf_win);
- peer = (rank+1) % nranks;
+ peer = (rank + 1) % nranks;
/* Perform ITERATIONS strided accumulate operations */
for (i = 0; i < ITERATIONS; i++) {
- int idx_rem[SUB_YDIM];
- int blk_len[SUB_YDIM];
- MPI_Datatype src_type, dst_type;
-
- for (j = 0; j < SUB_YDIM; j++) {
- idx_rem[j] = j*XDIM;
- blk_len[j] = SUB_XDIM;
- }
-
- MPI_Type_indexed(SUB_YDIM, blk_len, idx_rem, MPI_DOUBLE, &src_type);
- MPI_Type_indexed(SUB_YDIM, blk_len, idx_rem, MPI_DOUBLE, &dst_type);
-
- MPI_Type_commit(&src_type);
- MPI_Type_commit(&dst_type);
-
- /* PUT */
- MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
- MPI_Get_accumulate(src_buf, 1, src_type, dst_buf, 1, src_type, peer, 0,
- 1, dst_type, MPI_REPLACE, buf_win);
- MPI_Win_unlock(peer, buf_win);
-
- /* GET */
- MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
- MPI_Get_accumulate(src_buf, 1, src_type, dst_buf, 1, src_type, peer, 0,
- 1, dst_type, MPI_NO_OP, buf_win);
- MPI_Win_unlock(peer, buf_win);
-
- MPI_Type_free(&src_type);
- MPI_Type_free(&dst_type);
+ int idx_rem[SUB_YDIM];
+ int blk_len[SUB_YDIM];
+ MPI_Datatype src_type, dst_type;
+
+ for (j = 0; j < SUB_YDIM; j++) {
+ idx_rem[j] = j * XDIM;
+ blk_len[j] = SUB_XDIM;
+ }
+
+ MPI_Type_indexed(SUB_YDIM, blk_len, idx_rem, MPI_DOUBLE, &src_type);
+ MPI_Type_indexed(SUB_YDIM, blk_len, idx_rem, MPI_DOUBLE, &dst_type);
+
+ MPI_Type_commit(&src_type);
+ MPI_Type_commit(&dst_type);
+
+ /* PUT */
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
+ MPI_Get_accumulate(src_buf, 1, src_type, dst_buf, 1, src_type, peer, 0,
+ 1, dst_type, MPI_REPLACE, buf_win);
+ MPI_Win_unlock(peer, buf_win);
+
+ /* GET */
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
+ MPI_Get_accumulate(src_buf, 1, src_type, dst_buf, 1, src_type, peer, 0,
+ 1, dst_type, MPI_NO_OP, buf_win);
+ MPI_Win_unlock(peer, buf_win);
+
+ MPI_Type_free(&src_type);
+ MPI_Type_free(&dst_type);
}
MPI_Barrier(MPI_COMM_WORLD);
@@ -93,40 +94,40 @@ int main(int argc, char **argv) {
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, buf_win);
errors = 0;
for (i = 0; i < SUB_XDIM; i++) {
- for (j = 0; j < SUB_YDIM; j++) {
- const double actual = *(win_buf + i + j*XDIM);
- const double expected = (1.0 + ((rank+nranks-1)%nranks));
- if (fabs(actual - expected) > 1.0e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = 0; j < SUB_YDIM; j++) {
+ const double actual = *(win_buf + i + j * XDIM);
+ const double expected = (1.0 + ((rank + nranks - 1) % nranks));
+ if (fabs(actual - expected) > 1.0e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
for (i = SUB_XDIM; i < XDIM; i++) {
- for (j = 0; j < SUB_YDIM; j++) {
- const double actual = *(win_buf + i + j*XDIM);
- const double expected = -1.0;
- if (fabs(actual - expected) > 1.0e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = 0; j < SUB_YDIM; j++) {
+ const double actual = *(win_buf + i + j * XDIM);
+ const double expected = -1.0;
+ if (fabs(actual - expected) > 1.0e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
for (i = 0; i < XDIM; i++) {
- for (j = SUB_YDIM; j < YDIM; j++) {
- const double actual = *(win_buf + i + j*XDIM);
- const double expected = -1.0;
- if (fabs(actual - expected) > 1.0e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = SUB_YDIM; j < YDIM; j++) {
+ const double actual = *(win_buf + i + j * XDIM);
+ const double expected = -1.0;
+ if (fabs(actual - expected) > 1.0e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
MPI_Win_unlock(rank, buf_win);
@@ -135,7 +136,7 @@ int main(int argc, char **argv) {
MPI_Free_mem(src_buf);
MPI_Free_mem(dst_buf);
- MTest_Finalize( errors );
+ MTest_Finalize(errors);
MPI_Finalize();
- return MTestReturnValue( errors );
+ return MTestReturnValue(errors);
}
diff --git a/test/mpi/rma/strided_getacc_indexed_shared.c b/test/mpi/rma/strided_getacc_indexed_shared.c
index e1c8169..7ed4a8d 100644
--- a/test/mpi/rma/strided_getacc_indexed_shared.c
+++ b/test/mpi/rma/strided_getacc_indexed_shared.c
@@ -28,7 +28,8 @@
#define SUB_YDIM 2
#define ITERATIONS 10
-int main(int argc, char **argv) {
+int main(int argc, char **argv)
+{
int rank, nranks, rank_world, nranks_world;
int i, j, peer, bufsize, errors;
double *win_buf, *src_buf, *dst_buf;
@@ -53,47 +54,47 @@ int main(int argc, char **argv) {
MPI_Win_fence(0, buf_win);
- for (i = 0; i < XDIM*YDIM; i++) {
+ for (i = 0; i < XDIM * YDIM; i++) {
*(win_buf + i) = -1.0;
- *(src_buf + i) = 1.0 + rank;
+ *(src_buf + i) = 1.0 + rank;
}
MPI_Win_fence(0, buf_win);
- peer = (rank+1) % nranks;
+ peer = (rank + 1) % nranks;
/* Perform ITERATIONS strided accumulate operations */
for (i = 0; i < ITERATIONS; i++) {
- int idx_rem[SUB_YDIM];
- int blk_len[SUB_YDIM];
- MPI_Datatype src_type, dst_type;
-
- for (j = 0; j < SUB_YDIM; j++) {
- idx_rem[j] = j*XDIM;
- blk_len[j] = SUB_XDIM;
- }
-
- MPI_Type_indexed(SUB_YDIM, blk_len, idx_rem, MPI_DOUBLE, &src_type);
- MPI_Type_indexed(SUB_YDIM, blk_len, idx_rem, MPI_DOUBLE, &dst_type);
-
- MPI_Type_commit(&src_type);
- MPI_Type_commit(&dst_type);
-
- /* PUT */
- MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
- MPI_Get_accumulate(src_buf, 1, src_type, dst_buf, 1, src_type, peer, 0,
- 1, dst_type, MPI_REPLACE, buf_win);
- MPI_Win_unlock(peer, buf_win);
-
- /* GET */
- MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
- MPI_Get_accumulate(src_buf, 1, src_type, dst_buf, 1, src_type, peer, 0,
- 1, dst_type, MPI_NO_OP, buf_win);
- MPI_Win_unlock(peer, buf_win);
-
- MPI_Type_free(&src_type);
- MPI_Type_free(&dst_type);
+ int idx_rem[SUB_YDIM];
+ int blk_len[SUB_YDIM];
+ MPI_Datatype src_type, dst_type;
+
+ for (j = 0; j < SUB_YDIM; j++) {
+ idx_rem[j] = j * XDIM;
+ blk_len[j] = SUB_XDIM;
+ }
+
+ MPI_Type_indexed(SUB_YDIM, blk_len, idx_rem, MPI_DOUBLE, &src_type);
+ MPI_Type_indexed(SUB_YDIM, blk_len, idx_rem, MPI_DOUBLE, &dst_type);
+
+ MPI_Type_commit(&src_type);
+ MPI_Type_commit(&dst_type);
+
+ /* PUT */
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
+ MPI_Get_accumulate(src_buf, 1, src_type, dst_buf, 1, src_type, peer, 0,
+ 1, dst_type, MPI_REPLACE, buf_win);
+ MPI_Win_unlock(peer, buf_win);
+
+ /* GET */
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
+ MPI_Get_accumulate(src_buf, 1, src_type, dst_buf, 1, src_type, peer, 0,
+ 1, dst_type, MPI_NO_OP, buf_win);
+ MPI_Win_unlock(peer, buf_win);
+
+ MPI_Type_free(&src_type);
+ MPI_Type_free(&dst_type);
}
MPI_Barrier(MPI_COMM_WORLD);
@@ -103,40 +104,40 @@ int main(int argc, char **argv) {
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, buf_win);
errors = 0;
for (i = 0; i < SUB_XDIM; i++) {
- for (j = 0; j < SUB_YDIM; j++) {
- const double actual = *(win_buf + i + j*XDIM);
- const double expected = (1.0 + ((rank+nranks-1)%nranks));
- if (fabs(actual - expected) > 1.0e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = 0; j < SUB_YDIM; j++) {
+ const double actual = *(win_buf + i + j * XDIM);
+ const double expected = (1.0 + ((rank + nranks - 1) % nranks));
+ if (fabs(actual - expected) > 1.0e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
for (i = SUB_XDIM; i < XDIM; i++) {
- for (j = 0; j < SUB_YDIM; j++) {
- const double actual = *(win_buf + i + j*XDIM);
- const double expected = -1.0;
- if (fabs(actual - expected) > 1.0e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = 0; j < SUB_YDIM; j++) {
+ const double actual = *(win_buf + i + j * XDIM);
+ const double expected = -1.0;
+ if (fabs(actual - expected) > 1.0e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
for (i = 0; i < XDIM; i++) {
- for (j = SUB_YDIM; j < YDIM; j++) {
- const double actual = *(win_buf + i + j*XDIM);
- const double expected = -1.0;
- if (fabs(actual - expected) > 1.0e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = SUB_YDIM; j < YDIM; j++) {
+ const double actual = *(win_buf + i + j * XDIM);
+ const double expected = -1.0;
+ if (fabs(actual - expected) > 1.0e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
MPI_Win_unlock(rank, buf_win);
@@ -145,7 +146,7 @@ int main(int argc, char **argv) {
MPI_Free_mem(dst_buf);
MPI_Comm_free(&shr_comm);
- MTest_Finalize( errors );
+ MTest_Finalize(errors);
MPI_Finalize();
- return MTestReturnValue( errors );
+ return MTestReturnValue(errors);
}
diff --git a/test/mpi/rma/strided_putget_indexed.c b/test/mpi/rma/strided_putget_indexed.c
index 09f17ae..0b6c8c4 100644
--- a/test/mpi/rma/strided_putget_indexed.c
+++ b/test/mpi/rma/strided_putget_indexed.c
@@ -6,7 +6,7 @@
/* One-Sided MPI 2-D Strided Accumulate Test
*
- * Author: James Dinan <dinan at mcs.anl.gov>
+ * Author: James Dinan <dinan at mcs.anl.gov>
* Date : December, 2010
*
* This code performs N strided put operations followed by get operations into
@@ -28,7 +28,8 @@
#define SUB_YDIM 255
#define ITERATIONS 10
-int main(int argc, char **argv) {
+int main(int argc, char **argv)
+{
int i, j, rank, nranks, peer, bufsize, errors;
double *win_buf, *src_buf, *dst_buf;
MPI_Win buf_win;
@@ -43,43 +44,43 @@ int main(int argc, char **argv) {
MPI_Alloc_mem(bufsize, MPI_INFO_NULL, &src_buf);
MPI_Alloc_mem(bufsize, MPI_INFO_NULL, &dst_buf);
- for (i = 0; i < XDIM*YDIM; i++) {
+ for (i = 0; i < XDIM * YDIM; i++) {
*(win_buf + i) = -1.0;
- *(src_buf + i) = 1.0 + rank;
+ *(src_buf + i) = 1.0 + rank;
}
MPI_Win_create(win_buf, bufsize, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &buf_win);
- peer = (rank+1) % nranks;
+ peer = (rank + 1) % nranks;
/* Perform ITERATIONS strided accumulate operations */
for (i = 0; i < ITERATIONS; i++) {
- int idx_rem[SUB_YDIM];
- int blk_len[SUB_YDIM];
- MPI_Datatype src_type, dst_type;
+ int idx_rem[SUB_YDIM];
+ int blk_len[SUB_YDIM];
+ MPI_Datatype src_type, dst_type;
- for (j = 0; j < SUB_YDIM; j++) {
- idx_rem[j] = j*XDIM;
- blk_len[j] = SUB_XDIM;
- }
+ for (j = 0; j < SUB_YDIM; j++) {
+ idx_rem[j] = j * XDIM;
+ blk_len[j] = SUB_XDIM;
+ }
- MPI_Type_indexed(SUB_YDIM, blk_len, idx_rem, MPI_DOUBLE, &src_type);
- MPI_Type_indexed(SUB_YDIM, blk_len, idx_rem, MPI_DOUBLE, &dst_type);
+ MPI_Type_indexed(SUB_YDIM, blk_len, idx_rem, MPI_DOUBLE, &src_type);
+ MPI_Type_indexed(SUB_YDIM, blk_len, idx_rem, MPI_DOUBLE, &dst_type);
- MPI_Type_commit(&src_type);
- MPI_Type_commit(&dst_type);
+ MPI_Type_commit(&src_type);
+ MPI_Type_commit(&dst_type);
- MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
- MPI_Put(src_buf, 1, src_type, peer, 0, 1, dst_type, buf_win);
- MPI_Win_unlock(peer, buf_win);
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
+ MPI_Put(src_buf, 1, src_type, peer, 0, 1, dst_type, buf_win);
+ MPI_Win_unlock(peer, buf_win);
- MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
- MPI_Get(dst_buf, 1, src_type, peer, 0, 1, dst_type, buf_win);
- MPI_Win_unlock(peer, buf_win);
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
+ MPI_Get(dst_buf, 1, src_type, peer, 0, 1, dst_type, buf_win);
+ MPI_Win_unlock(peer, buf_win);
- MPI_Type_free(&src_type);
- MPI_Type_free(&dst_type);
+ MPI_Type_free(&src_type);
+ MPI_Type_free(&dst_type);
}
MPI_Barrier(MPI_COMM_WORLD);
@@ -89,40 +90,40 @@ int main(int argc, char **argv) {
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, buf_win);
errors = 0;
for (i = 0; i < SUB_XDIM; i++) {
- for (j = 0; j < SUB_YDIM; j++) {
- const double actual = *(win_buf + i + j*XDIM);
- const double expected = (1.0 + ((rank+nranks-1)%nranks));
- if (fabs(actual - expected) > 1.0e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = 0; j < SUB_YDIM; j++) {
+ const double actual = *(win_buf + i + j * XDIM);
+ const double expected = (1.0 + ((rank + nranks - 1) % nranks));
+ if (fabs(actual - expected) > 1.0e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
for (i = SUB_XDIM; i < XDIM; i++) {
- for (j = 0; j < SUB_YDIM; j++) {
- const double actual = *(win_buf + i + j*XDIM);
- const double expected = -1.0;
- if (fabs(actual - expected) > 1.0e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = 0; j < SUB_YDIM; j++) {
+ const double actual = *(win_buf + i + j * XDIM);
+ const double expected = -1.0;
+ if (fabs(actual - expected) > 1.0e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
for (i = 0; i < XDIM; i++) {
- for (j = SUB_YDIM; j < YDIM; j++) {
- const double actual = *(win_buf + i + j*XDIM);
- const double expected = -1.0;
- if (fabs(actual - expected) > 1.0e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = SUB_YDIM; j < YDIM; j++) {
+ const double actual = *(win_buf + i + j * XDIM);
+ const double expected = -1.0;
+ if (fabs(actual - expected) > 1.0e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
MPI_Win_unlock(rank, buf_win);
@@ -131,7 +132,7 @@ int main(int argc, char **argv) {
MPI_Free_mem(src_buf);
MPI_Free_mem(dst_buf);
- MTest_Finalize( errors );
+ MTest_Finalize(errors);
MPI_Finalize();
- return MTestReturnValue( errors );
+ return MTestReturnValue(errors);
}
diff --git a/test/mpi/rma/strided_putget_indexed_shared.c b/test/mpi/rma/strided_putget_indexed_shared.c
index 1e65f2a..998debd 100644
--- a/test/mpi/rma/strided_putget_indexed_shared.c
+++ b/test/mpi/rma/strided_putget_indexed_shared.c
@@ -28,7 +28,8 @@
#define SUB_YDIM 255
#define ITERATIONS 10
-int main(int argc, char **argv) {
+int main(int argc, char **argv)
+{
int rank, nranks, rank_world, nranks_world;
int i, j, peer, bufsize, errors;
double *win_buf, *src_buf, *dst_buf;
@@ -53,43 +54,43 @@ int main(int argc, char **argv) {
MPI_Win_fence(0, buf_win);
- for (i = 0; i < XDIM*YDIM; i++) {
+ for (i = 0; i < XDIM * YDIM; i++) {
*(win_buf + i) = -1.0;
- *(src_buf + i) = 1.0 + rank;
+ *(src_buf + i) = 1.0 + rank;
}
MPI_Win_fence(0, buf_win);
- peer = (rank+1) % nranks;
+ peer = (rank + 1) % nranks;
/* Perform ITERATIONS strided accumulate operations */
for (i = 0; i < ITERATIONS; i++) {
- int idx_rem[SUB_YDIM];
- int blk_len[SUB_YDIM];
- MPI_Datatype src_type, dst_type;
+ int idx_rem[SUB_YDIM];
+ int blk_len[SUB_YDIM];
+ MPI_Datatype src_type, dst_type;
- for (j = 0; j < SUB_YDIM; j++) {
- idx_rem[j] = j*XDIM;
- blk_len[j] = SUB_XDIM;
- }
+ for (j = 0; j < SUB_YDIM; j++) {
+ idx_rem[j] = j * XDIM;
+ blk_len[j] = SUB_XDIM;
+ }
- MPI_Type_indexed(SUB_YDIM, blk_len, idx_rem, MPI_DOUBLE, &src_type);
- MPI_Type_indexed(SUB_YDIM, blk_len, idx_rem, MPI_DOUBLE, &dst_type);
+ MPI_Type_indexed(SUB_YDIM, blk_len, idx_rem, MPI_DOUBLE, &src_type);
+ MPI_Type_indexed(SUB_YDIM, blk_len, idx_rem, MPI_DOUBLE, &dst_type);
- MPI_Type_commit(&src_type);
- MPI_Type_commit(&dst_type);
+ MPI_Type_commit(&src_type);
+ MPI_Type_commit(&dst_type);
- MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
- MPI_Put(src_buf, 1, src_type, peer, 0, 1, dst_type, buf_win);
- MPI_Win_unlock(peer, buf_win);
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
+ MPI_Put(src_buf, 1, src_type, peer, 0, 1, dst_type, buf_win);
+ MPI_Win_unlock(peer, buf_win);
- MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
- MPI_Get(dst_buf, 1, src_type, peer, 0, 1, dst_type, buf_win);
- MPI_Win_unlock(peer, buf_win);
+ MPI_Win_lock(MPI_LOCK_EXCLUSIVE, peer, 0, buf_win);
+ MPI_Get(dst_buf, 1, src_type, peer, 0, 1, dst_type, buf_win);
+ MPI_Win_unlock(peer, buf_win);
- MPI_Type_free(&src_type);
- MPI_Type_free(&dst_type);
+ MPI_Type_free(&src_type);
+ MPI_Type_free(&dst_type);
}
MPI_Barrier(shr_comm);
@@ -99,40 +100,40 @@ int main(int argc, char **argv) {
MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, buf_win);
errors = 0;
for (i = 0; i < SUB_XDIM; i++) {
- for (j = 0; j < SUB_YDIM; j++) {
- const double actual = *(win_buf + i + j*XDIM);
- const double expected = (1.0 + ((rank+nranks-1)%nranks));
- if (fabs(actual - expected) > 1.0e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = 0; j < SUB_YDIM; j++) {
+ const double actual = *(win_buf + i + j * XDIM);
+ const double expected = (1.0 + ((rank + nranks - 1) % nranks));
+ if (fabs(actual - expected) > 1.0e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
for (i = SUB_XDIM; i < XDIM; i++) {
- for (j = 0; j < SUB_YDIM; j++) {
- const double actual = *(win_buf + i + j*XDIM);
- const double expected = -1.0;
- if (fabs(actual - expected) > 1.0e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = 0; j < SUB_YDIM; j++) {
+ const double actual = *(win_buf + i + j * XDIM);
+ const double expected = -1.0;
+ if (fabs(actual - expected) > 1.0e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
for (i = 0; i < XDIM; i++) {
- for (j = SUB_YDIM; j < YDIM; j++) {
- const double actual = *(win_buf + i + j*XDIM);
- const double expected = -1.0;
- if (fabs(actual - expected) > 1.0e-10) {
- SQUELCH( printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
- rank, j, i, expected, actual); );
- errors++;
- fflush(stdout);
+ for (j = SUB_YDIM; j < YDIM; j++) {
+ const double actual = *(win_buf + i + j * XDIM);
+ const double expected = -1.0;
+ if (fabs(actual - expected) > 1.0e-10) {
+ SQUELCH(printf("%d: Data validation failed at [%d, %d] expected=%f actual=%f\n",
+ rank, j, i, expected, actual););
+ errors++;
+ fflush(stdout);
+ }
}
- }
}
MPI_Win_unlock(rank, buf_win);
@@ -141,7 +142,7 @@ int main(int argc, char **argv) {
MPI_Free_mem(dst_buf);
MPI_Comm_free(&shr_comm);
- MTest_Finalize( errors );
+ MTest_Finalize(errors);
MPI_Finalize();
- return MTestReturnValue( errors );
+ return MTestReturnValue(errors);
}
diff --git a/test/mpi/rma/test1.c b/test/mpi/rma/test1.c
index b11995b..eb2d1a1 100644
--- a/test/mpi/rma/test1.c
+++ b/test/mpi/rma/test1.c
@@ -3,7 +3,7 @@
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include "stdio.h"
#include "mpitest.h"
#include "squelch.h"
@@ -12,16 +12,16 @@
#define SIZE 100
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[])
+{
int rank, nprocs, A[SIZE], B[SIZE], i;
MPI_Comm CommDeuce;
MPI_Win win;
int errs = 0;
-
- MTest_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (nprocs < 2) {
printf("Run this program with 2 or more processes\n");
@@ -32,50 +32,52 @@ int main(int argc, char *argv[])
if (rank < 2) {
if (rank == 0) {
- for (i=0; i<SIZE; i++)
+ for (i = 0; i < SIZE; i++)
A[i] = B[i] = i;
}
else {
- for (i=0; i<SIZE; i++) {
- A[i] = (-3)*i;
- B[i] = (-4)*i;
+ for (i = 0; i < SIZE; i++) {
+ A[i] = (-3) * i;
+ B[i] = (-4) * i;
}
}
-
- MPI_Win_create(B, SIZE*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
-
- MPI_Win_fence(0, win);
-
+
+ MPI_Win_create(B, SIZE * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
+
+ MPI_Win_fence(0, win);
+
if (rank == 0) {
- for (i=0; i<SIZE-1; i++)
- MPI_Put(A+i, 1, MPI_INT, 1, i, 1, MPI_INT, win);
- }
+ for (i = 0; i < SIZE - 1; i++)
+ MPI_Put(A + i, 1, MPI_INT, 1, i, 1, MPI_INT, win);
+ }
else {
- for (i=0; i<SIZE-1; i++)
- MPI_Get(A+i, 1, MPI_INT, 0, i, 1, MPI_INT, win);
-
- MPI_Accumulate(A+i, 1, MPI_INT, 0, i, 1, MPI_INT, MPI_SUM, win);
+ for (i = 0; i < SIZE - 1; i++)
+ MPI_Get(A + i, 1, MPI_INT, 0, i, 1, MPI_INT, win);
+
+ MPI_Accumulate(A + i, 1, MPI_INT, 0, i, 1, MPI_INT, MPI_SUM, win);
}
- MPI_Win_fence(0, win);
-
+ MPI_Win_fence(0, win);
+
if (rank == 1) {
- for (i=0; i<SIZE-1; i++) {
+ for (i = 0; i < SIZE - 1; i++) {
if (A[i] != B[i]) {
- SQUELCH( printf("Put/Get Error: A[i]=%d, B[i]=%d\n", A[i], B[i]); );
+ SQUELCH(printf("Put/Get Error: A[i]=%d, B[i]=%d\n", A[i], B[i]););
errs++;
- }
+ }
}
}
else {
- if (B[SIZE-1] != SIZE - 1 - 3*(SIZE-1)) {
- SQUELCH( printf("Accumulate Error: B[SIZE-1] is %d, should be %d\n", B[SIZE-1], SIZE - 1 - 3*(SIZE-1)); );
+ if (B[SIZE - 1] != SIZE - 1 - 3 * (SIZE - 1)) {
+ SQUELCH(printf
+ ("Accumulate Error: B[SIZE-1] is %d, should be %d\n", B[SIZE - 1],
+ SIZE - 1 - 3 * (SIZE - 1)););
errs++;
}
- }
- MPI_Win_free(&win);
+ }
+ MPI_Win_free(&win);
}
MPI_Comm_free(&CommDeuce);
MTest_Finalize(errs);
- MPI_Finalize();
- return 0;
-}
+ MPI_Finalize();
+ return 0;
+}
diff --git a/test/mpi/rma/test1_am.c b/test/mpi/rma/test1_am.c
index 9ceedfd..2c88cb8 100644
--- a/test/mpi/rma/test1_am.c
+++ b/test/mpi/rma/test1_am.c
@@ -3,7 +3,7 @@
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include "stdio.h"
#include "mpitest.h"
#include "squelch.h"
@@ -14,18 +14,18 @@
#define SIZE 100
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[])
+{
int rank, nprocs, i;
MPI_Comm CommDeuce;
int *A, *B;
MPI_Win win;
int errs = 0;
-
- MTest_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (nprocs < 2) {
printf("Run this program with 2 or more processes\n");
@@ -45,49 +45,51 @@ int main(int argc, char *argv[])
printf("Can't allocate memory in test program\n");
MPI_Abort(MPI_COMM_WORLD, 1);
}
-
+
if (rank == 0) {
- for (i=0; i<SIZE; i++)
+ for (i = 0; i < SIZE; i++)
A[i] = B[i] = i;
}
else {
- for (i=0; i<SIZE; i++) {
- A[i] = (-3)*i;
- B[i] = (-4)*i;
+ for (i = 0; i < SIZE; i++) {
+ A[i] = (-3) * i;
+ B[i] = (-4) * i;
}
}
- MPI_Win_create(B, SIZE*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
+ MPI_Win_create(B, SIZE * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
+
+ MPI_Win_fence(0, win);
- MPI_Win_fence(0, win);
-
if (rank == 0) {
- for (i=0; i<SIZE-1; i++)
- MPI_Put(A+i, 1, MPI_INT, 1, i, 1, MPI_INT, win);
- }
+ for (i = 0; i < SIZE - 1; i++)
+ MPI_Put(A + i, 1, MPI_INT, 1, i, 1, MPI_INT, win);
+ }
else {
- for (i=0; i<SIZE-1; i++)
- MPI_Get(A+i, 1, MPI_INT, 0, i, 1, MPI_INT, win);
-
- MPI_Accumulate(A+i, 1, MPI_INT, 0, i, 1, MPI_INT, MPI_SUM, win);
+ for (i = 0; i < SIZE - 1; i++)
+ MPI_Get(A + i, 1, MPI_INT, 0, i, 1, MPI_INT, win);
+
+ MPI_Accumulate(A + i, 1, MPI_INT, 0, i, 1, MPI_INT, MPI_SUM, win);
}
- MPI_Win_fence(0, win);
-
+ MPI_Win_fence(0, win);
+
if (rank == 1) {
- for (i=0; i<SIZE-1; i++) {
+ for (i = 0; i < SIZE - 1; i++) {
if (A[i] != B[i]) {
- SQUELCH( printf("Put/Get Error: A[i]=%d, B[i]=%d\n", A[i], B[i]); );
+ SQUELCH(printf("Put/Get Error: A[i]=%d, B[i]=%d\n", A[i], B[i]););
errs++;
- }
+ }
}
}
else {
- if (B[SIZE-1] != SIZE - 1 - 3*(SIZE-1)) {
- SQUELCH( printf("Accumulate Error: B[SIZE-1] is %d, should be %d\n", B[SIZE-1], SIZE - 1 - 3*(SIZE-1)); );
+ if (B[SIZE - 1] != SIZE - 1 - 3 * (SIZE - 1)) {
+ SQUELCH(printf
+ ("Accumulate Error: B[SIZE-1] is %d, should be %d\n", B[SIZE - 1],
+ SIZE - 1 - 3 * (SIZE - 1)););
errs++;
}
- }
- MPI_Win_free(&win);
+ }
+ MPI_Win_free(&win);
MPI_Free_mem(A);
MPI_Free_mem(B);
@@ -95,6 +97,6 @@ int main(int argc, char *argv[])
MPI_Comm_free(&CommDeuce);
MTest_Finalize(errs);
- MPI_Finalize();
- return 0;
-}
+ MPI_Finalize();
+ return 0;
+}
diff --git a/test/mpi/rma/test1_dt.c b/test/mpi/rma/test1_dt.c
index 072c184..68bec22 100644
--- a/test/mpi/rma/test1_dt.c
+++ b/test/mpi/rma/test1_dt.c
@@ -3,7 +3,7 @@
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include "stdio.h"
#include "mpitest.h"
#include "squelch.h"
@@ -13,17 +13,17 @@
#define SIZE 100
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[])
+{
int rank, nprocs, A[SIZE], B[SIZE], i;
MPI_Comm CommDeuce;
MPI_Win win;
MPI_Datatype contig_2ints;
int errs = 0;
- MTest_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (nprocs < 2) {
printf("Run this program with 2 or more processes\n");
@@ -35,46 +35,48 @@ int main(int argc, char *argv[])
if (rank < 2) {
if (rank == 0) {
- for (i=0; i<SIZE; i++)
+ for (i = 0; i < SIZE; i++)
A[i] = B[i] = i;
}
else {
- for (i=0; i<SIZE; i++) {
- A[i] = (-3)*i;
- B[i] = (-4)*i;
+ for (i = 0; i < SIZE; i++) {
+ A[i] = (-3) * i;
+ B[i] = (-4) * i;
}
}
MPI_Type_contiguous(2, MPI_INT, &contig_2ints);
MPI_Type_commit(&contig_2ints);
- MPI_Win_create(B, SIZE*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
+ MPI_Win_create(B, SIZE * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
MPI_Win_fence(0, win);
if (rank == 0) {
- for (i=0; i<SIZE-2; i+=2)
- MPI_Put(A+i, 2, MPI_INT, 1, i, 1, contig_2ints, win);
+ for (i = 0; i < SIZE - 2; i += 2)
+ MPI_Put(A + i, 2, MPI_INT, 1, i, 1, contig_2ints, win);
}
else {
- for (i=0; i<SIZE-2; i+=2)
- MPI_Get(A+i, 2, MPI_INT, 0, i, 1, contig_2ints, win);
+ for (i = 0; i < SIZE - 2; i += 2)
+ MPI_Get(A + i, 2, MPI_INT, 0, i, 1, contig_2ints, win);
- MPI_Accumulate(A+SIZE-2, 2, MPI_INT, 0, SIZE-2, 1, contig_2ints, MPI_SUM, win);
+ MPI_Accumulate(A + SIZE - 2, 2, MPI_INT, 0, SIZE - 2, 1, contig_2ints, MPI_SUM, win);
}
MPI_Win_fence(0, win);
if (rank == 1) {
- for (i=0; i<SIZE-2; i++) {
+ for (i = 0; i < SIZE - 2; i++) {
if (A[i] != B[i]) {
- SQUELCH( printf("Put/Get Error: A[i]=%d, B[i]=%d\n", A[i], B[i]); );
+ SQUELCH(printf("Put/Get Error: A[i]=%d, B[i]=%d\n", A[i], B[i]););
errs++;
}
}
}
else {
- if (B[SIZE-1] != SIZE - 1 - 3*(SIZE-1)) {
- SQUELCH( printf("Accumulate Error: B[SIZE-1] is %d, should be %d\n", B[SIZE-1], SIZE - 1 - 3*(SIZE-1)); );
+ if (B[SIZE - 1] != SIZE - 1 - 3 * (SIZE - 1)) {
+ SQUELCH(printf
+ ("Accumulate Error: B[SIZE-1] is %d, should be %d\n", B[SIZE - 1],
+ SIZE - 1 - 3 * (SIZE - 1)););
errs++;
}
}
@@ -84,6 +86,6 @@ int main(int argc, char *argv[])
}
MPI_Comm_free(&CommDeuce);
MTest_Finalize(errs);
- MPI_Finalize();
- return 0;
-}
+ MPI_Finalize();
+ return 0;
+}
diff --git a/test/mpi/rma/test2.c b/test/mpi/rma/test2.c
index 527c2d6..b41c56c 100644
--- a/test/mpi/rma/test2.c
+++ b/test/mpi/rma/test2.c
@@ -3,7 +3,7 @@
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include "stdio.h"
#include "mpitest.h"
#include "squelch.h"
@@ -13,17 +13,17 @@
#define SIZE1 100
#define SIZE2 200
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[])
+{
int rank, destrank, nprocs, A[SIZE2], i;
MPI_Comm CommDeuce;
MPI_Group comm_group, group;
MPI_Win win;
int errs = 0;
- MTest_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (nprocs < 2) {
printf("Run this program with 2 or more processes\n");
@@ -32,13 +32,13 @@ int main(int argc, char *argv[])
MPI_Comm_split(MPI_COMM_WORLD, (rank < 2), rank, &CommDeuce);
- if (rank < 2)
- {
+ if (rank < 2) {
MPI_Comm_group(CommDeuce, &comm_group);
if (rank == 0) {
int B[SIZE2];
- for (i=0; i<SIZE2; i++) A[i] = B[i] = i;
+ for (i = 0; i < SIZE2; i++)
+ A[i] = B[i] = i;
#ifdef USE_WIN_ALLOCATE
char *base_ptr;
MPI_Win_allocate(0, 1, MPI_INFO_NULL, CommDeuce, &base_ptr, &win);
@@ -48,29 +48,31 @@ int main(int argc, char *argv[])
destrank = 1;
MPI_Group_incl(comm_group, 1, &destrank, &group);
MPI_Win_start(group, 0, win);
- for (i=0; i<SIZE1; i++)
- MPI_Put(A+i, 1, MPI_INT, 1, i, 1, MPI_INT, win);
- for (i=0; i<SIZE1; i++)
- MPI_Get(B+i, 1, MPI_INT, 1, SIZE1+i, 1, MPI_INT, win);
+ for (i = 0; i < SIZE1; i++)
+ MPI_Put(A + i, 1, MPI_INT, 1, i, 1, MPI_INT, win);
+ for (i = 0; i < SIZE1; i++)
+ MPI_Get(B + i, 1, MPI_INT, 1, SIZE1 + i, 1, MPI_INT, win);
MPI_Win_complete(win);
- for (i=0; i<SIZE1; i++)
- if (B[i] != (-4)*(i+SIZE1)) {
- SQUELCH( printf("Get Error: B[i] is %d, should be %d\n", B[i], (-4)*(i+SIZE1)); );
+ for (i = 0; i < SIZE1; i++)
+ if (B[i] != (-4) * (i + SIZE1)) {
+ SQUELCH(printf
+ ("Get Error: B[i] is %d, should be %d\n", B[i], (-4) * (i + SIZE1)););
errs++;
}
}
else if (rank == 1) {
#ifdef USE_WIN_ALLOCATE
int *B;
- MPI_Win_allocate(SIZE2*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &B, &win);
+ MPI_Win_allocate(SIZE2 * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &B, &win);
#else
int B[SIZE2];
- MPI_Win_create(B, SIZE2*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
+ MPI_Win_create(B, SIZE2 * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
#endif
MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, win);
- for (i=0; i<SIZE2; i++) B[i] = (-4)*i;
+ for (i = 0; i < SIZE2; i++)
+ B[i] = (-4) * i;
MPI_Win_unlock(rank, win);
destrank = 0;
@@ -78,9 +80,9 @@ int main(int argc, char *argv[])
MPI_Win_post(group, 0, win);
MPI_Win_wait(win);
- for (i=0; i<SIZE1; i++) {
+ for (i = 0; i < SIZE1; i++) {
if (B[i] != i) {
- SQUELCH( printf("Put Error: B[i] is %d, should be %d\n", B[i], i); );
+ SQUELCH(printf("Put Error: B[i] is %d, should be %d\n", B[i], i););
errs++;
}
}
@@ -93,5 +95,5 @@ int main(int argc, char *argv[])
MPI_Comm_free(&CommDeuce);
MTest_Finalize(errs);
MPI_Finalize();
- return 0;
-}
+ return 0;
+}
diff --git a/test/mpi/rma/test2_am.c b/test/mpi/rma/test2_am.c
index 1d9c7d0..c3fb529 100644
--- a/test/mpi/rma/test2_am.c
+++ b/test/mpi/rma/test2_am.c
@@ -3,7 +3,7 @@
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include "stdio.h"
#include "mpitest.h"
#include "squelch.h"
@@ -15,17 +15,17 @@
#define SIZE1 100
#define SIZE2 200
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[])
+{
int rank, destrank, nprocs, *A, *B, i;
MPI_Comm CommDeuce;
MPI_Group comm_group, group;
MPI_Win win;
int errs = 0;
- MTest_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (nprocs < 2) {
printf("Run this program with 2 or more processes\n");
@@ -34,8 +34,7 @@ int main(int argc, char *argv[])
MPI_Comm_split(MPI_COMM_WORLD, (rank < 2), rank, &CommDeuce);
- if (rank < 2)
- {
+ if (rank < 2) {
i = MPI_Alloc_mem(SIZE2 * sizeof(int), MPI_INFO_NULL, &A);
if (i) {
@@ -52,7 +51,8 @@ int main(int argc, char *argv[])
MPI_Abort(MPI_COMM_WORLD, 1);
}
- for (i=0; i<SIZE2; i++) A[i] = B[i] = i;
+ for (i = 0; i < SIZE2; i++)
+ A[i] = B[i] = i;
#ifdef USE_WIN_ALLOCATE
char *base_ptr;
MPI_Win_allocate(0, 1, MPI_INFO_NULL, CommDeuce, &base_ptr, &win);
@@ -62,16 +62,17 @@ int main(int argc, char *argv[])
destrank = 1;
MPI_Group_incl(comm_group, 1, &destrank, &group);
MPI_Win_start(group, 0, win);
- for (i=0; i<SIZE1; i++)
- MPI_Put(A+i, 1, MPI_INT, 1, i, 1, MPI_INT, win);
- for (i=0; i<SIZE1; i++)
- MPI_Get(B+i, 1, MPI_INT, 1, SIZE1+i, 1, MPI_INT, win);
+ for (i = 0; i < SIZE1; i++)
+ MPI_Put(A + i, 1, MPI_INT, 1, i, 1, MPI_INT, win);
+ for (i = 0; i < SIZE1; i++)
+ MPI_Get(B + i, 1, MPI_INT, 1, SIZE1 + i, 1, MPI_INT, win);
MPI_Win_complete(win);
- for (i=0; i<SIZE1; i++)
- if (B[i] != (-4)*(i+SIZE1)) {
- SQUELCH( printf("Get Error: B[i] is %d, should be %d\n", B[i], (-4)*(i+SIZE1)); );
+ for (i = 0; i < SIZE1; i++)
+ if (B[i] != (-4) * (i + SIZE1)) {
+ SQUELCH(printf
+ ("Get Error: B[i] is %d, should be %d\n", B[i], (-4) * (i + SIZE1)););
errs++;
}
@@ -79,17 +80,18 @@ int main(int argc, char *argv[])
}
else if (rank == 1) {
#ifdef USE_WIN_ALLOCATE
- MPI_Win_allocate(SIZE2*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &B, &win);
+ MPI_Win_allocate(SIZE2 * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &B, &win);
#else
i = MPI_Alloc_mem(SIZE2 * sizeof(int), MPI_INFO_NULL, &B);
if (i) {
printf("Can't allocate memory in test program\n");
MPI_Abort(MPI_COMM_WORLD, 1);
}
- MPI_Win_create(B, SIZE2*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
+ MPI_Win_create(B, SIZE2 * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
#endif
MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, win);
- for (i=0; i<SIZE2; i++) B[i] = (-4)*i;
+ for (i = 0; i < SIZE2; i++)
+ B[i] = (-4) * i;
MPI_Win_unlock(rank, win);
destrank = 0;
@@ -97,9 +99,9 @@ int main(int argc, char *argv[])
MPI_Win_post(group, 0, win);
MPI_Win_wait(win);
- for (i=0; i<SIZE1; i++) {
+ for (i = 0; i < SIZE1; i++) {
if (B[i] != i) {
- SQUELCH( printf("Put Error: B[i] is %d, should be %d\n", B[i], i); );
+ SQUELCH(printf("Put Error: B[i] is %d, should be %d\n", B[i], i););
errs++;
}
}
@@ -117,5 +119,5 @@ int main(int argc, char *argv[])
MPI_Comm_free(&CommDeuce);
MTest_Finalize(errs);
MPI_Finalize();
- return 0;
-}
+ return 0;
+}
diff --git a/test/mpi/rma/test3.c b/test/mpi/rma/test3.c
index 2a86c00..fcff72b 100644
--- a/test/mpi/rma/test3.c
+++ b/test/mpi/rma/test3.c
@@ -3,7 +3,7 @@
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include "stdio.h"
#include "stdlib.h"
#include "mpitest.h"
@@ -18,17 +18,17 @@
#define SIZE 1048576
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[])
+{
int rank, destrank, nprocs, *A, *B, i;
MPI_Comm CommDeuce;
MPI_Group comm_group, group;
MPI_Win win;
int errs = 0;
- MTest_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (nprocs < 2) {
printf("Run this program with 2 or more processes\n");
@@ -37,8 +37,7 @@ int main(int argc, char *argv[])
MPI_Comm_split(MPI_COMM_WORLD, (rank < 2), rank, &CommDeuce);
- if (rank < 2)
- {
+ if (rank < 2) {
A = (int *) malloc(SIZE * sizeof(int));
if (!A) {
printf("Can't allocate memory in test program\n");
@@ -54,7 +53,7 @@ int main(int argc, char *argv[])
MPI_Abort(MPI_COMM_WORLD, 1);
}
- for (i=0; i<SIZE; i++) {
+ for (i = 0; i < SIZE; i++) {
A[i] = i;
B[i] = SIZE + i;
}
@@ -76,17 +75,18 @@ int main(int argc, char *argv[])
else if (rank == 1) {
#ifdef USE_WIN_ALLOCATE
- MPI_Win_allocate(SIZE*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &B, &win);
+ MPI_Win_allocate(SIZE * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &B, &win);
#else
B = (int *) malloc(SIZE * sizeof(int));
if (!B) {
printf("Can't allocate memory in test program\n");
MPI_Abort(MPI_COMM_WORLD, 1);
}
- MPI_Win_create(B, SIZE*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
+ MPI_Win_create(B, SIZE * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
#endif
MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, win);
- for (i=0; i<SIZE; i++) A[i] = B[i] = (-4)*i;
+ for (i = 0; i < SIZE; i++)
+ A[i] = B[i] = (-4) * i;
MPI_Win_unlock(rank, win);
destrank = 0;
@@ -95,13 +95,15 @@ int main(int argc, char *argv[])
MPI_Recv(A, SIZE, MPI_INT, 0, 100, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
MPI_Win_wait(win);
- for (i=0; i<SIZE; i++) {
+ for (i = 0; i < SIZE; i++) {
if (B[i] != i) {
- SQUELCH( printf("Rank 1: Put Error: B[i] is %d, should be %d\n", B[i], i); );
+ SQUELCH(printf("Rank 1: Put Error: B[i] is %d, should be %d\n", B[i], i););
errs++;
}
if (A[i] != SIZE + i) {
- SQUELCH( printf("Rank 1: Send/Recv Error: A[i] is %d, should be %d\n", A[i], SIZE+i); );
+ SQUELCH(printf
+ ("Rank 1: Send/Recv Error: A[i] is %d, should be %d\n", A[i],
+ SIZE + i););
errs++;
}
}
@@ -117,6 +119,6 @@ int main(int argc, char *argv[])
}
MPI_Comm_free(&CommDeuce);
MTest_Finalize(errs);
- MPI_Finalize();
- return 0;
-}
+ MPI_Finalize();
+ return 0;
+}
diff --git a/test/mpi/rma/test3_am.c b/test/mpi/rma/test3_am.c
index 029dfc6..5ff0bfc 100644
--- a/test/mpi/rma/test3_am.c
+++ b/test/mpi/rma/test3_am.c
@@ -3,7 +3,7 @@
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include "stdio.h"
#include "stdlib.h"
#include "mpitest.h"
@@ -20,17 +20,17 @@
#define SIZE 1048576
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[])
+{
int rank, destrank, nprocs, *A, *B, i;
MPI_Comm CommDeuce;
MPI_Group comm_group, group;
MPI_Win win;
int errs = 0;
- MTest_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (nprocs < 2) {
printf("Run this program with 2 or more processes\n");
@@ -55,7 +55,7 @@ int main(int argc, char *argv[])
MPI_Abort(MPI_COMM_WORLD, 1);
}
- for (i=0; i<SIZE; i++) {
+ for (i = 0; i < SIZE; i++) {
A[i] = i;
B[i] = SIZE + i;
}
@@ -76,17 +76,18 @@ int main(int argc, char *argv[])
}
else { /* rank=1 */
#ifdef USE_WIN_ALLOCATE
- MPI_Win_allocate(SIZE*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &B, &win);
+ MPI_Win_allocate(SIZE * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &B, &win);
#else
i = MPI_Alloc_mem(SIZE * sizeof(int), MPI_INFO_NULL, &B);
if (i) {
printf("Can't allocate memory in test program\n");
MPI_Abort(MPI_COMM_WORLD, 1);
}
- MPI_Win_create(B, SIZE*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
+ MPI_Win_create(B, SIZE * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
#endif
MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, win);
- for (i=0; i<SIZE; i++) A[i] = B[i] = (-4)*i;
+ for (i = 0; i < SIZE; i++)
+ A[i] = B[i] = (-4) * i;
MPI_Win_unlock(rank, win);
destrank = 0;
@@ -95,13 +96,15 @@ int main(int argc, char *argv[])
MPI_Recv(A, SIZE, MPI_INT, 0, 100, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
MPI_Win_wait(win);
- for (i=0; i<SIZE; i++) {
+ for (i = 0; i < SIZE; i++) {
if (B[i] != i) {
- SQUELCH( printf("Rank 1: Put Error: B[i] is %d, should be %d\n", B[i], i); );
+ SQUELCH(printf("Rank 1: Put Error: B[i] is %d, should be %d\n", B[i], i););
errs++;
}
if (A[i] != SIZE + i) {
- SQUELCH( printf("Rank 1: Send/Recv Error: A[i] is %d, should be %d\n", A[i], SIZE+i); );
+ SQUELCH(printf
+ ("Rank 1: Send/Recv Error: A[i] is %d, should be %d\n", A[i],
+ SIZE + i););
errs++;
}
}
@@ -118,6 +121,6 @@ int main(int argc, char *argv[])
}
MPI_Comm_free(&CommDeuce);
MTest_Finalize(errs);
- MPI_Finalize();
- return 0;
-}
+ MPI_Finalize();
+ return 0;
+}
diff --git a/test/mpi/rma/test4.c b/test/mpi/rma/test4.c
index 11ee9dd..748170f 100644
--- a/test/mpi/rma/test4.c
+++ b/test/mpi/rma/test4.c
@@ -3,28 +3,28 @@
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include "stdio.h"
#include "stdlib.h"
#include "mpitest.h"
#include "squelch.h"
-/* tests passive target RMA on 2 processes. tests the lock-single_op-unlock
+/* tests passive target RMA on 2 processes. tests the lock-single_op-unlock
optimization. */
#define SIZE1 100
#define SIZE2 200
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[])
+{
int rank, nprocs, A[SIZE2], B[SIZE2], i, j;
MPI_Comm CommDeuce;
MPI_Win win;
int errs = 0;
- MTest_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (nprocs < 2) {
printf("Run this program with 2 or more processes\n");
@@ -35,40 +35,44 @@ int main(int argc, char *argv[])
if (rank < 2) {
if (rank == 0) {
- for (i=0; i<SIZE2; i++) A[i] = B[i] = i;
+ for (i = 0; i < SIZE2; i++)
+ A[i] = B[i] = i;
MPI_Win_create(NULL, 0, 1, MPI_INFO_NULL, CommDeuce, &win);
for (j = 0; j < 2; j++) {
- for (i=0; i<SIZE1; i++) {
+ for (i = 0; i < SIZE1; i++) {
MPI_Win_lock(MPI_LOCK_SHARED, 1, j == 0 ? 0 : MPI_MODE_NOCHECK, win);
- MPI_Put(A+i, 1, MPI_INT, 1, i, 1, MPI_INT, win);
+ MPI_Put(A + i, 1, MPI_INT, 1, i, 1, MPI_INT, win);
MPI_Win_unlock(1, win);
}
- for (i=0; i<SIZE1; i++) {
+ for (i = 0; i < SIZE1; i++) {
MPI_Win_lock(MPI_LOCK_SHARED, 1, j == 0 ? 0 : MPI_MODE_NOCHECK, win);
- MPI_Get(B+i, 1, MPI_INT, 1, SIZE1+i, 1, MPI_INT, win);
+ MPI_Get(B + i, 1, MPI_INT, 1, SIZE1 + i, 1, MPI_INT, win);
MPI_Win_unlock(1, win);
}
}
MPI_Win_free(&win);
- for (i=0; i<SIZE1; i++)
- if (B[i] != (-4)*(i+SIZE1)) {
- SQUELCH( printf("Get Error: B[%d] is %d, should be %d\n", i, B[i], (-4)*(i+SIZE1)); );
+ for (i = 0; i < SIZE1; i++)
+ if (B[i] != (-4) * (i + SIZE1)) {
+ SQUELCH(printf
+ ("Get Error: B[%d] is %d, should be %d\n", i, B[i],
+ (-4) * (i + SIZE1)););
errs++;
}
}
else { /* rank=1 */
- for (i=0; i<SIZE2; i++) B[i] = (-4)*i;
- MPI_Win_create(B, SIZE2*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
+ for (i = 0; i < SIZE2; i++)
+ B[i] = (-4) * i;
+ MPI_Win_create(B, SIZE2 * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
MPI_Win_free(&win);
- for (i=0; i<SIZE1; i++) {
+ for (i = 0; i < SIZE1; i++) {
if (B[i] != i) {
- SQUELCH( printf("Put Error: B[%d] is %d, should be %d\n", i, B[i], i); );
+ SQUELCH(printf("Put Error: B[%d] is %d, should be %d\n", i, B[i], i););
errs++;
}
}
@@ -76,6 +80,6 @@ int main(int argc, char *argv[])
}
MPI_Comm_free(&CommDeuce);
MTest_Finalize(errs);
- MPI_Finalize();
- return 0;
-}
+ MPI_Finalize();
+ return 0;
+}
diff --git a/test/mpi/rma/test4_am.c b/test/mpi/rma/test4_am.c
index 83cb3ef..0599439 100644
--- a/test/mpi/rma/test4_am.c
+++ b/test/mpi/rma/test4_am.c
@@ -3,13 +3,13 @@
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include "stdio.h"
#include "stdlib.h"
#include "mpitest.h"
#include "squelch.h"
-/* tests passive target RMA on 2 processes. tests the lock-single_op-unlock
+/* tests passive target RMA on 2 processes. tests the lock-single_op-unlock
optimization. */
/* same as test4.c but uses alloc_mem */
@@ -17,16 +17,16 @@
#define SIZE1 100
#define SIZE2 200
-int main(int argc, char *argv[])
-{
- int rank, nprocs, *A, *B, i;
+int main(int argc, char *argv[])
+{
+ int rank, nprocs, *A, *B, i;
MPI_Comm CommDeuce;
MPI_Win win;
int errs = 0;
- MTest_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (nprocs < 2) {
printf("Run this program with 2 or more processes\n");
@@ -48,38 +48,42 @@ int main(int argc, char *argv[])
}
if (rank == 0) {
- for (i=0; i<SIZE2; i++) A[i] = B[i] = i;
+ for (i = 0; i < SIZE2; i++)
+ A[i] = B[i] = i;
MPI_Win_create(NULL, 0, 1, MPI_INFO_NULL, CommDeuce, &win);
- for (i=0; i<SIZE1; i++) {
+ for (i = 0; i < SIZE1; i++) {
MPI_Win_lock(MPI_LOCK_SHARED, 1, 0, win);
- MPI_Put(A+i, 1, MPI_INT, 1, i, 1, MPI_INT, win);
+ MPI_Put(A + i, 1, MPI_INT, 1, i, 1, MPI_INT, win);
MPI_Win_unlock(1, win);
}
- for (i=0; i<SIZE1; i++) {
+ for (i = 0; i < SIZE1; i++) {
MPI_Win_lock(MPI_LOCK_SHARED, 1, 0, win);
- MPI_Get(B+i, 1, MPI_INT, 1, SIZE1+i, 1, MPI_INT, win);
+ MPI_Get(B + i, 1, MPI_INT, 1, SIZE1 + i, 1, MPI_INT, win);
MPI_Win_unlock(1, win);
}
MPI_Win_free(&win);
- for (i=0; i<SIZE1; i++)
- if (B[i] != (-4)*(i+SIZE1)) {
- SQUELCH( printf("Get Error: B[%d] is %d, should be %d\n", i, B[i], (-4)*(i+SIZE1)); );
+ for (i = 0; i < SIZE1; i++)
+ if (B[i] != (-4) * (i + SIZE1)) {
+ SQUELCH(printf
+ ("Get Error: B[%d] is %d, should be %d\n", i, B[i],
+ (-4) * (i + SIZE1)););
errs++;
}
}
else { /* rank=1 */
- for (i=0; i<SIZE2; i++) B[i] = (-4)*i;
- MPI_Win_create(B, SIZE2*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
+ for (i = 0; i < SIZE2; i++)
+ B[i] = (-4) * i;
+ MPI_Win_create(B, SIZE2 * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
MPI_Win_free(&win);
- for (i=0; i<SIZE1; i++) {
+ for (i = 0; i < SIZE1; i++) {
if (B[i] != i) {
- SQUELCH( printf("Put Error: B[%d] is %d, should be %d\n", i, B[i], i); );
+ SQUELCH(printf("Put Error: B[%d] is %d, should be %d\n", i, B[i], i););
errs++;
}
}
@@ -90,6 +94,6 @@ int main(int argc, char *argv[])
}
MPI_Comm_free(&CommDeuce);
MTest_Finalize(errs);
- MPI_Finalize();
- return 0;
-}
+ MPI_Finalize();
+ return 0;
+}
diff --git a/test/mpi/rma/test5.c b/test/mpi/rma/test5.c
index 4cc02cf..56b293a 100644
--- a/test/mpi/rma/test5.c
+++ b/test/mpi/rma/test5.c
@@ -3,7 +3,7 @@
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include "stdio.h"
#include "mpitest.h"
#include "squelch.h"
@@ -12,17 +12,17 @@
#define SIZE 2000
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[])
+{
int rank, nprocs, i, A[SIZE], B[SIZE];
MPI_Comm CommDeuce;
MPI_Win win;
int errs = 0;
- MTest_Init(&argc,&argv);
+ MTest_Init(&argc, &argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
- MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (nprocs < 2) {
printf("Run this program with 2 or more processes\n");
@@ -33,34 +33,34 @@ int main(int argc, char *argv[])
if (rank < 2) {
if (rank == 0) {
- for (i=0; i<SIZE; i++)
+ for (i = 0; i < SIZE; i++)
B[i] = 500 + i;
- MPI_Win_create(B, SIZE*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
+ MPI_Win_create(B, SIZE * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
MPI_Win_fence(0, win);
- for (i=0; i<SIZE; i++) {
- A[i] = i+100;
+ for (i = 0; i < SIZE; i++) {
+ A[i] = i + 100;
MPI_Get(&A[i], 1, MPI_INT, 1, i, 1, MPI_INT, win);
}
MPI_Win_fence(0, win);
- for (i=0; i<SIZE; i++)
+ for (i = 0; i < SIZE; i++)
if (A[i] != 1000 + i) {
- SQUELCH( printf("Rank 0: A[%d] is %d, should be %d\n", i, A[i], 1000+i); );
+ SQUELCH(printf("Rank 0: A[%d] is %d, should be %d\n", i, A[i], 1000 + i););
errs++;
}
}
if (rank == 1) {
- for (i=0; i<SIZE; i++)
+ for (i = 0; i < SIZE; i++)
A[i] = 1000 + i;
- MPI_Win_create(A, SIZE*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
+ MPI_Win_create(A, SIZE * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
MPI_Win_fence(0, win);
- for (i=0; i<SIZE; i++) {
- B[i] = i+200;
+ for (i = 0; i < SIZE; i++) {
+ B[i] = i + 200;
MPI_Get(&B[i], 1, MPI_INT, 0, i, 1, MPI_INT, win);
}
MPI_Win_fence(0, win);
- for (i=0; i<SIZE; i++)
+ for (i = 0; i < SIZE; i++)
if (B[i] != 500 + i) {
- SQUELCH( printf("Rank 1: B[%d] is %d, should be %d\n", i, B[i], 500+i); );
+ SQUELCH(printf("Rank 1: B[%d] is %d, should be %d\n", i, B[i], 500 + i););
errs++;
}
}
@@ -69,6 +69,6 @@ int main(int argc, char *argv[])
}
MPI_Comm_free(&CommDeuce);
MTest_Finalize(errs);
- MPI_Finalize();
- return 0;
-}
+ MPI_Finalize();
+ return 0;
+}
diff --git a/test/mpi/rma/test5_am.c b/test/mpi/rma/test5_am.c
index f0482d3..9e963f0 100644
--- a/test/mpi/rma/test5_am.c
+++ b/test/mpi/rma/test5_am.c
@@ -3,7 +3,7 @@
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include "stdio.h"
#include "mpitest.h"
#include "squelch.h"
@@ -14,17 +14,17 @@
#define SIZE 2000
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[])
+{
int rank, nprocs, i, *A, *B;
MPI_Comm CommDeuce;
MPI_Win win;
int errs = 0;
- MTest_Init(&argc,&argv);
+ MTest_Init(&argc, &argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
- MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (nprocs < 2) {
printf("Run this program with 2 or more processes\n");
@@ -46,34 +46,34 @@ int main(int argc, char *argv[])
}
if (rank == 0) {
- for (i=0; i<SIZE; i++)
+ for (i = 0; i < SIZE; i++)
B[i] = 500 + i;
- MPI_Win_create(B, SIZE*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
+ MPI_Win_create(B, SIZE * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
MPI_Win_fence(0, win);
- for (i=0; i<SIZE; i++) {
- A[i] = i+100;
+ for (i = 0; i < SIZE; i++) {
+ A[i] = i + 100;
MPI_Get(&A[i], 1, MPI_INT, 1, i, 1, MPI_INT, win);
}
MPI_Win_fence(0, win);
- for (i=0; i<SIZE; i++)
+ for (i = 0; i < SIZE; i++)
if (A[i] != 1000 + i) {
- SQUELCH( printf("Rank 0: A[%d] is %d, should be %d\n", i, A[i], 1000+i); );
+ SQUELCH(printf("Rank 0: A[%d] is %d, should be %d\n", i, A[i], 1000 + i););
errs++;
}
}
if (rank == 1) {
- for (i=0; i<SIZE; i++)
+ for (i = 0; i < SIZE; i++)
A[i] = 1000 + i;
- MPI_Win_create(A, SIZE*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
+ MPI_Win_create(A, SIZE * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
MPI_Win_fence(0, win);
- for (i=0; i<SIZE; i++) {
- B[i] = i+200;
+ for (i = 0; i < SIZE; i++) {
+ B[i] = i + 200;
MPI_Get(&B[i], 1, MPI_INT, 0, i, 1, MPI_INT, win);
}
MPI_Win_fence(0, win);
- for (i=0; i<SIZE; i++)
+ for (i = 0; i < SIZE; i++)
if (B[i] != 500 + i) {
- SQUELCH( printf("Rank 1: B[%d] is %d, should be %d\n", i, B[i], 500+i); );
+ SQUELCH(printf("Rank 1: B[%d] is %d, should be %d\n", i, B[i], 500 + i););
errs++;
}
}
@@ -87,6 +87,6 @@ int main(int argc, char *argv[])
MPI_Comm_free(&CommDeuce);
MTest_Finalize(errs);
- MPI_Finalize();
- return 0;
-}
+ MPI_Finalize();
+ return 0;
+}
diff --git a/test/mpi/rma/transpose1.c b/test/mpi/rma/transpose1.c
index 908ecc0..d2ed149 100644
--- a/test/mpi/rma/transpose1.c
+++ b/test/mpi/rma/transpose1.c
@@ -3,7 +3,7 @@
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include "stdio.h"
#include <stdlib.h>
#include "mpitest.h"
@@ -15,17 +15,17 @@
#define NROWS 1000
#define NCOLS 1000
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[])
+{
int rank, nprocs, **A, *A_data, i, j;
MPI_Comm CommDeuce;
MPI_Win win;
MPI_Datatype column, xpose;
int errs = 0;
- MTest_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (nprocs < 2) {
printf("Run this program with 2 or more processes\n");
@@ -39,14 +39,13 @@ int main(int argc, char *argv[])
A = (int **) malloc(NROWS * sizeof(int *));
A[0] = A_data;
- for (i=1; i<NROWS; i++)
- A[i] = A[i-1] + NCOLS;
+ for (i = 1; i < NROWS; i++)
+ A[i] = A[i - 1] + NCOLS;
- if (rank == 0)
- {
- for (i=0; i<NROWS; i++)
- for (j=0; j<NCOLS; j++)
- A[i][j] = i*NCOLS + j;
+ if (rank == 0) {
+ for (i = 0; i < NROWS; i++)
+ for (j = 0; j < NCOLS; j++)
+ A[i][j] = i * NCOLS + j;
/* create datatype for one column */
MPI_Type_vector(NROWS, 1, NCOLS, MPI_INT, &column);
@@ -58,40 +57,35 @@ int main(int argc, char *argv[])
MPI_Win_fence(0, win);
- MPI_Put(&A[0][0], NROWS*NCOLS, MPI_INT, 1, 0, 1, xpose, win);
+ MPI_Put(&A[0][0], NROWS * NCOLS, MPI_INT, 1, 0, 1, xpose, win);
MPI_Type_free(&column);
MPI_Type_free(&xpose);
MPI_Win_fence(0, win);
}
- else if (rank == 1)
- {
- for (i=0; i<NROWS; i++)
- for (j=0; j<NCOLS; j++)
+ else if (rank == 1) {
+ for (i = 0; i < NROWS; i++)
+ for (j = 0; j < NCOLS; j++)
A[i][j] = -1;
- MPI_Win_create(&A[0][0], NROWS*NCOLS*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
+ MPI_Win_create(&A[0][0], NROWS * NCOLS * sizeof(int), sizeof(int), MPI_INFO_NULL,
+ CommDeuce, &win);
MPI_Win_fence(0, win);
MPI_Win_fence(0, win);
- for (j=0; j<NCOLS; j++)
- {
- for (i=0; i<NROWS; i++)
- {
- if (A[j][i] != i*NCOLS + j)
- {
- if (errs < 50)
- {
+ for (j = 0; j < NCOLS; j++) {
+ for (i = 0; i < NROWS; i++) {
+ if (A[j][i] != i * NCOLS + j) {
+ if (errs < 50) {
printf("Error: A[%d][%d]=%d should be %d\n", j, i,
- A[j][i], i*NCOLS + j);
+ A[j][i], i * NCOLS + j);
}
errs++;
}
}
}
- if (errs >= 50)
- {
+ if (errs >= 50) {
printf("Total number of errors: %d\n", errs);
}
}
@@ -104,6 +98,6 @@ int main(int argc, char *argv[])
}
MPI_Comm_free(&CommDeuce);
MTest_Finalize(errs);
- MPI_Finalize();
- return 0;
-}
+ MPI_Finalize();
+ return 0;
+}
diff --git a/test/mpi/rma/transpose2.c b/test/mpi/rma/transpose2.c
index bfb30c4..101e1ea 100644
--- a/test/mpi/rma/transpose2.c
+++ b/test/mpi/rma/transpose2.c
@@ -3,30 +3,30 @@
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include "stdio.h"
#include "mpitest.h"
/* transposes a matrix using put, fence, and derived
datatypes. Uses vector and struct (Example 3.33 from MPI 1.1
Standard). We could use vector and type_create_resized instead. Run
- on 2 processes */
+ on 2 processes */
#define NROWS 100
#define NCOLS 100
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[])
+{
int rank, nprocs, A[NROWS][NCOLS], i, j, blocklen[2];
MPI_Comm CommDeuce;
MPI_Aint disp[2];
MPI_Win win;
MPI_Datatype column, column1, type[2];
- int errs=0;
+ int errs = 0;
- MTest_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (nprocs < 2) {
printf("Run this program with 2 or more processes\n");
@@ -36,23 +36,22 @@ int main(int argc, char *argv[])
MPI_Comm_split(MPI_COMM_WORLD, (rank < 2), rank, &CommDeuce);
if (rank < 2) {
- if (rank == 0)
- {
- for (i=0; i<NROWS; i++)
- for (j=0; j<NCOLS; j++)
- A[i][j] = i*NCOLS + j;
+ if (rank == 0) {
+ for (i = 0; i < NROWS; i++)
+ for (j = 0; j < NCOLS; j++)
+ A[i][j] = i * NCOLS + j;
/* create datatype for one column */
MPI_Type_vector(NROWS, 1, NCOLS, MPI_INT, &column);
/* create datatype for one column, with the extent of one
- integer. we could use type_create_resized instead. */
+ * integer. we could use type_create_resized instead. */
disp[0] = 0;
disp[1] = sizeof(int);
- type[0] = column;
- type[1] = MPI_UB;
- blocklen[0] = 1;
- blocklen[1] = 1;
+ type[0] = column;
+ type[1] = MPI_UB;
+ blocklen[0] = 1;
+ blocklen[1] = 1;
MPI_Type_struct(2, blocklen, disp, type, &column1);
MPI_Type_commit(&column1);
@@ -60,40 +59,35 @@ int main(int argc, char *argv[])
MPI_Win_fence(0, win);
- MPI_Put(A, NROWS*NCOLS, MPI_INT, 1, 0, NCOLS, column1, win);
+ MPI_Put(A, NROWS * NCOLS, MPI_INT, 1, 0, NCOLS, column1, win);
MPI_Type_free(&column);
MPI_Type_free(&column1);
MPI_Win_fence(0, win);
}
- else
- { /* rank=1 */
- for (i=0; i<NROWS; i++)
- for (j=0; j<NCOLS; j++)
+ else { /* rank=1 */
+ for (i = 0; i < NROWS; i++)
+ for (j = 0; j < NCOLS; j++)
A[i][j] = -1;
- MPI_Win_create(A, NROWS*NCOLS*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
+ MPI_Win_create(A, NROWS * NCOLS * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce,
+ &win);
MPI_Win_fence(0, win);
MPI_Win_fence(0, win);
- for (j=0; j<NCOLS; j++)
- {
- for (i=0; i<NROWS; i++)
- {
- if (A[j][i] != i*NCOLS + j)
- {
- if (errs < 50)
- {
+ for (j = 0; j < NCOLS; j++) {
+ for (i = 0; i < NROWS; i++) {
+ if (A[j][i] != i * NCOLS + j) {
+ if (errs < 50) {
printf("Error: A[%d][%d]=%d should be %d\n", j, i,
- A[j][i], i*NCOLS + j);
+ A[j][i], i * NCOLS + j);
}
errs++;
}
}
}
- if (errs >= 50)
- {
+ if (errs >= 50) {
printf("Total number of errors: %d\n", errs);
}
}
@@ -102,6 +96,6 @@ int main(int argc, char *argv[])
MPI_Comm_free(&CommDeuce);
MTest_Finalize(errs);
- MPI_Finalize();
- return 0;
-}
+ MPI_Finalize();
+ return 0;
+}
diff --git a/test/mpi/rma/transpose3.c b/test/mpi/rma/transpose3.c
index e08ee80..50a5c4a 100644
--- a/test/mpi/rma/transpose3.c
+++ b/test/mpi/rma/transpose3.c
@@ -3,7 +3,7 @@
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include "stdio.h"
#include "mpitest.h"
#include "squelch.h"
@@ -15,18 +15,18 @@
#define NROWS 100
#define NCOLS 100
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[])
+{
int rank, nprocs, i, j, destrank;
MPI_Comm CommDeuce;
MPI_Win win;
MPI_Datatype column, xpose;
MPI_Group comm_group, group;
- int errs=0;
+ int errs = 0;
- MTest_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (nprocs < 2) {
printf("Run this program with 2 or more processes\n");
@@ -35,17 +35,15 @@ int main(int argc, char *argv[])
MPI_Comm_split(MPI_COMM_WORLD, (rank < 2), rank, &CommDeuce);
- if (rank < 2)
- {
+ if (rank < 2) {
MPI_Comm_group(CommDeuce, &comm_group);
- if (rank == 0)
- {
+ if (rank == 0) {
int A[NROWS][NCOLS];
- for (i=0; i<NROWS; i++)
- for (j=0; j<NCOLS; j++)
- A[i][j] = i*NCOLS + j;
+ for (i = 0; i < NROWS; i++)
+ for (j = 0; j < NCOLS; j++)
+ A[i][j] = i * NCOLS + j;
/* create datatype for one column */
MPI_Type_vector(NROWS, 1, NCOLS, MPI_INT, &column);
@@ -64,26 +62,27 @@ int main(int argc, char *argv[])
MPI_Group_incl(comm_group, 1, &destrank, &group);
MPI_Win_start(group, 0, win);
- MPI_Put(A, NROWS*NCOLS, MPI_INT, 1, 0, 1, xpose, win);
+ MPI_Put(A, NROWS * NCOLS, MPI_INT, 1, 0, 1, xpose, win);
MPI_Type_free(&column);
MPI_Type_free(&xpose);
MPI_Win_complete(win);
}
- else
- { /* rank=1 */
+ else { /* rank=1 */
int *A;
#ifdef USE_WIN_ALLOCATE
- MPI_Win_allocate(NROWS*NCOLS*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &A, &win);
+ MPI_Win_allocate(NROWS * NCOLS * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &A,
+ &win);
#else
- MPI_Alloc_mem(NROWS*NCOLS*sizeof(int), MPI_INFO_NULL, &A);
- MPI_Win_create(A, NROWS*NCOLS*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
+ MPI_Alloc_mem(NROWS * NCOLS * sizeof(int), MPI_INFO_NULL, &A);
+ MPI_Win_create(A, NROWS * NCOLS * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce,
+ &win);
#endif
MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, win);
- for (i=0; i<NROWS; i++)
- for (j=0; j<NCOLS; j++)
- A[i*NCOLS+j] = -1;
+ for (i = 0; i < NROWS; i++)
+ for (j = 0; j < NCOLS; j++)
+ A[i * NCOLS + j] = -1;
MPI_Win_unlock(rank, win);
destrank = 0;
@@ -91,23 +90,18 @@ int main(int argc, char *argv[])
MPI_Win_post(group, 0, win);
MPI_Win_wait(win);
- for (j=0; j<NCOLS; j++)
- {
- for (i=0; i<NROWS; i++)
- {
- if (A[j*NROWS+i] != i*NCOLS + j)
- {
- if (errs < 50)
- {
- SQUELCH( printf("Error: A[%d][%d]=%d should be %d\n", j, i,
- A[j*NROWS+i], i*NCOLS + j); );
+ for (j = 0; j < NCOLS; j++) {
+ for (i = 0; i < NROWS; i++) {
+ if (A[j * NROWS + i] != i * NCOLS + j) {
+ if (errs < 50) {
+ SQUELCH(printf("Error: A[%d][%d]=%d should be %d\n", j, i,
+ A[j * NROWS + i], i * NCOLS + j););
}
errs++;
}
}
}
- if (errs >= 50)
- {
+ if (errs >= 50) {
printf("Total number of errors: %d\n", errs);
}
#ifndef USE_WIN_ALLOCATE
@@ -121,6 +115,6 @@ int main(int argc, char *argv[])
}
MPI_Comm_free(&CommDeuce);
MTest_Finalize(errs);
- MPI_Finalize();
- return 0;
-}
+ MPI_Finalize();
+ return 0;
+}
diff --git a/test/mpi/rma/transpose4.c b/test/mpi/rma/transpose4.c
index 6e81c43..1559a9d 100644
--- a/test/mpi/rma/transpose4.c
+++ b/test/mpi/rma/transpose4.c
@@ -3,7 +3,7 @@
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include "stdio.h"
#include "mpitest.h"
@@ -14,17 +14,17 @@
#define NROWS 100
#define NCOLS 100
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[])
+{
int rank, nprocs, A[NROWS][NCOLS], i, j;
MPI_Comm CommDeuce;
MPI_Win win;
MPI_Datatype column, xpose;
int errs = 0;
- MTest_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (nprocs < 2) {
printf("Run this program with 2 or more processes\n");
@@ -33,12 +33,11 @@ int main(int argc, char *argv[])
MPI_Comm_split(MPI_COMM_WORLD, (rank < 2), rank, &CommDeuce);
- if (rank < 2)
- {
+ if (rank < 2) {
if (rank == 0) {
- for (i=0; i<NROWS; i++)
- for (j=0; j<NCOLS; j++)
- A[i][j] = i*NCOLS + j;
+ for (i = 0; i < NROWS; i++)
+ for (j = 0; j < NCOLS; j++)
+ A[i][j] = i * NCOLS + j;
/* create datatype for one column */
MPI_Type_vector(NROWS, 1, NCOLS, MPI_INT, &column);
@@ -50,7 +49,7 @@ int main(int argc, char *argv[])
MPI_Win_lock(MPI_LOCK_SHARED, 1, 0, win);
- MPI_Put(A, NROWS*NCOLS, MPI_INT, 1, 0, 1, xpose, win);
+ MPI_Put(A, NROWS * NCOLS, MPI_INT, 1, 0, 1, xpose, win);
MPI_Type_free(&column);
MPI_Type_free(&xpose);
@@ -58,20 +57,19 @@ int main(int argc, char *argv[])
MPI_Win_unlock(1, win);
MPI_Win_free(&win);
}
- else
- { /* rank=1 */
- for (i=0; i<NROWS; i++)
- for (j=0; j<NCOLS; j++)
+ else { /* rank=1 */
+ for (i = 0; i < NROWS; i++)
+ for (j = 0; j < NCOLS; j++)
A[i][j] = -1;
- MPI_Win_create(A, NROWS*NCOLS*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
+ MPI_Win_create(A, NROWS * NCOLS * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce,
+ &win);
MPI_Win_free(&win);
- for (j=0; j<NCOLS; j++)
- for (i=0; i<NROWS; i++)
- if (A[j][i] != i*NCOLS + j) {
- printf("Error: A[%d][%d]=%d should be %d\n", j, i,
- A[j][i], i*NCOLS + j);
+ for (j = 0; j < NCOLS; j++)
+ for (i = 0; i < NROWS; i++)
+ if (A[j][i] != i * NCOLS + j) {
+ printf("Error: A[%d][%d]=%d should be %d\n", j, i, A[j][i], i * NCOLS + j);
errs++;
}
}
@@ -79,6 +77,6 @@ int main(int argc, char *argv[])
MPI_Comm_free(&CommDeuce);
MTest_Finalize(errs);
- MPI_Finalize();
- return 0;
-}
+ MPI_Finalize();
+ return 0;
+}
diff --git a/test/mpi/rma/transpose5.c b/test/mpi/rma/transpose5.c
index 2ae63bd..904fcdd 100644
--- a/test/mpi/rma/transpose5.c
+++ b/test/mpi/rma/transpose5.c
@@ -3,29 +3,29 @@
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include "stdio.h"
#include <stdlib.h>
#include "mpitest.h"
/* This does a transpose-cum-accumulate operation. Uses vector and
hvector datatypes (Example 3.32 from MPI 1.1 Standard). Run on 2
- processes */
+ processes */
#define NROWS 1000
#define NCOLS 1000
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[])
+{
int rank, nprocs, **A, *A_data, i, j;
MPI_Comm CommDeuce;
MPI_Win win;
MPI_Datatype column, xpose;
int errs = 0;
- MTest_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (nprocs < 2) {
printf("Run this program with 2 or more processes\n");
@@ -34,20 +34,18 @@ int main(int argc, char *argv[])
MPI_Comm_split(MPI_COMM_WORLD, (rank < 2), rank, &CommDeuce);
- if (rank < 2)
- {
+ if (rank < 2) {
A_data = (int *) malloc(NROWS * NCOLS * sizeof(int));
A = (int **) malloc(NROWS * sizeof(int *));
A[0] = A_data;
- for (i=1; i<NROWS; i++)
- A[i] = A[i-1] + NCOLS;
+ for (i = 1; i < NROWS; i++)
+ A[i] = A[i - 1] + NCOLS;
- if (rank == 0)
- {
- for (i=0; i<NROWS; i++)
- for (j=0; j<NCOLS; j++)
- A[i][j] = i*NCOLS + j;
+ if (rank == 0) {
+ for (i = 0; i < NROWS; i++)
+ for (j = 0; j < NCOLS; j++)
+ A[i][j] = i * NCOLS + j;
/* create datatype for one column */
MPI_Type_vector(NROWS, 1, NCOLS, MPI_INT, &column);
@@ -59,40 +57,35 @@ int main(int argc, char *argv[])
MPI_Win_fence(0, win);
- MPI_Accumulate(&A[0][0], NROWS*NCOLS, MPI_INT, 1, 0, 1, xpose, MPI_SUM, win);
+ MPI_Accumulate(&A[0][0], NROWS * NCOLS, MPI_INT, 1, 0, 1, xpose, MPI_SUM, win);
MPI_Type_free(&column);
MPI_Type_free(&xpose);
MPI_Win_fence(0, win);
}
- else
- { /* rank=1 */
- for (i=0; i<NROWS; i++)
- for (j=0; j<NCOLS; j++)
- A[i][j] = i*NCOLS + j;
- MPI_Win_create(&A[0][0], NROWS*NCOLS*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
+ else { /* rank=1 */
+ for (i = 0; i < NROWS; i++)
+ for (j = 0; j < NCOLS; j++)
+ A[i][j] = i * NCOLS + j;
+ MPI_Win_create(&A[0][0], NROWS * NCOLS * sizeof(int), sizeof(int), MPI_INFO_NULL,
+ CommDeuce, &win);
MPI_Win_fence(0, win);
MPI_Win_fence(0, win);
- for (j=0; j<NCOLS; j++)
- {
- for (i=0; i<NROWS; i++)
- {
- if (A[j][i] != i*NCOLS + j + j*NCOLS + i)
- {
- if (errs < 50)
- {
+ for (j = 0; j < NCOLS; j++) {
+ for (i = 0; i < NROWS; i++) {
+ if (A[j][i] != i * NCOLS + j + j * NCOLS + i) {
+ if (errs < 50) {
printf("Error: A[%d][%d]=%d should be %d\n", j, i,
- A[j][i], i*NCOLS + j + j*NCOLS + i);
+ A[j][i], i * NCOLS + j + j * NCOLS + i);
}
errs++;
}
}
}
- if (errs >= 50)
- {
+ if (errs >= 50) {
printf("Total number of errors: %d\n", errs);
}
}
@@ -106,6 +99,6 @@ int main(int argc, char *argv[])
MPI_Comm_free(&CommDeuce);
MTest_Finalize(errs);
- MPI_Finalize();
- return 0;
-}
+ MPI_Finalize();
+ return 0;
+}
diff --git a/test/mpi/rma/transpose6.c b/test/mpi/rma/transpose6.c
index 09471da..c9f36e1 100644
--- a/test/mpi/rma/transpose6.c
+++ b/test/mpi/rma/transpose6.c
@@ -3,74 +3,69 @@
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include "stdio.h"
#include "mpitest.h"
-/* This does a local transpose-cum-accumulate operation. Uses
+/* This does a local transpose-cum-accumulate operation. Uses
vector and hvector datatypes (Example 3.32 from MPI 1.1
Standard). Run on 1 process. */
#define NROWS 100
#define NCOLS 100
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[])
+{
int rank, nprocs, A[NROWS][NCOLS], B[NROWS][NCOLS], i, j;
MPI_Win win;
MPI_Datatype column, xpose;
int errs = 0;
-
- MTest_Init(&argc,&argv);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
- if (rank==0)
- {
- for (i=0; i<NROWS; i++)
- for (j=0; j<NCOLS; j++)
- A[i][j] = B[i][j] = i*NCOLS + j;
-
+ MTest_Init(&argc, &argv);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+
+ if (rank == 0) {
+ for (i = 0; i < NROWS; i++)
+ for (j = 0; j < NCOLS; j++)
+ A[i][j] = B[i][j] = i * NCOLS + j;
+
/* create datatype for one column */
MPI_Type_vector(NROWS, 1, NCOLS, MPI_INT, &column);
/* create datatype for matrix in column-major order */
MPI_Type_hvector(NCOLS, 1, sizeof(int), column, &xpose);
MPI_Type_commit(&xpose);
-
- MPI_Win_create(B, NROWS*NCOLS*sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_SELF, &win);
-
- MPI_Win_fence(0, win);
-
- MPI_Accumulate(A, NROWS*NCOLS, MPI_INT, 0, 0, 1, xpose, MPI_SUM, win);
-
+
+ MPI_Win_create(B, NROWS * NCOLS * sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_SELF,
+ &win);
+
+ MPI_Win_fence(0, win);
+
+ MPI_Accumulate(A, NROWS * NCOLS, MPI_INT, 0, 0, 1, xpose, MPI_SUM, win);
+
MPI_Type_free(&column);
MPI_Type_free(&xpose);
-
- MPI_Win_fence(0, win);
-
- for (j=0; j<NCOLS; j++)
- {
- for (i=0; i<NROWS; i++)
- {
- if (B[j][i] != i*NCOLS + j + j*NCOLS + i)
- {
- if (errs < 20)
- {
- printf("Error: B[%d][%d]=%d should be %d\n", j, i,
- B[j][i], i*NCOLS + j + j*NCOLS + i);
- }
+
+ MPI_Win_fence(0, win);
+
+ for (j = 0; j < NCOLS; j++) {
+ for (i = 0; i < NROWS; i++) {
+ if (B[j][i] != i * NCOLS + j + j * NCOLS + i) {
+ if (errs < 20) {
+ printf("Error: B[%d][%d]=%d should be %d\n", j, i,
+ B[j][i], i * NCOLS + j + j * NCOLS + i);
+ }
errs++;
}
- }
+ }
}
- if (errs >= 20)
- {
- printf("Total number of errors: %d\n", errs);
+ if (errs >= 20) {
+ printf("Total number of errors: %d\n", errs);
}
-
- MPI_Win_free(&win);
+
+ MPI_Win_free(&win);
}
MTest_Finalize(errs);
- MPI_Finalize();
- return 0;
-}
+ MPI_Finalize();
+ return 0;
+}
diff --git a/test/mpi/rma/transpose7.c b/test/mpi/rma/transpose7.c
index d78b2dd..4b4f6a0 100644
--- a/test/mpi/rma/transpose7.c
+++ b/test/mpi/rma/transpose7.c
@@ -3,7 +3,7 @@
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include <stdio.h>
#include <stdlib.h>
#include "mpitest.h"
@@ -15,17 +15,17 @@
#define NROWS 1000
#define NCOLS 1000
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[])
+{
int rank, nprocs, **A, *A_data, i, j;
MPI_Comm CommDeuce;
MPI_Win win;
MPI_Datatype column, xpose;
int errs = 0;
- MTest_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (nprocs < 2) {
printf("Run this program with 2 or more processes\n");
@@ -34,19 +34,17 @@ int main(int argc, char *argv[])
MPI_Comm_split(MPI_COMM_WORLD, (rank < 2), rank, &CommDeuce);
- if (rank < 2)
- {
+ if (rank < 2) {
A_data = (int *) malloc(NROWS * NCOLS * sizeof(int));
A = (int **) malloc(NROWS * sizeof(int *));
A[0] = A_data;
- for (i=1; i<NROWS; i++)
- A[i] = A[i-1] + NCOLS;
+ for (i = 1; i < NROWS; i++)
+ A[i] = A[i - 1] + NCOLS;
- if (rank == 0)
- {
- for (i=0; i<NROWS; i++)
- for (j=0; j<NCOLS; j++)
+ if (rank == 0) {
+ for (i = 0; i < NROWS; i++)
+ for (j = 0; j < NCOLS; j++)
A[i][j] = -1;
/* create datatype for one column */
@@ -59,40 +57,35 @@ int main(int argc, char *argv[])
MPI_Win_fence(0, win);
- MPI_Get(&A[0][0], NROWS*NCOLS, MPI_INT, 1, 0, 1, xpose, win);
+ MPI_Get(&A[0][0], NROWS * NCOLS, MPI_INT, 1, 0, 1, xpose, win);
MPI_Type_free(&column);
MPI_Type_free(&xpose);
MPI_Win_fence(0, win);
- for (j=0; j<NCOLS; j++)
- {
- for (i=0; i<NROWS; i++)
- {
- if (A[j][i] != i*NCOLS + j)
- {
- if (errs < 50)
- {
+ for (j = 0; j < NCOLS; j++) {
+ for (i = 0; i < NROWS; i++) {
+ if (A[j][i] != i * NCOLS + j) {
+ if (errs < 50) {
printf("Error: A[%d][%d]=%d should be %d\n", j, i,
- A[j][i], i*NCOLS + j);
+ A[j][i], i * NCOLS + j);
}
errs++;
}
}
}
- if (errs >= 50)
- {
+ if (errs >= 50) {
printf("Total number of errors: %d\n", errs);
}
}
- else
- {
- for (i=0; i<NROWS; i++)
- for (j=0; j<NCOLS; j++)
- A[i][j] = i*NCOLS + j;
+ else {
+ for (i = 0; i < NROWS; i++)
+ for (j = 0; j < NCOLS; j++)
+ A[i][j] = i * NCOLS + j;
- MPI_Win_create(&A[0][0], NROWS*NCOLS*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
+ MPI_Win_create(&A[0][0], NROWS * NCOLS * sizeof(int), sizeof(int), MPI_INFO_NULL,
+ CommDeuce, &win);
MPI_Win_fence(0, win);
MPI_Win_fence(0, win);
}
@@ -100,6 +93,6 @@ int main(int argc, char *argv[])
}
MPI_Comm_free(&CommDeuce);
MTest_Finalize(errs);
- MPI_Finalize();
- return 0;
-}
+ MPI_Finalize();
+ return 0;
+}
diff --git a/test/mpi/rma/win_dynamic_acc.c b/test/mpi/rma/win_dynamic_acc.c
index eef403d..d68f467 100644
--- a/test/mpi/rma/win_dynamic_acc.c
+++ b/test/mpi/rma/win_dynamic_acc.c
@@ -15,13 +15,14 @@
const int verbose = 0;
-int main(int argc, char **argv) {
- int i, rank, nproc;
- int errors = 0, all_errors = 0;
- int val = 0, one = 1;
- int iter;
+int main(int argc, char **argv)
+{
+ int i, rank, nproc;
+ int errors = 0, all_errors = 0;
+ int val = 0, one = 1;
+ int iter;
MPI_Aint *val_ptrs;
- MPI_Win dyn_win;
+ MPI_Win dyn_win;
MPI_Init(&argc, &argv);
@@ -33,22 +34,22 @@ int main(int argc, char **argv) {
val_ptrs = malloc(nproc * sizeof(MPI_Aint));
MPI_Get_address(&val, &val_ptrs[rank]);
- MPI_Allgather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, val_ptrs, 1, MPI_AINT,
- MPI_COMM_WORLD);
+ MPI_Allgather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, val_ptrs, 1, MPI_AINT, MPI_COMM_WORLD);
MPI_Win_create_dynamic(MPI_INFO_NULL, MPI_COMM_WORLD, &dyn_win);
MPI_Win_attach(dyn_win, &val, sizeof(int));
for (i = 0; i < iter; i++) {
- MPI_Win_fence(MPI_MODE_NOPRECEDE, dyn_win);
- MPI_Accumulate(&one, 1, MPI_INT, i%nproc, val_ptrs[i%nproc], 1, MPI_INT, MPI_SUM, dyn_win);
- MPI_Win_fence(MPI_MODE_NOSUCCEED, dyn_win);
+ MPI_Win_fence(MPI_MODE_NOPRECEDE, dyn_win);
+ MPI_Accumulate(&one, 1, MPI_INT, i % nproc, val_ptrs[i % nproc], 1, MPI_INT, MPI_SUM,
+ dyn_win);
+ MPI_Win_fence(MPI_MODE_NOSUCCEED, dyn_win);
}
MPI_Barrier(MPI_COMM_WORLD);
/* Read and verify my data */
- if ( val != iter ) {
+ if (val != iter) {
errors++;
printf("%d -- Got %d, expected %d\n", rank, val, iter);
}
diff --git a/test/mpi/rma/win_flavors.c b/test/mpi/rma/win_flavors.c
index c5179c4..4abc1d6 100644
--- a/test/mpi/rma/win_flavors.c
+++ b/test/mpi/rma/win_flavors.c
@@ -10,12 +10,12 @@
#define ELEM_SIZE 8
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
- int rank;
- int errors = 0, all_errors = 0;
- int *flavor, *model, flag;
- void *buf;
+ int rank;
+ int errors = 0, all_errors = 0;
+ int *flavor, *model, flag;
+ void *buf;
MPI_Win window;
MPI_Init(&argc, &argv);
@@ -24,63 +24,67 @@ int main( int argc, char *argv[] )
/** Create using MPI_Win_create() **/
if (rank > 0)
- MPI_Alloc_mem(rank*ELEM_SIZE, MPI_INFO_NULL, &buf);
+ MPI_Alloc_mem(rank * ELEM_SIZE, MPI_INFO_NULL, &buf);
else
- buf = NULL;
+ buf = NULL;
- MPI_Win_create(buf, rank*ELEM_SIZE, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &window);
+ MPI_Win_create(buf, rank * ELEM_SIZE, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &window);
MPI_Win_get_attr(window, MPI_WIN_CREATE_FLAVOR, &flavor, &flag);
if (!flag) {
- printf("%d: MPI_Win_create - Error, no flavor\n", rank);
- errors++;
- } else if (*flavor != MPI_WIN_FLAVOR_CREATE) {
- printf("%d: MPI_Win_create - Error, bad flavor (%d)\n", rank, *flavor);
- errors++;
+ printf("%d: MPI_Win_create - Error, no flavor\n", rank);
+ errors++;
+ }
+ else if (*flavor != MPI_WIN_FLAVOR_CREATE) {
+ printf("%d: MPI_Win_create - Error, bad flavor (%d)\n", rank, *flavor);
+ errors++;
}
MPI_Win_get_attr(window, MPI_WIN_MODEL, &model, &flag);
if (!flag) {
- printf("%d: MPI_Win_create - Error, no model\n", rank);
- errors++;
- } else if ( ! (*model == MPI_WIN_SEPARATE || *model == MPI_WIN_UNIFIED) ) {
- printf("%d: MPI_Win_create - Error, bad model (%d)\n", rank, *model);
- errors++;
+ printf("%d: MPI_Win_create - Error, no model\n", rank);
+ errors++;
+ }
+ else if (!(*model == MPI_WIN_SEPARATE || *model == MPI_WIN_UNIFIED)) {
+ printf("%d: MPI_Win_create - Error, bad model (%d)\n", rank, *model);
+ errors++;
}
MPI_Win_free(&window);
if (buf)
- MPI_Free_mem(buf);
+ MPI_Free_mem(buf);
/** Create using MPI_Win_allocate() **/
- MPI_Win_allocate(rank*ELEM_SIZE, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &buf, &window);
+ MPI_Win_allocate(rank * ELEM_SIZE, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &buf, &window);
if (rank > 0 && buf == NULL) {
- printf("%d: MPI_Win_allocate - Error, bad base pointer\n", rank);
- errors++;
+ printf("%d: MPI_Win_allocate - Error, bad base pointer\n", rank);
+ errors++;
}
MPI_Win_get_attr(window, MPI_WIN_CREATE_FLAVOR, &flavor, &flag);
if (!flag) {
- printf("%d: MPI_Win_allocate - Error, no flavor\n", rank);
- errors++;
- } else if (*flavor != MPI_WIN_FLAVOR_ALLOCATE) {
- printf("%d: MPI_Win_allocate - Error, bad flavor (%d)\n", rank, *flavor);
- errors++;
+ printf("%d: MPI_Win_allocate - Error, no flavor\n", rank);
+ errors++;
+ }
+ else if (*flavor != MPI_WIN_FLAVOR_ALLOCATE) {
+ printf("%d: MPI_Win_allocate - Error, bad flavor (%d)\n", rank, *flavor);
+ errors++;
}
MPI_Win_get_attr(window, MPI_WIN_MODEL, &model, &flag);
if (!flag) {
- printf("%d: MPI_Win_allocate - Error, no model\n", rank);
- errors++;
- } else if (*model != MPI_WIN_SEPARATE && *model != MPI_WIN_UNIFIED) {
- printf("%d: MPI_Win_allocate - Error, bad model (%d)\n", rank, *model);
- errors++;
+ printf("%d: MPI_Win_allocate - Error, no model\n", rank);
+ errors++;
+ }
+ else if (*model != MPI_WIN_SEPARATE && *model != MPI_WIN_UNIFIED) {
+ printf("%d: MPI_Win_allocate - Error, bad model (%d)\n", rank, *model);
+ errors++;
}
MPI_Win_free(&window);
@@ -92,21 +96,23 @@ int main( int argc, char *argv[] )
MPI_Win_get_attr(window, MPI_WIN_CREATE_FLAVOR, &flavor, &flag);
if (!flag) {
- printf("%d: MPI_Win_create_dynamic - Error, no flavor\n", rank);
- errors++;
- } else if (*flavor != MPI_WIN_FLAVOR_DYNAMIC) {
- printf("%d: MPI_Win_create_dynamic - Error, bad flavor (%d)\n", rank, *flavor);
- errors++;
+ printf("%d: MPI_Win_create_dynamic - Error, no flavor\n", rank);
+ errors++;
+ }
+ else if (*flavor != MPI_WIN_FLAVOR_DYNAMIC) {
+ printf("%d: MPI_Win_create_dynamic - Error, bad flavor (%d)\n", rank, *flavor);
+ errors++;
}
MPI_Win_get_attr(window, MPI_WIN_MODEL, &model, &flag);
if (!flag) {
- printf("%d: MPI_Win_create_dynamic - Error, no model\n", rank);
- errors++;
- } else if (*model != MPI_WIN_SEPARATE && *model != MPI_WIN_UNIFIED) {
- printf("%d: MPI_Win_create_dynamic - Error, bad model (%d)\n", rank, *model);
- errors++;
+ printf("%d: MPI_Win_create_dynamic - Error, no model\n", rank);
+ errors++;
+ }
+ else if (*model != MPI_WIN_SEPARATE && *model != MPI_WIN_UNIFIED) {
+ printf("%d: MPI_Win_create_dynamic - Error, bad model (%d)\n", rank, *model);
+ errors++;
}
MPI_Win_free(&window);
diff --git a/test/mpi/rma/win_info.c b/test/mpi/rma/win_info.c
index c490a9f..f5d2beb 100644
--- a/test/mpi/rma/win_info.c
+++ b/test/mpi/rma/win_info.c
@@ -12,15 +12,16 @@
#define VERBOSE 0
-int main(int argc, char **argv) {
- int rank, nproc;
+int main(int argc, char **argv)
+{
+ int rank, nproc;
MPI_Info info_in, info_out;
- int errors = 0, all_errors = 0;
- MPI_Win win;
- void *base;
- char invalid_key[] = "invalid_test_key";
- char buf[MPI_MAX_INFO_VAL];
- int flag;
+ int errors = 0, all_errors = 0;
+ MPI_Win win;
+ void *base;
+ char invalid_key[] = "invalid_test_key";
+ char buf[MPI_MAX_INFO_VAL];
+ int flag;
MPI_Init(&argc, &argv);
@@ -67,7 +68,8 @@ int main(int argc, char **argv) {
printf("%d: no_locks = %s, expected false\n", rank, buf);
errors++;
}
- if (flag && VERBOSE) printf("%d: no_locks = %s\n", rank, buf);
+ if (flag && VERBOSE)
+ printf("%d: no_locks = %s\n", rank, buf);
MPI_Info_free(&info_in);
MPI_Info_free(&info_out);
@@ -88,7 +90,8 @@ int main(int argc, char **argv) {
printf("%d: no_locks = %s, expected true\n", rank, buf);
errors++;
}
- if (flag && VERBOSE) printf("%d: no_locks = %s\n", rank, buf);
+ if (flag && VERBOSE)
+ printf("%d: no_locks = %s\n", rank, buf);
MPI_Info_free(&info_in);
MPI_Info_free(&info_out);
@@ -98,16 +101,20 @@ int main(int argc, char **argv) {
MPI_Win_get_info(win, &info_out);
MPI_Info_get(info_out, "accumulate_ordering", MPI_MAX_INFO_VAL, buf, &flag);
- if (flag && VERBOSE) printf("%d: accumulate_ordering = %s\n", rank, buf);
+ if (flag && VERBOSE)
+ printf("%d: accumulate_ordering = %s\n", rank, buf);
MPI_Info_get(info_out, "accumulate_ops", MPI_MAX_INFO_VAL, buf, &flag);
- if (flag && VERBOSE) printf("%d: accumulate_ops = %s\n", rank, buf);
+ if (flag && VERBOSE)
+ printf("%d: accumulate_ops = %s\n", rank, buf);
MPI_Info_get(info_out, "same_size", MPI_MAX_INFO_VAL, buf, &flag);
- if (flag && VERBOSE) printf("%d: same_size = %s\n", rank, buf);
+ if (flag && VERBOSE)
+ printf("%d: same_size = %s\n", rank, buf);
MPI_Info_get(info_out, "alloc_shm", MPI_MAX_INFO_VAL, buf, &flag);
- if (flag && VERBOSE) printf("%d: alloc_shm = %s\n", rank, buf);
+ if (flag && VERBOSE)
+ printf("%d: alloc_shm = %s\n", rank, buf);
MPI_Info_free(&info_out);
MPI_Win_free(&win);
diff --git a/test/mpi/rma/win_large_shm.c b/test/mpi/rma/win_large_shm.c
index 583eab2..63bb5f7 100644
--- a/test/mpi/rma/win_large_shm.c
+++ b/test/mpi/rma/win_large_shm.c
@@ -11,14 +11,15 @@
#include <stdlib.h>
#include <stdio.h>
-int main(int argc, char **argv) {
+int main(int argc, char **argv)
+{
int my_rank, shared_rank;
void *mybase = NULL;
MPI_Win win;
MPI_Info win_info;
MPI_Comm shared_comm;
int i;
- int shm_win_size = 1024 * 1024 * 1024 * sizeof(char); /* 1GB */
+ int shm_win_size = 1024 * 1024 * 1024 * sizeof(char); /* 1GB */
MPI_Init(&argc, &argv);
@@ -27,13 +28,14 @@ int main(int argc, char **argv) {
for (i = 0; i < 2; i++) {
if (i == 0) {
MPI_Info_create(&win_info);
- MPI_Info_set(win_info, (char*)"alloc_shm", (char*)"true");
+ MPI_Info_set(win_info, (char *) "alloc_shm", (char *) "true");
}
else {
win_info = MPI_INFO_NULL;
}
- MPI_Comm_split_type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, my_rank, MPI_INFO_NULL, &shared_comm);
+ MPI_Comm_split_type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, my_rank, MPI_INFO_NULL,
+ &shared_comm);
MPI_Comm_rank(shared_comm, &shared_rank);
@@ -55,7 +57,8 @@ int main(int argc, char **argv) {
MPI_Win_free(&win);
if (shared_rank % 2 == 0)
- MPI_Win_allocate_shared(shm_win_size, sizeof(char), win_info, shared_comm, &mybase, &win);
+ MPI_Win_allocate_shared(shm_win_size, sizeof(char), win_info, shared_comm, &mybase,
+ &win);
else
MPI_Win_allocate_shared(0, sizeof(char), win_info, shared_comm, &mybase, &win);
@@ -65,15 +68,18 @@ int main(int argc, char **argv) {
if (my_rank % 2 == 0)
MPI_Win_allocate(shm_win_size, sizeof(char), win_info, MPI_COMM_WORLD, &mybase, &win);
else
- MPI_Win_allocate(shm_win_size/2, sizeof(char), win_info, MPI_COMM_WORLD, &mybase, &win);
+ MPI_Win_allocate(shm_win_size / 2, sizeof(char), win_info, MPI_COMM_WORLD, &mybase,
+ &win);
MPI_Win_free(&win);
/* some processes allocate 1GB and some processes allocate smaller bytes */
if (shared_rank % 2 == 0)
- MPI_Win_allocate_shared(shm_win_size, sizeof(char), win_info, shared_comm, &mybase, &win);
+ MPI_Win_allocate_shared(shm_win_size, sizeof(char), win_info, shared_comm, &mybase,
+ &win);
else
- MPI_Win_allocate_shared(shm_win_size/2, sizeof(char), win_info, shared_comm, &mybase, &win);
+ MPI_Win_allocate_shared(shm_win_size / 2, sizeof(char), win_info, shared_comm, &mybase,
+ &win);
MPI_Win_free(&win);
diff --git a/test/mpi/rma/win_shared.c b/test/mpi/rma/win_shared.c
index 03e35de..7dc5e0c 100644
--- a/test/mpi/rma/win_shared.c
+++ b/test/mpi/rma/win_shared.c
@@ -15,14 +15,15 @@
const int verbose = 0;
-int main(int argc, char **argv) {
- int i, j, rank, nproc;
- int shm_rank, shm_nproc;
+int main(int argc, char **argv)
+{
+ int i, j, rank, nproc;
+ int shm_rank, shm_nproc;
MPI_Aint size;
- int errors = 0, all_errors = 0;
- int *base, *my_base;
- int disp_unit;
- MPI_Win shm_win;
+ int errors = 0, all_errors = 0;
+ int *base, *my_base;
+ int disp_unit;
+ MPI_Win shm_win;
MPI_Comm shm_comm;
MPI_Init(&argc, &argv);
@@ -36,11 +37,11 @@ int main(int argc, char **argv) {
MPI_Comm_size(shm_comm, &shm_nproc);
/* Allocate ELEM_PER_PROC integers for each process */
- MPI_Win_allocate_shared(sizeof(int)*ELEM_PER_PROC, sizeof(int), MPI_INFO_NULL,
- shm_comm, &my_base, &shm_win);
+ MPI_Win_allocate_shared(sizeof(int) * ELEM_PER_PROC, sizeof(int), MPI_INFO_NULL,
+ shm_comm, &my_base, &shm_win);
/* Locate absolute base */
- MPI_Win_shared_query(shm_win, MPI_PROC_NULL, &size, &disp_unit, &base);
+ MPI_Win_shared_query(shm_win, MPI_PROC_NULL, &size, &disp_unit, &base);
/* make sure the query returned the right values */
if (disp_unit != sizeof(int))
@@ -52,8 +53,9 @@ int main(int argc, char **argv) {
if (shm_rank && (base == my_base))
errors++;
- if (verbose) printf("%d -- size = %d baseptr = %p my_baseptr = %p\n", shm_rank,
- (int) size, (void*) base, (void*) my_base);
+ if (verbose)
+ printf("%d -- size = %d baseptr = %p my_baseptr = %p\n", shm_rank,
+ (int) size, (void *) base, (void *) my_base);
MPI_Win_lock_all(MPI_MODE_NOCHECK, shm_win);
@@ -69,10 +71,10 @@ int main(int argc, char **argv) {
/* Read and verify everyone's data */
for (i = 0; i < shm_nproc; i++) {
for (j = 0; j < ELEM_PER_PROC; j++) {
- if ( base[i*ELEM_PER_PROC + j] != j ) {
+ if (base[i * ELEM_PER_PROC + j] != j) {
errors++;
printf("%d -- Got %d at rank %d index %d, expected %d\n", shm_rank,
- base[i*ELEM_PER_PROC + j], i, j, j);
+ base[i * ELEM_PER_PROC + j], i, j, j);
}
}
}
diff --git a/test/mpi/rma/win_shared_noncontig.c b/test/mpi/rma/win_shared_noncontig.c
index 22e37e1..db25c33 100644
--- a/test/mpi/rma/win_shared_noncontig.c
+++ b/test/mpi/rma/win_shared_noncontig.c
@@ -15,14 +15,15 @@
const int verbose = 0;
-int main(int argc, char **argv) {
- int i, j, rank, nproc;
- int shm_rank, shm_nproc;
+int main(int argc, char **argv)
+{
+ int i, j, rank, nproc;
+ int shm_rank, shm_nproc;
MPI_Info alloc_shared_info;
- int errors = 0, all_errors = 0;
- int disp_unit;
- int *my_base;
- MPI_Win shm_win;
+ int errors = 0, all_errors = 0;
+ int disp_unit;
+ int *my_base;
+ MPI_Win shm_win;
MPI_Comm shm_comm;
MPI_Init(&argc, &argv);
@@ -39,8 +40,8 @@ int main(int argc, char **argv) {
MPI_Comm_size(shm_comm, &shm_nproc);
/* Allocate ELEM_PER_PROC integers for each process */
- MPI_Win_allocate_shared(sizeof(int)*ELEM_PER_PROC, sizeof(int), alloc_shared_info,
- shm_comm, &my_base, &shm_win);
+ MPI_Win_allocate_shared(sizeof(int) * ELEM_PER_PROC, sizeof(int), alloc_shared_info,
+ shm_comm, &my_base, &shm_win);
MPI_Win_lock_all(MPI_MODE_NOCHECK, shm_win);
@@ -55,16 +56,16 @@ int main(int argc, char **argv) {
/* Read and verify everyone's data */
for (i = 0; i < shm_nproc; i++) {
- int *base;
- MPI_Aint size;
+ int *base;
+ MPI_Aint size;
MPI_Win_shared_query(shm_win, i, &size, &disp_unit, &base);
assert(size >= ELEM_PER_PROC * sizeof(int));
for (j = 0; j < ELEM_PER_PROC; j++) {
- if ( base[j] != j ) {
+ if (base[j] != j) {
errors++;
- printf("%d -- Got %d at rank %d index %d, expected %d\n", shm_rank,
+ printf("%d -- Got %d at rank %d index %d, expected %d\n", shm_rank,
base[j], i, j, j);
}
}
diff --git a/test/mpi/rma/win_shared_noncontig_put.c b/test/mpi/rma/win_shared_noncontig_put.c
index 0e68d2d..e733c87 100644
--- a/test/mpi/rma/win_shared_noncontig_put.c
+++ b/test/mpi/rma/win_shared_noncontig_put.c
@@ -15,14 +15,15 @@
const int verbose = 0;
-int main(int argc, char **argv) {
- int i, j, rank, nproc;
- int shm_rank, shm_nproc;
+int main(int argc, char **argv)
+{
+ int i, j, rank, nproc;
+ int shm_rank, shm_nproc;
MPI_Info alloc_shared_info;
- int errors = 0, all_errors = 0;
- int disp_unit;
- int *my_base, my_size;
- MPI_Win shm_win;
+ int errors = 0, all_errors = 0;
+ int disp_unit;
+ int *my_base, my_size;
+ MPI_Win shm_win;
MPI_Comm shm_comm;
MPI_Init(&argc, &argv);
@@ -39,26 +40,25 @@ int main(int argc, char **argv) {
MPI_Comm_size(shm_comm, &shm_nproc);
/* Allocate ELEM_PER_PROC integers on each even rank process */
- my_size = (shm_rank % 2 == 0) ? sizeof(int)*ELEM_PER_PROC : 0;
- MPI_Win_allocate_shared(my_size, sizeof(int), alloc_shared_info,
- shm_comm, &my_base, &shm_win);
+ my_size = (shm_rank % 2 == 0) ? sizeof(int) * ELEM_PER_PROC : 0;
+ MPI_Win_allocate_shared(my_size, sizeof(int), alloc_shared_info, shm_comm, &my_base, &shm_win);
for (i = 0; i < ELEM_PER_PROC; i++) {
- MPI_Win_fence(MPI_MODE_NOPRECEDE, shm_win);
- if (shm_rank % 2 == 0) {
- MPI_Put(&i, 1, MPI_INT,
- (shm_rank + 2 > shm_nproc) ? 0 : (shm_rank+2) % shm_nproc,
- i, 1, MPI_INT, shm_win);
- }
- MPI_Win_fence(MPI_MODE_NOSUCCEED, shm_win);
+ MPI_Win_fence(MPI_MODE_NOPRECEDE, shm_win);
+ if (shm_rank % 2 == 0) {
+ MPI_Put(&i, 1, MPI_INT,
+ (shm_rank + 2 > shm_nproc) ? 0 : (shm_rank + 2) % shm_nproc,
+ i, 1, MPI_INT, shm_win);
+ }
+ MPI_Win_fence(MPI_MODE_NOSUCCEED, shm_win);
}
MPI_Barrier(shm_comm);
/* Read and verify everyone's data */
for (i = 0; i < shm_nproc; i++) {
- int *base;
- MPI_Aint size;
+ int *base;
+ MPI_Aint size;
MPI_Win_shared_query(shm_win, i, &size, &disp_unit, &base);
@@ -66,13 +66,14 @@ int main(int argc, char **argv) {
assert(size >= ELEM_PER_PROC * sizeof(int));
for (j = 0; j < ELEM_PER_PROC; j++) {
- if ( base[j] != j ) {
+ if (base[j] != j) {
errors++;
printf("%d -- Got %d at rank %d index %d, expected %d\n", shm_rank,
base[j], i, j, j);
}
}
- } else {
+ }
+ else {
assert(size == 0);
assert(base == NULL);
}
diff --git a/test/mpi/rma/win_shared_zerobyte.c b/test/mpi/rma/win_shared_zerobyte.c
index 329f0c0..2b17d79 100644
--- a/test/mpi/rma/win_shared_zerobyte.c
+++ b/test/mpi/rma/win_shared_zerobyte.c
@@ -54,7 +54,8 @@ int main(int argc, char **argv)
MPI_Win_shared_query(shm_win, MPI_PROC_NULL, &size, &disp_unit, &abs_base);
if (verbose)
- printf("%d -- allocate shared: my_base = %p, absolute base = %p\n", shm_rank, my_base, abs_base);
+ printf("%d -- allocate shared: my_base = %p, absolute base = %p\n", shm_rank, my_base,
+ abs_base);
for (i = 0; i < shm_nproc; i++) {
MPI_Win_shared_query(shm_win, i, &size, &disp_unit, &bases[i]);
diff --git a/test/mpi/rma/wincall.c b/test/mpi/rma/wincall.c
index c29b796..06a8823 100644
--- a/test/mpi/rma/wincall.c
+++ b/test/mpi/rma/wincall.c
@@ -15,51 +15,51 @@ static char MTEST_Descrip[] = "Test win_call_errhandler";
static int calls = 0;
static int errs = 0;
static MPI_Win mywin;
-void eh( MPI_Win *win, int *err, ... );
-void eh( MPI_Win *win, int *err, ... )
+void eh(MPI_Win * win, int *err, ...);
+void eh(MPI_Win * win, int *err, ...)
{
if (*err != MPI_ERR_OTHER) {
- errs++;
- printf( "Unexpected error code\n" );
+ errs++;
+ printf("Unexpected error code\n");
}
if (*win != mywin) {
- errs++;
- printf( "Unexpected window\n" );
+ errs++;
+ printf("Unexpected window\n");
}
calls++;
return;
}
-int main( int argc, char *argv[] )
+
+int main(int argc, char *argv[])
{
int buf[2];
- MPI_Win win;
+ MPI_Win win;
MPI_Errhandler newerr;
- int i;
+ int i;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
/* Run this test multiple times to expose storage leaks (we found a leak
- of error handlers with this test) */
- for (i=0;i<1000; i++) {
- calls = 0;
-
- MPI_Win_create( buf, 2*sizeof(int), sizeof(int),
- MPI_INFO_NULL, MPI_COMM_WORLD, &win );
- mywin = win;
-
- MPI_Win_create_errhandler( eh, &newerr );
-
- MPI_Win_set_errhandler( win, newerr );
- MPI_Win_call_errhandler( win, MPI_ERR_OTHER );
- MPI_Errhandler_free( &newerr );
- if (calls != 1) {
- errs++;
- printf( "Error handler not called\n" );
- }
- MPI_Win_free( &win );
+ * of error handlers with this test) */
+ for (i = 0; i < 1000; i++) {
+ calls = 0;
+
+ MPI_Win_create(buf, 2 * sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win);
+ mywin = win;
+
+ MPI_Win_create_errhandler(eh, &newerr);
+
+ MPI_Win_set_errhandler(win, newerr);
+ MPI_Win_call_errhandler(win, MPI_ERR_OTHER);
+ MPI_Errhandler_free(&newerr);
+ if (calls != 1) {
+ errs++;
+ printf("Error handler not called\n");
+ }
+ MPI_Win_free(&win);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/rma/window_creation.c b/test/mpi/rma/window_creation.c
index a805350..f96501c 100644
--- a/test/mpi/rma/window_creation.c
+++ b/test/mpi/rma/window_creation.c
@@ -15,39 +15,47 @@
static int verbose = 0;
-int main(int argc, char ** argv) {
- int rank, nproc, i;
- void *base_ptrs[NUM_WIN];
- MPI_Win windows[NUM_WIN];
+int main(int argc, char **argv)
+{
+ int rank, nproc, i;
+ void *base_ptrs[NUM_WIN];
+ MPI_Win windows[NUM_WIN];
- MPI_Init(&argc, &argv);
+ MPI_Init(&argc, &argv);
- MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- MPI_Comm_size(MPI_COMM_WORLD, &nproc);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &nproc);
- if (rank == 0) if (verbose) printf("Starting MPI window creation test with %d processes\n", nproc);
+ if (rank == 0)
+ if (verbose)
+ printf("Starting MPI window creation test with %d processes\n", nproc);
- /* Perform a pile of window creations */
- for (i = 0; i < NUM_WIN; i++) {
- if (rank == 0) if (verbose) printf(" + Creating window %d\n", i);
+ /* Perform a pile of window creations */
+ for (i = 0; i < NUM_WIN; i++) {
+ if (rank == 0)
+ if (verbose)
+ printf(" + Creating window %d\n", i);
- MPI_Alloc_mem(DATA_SZ, MPI_INFO_NULL, &base_ptrs[i]);
- MPI_Win_create(base_ptrs[i], DATA_SZ, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &windows[i]);
- }
+ MPI_Alloc_mem(DATA_SZ, MPI_INFO_NULL, &base_ptrs[i]);
+ MPI_Win_create(base_ptrs[i], DATA_SZ, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &windows[i]);
+ }
- MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Barrier(MPI_COMM_WORLD);
- /* Free all the windows */
- for (i = 0; i < NUM_WIN; i++) {
- if (rank == 0) if (verbose) printf(" + Freeing window %d\n", i);
+ /* Free all the windows */
+ for (i = 0; i < NUM_WIN; i++) {
+ if (rank == 0)
+ if (verbose)
+ printf(" + Freeing window %d\n", i);
- MPI_Win_free(&windows[i]);
- MPI_Free_mem(base_ptrs[i]);
- }
+ MPI_Win_free(&windows[i]);
+ MPI_Free_mem(base_ptrs[i]);
+ }
- if (rank == 0) printf(" No Errors\n");
+ if (rank == 0)
+ printf(" No Errors\n");
- MPI_Finalize();
+ MPI_Finalize();
- return 0;
+ return 0;
}
diff --git a/test/mpi/rma/winname.c b/test/mpi/rma/winname.c
index 290f26e..dfffb15 100644
--- a/test/mpi/rma/winname.c
+++ b/test/mpi/rma/winname.c
@@ -14,34 +14,34 @@
#include <string.h>
#endif
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
MPI_Win win;
int cnt, namelen;
char name[MPI_MAX_OBJECT_NAME], nameout[MPI_MAX_OBJECT_NAME];
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
cnt = 0;
- while (MTestGetWin( &win, 1 )) {
- if (win == MPI_WIN_NULL) continue;
-
- sprintf( name, "win-%d", cnt );
- cnt++;
- MPI_Win_set_name( win, name );
- nameout[0] = 0;
- MPI_Win_get_name( win, nameout, &namelen );
- if (strcmp( name, nameout )) {
- errs++;
- printf( "Unexpected name, was %s but should be %s\n",
- nameout, name );
- }
+ while (MTestGetWin(&win, 1)) {
+ if (win == MPI_WIN_NULL)
+ continue;
- MTestFreeWin( &win );
+ sprintf(name, "win-%d", cnt);
+ cnt++;
+ MPI_Win_set_name(win, name);
+ nameout[0] = 0;
+ MPI_Win_get_name(win, nameout, &namelen);
+ if (strcmp(name, nameout)) {
+ errs++;
+ printf("Unexpected name, was %s but should be %s\n", nameout, name);
+ }
+
+ MTestFreeWin(&win);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/rma/wintest.c b/test/mpi/rma/wintest.c
index 7ac1401..d28f806 100644
--- a/test/mpi/rma/wintest.c
+++ b/test/mpi/rma/wintest.c
@@ -3,7 +3,7 @@
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-#include "mpi.h"
+#include "mpi.h"
#include "stdio.h"
#include "mpitest.h"
@@ -13,17 +13,17 @@
#define SIZE1 10
#define SIZE2 20
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[])
+{
int rank, destrank, nprocs, A[SIZE2], i;
MPI_Comm CommDeuce;
MPI_Group comm_group, group;
MPI_Win win;
int errs = 0, flag;
- MTest_Init(&argc,&argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+ MTest_Init(&argc, &argv);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (nprocs < 2) {
printf("Run this program with 2 or more processes\n");
@@ -37,7 +37,8 @@ int main(int argc, char *argv[])
if (rank == 0) {
int B[SIZE2];
- for (i=0; i<SIZE2; i++) A[i] = B[i] = i;
+ for (i = 0; i < SIZE2; i++)
+ A[i] = B[i] = i;
#ifdef USE_WIN_ALLOCATE
int *base_ptr = NULL;
MPI_Win_allocate(0, 1, MPI_INFO_NULL, CommDeuce, &base_ptr, &win);
@@ -47,29 +48,30 @@ int main(int argc, char *argv[])
destrank = 1;
MPI_Group_incl(comm_group, 1, &destrank, &group);
MPI_Win_start(group, 0, win);
- for (i=0; i<SIZE1; i++)
- MPI_Put(A+i, 1, MPI_INT, 1, i, 1, MPI_INT, win);
- for (i=0; i<SIZE1; i++)
- MPI_Get(B+i, 1, MPI_INT, 1, SIZE1+i, 1, MPI_INT, win);
+ for (i = 0; i < SIZE1; i++)
+ MPI_Put(A + i, 1, MPI_INT, 1, i, 1, MPI_INT, win);
+ for (i = 0; i < SIZE1; i++)
+ MPI_Get(B + i, 1, MPI_INT, 1, SIZE1 + i, 1, MPI_INT, win);
MPI_Win_complete(win);
- for (i=0; i<SIZE1; i++)
- if (B[i] != (-4)*(i+SIZE1)) {
- printf("Get Error: B[i] is %d, should be %d\n", B[i], (-4)*(i+SIZE1));
+ for (i = 0; i < SIZE1; i++)
+ if (B[i] != (-4) * (i + SIZE1)) {
+ printf("Get Error: B[i] is %d, should be %d\n", B[i], (-4) * (i + SIZE1));
errs++;
}
}
else { /* rank=1 */
#ifdef USE_WIN_ALLOCATE
int *B;
- MPI_Win_allocate(SIZE2*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &B, &win);
+ MPI_Win_allocate(SIZE2 * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &B, &win);
#else
int B[SIZE2];
- MPI_Win_create(B, SIZE2*sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
+ MPI_Win_create(B, SIZE2 * sizeof(int), sizeof(int), MPI_INFO_NULL, CommDeuce, &win);
#endif
MPI_Win_lock(MPI_LOCK_SHARED, rank, 0, win);
- for (i=0; i<SIZE2; i++) B[i] = (-4)*i;
+ for (i = 0; i < SIZE2; i++)
+ B[i] = (-4) * i;
MPI_Win_unlock(rank, win);
destrank = 0;
@@ -79,7 +81,7 @@ int main(int argc, char *argv[])
while (!flag)
MPI_Win_test(win, &flag);
- for (i=0; i<SIZE1; i++) {
+ for (i = 0; i < SIZE1; i++) {
if (B[i] != i) {
printf("Put Error: B[i] is %d, should be %d\n", B[i], i);
errs++;
@@ -89,10 +91,10 @@ int main(int argc, char *argv[])
MPI_Group_free(&group);
MPI_Group_free(&comm_group);
- MPI_Win_free(&win);
+ MPI_Win_free(&win);
}
MPI_Comm_free(&CommDeuce);
MTest_Finalize(errs);
MPI_Finalize();
- return 0;
-}
+ return 0;
+}
diff --git a/test/mpi/spawn/concurrent_spawns.c b/test/mpi/spawn/concurrent_spawns.c
index 389e517..1f39872 100644
--- a/test/mpi/spawn/concurrent_spawns.c
+++ b/test/mpi/spawn/concurrent_spawns.c
@@ -17,13 +17,13 @@
/* #include <fcntl.h> */
-/* This test tests the ability to handle multiple simultaneous calls to
+/* This test tests the ability to handle multiple simultaneous calls to
* MPI_Comm_spawn.
- * The first process spawns MAX_NUM_SPAWNS processes and tells them to spawn
+ * The first process spawns MAX_NUM_SPAWNS processes and tells them to spawn
* MAX_NUM_SPAWNS -1 processes.
- * This repeats until no processes are spawned. For MAX_NUM_SPAWNS = 4 this
- * results in 64 processes
- * created. Hopefully this will result in concurrent handling of
+ * This repeats until no processes are spawned. For MAX_NUM_SPAWNS = 4 this
+ * results in 64 processes
+ * created. Hopefully this will result in concurrent handling of
* MPI_Comm_spawn calls from multiple processes.
*/
@@ -43,36 +43,33 @@ int main(int argc, char *argv[])
char description[100];
char child_spawns[10];
char *argv1[3] = { child_spawns, description, NULL };
- MPI_Comm parentcomm, intercomm[MAX_NUM_SPAWNS];
+ MPI_Comm parentcomm, intercomm[MAX_NUM_SPAWNS];
MPI_Status status;
int verbose = 0;
char *env;
int can_spawn;
env = getenv("MPITEST_VERBOSE");
- if (env)
- {
- if (*env != '0')
- verbose = 1;
+ if (env) {
+ if (*env != '0')
+ verbose = 1;
}
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
errs += MTestSpawnPossible(&can_spawn);
if (can_spawn) {
/* Set the num_spawns for the first process to MAX_NUM_SPAWNS */
- MPI_Comm_get_parent( &parentcomm );
- if (parentcomm == MPI_COMM_NULL)
- {
+ MPI_Comm_get_parent(&parentcomm);
+ if (parentcomm == MPI_COMM_NULL) {
num_spawns = MAX_NUM_SPAWNS;
}
/* If an argument is passed in use it for num_spawns */
/* This is the case for all spawned processes and optionally the first
- process as well */
- if (argc > 1)
- {
+ * process as well */
+ if (argc > 1) {
num_spawns = atoi(argv[1]);
if (num_spawns < 0)
num_spawns = 0;
@@ -81,29 +78,24 @@ int main(int argc, char *argv[])
}
/* Send num_spawns - 1 on the command line to the spawned children */
- sprintf(child_spawns, "%d", num_spawns-1 > 0 ? num_spawns-1 : 0);
+ sprintf(child_spawns, "%d", num_spawns - 1 > 0 ? num_spawns - 1 : 0);
/* Spawn the children */
IF_VERBOSE(("spawning %d\n", num_spawns));
- for (i=0; i<num_spawns; i++)
- {
- if (argc > 2)
- {
+ for (i = 0; i < num_spawns; i++) {
+ if (argc > 2) {
sprintf(description, "%s:%d", argv[2], i);
}
- else
- {
+ else {
sprintf(description, "%d", i);
}
IF_VERBOSE(("spawning %s\n", description));
- MPI_Comm_spawn((char*)"./concurrent_spawns", argv1, 1,
- MPI_INFO_NULL, 0, MPI_COMM_WORLD,
- &intercomm[i], MPI_ERRCODES_IGNORE);
+ MPI_Comm_spawn((char *) "./concurrent_spawns", argv1, 1,
+ MPI_INFO_NULL, 0, MPI_COMM_WORLD, &intercomm[i], MPI_ERRCODES_IGNORE);
MPI_Comm_remote_size(intercomm[i], &rsize);
MPI_Comm_size(intercomm[i], &size);
- if (rsize != 1)
- {
+ if (rsize != 1) {
errs++;
printf("Did not create 1 process (got %d)\n", rsize);
fflush(stdout);
@@ -111,28 +103,27 @@ int main(int argc, char *argv[])
}
/* Receive the error count from each of your children and add it to your
- error count */
- for (i=0; i<num_spawns; i++)
- {
+ * error count */
+ for (i = 0; i < num_spawns; i++) {
MPI_Recv(&child_errs, 1, MPI_INT, 0, 0, intercomm[i], &status);
errs += child_errs;
- MPI_Comm_disconnect( &intercomm[i] );
+ MPI_Comm_disconnect(&intercomm[i]);
}
/* If you are a spawned process send your errors to your parent */
- if (parentcomm != MPI_COMM_NULL)
- {
+ if (parentcomm != MPI_COMM_NULL) {
MPI_Send(&errs, 1, MPI_INT, 0, 0, parentcomm);
- MPI_Comm_disconnect( &parentcomm );
+ MPI_Comm_disconnect(&parentcomm);
}
else {
/* Note that the MTest_Finalize get errs only over COMM_WORLD */
/* Note also that both the parent and child will generate "No Errors"
- if both call MTest_Finalize */
- MTest_Finalize( errs );
+ * if both call MTest_Finalize */
+ MTest_Finalize(errs);
}
- } else {
- MTest_Finalize( errs );
+ }
+ else {
+ MTest_Finalize(errs);
}
IF_VERBOSE(("calling finalize\n"));
diff --git a/test/mpi/spawn/disconnect.c b/test/mpi/spawn/disconnect.c
index 47aadc7..bd8aa6a 100644
--- a/test/mpi/spawn/disconnect.c
+++ b/test/mpi/spawn/disconnect.c
@@ -26,35 +26,31 @@ int main(int argc, char *argv[])
int errs = 0;
int rank, size, rsize;
int np = 3;
- MPI_Comm parentcomm, intercomm;
+ MPI_Comm parentcomm, intercomm;
int verbose = 0;
char *env;
int can_spawn;
env = getenv("MPITEST_VERBOSE");
- if (env)
- {
- if (*env != '0')
- verbose = 1;
+ if (env) {
+ if (*env != '0')
+ verbose = 1;
}
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
errs += MTestSpawnPossible(&can_spawn);
if (can_spawn) {
- MPI_Comm_get_parent( &parentcomm );
+ MPI_Comm_get_parent(&parentcomm);
- if (parentcomm == MPI_COMM_NULL)
- {
+ if (parentcomm == MPI_COMM_NULL) {
IF_VERBOSE(("spawning %d processes\n", np));
/* Create 3 more processes */
- MPI_Comm_spawn((char*)"./disconnect", MPI_ARGV_NULL, np,
- MPI_INFO_NULL, 0, MPI_COMM_WORLD,
- &intercomm, MPI_ERRCODES_IGNORE);
+ MPI_Comm_spawn((char *) "./disconnect", MPI_ARGV_NULL, np,
+ MPI_INFO_NULL, 0, MPI_COMM_WORLD, &intercomm, MPI_ERRCODES_IGNORE);
}
- else
- {
+ else {
intercomm = parentcomm;
}
@@ -64,12 +60,10 @@ int main(int argc, char *argv[])
MPI_Comm_size(intercomm, &size);
MPI_Comm_rank(intercomm, &rank);
- if (parentcomm == MPI_COMM_NULL)
- {
+ if (parentcomm == MPI_COMM_NULL) {
IF_VERBOSE(("parent rank %d alive.\n", rank));
/* Parent */
- if (rsize != np)
- {
+ if (rsize != np) {
errs++;
printf("Did not create %d processes (got %d)\n", np, rsize);
fflush(stdout);
@@ -78,20 +72,18 @@ int main(int argc, char *argv[])
MPI_Comm_disconnect(&intercomm);
/* Errors cannot be sent back to the parent because there is no
- communicator connected to the children
- for (i=0; i<rsize; i++)
- {
- MPI_Recv( &err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE );
- errs += err;
- }
- */
+ * communicator connected to the children
+ * for (i=0; i<rsize; i++)
+ * {
+ * MPI_Recv(&err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE);
+ * errs += err;
+ * }
+ */
}
- else
- {
+ else {
IF_VERBOSE(("child rank %d alive.\n", rank));
/* Child */
- if (size != np)
- {
+ if (size != np) {
errs++;
printf("(Child) Did not create %d processes (got %d)\n", np, size);
fflush(stdout);
@@ -102,19 +94,19 @@ int main(int argc, char *argv[])
/* Send the errs back to the master process */
/* Errors cannot be sent back to the parent because there is no
- communicator connected to the parent */
- /*MPI_Ssend( &errs, 1, MPI_INT, 0, 1, intercomm );*/
+ * communicator connected to the parent */
+ /*MPI_Ssend(&errs, 1, MPI_INT, 0, 1, intercomm); */
}
/* Note that the MTest_Finalize get errs only over COMM_WORLD */
/* Note also that both the parent and child will generate "No Errors"
- if both call MTest_Finalize */
- if (parentcomm == MPI_COMM_NULL)
- {
- MTest_Finalize( errs );
+ * if both call MTest_Finalize */
+ if (parentcomm == MPI_COMM_NULL) {
+ MTest_Finalize(errs);
}
- } else {
- MTest_Finalize( errs );
+ }
+ else {
+ MTest_Finalize(errs);
}
IF_VERBOSE(("calling finalize\n"));
diff --git a/test/mpi/spawn/disconnect2.c b/test/mpi/spawn/disconnect2.c
index d8259c4..e5c9cb4 100644
--- a/test/mpi/spawn/disconnect2.c
+++ b/test/mpi/spawn/disconnect2.c
@@ -30,36 +30,32 @@ int main(int argc, char *argv[])
int errs = 0;
int rank, size, rsize, i, data = -1;
int np = 3;
- MPI_Comm parentcomm, intercomm;
- MPI_Status status;
+ MPI_Comm parentcomm, intercomm;
+ MPI_Status status;
int verbose = 0;
char *env;
int can_spawn;
env = getenv("MPITEST_VERBOSE");
- if (env)
- {
- if (*env != '0')
- verbose = 1;
+ if (env) {
+ if (*env != '0')
+ verbose = 1;
}
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
errs += MTestSpawnPossible(&can_spawn);
if (can_spawn) {
- MPI_Comm_get_parent( &parentcomm );
+ MPI_Comm_get_parent(&parentcomm);
- if (parentcomm == MPI_COMM_NULL)
- {
+ if (parentcomm == MPI_COMM_NULL) {
IF_VERBOSE(("spawning %d processes\n", np));
/* Create 3 more processes */
- MPI_Comm_spawn((char*)"./disconnect2", MPI_ARGV_NULL, np,
- MPI_INFO_NULL, 0, MPI_COMM_WORLD,
- &intercomm, MPI_ERRCODES_IGNORE);
+ MPI_Comm_spawn((char *) "./disconnect2", MPI_ARGV_NULL, np,
+ MPI_INFO_NULL, 0, MPI_COMM_WORLD, &intercomm, MPI_ERRCODES_IGNORE);
}
- else
- {
+ else {
intercomm = parentcomm;
}
@@ -69,25 +65,20 @@ int main(int argc, char *argv[])
MPI_Comm_size(intercomm, &size);
MPI_Comm_rank(intercomm, &rank);
- if (parentcomm == MPI_COMM_NULL)
- {
+ if (parentcomm == MPI_COMM_NULL) {
IF_VERBOSE(("parent rank %d alive.\n", rank));
/* Parent */
- if (rsize != np)
- {
+ if (rsize != np) {
errs++;
printf("Did not create %d processes (got %d)\n", np, rsize);
fflush(stdout);
}
- if (rank == SENDER_RANK)
- {
+ if (rank == SENDER_RANK) {
IF_VERBOSE(("sending int\n"));
i = DATA_VALUE;
MPI_Send(&i, 1, MPI_INT, RECEIVER_RANK, DATA_TAG, intercomm);
- MPI_Recv(&data, 1, MPI_INT, RECEIVER_RANK, DATA_TAG, intercomm,
- &status);
- if (data != i)
- {
+ MPI_Recv(&data, 1, MPI_INT, RECEIVER_RANK, DATA_TAG, intercomm, &status);
+ if (data != i) {
errs++;
}
}
@@ -95,32 +86,28 @@ int main(int argc, char *argv[])
MPI_Comm_disconnect(&intercomm);
/* Errors cannot be sent back to the parent because there is no
- communicator connected to the children
- for (i=0; i<rsize; i++)
- {
- MPI_Recv( &err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE );
- errs += err;
- }
- */
+ * communicator connected to the children
+ * for (i=0; i<rsize; i++)
+ * {
+ * MPI_Recv(&err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE);
+ * errs += err;
+ * }
+ */
}
- else
- {
+ else {
IF_VERBOSE(("child rank %d alive.\n", rank));
/* Child */
- if (size != np)
- {
+ if (size != np) {
errs++;
printf("(Child) Did not create %d processes (got %d)\n", np, size);
fflush(stdout);
}
- if (rank == RECEIVER_RANK)
- {
+ if (rank == RECEIVER_RANK) {
IF_VERBOSE(("receiving int\n"));
i = -1;
MPI_Recv(&i, 1, MPI_INT, SENDER_RANK, DATA_TAG, intercomm, &status);
- if (i != DATA_VALUE)
- {
+ if (i != DATA_VALUE) {
errs++;
printf("expected %d but received %d\n", DATA_VALUE, i);
fflush(stdout);
@@ -134,19 +121,19 @@ int main(int argc, char *argv[])
/* Send the errs back to the master process */
/* Errors cannot be sent back to the parent because there is no
- communicator connected to the parent */
- /*MPI_Ssend( &errs, 1, MPI_INT, 0, 1, intercomm );*/
+ * communicator connected to the parent */
+ /*MPI_Ssend(&errs, 1, MPI_INT, 0, 1, intercomm); */
}
/* Note that the MTest_Finalize get errs only over COMM_WORLD */
/* Note also that both the parent and child will generate "No Errors"
- if both call MTest_Finalize */
- if (parentcomm == MPI_COMM_NULL)
- {
- MTest_Finalize( errs );
+ * if both call MTest_Finalize */
+ if (parentcomm == MPI_COMM_NULL) {
+ MTest_Finalize(errs);
}
- } else {
- MTest_Finalize( errs );
+ }
+ else {
+ MTest_Finalize(errs);
}
IF_VERBOSE(("calling finalize\n"));
diff --git a/test/mpi/spawn/disconnect3.c b/test/mpi/spawn/disconnect3.c
index c4d6c92..277bc23 100644
--- a/test/mpi/spawn/disconnect3.c
+++ b/test/mpi/spawn/disconnect3.c
@@ -30,36 +30,32 @@ int main(int argc, char *argv[])
int errs = 0;
int rank, size, rsize, i, data = -1;
int np = 3;
- MPI_Comm parentcomm, intercomm;
- MPI_Status status;
+ MPI_Comm parentcomm, intercomm;
+ MPI_Status status;
int verbose = 0;
char *env;
int can_spawn;
env = getenv("MPITEST_VERBOSE");
- if (env)
- {
- if (*env != '0')
- verbose = 1;
+ if (env) {
+ if (*env != '0')
+ verbose = 1;
}
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
errs += MTestSpawnPossible(&can_spawn);
if (can_spawn) {
- MPI_Comm_get_parent( &parentcomm );
+ MPI_Comm_get_parent(&parentcomm);
- if (parentcomm == MPI_COMM_NULL)
- {
+ if (parentcomm == MPI_COMM_NULL) {
IF_VERBOSE(("spawning %d processes\n", np));
/* Create 3 more processes */
- MPI_Comm_spawn((char*)"./disconnect3", MPI_ARGV_NULL, np,
- MPI_INFO_NULL, 0, MPI_COMM_WORLD,
- &intercomm, MPI_ERRCODES_IGNORE);
+ MPI_Comm_spawn((char *) "./disconnect3", MPI_ARGV_NULL, np,
+ MPI_INFO_NULL, 0, MPI_COMM_WORLD, &intercomm, MPI_ERRCODES_IGNORE);
}
- else
- {
+ else {
intercomm = parentcomm;
}
@@ -69,25 +65,20 @@ int main(int argc, char *argv[])
MPI_Comm_size(intercomm, &size);
MPI_Comm_rank(intercomm, &rank);
- if (parentcomm == MPI_COMM_NULL)
- {
+ if (parentcomm == MPI_COMM_NULL) {
IF_VERBOSE(("parent rank %d alive.\n", rank));
/* Parent */
- if (rsize != np)
- {
+ if (rsize != np) {
errs++;
printf("Did not create %d processes (got %d)\n", np, rsize);
fflush(stdout);
}
- if (rank == SENDER_RANK)
- {
+ if (rank == SENDER_RANK) {
IF_VERBOSE(("sending int\n"));
i = DATA_VALUE;
MPI_Send(&i, 1, MPI_INT, RECEIVER_RANK, DATA_TAG, intercomm);
- MPI_Recv(&data, 1, MPI_INT, RECEIVER_RANK, DATA_TAG, intercomm,
- &status);
- if (data != i)
- {
+ MPI_Recv(&data, 1, MPI_INT, RECEIVER_RANK, DATA_TAG, intercomm, &status);
+ if (data != i) {
errs++;
}
}
@@ -95,32 +86,28 @@ int main(int argc, char *argv[])
MPI_Comm_disconnect(&intercomm);
/* Errors cannot be sent back to the parent because there is no
- communicator connected to the children
- for (i=0; i<rsize; i++)
- {
- MPI_Recv( &err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE );
- errs += err;
- }
- */
+ * communicator connected to the children
+ * for (i=0; i<rsize; i++)
+ * {
+ * MPI_Recv(&err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE);
+ * errs += err;
+ * }
+ */
}
- else
- {
+ else {
IF_VERBOSE(("child rank %d alive.\n", rank));
/* Child */
- if (size != np)
- {
+ if (size != np) {
errs++;
printf("(Child) Did not create %d processes (got %d)\n", np, size);
fflush(stdout);
}
- if (rank == RECEIVER_RANK)
- {
+ if (rank == RECEIVER_RANK) {
IF_VERBOSE(("receiving int\n"));
i = -1;
MPI_Recv(&i, 1, MPI_INT, SENDER_RANK, DATA_TAG, intercomm, &status);
- if (i != DATA_VALUE)
- {
+ if (i != DATA_VALUE) {
errs++;
printf("expected %d but received %d\n", DATA_VALUE, i);
fflush(stdout);
@@ -134,19 +121,19 @@ int main(int argc, char *argv[])
/* Send the errs back to the master process */
/* Errors cannot be sent back to the parent because there is no
- communicator connected to the parent */
- /*MPI_Ssend( &errs, 1, MPI_INT, 0, 1, intercomm );*/
+ * communicator connected to the parent */
+ /*MPI_Ssend(&errs, 1, MPI_INT, 0, 1, intercomm); */
}
/* Note that the MTest_Finalize get errs only over COMM_WORLD */
/* Note also that both the parent and child will generate "No Errors"
- if both call MTest_Finalize */
- if (parentcomm == MPI_COMM_NULL)
- {
- MTest_Finalize( errs );
+ * if both call MTest_Finalize */
+ if (parentcomm == MPI_COMM_NULL) {
+ MTest_Finalize(errs);
}
- } else {
- MTest_Finalize( errs );
+ }
+ else {
+ MTest_Finalize(errs);
}
IF_VERBOSE(("calling finalize\n"));
diff --git a/test/mpi/spawn/disconnect_reconnect.c b/test/mpi/spawn/disconnect_reconnect.c
index c827563..c6cdc69 100644
--- a/test/mpi/spawn/disconnect_reconnect.c
+++ b/test/mpi/spawn/disconnect_reconnect.c
@@ -26,22 +26,21 @@ int main(int argc, char *argv[])
int errs = 0;
int rank, size, rsize, i, j, data, num_loops = 100;
int np = 3;
- MPI_Comm parentcomm, intercomm;
- MPI_Status status;
- char port[MPI_MAX_PORT_NAME] = {0};
+ MPI_Comm parentcomm, intercomm;
+ MPI_Status status;
+ char port[MPI_MAX_PORT_NAME] = { 0 };
int verbose = 0;
int do_messages = 1;
char *env;
int can_spawn;
env = getenv("MPITEST_VERBOSE");
- if (env)
- {
- if (*env != '0')
- verbose = 1;
+ if (env) {
+ if (*env != '0')
+ verbose = 1;
}
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
errs += MTestSpawnPossible(&can_spawn);
@@ -54,24 +53,20 @@ int main(int argc, char *argv[])
if (num_loops > 100)
num_loops = 100;
}
- if (argc > 2)
- {
+ if (argc > 2) {
do_messages = atoi(argv[2]);
}
- MPI_Comm_get_parent( &parentcomm );
+ MPI_Comm_get_parent(&parentcomm);
- if (parentcomm == MPI_COMM_NULL)
- {
- MPI_Comm_rank( MPI_COMM_WORLD, &rank ); /* Get rank for verbose msg */
+ if (parentcomm == MPI_COMM_NULL) {
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank); /* Get rank for verbose msg */
IF_VERBOSE(("[%d] spawning %d processes\n", rank, np));
/* Create 3 more processes */
- MPI_Comm_spawn((char*)"./disconnect_reconnect",
- /*MPI_ARGV_NULL*/&argv[1], np,
- MPI_INFO_NULL, 0, MPI_COMM_WORLD,
- &intercomm, MPI_ERRCODES_IGNORE);
+ MPI_Comm_spawn((char *) "./disconnect_reconnect",
+ /*MPI_ARGV_NULL */ &argv[1], np,
+ MPI_INFO_NULL, 0, MPI_COMM_WORLD, &intercomm, MPI_ERRCODES_IGNORE);
}
- else
- {
+ else {
intercomm = parentcomm;
}
@@ -81,42 +76,35 @@ int main(int argc, char *argv[])
MPI_Comm_size(intercomm, &size);
MPI_Comm_rank(intercomm, &rank);
- if (parentcomm == MPI_COMM_NULL)
- {
+ if (parentcomm == MPI_COMM_NULL) {
IF_VERBOSE(("[%d] parent rank %d alive.\n", rank, rank));
/* Parent */
- if (rsize != np)
- {
+ if (rsize != np) {
errs++;
printf("Did not create %d processes (got %d)\n", np, rsize);
fflush(stdout);
}
- if (rank == 0 && num_loops > 0)
- {
+ if (rank == 0 && num_loops > 0) {
MPI_Open_port(MPI_INFO_NULL, port);
IF_VERBOSE(("[%d] port = %s\n", rank, port));
MPI_Send(port, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0, intercomm);
}
- IF_VERBOSE(("[%d] disconnecting child communicator\n",rank));
+ IF_VERBOSE(("[%d] disconnecting child communicator\n", rank));
MPI_Comm_disconnect(&intercomm);
- for (i=0; i<num_loops; i++)
- {
- IF_VERBOSE(("[%d] accepting connection\n",rank));
+ for (i = 0; i < num_loops; i++) {
+ IF_VERBOSE(("[%d] accepting connection\n", rank));
MPI_Comm_accept(port, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &intercomm);
MPI_Comm_remote_size(intercomm, &rsize);
- if (do_messages && (rank == 0))
- {
+ if (do_messages && (rank == 0)) {
j = 0;
- for (j=0; j<rsize; j++)
- {
+ for (j = 0; j < rsize; j++) {
data = i;
IF_VERBOSE(("[%d]sending int to child process %d\n", rank, j));
MPI_Send(&data, 1, MPI_INT, j, 100, intercomm);
IF_VERBOSE(("[%d] receiving int from child process %d\n", rank, j));
- data = i-1;
+ data = i - 1;
MPI_Recv(&data, 1, MPI_INT, j, 100, intercomm, &status);
- if (data != i)
- {
+ if (data != i) {
errs++;
}
}
@@ -126,72 +114,66 @@ int main(int argc, char *argv[])
}
/* Errors cannot be sent back to the parent because there is no
- communicator connected to the children
- for (i=0; i<rsize; i++)
- {
- MPI_Recv( &err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE );
- errs += err;
- }
- */
+ * communicator connected to the children
+ * for (i=0; i<rsize; i++)
+ * {
+ * MPI_Recv(&err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE);
+ * errs += err;
+ * }
+ */
}
- else
- {
+ else {
IF_VERBOSE(("[%d] child rank %d alive.\n", rank, rank));
/* Child */
- if (size != np)
- {
+ if (size != np) {
errs++;
printf("(Child) Did not create %d processes (got %d)\n", np, size);
fflush(stdout);
}
- if (rank == 0 && num_loops > 0)
- {
+ if (rank == 0 && num_loops > 0) {
IF_VERBOSE(("[%d] receiving port\n", rank));
MPI_Recv(port, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0, intercomm, &status);
}
IF_VERBOSE(("[%d] disconnecting communicator\n", rank));
MPI_Comm_disconnect(&intercomm);
- for (i=0; i<num_loops; i++)
- {
- IF_VERBOSE(("[%d] connecting to port (loop %d)\n",rank,i));
+ for (i = 0; i < num_loops; i++) {
+ IF_VERBOSE(("[%d] connecting to port (loop %d)\n", rank, i));
MPI_Comm_connect(port, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &intercomm);
- if (do_messages)
- {
- IF_VERBOSE(("[%d] receiving int from parent process 0\n",rank));
+ if (do_messages) {
+ IF_VERBOSE(("[%d] receiving int from parent process 0\n", rank));
MPI_Recv(&data, 1, MPI_INT, 0, 100, intercomm, &status);
- if (data != i)
- {
+ if (data != i) {
printf("expected %d but received %d\n", i, data);
fflush(stdout);
MPI_Abort(MPI_COMM_WORLD, 1);
}
- IF_VERBOSE(("[%d] sending int back to parent process 1\n",rank));
+ IF_VERBOSE(("[%d] sending int back to parent process 1\n", rank));
MPI_Send(&data, 1, MPI_INT, 0, 100, intercomm);
}
- IF_VERBOSE(("[%d] disconnecting communicator\n",rank));
+ IF_VERBOSE(("[%d] disconnecting communicator\n", rank));
MPI_Comm_disconnect(&intercomm);
}
/* Send the errs back to the master process */
/* Errors cannot be sent back to the parent because there is no
- communicator connected to the parent */
- /*MPI_Ssend( &errs, 1, MPI_INT, 0, 1, intercomm );*/
+ * communicator connected to the parent */
+ /*MPI_Ssend(&errs, 1, MPI_INT, 0, 1, intercomm); */
}
/* Note that the MTest_Finalize get errs only over COMM_WORLD */
/* Note also that both the parent and child will generate "No Errors"
- if both call MTest_Finalize */
- if (parentcomm == MPI_COMM_NULL)
- {
- MTest_Finalize( errs );
+ * if both call MTest_Finalize */
+ if (parentcomm == MPI_COMM_NULL) {
+ MTest_Finalize(errs);
}
- } else {
- MTest_Finalize( errs );
+ }
+ else {
+ MTest_Finalize(errs);
}
- IF_VERBOSE(("[%d] calling finalize\n",rank));
+ IF_VERBOSE(("[%d] calling finalize\n", rank));
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/spawn/disconnect_reconnect2.c b/test/mpi/spawn/disconnect_reconnect2.c
index c23d667..d419f5c 100644
--- a/test/mpi/spawn/disconnect_reconnect2.c
+++ b/test/mpi/spawn/disconnect_reconnect2.c
@@ -10,9 +10,9 @@
#include "mpitest.h"
/* Note: In this program, the return codes from the MPI routines are checked.
- Since the error handlers for the communicators are not set to
+ Since the error handlers for the communicators are not set to
MPI_ERRORS_RETURN, any error should cause an abort rather than a return.
- The test on the return value is an extra safety check; note that a
+ The test on the return value is an extra safety check; note that a
return value of other than MPI_SUCCESS in these routines indicates an
error in the error handling by the MPI implementation */
@@ -23,16 +23,15 @@ void check_error(int error, const char *fcname)
{
char err_string[MPI_MAX_ERROR_STRING] = "";
int length;
- if (error != MPI_SUCCESS)
- {
- MPI_Error_string(error, err_string, &length);
- printf("%s failed: %s\n", fcname, err_string);
- fflush(stdout);
- MPI_Abort(MPI_COMM_WORLD, error);
+ if (error != MPI_SUCCESS) {
+ MPI_Error_string(error, err_string, &length);
+ printf("%s failed: %s\n", fcname, err_string);
+ fflush(stdout);
+ MPI_Abort(MPI_COMM_WORLD, error);
}
}
-/* This test spawns two child jobs and has them open a port and connect to
+/* This test spawns two child jobs and has them open a port and connect to
* each other.
* The two children repeatedly connect, accept, and disconnect from each other.
*/
@@ -41,10 +40,10 @@ int main(int argc, char *argv[])
int error;
int rank, size;
int numprocs = 3;
- char *argv1[2] = { (char*)"connector", NULL };
- char *argv2[2] = { (char*)"acceptor", NULL };
+ char *argv1[2] = { (char *) "connector", NULL };
+ char *argv2[2] = { (char *) "acceptor", NULL };
MPI_Comm comm_connector, comm_acceptor, comm_parent, comm;
- char port[MPI_MAX_PORT_NAME] = {0};
+ char port[MPI_MAX_PORT_NAME] = { 0 };
MPI_Status status;
MPI_Info spawn_path = MPI_INFO_NULL;
int i, num_loops = 100;
@@ -52,9 +51,8 @@ int main(int argc, char *argv[])
int verbose = 0;
int can_spawn, errs = 0;
- if (getenv("MPITEST_VERBOSE"))
- {
- verbose = 1;
+ if (getenv("MPITEST_VERBOSE")) {
+ verbose = 1;
}
IF_VERBOSE(("init.\n"));
@@ -64,11 +62,12 @@ int main(int argc, char *argv[])
errs += MTestSpawnPossible(&can_spawn);
if (!can_spawn) {
if (errs)
- printf( " Found %d errors\n", errs );
+ printf(" Found %d errors\n", errs);
else
- printf( " No Errors\n" );
+ printf(" No Errors\n");
fflush(stdout);
- } else {
+ }
+ else {
IF_VERBOSE(("size.\n"));
error = MPI_Comm_size(MPI_COMM_WORLD, &size);
check_error(error, "MPI_Comm_size");
@@ -77,42 +76,36 @@ int main(int argc, char *argv[])
error = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
check_error(error, "MPI_Comm_rank");
- if (argc == 1)
- {
+ if (argc == 1) {
/* Make sure that the current directory is in the path.
- Not all implementations may honor or understand this, but
- it is highly recommended as it gives users a clean way
- to specify the location of the executable without
- specifying a particular directory format (e.g., this
- should work with both Windows and Unix implementations) */
- MPI_Info_create( &spawn_path );
- MPI_Info_set( spawn_path, (char*)"path", (char*)"." );
+ * Not all implementations may honor or understand this, but
+ * it is highly recommended as it gives users a clean way
+ * to specify the location of the executable without
+ * specifying a particular directory format (e.g., this
+ * should work with both Windows and Unix implementations) */
+ MPI_Info_create(&spawn_path);
+ MPI_Info_set(spawn_path, (char *) "path", (char *) ".");
IF_VERBOSE(("spawn connector.\n"));
- error = MPI_Comm_spawn((char*)"disconnect_reconnect2",
- argv1, numprocs, spawn_path, 0,
- MPI_COMM_WORLD, &comm_connector,
- MPI_ERRCODES_IGNORE);
+ error = MPI_Comm_spawn((char *) "disconnect_reconnect2",
+ argv1, numprocs, spawn_path, 0,
+ MPI_COMM_WORLD, &comm_connector, MPI_ERRCODES_IGNORE);
check_error(error, "MPI_Comm_spawn");
IF_VERBOSE(("spawn acceptor.\n"));
- error = MPI_Comm_spawn((char*)"disconnect_reconnect2",
- argv2, numprocs, spawn_path, 0,
- MPI_COMM_WORLD, &comm_acceptor,
- MPI_ERRCODES_IGNORE);
+ error = MPI_Comm_spawn((char *) "disconnect_reconnect2",
+ argv2, numprocs, spawn_path, 0,
+ MPI_COMM_WORLD, &comm_acceptor, MPI_ERRCODES_IGNORE);
check_error(error, "MPI_Comm_spawn");
- MPI_Info_free( &spawn_path );
+ MPI_Info_free(&spawn_path);
- if (rank == 0)
- {
+ if (rank == 0) {
IF_VERBOSE(("recv port.\n"));
- error = MPI_Recv(port, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0,
- comm_acceptor, &status);
+ error = MPI_Recv(port, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0, comm_acceptor, &status);
check_error(error, "MPI_Recv");
IF_VERBOSE(("send port.\n"));
- error = MPI_Send(port, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0,
- comm_connector);
+ error = MPI_Send(port, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0, comm_connector);
check_error(error, "MPI_Send");
}
@@ -129,24 +122,21 @@ int main(int argc, char *argv[])
error = MPI_Comm_free(&comm_connector);
check_error(error, "MPI_Comm_free");
- if (rank == 0)
- {
+ if (rank == 0) {
printf(" No Errors\n");
fflush(stdout);
}
}
- else if ((argc == 2) && (strcmp(argv[1], "acceptor") == 0))
- {
+ else if ((argc == 2) && (strcmp(argv[1], "acceptor") == 0)) {
IF_VERBOSE(("get_parent.\n"));
error = MPI_Comm_get_parent(&comm_parent);
check_error(error, "MPI_Comm_get_parent");
- if (comm_parent == MPI_COMM_NULL)
- {
- printf("acceptor's parent is NULL.\n");fflush(stdout);
+ if (comm_parent == MPI_COMM_NULL) {
+ printf("acceptor's parent is NULL.\n");
+ fflush(stdout);
MPI_Abort(MPI_COMM_WORLD, -1);
}
- if (rank == 0)
- {
+ if (rank == 0) {
IF_VERBOSE(("open_port.\n"));
error = MPI_Open_port(MPI_INFO_NULL, port);
check_error(error, "MPI_Open_port");
@@ -157,21 +147,18 @@ int main(int argc, char *argv[])
check_error(error, "MPI_Send");
}
- for (i=0; i<num_loops; i++)
- {
+ for (i = 0; i < num_loops; i++) {
IF_VERBOSE(("accept.\n"));
error = MPI_Comm_accept(port, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &comm);
check_error(error, "MPI_Comm_accept");
- if (rank == 0)
- {
+ if (rank == 0) {
data = i;
error = MPI_Send(&data, 1, MPI_INT, 0, 0, comm);
check_error(error, "MPI_Send");
error = MPI_Recv(&data, 1, MPI_INT, 0, 0, comm, &status);
check_error(error, "MPI_Recv");
- if (data != i)
- {
+ if (data != i) {
printf("expected %d but received %d\n", i, data);
fflush(stdout);
MPI_Abort(MPI_COMM_WORLD, 1);
@@ -183,8 +170,7 @@ int main(int argc, char *argv[])
check_error(error, "MPI_Comm_disconnect");
}
- if (rank == 0)
- {
+ if (rank == 0) {
IF_VERBOSE(("close_port.\n"));
error = MPI_Close_port(port);
check_error(error, "MPI_Close_port");
@@ -194,41 +180,35 @@ int main(int argc, char *argv[])
error = MPI_Barrier(comm_parent);
check_error(error, "MPI_Barrier");
- MPI_Comm_free( &comm_parent );
+ MPI_Comm_free(&comm_parent);
}
- else if ((argc == 2) && (strcmp(argv[1], "connector") == 0))
- {
+ else if ((argc == 2) && (strcmp(argv[1], "connector") == 0)) {
IF_VERBOSE(("get_parent.\n"));
error = MPI_Comm_get_parent(&comm_parent);
check_error(error, "MPI_Comm_get_parent");
- if (comm_parent == MPI_COMM_NULL)
- {
- printf("acceptor's parent is NULL.\n");fflush(stdout);
+ if (comm_parent == MPI_COMM_NULL) {
+ printf("acceptor's parent is NULL.\n");
+ fflush(stdout);
MPI_Abort(MPI_COMM_WORLD, -1);
}
- if (rank == 0)
- {
+ if (rank == 0) {
IF_VERBOSE(("recv.\n"));
- error = MPI_Recv(port, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0,
- comm_parent, &status);
+ error = MPI_Recv(port, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0, comm_parent, &status);
check_error(error, "MPI_Recv");
IF_VERBOSE(("1: received port: <%s>\n", port));
}
- for (i=0; i<num_loops; i++)
- {
+ for (i = 0; i < num_loops; i++) {
IF_VERBOSE(("connect.\n"));
error = MPI_Comm_connect(port, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &comm);
check_error(error, "MPI_Comm_connect");
- if (rank == 0)
- {
+ if (rank == 0) {
data = -1;
error = MPI_Recv(&data, 1, MPI_INT, 0, 0, comm, &status);
check_error(error, "MPI_Recv");
- if (data != i)
- {
+ if (data != i) {
printf("expected %d but received %d\n", i, data);
fflush(stdout);
MPI_Abort(MPI_COMM_WORLD, 1);
@@ -246,15 +226,14 @@ int main(int argc, char *argv[])
error = MPI_Barrier(comm_parent);
check_error(error, "MPI_Barrier");
- MPI_Comm_free( &comm_parent );
+ MPI_Comm_free(&comm_parent);
}
- else
- {
- printf("invalid command line.\n");fflush(stdout);
+ else {
+ printf("invalid command line.\n");
+ fflush(stdout);
{
int ii;
- for (ii=0; ii<argc; ii++)
- {
+ for (ii = 0; ii < argc; ii++) {
printf("argv[%d] = <%s>\n", ii, argv[ii]);
}
}
diff --git a/test/mpi/spawn/disconnect_reconnect3.c b/test/mpi/spawn/disconnect_reconnect3.c
index 6ef155c..79a43d8 100644
--- a/test/mpi/spawn/disconnect_reconnect3.c
+++ b/test/mpi/spawn/disconnect_reconnect3.c
@@ -19,11 +19,11 @@
/*
* This test tests the disconnect code for processes that span process groups.
*
- * This test spawns a group of processes and then merges them into a single
+ * This test spawns a group of processes and then merges them into a single
* communicator.
* Then the single communicator is split into two communicators, one containing
* the even ranks and the other the odd ranks.
- * Then the two new communicators do MPI_Comm_accept/connect/disconnect calls
+ * Then the two new communicators do MPI_Comm_accept/connect/disconnect calls
* in a loop.
* The even group does the accepting while the odd group does the connecting.
*
@@ -40,8 +40,8 @@ static char MTEST_Descrip[] = "A simple test of Comm_connect/accept/disconnect";
*
* Thanks to Edric Ellis for contributing this portion of the test program.
*/
-void checkReverseMergedComm( MPI_Comm comm );
-void checkReverseMergedComm( MPI_Comm comm )
+void checkReverseMergedComm(MPI_Comm comm);
+void checkReverseMergedComm(MPI_Comm comm)
{
MPI_Group origGroup;
MPI_Group newGroup;
@@ -57,21 +57,21 @@ void checkReverseMergedComm( MPI_Comm comm )
MPI_Comm_size(comm, &merged_size);
newGroupRanks = calloc(merged_size, sizeof(int));
- for ( ii = 0; ii < merged_size; ++ii ) {
+ for (ii = 0; ii < merged_size; ++ii) {
newGroupRanks[ii] = merged_size - ii - 1;
}
- MPI_Comm_group( comm, &origGroup );
- MPI_Group_incl( origGroup, merged_size, newGroupRanks, &newGroup );
- free( newGroupRanks );
- MPI_Comm_create( comm, newGroup, &newComm );
+ MPI_Comm_group(comm, &origGroup);
+ MPI_Group_incl(origGroup, merged_size, newGroupRanks, &newGroup);
+ free(newGroupRanks);
+ MPI_Comm_create(comm, newGroup, &newComm);
assert(newComm != MPI_COMM_NULL);
/* try a bcast as a weak sanity check that the communicator works */
MPI_Bcast(&buf, 1, MPI_INT, 0, newComm);
- MPI_Group_free( &origGroup );
- MPI_Group_free( &newGroup );
- MPI_Comm_free( &newComm );
+ MPI_Group_free(&origGroup);
+ MPI_Group_free(&newGroup);
+ MPI_Comm_free(&newComm);
}
@@ -83,7 +83,7 @@ int main(int argc, char *argv[])
int np = 4;
MPI_Comm parentcomm, intercomm, intracomm, comm;
MPI_Status status;
- char port[MPI_MAX_PORT_NAME] = {0};
+ char port[MPI_MAX_PORT_NAME] = { 0 };
int even_odd;
int verbose = 0;
int do_messages = 1;
@@ -91,45 +91,39 @@ int main(int argc, char *argv[])
int can_spawn;
env = getenv("MPITEST_VERBOSE");
- if (env)
- {
- if (*env != '0')
- verbose = 1;
+ if (env) {
+ if (*env != '0')
+ verbose = 1;
}
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
errs += MTestSpawnPossible(&can_spawn);
if (can_spawn) {
/* command line arguments can change the number of loop iterations and
- whether or not messages are sent over the new communicators */
- if (argc > 1)
- {
+ * whether or not messages are sent over the new communicators */
+ if (argc > 1) {
num_loops = atoi(argv[1]);
if (num_loops < 0)
num_loops = 0;
if (num_loops > 100)
num_loops = 100;
}
- if (argc > 2)
- {
+ if (argc > 2) {
do_messages = atoi(argv[2]);
}
/* Spawn the child processes and merge them into a single communicator */
- MPI_Comm_get_parent( &parentcomm );
- if (parentcomm == MPI_COMM_NULL)
- {
+ MPI_Comm_get_parent(&parentcomm);
+ if (parentcomm == MPI_COMM_NULL) {
IF_VERBOSE(("spawning %d processes\n", np));
/* Create 4 more processes */
- MPI_Comm_spawn((char*)"./disconnect_reconnect3",
- /*MPI_ARGV_NULL*/&argv[1], np,
- MPI_INFO_NULL, 0, MPI_COMM_WORLD,
- &intercomm, MPI_ERRCODES_IGNORE);
+ MPI_Comm_spawn((char *) "./disconnect_reconnect3",
+ /*MPI_ARGV_NULL */ &argv[1], np,
+ MPI_INFO_NULL, 0, MPI_COMM_WORLD, &intercomm, MPI_ERRCODES_IGNORE);
MPI_Intercomm_merge(intercomm, 0, &intracomm);
}
- else
- {
+ else {
intercomm = parentcomm;
MPI_Intercomm_merge(intercomm, 1, &intracomm);
}
@@ -141,20 +135,19 @@ int main(int argc, char *argv[])
MPI_Comm_rank(intracomm, &rank);
/* Split the communicator so that the even ranks are in one communicator
- and the odd ranks are in another */
+ * and the odd ranks are in another */
even_odd = rank % 2;
MPI_Comm_split(intracomm, even_odd, rank, &comm);
/* Open a port on rank zero of the even communicator */
/* rank 0 on intracomm == rank 0 on even communicator */
- if (rank == 0)
- {
+ if (rank == 0) {
MPI_Open_port(MPI_INFO_NULL, port);
IF_VERBOSE(("port = %s\n", port));
}
/* Broadcast the port to everyone. This makes the logic easier than
- trying to figure out which process in the odd communicator to send it
- to */
+ * trying to figure out which process in the odd communicator to send it
+ * to */
MPI_Bcast(port, MPI_MAX_PORT_NAME, MPI_CHAR, 0, intracomm);
IF_VERBOSE(("disconnecting parent/child communicator\n"));
@@ -163,27 +156,22 @@ int main(int argc, char *argv[])
MPI_Comm_rank(comm, &rank);
- if (!even_odd)
- {
+ if (!even_odd) {
/* The even group does the accepting */
- for (i=0; i<num_loops; i++)
- {
+ for (i = 0; i < num_loops; i++) {
IF_VERBOSE(("accepting connection\n"));
MPI_Comm_accept(port, MPI_INFO_NULL, 0, comm, &intercomm);
MPI_Comm_remote_size(intercomm, &rsize);
- if (do_messages && (rank == 0))
- {
+ if (do_messages && (rank == 0)) {
j = 0;
- for (j=0; j<rsize; j++)
- {
+ for (j = 0; j < rsize; j++) {
data = i;
IF_VERBOSE(("sending int to odd_communicator process %d\n", j));
MPI_Send(&data, 1, MPI_INT, j, 100, intercomm);
IF_VERBOSE(("receiving int from odd_communicator process %d\n", j));
- data = i-1;
+ data = i - 1;
MPI_Recv(&data, 1, MPI_INT, j, 100, intercomm, &status);
- if (data != i)
- {
+ if (data != i) {
errs++;
}
}
@@ -193,27 +181,23 @@ int main(int argc, char *argv[])
}
/* Errors cannot be sent back to the parent because there is no
- communicator connected to the children
- for (i=0; i<rsize; i++)
- {
- MPI_Recv( &err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE );
- errs += err;
- }
- */
+ * communicator connected to the children
+ * for (i=0; i<rsize; i++)
+ * {
+ * MPI_Recv(&err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE);
+ * errs += err;
+ * }
+ */
}
- else
- {
+ else {
/* The odd group does the connecting */
- for (i=0; i<num_loops; i++)
- {
+ for (i = 0; i < num_loops; i++) {
IF_VERBOSE(("connecting to port\n"));
MPI_Comm_connect(port, MPI_INFO_NULL, 0, comm, &intercomm);
- if (do_messages)
- {
+ if (do_messages) {
IF_VERBOSE(("receiving int from even_communicator process 0\n"));
MPI_Recv(&data, 1, MPI_INT, 0, 100, intercomm, &status);
- if (data != i)
- {
+ if (data != i) {
printf("expected %d but received %d\n", i, data);
fflush(stdout);
MPI_Abort(MPI_COMM_WORLD, 1);
@@ -227,20 +211,20 @@ int main(int argc, char *argv[])
/* Send the errs back to the master process */
/* Errors cannot be sent back to the parent because there is no
- communicator connected to the parent */
- /*MPI_Ssend( &errs, 1, MPI_INT, 0, 1, intercomm );*/
+ * communicator connected to the parent */
+ /*MPI_Ssend(&errs, 1, MPI_INT, 0, 1, intercomm); */
}
- MPI_Comm_free( &comm );
+ MPI_Comm_free(&comm);
/* Note that the MTest_Finalize get errs only over COMM_WORLD */
/* Note also that both the parent and child will generate "No Errors"
- if both call MTest_Finalize */
- if (parentcomm == MPI_COMM_NULL)
- {
- MTest_Finalize( errs );
+ * if both call MTest_Finalize */
+ if (parentcomm == MPI_COMM_NULL) {
+ MTest_Finalize(errs);
}
- } else {
- MTest_Finalize( errs );
+ }
+ else {
+ MTest_Finalize(errs);
}
IF_VERBOSE(("calling finalize\n"));
diff --git a/test/mpi/spawn/join.c b/test/mpi/spawn/join.c
index 0ff340f..b45837c 100644
--- a/test/mpi/spawn/join.c
+++ b/test/mpi/spawn/join.c
@@ -9,7 +9,7 @@
#include <stdio.h>
#ifdef HAVE_WINDOWS_H
#include <winsock2.h>
-#include <ws2tcpip.h> /* socklen_t */
+#include <ws2tcpip.h> /* socklen_t */
#else
#include <sys/socket.h>
#include <sys/types.h>
@@ -26,10 +26,10 @@ static char MTEST_Descrip[] = "A simple test of Comm_join";
#define COUNT 1024
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int sendbuf[COUNT], recvbuf[COUNT], i;
- int err=0, rank, nprocs, errs=0;
+ int err = 0, rank, nprocs, errs = 0;
MPI_Comm intercomm;
int listenfd, connfd, port, namelen;
struct sockaddr_in cliaddr, servaddr;
@@ -37,14 +37,14 @@ int main( int argc, char *argv[] )
char hostname[MPI_MAX_PROCESSOR_NAME];
socklen_t len, clilen;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
+ MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (nprocs != 2) {
printf("Run this program with 2 processes\n");
- MPI_Abort(MPI_COMM_WORLD,1);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
if (rank == 1) {
@@ -52,9 +52,9 @@ int main( int argc, char *argv[] )
listenfd = socket(AF_INET, SOCK_STREAM, 0);
if (listenfd < 0) {
printf("server cannot open socket\n");
- MPI_Abort(MPI_COMM_WORLD,1);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
-
+
memset(&servaddr, 0, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
@@ -62,17 +62,17 @@ int main( int argc, char *argv[] )
err = bind(listenfd, (struct sockaddr *) &servaddr, sizeof(servaddr));
if (err < 0) {
- errs++;
+ errs++;
printf("bind failed\n");
- MPI_Abort(MPI_COMM_WORLD,1);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
len = sizeof(servaddr);
err = getsockname(listenfd, (struct sockaddr *) &servaddr, &len);
if (err < 0) {
- errs++;
+ errs++;
printf("getsockname failed\n");
- MPI_Abort(MPI_COMM_WORLD,1);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
port = ntohs(servaddr.sin_port);
@@ -80,12 +80,12 @@ int main( int argc, char *argv[] )
err = listen(listenfd, 5);
if (err < 0) {
- errs++;
+ errs++;
printf("listen failed\n");
MPI_Abort(MPI_COMM_WORLD, 1);
}
- MPI_Send(hostname, namelen+1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+ MPI_Send(hostname, namelen + 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
MPI_Send(&port, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
clilen = sizeof(cliaddr);
@@ -99,7 +99,7 @@ int main( int argc, char *argv[] )
else {
/* client */
- MPI_Recv(hostname, MPI_MAX_PROCESSOR_NAME, MPI_CHAR, 1, 0,
+ MPI_Recv(hostname, MPI_MAX_PROCESSOR_NAME, MPI_CHAR, 1, 0,
MPI_COMM_WORLD, MPI_STATUS_IGNORE);
MPI_Recv(&port, 1, MPI_INT, 1, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
@@ -123,7 +123,7 @@ int main( int argc, char *argv[] )
/* connect to server */
err = connect(connfd, (struct sockaddr *) &servaddr, sizeof(servaddr));
if (err < 0) {
- errs++;
+ errs++;
printf("client cannot connect\n");
MPI_Abort(MPI_COMM_WORLD, 1);
}
@@ -132,31 +132,34 @@ int main( int argc, char *argv[] )
MPI_Barrier(MPI_COMM_WORLD);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
err = MPI_Comm_join(connfd, &intercomm);
- if (err) { errs++; printf("Error in MPI_Comm_join %d\n", err); }
+ if (err) {
+ errs++;
+ printf("Error in MPI_Comm_join %d\n", err);
+ }
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( intercomm, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(intercomm, MPI_ERRORS_RETURN);
- for (i=0; i<COUNT; i++) {
+ for (i = 0; i < COUNT; i++) {
recvbuf[i] = -1;
- sendbuf[i] = i + COUNT*rank;
+ sendbuf[i] = i + COUNT * rank;
}
- err = MPI_Sendrecv(sendbuf, COUNT, MPI_INT, 0, 0, recvbuf, COUNT, MPI_INT,
+ err = MPI_Sendrecv(sendbuf, COUNT, MPI_INT, 0, 0, recvbuf, COUNT, MPI_INT,
0, 0, intercomm, MPI_STATUS_IGNORE);
if (err != MPI_SUCCESS) {
errs++;
- printf( "Error in MPI_Sendrecv on new communicator\n" );
+ printf("Error in MPI_Sendrecv on new communicator\n");
}
- for (i=0; i<COUNT; i++) {
- if (recvbuf[i] != ((rank+1)%2) * COUNT + i)
+ for (i = 0; i < COUNT; i++) {
+ if (recvbuf[i] != ((rank + 1) % 2) * COUNT + i)
errs++;
}
@@ -164,9 +167,9 @@ int main( int argc, char *argv[] )
err = MPI_Comm_disconnect(&intercomm);
if (err != MPI_SUCCESS) {
errs++;
- printf( "Error in MPI_Comm_disconnect\n" );
+ printf("Error in MPI_Comm_disconnect\n");
}
-
+
MTest_Finalize(errs);
MPI_Finalize();
diff --git a/test/mpi/spawn/multiple_ports.c b/test/mpi/spawn/multiple_ports.c
index 23b3327..c747fce 100644
--- a/test/mpi/spawn/multiple_ports.c
+++ b/test/mpi/spawn/multiple_ports.c
@@ -21,7 +21,7 @@
* the connection from process 1.
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int num_errors = 0, total_num_errors = 0;
int rank, size;
@@ -32,113 +32,103 @@ int main( int argc, char *argv[] )
int verbose = 0;
int data = 0;
- if (getenv("MPITEST_VERBOSE"))
- {
- verbose = 1;
+ if (getenv("MPITEST_VERBOSE")) {
+ verbose = 1;
}
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- if (size < 3)
- {
- printf("Three processes needed to run this test.\n");
- MPI_Finalize();
- return 0;
+ if (size < 3) {
+ printf("Three processes needed to run this test.\n");
+ MPI_Finalize();
+ return 0;
}
- if (rank == 0)
- {
- IF_VERBOSE(("0: opening ports.\n"));
- MPI_Open_port(MPI_INFO_NULL, port1);
- MPI_Open_port(MPI_INFO_NULL, port2);
-
- IF_VERBOSE(("0: opened port1: <%s>\n", port1));
- IF_VERBOSE(("0: opened port2: <%s>\n", port2));
- IF_VERBOSE(("0: sending ports.\n"));
- MPI_Send(port1, MPI_MAX_PORT_NAME, MPI_CHAR, 1, 0, MPI_COMM_WORLD);
- MPI_Send(port2, MPI_MAX_PORT_NAME, MPI_CHAR, 2, 0, MPI_COMM_WORLD);
-
- IF_VERBOSE(("0: accepting port2.\n"));
- MPI_Comm_accept(port2, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm2);
- IF_VERBOSE(("0: accepting port1.\n"));
- MPI_Comm_accept(port1, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm1);
-
- IF_VERBOSE(("0: closing ports.\n"));
- MPI_Close_port(port1);
- MPI_Close_port(port2);
-
- IF_VERBOSE(("0: sending 1 to process 1.\n"));
- data = 1;
- MPI_Send(&data, 1, MPI_INT, 0, 0, comm1);
-
- IF_VERBOSE(("0: sending 2 to process 2.\n"));
- data = 2;
- MPI_Send(&data, 1, MPI_INT, 0, 0, comm2);
-
- IF_VERBOSE(("0: disconnecting.\n"));
- MPI_Comm_disconnect(&comm1);
- MPI_Comm_disconnect(&comm2);
+ if (rank == 0) {
+ IF_VERBOSE(("0: opening ports.\n"));
+ MPI_Open_port(MPI_INFO_NULL, port1);
+ MPI_Open_port(MPI_INFO_NULL, port2);
+
+ IF_VERBOSE(("0: opened port1: <%s>\n", port1));
+ IF_VERBOSE(("0: opened port2: <%s>\n", port2));
+ IF_VERBOSE(("0: sending ports.\n"));
+ MPI_Send(port1, MPI_MAX_PORT_NAME, MPI_CHAR, 1, 0, MPI_COMM_WORLD);
+ MPI_Send(port2, MPI_MAX_PORT_NAME, MPI_CHAR, 2, 0, MPI_COMM_WORLD);
+
+ IF_VERBOSE(("0: accepting port2.\n"));
+ MPI_Comm_accept(port2, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm2);
+ IF_VERBOSE(("0: accepting port1.\n"));
+ MPI_Comm_accept(port1, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm1);
+
+ IF_VERBOSE(("0: closing ports.\n"));
+ MPI_Close_port(port1);
+ MPI_Close_port(port2);
+
+ IF_VERBOSE(("0: sending 1 to process 1.\n"));
+ data = 1;
+ MPI_Send(&data, 1, MPI_INT, 0, 0, comm1);
+
+ IF_VERBOSE(("0: sending 2 to process 2.\n"));
+ data = 2;
+ MPI_Send(&data, 1, MPI_INT, 0, 0, comm2);
+
+ IF_VERBOSE(("0: disconnecting.\n"));
+ MPI_Comm_disconnect(&comm1);
+ MPI_Comm_disconnect(&comm2);
}
- else if (rank == 1)
- {
- IF_VERBOSE(("1: receiving port.\n"));
- MPI_Recv(port1, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &status);
-
- IF_VERBOSE(("1: received port1: <%s>\n", port1));
- IF_VERBOSE(("1: connecting.\n"));
- MPI_Comm_connect(port1, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm1);
-
- MPI_Recv(&data, 1, MPI_INT, 0, 0, comm1, &status);
- if (data != 1)
- {
- printf("Received %d from root when expecting 1\n", data);
- fflush(stdout);
- num_errors++;
- }
-
- IF_VERBOSE(("1: disconnecting.\n"));
- MPI_Comm_disconnect(&comm1);
+ else if (rank == 1) {
+ IF_VERBOSE(("1: receiving port.\n"));
+ MPI_Recv(port1, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &status);
+
+ IF_VERBOSE(("1: received port1: <%s>\n", port1));
+ IF_VERBOSE(("1: connecting.\n"));
+ MPI_Comm_connect(port1, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm1);
+
+ MPI_Recv(&data, 1, MPI_INT, 0, 0, comm1, &status);
+ if (data != 1) {
+ printf("Received %d from root when expecting 1\n", data);
+ fflush(stdout);
+ num_errors++;
+ }
+
+ IF_VERBOSE(("1: disconnecting.\n"));
+ MPI_Comm_disconnect(&comm1);
}
- else if (rank == 2)
- {
- IF_VERBOSE(("2: receiving port.\n"));
- MPI_Recv(port2, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &status);
-
- IF_VERBOSE(("2: received port2: <%s>\n", port2));
- /* make sure process 1 has time to do the connect before this process
- attempts to connect */
- MTestSleep(3);
- IF_VERBOSE(("2: connecting.\n"));
- MPI_Comm_connect(port2, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm2);
-
- MPI_Recv(&data, 1, MPI_INT, 0, 0, comm2, &status);
- if (data != 2)
- {
- printf("Received %d from root when expecting 2\n", data);
- fflush(stdout);
- num_errors++;
- }
-
- IF_VERBOSE(("2: disconnecting.\n"));
- MPI_Comm_disconnect(&comm2);
+ else if (rank == 2) {
+ IF_VERBOSE(("2: receiving port.\n"));
+ MPI_Recv(port2, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &status);
+
+ IF_VERBOSE(("2: received port2: <%s>\n", port2));
+ /* make sure process 1 has time to do the connect before this process
+ * attempts to connect */
+ MTestSleep(3);
+ IF_VERBOSE(("2: connecting.\n"));
+ MPI_Comm_connect(port2, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm2);
+
+ MPI_Recv(&data, 1, MPI_INT, 0, 0, comm2, &status);
+ if (data != 2) {
+ printf("Received %d from root when expecting 2\n", data);
+ fflush(stdout);
+ num_errors++;
+ }
+
+ IF_VERBOSE(("2: disconnecting.\n"));
+ MPI_Comm_disconnect(&comm2);
}
MPI_Barrier(MPI_COMM_WORLD);
MPI_Reduce(&num_errors, &total_num_errors, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
- if (rank == 0)
- {
- if (total_num_errors)
- {
- printf(" Found %d errors\n", total_num_errors);
- }
- else
- {
- printf(" No Errors\n");
- }
- fflush(stdout);
+ if (rank == 0) {
+ if (total_num_errors) {
+ printf(" Found %d errors\n", total_num_errors);
+ }
+ else {
+ printf(" No Errors\n");
+ }
+ fflush(stdout);
}
MPI_Finalize();
return total_num_errors;
diff --git a/test/mpi/spawn/multiple_ports2.c b/test/mpi/spawn/multiple_ports2.c
index 3463b99..b07f8dc 100644
--- a/test/mpi/spawn/multiple_ports2.c
+++ b/test/mpi/spawn/multiple_ports2.c
@@ -11,22 +11,22 @@
#define IF_VERBOSE(a) if (verbose) { printf a ; fflush(stdout); }
-/* This test checks to make sure that two MPI_Comm_connects to two different
+/* This test checks to make sure that two MPI_Comm_connects to two different
* MPI ports
- * match their corresponding MPI_Comm_accepts. The root process opens two
+ * match their corresponding MPI_Comm_accepts. The root process opens two
* MPI ports and
- * sends the first port to process 1 and the second to process 2. Then the
+ * sends the first port to process 1 and the second to process 2. Then the
* root process
* accepts a connection from the second port followed by the first port. '
* Processes 1 and
- * 2 both connect back to the root but process 2 first sleeps for three
+ * 2 both connect back to the root but process 2 first sleeps for three
* seconds to give
- * process 1 time to attempt to connect to the root. The root should wait
+ * process 1 time to attempt to connect to the root. The root should wait
* until
* process 2 connects before accepting the connection from process 1.
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int num_errors = 0, total_num_errors = 0;
int rank, size;
@@ -38,147 +38,135 @@ int main( int argc, char *argv[] )
int verbose = 0;
int data = 0;
- if (getenv("MPITEST_VERBOSE"))
- {
- verbose = 1;
+ if (getenv("MPITEST_VERBOSE")) {
+ verbose = 1;
}
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- if (size < 4)
- {
- printf("Four processes needed to run this test.\n");
- MPI_Finalize();
- return 0;
+ if (size < 4) {
+ printf("Four processes needed to run this test.\n");
+ MPI_Finalize();
+ return 0;
}
- if (rank == 0)
- {
- IF_VERBOSE(("0: opening ports.\n"));
- MPI_Open_port(MPI_INFO_NULL, port1);
- MPI_Open_port(MPI_INFO_NULL, port2);
- MPI_Open_port(MPI_INFO_NULL, port3);
-
- IF_VERBOSE(("0: opened port1: <%s>\n", port1));
- IF_VERBOSE(("0: opened port2: <%s>\n", port2));
- IF_VERBOSE(("0: opened port3: <%s>\n", port3));
- IF_VERBOSE(("0: sending ports.\n"));
- MPI_Send(port1, MPI_MAX_PORT_NAME, MPI_CHAR, 1, 0, MPI_COMM_WORLD);
- MPI_Send(port2, MPI_MAX_PORT_NAME, MPI_CHAR, 2, 0, MPI_COMM_WORLD);
- MPI_Send(port3, MPI_MAX_PORT_NAME, MPI_CHAR, 3, 0, MPI_COMM_WORLD);
-
- IF_VERBOSE(("0: accepting port3.\n"));
- MPI_Comm_accept(port3, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm3);
- IF_VERBOSE(("0: accepting port2.\n"));
- MPI_Comm_accept(port2, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm2);
- IF_VERBOSE(("0: accepting port1.\n"));
- MPI_Comm_accept(port1, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm1);
-
- IF_VERBOSE(("0: closing ports.\n"));
- MPI_Close_port(port1);
- MPI_Close_port(port2);
- MPI_Close_port(port3);
-
- IF_VERBOSE(("0: sending 1 to process 1.\n"));
- data = 1;
- MPI_Send(&data, 1, MPI_INT, 0, 0, comm1);
-
- IF_VERBOSE(("0: sending 2 to process 2.\n"));
- data = 2;
- MPI_Send(&data, 1, MPI_INT, 0, 0, comm2);
-
- IF_VERBOSE(("0: sending 3 to process 3.\n"));
- data = 3;
- MPI_Send(&data, 1, MPI_INT, 0, 0, comm3);
-
- IF_VERBOSE(("0: disconnecting.\n"));
- MPI_Comm_disconnect(&comm1);
- MPI_Comm_disconnect(&comm2);
- MPI_Comm_disconnect(&comm3);
+ if (rank == 0) {
+ IF_VERBOSE(("0: opening ports.\n"));
+ MPI_Open_port(MPI_INFO_NULL, port1);
+ MPI_Open_port(MPI_INFO_NULL, port2);
+ MPI_Open_port(MPI_INFO_NULL, port3);
+
+ IF_VERBOSE(("0: opened port1: <%s>\n", port1));
+ IF_VERBOSE(("0: opened port2: <%s>\n", port2));
+ IF_VERBOSE(("0: opened port3: <%s>\n", port3));
+ IF_VERBOSE(("0: sending ports.\n"));
+ MPI_Send(port1, MPI_MAX_PORT_NAME, MPI_CHAR, 1, 0, MPI_COMM_WORLD);
+ MPI_Send(port2, MPI_MAX_PORT_NAME, MPI_CHAR, 2, 0, MPI_COMM_WORLD);
+ MPI_Send(port3, MPI_MAX_PORT_NAME, MPI_CHAR, 3, 0, MPI_COMM_WORLD);
+
+ IF_VERBOSE(("0: accepting port3.\n"));
+ MPI_Comm_accept(port3, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm3);
+ IF_VERBOSE(("0: accepting port2.\n"));
+ MPI_Comm_accept(port2, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm2);
+ IF_VERBOSE(("0: accepting port1.\n"));
+ MPI_Comm_accept(port1, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm1);
+
+ IF_VERBOSE(("0: closing ports.\n"));
+ MPI_Close_port(port1);
+ MPI_Close_port(port2);
+ MPI_Close_port(port3);
+
+ IF_VERBOSE(("0: sending 1 to process 1.\n"));
+ data = 1;
+ MPI_Send(&data, 1, MPI_INT, 0, 0, comm1);
+
+ IF_VERBOSE(("0: sending 2 to process 2.\n"));
+ data = 2;
+ MPI_Send(&data, 1, MPI_INT, 0, 0, comm2);
+
+ IF_VERBOSE(("0: sending 3 to process 3.\n"));
+ data = 3;
+ MPI_Send(&data, 1, MPI_INT, 0, 0, comm3);
+
+ IF_VERBOSE(("0: disconnecting.\n"));
+ MPI_Comm_disconnect(&comm1);
+ MPI_Comm_disconnect(&comm2);
+ MPI_Comm_disconnect(&comm3);
}
- else if (rank == 1)
- {
- IF_VERBOSE(("1: receiving port.\n"));
- MPI_Recv(port1, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &status);
-
- IF_VERBOSE(("1: received port1: <%s>\n", port1));
- IF_VERBOSE(("1: connecting.\n"));
- MPI_Comm_connect(port1, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm1);
-
- MPI_Recv(&data, 1, MPI_INT, 0, 0, comm1, &status);
- if (data != 1)
- {
- printf("Received %d from root when expecting 1\n", data);
- fflush(stdout);
- num_errors++;
- }
-
- IF_VERBOSE(("1: disconnecting.\n"));
- MPI_Comm_disconnect(&comm1);
+ else if (rank == 1) {
+ IF_VERBOSE(("1: receiving port.\n"));
+ MPI_Recv(port1, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &status);
+
+ IF_VERBOSE(("1: received port1: <%s>\n", port1));
+ IF_VERBOSE(("1: connecting.\n"));
+ MPI_Comm_connect(port1, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm1);
+
+ MPI_Recv(&data, 1, MPI_INT, 0, 0, comm1, &status);
+ if (data != 1) {
+ printf("Received %d from root when expecting 1\n", data);
+ fflush(stdout);
+ num_errors++;
+ }
+
+ IF_VERBOSE(("1: disconnecting.\n"));
+ MPI_Comm_disconnect(&comm1);
}
- else if (rank == 2)
- {
- IF_VERBOSE(("2: receiving port.\n"));
- MPI_Recv(port2, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &status);
-
- IF_VERBOSE(("2: received port2: <%s>\n", port2));
- /* make sure process 1 has time to do the connect before this process
- attempts to connect */
- MTestSleep(2);
- IF_VERBOSE(("2: connecting.\n"));
- MPI_Comm_connect(port2, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm2);
-
- MPI_Recv(&data, 1, MPI_INT, 0, 0, comm2, &status);
- if (data != 2)
- {
- printf("Received %d from root when expecting 2\n", data);
- fflush(stdout);
- num_errors++;
- }
-
- IF_VERBOSE(("2: disconnecting.\n"));
- MPI_Comm_disconnect(&comm2);
+ else if (rank == 2) {
+ IF_VERBOSE(("2: receiving port.\n"));
+ MPI_Recv(port2, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &status);
+
+ IF_VERBOSE(("2: received port2: <%s>\n", port2));
+ /* make sure process 1 has time to do the connect before this process
+ * attempts to connect */
+ MTestSleep(2);
+ IF_VERBOSE(("2: connecting.\n"));
+ MPI_Comm_connect(port2, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm2);
+
+ MPI_Recv(&data, 1, MPI_INT, 0, 0, comm2, &status);
+ if (data != 2) {
+ printf("Received %d from root when expecting 2\n", data);
+ fflush(stdout);
+ num_errors++;
+ }
+
+ IF_VERBOSE(("2: disconnecting.\n"));
+ MPI_Comm_disconnect(&comm2);
}
- else if (rank == 3)
- {
- IF_VERBOSE(("3: receiving port.\n"));
- MPI_Recv(port3, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &status);
-
- IF_VERBOSE(("2: received port2: <%s>\n", port2));
- /* make sure process 1 and 2 have time to do the connect before this
- process attempts to connect */
- MTestSleep(4);
- IF_VERBOSE(("3: connecting.\n"));
- MPI_Comm_connect(port3, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm3);
-
- MPI_Recv(&data, 1, MPI_INT, 0, 0, comm3, &status);
- if (data != 3)
- {
- printf("Received %d from root when expecting 3\n", data);
- fflush(stdout);
- num_errors++;
- }
-
- IF_VERBOSE(("3: disconnecting.\n"));
- MPI_Comm_disconnect(&comm3);
+ else if (rank == 3) {
+ IF_VERBOSE(("3: receiving port.\n"));
+ MPI_Recv(port3, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &status);
+
+ IF_VERBOSE(("2: received port2: <%s>\n", port2));
+ /* make sure process 1 and 2 have time to do the connect before this
+ * process attempts to connect */
+ MTestSleep(4);
+ IF_VERBOSE(("3: connecting.\n"));
+ MPI_Comm_connect(port3, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm3);
+
+ MPI_Recv(&data, 1, MPI_INT, 0, 0, comm3, &status);
+ if (data != 3) {
+ printf("Received %d from root when expecting 3\n", data);
+ fflush(stdout);
+ num_errors++;
+ }
+
+ IF_VERBOSE(("3: disconnecting.\n"));
+ MPI_Comm_disconnect(&comm3);
}
MPI_Barrier(MPI_COMM_WORLD);
MPI_Reduce(&num_errors, &total_num_errors, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
- if (rank == 0)
- {
- if (total_num_errors)
- {
- printf(" Found %d errors\n", total_num_errors);
- }
- else
- {
- printf(" No Errors\n");
- }
- fflush(stdout);
+ if (rank == 0) {
+ if (total_num_errors) {
+ printf(" Found %d errors\n", total_num_errors);
+ }
+ else {
+ printf(" No Errors\n");
+ }
+ fflush(stdout);
}
MPI_Finalize();
return total_num_errors;
diff --git a/test/mpi/spawn/namepub.c b/test/mpi/spawn/namepub.c
index 5bf1c69..4a809e8 100644
--- a/test/mpi/spawn/namepub.c
+++ b/test/mpi/spawn/namepub.c
@@ -9,7 +9,7 @@
#include <string.h>
#include "mpitest.h"
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
char port_name[MPI_MAX_PORT_NAME], port_name_out[MPI_MAX_PORT_NAME];
@@ -19,82 +19,79 @@ int main( int argc, char *argv[] )
int msglen;
int rank;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
/* Note that according to the MPI standard, port_name must
- have been created by MPI_Open_port. For current testing
- purposes, we'll use a fake name. This test should eventually use
- a valid name from Open_port */
-
- strcpy( port_name, "otherhost:122" );
- strcpy( serv_name, "MyTest" );
-
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
-
- if (rank == 0)
- {
- merr = MPI_Publish_name( serv_name, MPI_INFO_NULL, port_name );
- if (merr) {
- errs++;
- MPI_Error_string( merr, errmsg, &msglen );
- printf( "Error in Publish_name: \"%s\"\n", errmsg );
- }
-
- MPI_Barrier(MPI_COMM_WORLD);
- MPI_Barrier(MPI_COMM_WORLD);
-
- merr = MPI_Unpublish_name( serv_name, MPI_INFO_NULL, port_name );
- if (merr) {
- errs++;
- MPI_Error_string( merr, errmsg, &msglen );
- printf( "Error in Unpublish name: \"%s\"\n", errmsg );
- }
+ * have been created by MPI_Open_port. For current testing
+ * purposes, we'll use a fake name. This test should eventually use
+ * a valid name from Open_port */
+
+ strcpy(port_name, "otherhost:122");
+ strcpy(serv_name, "MyTest");
+
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+
+ if (rank == 0) {
+ merr = MPI_Publish_name(serv_name, MPI_INFO_NULL, port_name);
+ if (merr) {
+ errs++;
+ MPI_Error_string(merr, errmsg, &msglen);
+ printf("Error in Publish_name: \"%s\"\n", errmsg);
+ }
+
+ MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ merr = MPI_Unpublish_name(serv_name, MPI_INFO_NULL, port_name);
+ if (merr) {
+ errs++;
+ MPI_Error_string(merr, errmsg, &msglen);
+ printf("Error in Unpublish name: \"%s\"\n", errmsg);
+ }
}
- else
- {
- MPI_Barrier(MPI_COMM_WORLD);
-
- merr = MPI_Lookup_name( serv_name, MPI_INFO_NULL, port_name_out );
- if (merr) {
- errs++;
- MPI_Error_string( merr, errmsg, &msglen );
- printf( "Error in Lookup name: \"%s\"\n", errmsg );
- }
- else {
- if (strcmp( port_name, port_name_out )) {
- errs++;
- printf( "Lookup name returned the wrong value (%s)\n",
- port_name_out );
- }
- }
-
- MPI_Barrier(MPI_COMM_WORLD);
+ else {
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ merr = MPI_Lookup_name(serv_name, MPI_INFO_NULL, port_name_out);
+ if (merr) {
+ errs++;
+ MPI_Error_string(merr, errmsg, &msglen);
+ printf("Error in Lookup name: \"%s\"\n", errmsg);
+ }
+ else {
+ if (strcmp(port_name, port_name_out)) {
+ errs++;
+ printf("Lookup name returned the wrong value (%s)\n", port_name_out);
+ }
+ }
+
+ MPI_Barrier(MPI_COMM_WORLD);
}
MPI_Barrier(MPI_COMM_WORLD);
-
- merr = MPI_Lookup_name( serv_name, MPI_INFO_NULL, port_name_out );
+
+ merr = MPI_Lookup_name(serv_name, MPI_INFO_NULL, port_name_out);
if (!merr) {
- errs++;
- printf( "Lookup name returned name after it was unpublished\n" );
+ errs++;
+ printf("Lookup name returned name after it was unpublished\n");
}
else {
- /* Must be class MPI_ERR_NAME */
- MPI_Error_class( merr, &mclass );
- if (mclass != MPI_ERR_NAME) {
- errs++;
- MPI_Error_string( merr, errmsg, &msglen );
- printf( "Lookup name returned the wrong error class (%d), msg: \"%s\"\n",
- mclass, errmsg );
- }
+ /* Must be class MPI_ERR_NAME */
+ MPI_Error_class(merr, &mclass);
+ if (mclass != MPI_ERR_NAME) {
+ errs++;
+ MPI_Error_string(merr, errmsg, &msglen);
+ printf("Lookup name returned the wrong error class (%d), msg: \"%s\"\n",
+ mclass, errmsg);
+ }
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/spawn/pgroup_connect_test.c b/test/mpi/spawn/pgroup_connect_test.c
index 51d7427..63bc719 100644
--- a/test/mpi/spawn/pgroup_connect_test.c
+++ b/test/mpi/spawn/pgroup_connect_test.c
@@ -23,132 +23,134 @@
const int verbose = 0;
-void PGroup_create(int count, int members[], MPI_Comm *group);
-void PGroup_create(int count, int members[], MPI_Comm *group)
+void PGroup_create(int count, int members[], MPI_Comm * group);
+void PGroup_create(int count, int members[], MPI_Comm * group)
{
- int i, me, nproc, is_member;
- char *port;
- MPI_Comm pgroup;
-
- MPI_Comm_rank(MPI_COMM_WORLD, &me);
- MPI_Comm_size(MPI_COMM_WORLD, &nproc);
-
- if (count == 0) {
- *group = MPI_COMM_NULL;
- return;
- }
- else if (count == 1 && members[0] == me) {
- *group = MPI_COMM_SELF;
- return;
- }
-
- for (i = 0, is_member = 0; i < count; i++) {
- if (members[i] == me) {
- is_member = 1;
- break;
+ int i, me, nproc, is_member;
+ char *port;
+ MPI_Comm pgroup;
+
+ MPI_Comm_rank(MPI_COMM_WORLD, &me);
+ MPI_Comm_size(MPI_COMM_WORLD, &nproc);
+
+ if (count == 0) {
+ *group = MPI_COMM_NULL;
+ return;
+ }
+ else if (count == 1 && members[0] == me) {
+ *group = MPI_COMM_SELF;
+ return;
}
- }
- if (!is_member) {
- *group = MPI_COMM_NULL;
- return;
- }
+ for (i = 0, is_member = 0; i < count; i++) {
+ if (members[i] == me) {
+ is_member = 1;
+ break;
+ }
+ }
- port = malloc(MPI_MAX_PORT_NAME);
+ if (!is_member) {
+ *group = MPI_COMM_NULL;
+ return;
+ }
- /* NOTE: Assume members list is identical and sorted on all processes */
+ port = malloc(MPI_MAX_PORT_NAME);
- /* I am the leader */
- if (me == members[0]) {
- MPI_Comm pgroup_new;
+ /* NOTE: Assume members list is identical and sorted on all processes */
- pgroup = MPI_COMM_SELF;
+ /* I am the leader */
+ if (me == members[0]) {
+ MPI_Comm pgroup_new;
- MPI_Open_port(MPI_INFO_NULL, port);
+ pgroup = MPI_COMM_SELF;
- for (i = 1; i < count; i++) {
- MPI_Comm pgroup_old = pgroup;
+ MPI_Open_port(MPI_INFO_NULL, port);
- MPI_Send(port, MPI_MAX_PORT_NAME, MPI_CHAR, members[i], 0, MPI_COMM_WORLD);
- MPI_Comm_accept(port, MPI_INFO_NULL, 0, pgroup, &pgroup_new);
- MPI_Intercomm_merge(pgroup_new, 0 /* LOW */, &pgroup);
+ for (i = 1; i < count; i++) {
+ MPI_Comm pgroup_old = pgroup;
- MPI_Comm_free(&pgroup_new);
- if (pgroup_old != MPI_COMM_SELF)
- MPI_Comm_free(&pgroup_old);
+ MPI_Send(port, MPI_MAX_PORT_NAME, MPI_CHAR, members[i], 0, MPI_COMM_WORLD);
+ MPI_Comm_accept(port, MPI_INFO_NULL, 0, pgroup, &pgroup_new);
+ MPI_Intercomm_merge(pgroup_new, 0 /* LOW */ , &pgroup);
+
+ MPI_Comm_free(&pgroup_new);
+ if (pgroup_old != MPI_COMM_SELF)
+ MPI_Comm_free(&pgroup_old);
+ }
+
+ MPI_Close_port(port);
}
- MPI_Close_port(port);
- }
-
- /* I am not the leader */
- else {
- int merged=0;
- MPI_Comm pgroup_new;
-
- for (i = 0; i < count; i ++) {
- if (members[i] == me) {
- MPI_Recv(port, MPI_MAX_PORT_NAME, MPI_CHAR, members[0], 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
- MPI_Comm_connect(port, MPI_INFO_NULL, 0, MPI_COMM_SELF, &pgroup_new);
- MPI_Intercomm_merge(pgroup_new, 1 /* HIGH */, &pgroup);
- MPI_Comm_free(&pgroup_new);
- merged = 1;
- }
- else if (merged) {
- MPI_Comm pgroup_old = pgroup;
-
- MPI_Comm_connect(port, MPI_INFO_NULL, 0, pgroup, &pgroup_new);
- MPI_Intercomm_merge(pgroup_new, 0 /* HIGH */, &pgroup);
-
- MPI_Comm_free(&pgroup_new);
- MPI_Comm_free(&pgroup_old);
- }
- /* else => !merged */
+ /* I am not the leader */
+ else {
+ int merged = 0;
+ MPI_Comm pgroup_new;
+
+ for (i = 0; i < count; i++) {
+ if (members[i] == me) {
+ MPI_Recv(port, MPI_MAX_PORT_NAME, MPI_CHAR, members[0], 0, MPI_COMM_WORLD,
+ MPI_STATUS_IGNORE);
+ MPI_Comm_connect(port, MPI_INFO_NULL, 0, MPI_COMM_SELF, &pgroup_new);
+ MPI_Intercomm_merge(pgroup_new, 1 /* HIGH */ , &pgroup);
+ MPI_Comm_free(&pgroup_new);
+ merged = 1;
+ }
+ else if (merged) {
+ MPI_Comm pgroup_old = pgroup;
+
+ MPI_Comm_connect(port, MPI_INFO_NULL, 0, pgroup, &pgroup_new);
+ MPI_Intercomm_merge(pgroup_new, 0 /* HIGH */ , &pgroup);
+
+ MPI_Comm_free(&pgroup_new);
+ MPI_Comm_free(&pgroup_old);
+ }
+ /* else => !merged */
+ }
}
- }
- free(port);
- *group = pgroup;
+ free(port);
+ *group = pgroup;
}
-int main(int argc, char **argv) {
- int me, nproc, i;
- int gsize, *glist;
- MPI_Comm group;
+int main(int argc, char **argv)
+{
+ int me, nproc, i;
+ int gsize, *glist;
+ MPI_Comm group;
- MPI_Init(&argc, &argv);
+ MPI_Init(&argc, &argv);
- MPI_Comm_rank(MPI_COMM_WORLD, &me);
- MPI_Comm_size(MPI_COMM_WORLD, &nproc);
+ MPI_Comm_rank(MPI_COMM_WORLD, &me);
+ MPI_Comm_size(MPI_COMM_WORLD, &nproc);
- gsize = nproc/2 + (nproc % 2);
- glist = malloc(gsize*sizeof(int));
+ gsize = nproc / 2 + (nproc % 2);
+ glist = malloc(gsize * sizeof(int));
- for (i = 0; i < nproc; i += 2)
- glist[i/2] = i;
+ for (i = 0; i < nproc; i += 2)
+ glist[i / 2] = i;
- if (me % 2 == 0) {
- int gme, gnproc;
+ if (me % 2 == 0) {
+ int gme, gnproc;
- PGroup_create(gsize, glist, &group);
- MPI_Barrier(group);
+ PGroup_create(gsize, glist, &group);
+ MPI_Barrier(group);
- MPI_Comm_rank(group, &gme);
- MPI_Comm_size(group, &gnproc);
- if (verbose)
- printf("[%d] Group rank = %d, size = %d\n", me, gme, gnproc);
+ MPI_Comm_rank(group, &gme);
+ MPI_Comm_size(group, &gnproc);
+ if (verbose)
+ printf("[%d] Group rank = %d, size = %d\n", me, gme, gnproc);
- if (group != MPI_COMM_SELF)
- MPI_Comm_free(&group);
- }
+ if (group != MPI_COMM_SELF)
+ MPI_Comm_free(&group);
+ }
- free(glist);
+ free(glist);
- MPI_Finalize();
+ MPI_Finalize();
- if (me == 0)
- printf(" No Errors\n");
+ if (me == 0)
+ printf(" No Errors\n");
- return 0;
+ return 0;
}
diff --git a/test/mpi/spawn/pgroup_intercomm_test.c b/test/mpi/spawn/pgroup_intercomm_test.c
index c3c199e..13b9d0c 100644
--- a/test/mpi/spawn/pgroup_intercomm_test.c
+++ b/test/mpi/spawn/pgroup_intercomm_test.c
@@ -24,17 +24,18 @@
const int verbose = 0;
-void pgroup_create(int grp_size, int *pid_list, MPI_Comm *group_out);
-void pgroup_free(MPI_Comm *group);
+void pgroup_create(int grp_size, int *pid_list, MPI_Comm * group_out);
+void pgroup_free(MPI_Comm * group);
/** Free the group
*/
-void pgroup_free(MPI_Comm *group) {
- /* Note: It's ok to compare predefined handles */
- if (*group == MPI_COMM_NULL || *group == MPI_COMM_SELF)
- return;
+void pgroup_free(MPI_Comm * group)
+{
+ /* Note: It's ok to compare predefined handles */
+ if (*group == MPI_COMM_NULL || *group == MPI_COMM_SELF)
+ return;
- MPI_Comm_free((MPI_Comm*) group);
+ MPI_Comm_free((MPI_Comm *) group);
}
@@ -42,105 +43,112 @@ void pgroup_free(MPI_Comm *group) {
*
* NOTE: pid_list list must be identical and sorted on all processes
*/
-void pgroup_create(int grp_size, int *pid_list, MPI_Comm *group_out) {
- int i, grp_me, me, nproc, merge_size;
- MPI_Comm pgroup, inter_pgroup;
-
- MPI_Comm_rank(MPI_COMM_WORLD, &me);
- MPI_Comm_size(MPI_COMM_WORLD, &nproc);
-
- /* CASE: Group size 0 */
- if (grp_size == 0) {
- *group_out = MPI_COMM_NULL;
- return;
- }
-
- /* CASE: Group size 1 */
- else if (grp_size == 1 && pid_list[0] == me) {
- *group_out = MPI_COMM_SELF;
- return;
- }
-
- /* CHECK: If I'm not a member, return COMM_NULL */
- grp_me = -1;
- for (i = 0; i < grp_size; i++) {
- if (pid_list[i] == me) {
- grp_me = i;
- break;
+void pgroup_create(int grp_size, int *pid_list, MPI_Comm * group_out)
+{
+ int i, grp_me, me, nproc, merge_size;
+ MPI_Comm pgroup, inter_pgroup;
+
+ MPI_Comm_rank(MPI_COMM_WORLD, &me);
+ MPI_Comm_size(MPI_COMM_WORLD, &nproc);
+
+ /* CASE: Group size 0 */
+ if (grp_size == 0) {
+ *group_out = MPI_COMM_NULL;
+ return;
}
- }
- if (grp_me < 0) {
- *group_out = MPI_COMM_NULL;
- return;
- }
-
- pgroup = MPI_COMM_SELF;
-
- for (merge_size = 1; merge_size < grp_size; merge_size *= 2) {
- int gid = grp_me / merge_size;
- MPI_Comm pgroup_old = pgroup;
+ /* CASE: Group size 1 */
+ else if (grp_size == 1 && pid_list[0] == me) {
+ *group_out = MPI_COMM_SELF;
+ return;
+ }
- if (gid % 2 == 0) {
- /* Check if right partner doesn't exist */
- if ((gid+1)*merge_size >= grp_size)
- continue;
+ /* CHECK: If I'm not a member, return COMM_NULL */
+ grp_me = -1;
+ for (i = 0; i < grp_size; i++) {
+ if (pid_list[i] == me) {
+ grp_me = i;
+ break;
+ }
+ }
- MPI_Intercomm_create(pgroup, 0, MPI_COMM_WORLD, pid_list[(gid+1)*merge_size], INTERCOMM_TAG, &inter_pgroup);
- MPI_Intercomm_merge(inter_pgroup, 0 /* LOW */, &pgroup);
- } else {
- MPI_Intercomm_create(pgroup, 0, MPI_COMM_WORLD, pid_list[(gid-1)*merge_size], INTERCOMM_TAG, &inter_pgroup);
- MPI_Intercomm_merge(inter_pgroup, 1 /* HIGH */, &pgroup);
+ if (grp_me < 0) {
+ *group_out = MPI_COMM_NULL;
+ return;
}
- MPI_Comm_free(&inter_pgroup);
- if (pgroup_old != MPI_COMM_SELF) MPI_Comm_free(&pgroup_old);
- }
+ pgroup = MPI_COMM_SELF;
+
+ for (merge_size = 1; merge_size < grp_size; merge_size *= 2) {
+ int gid = grp_me / merge_size;
+ MPI_Comm pgroup_old = pgroup;
+
+ if (gid % 2 == 0) {
+ /* Check if right partner doesn't exist */
+ if ((gid + 1) * merge_size >= grp_size)
+ continue;
+
+ MPI_Intercomm_create(pgroup, 0, MPI_COMM_WORLD, pid_list[(gid + 1) * merge_size],
+ INTERCOMM_TAG, &inter_pgroup);
+ MPI_Intercomm_merge(inter_pgroup, 0 /* LOW */ , &pgroup);
+ }
+ else {
+ MPI_Intercomm_create(pgroup, 0, MPI_COMM_WORLD, pid_list[(gid - 1) * merge_size],
+ INTERCOMM_TAG, &inter_pgroup);
+ MPI_Intercomm_merge(inter_pgroup, 1 /* HIGH */ , &pgroup);
+ }
+
+ MPI_Comm_free(&inter_pgroup);
+ if (pgroup_old != MPI_COMM_SELF)
+ MPI_Comm_free(&pgroup_old);
+ }
- *group_out = pgroup;
+ *group_out = pgroup;
}
-int main(int argc, char **argv) {
- int me, nproc, i;
- int gsize, *glist;
- MPI_Comm group;
+int main(int argc, char **argv)
+{
+ int me, nproc, i;
+ int gsize, *glist;
+ MPI_Comm group;
- MPI_Init(&argc, &argv);
+ MPI_Init(&argc, &argv);
- MPI_Comm_rank(MPI_COMM_WORLD, &me);
- MPI_Comm_size(MPI_COMM_WORLD, &nproc);
+ MPI_Comm_rank(MPI_COMM_WORLD, &me);
+ MPI_Comm_size(MPI_COMM_WORLD, &nproc);
- gsize = nproc/2 + (nproc % 2);
- glist = malloc(gsize*sizeof(int));
+ gsize = nproc / 2 + (nproc % 2);
+ glist = malloc(gsize * sizeof(int));
- for (i = 0; i < nproc; i += 2)
- glist[i/2] = i;
+ for (i = 0; i < nproc; i += 2)
+ glist[i / 2] = i;
- MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Barrier(MPI_COMM_WORLD);
- if (me % 2 == 0) {
- int gme, gnproc;
- double t1, t2;
+ if (me % 2 == 0) {
+ int gme, gnproc;
+ double t1, t2;
- t1 = MPI_Wtime();
- pgroup_create(gsize, glist, &group);
- t2 = MPI_Wtime();
+ t1 = MPI_Wtime();
+ pgroup_create(gsize, glist, &group);
+ t2 = MPI_Wtime();
- MPI_Barrier(group);
+ MPI_Barrier(group);
- MPI_Comm_rank(group, &gme);
- MPI_Comm_size(group, &gnproc);
- if (verbose) printf("[%d] Group rank = %d, size = %d time = %f sec\n", me, gme, gnproc, t2-t1);
+ MPI_Comm_rank(group, &gme);
+ MPI_Comm_size(group, &gnproc);
+ if (verbose)
+ printf("[%d] Group rank = %d, size = %d time = %f sec\n", me, gme, gnproc, t2 - t1);
- pgroup_free(&group);
- }
+ pgroup_free(&group);
+ }
- free(glist);
+ free(glist);
- if (me == 0)
- printf(" No Errors\n");
+ if (me == 0)
+ printf(" No Errors\n");
- MPI_Finalize();
- return 0;
+ MPI_Finalize();
+ return 0;
}
diff --git a/test/mpi/spawn/selfconacc.c b/test/mpi/spawn/selfconacc.c
index 2010482..85d4e5c 100644
--- a/test/mpi/spawn/selfconacc.c
+++ b/test/mpi/spawn/selfconacc.c
@@ -8,21 +8,20 @@
#include <stdlib.h>
#include <string.h>
-void check_error( int, const char * );
+void check_error(int, const char *);
void check_error(int error, const char *fcname)
{
char err_string[MPI_MAX_ERROR_STRING] = "";
int length;
- if (error != MPI_SUCCESS)
- {
- MPI_Error_string(error, err_string, &length);
- printf("%s failed: %s\n", fcname, err_string);
- fflush(stdout);
- MPI_Abort(MPI_COMM_WORLD, error);
+ if (error != MPI_SUCCESS) {
+ MPI_Error_string(error, err_string, &length);
+ printf("%s failed: %s\n", fcname, err_string);
+ fflush(stdout);
+ MPI_Abort(MPI_COMM_WORLD, error);
}
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int error;
int rank, size;
@@ -31,82 +30,116 @@ int main( int argc, char *argv[] )
MPI_Comm comm;
int verbose = 0;
- if (getenv("MPITEST_VERBOSE"))
- {
- verbose = 1;
+ if (getenv("MPITEST_VERBOSE")) {
+ verbose = 1;
}
- if (verbose) { printf("init.\n");fflush(stdout); }
+ if (verbose) {
+ printf("init.\n");
+ fflush(stdout);
+ }
error = MPI_Init(&argc, &argv);
check_error(error, "MPI_Init");
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
- MPI_Comm_set_errhandler( MPI_COMM_SELF, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+ MPI_Comm_set_errhandler(MPI_COMM_SELF, MPI_ERRORS_RETURN);
- if (verbose) { printf("size.\n");fflush(stdout); }
+ if (verbose) {
+ printf("size.\n");
+ fflush(stdout);
+ }
error = MPI_Comm_size(MPI_COMM_WORLD, &size);
check_error(error, "MPI_Comm_size");
- if (verbose) { printf("rank.\n");fflush(stdout); }
+ if (verbose) {
+ printf("rank.\n");
+ fflush(stdout);
+ }
error = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
check_error(error, "MPI_Comm_rank");
- if (size < 2)
- {
- printf("Two processes needed.\n");
- MPI_Finalize();
- return 0;
+ if (size < 2) {
+ printf("Two processes needed.\n");
+ MPI_Finalize();
+ return 0;
}
- if (rank == 0)
- {
- if (verbose) { printf("open_port.\n");fflush(stdout); }
- error = MPI_Open_port(MPI_INFO_NULL, port);
- check_error(error, "MPI_Open_port");
-
- if (verbose) { printf("0: opened port: <%s>\n", port);fflush(stdout); }
- if (verbose) { printf("send.\n");fflush(stdout); }
- error = MPI_Send(port, MPI_MAX_PORT_NAME, MPI_CHAR, 1, 0, MPI_COMM_WORLD);
- check_error(error, "MPI_Send");
-
- if (verbose) { printf("accept.\n");fflush(stdout); }
- error = MPI_Comm_accept(port, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm);
- check_error(error, "MPI_Comm_accept");
-
- if (verbose) { printf("close_port.\n");fflush(stdout); }
- error = MPI_Close_port(port);
- check_error(error, "MPI_Close_port");
-
- if (verbose) { printf("disconnect.\n");fflush(stdout); }
- error = MPI_Comm_disconnect(&comm);
- check_error(error, "MPI_Comm_disconnect");
+ if (rank == 0) {
+ if (verbose) {
+ printf("open_port.\n");
+ fflush(stdout);
+ }
+ error = MPI_Open_port(MPI_INFO_NULL, port);
+ check_error(error, "MPI_Open_port");
+
+ if (verbose) {
+ printf("0: opened port: <%s>\n", port);
+ fflush(stdout);
+ }
+ if (verbose) {
+ printf("send.\n");
+ fflush(stdout);
+ }
+ error = MPI_Send(port, MPI_MAX_PORT_NAME, MPI_CHAR, 1, 0, MPI_COMM_WORLD);
+ check_error(error, "MPI_Send");
+
+ if (verbose) {
+ printf("accept.\n");
+ fflush(stdout);
+ }
+ error = MPI_Comm_accept(port, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm);
+ check_error(error, "MPI_Comm_accept");
+
+ if (verbose) {
+ printf("close_port.\n");
+ fflush(stdout);
+ }
+ error = MPI_Close_port(port);
+ check_error(error, "MPI_Close_port");
+
+ if (verbose) {
+ printf("disconnect.\n");
+ fflush(stdout);
+ }
+ error = MPI_Comm_disconnect(&comm);
+ check_error(error, "MPI_Comm_disconnect");
}
- else if (rank == 1)
- {
- if (verbose) { printf("recv.\n");fflush(stdout); }
- error = MPI_Recv(port, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &status);
- check_error(error, "MPI_Recv");
-
- if (verbose) { printf("1: received port: <%s>\n", port);fflush(stdout); }
- if (verbose) { printf("connect.\n");fflush(stdout); }
- error = MPI_Comm_connect(port, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm);
- check_error(error, "MPI_Comm_connect");
-
- MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN );
-
- if (verbose) { printf("disconnect.\n");fflush(stdout); }
- error = MPI_Comm_disconnect(&comm);
- check_error(error, "MPI_Comm_disconnect");
+ else if (rank == 1) {
+ if (verbose) {
+ printf("recv.\n");
+ fflush(stdout);
+ }
+ error = MPI_Recv(port, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &status);
+ check_error(error, "MPI_Recv");
+
+ if (verbose) {
+ printf("1: received port: <%s>\n", port);
+ fflush(stdout);
+ }
+ if (verbose) {
+ printf("connect.\n");
+ fflush(stdout);
+ }
+ error = MPI_Comm_connect(port, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm);
+ check_error(error, "MPI_Comm_connect");
+
+ MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN);
+
+ if (verbose) {
+ printf("disconnect.\n");
+ fflush(stdout);
+ }
+ error = MPI_Comm_disconnect(&comm);
+ check_error(error, "MPI_Comm_disconnect");
}
error = MPI_Barrier(MPI_COMM_WORLD);
check_error(error, "MPI_Barrier");
- if (rank == 0)
- {
- printf(" No Errors\n");
+ if (rank == 0) {
+ printf(" No Errors\n");
}
MPI_Finalize();
return 0;
diff --git a/test/mpi/spawn/spaconacc.c b/test/mpi/spawn/spaconacc.c
index 8fe6078..1f252f3 100644
--- a/test/mpi/spawn/spaconacc.c
+++ b/test/mpi/spawn/spaconacc.c
@@ -16,12 +16,11 @@ void check_error(int error, const char *fcname)
{
char err_string[MPI_MAX_ERROR_STRING] = "";
int length;
- if (error != MPI_SUCCESS)
- {
- MPI_Error_string(error, err_string, &length);
- printf("%s failed: %s\n", fcname, err_string);
- fflush(stdout);
- MPI_Abort(MPI_COMM_WORLD, error);
+ if (error != MPI_SUCCESS) {
+ MPI_Error_string(error, err_string, &length);
+ printf("%s failed: %s\n", fcname, err_string);
+ fflush(stdout);
+ MPI_Abort(MPI_COMM_WORLD, error);
}
}
@@ -29,8 +28,8 @@ int main(int argc, char *argv[])
{
int error;
int rank, size;
- char *argv1[2] = { (char*)"connector", NULL };
- char *argv2[2] = { (char*)"acceptor", NULL };
+ char *argv1[2] = { (char *) "connector", NULL };
+ char *argv2[2] = { (char *) "acceptor", NULL };
MPI_Comm comm_connector, comm_acceptor, comm_parent, comm;
char port[MPI_MAX_PORT_NAME];
MPI_Status status;
@@ -38,9 +37,8 @@ int main(int argc, char *argv[])
int verbose = 0;
int can_spawn, errs = 0;
- if (getenv("MPITEST_VERBOSE"))
- {
- verbose = 1;
+ if (getenv("MPITEST_VERBOSE")) {
+ verbose = 1;
}
IF_VERBOSE(("init.\n"));
@@ -50,15 +48,16 @@ int main(int argc, char *argv[])
errs += MTestSpawnPossible(&can_spawn);
if (!can_spawn) {
if (errs)
- printf( " Found %d errors\n", errs );
+ printf(" Found %d errors\n", errs);
else
- printf( " No Errors\n" );
- fflush( stdout );
- } else {
+ printf(" No Errors\n");
+ fflush(stdout);
+ }
+ else {
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
- MPI_Comm_set_errhandler( MPI_COMM_SELF, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+ MPI_Comm_set_errhandler(MPI_COMM_SELF, MPI_ERRORS_RETURN);
IF_VERBOSE(("size.\n"));
error = MPI_Comm_size(MPI_COMM_WORLD, &size);
@@ -68,44 +67,39 @@ int main(int argc, char *argv[])
error = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
check_error(error, "MPI_Comm_rank");
- if (argc == 1)
- {
+ if (argc == 1) {
/* Make sure that the current directory is in the path.
- Not all implementations may honor or understand this, but
- it is highly recommended as it gives users a clean way
- to specify the location of the executable without
- specifying a particular directory format (e.g., this
- should work with both Windows and Unix implementations) */
- error = MPI_Info_create( &spawn_path );
- check_error( error, "MPI_Info_create" );
- error = MPI_Info_set( spawn_path, (char*)"path", (char*)"." );
- check_error( error, "MPI_Info_set" );
+ * Not all implementations may honor or understand this, but
+ * it is highly recommended as it gives users a clean way
+ * to specify the location of the executable without
+ * specifying a particular directory format (e.g., this
+ * should work with both Windows and Unix implementations) */
+ error = MPI_Info_create(&spawn_path);
+ check_error(error, "MPI_Info_create");
+ error = MPI_Info_set(spawn_path, (char *) "path", (char *) ".");
+ check_error(error, "MPI_Info_set");
IF_VERBOSE(("spawn connector.\n"));
- error = MPI_Comm_spawn((char*)"spaconacc", argv1, 1, spawn_path, 0,
- MPI_COMM_SELF, &comm_connector,
- MPI_ERRCODES_IGNORE);
+ error = MPI_Comm_spawn((char *) "spaconacc", argv1, 1, spawn_path, 0,
+ MPI_COMM_SELF, &comm_connector, MPI_ERRCODES_IGNORE);
check_error(error, "MPI_Comm_spawn");
IF_VERBOSE(("spawn acceptor.\n"));
- error = MPI_Comm_spawn((char*)"spaconacc", argv2, 1, spawn_path, 0,
- MPI_COMM_SELF, &comm_acceptor,
- MPI_ERRCODES_IGNORE);
+ error = MPI_Comm_spawn((char *) "spaconacc", argv2, 1, spawn_path, 0,
+ MPI_COMM_SELF, &comm_acceptor, MPI_ERRCODES_IGNORE);
check_error(error, "MPI_Comm_spawn");
- error = MPI_Info_free( &spawn_path );
- check_error( error, "MPI_Info_free" );
+ error = MPI_Info_free(&spawn_path);
+ check_error(error, "MPI_Info_free");
- MPI_Comm_set_errhandler( comm_connector, MPI_ERRORS_RETURN );
- MPI_Comm_set_errhandler( comm_acceptor, MPI_ERRORS_RETURN );
+ MPI_Comm_set_errhandler(comm_connector, MPI_ERRORS_RETURN);
+ MPI_Comm_set_errhandler(comm_acceptor, MPI_ERRORS_RETURN);
IF_VERBOSE(("recv port.\n"));
- error = MPI_Recv(port, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0,
- comm_acceptor, &status);
+ error = MPI_Recv(port, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0, comm_acceptor, &status);
check_error(error, "MPI_Recv");
IF_VERBOSE(("send port.\n"));
- error = MPI_Send(port, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0,
- comm_connector);
+ error = MPI_Send(port, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0, comm_connector);
check_error(error, "MPI_Send");
IF_VERBOSE(("barrier acceptor.\n"));
@@ -123,21 +117,20 @@ int main(int argc, char *argv[])
printf(" No Errors\n");
}
- else if ((argc == 2) && (strcmp(argv[1], "acceptor") == 0))
- {
+ else if ((argc == 2) && (strcmp(argv[1], "acceptor") == 0)) {
IF_VERBOSE(("get_parent.\n"));
error = MPI_Comm_get_parent(&comm_parent);
check_error(error, "MPI_Comm_get_parent");
- if (comm_parent == MPI_COMM_NULL)
- {
- printf("acceptor's parent is NULL.\n");fflush(stdout);
+ if (comm_parent == MPI_COMM_NULL) {
+ printf("acceptor's parent is NULL.\n");
+ fflush(stdout);
MPI_Abort(MPI_COMM_WORLD, -1);
}
IF_VERBOSE(("open_port.\n"));
error = MPI_Open_port(MPI_INFO_NULL, port);
check_error(error, "MPI_Open_port");
- MPI_Comm_set_errhandler( comm_parent, MPI_ERRORS_RETURN );
+ MPI_Comm_set_errhandler(comm_parent, MPI_ERRORS_RETURN);
IF_VERBOSE(("0: opened port: <%s>\n", port));
IF_VERBOSE(("send.\n"));
@@ -160,23 +153,21 @@ int main(int argc, char *argv[])
error = MPI_Barrier(comm_parent);
check_error(error, "MPI_Barrier");
- MPI_Comm_free( &comm_parent );
+ MPI_Comm_free(&comm_parent);
}
- else if ((argc == 2) && (strcmp(argv[1], "connector") == 0))
- {
+ else if ((argc == 2) && (strcmp(argv[1], "connector") == 0)) {
IF_VERBOSE(("get_parent.\n"));
error = MPI_Comm_get_parent(&comm_parent);
check_error(error, "MPI_Comm_get_parent");
- if (comm_parent == MPI_COMM_NULL)
- {
- printf("acceptor's parent is NULL.\n");fflush(stdout);
+ if (comm_parent == MPI_COMM_NULL) {
+ printf("acceptor's parent is NULL.\n");
+ fflush(stdout);
MPI_Abort(MPI_COMM_WORLD, -1);
}
- MPI_Comm_set_errhandler( comm_parent, MPI_ERRORS_RETURN );
+ MPI_Comm_set_errhandler(comm_parent, MPI_ERRORS_RETURN);
IF_VERBOSE(("recv.\n"));
- error = MPI_Recv(port, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0,
- comm_parent, &status);
+ error = MPI_Recv(port, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0, comm_parent, &status);
check_error(error, "MPI_Recv");
IF_VERBOSE(("1: received port: <%s>\n", port));
@@ -184,7 +175,7 @@ int main(int argc, char *argv[])
error = MPI_Comm_connect(port, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm);
check_error(error, "MPI_Comm_connect");
- MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN );
+ MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN);
IF_VERBOSE(("disconnect.\n"));
error = MPI_Comm_disconnect(&comm);
check_error(error, "MPI_Comm_disconnect");
@@ -193,15 +184,14 @@ int main(int argc, char *argv[])
error = MPI_Barrier(comm_parent);
check_error(error, "MPI_Barrier");
- MPI_Comm_free( &comm_parent );
+ MPI_Comm_free(&comm_parent);
}
- else
- {
- printf("invalid command line.\n");fflush(stdout);
+ else {
+ printf("invalid command line.\n");
+ fflush(stdout);
{
int i;
- for (i=0; i<argc; i++)
- {
+ for (i = 0; i < argc; i++) {
printf("argv[%d] = <%s>\n", i, argv[i]);
}
}
diff --git a/test/mpi/spawn/spaconacc2.c b/test/mpi/spawn/spaconacc2.c
index d084c22..dad8697 100644
--- a/test/mpi/spawn/spaconacc2.c
+++ b/test/mpi/spawn/spaconacc2.c
@@ -10,9 +10,9 @@
#include "mpitest.h"
/* Note: In this program, the return codes from the MPI routines are checked.
- Since the error handlers for the communicators are not set to
+ Since the error handlers for the communicators are not set to
MPI_ERRORS_RETURN, any error should cause an abort rather than a return.
- The test on the return value is an extra safety check; note that a
+ The test on the return value is an extra safety check; note that a
return value of other than MPI_SUCCESS in these routines indicates an
error in the error handling by the MPI implementation */
@@ -23,12 +23,11 @@ void check_error(int error, const char *fcname)
{
char err_string[MPI_MAX_ERROR_STRING] = "";
int length;
- if (error != MPI_SUCCESS)
- {
- MPI_Error_string(error, err_string, &length);
- printf("%s failed: %s\n", fcname, err_string);
- fflush(stdout);
- MPI_Abort(MPI_COMM_WORLD, error);
+ if (error != MPI_SUCCESS) {
+ MPI_Error_string(error, err_string, &length);
+ printf("%s failed: %s\n", fcname, err_string);
+ fflush(stdout);
+ MPI_Abort(MPI_COMM_WORLD, error);
}
}
@@ -36,8 +35,8 @@ int main(int argc, char *argv[])
{
int error;
int rank, size, i;
- char *argv1[2] = { (char*)"connector", NULL };
- char *argv2[2] = { (char*)"acceptor", NULL };
+ char *argv1[2] = { (char *) "connector", NULL };
+ char *argv2[2] = { (char *) "acceptor", NULL };
MPI_Comm comm_connector, comm_acceptor, comm_parent, comm;
char port[MPI_MAX_PORT_NAME];
MPI_Status status;
@@ -45,9 +44,8 @@ int main(int argc, char *argv[])
int verbose = 0;
int can_spawn, errs = 0;
- if (getenv("MPITEST_VERBOSE"))
- {
- verbose = 1;
+ if (getenv("MPITEST_VERBOSE")) {
+ verbose = 1;
}
IF_VERBOSE(("init.\n"));
@@ -57,11 +55,12 @@ int main(int argc, char *argv[])
errs += MTestSpawnPossible(&can_spawn);
if (!can_spawn) {
if (errs)
- printf( " Found %d errors\n", errs );
+ printf(" Found %d errors\n", errs);
else
- printf( " No Errors\n" );
- fflush( stdout );
- } else {
+ printf(" No Errors\n");
+ fflush(stdout);
+ }
+ else {
IF_VERBOSE(("size.\n"));
error = MPI_Comm_size(MPI_COMM_WORLD, &size);
check_error(error, "MPI_Comm_size");
@@ -70,38 +69,33 @@ int main(int argc, char *argv[])
error = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
check_error(error, "MPI_Comm_rank");
- if (argc == 1)
- {
+ if (argc == 1) {
/* Make sure that the current directory is in the path.
- Not all implementations may honor or understand this, but
- it is highly recommended as it gives users a clean way
- to specify the location of the executable without
- specifying a particular directory format (e.g., this
- should work with both Windows and Unix implementations) */
- MPI_Info_create( &spawn_path );
- MPI_Info_set( spawn_path, (char*)"path", (char*)"." );
+ * Not all implementations may honor or understand this, but
+ * it is highly recommended as it gives users a clean way
+ * to specify the location of the executable without
+ * specifying a particular directory format (e.g., this
+ * should work with both Windows and Unix implementations) */
+ MPI_Info_create(&spawn_path);
+ MPI_Info_set(spawn_path, (char *) "path", (char *) ".");
IF_VERBOSE(("spawn connector.\n"));
- error = MPI_Comm_spawn((char*)"spaconacc2", argv1, 1, spawn_path, 0,
- MPI_COMM_SELF, &comm_connector,
- MPI_ERRCODES_IGNORE);
+ error = MPI_Comm_spawn((char *) "spaconacc2", argv1, 1, spawn_path, 0,
+ MPI_COMM_SELF, &comm_connector, MPI_ERRCODES_IGNORE);
check_error(error, "MPI_Comm_spawn");
IF_VERBOSE(("spawn acceptor.\n"));
- error = MPI_Comm_spawn((char*)"spaconacc2", argv2, 1, spawn_path, 0,
- MPI_COMM_SELF, &comm_acceptor,
- MPI_ERRCODES_IGNORE);
+ error = MPI_Comm_spawn((char *) "spaconacc2", argv2, 1, spawn_path, 0,
+ MPI_COMM_SELF, &comm_acceptor, MPI_ERRCODES_IGNORE);
check_error(error, "MPI_Comm_spawn");
- MPI_Info_free( &spawn_path );
+ MPI_Info_free(&spawn_path);
IF_VERBOSE(("recv port.\n"));
- error = MPI_Recv(port, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0,
- comm_acceptor, &status);
+ error = MPI_Recv(port, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0, comm_acceptor, &status);
check_error(error, "MPI_Recv");
IF_VERBOSE(("send port.\n"));
- error = MPI_Send(port, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0,
- comm_connector);
+ error = MPI_Send(port, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0, comm_connector);
check_error(error, "MPI_Send");
IF_VERBOSE(("barrier acceptor.\n"));
@@ -119,14 +113,13 @@ int main(int argc, char *argv[])
printf(" No Errors\n");
}
- else if ((argc == 2) && (strcmp(argv[1], "acceptor") == 0))
- {
+ else if ((argc == 2) && (strcmp(argv[1], "acceptor") == 0)) {
IF_VERBOSE(("get_parent.\n"));
error = MPI_Comm_get_parent(&comm_parent);
check_error(error, "MPI_Comm_get_parent");
- if (comm_parent == MPI_COMM_NULL)
- {
- printf("acceptor's parent is NULL.\n");fflush(stdout);
+ if (comm_parent == MPI_COMM_NULL) {
+ printf("acceptor's parent is NULL.\n");
+ fflush(stdout);
MPI_Abort(MPI_COMM_WORLD, -1);
}
IF_VERBOSE(("open_port.\n"));
@@ -160,22 +153,20 @@ int main(int argc, char *argv[])
error = MPI_Barrier(comm_parent);
check_error(error, "MPI_Barrier");
- MPI_Comm_free( &comm_parent );
+ MPI_Comm_free(&comm_parent);
}
- else if ((argc == 2) && (strcmp(argv[1], "connector") == 0))
- {
+ else if ((argc == 2) && (strcmp(argv[1], "connector") == 0)) {
IF_VERBOSE(("get_parent.\n"));
error = MPI_Comm_get_parent(&comm_parent);
check_error(error, "MPI_Comm_get_parent");
- if (comm_parent == MPI_COMM_NULL)
- {
- printf("acceptor's parent is NULL.\n");fflush(stdout);
+ if (comm_parent == MPI_COMM_NULL) {
+ printf("acceptor's parent is NULL.\n");
+ fflush(stdout);
MPI_Abort(MPI_COMM_WORLD, -1);
}
IF_VERBOSE(("recv.\n"));
- error = MPI_Recv(port, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0,
- comm_parent, &status);
+ error = MPI_Recv(port, MPI_MAX_PORT_NAME, MPI_CHAR, 0, 0, comm_parent, &status);
check_error(error, "MPI_Recv");
IF_VERBOSE(("1: received port: <%s>\n", port));
@@ -188,8 +179,7 @@ int main(int argc, char *argv[])
i = -1;
error = MPI_Recv(&i, 1, MPI_INT, 0, 0, comm, &status);
check_error(error, "MPI_Recv");
- if (i != 123)
- {
+ if (i != 123) {
printf("expected 123 but received %d\n", i);
fflush(stdout);
MPI_Abort(MPI_COMM_WORLD, 1);
@@ -203,15 +193,14 @@ int main(int argc, char *argv[])
error = MPI_Barrier(comm_parent);
check_error(error, "MPI_Barrier");
- MPI_Comm_free( &comm_parent );
+ MPI_Comm_free(&comm_parent);
}
- else
- {
- printf("invalid command line.\n");fflush(stdout);
+ else {
+ printf("invalid command line.\n");
+ fflush(stdout);
{
int ii;
- for (ii=0; ii<argc; ii++)
- {
+ for (ii = 0; ii < argc; ii++) {
printf("argv[%d] = <%s>\n", ii, argv[ii]);
}
}
diff --git a/test/mpi/spawn/spaiccreate.c b/test/mpi/spawn/spaiccreate.c
index 873f613..6e78eb7 100644
--- a/test/mpi/spawn/spaiccreate.c
+++ b/test/mpi/spawn/spaiccreate.c
@@ -13,36 +13,35 @@ static char MTEST_Descrip[] = "Use Spawn to create an intercomm, then create a n
*/
/*
- * This test ensures that spawned processes are able to communicate with
+ * This test ensures that spawned processes are able to communicate with
* processes that were not in the communicator from which they were spawned.
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int wrank, wsize;
int np = 2;
int errcodes[2];
- MPI_Comm parentcomm, intercomm, intercomm2;
+ MPI_Comm parentcomm, intercomm, intercomm2;
int can_spawn;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
errs += MTestSpawnPossible(&can_spawn);
if (can_spawn) {
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
- MPI_Comm_size( MPI_COMM_WORLD, &wsize );
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
+ MPI_Comm_size(MPI_COMM_WORLD, &wsize);
- MPI_Comm_get_parent( &parentcomm );
+ MPI_Comm_get_parent(&parentcomm);
if (parentcomm == MPI_COMM_NULL) {
/* Create 2 more processes, from process 0 in the original
- comm world */
+ * comm world */
if (wrank == 0) {
- MPI_Comm_spawn( (char*)"./spaiccreate", MPI_ARGV_NULL, np,
- MPI_INFO_NULL, 0, MPI_COMM_SELF,
- &intercomm, errcodes );
+ MPI_Comm_spawn((char *) "./spaiccreate", MPI_ARGV_NULL, np,
+ MPI_INFO_NULL, 0, MPI_COMM_SELF, &intercomm, errcodes);
}
else {
intercomm = MPI_COMM_NULL;
@@ -52,49 +51,49 @@ int main( int argc, char *argv[] )
intercomm = parentcomm;
/* We now have a valid intercomm. Use it to create a NEW intercomm
- that includes all processes */
- MPI_Intercomm_create( MPI_COMM_WORLD, 0, intercomm, 0, 123, &intercomm2 );
+ * that includes all processes */
+ MPI_Intercomm_create(MPI_COMM_WORLD, 0, intercomm, 0, 123, &intercomm2);
/* Have the spawned processes send to rank 1 in the comm world of the
- parent */
+ * parent */
if (parentcomm == MPI_COMM_NULL) {
- MPI_Send( &wrank, 1, MPI_INT, 1, wrank, intercomm2 );
+ MPI_Send(&wrank, 1, MPI_INT, 1, wrank, intercomm2);
}
else {
if (wrank == 1) {
int i, rsize, rrank;
MPI_Status status;
- MPI_Comm_remote_size( intercomm2, &rsize );
- for (i=0; i<rsize; i++) {
- MPI_Recv( &rrank, 1, MPI_INT, i, i, intercomm2, &status );
+ MPI_Comm_remote_size(intercomm2, &rsize);
+ for (i = 0; i < rsize; i++) {
+ MPI_Recv(&rrank, 1, MPI_INT, i, i, intercomm2, &status);
if (rrank != i) {
errs++;
- printf( "Received %d from %d; expected %d\n",
- rrank, i, i );
+ printf("Received %d from %d; expected %d\n", rrank, i, i);
}
}
}
}
- /* printf( "%sAbout to barrier on intercomm2\n",
- (parentcomm == MPI_COMM_NULL) ? "<orig>" : "<spawned>" );
- fflush(stdout);*/
- MPI_Barrier( intercomm2 );
+ /* printf("%sAbout to barrier on intercomm2\n",
+ * (parentcomm == MPI_COMM_NULL) ? "<orig>" : "<spawned>");
+ * fflush(stdout); */
+ MPI_Barrier(intercomm2);
/* It isn't necessary to free the intercomms, but it should not hurt */
if (intercomm != MPI_COMM_NULL)
- MPI_Comm_free( &intercomm );
- MPI_Comm_free( &intercomm2 );
+ MPI_Comm_free(&intercomm);
+ MPI_Comm_free(&intercomm2);
/* Note that the MTest_Finalize get errs only over COMM_WORLD */
/* Note also that both the parent and child will generate "No Errors"
- if both call MTest_Finalize */
+ * if both call MTest_Finalize */
if (parentcomm == MPI_COMM_NULL) {
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
}
- } else {
- MTest_Finalize( errs );
+ }
+ else {
+ MTest_Finalize(errs);
}
MPI_Finalize();
diff --git a/test/mpi/spawn/spaiccreate2.c b/test/mpi/spawn/spaiccreate2.c
index 20ca764..4ed5043 100644
--- a/test/mpi/spawn/spaiccreate2.c
+++ b/test/mpi/spawn/spaiccreate2.c
@@ -19,73 +19,72 @@ static char MTEST_Descrip[] = "Use Spawn to create an intercomm, then create a n
* a different MPI_COMM_WORLD.
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int wrank, wsize, mrank, msize, inter_rank;
int np = 2;
int errcodes[2];
int rrank = -1;
- MPI_Comm parentcomm, intercomm, intercomm2, even_odd_comm, merged_world;
+ MPI_Comm parentcomm, intercomm, intercomm2, even_odd_comm, merged_world;
int can_spawn;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
errs += MTestSpawnPossible(&can_spawn);
if (can_spawn) {
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
- MPI_Comm_size( MPI_COMM_WORLD, &wsize );
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
+ MPI_Comm_size(MPI_COMM_WORLD, &wsize);
if (wsize != 2) {
- printf( "world size != 2, this test will not work correctly\n" );
+ printf("world size != 2, this test will not work correctly\n");
errs++;
}
- MPI_Comm_get_parent( &parentcomm );
+ MPI_Comm_get_parent(&parentcomm);
if (parentcomm == MPI_COMM_NULL) {
- MPI_Comm_spawn( (char*)"./spaiccreate2", MPI_ARGV_NULL, np,
- MPI_INFO_NULL, 0, MPI_COMM_WORLD,
- &intercomm, errcodes );
+ MPI_Comm_spawn((char *) "./spaiccreate2", MPI_ARGV_NULL, np,
+ MPI_INFO_NULL, 0, MPI_COMM_WORLD, &intercomm, errcodes);
}
else {
intercomm = parentcomm;
}
- MPI_Intercomm_merge( intercomm, (parentcomm == MPI_COMM_NULL ? 0 : 1), &merged_world );
- MPI_Comm_rank( merged_world, &mrank );
- MPI_Comm_size( merged_world, &msize );
+ MPI_Intercomm_merge(intercomm, (parentcomm == MPI_COMM_NULL ? 0 : 1), &merged_world);
+ MPI_Comm_rank(merged_world, &mrank);
+ MPI_Comm_size(merged_world, &msize);
- MPI_Comm_split( merged_world, mrank % 2, wrank, &even_odd_comm );
+ MPI_Comm_split(merged_world, mrank % 2, wrank, &even_odd_comm);
- MPI_Intercomm_create( even_odd_comm, 0, merged_world, (mrank + 1) % 2, 123, &intercomm2 );
- MPI_Comm_rank( intercomm2, &inter_rank );
+ MPI_Intercomm_create(even_odd_comm, 0, merged_world, (mrank + 1) % 2, 123, &intercomm2);
+ MPI_Comm_rank(intercomm2, &inter_rank);
/* odds receive from evens */
- MPI_Sendrecv( &inter_rank, 1, MPI_INT, inter_rank, 456,
- &rrank, 1, MPI_INT, inter_rank, 456, intercomm2, MPI_STATUS_IGNORE );
+ MPI_Sendrecv(&inter_rank, 1, MPI_INT, inter_rank, 456,
+ &rrank, 1, MPI_INT, inter_rank, 456, intercomm2, MPI_STATUS_IGNORE);
if (rrank != inter_rank) {
- printf( "Received %d from %d; expected %d\n",
- rrank, inter_rank, inter_rank );
+ printf("Received %d from %d; expected %d\n", rrank, inter_rank, inter_rank);
errs++;
}
- MPI_Barrier( intercomm2 );
+ MPI_Barrier(intercomm2);
- MPI_Comm_free( &intercomm );
- MPI_Comm_free( &intercomm2 );
- MPI_Comm_free( &merged_world );
- MPI_Comm_free( &even_odd_comm );
+ MPI_Comm_free(&intercomm);
+ MPI_Comm_free(&intercomm2);
+ MPI_Comm_free(&merged_world);
+ MPI_Comm_free(&even_odd_comm);
/* Note that the MTest_Finalize get errs only over COMM_WORLD */
/* Note also that both the parent and child will generate "No Errors"
- if both call MTest_Finalize */
+ * if both call MTest_Finalize */
if (parentcomm == MPI_COMM_NULL) {
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
}
- } else {
- MTest_Finalize( errs );
+ }
+ else {
+ MTest_Finalize(errs);
}
MPI_Finalize();
diff --git a/test/mpi/spawn/spawn1.c b/test/mpi/spawn/spawn1.c
index 864f763..f88fa6f 100644
--- a/test/mpi/spawn/spawn1.c
+++ b/test/mpi/spawn/spawn1.c
@@ -19,52 +19,51 @@
static char MTEST_Descrip[] = "A simple test of Comm_spawn";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int rank, size, rsize, i;
int np = 2;
int errcodes[2];
- MPI_Comm parentcomm, intercomm;
- MPI_Status status;
+ MPI_Comm parentcomm, intercomm;
+ MPI_Status status;
int can_spawn;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
errs += MTestSpawnPossible(&can_spawn);
if (can_spawn) {
- MPI_Comm_get_parent( &parentcomm );
+ MPI_Comm_get_parent(&parentcomm);
if (parentcomm == MPI_COMM_NULL) {
/* Create 2 more processes */
- MPI_Comm_spawn( (char*)"./spawn1", MPI_ARGV_NULL, np,
- MPI_INFO_NULL, 0, MPI_COMM_WORLD,
- &intercomm, errcodes );
+ MPI_Comm_spawn((char *) "./spawn1", MPI_ARGV_NULL, np,
+ MPI_INFO_NULL, 0, MPI_COMM_WORLD, &intercomm, errcodes);
}
else
intercomm = parentcomm;
/* We now have a valid intercomm */
- MPI_Comm_remote_size( intercomm, &rsize );
- MPI_Comm_size( intercomm, &size );
- MPI_Comm_rank( intercomm, &rank );
+ MPI_Comm_remote_size(intercomm, &rsize);
+ MPI_Comm_size(intercomm, &size);
+ MPI_Comm_rank(intercomm, &rank);
if (parentcomm == MPI_COMM_NULL) {
/* Master */
if (rsize != np) {
errs++;
- printf( "Did not create %d processes (got %d)\n", np, rsize );
+ printf("Did not create %d processes (got %d)\n", np, rsize);
}
if (rank == 0) {
- for (i=0; i<rsize; i++) {
- MPI_Send( &i, 1, MPI_INT, i, 0, intercomm );
+ for (i = 0; i < rsize; i++) {
+ MPI_Send(&i, 1, MPI_INT, i, 0, intercomm);
}
/* We could use intercomm reduce to get the errors from the
- children, but we'll use a simpler loop to make sure that
- we get valid data */
- for (i=0; i<rsize; i++) {
- MPI_Recv( &err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE );
+ * children, but we'll use a simpler loop to make sure that
+ * we get valid data */
+ for (i = 0; i < rsize; i++) {
+ MPI_Recv(&err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE);
errs += err;
}
}
@@ -76,31 +75,30 @@ int main( int argc, char *argv[] )
if (size != np) {
errs++;
- printf( "(Child) Did not create %d processes (got %d)\n",
- np, size );
+ printf("(Child) Did not create %d processes (got %d)\n", np, size);
}
/* Check the name of the parent */
cname[0] = 0;
- MPI_Comm_get_name( intercomm, cname, &rlen );
+ MPI_Comm_get_name(intercomm, cname, &rlen);
/* MPI-2 section 8.4 requires that the parent have this
- default name */
- if (strcmp( cname, "MPI_COMM_PARENT" ) != 0) {
+ * default name */
+ if (strcmp(cname, "MPI_COMM_PARENT") != 0) {
errs++;
- printf( "Name of parent is not correct\n" );
+ printf("Name of parent is not correct\n");
if (rlen > 0 && cname[0]) {
- printf( " Got %s but expected MPI_COMM_PARENT\n", cname );
+ printf(" Got %s but expected MPI_COMM_PARENT\n", cname);
}
else {
- printf( " Expected MPI_COMM_PARENT but no name set\n" );
+ printf(" Expected MPI_COMM_PARENT but no name set\n");
}
}
- MPI_Recv( &i, 1, MPI_INT, 0, 0, intercomm, &status );
+ MPI_Recv(&i, 1, MPI_INT, 0, 0, intercomm, &status);
if (i != rank) {
errs++;
- printf( "Unexpected rank on child %d (%d)\n", rank, i );
+ printf("Unexpected rank on child %d (%d)\n", rank, i);
}
/* Send the errs back to the master process */
- MPI_Ssend( &errs, 1, MPI_INT, 0, 1, intercomm );
+ MPI_Ssend(&errs, 1, MPI_INT, 0, 1, intercomm);
}
/* It isn't necessary to free the intercomm, but it should not hurt */
@@ -108,17 +106,18 @@ int main( int argc, char *argv[] )
* test, as a high-quality MPI implementation will be able to
* recover some resources that it should hold on to in the case
* of MPI_Comm_free */
- /* MPI_Comm_free( &intercomm ); */
- MPI_Comm_disconnect( &intercomm );
+ /* MPI_Comm_free(&intercomm); */
+ MPI_Comm_disconnect(&intercomm);
/* Note that the MTest_Finalize get errs only over COMM_WORLD */
/* Note also that both the parent and child will generate "No Errors"
- if both call MTest_Finalize */
+ * if both call MTest_Finalize */
if (parentcomm == MPI_COMM_NULL) {
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
}
- } else {
- MTest_Finalize( errs );
+ }
+ else {
+ MTest_Finalize(errs);
}
MPI_Finalize();
diff --git a/test/mpi/spawn/spawn2.c b/test/mpi/spawn/spawn2.c
index 2f310d3..aa84f56 100644
--- a/test/mpi/spawn/spawn2.c
+++ b/test/mpi/spawn/spawn2.c
@@ -14,62 +14,61 @@ static char MTEST_Descrip[] = "A simple test of Comm_spawn, called twice";
*/
/*
- * One bug report indicated that two calls to Spawn failed, even when
+ * One bug report indicated that two calls to Spawn failed, even when
* one succeeded. This test makes sure that an MPI program can make
* multiple calls to spawn.
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int rank, size, rsize, i;
int np = 2;
int errcodes[2];
- MPI_Comm parentcomm, intercomm, intercomm2;
- MPI_Status status;
+ MPI_Comm parentcomm, intercomm, intercomm2;
+ MPI_Status status;
int can_spawn;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
errs += MTestSpawnPossible(&can_spawn);
if (can_spawn) {
- MPI_Comm_get_parent( &parentcomm );
+ MPI_Comm_get_parent(&parentcomm);
if (parentcomm == MPI_COMM_NULL) {
/* Create 2 more processes */
/* This uses a Unix name for the program;
- Windows applications may need to use just spawn2 or
- spawn2.exe. We can't rely on using info to place . in the
- path, since info is not required to be followed. */
- MPI_Comm_spawn( (char*)"./spawn2", MPI_ARGV_NULL, np,
- MPI_INFO_NULL, 0, MPI_COMM_WORLD,
- &intercomm, errcodes );
+ * Windows applications may need to use just spawn2 or
+ * spawn2.exe. We can't rely on using info to place . in the
+ * path, since info is not required to be followed. */
+ MPI_Comm_spawn((char *) "./spawn2", MPI_ARGV_NULL, np,
+ MPI_INFO_NULL, 0, MPI_COMM_WORLD, &intercomm, errcodes);
}
else
intercomm = parentcomm;
/* We now have a valid intercomm */
- MPI_Comm_remote_size( intercomm, &rsize );
- MPI_Comm_size( intercomm, &size );
- MPI_Comm_rank( intercomm, &rank );
+ MPI_Comm_remote_size(intercomm, &rsize);
+ MPI_Comm_size(intercomm, &size);
+ MPI_Comm_rank(intercomm, &rank);
if (parentcomm == MPI_COMM_NULL) {
/* Master */
if (rsize != np) {
errs++;
- printf( "Did not create %d processes (got %d)\n", np, rsize );
+ printf("Did not create %d processes (got %d)\n", np, rsize);
}
if (rank == 0) {
- for (i=0; i<rsize; i++) {
- MPI_Send( &i, 1, MPI_INT, i, 0, intercomm );
+ for (i = 0; i < rsize; i++) {
+ MPI_Send(&i, 1, MPI_INT, i, 0, intercomm);
}
/* We could use intercomm reduce to get the errors from the
- children, but we'll use a simpler loop to make sure that
- we get valid data */
- for (i=0; i<rsize; i++) {
- MPI_Recv( &err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE );
+ * children, but we'll use a simpler loop to make sure that
+ * we get valid data */
+ for (i = 0; i < rsize; i++) {
+ MPI_Recv(&err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE);
errs += err;
}
}
@@ -81,85 +80,84 @@ int main( int argc, char *argv[] )
if (size != np) {
errs++;
- printf( "(Child) Did not create %d processes (got %d)\n",
- np, size );
+ printf("(Child) Did not create %d processes (got %d)\n", np, size);
}
/* Check the name of the parent */
cname[0] = 0;
- MPI_Comm_get_name( intercomm, cname, &rlen );
+ MPI_Comm_get_name(intercomm, cname, &rlen);
/* MPI-2 section 8.4 requires that the parent have this
- default name */
- if (strcmp( cname, "MPI_COMM_PARENT" ) != 0) {
+ * default name */
+ if (strcmp(cname, "MPI_COMM_PARENT") != 0) {
errs++;
- printf( "Name of parent is not correct\n" );
+ printf("Name of parent is not correct\n");
if (rlen > 0 && cname[0]) {
- printf( " Got %s but expected MPI_COMM_PARENT\n", cname );
+ printf(" Got %s but expected MPI_COMM_PARENT\n", cname);
}
else {
- printf( " Expected MPI_COMM_PARENT but no name set\n" );
+ printf(" Expected MPI_COMM_PARENT but no name set\n");
}
}
- MPI_Recv( &i, 1, MPI_INT, 0, 0, intercomm, &status );
+ MPI_Recv(&i, 1, MPI_INT, 0, 0, intercomm, &status);
if (i != rank) {
errs++;
- printf( "Unexpected rank on child %d (%d)\n", rank, i );
+ printf("Unexpected rank on child %d (%d)\n", rank, i);
}
/* Send the errs back to the master process */
- MPI_Ssend( &errs, 1, MPI_INT, 0, 1, intercomm );
+ MPI_Ssend(&errs, 1, MPI_INT, 0, 1, intercomm);
}
if (parentcomm == MPI_COMM_NULL) {
/* Create 2 more processes */
/* This uses a Unix name for the program;
- Windows applications may need to use just spawn2 or
- spawn2.exe. We can't rely on using info to place . in the
- path, since info is not required to be followed. */
- MPI_Comm_spawn( (char*)"./spawn2", MPI_ARGV_NULL, np,
- MPI_INFO_NULL, 0, MPI_COMM_WORLD,
- &intercomm2, MPI_ERRCODES_IGNORE );
+ * Windows applications may need to use just spawn2 or
+ * spawn2.exe. We can't rely on using info to place . in the
+ * path, since info is not required to be followed. */
+ MPI_Comm_spawn((char *) "./spawn2", MPI_ARGV_NULL, np,
+ MPI_INFO_NULL, 0, MPI_COMM_WORLD, &intercomm2, MPI_ERRCODES_IGNORE);
}
else
intercomm2 = parentcomm;
/* We now have a valid intercomm */
- MPI_Comm_remote_size( intercomm2, &rsize );
- MPI_Comm_size( intercomm2, &size );
- MPI_Comm_rank( intercomm2, &rank );
+ MPI_Comm_remote_size(intercomm2, &rsize);
+ MPI_Comm_size(intercomm2, &size);
+ MPI_Comm_rank(intercomm2, &rank);
if (parentcomm == MPI_COMM_NULL) {
/* Master */
if (rsize != np) {
errs++;
- printf( "Did not create %d processes (got %d)\n", np, rsize );
+ printf("Did not create %d processes (got %d)\n", np, rsize);
}
if (rank == 0) {
- for (i=0; i<rsize; i++) {
- MPI_Send( &i, 1, MPI_INT, i, 0, intercomm2 );
+ for (i = 0; i < rsize; i++) {
+ MPI_Send(&i, 1, MPI_INT, i, 0, intercomm2);
}
/* We could use intercomm2 reduce to get the errors from the
- children, but we'll use a simpler loop to make sure that
- we get valid data */
- for (i=0; i<rsize; i++) {
- MPI_Recv( &err, 1, MPI_INT, i, 1, intercomm2, MPI_STATUS_IGNORE );
+ * children, but we'll use a simpler loop to make sure that
+ * we get valid data */
+ for (i = 0; i < rsize; i++) {
+ MPI_Recv(&err, 1, MPI_INT, i, 1, intercomm2, MPI_STATUS_IGNORE);
errs += err;
}
}
- MPI_Comm_free( &intercomm2 );
+ MPI_Comm_free(&intercomm2);
}
/* It isn't necessary to free the intercomm, but it should not hurt */
- MPI_Comm_free( &intercomm );
+ MPI_Comm_free(&intercomm);
/* Note that the MTest_Finalize get errs only over COMM_WORLD */
/* Note also that both the parent and child will generate "No Errors"
- if both call MTest_Finalize */
+ * if both call MTest_Finalize */
if (parentcomm == MPI_COMM_NULL) {
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
}
- } else {
- MTest_Finalize( errs );
+ }
+ else {
+ MTest_Finalize(errs);
}
MPI_Finalize();
diff --git a/test/mpi/spawn/spawnargv.c b/test/mpi/spawn/spawnargv.c
index 95b52aa..524c454 100644
--- a/test/mpi/spawn/spawnargv.c
+++ b/test/mpi/spawn/spawnargv.c
@@ -17,105 +17,105 @@
static char MTEST_Descrip[] = "A simple test of Comm_spawn, with complex arguments";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int rank, size, rsize, i;
int np = 2;
int errcodes[2];
- MPI_Comm parentcomm, intercomm;
- MPI_Status status;
- char * inargv[] = { (char*)"a", (char*)"b=c", (char*)"d e", (char*)"-pf", (char*)" Ss", 0 };
- char * outargv[] = { (char*)"a", (char*)"b=c", (char*)"d e", (char*)"-pf", (char*)" Ss", 0 };
+ MPI_Comm parentcomm, intercomm;
+ MPI_Status status;
+ char *inargv[] =
+ { (char *) "a", (char *) "b=c", (char *) "d e", (char *) "-pf", (char *) " Ss", 0 };
+ char *outargv[] =
+ { (char *) "a", (char *) "b=c", (char *) "d e", (char *) "-pf", (char *) " Ss", 0 };
int can_spawn;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
errs += MTestSpawnPossible(&can_spawn);
if (can_spawn) {
- MPI_Comm_get_parent( &parentcomm );
+ MPI_Comm_get_parent(&parentcomm);
if (parentcomm == MPI_COMM_NULL) {
/* Create 2 more processes */
/* ./ is unix specific .
- The more generic approach would be to specify "spawnargv" as the
- executable and pass an info with ("path", ".") */
- MPI_Comm_spawn( (char*)"./spawnargv", inargv, np,
- MPI_INFO_NULL, 0, MPI_COMM_WORLD,
- &intercomm, errcodes );
+ * The more generic approach would be to specify "spawnargv" as the
+ * executable and pass an info with ("path", ".") */
+ MPI_Comm_spawn((char *) "./spawnargv", inargv, np,
+ MPI_INFO_NULL, 0, MPI_COMM_WORLD, &intercomm, errcodes);
}
else
intercomm = parentcomm;
/* We now have a valid intercomm */
- MPI_Comm_remote_size( intercomm, &rsize );
- MPI_Comm_size( intercomm, &size );
- MPI_Comm_rank( intercomm, &rank );
+ MPI_Comm_remote_size(intercomm, &rsize);
+ MPI_Comm_size(intercomm, &size);
+ MPI_Comm_rank(intercomm, &rank);
if (parentcomm == MPI_COMM_NULL) {
/* Master */
if (rsize != np) {
errs++;
- printf( "Did not create %d processes (got %d)\n", np, rsize );
+ printf("Did not create %d processes (got %d)\n", np, rsize);
}
- for (i=0; i<rsize; i++) {
- MPI_Send( &i, 1, MPI_INT, i, 0, intercomm );
+ for (i = 0; i < rsize; i++) {
+ MPI_Send(&i, 1, MPI_INT, i, 0, intercomm);
}
/* We could use intercomm reduce to get the errors from the
- children, but we'll use a simpler loop to make sure that
- we get valid data */
- for (i=0; i<rsize; i++) {
- MPI_Recv( &err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE );
+ * children, but we'll use a simpler loop to make sure that
+ * we get valid data */
+ for (i = 0; i < rsize; i++) {
+ MPI_Recv(&err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE);
errs += err;
}
}
else {
/* Child */
/* FIXME: This assumes that stdout is handled for the children
- (the error count will still be reported to the parent) */
+ * (the error count will still be reported to the parent) */
if (size != np) {
errs++;
- printf( "(Child) Did not create %d processes (got %d)\n",
- np, size );
+ printf("(Child) Did not create %d processes (got %d)\n", np, size);
}
- MPI_Recv( &i, 1, MPI_INT, 0, 0, intercomm, &status );
+ MPI_Recv(&i, 1, MPI_INT, 0, 0, intercomm, &status);
if (i != rank) {
errs++;
- printf( "Unexpected rank on child %d (%d)\n", rank, i );
+ printf("Unexpected rank on child %d (%d)\n", rank, i);
}
/* Check the command line */
- for (i=1; i<argc; i++) {
- if (!outargv[i-1]) {
+ for (i = 1; i < argc; i++) {
+ if (!outargv[i - 1]) {
errs++;
- printf( "Wrong number of arguments (%d)\n", argc );
+ printf("Wrong number of arguments (%d)\n", argc);
break;
}
- if (strcmp( argv[i], outargv[i-1] ) != 0) {
+ if (strcmp(argv[i], outargv[i - 1]) != 0) {
errs++;
- printf( "Found arg %s but expected %s\n", argv[i],
- outargv[i-1] );
+ printf("Found arg %s but expected %s\n", argv[i], outargv[i - 1]);
}
}
- if (outargv[i-1]) {
+ if (outargv[i - 1]) {
/* We had too few args in the spawned command */
errs++;
- printf( "Too few arguments to spawned command\n" );
+ printf("Too few arguments to spawned command\n");
}
/* Send the errs back to the master process */
- MPI_Ssend( &errs, 1, MPI_INT, 0, 1, intercomm );
+ MPI_Ssend(&errs, 1, MPI_INT, 0, 1, intercomm);
}
/* It isn't necessary to free the intercomm, but it should not hurt */
- MPI_Comm_free( &intercomm );
+ MPI_Comm_free(&intercomm);
/* Note that the MTest_Finalize get errs only over COMM_WORLD */
if (parentcomm == MPI_COMM_NULL) {
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
}
- } else {
- MTest_Finalize( errs );
+ }
+ else {
+ MTest_Finalize(errs);
}
MPI_Finalize();
diff --git a/test/mpi/spawn/spawninfo1.c b/test/mpi/spawn/spawninfo1.c
index abd2a12..871d539 100644
--- a/test/mpi/spawn/spawninfo1.c
+++ b/test/mpi/spawn/spawninfo1.c
@@ -23,79 +23,78 @@
static char MTEST_Descrip[] = "A simple test of Comm_spawn with info";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int rank, size, rsize, i;
int np = 2;
int errcodes[2];
- MPI_Comm parentcomm, intercomm;
- MPI_Status status;
- MPI_Info spawninfo;
+ MPI_Comm parentcomm, intercomm;
+ MPI_Status status;
+ MPI_Info spawninfo;
char curdir[1024], wd[1024], childwd[1024];
char *cerr;
int can_spawn;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
errs += MTestSpawnPossible(&can_spawn);
if (can_spawn) {
- cerr = getcwd( curdir, sizeof(curdir) );
+ cerr = getcwd(curdir, sizeof(curdir));
- MPI_Comm_get_parent( &parentcomm );
+ MPI_Comm_get_parent(&parentcomm);
if (parentcomm == MPI_COMM_NULL) {
char *p;
/* Create 2 more processes. Make the working directory the
- directory above the current running directory */
- strncpy( wd, curdir, sizeof(wd) );
+ * directory above the current running directory */
+ strncpy(wd, curdir, sizeof(wd));
/* Lop off the last element of the directory */
p = wd + strlen(wd) - 1;
- while (p > wd && *p != '/' && *p != '\\') p--;
+ while (p > wd && *p != '/' && *p != '\\')
+ p--;
*p = 0;
- MPI_Info_create( &spawninfo );
- MPI_Info_set( spawninfo, (char*)"path", curdir );
- MPI_Info_set( spawninfo, (char*)"wdir", wd );
- MPI_Comm_spawn( (char*)"spawninfo1", MPI_ARGV_NULL, np,
- spawninfo, 0, MPI_COMM_WORLD,
- &intercomm, errcodes );
- MPI_Info_free( &spawninfo );
+ MPI_Info_create(&spawninfo);
+ MPI_Info_set(spawninfo, (char *) "path", curdir);
+ MPI_Info_set(spawninfo, (char *) "wdir", wd);
+ MPI_Comm_spawn((char *) "spawninfo1", MPI_ARGV_NULL, np,
+ spawninfo, 0, MPI_COMM_WORLD, &intercomm, errcodes);
+ MPI_Info_free(&spawninfo);
}
else
intercomm = parentcomm;
/* We now have a valid intercomm */
- MPI_Comm_remote_size( intercomm, &rsize );
- MPI_Comm_size( intercomm, &size );
- MPI_Comm_rank( intercomm, &rank );
+ MPI_Comm_remote_size(intercomm, &rsize);
+ MPI_Comm_size(intercomm, &size);
+ MPI_Comm_rank(intercomm, &rank);
if (parentcomm == MPI_COMM_NULL) {
/* Master */
if (rsize != np) {
errs++;
- printf( "Did not create %d processes (got %d)\n", np, rsize );
+ printf("Did not create %d processes (got %d)\n", np, rsize);
}
if (rank == 0) {
- for (i=0; i<rsize; i++) {
- MPI_Send( &i, 1, MPI_INT, i, 0, intercomm );
+ for (i = 0; i < rsize; i++) {
+ MPI_Send(&i, 1, MPI_INT, i, 0, intercomm);
}
/* We could use intercomm reduce to get the errors from the
- children, but we'll use a simpler loop to make sure that
- we get valid data */
- for (i=0; i<rsize; i++) {
- MPI_Recv( &err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE );
+ * children, but we'll use a simpler loop to make sure that
+ * we get valid data */
+ for (i = 0; i < rsize; i++) {
+ MPI_Recv(&err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE);
errs += err;
}
- for (i=0; i<rsize; i++) {
- MPI_Recv( childwd, sizeof(childwd), MPI_CHAR, i, 2, intercomm,
- MPI_STATUS_IGNORE );
- if (strcmp( childwd, wd ) != 0) {
- printf( "Expected a working dir of %s but child is in %s\n",
- wd, childwd );
- errs ++;
+ for (i = 0; i < rsize; i++) {
+ MPI_Recv(childwd, sizeof(childwd), MPI_CHAR, i, 2, intercomm,
+ MPI_STATUS_IGNORE);
+ if (strcmp(childwd, wd) != 0) {
+ printf("Expected a working dir of %s but child is in %s\n", wd, childwd);
+ errs++;
}
}
}
@@ -107,47 +106,47 @@ int main( int argc, char *argv[] )
if (size != np) {
errs++;
- printf( "(Child) Did not create %d processes (got %d)\n",
- np, size );
+ printf("(Child) Did not create %d processes (got %d)\n", np, size);
}
/* Check the name of the parent */
cname[0] = 0;
- MPI_Comm_get_name( intercomm, cname, &rlen );
+ MPI_Comm_get_name(intercomm, cname, &rlen);
/* MPI-2 section 8.4 requires that the parent have this
- default name */
- if (strcmp( cname, "MPI_COMM_PARENT" ) != 0) {
+ * default name */
+ if (strcmp(cname, "MPI_COMM_PARENT") != 0) {
errs++;
- printf( "Name of parent is not correct\n" );
+ printf("Name of parent is not correct\n");
if (rlen > 0 && cname[0]) {
- printf( " Got %s but expected MPI_COMM_PARENT\n", cname );
+ printf(" Got %s but expected MPI_COMM_PARENT\n", cname);
}
else {
- printf( " Expected MPI_COMM_PARENT but no name set\n" );
+ printf(" Expected MPI_COMM_PARENT but no name set\n");
}
}
- MPI_Recv( &i, 1, MPI_INT, 0, 0, intercomm, &status );
+ MPI_Recv(&i, 1, MPI_INT, 0, 0, intercomm, &status);
if (i != rank) {
errs++;
- printf( "Unexpected rank on child %d (%d)\n", rank, i );
+ printf("Unexpected rank on child %d (%d)\n", rank, i);
}
/* Send our notion of the current directory to the parent */
- MPI_Send( curdir, strlen(curdir)+1, MPI_CHAR, 0, 2, intercomm );
+ MPI_Send(curdir, strlen(curdir) + 1, MPI_CHAR, 0, 2, intercomm);
/* Send the errs back to the master process */
- MPI_Ssend( &errs, 1, MPI_INT, 0, 1, intercomm );
+ MPI_Ssend(&errs, 1, MPI_INT, 0, 1, intercomm);
}
/* It isn't necessary to free the intercomm, but it should not hurt */
- MPI_Comm_free( &intercomm );
+ MPI_Comm_free(&intercomm);
/* Note that the MTest_Finalize get errs only over COMM_WORLD */
/* Note also that both the parent and child will generate "No Errors"
- if both call MTest_Finalize */
+ * if both call MTest_Finalize */
if (parentcomm == MPI_COMM_NULL) {
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
}
- } else {
- MTest_Finalize( errs );
+ }
+ else {
+ MTest_Finalize(errs);
}
MPI_Finalize();
diff --git a/test/mpi/spawn/spawnintra.c b/test/mpi/spawn/spawnintra.c
index 41b6603..97e80ca 100644
--- a/test/mpi/spawn/spawnintra.c
+++ b/test/mpi/spawn/spawnintra.c
@@ -12,48 +12,47 @@
static char MTEST_Descrip[] = "A simple test of Comm_spawn, followed by intercomm merge";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int rank, size, rsize, i;
int np = 2;
int errcodes[2];
- MPI_Comm parentcomm, intercomm, intracomm, intracomm2, intracomm3;
- int isChild = 0;
- MPI_Status status;
+ MPI_Comm parentcomm, intercomm, intracomm, intracomm2, intracomm3;
+ int isChild = 0;
+ MPI_Status status;
int can_spawn;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
errs += MTestSpawnPossible(&can_spawn);
if (can_spawn) {
- MPI_Comm_get_parent( &parentcomm );
+ MPI_Comm_get_parent(&parentcomm);
if (parentcomm == MPI_COMM_NULL) {
/* Create 2 more processes */
- MPI_Comm_spawn( (char*)"./spawnintra", MPI_ARGV_NULL, np,
- MPI_INFO_NULL, 0, MPI_COMM_WORLD,
- &intercomm, errcodes );
+ MPI_Comm_spawn((char *) "./spawnintra", MPI_ARGV_NULL, np,
+ MPI_INFO_NULL, 0, MPI_COMM_WORLD, &intercomm, errcodes);
}
else
intercomm = parentcomm;
/* We now have a valid intercomm */
- MPI_Comm_remote_size( intercomm, &rsize );
- MPI_Comm_size( intercomm, &size );
- MPI_Comm_rank( intercomm, &rank );
+ MPI_Comm_remote_size(intercomm, &rsize);
+ MPI_Comm_size(intercomm, &size);
+ MPI_Comm_rank(intercomm, &rank);
if (parentcomm == MPI_COMM_NULL) {
/* Master */
if (rsize != np) {
errs++;
- printf( "Did not create %d processes (got %d)\n", np, rsize );
+ printf("Did not create %d processes (got %d)\n", np, rsize);
}
if (rank == 0) {
- for (i=0; i<rsize; i++) {
- MPI_Send( &i, 1, MPI_INT, i, 0, intercomm );
+ for (i = 0; i < rsize; i++) {
+ MPI_Send(&i, 1, MPI_INT, i, 0, intercomm);
}
}
}
@@ -62,140 +61,139 @@ int main( int argc, char *argv[] )
isChild = 1;
if (size != np) {
errs++;
- printf( "(Child) Did not create %d processes (got %d)\n",
- np, size );
+ printf("(Child) Did not create %d processes (got %d)\n", np, size);
}
- MPI_Recv( &i, 1, MPI_INT, 0, 0, intercomm, &status );
+ MPI_Recv(&i, 1, MPI_INT, 0, 0, intercomm, &status);
if (i != rank) {
errs++;
- printf( "Unexpected rank on child %d (%d)\n", rank, i );
+ printf("Unexpected rank on child %d (%d)\n", rank, i);
}
}
/* At this point, try to form the intracommunicator */
- MPI_Intercomm_merge( intercomm, isChild, &intracomm );
+ MPI_Intercomm_merge(intercomm, isChild, &intracomm);
/* Check on the intra comm */
{
int icsize, icrank, wrank;
- MPI_Comm_size( intracomm, &icsize );
- MPI_Comm_rank( intracomm, &icrank );
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
+ MPI_Comm_size(intracomm, &icsize);
+ MPI_Comm_rank(intracomm, &icrank);
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
if (icsize != rsize + size) {
errs++;
- printf( "Intracomm rank %d thinks size is %d, not %d\n",
- icrank, icsize, rsize + size );
+ printf("Intracomm rank %d thinks size is %d, not %d\n",
+ icrank, icsize, rsize + size);
}
/* Make sure that the processes are ordered correctly */
if (isChild) {
int psize;
- MPI_Comm_remote_size( parentcomm, &psize );
- if (icrank != psize + wrank ) {
+ MPI_Comm_remote_size(parentcomm, &psize);
+ if (icrank != psize + wrank) {
errs++;
- printf( "Intracomm rank %d (from child) should have rank %d\n",
- icrank, psize + wrank );
+ printf("Intracomm rank %d (from child) should have rank %d\n",
+ icrank, psize + wrank);
}
}
else {
if (icrank != wrank) {
errs++;
- printf( "Intracomm rank %d (from parent) should have rank %d\n",
- icrank, wrank );
+ printf("Intracomm rank %d (from parent) should have rank %d\n", icrank, wrank);
}
}
}
/* At this point, try to form the intracommunicator, with the other
- processes first */
- MPI_Intercomm_merge( intercomm, !isChild, &intracomm2 );
+ * processes first */
+ MPI_Intercomm_merge(intercomm, !isChild, &intracomm2);
/* Check on the intra comm */
{
int icsize, icrank, wrank;
- MPI_Comm_size( intracomm2, &icsize );
- MPI_Comm_rank( intracomm2, &icrank );
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
+ MPI_Comm_size(intracomm2, &icsize);
+ MPI_Comm_rank(intracomm2, &icrank);
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
if (icsize != rsize + size) {
errs++;
- printf( "(2)Intracomm rank %d thinks size is %d, not %d\n",
- icrank, icsize, rsize + size );
+ printf("(2)Intracomm rank %d thinks size is %d, not %d\n",
+ icrank, icsize, rsize + size);
}
/* Make sure that the processes are ordered correctly */
if (isChild) {
- if (icrank != wrank ) {
+ if (icrank != wrank) {
errs++;
- printf( "(2)Intracomm rank %d (from child) should have rank %d\n",
- icrank, wrank );
+ printf("(2)Intracomm rank %d (from child) should have rank %d\n",
+ icrank, wrank);
}
}
else {
int csize;
- MPI_Comm_remote_size( intercomm, &csize );
+ MPI_Comm_remote_size(intercomm, &csize);
if (icrank != wrank + csize) {
errs++;
- printf( "(2)Intracomm rank %d (from parent) should have rank %d\n",
- icrank, wrank + csize );
+ printf("(2)Intracomm rank %d (from parent) should have rank %d\n",
+ icrank, wrank + csize);
}
}
}
/* At this point, try to form the intracommunicator, with an
- arbitrary choice for the first group of processes */
- MPI_Intercomm_merge( intercomm, 0, &intracomm3 );
+ * arbitrary choice for the first group of processes */
+ MPI_Intercomm_merge(intercomm, 0, &intracomm3);
/* Check on the intra comm */
{
int icsize, icrank, wrank;
- MPI_Comm_size( intracomm3, &icsize );
- MPI_Comm_rank( intracomm3, &icrank );
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
+ MPI_Comm_size(intracomm3, &icsize);
+ MPI_Comm_rank(intracomm3, &icrank);
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
if (icsize != rsize + size) {
errs++;
- printf( "(3)Intracomm rank %d thinks size is %d, not %d\n",
- icrank, icsize, rsize + size );
+ printf("(3)Intracomm rank %d thinks size is %d, not %d\n",
+ icrank, icsize, rsize + size);
}
/* Eventually, we should test that the processes are ordered
- correctly, by groups (must be one of the two cases above) */
+ * correctly, by groups (must be one of the two cases above) */
}
/* Update error count */
if (isChild) {
/* Send the errs back to the master process */
- MPI_Ssend( &errs, 1, MPI_INT, 0, 1, intercomm );
+ MPI_Ssend(&errs, 1, MPI_INT, 0, 1, intercomm);
}
else {
if (rank == 0) {
/* We could use intercomm reduce to get the errors from the
- children, but we'll use a simpler loop to make sure that
- we get valid data */
- for (i=0; i<rsize; i++) {
- MPI_Recv( &err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE );
+ * children, but we'll use a simpler loop to make sure that
+ * we get valid data */
+ for (i = 0; i < rsize; i++) {
+ MPI_Recv(&err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE);
errs += err;
}
}
}
/* It isn't necessary to free the intracomms, but it should not hurt */
- MPI_Comm_free( &intracomm );
- MPI_Comm_free( &intracomm2 );
- MPI_Comm_free( &intracomm3 );
+ MPI_Comm_free(&intracomm);
+ MPI_Comm_free(&intracomm2);
+ MPI_Comm_free(&intracomm3);
/* It isn't necessary to free the intercomm, but it should not hurt */
- MPI_Comm_free( &intercomm );
+ MPI_Comm_free(&intercomm);
/* Note that the MTest_Finalize get errs only over COMM_WORLD */
/* Note also that both the parent and child will generate "No Errors"
- if both call MTest_Finalize */
+ * if both call MTest_Finalize */
if (parentcomm == MPI_COMM_NULL) {
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
}
- } else {
- MTest_Finalize( errs );
+ }
+ else {
+ MTest_Finalize(errs);
}
MPI_Finalize();
diff --git a/test/mpi/spawn/spawnmanyarg.c b/test/mpi/spawn/spawnmanyarg.c
index 68d6c4e..1547110 100644
--- a/test/mpi/spawn/spawnmanyarg.c
+++ b/test/mpi/spawn/spawnmanyarg.c
@@ -18,106 +18,105 @@ static char MTEST_Descrip[] = "A simple test of Comm_spawn, with many arguments"
*/
#define MAX_ARGV 1024
-int worker( int argc, char *argv[],
- MPI_Comm intercomm, char *outargv[], int np );
+int worker(int argc, char *argv[], MPI_Comm intercomm, char *outargv[], int np);
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int rank, size, rsize, i;
int np = 2;
int errcodes[2];
- MPI_Comm parentcomm, intercomm;
+ MPI_Comm parentcomm, intercomm;
char *inargv[MAX_ARGV];
char *outargv[MAX_ARGV];
int narg = 40;
char *saveArgp = 0;
int can_spawn;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
errs += MTestSpawnPossible(&can_spawn);
if (can_spawn) {
/* Initialize the argument vectors */
- for (i=0; i<MAX_ARGV; i++) {
+ for (i = 0; i < MAX_ARGV; i++) {
char *p;
- p = (char *)malloc( 9 );
+ p = (char *) malloc(9);
if (!p) {
- fprintf( stderr, "Unable to allocated memory\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Unable to allocated memory\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- strcpy( p, "01234567" );
+ strcpy(p, "01234567");
inargv[i] = p;
- p = (char *)malloc( 9 );
+ p = (char *) malloc(9);
if (!p) {
- fprintf( stderr, "Unable to allocated memory\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Unable to allocated memory\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- strcpy( p, "01234567" );
+ strcpy(p, "01234567");
outargv[i] = p;
}
- MPI_Comm_get_parent( &parentcomm );
+ MPI_Comm_get_parent(&parentcomm);
if (parentcomm == MPI_COMM_NULL) {
- for (narg=16; narg < 512; narg += narg) {
+ for (narg = 16; narg < 512; narg += narg) {
/* Create 2 more processes */
/* Set a null at argument length narg */
saveArgp = inargv[narg];
inargv[narg] = 0;
/* ./ is unix specific .
- The more generic approach would be to specify "spawnmanyarg" as
- the executable and pass an info with ("path", ".") */
- MPI_Comm_spawn( (char*)"./spawnmanyarg", inargv, np,
- MPI_INFO_NULL, 0, MPI_COMM_WORLD,
- &intercomm, errcodes );
+ * The more generic approach would be to specify "spawnmanyarg" as
+ * the executable and pass an info with ("path", ".") */
+ MPI_Comm_spawn((char *) "./spawnmanyarg", inargv, np,
+ MPI_INFO_NULL, 0, MPI_COMM_WORLD, &intercomm, errcodes);
inargv[narg] = saveArgp;
/* We now have a valid intercomm */
/* Master */
- MPI_Comm_remote_size( intercomm, &rsize );
- MPI_Comm_size( intercomm, &size );
- MPI_Comm_rank( intercomm, &rank );
+ MPI_Comm_remote_size(intercomm, &rsize);
+ MPI_Comm_size(intercomm, &size);
+ MPI_Comm_rank(intercomm, &rank);
if (rsize != np) {
errs++;
- printf( "Did not create %d processes (got %d)\n", np, rsize );
+ printf("Did not create %d processes (got %d)\n", np, rsize);
}
/* Send the expected rank */
- for (i=0; i<rsize; i++) {
- MPI_Send( &i, 1, MPI_INT, i, 0, intercomm );
+ for (i = 0; i < rsize; i++) {
+ MPI_Send(&i, 1, MPI_INT, i, 0, intercomm);
}
/* Send the number of arguments */
- for (i=0; i<rsize; i++) {
- MPI_Send( &narg, 1, MPI_INT, i, 0, intercomm );
+ for (i = 0; i < rsize; i++) {
+ MPI_Send(&narg, 1, MPI_INT, i, 0, intercomm);
}
/* We could use intercomm reduce to get the errors from the
- children, but we'll use a simpler loop to make sure that
- we get valid data */
- for (i=0; i<rsize; i++) {
- MPI_Recv( &err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE );
+ * children, but we'll use a simpler loop to make sure that
+ * we get valid data */
+ for (i = 0; i < rsize; i++) {
+ MPI_Recv(&err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE);
errs += err;
}
/* Free the intercomm before the next round of spawns */
- MPI_Comm_free( &intercomm );
+ MPI_Comm_free(&intercomm);
}
}
else {
/* Note that worker also send errs to the parent */
- errs += worker( argc, argv, parentcomm, outargv, np );
- MPI_Comm_free( &parentcomm );
+ errs += worker(argc, argv, parentcomm, outargv, np);
+ MPI_Comm_free(&parentcomm);
MPI_Finalize();
return 0;
}
/* Note that the MTest_Finalize get errs only over COMM_WORLD */
if (parentcomm == MPI_COMM_NULL) {
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
}
- } else {
- MTest_Finalize( errs );
+ }
+ else {
+ MTest_Finalize(errs);
}
MPI_Finalize();
@@ -125,8 +124,7 @@ int main( int argc, char *argv[] )
}
/* Call this routine if this process is the spawned child */
-int worker( int argc, char *argv[],
- MPI_Comm intercomm, char *outargv[], int np )
+int worker(int argc, char *argv[], MPI_Comm intercomm, char *outargv[], int np)
{
int i, narg;
int rsize, size, rank;
@@ -134,49 +132,47 @@ int worker( int argc, char *argv[],
char *saveoutArgp = 0;
MPI_Status status;
- MPI_Comm_remote_size( intercomm, &rsize );
- MPI_Comm_size( intercomm, &size );
- MPI_Comm_rank( intercomm, &rank );
+ MPI_Comm_remote_size(intercomm, &rsize);
+ MPI_Comm_size(intercomm, &size);
+ MPI_Comm_rank(intercomm, &rank);
/* Child */
/* FIXME: This assumes that stdout is handled for the children
- (the error count will still be reported to the parent) */
+ * (the error count will still be reported to the parent) */
if (size != np) {
- errs++;
- printf( "(Child) Did not create %d processes (got %d)\n",
- np, size );
+ errs++;
+ printf("(Child) Did not create %d processes (got %d)\n", np, size);
}
- MPI_Recv( &i, 1, MPI_INT, 0, 0, intercomm, &status );
+ MPI_Recv(&i, 1, MPI_INT, 0, 0, intercomm, &status);
if (i != rank) {
- errs++;
- printf( "Unexpected rank on child %d (%d)\n", rank, i );
+ errs++;
+ printf("Unexpected rank on child %d (%d)\n", rank, i);
}
- MPI_Recv( &narg, 1, MPI_INT, 0, 0, intercomm, MPI_STATUS_IGNORE );
+ MPI_Recv(&narg, 1, MPI_INT, 0, 0, intercomm, MPI_STATUS_IGNORE);
saveoutArgp = outargv[narg];
outargv[narg] = 0;
/* Check the command line */
- for (i=1; i<argc; i++) {
- if (!outargv[i-1]) {
- errs++;
- printf( "Wrong number of arguments (%d)\n", argc );
- break;
- }
- if (strcmp( argv[i], outargv[i-1] ) != 0) {
- errs++;
- printf( "Found arg %s but expected %s\n", argv[i],
- outargv[i-1] );
- }
+ for (i = 1; i < argc; i++) {
+ if (!outargv[i - 1]) {
+ errs++;
+ printf("Wrong number of arguments (%d)\n", argc);
+ break;
+ }
+ if (strcmp(argv[i], outargv[i - 1]) != 0) {
+ errs++;
+ printf("Found arg %s but expected %s\n", argv[i], outargv[i - 1]);
+ }
}
- if (outargv[i-1]) {
- /* We had too few args in the spawned command */
- errs++;
- printf( "Too few arguments to spawned command (only %d)\n", i );
+ if (outargv[i - 1]) {
+ /* We had too few args in the spawned command */
+ errs++;
+ printf("Too few arguments to spawned command (only %d)\n", i);
}
- /* Restore the argument vector (not necessary in this case, since the
- worker will exit) */
+ /* Restore the argument vector (not necessary in this case, since the
+ * worker will exit) */
outargv[narg] = saveoutArgp;
/* Send the errs back to the master process */
- MPI_Ssend( &errs, 1, MPI_INT, 0, 1, intercomm );
+ MPI_Ssend(&errs, 1, MPI_INT, 0, 1, intercomm);
- return errs;
+ return errs;
}
diff --git a/test/mpi/spawn/spawnminfo1.c b/test/mpi/spawn/spawnminfo1.c
index 11c27d2..eb1d211 100644
--- a/test/mpi/spawn/spawnminfo1.c
+++ b/test/mpi/spawn/spawnminfo1.c
@@ -23,88 +23,91 @@
static char MTEST_Descrip[] = "A simple test of Comm_spawn_multiple with info";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int rank, size, rsize, i;
int np[2] = { 1, 1 }, sumnp = 2;
int errcodes[2];
- MPI_Comm parentcomm, intercomm;
- MPI_Status status;
- MPI_Info spawninfos[2];
+ MPI_Comm parentcomm, intercomm;
+ MPI_Status status;
+ MPI_Info spawninfos[2];
char curdir[1024], wd[1024], childwd[1024];
- char *commands[2] = { (char*)"spawnminfo1", (char*)"spawnminfo1" };
+ char *commands[2] = { (char *) "spawnminfo1", (char *) "spawnminfo1" };
char *cerr;
int can_spawn;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
errs += MTestSpawnPossible(&can_spawn);
if (can_spawn) {
- cerr = getcwd( curdir, sizeof(curdir) );
+ cerr = getcwd(curdir, sizeof(curdir));
- MPI_Comm_get_parent( &parentcomm );
+ MPI_Comm_get_parent(&parentcomm);
if (parentcomm == MPI_COMM_NULL) {
char *p;
/* Create 2 more processes. Make the working directory the
- directory above the current running directory */
- strncpy( wd, curdir, sizeof(wd) );
+ * directory above the current running directory */
+ strncpy(wd, curdir, sizeof(wd));
/* Lop off the last element of the directory */
p = wd + strlen(wd) - 1;
- while (p > wd && *p != '/' && *p != '\\') p--;
+ while (p > wd && *p != '/' && *p != '\\')
+ p--;
*p = 0;
- MPI_Info_create( &spawninfos[0] );
- MPI_Info_set( spawninfos[0], (char*)"path", curdir );
- MPI_Info_set( spawninfos[0], (char*)"wdir", wd );
- MPI_Info_create( &spawninfos[1] );
- MPI_Info_set( spawninfos[1], (char*)"path", curdir );
- MPI_Info_set( spawninfos[1], (char*)"wdir", curdir );
- MPI_Comm_spawn_multiple( 2, commands, MPI_ARGVS_NULL, np,
- spawninfos, 0, MPI_COMM_WORLD,
- &intercomm, errcodes );
- MPI_Info_free( &spawninfos[0] );
- MPI_Info_free( &spawninfos[1] );
+ MPI_Info_create(&spawninfos[0]);
+ MPI_Info_set(spawninfos[0], (char *) "path", curdir);
+ MPI_Info_set(spawninfos[0], (char *) "wdir", wd);
+ MPI_Info_create(&spawninfos[1]);
+ MPI_Info_set(spawninfos[1], (char *) "path", curdir);
+ MPI_Info_set(spawninfos[1], (char *) "wdir", curdir);
+ MPI_Comm_spawn_multiple(2, commands, MPI_ARGVS_NULL, np,
+ spawninfos, 0, MPI_COMM_WORLD, &intercomm, errcodes);
+ MPI_Info_free(&spawninfos[0]);
+ MPI_Info_free(&spawninfos[1]);
}
else
intercomm = parentcomm;
/* We now have a valid intercomm */
- MPI_Comm_remote_size( intercomm, &rsize );
- MPI_Comm_size( intercomm, &size );
- MPI_Comm_rank( intercomm, &rank );
+ MPI_Comm_remote_size(intercomm, &rsize);
+ MPI_Comm_size(intercomm, &size);
+ MPI_Comm_rank(intercomm, &rank);
if (parentcomm == MPI_COMM_NULL) {
/* Master */
if (rsize != sumnp) {
errs++;
- printf( "Did not create %d processes (got %d)\n", sumnp, rsize );
+ printf("Did not create %d processes (got %d)\n", sumnp, rsize);
}
if (rank == 0) {
- for (i=0; i<rsize; i++) {
- MPI_Send( &i, 1, MPI_INT, i, 0, intercomm );
+ for (i = 0; i < rsize; i++) {
+ MPI_Send(&i, 1, MPI_INT, i, 0, intercomm);
}
/* We could use intercomm reduce to get the errors from the
- children, but we'll use a simpler loop to make sure that
- we get valid data */
- for (i=0; i<rsize; i++) {
- MPI_Recv( &err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE );
+ * children, but we'll use a simpler loop to make sure that
+ * we get valid data */
+ for (i = 0; i < rsize; i++) {
+ MPI_Recv(&err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE);
errs += err;
}
- for (i=0; i<rsize; i++) {
+ for (i = 0; i < rsize; i++) {
char *expected = 0;
- MPI_Recv( childwd, sizeof(childwd), MPI_CHAR, i, 2, intercomm,
- MPI_STATUS_IGNORE );
+ MPI_Recv(childwd, sizeof(childwd), MPI_CHAR, i, 2, intercomm,
+ MPI_STATUS_IGNORE);
/* The first set uses wd the second set curdir */
- if (i <np[0]) expected = wd;
- else expected = curdir;
- if (strcmp( childwd, expected ) != 0) {
- printf( "Expected a working dir of %s but child is in %s for child rank %d\n",
- expected, childwd, i );
- errs ++;
+ if (i < np[0])
+ expected = wd;
+ else
+ expected = curdir;
+ if (strcmp(childwd, expected) != 0) {
+ printf
+ ("Expected a working dir of %s but child is in %s for child rank %d\n",
+ expected, childwd, i);
+ errs++;
}
}
}
@@ -116,47 +119,47 @@ int main( int argc, char *argv[] )
if (size != sumnp) {
errs++;
- printf( "(Child) Did not create %d processes (got %d)\n",
- sumnp, size );
+ printf("(Child) Did not create %d processes (got %d)\n", sumnp, size);
}
/* Check the name of the parent */
cname[0] = 0;
- MPI_Comm_get_name( intercomm, cname, &rlen );
+ MPI_Comm_get_name(intercomm, cname, &rlen);
/* MPI-2 section 8.4 requires that the parent have this
- default name */
- if (strcmp( cname, "MPI_COMM_PARENT" ) != 0) {
+ * default name */
+ if (strcmp(cname, "MPI_COMM_PARENT") != 0) {
errs++;
- printf( "Name of parent is not correct\n" );
+ printf("Name of parent is not correct\n");
if (rlen > 0 && cname[0]) {
- printf( " Got %s but expected MPI_COMM_PARENT\n", cname );
+ printf(" Got %s but expected MPI_COMM_PARENT\n", cname);
}
else {
- printf( " Expected MPI_COMM_PARENT but no name set\n" );
+ printf(" Expected MPI_COMM_PARENT but no name set\n");
}
}
- MPI_Recv( &i, 1, MPI_INT, 0, 0, intercomm, &status );
+ MPI_Recv(&i, 1, MPI_INT, 0, 0, intercomm, &status);
if (i != rank) {
errs++;
- printf( "Unexpected rank on child %d (%d)\n", rank, i );
+ printf("Unexpected rank on child %d (%d)\n", rank, i);
}
/* Send our notion of the current directory to the parent */
- MPI_Send( curdir, strlen(curdir)+1, MPI_CHAR, 0, 2, intercomm );
+ MPI_Send(curdir, strlen(curdir) + 1, MPI_CHAR, 0, 2, intercomm);
/* Send the errs back to the master process */
- MPI_Ssend( &errs, 1, MPI_INT, 0, 1, intercomm );
+ MPI_Ssend(&errs, 1, MPI_INT, 0, 1, intercomm);
}
/* It isn't necessary to free the intercomm, but it should not hurt */
- MPI_Comm_free( &intercomm );
+ MPI_Comm_free(&intercomm);
/* Note that the MTest_Finalize get errs only over COMM_WORLD */
/* Note also that both the parent and child will generate "No Errors"
- if both call MTest_Finalize */
+ * if both call MTest_Finalize */
if (parentcomm == MPI_COMM_NULL) {
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
}
- } else {
- MTest_Finalize( errs );
+ }
+ else {
+ MTest_Finalize(errs);
}
MPI_Finalize();
diff --git a/test/mpi/spawn/spawnmult2.c b/test/mpi/spawn/spawnmult2.c
index ab5b5a1..5fef931 100644
--- a/test/mpi/spawn/spawnmult2.c
+++ b/test/mpi/spawn/spawnmult2.c
@@ -15,7 +15,7 @@
* executable is running.
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
MPI_Comm parentcomm, intercomm;
int i, size, rsize, rank;
@@ -26,20 +26,20 @@ int main( int argc, char *argv[] )
int *appnum_ptr;
int can_spawn;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
MTestSpawnPossible(&can_spawn);
if (can_spawn) {
- MPI_Comm_get_parent( &parentcomm );
+ MPI_Comm_get_parent(&parentcomm);
if (parentcomm == MPI_COMM_NULL) {
/* Create 2 more processes */
- static char *cmds[2] = { (char*)"./spawnmult2", (char*)"./spawnmult2" };
+ static char *cmds[2] = { (char *) "./spawnmult2", (char *) "./spawnmult2" };
static MPI_Info infos[2] = { MPI_INFO_NULL, MPI_INFO_NULL };
int errcodes[2];
- MPI_Comm_spawn_multiple( 2, cmds, MPI_ARGVS_NULL, np, infos, 0,
- MPI_COMM_WORLD, &intercomm, errcodes );
+ MPI_Comm_spawn_multiple(2, cmds, MPI_ARGVS_NULL, np, infos, 0,
+ MPI_COMM_WORLD, &intercomm, errcodes);
}
else {
@@ -47,28 +47,26 @@ int main( int argc, char *argv[] )
}
/* We now have a valid intercomm */
- MPI_Comm_remote_size( intercomm, &rsize );
- MPI_Comm_size( intercomm, &size );
- MPI_Comm_rank( intercomm, &rank );
+ MPI_Comm_remote_size(intercomm, &rsize);
+ MPI_Comm_size(intercomm, &size);
+ MPI_Comm_rank(intercomm, &rank);
if (parentcomm == MPI_COMM_NULL) {
/* This is the master process */
if (rsize != np[0] + np[1]) {
errs++;
- printf( "Did not create %d processes (got %d)\n",
- np[0] + np[1], rsize );
+ printf("Did not create %d processes (got %d)\n", np[0] + np[1], rsize);
}
if (rank == 0) {
/* Tell each child process what rank we think they are */
- for (i=0; i<rsize; i++) {
- MPI_Send( &i, 1, MPI_INT, i, 0, intercomm );
+ for (i = 0; i < rsize; i++) {
+ MPI_Send(&i, 1, MPI_INT, i, 0, intercomm);
}
/* We could use intercomm reduce to get the errors from the
* children, but we'll use a simpler loop to make sure that
* we get valid data */
- for (i=0; i<rsize; i++) {
- MPI_Recv( &err, 1, MPI_INT, i, 1, intercomm,
- MPI_STATUS_IGNORE );
+ for (i = 0; i < rsize; i++) {
+ MPI_Recv(&err, 1, MPI_INT, i, 1, intercomm, MPI_STATUS_IGNORE);
errs += err;
}
}
@@ -80,47 +78,48 @@ int main( int argc, char *argv[] )
if (size != 2) {
int wsize;
errs++;
- printf( "(Child) Did not create 2 processes (got %d)\n", size);
- MPI_Comm_size( MPI_COMM_WORLD, &wsize );
+ printf("(Child) Did not create 2 processes (got %d)\n", size);
+ MPI_Comm_size(MPI_COMM_WORLD, &wsize);
if (wsize == 2) {
errs++;
- printf( "(Child) world size is 2 but local intercomm size is not 2\n" );
+ printf("(Child) world size is 2 but local intercomm size is not 2\n");
}
}
- MPI_Recv( &i, 1, MPI_INT, 0, 0, intercomm, &status );
+ MPI_Recv(&i, 1, MPI_INT, 0, 0, intercomm, &status);
if (i != rank) {
errs++;
- printf( "Unexpected rank on child %d (%d)\n", rank, i );
+ printf("Unexpected rank on child %d (%d)\n", rank, i);
}
/* Check for correct APPNUM */
- MPI_Comm_get_attr( MPI_COMM_WORLD, MPI_APPNUM, &appnum_ptr, &flag );
+ MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_APPNUM, &appnum_ptr, &flag);
/* My appnum should be my rank in comm world */
if (flag) {
if (*appnum_ptr != rank) {
errs++;
- printf( "appnum is %d but should be %d\n", *appnum_ptr, rank );
+ printf("appnum is %d but should be %d\n", *appnum_ptr, rank);
}
}
else {
errs++;
- printf( "appnum was not set\n" );
+ printf("appnum was not set\n");
}
/* Send the errs back to the master process */
- MPI_Ssend( &errs, 1, MPI_INT, 0, 1, intercomm );
+ MPI_Ssend(&errs, 1, MPI_INT, 0, 1, intercomm);
}
/* It isn't necessary to free the intercomm, but it should not hurt */
- MPI_Comm_free( &intercomm );
+ MPI_Comm_free(&intercomm);
/* Note that the MTest_Finalize get errs only over COMM_WORLD */
if (parentcomm == MPI_COMM_NULL) {
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
}
- } else {
- MTest_Finalize( errs );
+ }
+ else {
+ MTest_Finalize(errs);
}
MPI_Finalize();
diff --git a/test/mpi/spawn/taskmaster.c b/test/mpi/spawn/taskmaster.c
index 4a06629..f5cffd7 100644
--- a/test/mpi/spawn/taskmaster.c
+++ b/test/mpi/spawn/taskmaster.c
@@ -27,23 +27,23 @@ int comm_world_size;
void process_spawn(MPI_Comm * comm, int thread_id);
void process_spawn(MPI_Comm * comm, int thread_id)
{
- CHECK_SUCCESS(MPI_Comm_spawn((char*)"./taskmaster", (char **) NULL, 1, MPI_INFO_NULL, 0,
- MPI_COMM_WORLD, comm, NULL));
+ CHECK_SUCCESS(MPI_Comm_spawn((char *) "./taskmaster", (char **) NULL, 1, MPI_INFO_NULL, 0,
+ MPI_COMM_WORLD, comm, NULL));
}
void process_disconnect(MPI_Comm * comm, int thread_id);
void process_disconnect(MPI_Comm * comm, int thread_id)
{
if (comm_world_rank == 0) {
- CHECK_SUCCESS(MPI_Recv(NULL, 0, MPI_CHAR, 0, 1, *comm, MPI_STATUS_IGNORE));
- CHECK_SUCCESS(MPI_Send(NULL, 0, MPI_CHAR, 0, 1, *comm));
+ CHECK_SUCCESS(MPI_Recv(NULL, 0, MPI_CHAR, 0, 1, *comm, MPI_STATUS_IGNORE));
+ CHECK_SUCCESS(MPI_Send(NULL, 0, MPI_CHAR, 0, 1, *comm));
}
CHECK_SUCCESS(MPI_Comm_disconnect(comm));
}
#ifdef USE_THREADS
-static void * main_thread(void * arg)
+static void *main_thread(void *arg)
{
MPI_Comm child_comm;
int thread_id = *((int *) arg);
@@ -62,17 +62,17 @@ int main(int argc, char *argv[])
MPI_Comm parent;
#ifdef USE_THREADS
int provided;
- pthread_t * threads = NULL;
+ pthread_t *threads = NULL;
#else
- MPI_Comm * child;
+ MPI_Comm *child;
#endif /* USE_THREADS */
int can_spawn, errs = 0;
#ifdef USE_THREADS
CHECK_SUCCESS(MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided));
if (provided != MPI_THREAD_MULTIPLE) {
- fprintf(stderr, "MPI does not provide THREAD_MULTIPLE support\n");
- MPI_Abort(MPI_COMM_WORLD, -1);
+ fprintf(stderr, "MPI does not provide THREAD_MULTIPLE support\n");
+ MPI_Abort(MPI_COMM_WORLD, -1);
}
#else
CHECK_SUCCESS(MPI_Init(&argc, &argv));
@@ -82,81 +82,82 @@ int main(int argc, char *argv[])
if (!can_spawn) {
if (errs)
- printf( " Found %d errors\n", errs );
+ printf(" Found %d errors\n", errs);
else
- printf( " No Errors\n" );
- fflush( stdout );
+ printf(" No Errors\n");
+ fflush(stdout);
goto fn_exit;
}
CHECK_SUCCESS(MPI_Comm_get_parent(&parent));
- if (parent == MPI_COMM_NULL) { /* Parent communicator */
- if (argc == 2) {
- tasks = atoi(argv[1]);
- }
- else if (argc == 1) {
- tasks = DEFAULT_TASKS;
- }
- else {
- fprintf(stderr, "Usage: %s {number_of_tasks}\n", argv[0]);
- MPI_Abort(MPI_COMM_WORLD, -1);
- }
-
- CHECK_SUCCESS(MPI_Comm_rank(MPI_COMM_WORLD, &comm_world_rank));
- CHECK_SUCCESS(MPI_Comm_size(MPI_COMM_WORLD, &comm_world_size));
+ if (parent == MPI_COMM_NULL) { /* Parent communicator */
+ if (argc == 2) {
+ tasks = atoi(argv[1]);
+ }
+ else if (argc == 1) {
+ tasks = DEFAULT_TASKS;
+ }
+ else {
+ fprintf(stderr, "Usage: %s {number_of_tasks}\n", argv[0]);
+ MPI_Abort(MPI_COMM_WORLD, -1);
+ }
+
+ CHECK_SUCCESS(MPI_Comm_rank(MPI_COMM_WORLD, &comm_world_rank));
+ CHECK_SUCCESS(MPI_Comm_size(MPI_COMM_WORLD, &comm_world_size));
#ifdef USE_THREADS
- threads = (pthread_t *) malloc(tasks * sizeof(pthread_t));
- if (!threads) {
- fprintf(stderr, "Unable to allocate memory for threads\n");
- MPI_Abort(MPI_COMM_WORLD, -1);
- }
+ threads = (pthread_t *) malloc(tasks * sizeof(pthread_t));
+ if (!threads) {
+ fprintf(stderr, "Unable to allocate memory for threads\n");
+ MPI_Abort(MPI_COMM_WORLD, -1);
+ }
#else
- child = (MPI_Comm *) malloc(tasks * sizeof(MPI_Comm));
- if (!child) {
- fprintf(stderr, "Unable to allocate memory for child communicators\n");
- MPI_Abort(MPI_COMM_WORLD, -1);
- }
+ child = (MPI_Comm *) malloc(tasks * sizeof(MPI_Comm));
+ if (!child) {
+ fprintf(stderr, "Unable to allocate memory for child communicators\n");
+ MPI_Abort(MPI_COMM_WORLD, -1);
+ }
#endif /* USE_THREADS */
#ifdef USE_THREADS
- /* Create a thread for each task. Each thread will spawn a
- * child process to perform its task. */
- for (i = 0; i < tasks;) {
- for (j = 0; j < DEFAULT_TASK_WINDOW; j++)
- pthread_create(&threads[j], NULL, main_thread, &j);
- for (j = 0; j < DEFAULT_TASK_WINDOW; j++)
- pthread_join(threads[j], NULL);
- i += DEFAULT_TASK_WINDOW;
- }
+ /* Create a thread for each task. Each thread will spawn a
+ * child process to perform its task. */
+ for (i = 0; i < tasks;) {
+ for (j = 0; j < DEFAULT_TASK_WINDOW; j++)
+ pthread_create(&threads[j], NULL, main_thread, &j);
+ for (j = 0; j < DEFAULT_TASK_WINDOW; j++)
+ pthread_join(threads[j], NULL);
+ i += DEFAULT_TASK_WINDOW;
+ }
#else
- /* Directly spawn a child process to perform each task */
- for (i = 0; i < tasks;) {
- for (j = 0; j < DEFAULT_TASK_WINDOW; j++)
- process_spawn(&child[j], -1);
- for (j = 0; j < DEFAULT_TASK_WINDOW; j++)
- process_disconnect(&child[j], -1);
- i += DEFAULT_TASK_WINDOW;
- }
+ /* Directly spawn a child process to perform each task */
+ for (i = 0; i < tasks;) {
+ for (j = 0; j < DEFAULT_TASK_WINDOW; j++)
+ process_spawn(&child[j], -1);
+ for (j = 0; j < DEFAULT_TASK_WINDOW; j++)
+ process_disconnect(&child[j], -1);
+ i += DEFAULT_TASK_WINDOW;
+ }
#endif /* USE_THREADS */
- CHECK_SUCCESS(MPI_Barrier(MPI_COMM_WORLD));
+ CHECK_SUCCESS(MPI_Barrier(MPI_COMM_WORLD));
- if (comm_world_rank == 0)
- printf(" No Errors\n");
+ if (comm_world_rank == 0)
+ printf(" No Errors\n");
}
- else { /* Child communicator */
- /* Do some work here and send a message to the root process in
- * the parent communicator. */
- CHECK_SUCCESS(MPI_Send(NULL, 0, MPI_CHAR, 0, 1, parent));
- CHECK_SUCCESS(MPI_Recv(NULL, 0, MPI_CHAR, 0, 1, parent, MPI_STATUS_IGNORE));
- CHECK_SUCCESS(MPI_Comm_disconnect(&parent));
+ else { /* Child communicator */
+ /* Do some work here and send a message to the root process in
+ * the parent communicator. */
+ CHECK_SUCCESS(MPI_Send(NULL, 0, MPI_CHAR, 0, 1, parent));
+ CHECK_SUCCESS(MPI_Recv(NULL, 0, MPI_CHAR, 0, 1, parent, MPI_STATUS_IGNORE));
+ CHECK_SUCCESS(MPI_Comm_disconnect(&parent));
}
-fn_exit:
+ fn_exit:
#ifdef USE_THREADS
- if (threads) free(threads);
+ if (threads)
+ free(threads);
#endif
MPI_Finalize();
diff --git a/test/mpi/template.c b/test/mpi/template.c
index 801fc5e..2eb46d5 100644
--- a/test/mpi/template.c
+++ b/test/mpi/template.c
@@ -11,69 +11,68 @@
static char MTEST_Descrip[] = "";
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, err;
int rank, size, source, dest;
- int minsize = 2, count;
- MPI_Comm comm;
- MPI_Status status;
+ int minsize = 2, count;
+ MPI_Comm comm;
+ MPI_Status status;
MTestDatatype sendtype, recvtype;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- /* The following illustrates the use of the routines to
- run through a selection of communicators and datatypes.
- Use subsets of these for tests that do not involve combinations
- of communicators, datatypes, and counts of datatypes */
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
- /* Determine the sender and receiver */
- MPI_Comm_rank( comm, &rank );
- MPI_Comm_size( comm, &size );
- source = 0;
- dest = size - 1;
+ /* The following illustrates the use of the routines to
+ * run through a selection of communicators and datatypes.
+ * Use subsets of these for tests that do not involve combinations
+ * of communicators, datatypes, and counts of datatypes */
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
+ /* Determine the sender and receiver */
+ MPI_Comm_rank(comm, &rank);
+ MPI_Comm_size(comm, &size);
+ source = 0;
+ dest = size - 1;
- /* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( comm, MPI_ERRORS_RETURN );
-
- MTEST_DATATYPE_FOR_EACH_COUNT(count) {
- while (MTestGetDatatypes( &sendtype, &recvtype, count )) {
- if (rank == source) {
- sendtype.InitBuf( &sendtype );
-
- err = MPI_Send( sendtype.buf, sendtype.count,
- sendtype.datatype, dest, 0, comm );
- if (err) {
- errs++;
- MTestPrintError( err );
- }
- MTestFreeDatatype( &sendtype );
- }
- else if (rank == dest) {
- recvtype.InitBuf( &recvtype );
- err = MPI_Recv( recvtype.buf, recvtype.count,
- recvtype.datatype, source, 0, comm, &status );
- if (err) {
- errs++;
- fprintf( stderr, "Error with communicator %s and datatype %s\n",
- MTestGetIntracommName(),
- MTestGetDatatypeName( &recvtype ) );
- MTestPrintError( err );
- }
- err = MTestCheckRecv( &status, &recvtype );
- if (err) {
- errs += errs;
- }
- MTestFreeDatatype( &recvtype );
- }
- }
- }
- MTestFreeComm( &comm );
+ /* To improve reporting of problems about operations, we
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(comm, MPI_ERRORS_RETURN);
+
+ MTEST_DATATYPE_FOR_EACH_COUNT(count) {
+ while (MTestGetDatatypes(&sendtype, &recvtype, count)) {
+ if (rank == source) {
+ sendtype.InitBuf(&sendtype);
+
+ err = MPI_Send(sendtype.buf, sendtype.count, sendtype.datatype, dest, 0, comm);
+ if (err) {
+ errs++;
+ MTestPrintError(err);
+ }
+ MTestFreeDatatype(&sendtype);
+ }
+ else if (rank == dest) {
+ recvtype.InitBuf(&recvtype);
+ err = MPI_Recv(recvtype.buf, recvtype.count,
+ recvtype.datatype, source, 0, comm, &status);
+ if (err) {
+ errs++;
+ fprintf(stderr, "Error with communicator %s and datatype %s\n",
+ MTestGetIntracommName(), MTestGetDatatypeName(&recvtype));
+ MTestPrintError(err);
+ }
+ err = MTestCheckRecv(&status, &recvtype);
+ if (err) {
+ errs += errs;
+ }
+ MTestFreeDatatype(&recvtype);
+ }
+ }
+ }
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/threads/coll/allred.c b/test/mpi/threads/coll/allred.c
index 1e00c78..103a6e9 100644
--- a/test/mpi/threads/coll/allred.c
+++ b/test/mpi/threads/coll/allred.c
@@ -28,8 +28,8 @@
} \
} while (0)
-MPI_Comm comms[NUM_THREADS];
-int rank, size;
+MPI_Comm comms[NUM_THREADS];
+int rank, size;
MTEST_THREAD_RETURN_TYPE test_iallred(void *arg)
{
@@ -41,15 +41,15 @@ MTEST_THREAD_RETURN_TYPE test_iallred(void *arg)
MTestSleep(1);
MPI_Allreduce(MPI_IN_PLACE, buf, BUF_SIZE, MPI_INT, MPI_BAND, comms[tid]);
- return (MTEST_THREAD_RETURN_TYPE)0;
+ return (MTEST_THREAD_RETURN_TYPE) 0;
}
int main(int argc, char **argv)
{
- int thread_args[NUM_THREADS];
- int i, provided;
- int errs = 0;
+ int thread_args[NUM_THREADS];
+ int i, provided;
+ int errs = 0;
MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
@@ -64,7 +64,7 @@ int main(int argc, char **argv)
for (i = 0; i < NUM_THREADS; i++) {
thread_args[i] = i;
- MTest_Start_thread( test_iallred, (void *)&thread_args[i] );
+ MTest_Start_thread(test_iallred, (void *) &thread_args[i]);
}
errs = MTest_Join_threads();
diff --git a/test/mpi/threads/coll/iallred.c b/test/mpi/threads/coll/iallred.c
index e80cfc5..974d43b 100644
--- a/test/mpi/threads/coll/iallred.c
+++ b/test/mpi/threads/coll/iallred.c
@@ -28,8 +28,8 @@
} \
} while (0)
-MPI_Comm comms[NUM_THREADS];
-int rank, size;
+MPI_Comm comms[NUM_THREADS];
+int rank, size;
MTEST_THREAD_RETURN_TYPE test_iallred(void *arg)
{
@@ -42,15 +42,15 @@ MTEST_THREAD_RETURN_TYPE test_iallred(void *arg)
MPI_Iallreduce(MPI_IN_PLACE, buf, BUF_SIZE, MPI_INT, MPI_BAND, comms[tid], &req);
MPI_Wait(&req, MPI_STATUS_IGNORE);
- return (MTEST_THREAD_RETURN_TYPE)0;
+ return (MTEST_THREAD_RETURN_TYPE) 0;
}
int main(int argc, char **argv)
{
- int thread_args[NUM_THREADS];
- int i, provided;
- int errs = 0;
+ int thread_args[NUM_THREADS];
+ int i, provided;
+ int errs = 0;
MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
@@ -65,7 +65,7 @@ int main(int argc, char **argv)
for (i = 0; i < NUM_THREADS; i++) {
thread_args[i] = i;
- MTest_Start_thread( test_iallred, (void *)&thread_args[i] );
+ MTest_Start_thread(test_iallred, (void *) &thread_args[i]);
}
errs = MTest_Join_threads();
diff --git a/test/mpi/threads/comm/comm_create_group_threads.c b/test/mpi/threads/comm/comm_create_group_threads.c
index 77276df..9eaeaf9 100644
--- a/test/mpi/threads/comm/comm_create_group_threads.c
+++ b/test/mpi/threads/comm/comm_create_group_threads.c
@@ -20,20 +20,20 @@
} \
} while (0)
-MPI_Comm comms[NUM_THREADS];
+MPI_Comm comms[NUM_THREADS];
MTEST_THREAD_LOCK_TYPE comm_lock;
-int rank, size;
-int verbose = 0;
+int rank, size;
+int verbose = 0;
MTEST_THREAD_RETURN_TYPE test_comm_create_group(void *arg)
{
int i;
for (i = 0; i < NUM_ITER; i++) {
- MPI_Group world_group;
- MPI_Comm comm, self_dup;
+ MPI_Group world_group;
+ MPI_Comm comm, self_dup;
- MPI_Comm_group(comms[*(int*)arg], &world_group);
+ MPI_Comm_group(comms[*(int *) arg], &world_group);
/* Every thread paticipates in a distinct MPI_Comm_create group,
* distinguished by its thread-id (used as the tag). Threads on even
@@ -41,11 +41,13 @@ MTEST_THREAD_RETURN_TYPE test_comm_create_group(void *arg)
*/
#ifndef USE_STRICT_MPI
- if (verbose) printf("%d: Thread %d - Comm_create_group %d start\n", rank, *(int*)arg, i);
- MPI_Comm_create_group(comms[*(int*)arg], world_group, *(int*)arg /* tag */, &comm);
+ if (verbose)
+ printf("%d: Thread %d - Comm_create_group %d start\n", rank, *(int *) arg, i);
+ MPI_Comm_create_group(comms[*(int *) arg], world_group, *(int *) arg /* tag */ , &comm);
MPI_Barrier(comm);
MPI_Comm_free(&comm);
- if (verbose) printf("%d: Thread %d - Comm_create_group %d finish\n", rank, *(int*)arg, i);
+ if (verbose)
+ printf("%d: Thread %d - Comm_create_group %d finish\n", rank, *(int *) arg, i);
#endif /* USE_STRICT_MPI */
MPI_Group_free(&world_group);
@@ -56,24 +58,27 @@ MTEST_THREAD_RETURN_TYPE test_comm_create_group(void *arg)
* collective semantics.
*/
MTest_thread_lock(&comm_lock);
- if (verbose) printf("%d: Thread %d - Comm_dup %d start\n", rank, *(int*)arg, i);
+ if (verbose)
+ printf("%d: Thread %d - Comm_dup %d start\n", rank, *(int *) arg, i);
MPI_Comm_dup(MPI_COMM_SELF, &self_dup);
- if (verbose) printf("%d: Thread %d - Comm_dup %d finish\n", rank, *(int*)arg, i);
+ if (verbose)
+ printf("%d: Thread %d - Comm_dup %d finish\n", rank, *(int *) arg, i);
MTest_thread_unlock(&comm_lock);
MPI_Barrier(self_dup);
MPI_Comm_free(&self_dup);
}
- if (verbose) printf("%d: Thread %d - Done.\n", rank, *(int*)arg);
+ if (verbose)
+ printf("%d: Thread %d - Done.\n", rank, *(int *) arg);
return NULL;
}
int main(int argc, char **argv)
{
- int thread_args[NUM_THREADS];
- int i, err, provided;
+ int thread_args[NUM_THREADS];
+ int i, err, provided;
MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
@@ -90,7 +95,7 @@ int main(int argc, char **argv)
for (i = 0; i < NUM_THREADS; i++) {
thread_args[i] = i;
- MTest_Start_thread( test_comm_create_group, (void *)&thread_args[i] );
+ MTest_Start_thread(test_comm_create_group, (void *) &thread_args[i]);
}
MTest_Join_threads();
diff --git a/test/mpi/threads/comm/comm_create_threads.c b/test/mpi/threads/comm/comm_create_threads.c
index 95f868a..2b04011 100644
--- a/test/mpi/threads/comm/comm_create_threads.c
+++ b/test/mpi/threads/comm/comm_create_threads.c
@@ -20,25 +20,25 @@
} \
} while (0)
-MPI_Comm comms[NUM_THREADS];
-int rank, size;
+MPI_Comm comms[NUM_THREADS];
+int rank, size;
MTEST_THREAD_RETURN_TYPE test_comm_create(void *arg)
{
int i;
for (i = 0; i < NUM_ITER; i++) {
- MPI_Group world_group;
- MPI_Comm comm;
+ MPI_Group world_group;
+ MPI_Comm comm;
- MPI_Comm_group(comms[*(int*)arg], &world_group);
+ MPI_Comm_group(comms[*(int *) arg], &world_group);
/* Every thread paticipates in a distinct MPI_Comm_create on distinct
* communicators. Thus, there is no violation of MPI threads +
* communicators semantics.
*/
- MPI_Comm_create(comms[*(int*)arg], world_group, &comm);
+ MPI_Comm_create(comms[*(int *) arg], world_group, &comm);
MPI_Barrier(comm);
MPI_Comm_free(&comm);
@@ -52,8 +52,8 @@ MTEST_THREAD_RETURN_TYPE test_comm_create(void *arg)
int main(int argc, char **argv)
{
- int thread_args[NUM_THREADS];
- int i, err, provided;
+ int thread_args[NUM_THREADS];
+ int i, err, provided;
MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
@@ -68,7 +68,7 @@ int main(int argc, char **argv)
for (i = 0; i < NUM_THREADS; i++) {
thread_args[i] = i;
- MTest_Start_thread( test_comm_create, (void *)&thread_args[i] );
+ MTest_Start_thread(test_comm_create, (void *) &thread_args[i]);
}
MTest_Join_threads();
diff --git a/test/mpi/threads/comm/comm_dup_deadlock.c b/test/mpi/threads/comm/comm_dup_deadlock.c
index 1bfc29a..36b33cf 100644
--- a/test/mpi/threads/comm/comm_dup_deadlock.c
+++ b/test/mpi/threads/comm/comm_dup_deadlock.c
@@ -20,48 +20,53 @@
} \
} while (0)
-MPI_Comm comms[NUM_THREADS];
+MPI_Comm comms[NUM_THREADS];
MTEST_THREAD_LOCK_TYPE comm_lock;
-int rank, size;
-int verbose = 0;
+int rank, size;
+int verbose = 0;
MTEST_THREAD_RETURN_TYPE test_comm_dup(void *arg)
{
int rank;
int i;
- MPI_Comm_rank(comms[*(int*)arg], &rank);
+ MPI_Comm_rank(comms[*(int *) arg], &rank);
for (i = 0; i < NUM_ITER; i++) {
- MPI_Comm comm, self_dup;
+ MPI_Comm comm, self_dup;
- if (*(int*)arg == rank) {
+ if (*(int *) arg == rank) {
MTestSleep(1);
}
MTest_thread_lock(&comm_lock);
- if (verbose) printf("%d: Thread %d - Comm_dup %d start\n", rank, *(int*)arg, i);
+ if (verbose)
+ printf("%d: Thread %d - Comm_dup %d start\n", rank, *(int *) arg, i);
MPI_Comm_dup(MPI_COMM_SELF, &self_dup);
- if (verbose) printf("%d: Thread %d - Comm_dup %d finish\n", rank, *(int*)arg, i);
+ if (verbose)
+ printf("%d: Thread %d - Comm_dup %d finish\n", rank, *(int *) arg, i);
MTest_thread_unlock(&comm_lock);
MPI_Comm_free(&self_dup);
- if (verbose) printf("%d: Thread %d - comm_dup %d start\n", rank, *(int*)arg, i);
- MPI_Comm_dup(comms[*(int*)arg], &comm);
+ if (verbose)
+ printf("%d: Thread %d - comm_dup %d start\n", rank, *(int *) arg, i);
+ MPI_Comm_dup(comms[*(int *) arg], &comm);
MPI_Comm_free(&comm);
- if (verbose) printf("%d: Thread %d - comm_dup %d finish\n", rank, *(int*)arg, i);
+ if (verbose)
+ printf("%d: Thread %d - comm_dup %d finish\n", rank, *(int *) arg, i);
}
- if (verbose) printf("%d: Thread %d - Done.\n", rank, *(int*)arg);
- return (MTEST_THREAD_RETURN_TYPE)0;
+ if (verbose)
+ printf("%d: Thread %d - Done.\n", rank, *(int *) arg);
+ return (MTEST_THREAD_RETURN_TYPE) 0;
}
int main(int argc, char **argv)
{
- int thread_args[NUM_THREADS];
- int i, provided;
+ int thread_args[NUM_THREADS];
+ int i, provided;
MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
@@ -78,7 +83,7 @@ int main(int argc, char **argv)
for (i = 0; i < NUM_THREADS; i++) {
thread_args[i] = i;
- MTest_Start_thread( test_comm_dup, (void *)&thread_args[i] );
+ MTest_Start_thread(test_comm_dup, (void *) &thread_args[i]);
}
MTest_Join_threads();
diff --git a/test/mpi/threads/comm/comm_idup.c b/test/mpi/threads/comm/comm_idup.c
index 1a183ee..a1a64bb 100644
--- a/test/mpi/threads/comm/comm_idup.c
+++ b/test/mpi/threads/comm/comm_idup.c
@@ -20,10 +20,10 @@
} \
} while (0)
-MPI_Comm comms[NUM_THREADS];
+MPI_Comm comms[NUM_THREADS];
MTEST_THREAD_LOCK_TYPE comm_lock;
-int rank, size;
-int verbose = 0;
+int rank, size;
+int verbose = 0;
MTEST_THREAD_RETURN_TYPE test_comm_dup(void *arg)
{
@@ -31,39 +31,44 @@ MTEST_THREAD_RETURN_TYPE test_comm_dup(void *arg)
int i;
MPI_Request req;
- MPI_Comm_rank(comms[*(int*)arg], &rank);
+ MPI_Comm_rank(comms[*(int *) arg], &rank);
for (i = 0; i < NUM_ITER; i++) {
- MPI_Comm comm, self_dup;
+ MPI_Comm comm, self_dup;
- if (*(int*)arg == rank) {
+ if (*(int *) arg == rank) {
MTestSleep(1);
}
MTest_thread_lock(&comm_lock);
- if (verbose) printf("%d: Thread %d - COMM_IDUP %d start\n", rank, *(int*)arg, i);
+ if (verbose)
+ printf("%d: Thread %d - COMM_IDUP %d start\n", rank, *(int *) arg, i);
MPI_Comm_idup(MPI_COMM_SELF, &self_dup, &req);
MPI_Wait(&req, MPI_STATUS_IGNORE);
- if (verbose) printf("\t%d: Thread %d - COMM_IDUP %d finish\n", rank, *(int*)arg, i);
+ if (verbose)
+ printf("\t%d: Thread %d - COMM_IDUP %d finish\n", rank, *(int *) arg, i);
MTest_thread_unlock(&comm_lock);
MPI_Comm_free(&self_dup);
- if (verbose) printf("%d: Thread %d - comm_idup %d start\n", rank, *(int*)arg, i);
- MPI_Comm_idup(comms[*(int*)arg], &comm, &req);
+ if (verbose)
+ printf("%d: Thread %d - comm_idup %d start\n", rank, *(int *) arg, i);
+ MPI_Comm_idup(comms[*(int *) arg], &comm, &req);
MPI_Wait(&req, MPI_STATUS_IGNORE);
MPI_Comm_free(&comm);
- if (verbose) printf("\t%d: Thread %d - comm_idup %d finish\n", rank, *(int*)arg, i);
+ if (verbose)
+ printf("\t%d: Thread %d - comm_idup %d finish\n", rank, *(int *) arg, i);
}
- if (verbose) printf("%d: Thread %d - Done.\n", rank, *(int*)arg);
- return (MTEST_THREAD_RETURN_TYPE)0;
+ if (verbose)
+ printf("%d: Thread %d - Done.\n", rank, *(int *) arg);
+ return (MTEST_THREAD_RETURN_TYPE) 0;
}
int main(int argc, char **argv)
{
- int thread_args[NUM_THREADS];
- int i, provided;
+ int thread_args[NUM_THREADS];
+ int i, provided;
MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
@@ -80,7 +85,7 @@ int main(int argc, char **argv)
for (i = 0; i < NUM_THREADS; i++) {
thread_args[i] = i;
- MTest_Start_thread( test_comm_dup, (void *)&thread_args[i] );
+ MTest_Start_thread(test_comm_dup, (void *) &thread_args[i]);
}
MTest_Join_threads();
diff --git a/test/mpi/threads/comm/ctxdup.c b/test/mpi/threads/comm/ctxdup.c
index 6d3aaa8..c45c664 100644
--- a/test/mpi/threads/comm/ctxdup.c
+++ b/test/mpi/threads/comm/ctxdup.c
@@ -20,29 +20,28 @@ MTEST_THREAD_RETURN_TYPE dup_thread(void *p)
{
int rank;
int buffer[1];
- MPI_Comm *comm2_ptr = (MPI_Comm *)p;
+ MPI_Comm *comm2_ptr = (MPI_Comm *) p;
MPI_Comm comm3;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank & 0x1) {
- /* If odd, wait for message */
- MPI_Recv( buffer, 0, MPI_INT, rank, 0, MPI_COMM_WORLD,
- MPI_STATUS_IGNORE );
+ /* If odd, wait for message */
+ MPI_Recv(buffer, 0, MPI_INT, rank, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
}
- MPI_Comm_dup( *comm2_ptr, &comm3 );
+ MPI_Comm_dup(*comm2_ptr, &comm3);
- MPI_Barrier( comm3 );
- MPI_Recv( buffer, 0, MPI_INT, rank, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE );
-
- MPI_Comm_free( &comm3 );
+ MPI_Barrier(comm3);
+ MPI_Recv(buffer, 0, MPI_INT, rank, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+
+ MPI_Comm_free(&comm3);
/* Tell the main thread that we're done */
- MPI_Send( buffer, 0, MPI_INT, rank, 2, MPI_COMM_WORLD );
+ MPI_Send(buffer, 0, MPI_INT, rank, 2, MPI_COMM_WORLD);
- return (MTEST_THREAD_RETURN_TYPE)0;
+ return (MTEST_THREAD_RETURN_TYPE) 0;
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int rank, size;
int provided;
@@ -56,45 +55,46 @@ int main( int argc, char *argv[] )
/* Check that we're multi-threaded */
if (provided != MPI_THREAD_MULTIPLE) {
- if (rank == 0) {
- printf("MPI_Init_thread must return MPI_THREAD_MULTIPLE in order for this test to run.\n");
- fflush(stdout);
- }
- MPI_Finalize();
- return 1;
+ if (rank == 0) {
+ printf
+ ("MPI_Init_thread must return MPI_THREAD_MULTIPLE in order for this test to run.\n");
+ fflush(stdout);
+ }
+ MPI_Finalize();
+ return 1;
}
/* The test is this:
- The main thread on ODD processors tells the other thread to start
- a comm dup(on comm2), then starts a comm dup(on comm1) after a delay.
- The main thread on even processors starts a comm dup(on comm1)
-
- The second thread on ODD processors waits until it gets a message
- (from the same process) before starting the comm dup on comm2.
- */
+ * The main thread on ODD processors tells the other thread to start
+ * a comm dup(on comm2), then starts a comm dup(on comm1) after a delay.
+ * The main thread on even processors starts a comm dup(on comm1)
+ *
+ * The second thread on ODD processors waits until it gets a message
+ * (from the same process) before starting the comm dup on comm2.
+ */
/* Create two communicators */
- MPI_Comm_dup( MPI_COMM_WORLD, &comm1 );
- MPI_Comm_dup( MPI_COMM_WORLD, &comm2 );
+ MPI_Comm_dup(MPI_COMM_WORLD, &comm1);
+ MPI_Comm_dup(MPI_COMM_WORLD, &comm2);
/* Start a thread that will perform a dup comm2 */
- MTest_Start_thread( dup_thread, (void *)&comm2 );
+ MTest_Start_thread(dup_thread, (void *) &comm2);
/* If we're odd, send to our new thread and then delay */
if (rank & 0x1) {
- MPI_Ssend( buffer, 0, MPI_INT, rank, 0, MPI_COMM_WORLD );
- MTestSleep(1);
+ MPI_Ssend(buffer, 0, MPI_INT, rank, 0, MPI_COMM_WORLD);
+ MTestSleep(1);
}
- MPI_Comm_dup( comm1, &comm4 );
+ MPI_Comm_dup(comm1, &comm4);
/* Tell the threads to exit after we've created our new comm */
- MPI_Barrier( comm4 );
- MPI_Ssend( buffer, 0, MPI_INT, rank, 1, MPI_COMM_WORLD );
- MPI_Recv( buffer, 0, MPI_INT, rank, 2, MPI_COMM_WORLD, MPI_STATUS_IGNORE );
+ MPI_Barrier(comm4);
+ MPI_Ssend(buffer, 0, MPI_INT, rank, 1, MPI_COMM_WORLD);
+ MPI_Recv(buffer, 0, MPI_INT, rank, 2, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
- MPI_Comm_free( &comm4 );
- MPI_Comm_free( &comm1 );
- MPI_Comm_free( &comm2 );
+ MPI_Comm_free(&comm4);
+ MPI_Comm_free(&comm1);
+ MPI_Comm_free(&comm2);
MTest_Finalize(0);
MPI_Finalize();
diff --git a/test/mpi/threads/comm/ctxidup.c b/test/mpi/threads/comm/ctxidup.c
index b13fd91..b6308d9 100644
--- a/test/mpi/threads/comm/ctxidup.c
+++ b/test/mpi/threads/comm/ctxidup.c
@@ -20,7 +20,7 @@ MTEST_THREAD_RETURN_TYPE dup_thread(void *p)
{
int rank;
int buffer[1];
- MPI_Comm *comm2_ptr = (MPI_Comm *)p;
+ MPI_Comm *comm2_ptr = (MPI_Comm *) p;
MPI_Comm comm3;
MPI_Request req;
@@ -28,23 +28,22 @@ MTEST_THREAD_RETURN_TYPE dup_thread(void *p)
if (rank & 0x1) {
/* If odd, wait for message */
- MPI_Recv( buffer, 0, MPI_INT, rank, 0, MPI_COMM_WORLD,
- MPI_STATUS_IGNORE );
+ MPI_Recv(buffer, 0, MPI_INT, rank, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
}
- MPI_Comm_idup( *comm2_ptr, &comm3, &req );
+ MPI_Comm_idup(*comm2_ptr, &comm3, &req);
MPI_Wait(&req, MPI_STATUS_IGNORE);
- MPI_Barrier( comm3 );
- MPI_Recv( buffer, 0, MPI_INT, rank, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE );
+ MPI_Barrier(comm3);
+ MPI_Recv(buffer, 0, MPI_INT, rank, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
- MPI_Comm_free( &comm3 );
+ MPI_Comm_free(&comm3);
/* Tell the main thread that we're done */
- MPI_Send( buffer, 0, MPI_INT, rank, 2, MPI_COMM_WORLD );
+ MPI_Send(buffer, 0, MPI_INT, rank, 2, MPI_COMM_WORLD);
- return (MTEST_THREAD_RETURN_TYPE)0;
+ return (MTEST_THREAD_RETURN_TYPE) 0;
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int rank, size;
int provided;
@@ -59,7 +58,8 @@ int main( int argc, char *argv[] )
/* Check that we're multi-threaded */
if (provided != MPI_THREAD_MULTIPLE) {
if (rank == 0) {
- printf("MPI_Init_thread must return MPI_THREAD_MULTIPLE in order for this test to run.\n");
+ printf
+ ("MPI_Init_thread must return MPI_THREAD_MULTIPLE in order for this test to run.\n");
fflush(stdout);
}
MPI_Finalize();
@@ -67,36 +67,36 @@ int main( int argc, char *argv[] )
}
/* The test is this:
- The main thread on ODD processors tells the other thread to start
- a comm dup(on comm2), then starts a comm dup(on comm1) after a delay.
- The main thread on even processors starts a comm dup(on comm1)
-
- The second thread on ODD processors waits until it gets a message
- (from the same process) before starting the comm dup on comm2.
- */
+ * The main thread on ODD processors tells the other thread to start
+ * a comm dup(on comm2), then starts a comm dup(on comm1) after a delay.
+ * The main thread on even processors starts a comm dup(on comm1)
+ *
+ * The second thread on ODD processors waits until it gets a message
+ * (from the same process) before starting the comm dup on comm2.
+ */
/* Create two communicators */
- MPI_Comm_dup( MPI_COMM_WORLD, &comm1 );
- MPI_Comm_dup( MPI_COMM_WORLD, &comm2 );
+ MPI_Comm_dup(MPI_COMM_WORLD, &comm1);
+ MPI_Comm_dup(MPI_COMM_WORLD, &comm2);
/* Start a thread that will perform a dup comm2 */
- MTest_Start_thread( dup_thread, (void *)&comm2 );
+ MTest_Start_thread(dup_thread, (void *) &comm2);
/* If we're odd, send to our new thread and then delay */
if (rank & 0x1) {
- MPI_Ssend( buffer, 0, MPI_INT, rank, 0, MPI_COMM_WORLD );
+ MPI_Ssend(buffer, 0, MPI_INT, rank, 0, MPI_COMM_WORLD);
MTestSleep(1);
}
- MPI_Comm_dup( comm1, &comm4 );
+ MPI_Comm_dup(comm1, &comm4);
/* Tell the threads to exit after we've created our new comm */
- MPI_Barrier( comm4 );
- MPI_Ssend( buffer, 0, MPI_INT, rank, 1, MPI_COMM_WORLD );
- MPI_Recv( buffer, 0, MPI_INT, rank, 2, MPI_COMM_WORLD, MPI_STATUS_IGNORE );
+ MPI_Barrier(comm4);
+ MPI_Ssend(buffer, 0, MPI_INT, rank, 1, MPI_COMM_WORLD);
+ MPI_Recv(buffer, 0, MPI_INT, rank, 2, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
- MPI_Comm_free( &comm4 );
- MPI_Comm_free( &comm1 );
- MPI_Comm_free( &comm2 );
+ MPI_Comm_free(&comm4);
+ MPI_Comm_free(&comm1);
+ MPI_Comm_free(&comm2);
MTest_Finalize(0);
MPI_Finalize();
diff --git a/test/mpi/threads/comm/dup_leak_test.c b/test/mpi/threads/comm/dup_leak_test.c
index 9803856..5fa7ce5 100644
--- a/test/mpi/threads/comm/dup_leak_test.c
+++ b/test/mpi/threads/comm/dup_leak_test.c
@@ -28,13 +28,13 @@ MTEST_THREAD_RETURN_TYPE do_thread(void *v);
MTEST_THREAD_RETURN_TYPE do_thread(void *v)
{
int x;
- MPI_Comm comm = *(MPI_Comm*)v;
+ MPI_Comm comm = *(MPI_Comm *) v;
MPI_Comm newcomm;
for (x = 0; x < NITER; ++x) {
MPI_Comm_dup(comm, &newcomm);
MPI_Comm_free(&newcomm);
}
- return (MTEST_THREAD_RETURN_TYPE)0;
+ return (MTEST_THREAD_RETURN_TYPE) 0;
}
int main(int argc, char **argv)
@@ -54,7 +54,7 @@ int main(int argc, char **argv)
for (x = 0; x < NTHREADS; ++x) {
MPI_Comm_dup(MPI_COMM_WORLD, &comms[x]);
if (x != 0) {
- err = MTest_Start_thread(do_thread, (void *)&comms[x]);
+ err = MTest_Start_thread(do_thread, (void *) &comms[x]);
if (err) {
/* attempt to continue with fewer threads, we may be on a
* thread-constrained platform like BG/P in DUAL mode */
@@ -70,7 +70,7 @@ int main(int argc, char **argv)
goto fn_fail;
}
- do_thread((void *)&comms[0]); /* we are thread 0 */
+ do_thread((void *) &comms[0]); /* we are thread 0 */
err = MTest_Join_threads();
if (err) {
@@ -82,12 +82,11 @@ int main(int argc, char **argv)
MPI_Comm_free(&comms[x]);
}
-fn_exit:
+ fn_exit:
MTest_Finalize(err);
MPI_Finalize();
return 0;
-fn_fail:
+ fn_fail:
err = 1;
goto fn_exit;
}
-
diff --git a/test/mpi/threads/comm/idup_comm_gen.c b/test/mpi/threads/comm/idup_comm_gen.c
index ca09cc9..f926ff9 100644
--- a/test/mpi/threads/comm/idup_comm_gen.c
+++ b/test/mpi/threads/comm/idup_comm_gen.c
@@ -18,7 +18,8 @@
#define NUM_IDUPS 5
MPI_Comm comms[NUM_THREADS];
-MPI_Comm errs[NUM_THREADS] = {0};
+MPI_Comm errs[NUM_THREADS] = { 0 };
+
int verbose = 0;
MTEST_THREAD_RETURN_TYPE test_idup(void *arg)
@@ -28,7 +29,7 @@ MTEST_THREAD_RETURN_TYPE test_idup(void *arg)
int ranges[1][3];
int rleader, isLeft;
int *excl = NULL;
- int tid = *(int*)arg;
+ int tid = *(int *) arg;
MPI_Group ingroup, high_group, even_group;
MPI_Comm local_comm, inter_comm;
@@ -55,13 +56,13 @@ MTEST_THREAD_RETURN_TYPE test_idup(void *arg)
MTestFreeComm(&outcomm);
/* Comm_split */
- MPI_Comm_split(incomm, rank%2, size-rank, &outcomm);
+ MPI_Comm_split(incomm, rank % 2, size - rank, &outcomm);
errs[tid] += MTestTestComm(outcomm);
MTestFreeComm(&outcomm);
- /* Comm_create, high half of incomm */
- ranges[0][0] = size/2;
- ranges[0][1] = size-1;
+ /* Comm_create, high half of incomm */
+ ranges[0][0] = size / 2;
+ ranges[0][1] = size - 1;
ranges[0][2] = 1;
MPI_Group_range_incl(ingroup, 1, ranges, &high_group);
MPI_Comm_create(incomm, high_group, &outcomm);
@@ -71,16 +72,18 @@ MTEST_THREAD_RETURN_TYPE test_idup(void *arg)
/* Comm_create_group, even ranks of incomm */
/* exclude the odd ranks */
- excl = malloc((size/2) * sizeof(int));
- for (i = 0; i < size / 2; i++) excl[i] = (2 * i) + 1;
+ excl = malloc((size / 2) * sizeof(int));
+ for (i = 0; i < size / 2; i++)
+ excl[i] = (2 * i) + 1;
MPI_Group_excl(ingroup, size / 2, excl, &even_group);
free(excl);
if (rank % 2 == 0) {
MPI_Comm_create_group(incomm, even_group, 0, &outcomm);
- } else {
- outcomm = MPI_COMM_NULL;
+ }
+ else {
+ outcomm = MPI_COMM_NULL;
}
MPI_Group_free(&even_group);
@@ -88,12 +91,18 @@ MTEST_THREAD_RETURN_TYPE test_idup(void *arg)
MTestFreeComm(&outcomm);
/* Intercomm_create & Intercomm_merge */
- MPI_Comm_split(incomm, (rank < size/2), rank, &local_comm);
+ MPI_Comm_split(incomm, (rank < size / 2), rank, &local_comm);
- if (rank == 0) { rleader = size/2; }
- else if (rank == size/2) { rleader = 0; }
- else { rleader = -1; }
- isLeft = rank < size/2;
+ if (rank == 0) {
+ rleader = size / 2;
+ }
+ else if (rank == size / 2) {
+ rleader = 0;
+ }
+ else {
+ rleader = -1;
+ }
+ isLeft = rank < size / 2;
MPI_Intercomm_create(local_comm, 0, incomm, rleader, 99, &inter_comm);
MPI_Intercomm_merge(inter_comm, isLeft, &outcomm);
@@ -143,7 +152,7 @@ int main(int argc, char **argv)
for (i = 0; i < NUM_THREADS; i++) {
thread_args[i] = i;
- MTest_Start_thread(test_idup, (void *)&thread_args[i] );
+ MTest_Start_thread(test_idup, (void *) &thread_args[i]);
}
MTest_Join_threads();
diff --git a/test/mpi/threads/comm/idup_nb.c b/test/mpi/threads/comm/idup_nb.c
index b38aeda..88b7df4 100644
--- a/test/mpi/threads/comm/idup_nb.c
+++ b/test/mpi/threads/comm/idup_nb.c
@@ -20,8 +20,8 @@
#include "mpithreadtest.h"
#define NUM_THREADS 3 /* threads to spawn per process, must >= 1 */
-#define NUM_IDUPS1 3 /* child communicators to iduplicate per thread, must >= 1*/
-#define NUM_IDUPS2 3 /* grandchild communicators to iduplicate per thread, must >= 1*/
+#define NUM_IDUPS1 3 /* child communicators to iduplicate per thread, must >= 1 */
+#define NUM_IDUPS2 3 /* grandchild communicators to iduplicate per thread, must >= 1 */
#define NUM_ITER 1 /* run the kernel this times */
#define check(X_) \
@@ -32,10 +32,11 @@
} \
} while (0)
-int isLeft; /* Is left group of an intercomm? */
+int isLeft; /* Is left group of an intercomm? */
MPI_Comm parentcomms[NUM_THREADS];
MPI_Comm nbrcomms[NUM_THREADS];
-int errs[NUM_THREADS] = {0};
+int errs[NUM_THREADS] = { 0 };
+
int verbose = 0;
/* Threads idup the communicator assigned to them NUM_IDUPS1 times. The operation
@@ -48,19 +49,21 @@ MTEST_THREAD_RETURN_TYPE test_intracomm(void *arg)
int root, bcastbuf;
int rank, size;
int ans[4], expected[4];
- MPI_Request reqs[NUM_IDUPS1 + NUM_IDUPS2 + 10] = { MPI_REQUEST_NULL }; /* Preallocate enough reqs */
- MPI_Comm comms[NUM_IDUPS1 + NUM_IDUPS2]; /* Hold all descendant comms */
+ MPI_Request reqs[NUM_IDUPS1 + NUM_IDUPS2 + 10] = { MPI_REQUEST_NULL }; /* Preallocate enough reqs */
+ MPI_Comm comms[NUM_IDUPS1 + NUM_IDUPS2]; /* Hold all descendant comms */
int cnt;
- int tid = *(int*)arg;
+ int tid = *(int *) arg;
MPI_Comm parentcomm = parentcomms[tid];
MPI_Comm nbrcomm = nbrcomms[tid];
for (i = 0; i < NUM_ITER; i++) {
cnt = 0;
- if (*(int*)arg == rank) MTestSleep(1);
+ if (*(int *) arg == rank)
+ MTestSleep(1);
- if (verbose) printf("%d: Thread %d - comm_idup %d start\n", rank, tid, i);
+ if (verbose)
+ printf("%d: Thread %d - comm_idup %d start\n", rank, tid, i);
/* Idup the parent intracomm NUM_IDUPS1 times */
for (j = 0; j < NUM_IDUPS1; j++)
@@ -69,22 +72,22 @@ MTEST_THREAD_RETURN_TYPE test_intracomm(void *arg)
/* Issue an iscan on parent comm to overlap with the pending idups */
MPI_Comm_rank(parentcomm, &rank);
MPI_Iscan(&rank, &ans[0], 1, MPI_INT, MPI_SUM, parentcomm, &reqs[cnt++]);
- expected[0] = rank*(rank+1)/2;
+ expected[0] = rank * (rank + 1) / 2;
/* Wait for the first child comm to be ready */
MPI_Wait(&reqs[0], MPI_STATUS_IGNORE);
/* Do Idups & iallreduce on the first child comm simultaneously */
for (j = 0; j < NUM_IDUPS2; j++)
- MPI_Comm_idup(comms[0], &comms[NUM_IDUPS1+j], &reqs[cnt++]);
+ MPI_Comm_idup(comms[0], &comms[NUM_IDUPS1 + j], &reqs[cnt++]);
MPI_Comm_size(comms[0], &size);
MPI_Iallreduce(&rank, &ans[1], 1, MPI_INT, MPI_SUM, comms[0], &reqs[cnt++]);
- expected[1] = (size-1)*size/2;
+ expected[1] = (size - 1) * size / 2;
/* Issue an ibcast on the parent comm */
MPI_Comm_rank(parentcomm, &rank);
- ans[2] = (rank == 0)? 199 : 111;
+ ans[2] = (rank == 0) ? 199 : 111;
MPI_Ibcast(&ans[2], 1, MPI_INT, 0, parentcomm, &reqs[cnt++]);
expected[2] = 199;
@@ -94,29 +97,32 @@ MTEST_THREAD_RETURN_TYPE test_intracomm(void *arg)
/* Issue an iscan on a neighbor comm */
MPI_Comm_rank(nbrcomm, &rank);
MPI_Iscan(&rank, &ans[3], 1, MPI_INT, MPI_SUM, nbrcomm, &reqs[cnt++]);
- expected[3] = rank*(rank+1)/2;
+ expected[3] = rank * (rank + 1) / 2;
/* Pending operations include idup/iscan/ibcast on parentcomm
- idup/Iallreduce/Ibarrier on comms[0], and Iscan on nbrcomm */
+ * idup/Iallreduce/Ibarrier on comms[0], and Iscan on nbrcomm */
/* Waitall even if the first request is completed */
MPI_Waitall(cnt, reqs, MPI_STATUSES_IGNORE);
/* Check the answers */
for (j = 0; j < 4; j++) {
- if (ans[j] != expected[j]) errs[tid]++;
+ if (ans[j] != expected[j])
+ errs[tid]++;
}
for (j = 0; j < NUM_IDUPS1 + NUM_IDUPS2; j++) {
- errs[tid] += MTestTestComm(comms[j]);
- MPI_Comm_free(&comms[j]);
+ errs[tid] += MTestTestComm(comms[j]);
+ MPI_Comm_free(&comms[j]);
}
- if (verbose) printf("\t%d: Thread %d - comm_idup %d finish\n", rank, tid, i);
+ if (verbose)
+ printf("\t%d: Thread %d - comm_idup %d finish\n", rank, tid, i);
}
- if (verbose) printf("%d: Thread %d - Done.\n", rank, tid);
- return (MTEST_THREAD_RETURN_TYPE)0;
+ if (verbose)
+ printf("%d: Thread %d - Done.\n", rank, tid);
+ return (MTEST_THREAD_RETURN_TYPE) 0;
}
/* Threads idup the communicator assigned to them NUM_IDUPS1 times. The operation
@@ -127,20 +133,22 @@ MTEST_THREAD_RETURN_TYPE test_intercomm(void *arg)
{
int rank, rsize, root;
int i, j;
- int tid = *(int*)arg;
+ int tid = *(int *) arg;
int ans[4], expected[4];
MPI_Comm parentcomm = parentcomms[tid];
MPI_Comm nbrcomm = nbrcomms[tid];
- MPI_Request reqs[NUM_IDUPS1 + NUM_IDUPS2 + 10] = { MPI_REQUEST_NULL }; /* Preallocate enough reqs */
- MPI_Comm comms[NUM_IDUPS1 + NUM_IDUPS2]; /* Hold all descendant comms */
+ MPI_Request reqs[NUM_IDUPS1 + NUM_IDUPS2 + 10] = { MPI_REQUEST_NULL }; /* Preallocate enough reqs */
+ MPI_Comm comms[NUM_IDUPS1 + NUM_IDUPS2]; /* Hold all descendant comms */
int cnt;
for (i = 0; i < NUM_ITER; i++) {
cnt = 0;
- if (*(int*)arg == rank) MTestSleep(1);
+ if (*(int *) arg == rank)
+ MTestSleep(1);
- if (verbose) printf("%d: Thread %d - comm_idup %d start\n", rank, tid, i);
+ if (verbose)
+ printf("%d: Thread %d - comm_idup %d start\n", rank, tid, i);
/* Idup the parent intracomm multiple times */
for (j = 0; j < NUM_IDUPS1; j++)
@@ -150,33 +158,35 @@ MTEST_THREAD_RETURN_TYPE test_intercomm(void *arg)
MPI_Comm_rank(parentcomm, &rank);
MPI_Comm_remote_size(parentcomm, &rsize);
MPI_Iallreduce(&rank, &ans[0], 1, MPI_INT, MPI_SUM, parentcomm, &reqs[cnt++]);
- expected[0] = (rsize-1)*rsize/2;
+ expected[0] = (rsize - 1) * rsize / 2;
/* Wait for the first child comm to be ready */
MPI_Wait(&reqs[0], MPI_STATUS_IGNORE);
/* Do idup & iallreduce on the first child comm simultaneously */
for (j = 0; j < NUM_IDUPS2; j++)
- MPI_Comm_idup(comms[0], &comms[NUM_IDUPS1+j], &reqs[cnt++]);
+ MPI_Comm_idup(comms[0], &comms[NUM_IDUPS1 + j], &reqs[cnt++]);
MPI_Comm_rank(comms[0], &rank);
MPI_Comm_remote_size(comms[0], &rsize);
MPI_Iallreduce(&rank, &ans[1], 1, MPI_INT, MPI_SUM, comms[0], &reqs[cnt++]);
- expected[1] = (rsize-1)*rsize/2;
+ expected[1] = (rsize - 1) * rsize / 2;
/* Issue an ibcast on parentcomm */
MPI_Comm_rank(parentcomm, &rank);
if (isLeft) {
- if (rank == 0) {
- root = MPI_ROOT;
- ans[2] = 199;
- } else {
- root = MPI_PROC_NULL;
- ans[2] = 199; /* not needed, just to make correctness checking easier */
- }
- } else {
- root = 0;
- ans[2] = 111; /* garbage value */
+ if (rank == 0) {
+ root = MPI_ROOT;
+ ans[2] = 199;
+ }
+ else {
+ root = MPI_PROC_NULL;
+ ans[2] = 199; /* not needed, just to make correctness checking easier */
+ }
+ }
+ else {
+ root = 0;
+ ans[2] = 111; /* garbage value */
}
MPI_Ibcast(&ans[2], 1, MPI_INT, root, parentcomm, &reqs[cnt++]);
expected[2] = 199;
@@ -187,37 +197,40 @@ MTEST_THREAD_RETURN_TYPE test_intercomm(void *arg)
MPI_Comm_rank(nbrcomm, &rank);
MPI_Comm_remote_size(nbrcomm, &rsize);
MPI_Iallreduce(&rank, &ans[3], 1, MPI_INT, MPI_SUM, nbrcomm, &reqs[cnt++]);
- expected[3] = (rsize-1)*rsize/2;
+ expected[3] = (rsize - 1) * rsize / 2;
/* Pending operations include idup/iallreduce/ibcast on parentcomm
- Iallreduce/Ibarrier on comms[0], and Iallreduce on nbrcomm */
+ * Iallreduce/Ibarrier on comms[0], and Iallreduce on nbrcomm */
/* Waitall even if the first request is completed */
MPI_Waitall(cnt, reqs, MPI_STATUSES_IGNORE);
/* Check the answers */
for (j = 0; j < 4; j++) {
- if (ans[j] != expected[j]) errs[tid]++;
+ if (ans[j] != expected[j])
+ errs[tid]++;
}
for (j = 0; j < NUM_IDUPS1 + NUM_IDUPS2; j++) {
- errs[tid] += MTestTestComm(comms[j]);
- MPI_Comm_free(&comms[j]);
+ errs[tid] += MTestTestComm(comms[j]);
+ MPI_Comm_free(&comms[j]);
}
- if (verbose) printf("\t%d: Thread %d - comm_idup %d finish\n", rank, tid, i);
+ if (verbose)
+ printf("\t%d: Thread %d - comm_idup %d finish\n", rank, tid, i);
}
- if (verbose) printf("%d: Thread %d - Done.\n", rank, tid);
- return (MTEST_THREAD_RETURN_TYPE)0;
+ if (verbose)
+ printf("%d: Thread %d - Done.\n", rank, tid);
+ return (MTEST_THREAD_RETURN_TYPE) 0;
}
int main(int argc, char **argv)
{
- int thread_args[NUM_THREADS];
- MPI_Request requests[NUM_THREADS*2];
- int i, provided;
+ int thread_args[NUM_THREADS];
+ MPI_Request requests[NUM_THREADS * 2];
+ int i, provided;
MPI_Comm newcomm;
int toterrs = 0;
@@ -227,21 +240,22 @@ int main(int argc, char **argv)
check(NUM_IDUPS1 >= 1 && NUM_IDUPS2 >= 1);
/* In each iteration, the process generates a new kind of intracommunicator, then
- uses idup to duplicate the communicator for NUM_THREADS threads.
+ * uses idup to duplicate the communicator for NUM_THREADS threads.
*/
while (MTestGetIntracommGeneral(&newcomm, 1, 1)) {
- if (newcomm == MPI_COMM_NULL) continue;
+ if (newcomm == MPI_COMM_NULL)
+ continue;
for (i = 0; i < NUM_THREADS; i++) {
- MPI_Comm_idup(newcomm, &parentcomms[i], &requests[2*i]);
- MPI_Comm_idup(newcomm, &nbrcomms[i], &requests[2*i+1]);
+ MPI_Comm_idup(newcomm, &parentcomms[i], &requests[2 * i]);
+ MPI_Comm_idup(newcomm, &nbrcomms[i], &requests[2 * i + 1]);
}
- MPI_Waitall(NUM_THREADS*2, requests, MPI_STATUSES_IGNORE);
+ MPI_Waitall(NUM_THREADS * 2, requests, MPI_STATUSES_IGNORE);
for (i = 0; i < NUM_THREADS; i++) {
thread_args[i] = i;
- MTest_Start_thread(test_intracomm, (void *)&thread_args[i] );
+ MTest_Start_thread(test_intracomm, (void *) &thread_args[i]);
}
MTest_Join_threads();
@@ -256,21 +270,22 @@ int main(int argc, char **argv)
}
/* In each iteration, the process generates a new kind of intercommunicator, then
- uses idup to duplicate the communicator for NUM_THREADS threads.
+ * uses idup to duplicate the communicator for NUM_THREADS threads.
*/
while (MTestGetIntercomm(&newcomm, &isLeft, 1)) {
- if (newcomm == MPI_COMM_NULL) continue;
+ if (newcomm == MPI_COMM_NULL)
+ continue;
for (i = 0; i < NUM_THREADS; i++) {
- MPI_Comm_idup(newcomm, &parentcomms[i], &requests[2*i]);
- MPI_Comm_idup(newcomm, &nbrcomms[i], &requests[2*i+1]);
+ MPI_Comm_idup(newcomm, &parentcomms[i], &requests[2 * i]);
+ MPI_Comm_idup(newcomm, &nbrcomms[i], &requests[2 * i + 1]);
}
- MPI_Waitall(NUM_THREADS*2, requests, MPI_STATUSES_IGNORE);
+ MPI_Waitall(NUM_THREADS * 2, requests, MPI_STATUSES_IGNORE);
for (i = 0; i < NUM_THREADS; i++) {
thread_args[i] = i;
- MTest_Start_thread(test_intercomm, (void *)&thread_args[i] );
+ MTest_Start_thread(test_intercomm, (void *) &thread_args[i]);
}
MTest_Join_threads();
@@ -288,4 +303,3 @@ int main(int argc, char **argv)
MPI_Finalize();
return 0;
}
-
diff --git a/test/mpi/threads/init/initth.c b/test/mpi/threads/init/initth.c
index 4978783..7917725 100644
--- a/test/mpi/threads/init/initth.c
+++ b/test/mpi/threads/init/initth.c
@@ -7,20 +7,20 @@
#include "stdio.h"
#include "mpi.h"
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int provided, rank;
- MPI_Init_thread( &argc, &argv, MPI_THREAD_MULTIPLE, &provided );
+ MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Finalize();
/* The test here is a simple one that Finalize exits, so the only action
- is to write no errors */
+ * is to write no errors */
if (rank == 0) {
- printf( " No Errors\n" );
+ printf(" No Errors\n");
}
return 0;
diff --git a/test/mpi/threads/mpi_t/mpit_threading.c b/test/mpi/threads/mpi_t/mpit_threading.c
index 09998f7..171f671 100644
--- a/test/mpi/threads/mpi_t/mpit_threading.c
+++ b/test/mpi/threads/mpi_t/mpit_threading.c
@@ -42,7 +42,7 @@ int PrintCategories(FILE * fp, int myThreadId);
MTEST_THREAD_RETURN_TYPE RunTest(void *p)
{
- int myThreadId = (int)(long)p;
+ int myThreadId = (int) (long) p;
PrintControlVars(stdout, myThreadId);
if (DOPRINT)
@@ -79,7 +79,7 @@ int main(int argc, char *argv[])
/* Spawn threads */
for (i = 0; i < NTHREADS; i++) {
- MTest_Start_thread(RunTest, (void *)(long)i);
+ MTest_Start_thread(RunTest, (void *) (long) i);
}
MTest_Join_threads();
@@ -222,7 +222,8 @@ int PrintCategories(FILE * fp, int myThreadId)
MPI_T_category_get_info(i, name, &nameLen, desc, &descLen, &numCvars,
&numPvars, &numSubcat);
if (DOPRINT)
- fprintf(fp, "Category %s has %d control variables, %d performance variables, %d subcategories\n",
+ fprintf(fp,
+ "Category %s has %d control variables, %d performance variables, %d subcategories\n",
name, numCvars, numPvars, numSubcat);
if (numCvars > 0) {
diff --git a/test/mpi/threads/pt2pt/greq_test.c b/test/mpi/threads/pt2pt/greq_test.c
index 1b6cce0..d685ff9 100644
--- a/test/mpi/threads/pt2pt/greq_test.c
+++ b/test/mpi/threads/pt2pt/greq_test.c
@@ -10,7 +10,7 @@
#include "mpithreadtest.h"
#include "mpitest.h"
#ifdef HAVE_UNISTD_H
- #include <unistd.h>
+#include <unistd.h>
#endif
/* static char MTEST_Descrip[] = "threaded generalized request tests"; */
@@ -25,21 +25,27 @@ do { \
static int verbose = 0;
-int query_fn(void *extra_state, MPI_Status *status);
-int query_fn(void *extra_state, MPI_Status *status)
+int query_fn(void *extra_state, MPI_Status * status);
+int query_fn(void *extra_state, MPI_Status * status)
{
- status->MPI_SOURCE = MPI_UNDEFINED;
- status->MPI_TAG = MPI_UNDEFINED;
- MPI_Status_set_cancelled(status, 0);
- MPI_Status_set_elements(status, MPI_BYTE, 0);
- return 0;
+ status->MPI_SOURCE = MPI_UNDEFINED;
+ status->MPI_TAG = MPI_UNDEFINED;
+ MPI_Status_set_cancelled(status, 0);
+ MPI_Status_set_elements(status, MPI_BYTE, 0);
+ return 0;
}
int free_fn(void *extra_state);
-int free_fn(void *extra_state) { return 0; }
+int free_fn(void *extra_state)
+{
+ return 0;
+}
int cancel_fn(void *extra_state, int complete);
-int cancel_fn(void *extra_state, int complete) { return 0; }
+int cancel_fn(void *extra_state, int complete)
+{
+ return 0;
+}
MPI_Request grequest;
@@ -47,12 +53,12 @@ MPI_Request grequest;
MTEST_THREAD_RETURN_TYPE do_work(void *arg);
MTEST_THREAD_RETURN_TYPE do_work(void *arg)
{
- MPI_Request *req = (MPI_Request *)arg;
- IF_VERBOSE(("Starting work in thread ...\n"));
- MTestSleep(3);
- IF_VERBOSE(("Work in thread done !!!\n"));
- MPI_Grequest_complete(*req);
- return MTEST_THREAD_RETVAL_IGN;
+ MPI_Request *req = (MPI_Request *) arg;
+ IF_VERBOSE(("Starting work in thread ...\n"));
+ MTestSleep(3);
+ IF_VERBOSE(("Work in thread done !!!\n"));
+ MPI_Grequest_complete(*req);
+ return MTEST_THREAD_RETVAL_IGN;
}
int main(int argc, char *argv[])
@@ -61,21 +67,20 @@ int main(int argc, char *argv[])
MPI_Request request;
int flag;
int outcount = -1;
- int indices[1] = {-1};
+ int indices[1] = { -1 };
MPI_Status status;
char *env;
env = getenv("MPITEST_VERBOSE");
- if (env)
- {
+ if (env) {
if (*env != '0')
verbose = 1;
}
- MPI_Init_thread( &argc, &argv, MPI_THREAD_MULTIPLE, &provided);
+ MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
if (provided != MPI_THREAD_MULTIPLE) {
- printf( "This test requires MPI_THREAD_MULTIPLE\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ printf("This test requires MPI_THREAD_MULTIPLE\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
IF_VERBOSE(("Post Init ...\n"));
diff --git a/test/mpi/threads/pt2pt/greq_wait.c b/test/mpi/threads/pt2pt/greq_wait.c
index 40ca126..17ec7b3 100644
--- a/test/mpi/threads/pt2pt/greq_wait.c
+++ b/test/mpi/threads/pt2pt/greq_wait.c
@@ -10,7 +10,7 @@
#include "mpithreadtest.h"
#include "mpitest.h"
#ifdef HAVE_UNISTD_H
- #include <unistd.h>
+#include <unistd.h>
#endif
/*
@@ -27,21 +27,27 @@ do { \
static int verbose = 0;
-int query_fn(void *extra_state, MPI_Status *status);
-int query_fn(void *extra_state, MPI_Status *status)
+int query_fn(void *extra_state, MPI_Status * status);
+int query_fn(void *extra_state, MPI_Status * status)
{
- status->MPI_SOURCE = MPI_UNDEFINED;
- status->MPI_TAG = MPI_UNDEFINED;
- MPI_Status_set_cancelled(status, 0);
- MPI_Status_set_elements(status, MPI_BYTE, 0);
- return 0;
+ status->MPI_SOURCE = MPI_UNDEFINED;
+ status->MPI_TAG = MPI_UNDEFINED;
+ MPI_Status_set_cancelled(status, 0);
+ MPI_Status_set_elements(status, MPI_BYTE, 0);
+ return 0;
}
int free_fn(void *extra_state);
-int free_fn(void *extra_state) { return 0; }
+int free_fn(void *extra_state)
+{
+ return 0;
+}
int cancel_fn(void *extra_state, int complete);
-int cancel_fn(void *extra_state, int complete) { return 0; }
+int cancel_fn(void *extra_state, int complete)
+{
+ return 0;
+}
MPI_Request grequest;
@@ -49,12 +55,12 @@ MPI_Request grequest;
MTEST_THREAD_RETURN_TYPE do_work(void *arg);
MTEST_THREAD_RETURN_TYPE do_work(void *arg)
{
- MPI_Request *req = (MPI_Request *)arg;
- IF_VERBOSE(("Starting work in thread ...\n"));
- MTestSleep(3);
- IF_VERBOSE(("Work in thread done !!!\n"));
- MPI_Grequest_complete(*req);
- return MTEST_THREAD_RETVAL_IGN;
+ MPI_Request *req = (MPI_Request *) arg;
+ IF_VERBOSE(("Starting work in thread ...\n"));
+ MTestSleep(3);
+ IF_VERBOSE(("Work in thread done !!!\n"));
+ MPI_Grequest_complete(*req);
+ return MTEST_THREAD_RETVAL_IGN;
}
int main(int argc, char *argv[])
@@ -62,21 +68,20 @@ int main(int argc, char *argv[])
int provided;
MPI_Request request;
int outcount = -1;
- int indices[1] = {-1};
+ int indices[1] = { -1 };
MPI_Status status;
char *env;
env = getenv("MPITEST_VERBOSE");
- if (env)
- {
+ if (env) {
if (*env != '0')
verbose = 1;
}
- MPI_Init_thread( &argc, &argv, MPI_THREAD_MULTIPLE, &provided);
+ MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
if (provided != MPI_THREAD_MULTIPLE) {
- printf( "This test requires MPI_THREAD_MULTIPLE\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ printf("This test requires MPI_THREAD_MULTIPLE\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
IF_VERBOSE(("Post Init ...\n"));
diff --git a/test/mpi/threads/pt2pt/ibsend.c b/test/mpi/threads/pt2pt/ibsend.c
index 1e634c4..aa868be 100644
--- a/test/mpi/threads/pt2pt/ibsend.c
+++ b/test/mpi/threads/pt2pt/ibsend.c
@@ -50,8 +50,7 @@ void *receiver(void *ptr)
void *sender_bsend(void *ptr)
{
char buffer[MSGSIZE];
- MPI_Bsend(buffer, MSGSIZE, MPI_CHAR, (rank + 1) % size, 0,
- MPI_COMM_WORLD);
+ MPI_Bsend(buffer, MSGSIZE, MPI_CHAR, (rank + 1) % size, 0, MPI_COMM_WORLD);
return NULL;
}
@@ -60,8 +59,7 @@ void *sender_ibsend(void *ptr)
{
char buffer[MSGSIZE];
MPI_Request req;
- MPI_Ibsend(buffer, MSGSIZE, MPI_CHAR, (rank + 1) % size, 0,
- MPI_COMM_WORLD, &req);
+ MPI_Ibsend(buffer, MSGSIZE, MPI_CHAR, (rank + 1) % size, 0, MPI_COMM_WORLD, &req);
MPI_Wait(&req, MPI_STATUS_IGNORE);
return NULL;
@@ -71,8 +69,7 @@ void *sender_isend(void *ptr)
{
char buffer[MSGSIZE];
MPI_Request req;
- MPI_Isend(buffer, MSGSIZE, MPI_CHAR, (rank + 1) % size, 0,
- MPI_COMM_WORLD, &req);
+ MPI_Isend(buffer, MSGSIZE, MPI_CHAR, (rank + 1) % size, 0, MPI_COMM_WORLD, &req);
MPI_Wait(&req, MPI_STATUS_IGNORE);
return NULL;
@@ -81,8 +78,7 @@ void *sender_isend(void *ptr)
void *sender_send(void *ptr)
{
char buffer[MSGSIZE];
- MPI_Send(buffer, MSGSIZE, MPI_CHAR, (rank + 1) % size, 0,
- MPI_COMM_WORLD);
+ MPI_Send(buffer, MSGSIZE, MPI_CHAR, (rank + 1) % size, 0, MPI_COMM_WORLD);
return NULL;
}
@@ -111,9 +107,9 @@ int main(int argc, char *argv[])
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_dup(MPI_COMM_WORLD, &communicator); /* We do not use this communicator in this program, but
- with this call, the problem appears more reliably.
- If the MPI_Comm_dup() call is commented out, it is still
- evident but does not appear that often (don't know why) */
+ * with this call, the problem appears more reliably.
+ * If the MPI_Comm_dup() call is commented out, it is still
+ * evident but does not appear that often (don't know why) */
/* Initialize and set thread detached attribute */
pthread_attr_init(&attr);
@@ -153,7 +149,7 @@ int main(int argc, char *argv[])
pthread_attr_destroy(&attr);
if (!rank)
- printf( " No Errors\n" );
+ printf(" No Errors\n");
MPI_Comm_free(&communicator);
MPI_Buffer_detach(&ptr_dt, &bs);
diff --git a/test/mpi/threads/pt2pt/multisend.c b/test/mpi/threads/pt2pt/multisend.c
index 6c433a4..d70751e 100644
--- a/test/mpi/threads/pt2pt/multisend.c
+++ b/test/mpi/threads/pt2pt/multisend.c
@@ -11,46 +11,46 @@
int rank;
-MTEST_THREAD_RETURN_TYPE run_test(void * arg);
-MTEST_THREAD_RETURN_TYPE run_test(void * arg)
+MTEST_THREAD_RETURN_TYPE run_test(void *arg);
+MTEST_THREAD_RETURN_TYPE run_test(void *arg)
{
- MPI_Status reqstat;
+ MPI_Status reqstat;
int i, j;
int peer = rank ? 0 : 1;
for (j = 0; j < 10; j++) {
- if (rank % 2) {
- for (i = 0; i < 16; i++)
- MPI_Send(NULL, 0, MPI_CHAR, peer, j, MPI_COMM_WORLD);
- for (i = 0; i < 16; i++)
- MPI_Recv(NULL, 0, MPI_CHAR, peer, j, MPI_COMM_WORLD, &reqstat);
- }
- else {
- for (i = 0; i < 16; i++)
- MPI_Recv(NULL, 0, MPI_CHAR, peer, j, MPI_COMM_WORLD, &reqstat);
- for (i = 0; i < 16; i++)
- MPI_Send(NULL, 0, MPI_CHAR, peer, j, MPI_COMM_WORLD);
- }
+ if (rank % 2) {
+ for (i = 0; i < 16; i++)
+ MPI_Send(NULL, 0, MPI_CHAR, peer, j, MPI_COMM_WORLD);
+ for (i = 0; i < 16; i++)
+ MPI_Recv(NULL, 0, MPI_CHAR, peer, j, MPI_COMM_WORLD, &reqstat);
+ }
+ else {
+ for (i = 0; i < 16; i++)
+ MPI_Recv(NULL, 0, MPI_CHAR, peer, j, MPI_COMM_WORLD, &reqstat);
+ for (i = 0; i < 16; i++)
+ MPI_Send(NULL, 0, MPI_CHAR, peer, j, MPI_COMM_WORLD);
+ }
}
- return (MTEST_THREAD_RETURN_TYPE)NULL;
+ return (MTEST_THREAD_RETURN_TYPE) NULL;
}
-int main(int argc, char ** argv)
+int main(int argc, char **argv)
{
int zero = 0, pmode, nprocs;
MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &pmode);
if (pmode != MPI_THREAD_MULTIPLE) {
- fprintf(stderr, "Thread Multiple not supported by the MPI implementation\n");
- MPI_Abort(MPI_COMM_WORLD, -1);
+ fprintf(stderr, "Thread Multiple not supported by the MPI implementation\n");
+ MPI_Abort(MPI_COMM_WORLD, -1);
}
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (nprocs != 2) {
- fprintf(stderr, "Need two processes\n");
- MPI_Abort(MPI_COMM_WORLD, -1);
+ fprintf(stderr, "Need two processes\n");
+ MPI_Abort(MPI_COMM_WORLD, -1);
}
MTest_Start_thread(run_test, NULL);
@@ -61,7 +61,7 @@ int main(int argc, char ** argv)
/* This program works if it gets here */
if (rank == 0) {
- printf( " No Errors\n" );
+ printf(" No Errors\n");
}
return 0;
diff --git a/test/mpi/threads/pt2pt/multisend2.c b/test/mpi/threads/pt2pt/multisend2.c
index 5ac31a5..4035504 100644
--- a/test/mpi/threads/pt2pt/multisend2.c
+++ b/test/mpi/threads/pt2pt/multisend2.c
@@ -4,8 +4,8 @@
* See COPYRIGHT in top-level directory.
*/
-/*
- * Run concurrent sends to different target processes. Stresses an
+/*
+ * Run concurrent sends to different target processes. Stresses an
* implementation that permits concurrent sends to different targets.
*
* By turning on verbose output, some simple performance data will be output.
@@ -25,81 +25,81 @@ static int nthreads = -1;
MTEST_THREAD_RETURN_TYPE run_test_send(void *arg);
MTEST_THREAD_RETURN_TYPE run_test_send(void *arg)
{
- int cnt, j, *buf;
- int thread_num = (int)(long)arg;
+ int cnt, j, *buf;
+ int thread_num = (int) (long) arg;
double t;
- for (cnt=1; cnt < MAX_CNT; cnt = 2*cnt) {
- buf = (int *)malloc( cnt * sizeof(int) );
+ for (cnt = 1; cnt < MAX_CNT; cnt = 2 * cnt) {
+ buf = (int *) malloc(cnt * sizeof(int));
- /* Wait for all senders to be ready */
- MTest_thread_barrier(nthreads);
+ /* Wait for all senders to be ready */
+ MTest_thread_barrier(nthreads);
- t = MPI_Wtime();
- for (j=0; j<MAX_LOOP; j++)
- MPI_Send( buf, cnt, MPI_INT, thread_num, cnt, MPI_COMM_WORLD );
- t = MPI_Wtime() - t;
- free( buf );
- if (thread_num == 1)
- MTestPrintfMsg( 1, "buf size %d: time %f\n", cnt, t / MAX_LOOP );
+ t = MPI_Wtime();
+ for (j = 0; j < MAX_LOOP; j++)
+ MPI_Send(buf, cnt, MPI_INT, thread_num, cnt, MPI_COMM_WORLD);
+ t = MPI_Wtime() - t;
+ free(buf);
+ if (thread_num == 1)
+ MTestPrintfMsg(1, "buf size %d: time %f\n", cnt, t / MAX_LOOP);
}
- return (MTEST_THREAD_RETURN_TYPE)NULL;
+ return (MTEST_THREAD_RETURN_TYPE) NULL;
}
-void run_test_recv( void );
-void run_test_recv( void )
+void run_test_recv(void);
+void run_test_recv(void)
{
- int cnt, j, *buf;
+ int cnt, j, *buf;
MPI_Status status;
- double t;
-
- for (cnt=1; cnt < MAX_CNT; cnt = 2*cnt) {
- buf = (int *)malloc( cnt * sizeof(int) );
- t = MPI_Wtime();
- for (j=0; j<MAX_LOOP; j++)
- MPI_Recv( buf, cnt, MPI_INT, 0, cnt, MPI_COMM_WORLD, &status );
- t = MPI_Wtime() - t;
- free( buf );
+ double t;
+
+ for (cnt = 1; cnt < MAX_CNT; cnt = 2 * cnt) {
+ buf = (int *) malloc(cnt * sizeof(int));
+ t = MPI_Wtime();
+ for (j = 0; j < MAX_LOOP; j++)
+ MPI_Recv(buf, cnt, MPI_INT, 0, cnt, MPI_COMM_WORLD, &status);
+ t = MPI_Wtime() - t;
+ free(buf);
}
}
-int main(int argc, char ** argv)
+int main(int argc, char **argv)
{
int i, pmode, nprocs, rank;
int errs = 0, err;
MTest_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &pmode);
if (pmode != MPI_THREAD_MULTIPLE) {
- fprintf(stderr, "Thread Multiple not supported by the MPI implementation\n");
- MPI_Abort(MPI_COMM_WORLD, -1);
+ fprintf(stderr, "Thread Multiple not supported by the MPI implementation\n");
+ MPI_Abort(MPI_COMM_WORLD, -1);
}
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (nprocs < 2) {
- fprintf(stderr, "Need at least two processes\n");
- MPI_Abort(MPI_COMM_WORLD, 1);
+ fprintf(stderr, "Need at least two processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
err = MTest_thread_barrier_init();
if (err) {
- fprintf( stderr, "Could not create thread barrier\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Could not create thread barrier\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
if (rank == 0) {
- nthreads = nprocs-1;
- for (i=1; i<nprocs; i++)
- MTest_Start_thread( run_test_send, (void *)(long)i );
- MTest_Join_threads( );
+ nthreads = nprocs - 1;
+ for (i = 1; i < nprocs; i++)
+ MTest_Start_thread(run_test_send, (void *) (long) i);
+ MTest_Join_threads();
}
else {
- run_test_recv();
+ run_test_recv();
}
MTest_thread_barrier_free();
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
diff --git a/test/mpi/threads/pt2pt/multisend3.c b/test/mpi/threads/pt2pt/multisend3.c
index 3e3dfd4..fb307d7 100644
--- a/test/mpi/threads/pt2pt/multisend3.c
+++ b/test/mpi/threads/pt2pt/multisend3.c
@@ -4,8 +4,8 @@
* See COPYRIGHT in top-level directory.
*/
-/*
- * Run concurrent sends to different target processes. Stresses an
+/*
+ * Run concurrent sends to different target processes. Stresses an
* implementation that permits concurrent sends to different targets.
*
* By turning on verbose output, some simple performance data will be output.
@@ -30,107 +30,107 @@ static int nthreads = -1;
MTEST_THREAD_RETURN_TYPE run_test_send(void *arg);
MTEST_THREAD_RETURN_TYPE run_test_send(void *arg)
{
- int cnt, j, *buf, wsize;
- int thread_num = (int)(long)arg;
+ int cnt, j, *buf, wsize;
+ int thread_num = (int) (long) arg;
double t;
static MPI_Request r[MAX_NTHREAD];
/* Create the buf just once to avoid finding races in malloc instead
- of the MPI library */
- buf = (int *)malloc( MAX_CNT * sizeof(int) );
- MTestPrintfMsg( 1, "buf address %p (size %d)\n", buf, MAX_CNT * sizeof(int) );
- MPI_Comm_size( MPI_COMM_WORLD, &wsize );
- if (wsize >= MAX_NTHREAD) wsize = MAX_NTHREAD;
+ * of the MPI library */
+ buf = (int *) malloc(MAX_CNT * sizeof(int));
+ MTestPrintfMsg(1, "buf address %p (size %d)\n", buf, MAX_CNT * sizeof(int));
+ MPI_Comm_size(MPI_COMM_WORLD, &wsize);
+ if (wsize >= MAX_NTHREAD)
+ wsize = MAX_NTHREAD;
/* Sanity check */
- if (nthreads != wsize-1)
- fprintf( stderr, "Panic wsize = %d nthreads = %d\n",
- wsize, nthreads );
-
- for (cnt=1; cnt < MAX_CNT; cnt = 2*cnt) {
- /* Wait for all senders to be ready */
- MTest_thread_barrier(nthreads);
-
- t = MPI_Wtime();
- for (j=0; j<MAX_LOOP; j++) {
- MTest_thread_barrier(nthreads);
- MPI_Isend( buf, cnt, MPI_INT, thread_num, cnt, MPI_COMM_WORLD,
- &r[thread_num-1]);
- if (ownerWaits) {
- MPI_Wait( &r[thread_num-1], MPI_STATUS_IGNORE );
- }
- else {
- /* Wait for all threads to start the sends */
- MTest_thread_barrier(nthreads);
- if (thread_num == 1) {
- MPI_Waitall( wsize-1, r, MPI_STATUSES_IGNORE );
- }
- }
- }
- t = MPI_Wtime() - t;
- if (thread_num == 1)
- MTestPrintfMsg( 1, "buf size %d: time %f\n", cnt*sizeof(int),
- t / MAX_LOOP );
+ if (nthreads != wsize - 1)
+ fprintf(stderr, "Panic wsize = %d nthreads = %d\n", wsize, nthreads);
+
+ for (cnt = 1; cnt < MAX_CNT; cnt = 2 * cnt) {
+ /* Wait for all senders to be ready */
+ MTest_thread_barrier(nthreads);
+
+ t = MPI_Wtime();
+ for (j = 0; j < MAX_LOOP; j++) {
+ MTest_thread_barrier(nthreads);
+ MPI_Isend(buf, cnt, MPI_INT, thread_num, cnt, MPI_COMM_WORLD, &r[thread_num - 1]);
+ if (ownerWaits) {
+ MPI_Wait(&r[thread_num - 1], MPI_STATUS_IGNORE);
+ }
+ else {
+ /* Wait for all threads to start the sends */
+ MTest_thread_barrier(nthreads);
+ if (thread_num == 1) {
+ MPI_Waitall(wsize - 1, r, MPI_STATUSES_IGNORE);
+ }
+ }
+ }
+ t = MPI_Wtime() - t;
+ if (thread_num == 1)
+ MTestPrintfMsg(1, "buf size %d: time %f\n", cnt * sizeof(int), t / MAX_LOOP);
}
MTest_thread_barrier(nthreads);
- free( buf );
- return (MTEST_THREAD_RETURN_TYPE)NULL;
+ free(buf);
+ return (MTEST_THREAD_RETURN_TYPE) NULL;
}
-void run_test_recv( void );
-void run_test_recv( void )
+
+void run_test_recv(void);
+void run_test_recv(void)
{
- int cnt, j, *buf;
+ int cnt, j, *buf;
MPI_Status status;
- double t;
-
- for (cnt=1; cnt < MAX_CNT; cnt = 2*cnt) {
- buf = (int *)malloc( cnt * sizeof(int) );
- t = MPI_Wtime();
- for (j=0; j<MAX_LOOP; j++)
- MPI_Recv( buf, cnt, MPI_INT, 0, cnt, MPI_COMM_WORLD, &status );
- t = MPI_Wtime() - t;
- free( buf );
+ double t;
+
+ for (cnt = 1; cnt < MAX_CNT; cnt = 2 * cnt) {
+ buf = (int *) malloc(cnt * sizeof(int));
+ t = MPI_Wtime();
+ for (j = 0; j < MAX_LOOP; j++)
+ MPI_Recv(buf, cnt, MPI_INT, 0, cnt, MPI_COMM_WORLD, &status);
+ t = MPI_Wtime() - t;
+ free(buf);
}
}
-int main(int argc, char ** argv)
+int main(int argc, char **argv)
{
int i, pmode, nprocs, rank;
int errs = 0, err;
MTest_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &pmode);
if (pmode != MPI_THREAD_MULTIPLE) {
- fprintf(stderr, "Thread Multiple not supported by the MPI implementation\n");
- MPI_Abort(MPI_COMM_WORLD, -1);
+ fprintf(stderr, "Thread Multiple not supported by the MPI implementation\n");
+ MPI_Abort(MPI_COMM_WORLD, -1);
}
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (nprocs < 2) {
- fprintf(stderr, "Need at least two processes\n");
- MPI_Abort(MPI_COMM_WORLD, 1);
+ fprintf(stderr, "Need at least two processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- if (nprocs > MAX_NTHREAD) nprocs = MAX_NTHREAD;
+ if (nprocs > MAX_NTHREAD)
+ nprocs = MAX_NTHREAD;
err = MTest_thread_barrier_init();
if (err) {
- fprintf( stderr, "Could not create thread barrier\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Could not create thread barrier\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
if (rank == 0) {
- nthreads = nprocs - 1;
- for (i=1; i<nprocs; i++)
- MTest_Start_thread( run_test_send, (void *)(long)i );
+ nthreads = nprocs - 1;
+ for (i = 1; i < nprocs; i++)
+ MTest_Start_thread(run_test_send, (void *) (long) i);
- MTest_Join_threads( );
+ MTest_Join_threads();
}
else if (rank < MAX_NTHREAD) {
- run_test_recv();
+ run_test_recv();
}
MTest_thread_barrier_free();
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
diff --git a/test/mpi/threads/pt2pt/multisend4.c b/test/mpi/threads/pt2pt/multisend4.c
index 041e6af..b65bf4f 100644
--- a/test/mpi/threads/pt2pt/multisend4.c
+++ b/test/mpi/threads/pt2pt/multisend4.c
@@ -4,8 +4,8 @@
* See COPYRIGHT in top-level directory.
*/
-/*
- * Run concurrent sends to different target processes. Stresses an
+/*
+ * Run concurrent sends to different target processes. Stresses an
* implementation that permits concurrent sends to different targets.
*
* By turning on verbose output, some simple performance data will be output.
@@ -30,92 +30,92 @@ static int nthreads = -1;
MTEST_THREAD_RETURN_TYPE run_test_sendrecv(void *arg);
MTEST_THREAD_RETURN_TYPE run_test_sendrecv(void *arg)
{
- int cnt, j, *buf, wsize;
- int thread_num = (int)(long)arg;
+ int cnt, j, *buf, wsize;
+ int thread_num = (int) (long) arg;
double t;
- int myrloc = 2*thread_num;
- static MPI_Request r[2*MAX_NTHREAD];
+ int myrloc = 2 * thread_num;
+ static MPI_Request r[2 * MAX_NTHREAD];
- MPI_Comm_size( MPI_COMM_WORLD, &wsize );
- if (wsize >= MAX_NTHREAD) wsize = MAX_NTHREAD;
+ MPI_Comm_size(MPI_COMM_WORLD, &wsize);
+ if (wsize >= MAX_NTHREAD)
+ wsize = MAX_NTHREAD;
/* Sanity check */
if (nthreads != wsize)
- fprintf( stderr, "Panic wsize = %d nthreads = %d\n",
- wsize, nthreads );
-
- for (cnt=1; cnt < MAX_CNT; cnt = 2*cnt) {
- buf = (int *)malloc( 2*cnt * sizeof(int) );
-
- /* Wait for all senders to be ready */
- MTest_thread_barrier(nthreads);
-
- t = MPI_Wtime();
- for (j=0; j<MAX_LOOP; j++) {
- MTest_thread_barrier(nthreads);
- MPI_Isend( buf, cnt, MPI_INT, thread_num, cnt, MPI_COMM_WORLD,
- &r[myrloc]);
- MPI_Irecv( buf+cnt, cnt, MPI_INT, thread_num, cnt, MPI_COMM_WORLD,
- &r[myrloc+1]);
- /* Wait for all threads to start the sends */
- if (ownerWaits) {
- MPI_Waitall( 2, &r[myrloc], MPI_STATUSES_IGNORE );
- }
- else {
- /* Wait for all threads to create their requests */
- MTest_thread_barrier(nthreads);
- if (thread_num == 1)
- MPI_Waitall( 2*wsize, r, MPI_STATUSES_IGNORE );
-
- }
- }
- t = MPI_Wtime() - t;
- /* can't free the buffers until the requests are completed */
- MTest_thread_barrier(nthreads);
- free( buf );
- if (thread_num == 1)
- MTestPrintfMsg( 1, "buf size %d: time %f\n", cnt, t / MAX_LOOP );
+ fprintf(stderr, "Panic wsize = %d nthreads = %d\n", wsize, nthreads);
+
+ for (cnt = 1; cnt < MAX_CNT; cnt = 2 * cnt) {
+ buf = (int *) malloc(2 * cnt * sizeof(int));
+
+ /* Wait for all senders to be ready */
+ MTest_thread_barrier(nthreads);
+
+ t = MPI_Wtime();
+ for (j = 0; j < MAX_LOOP; j++) {
+ MTest_thread_barrier(nthreads);
+ MPI_Isend(buf, cnt, MPI_INT, thread_num, cnt, MPI_COMM_WORLD, &r[myrloc]);
+ MPI_Irecv(buf + cnt, cnt, MPI_INT, thread_num, cnt, MPI_COMM_WORLD, &r[myrloc + 1]);
+ /* Wait for all threads to start the sends */
+ if (ownerWaits) {
+ MPI_Waitall(2, &r[myrloc], MPI_STATUSES_IGNORE);
+ }
+ else {
+ /* Wait for all threads to create their requests */
+ MTest_thread_barrier(nthreads);
+ if (thread_num == 1)
+ MPI_Waitall(2 * wsize, r, MPI_STATUSES_IGNORE);
+
+ }
+ }
+ t = MPI_Wtime() - t;
+ /* can't free the buffers until the requests are completed */
+ MTest_thread_barrier(nthreads);
+ free(buf);
+ if (thread_num == 1)
+ MTestPrintfMsg(1, "buf size %d: time %f\n", cnt, t / MAX_LOOP);
}
- return (MTEST_THREAD_RETURN_TYPE)NULL;
+ return (MTEST_THREAD_RETURN_TYPE) NULL;
}
-int main(int argc, char ** argv)
+int main(int argc, char **argv)
{
int i, pmode, nprocs, rank;
int errs = 0, err;
MTest_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &pmode);
if (pmode != MPI_THREAD_MULTIPLE) {
- fprintf(stderr, "Thread Multiple not supported by the MPI implementation\n");
- MPI_Abort(MPI_COMM_WORLD, -1);
+ fprintf(stderr, "Thread Multiple not supported by the MPI implementation\n");
+ MPI_Abort(MPI_COMM_WORLD, -1);
}
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (nprocs < 2) {
- fprintf(stderr, "Need at least two processes\n");
- MPI_Abort(MPI_COMM_WORLD, 1);
+ fprintf(stderr, "Need at least two processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- if (nprocs > MAX_NTHREAD) nprocs = MAX_NTHREAD;
+ if (nprocs > MAX_NTHREAD)
+ nprocs = MAX_NTHREAD;
err = MTest_thread_barrier_init();
if (err) {
- fprintf( stderr, "Could not create thread barrier\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "Could not create thread barrier\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- MPI_Barrier( MPI_COMM_WORLD );
+ MPI_Barrier(MPI_COMM_WORLD);
if (rank < MAX_NTHREAD) {
- int nt = nprocs;
- if (nt > MAX_NTHREAD) nt = MAX_NTHREAD;
- nthreads = nt;
- for (i=0; i<nt; i++)
- MTest_Start_thread( run_test_sendrecv, (void *)(long)i );
+ int nt = nprocs;
+ if (nt > MAX_NTHREAD)
+ nt = MAX_NTHREAD;
+ nthreads = nt;
+ for (i = 0; i < nt; i++)
+ MTest_Start_thread(run_test_sendrecv, (void *) (long) i);
}
- MTest_Join_threads( );
+ MTest_Join_threads();
MTest_thread_barrier_free();
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
diff --git a/test/mpi/threads/pt2pt/sendselfth.c b/test/mpi/threads/pt2pt/sendselfth.c
index 40f0ec8..4e2342e 100644
--- a/test/mpi/threads/pt2pt/sendselfth.c
+++ b/test/mpi/threads/pt2pt/sendselfth.c
@@ -26,7 +26,7 @@ MTEST_THREAD_RETURN_TYPE send_thread(void *p)
return MTEST_THREAD_RETVAL_IGN;
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int rank, size;
int provided;
@@ -38,20 +38,19 @@ int main( int argc, char *argv[] )
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
- if (provided != MPI_THREAD_MULTIPLE)
- {
- if (rank == 0)
- {
- printf("MPI_Init_thread must return MPI_THREAD_MULTIPLE in order for this test to run.\n");
- fflush(stdout);
- }
- MPI_Finalize();
- return -1;
+ if (provided != MPI_THREAD_MULTIPLE) {
+ if (rank == 0) {
+ printf
+ ("MPI_Init_thread must return MPI_THREAD_MULTIPLE in order for this test to run.\n");
+ fflush(stdout);
+ }
+ MPI_Finalize();
+ return -1;
}
MTest_Start_thread(send_thread, NULL);
- MPI_Probe(MPI_ANY_SOURCE,MPI_ANY_TAG,MPI_COMM_WORLD,&status);
+ MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
MPI_Recv(buffer, sizeof(buffer), MPI_CHAR, rank, 0, MPI_COMM_WORLD, &status);
diff --git a/test/mpi/threads/pt2pt/threaded_sr.c b/test/mpi/threads/pt2pt/threaded_sr.c
index cfab907..277037d 100644
--- a/test/mpi/threads/pt2pt/threaded_sr.c
+++ b/test/mpi/threads/pt2pt/threaded_sr.c
@@ -14,14 +14,14 @@
static char MTEST_Descrip[] = "Threaded Send-Recv";
*/
-/* The buffer size needs to be large enough to cause the rndv protocol to be
+/* The buffer size needs to be large enough to cause the rndv protocol to be
used.
If the MPI provider doesn't use a rndv protocol then the size doesn't matter.
*/
#define MSG_SIZE 1024*1024
/* Keep track of whether the send succeeded. The values are:
- -1 (unset), 0 (failure), 1 (ok). The unset value allows us to
+ -1 (unset), 0 (failure), 1 (ok). The unset value allows us to
avoid a possible race caused by reading the value before the send
thread sets it.
*/
@@ -34,38 +34,36 @@ MTEST_THREAD_RETURN_TYPE send_thread(void *p)
int length;
int rank;
- buffer = malloc(sizeof(char)*MSG_SIZE);
- if (buffer == NULL)
- {
- printf("malloc failed to allocate %d bytes for the send buffer.\n", MSG_SIZE);
- fflush(stdout);
- sendok = 0;
- return (MTEST_THREAD_RETURN_TYPE )-1;
+ buffer = malloc(sizeof(char) * MSG_SIZE);
+ if (buffer == NULL) {
+ printf("malloc failed to allocate %d bytes for the send buffer.\n", MSG_SIZE);
+ fflush(stdout);
+ sendok = 0;
+ return (MTEST_THREAD_RETURN_TYPE) - 1;
}
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
err = MPI_Send(buffer, MSG_SIZE, MPI_CHAR, rank == 0 ? 1 : 0, 0, MPI_COMM_WORLD);
- if (err)
- {
- MPI_Error_string(err, buffer, &length);
- printf("MPI_Send of %d bytes from %d to %d failed, error: %s\n",
- MSG_SIZE, rank, rank == 0 ? 1 : 0, buffer);
- fflush(stdout);
- sendok = 0;
+ if (err) {
+ MPI_Error_string(err, buffer, &length);
+ printf("MPI_Send of %d bytes from %d to %d failed, error: %s\n",
+ MSG_SIZE, rank, rank == 0 ? 1 : 0, buffer);
+ fflush(stdout);
+ sendok = 0;
}
else {
- sendok = 1;
+ sendok = 1;
}
- return (MTEST_THREAD_RETURN_TYPE)(long)err;
+ return (MTEST_THREAD_RETURN_TYPE) (long) err;
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
- int err, errs=0;
+ int err, errs = 0;
int rank, size;
int provided;
char *buffer;
@@ -73,63 +71,58 @@ int main( int argc, char *argv[] )
MPI_Status status;
err = MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
- if (err != MPI_SUCCESS)
- {
- MPI_Abort(MPI_COMM_WORLD, 1);
+ if (err != MPI_SUCCESS) {
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
- if (provided != MPI_THREAD_MULTIPLE)
- {
- if (rank == 0)
- {
- printf("MPI_Init_thread must return MPI_THREAD_MULTIPLE in order for this test to run.\n");
- fflush(stdout);
- }
- MPI_Finalize();
- return -1;
+ if (provided != MPI_THREAD_MULTIPLE) {
+ if (rank == 0) {
+ printf
+ ("MPI_Init_thread must return MPI_THREAD_MULTIPLE in order for this test to run.\n");
+ fflush(stdout);
+ }
+ MPI_Finalize();
+ return -1;
}
- if (size > 2)
- {
- printf("please run with exactly two processes.\n");
- MPI_Finalize();
- return -1;
+ if (size > 2) {
+ printf("please run with exactly two processes.\n");
+ MPI_Finalize();
+ return -1;
}
MTest_Start_thread(send_thread, NULL);
/* give the send thread time to start up and begin sending the message */
- MTestSleep(3);
-
- buffer = malloc(sizeof(char)*MSG_SIZE);
- if (buffer == NULL)
- {
- printf("malloc failed to allocate %d bytes for the recv buffer.\n", MSG_SIZE);
- fflush(stdout);
- MPI_Abort(MPI_COMM_WORLD, -1);
+ MTestSleep(3);
+
+ buffer = malloc(sizeof(char) * MSG_SIZE);
+ if (buffer == NULL) {
+ printf("malloc failed to allocate %d bytes for the recv buffer.\n", MSG_SIZE);
+ fflush(stdout);
+ MPI_Abort(MPI_COMM_WORLD, -1);
}
/* To improve reporting of problems about operations, we
- change the error handler to errors return */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ * change the error handler to errors return */
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
- err = MPI_Recv(buffer, MSG_SIZE, MPI_CHAR, rank == 0 ? 1 : 0, 0,
- MPI_COMM_WORLD, &status);
+ err = MPI_Recv(buffer, MSG_SIZE, MPI_CHAR, rank == 0 ? 1 : 0, 0, MPI_COMM_WORLD, &status);
if (err) {
- errs++;
- MPI_Error_string(err, buffer, &length);
- printf("MPI_Recv of %d bytes from %d to %d failed, error: %s\n",
- MSG_SIZE, rank, rank == 0 ? 1 : 0, buffer);
- fflush(stdout);
+ errs++;
+ MPI_Error_string(err, buffer, &length);
+ printf("MPI_Recv of %d bytes from %d to %d failed, error: %s\n",
+ MSG_SIZE, rank, rank == 0 ? 1 : 0, buffer);
+ fflush(stdout);
}
/* Loop until the send flag is set */
- while (sendok == -1) ;
+ while (sendok == -1);
if (!sendok) {
- errs ++;
+ errs++;
}
MTest_Finalize(errs);
diff --git a/test/mpi/threads/pt2pt/threads.c b/test/mpi/threads/pt2pt/threads.c
index 07d88ab..79a6d1b 100644
--- a/test/mpi/threads/pt2pt/threads.c
+++ b/test/mpi/threads/pt2pt/threads.c
@@ -39,7 +39,7 @@ static MTEST_THREAD_LOCK_TYPE num_threads_lock;
MTEST_THREAD_RETURN_TYPE run_test(void *arg);
MTEST_THREAD_RETURN_TYPE run_test(void *arg)
{
- int thread_id = (int)(long) arg;
+ int thread_id = (int) (long) arg;
int i, j, peer;
MPI_Status status[WINDOW];
MPI_Request req[WINDOW];
@@ -53,10 +53,12 @@ MTEST_THREAD_RETURN_TYPE run_test(void *arg)
peer = (rank % 2) ? rank - 1 : rank + 1;
err = MTest_thread_lock(&num_threads_lock);
- if (err) ABORT_MSG("unable to acquire lock, aborting\n");
+ if (err)
+ ABORT_MSG("unable to acquire lock, aborting\n");
local_num_threads = num_threads;
err = MTest_thread_unlock(&num_threads_lock);
- if (err) ABORT_MSG("unable to release lock, aborting\n");
+ if (err)
+ ABORT_MSG("unable to release lock, aborting\n");
MTest_thread_barrier(num_threads);
@@ -104,20 +106,22 @@ void loops(void)
int i, nt;
double latency, mrate, avg_latency, agg_mrate;
int err;
-
+
err = MTest_thread_lock_create(&num_threads_lock);
- if (err) ABORT_MSG("unable to create lock, aborting\n");
+ if (err)
+ ABORT_MSG("unable to create lock, aborting\n");
for (nt = 1; nt <= MAX_THREADS; nt++) {
err = MTest_thread_lock(&num_threads_lock);
- if (err) ABORT_MSG("unable to acquire lock, aborting\n");
+ if (err)
+ ABORT_MSG("unable to acquire lock, aborting\n");
num_threads = 1;
MPI_Barrier(MPI_COMM_WORLD);
MTest_thread_barrier_init();
for (i = 1; i < nt; i++) {
- err = MTest_Start_thread(run_test, (void *)(long)i);
+ err = MTest_Start_thread(run_test, (void *) (long) i);
if (err) {
/* attempt to continue with fewer threads, we may be on a
* thread-constrained platform like BG/P in DUAL mode */
@@ -127,13 +131,14 @@ void loops(void)
}
err = MTest_thread_unlock(&num_threads_lock);
- if (err) ABORT_MSG("unable to release lock, aborting\n");
+ if (err)
+ ABORT_MSG("unable to release lock, aborting\n");
if (nt > 1 && num_threads <= 1) {
ABORT_MSG("unable to create any additional threads, aborting\n");
}
- run_test((void *) 0); /* we are thread 0 */
+ run_test((void *) 0); /* we are thread 0 */
err = MTest_Join_threads();
if (err) {
printf("error joining threads, err=%d", err);
@@ -146,7 +151,7 @@ void loops(void)
for (i = 0; i < num_threads; i++)
latency += tp[i].latency;
latency /= num_threads; /* Average latency */
- mrate = num_threads / latency; /* Message rate */
+ mrate = num_threads / latency; /* Message rate */
/* Global latency and message rate */
MPI_Reduce(&latency, &avg_latency, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);
@@ -154,16 +159,16 @@ void loops(void)
MPI_Reduce(&mrate, &agg_mrate, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);
if (!rank && verbose) {
- printf("Threads: %d; Latency: %.3f; Mrate: %.3f\n",
- num_threads, latency, mrate);
+ printf("Threads: %d; Latency: %.3f; Mrate: %.3f\n", num_threads, latency, mrate);
}
}
err = MTest_thread_lock_free(&num_threads_lock);
- if (err) ABORT_MSG("unable to free lock, aborting\n");
+ if (err)
+ ABORT_MSG("unable to free lock, aborting\n");
}
-int main(int argc, char ** argv)
+int main(int argc, char **argv)
{
int pmode, i, j;
@@ -229,7 +234,7 @@ int main(int argc, char ** argv)
}
if (rank == 0) {
- printf( " No Errors\n" );
+ printf(" No Errors\n");
}
MPI_Finalize();
diff --git a/test/mpi/threads/rma/multiget.c b/test/mpi/threads/rma/multiget.c
index fd5e763..4a090ea 100644
--- a/test/mpi/threads/rma/multiget.c
+++ b/test/mpi/threads/rma/multiget.c
@@ -55,10 +55,10 @@ int main(int argc, char *argv[])
if (rank == 0) {
errs += MPI_Win_allocate(COUNT * sizeof(double), sizeof(double),
- MPI_INFO_NULL, MPI_COMM_WORLD, &win_mem, &win);
- } else {
- errs += MPI_Win_allocate(0, sizeof(double), MPI_INFO_NULL,
- MPI_COMM_WORLD, &win_mem, &win);
+ MPI_INFO_NULL, MPI_COMM_WORLD, &win_mem, &win);
+ }
+ else {
+ errs += MPI_Win_allocate(0, sizeof(double), MPI_INFO_NULL, MPI_COMM_WORLD, &win_mem, &win);
}
errs += MPI_Win_lock_all(0, win);
diff --git a/test/mpi/threads/rma/multirma.c b/test/mpi/threads/rma/multirma.c
index 4501dca..7b8e97a 100644
--- a/test/mpi/threads/rma/multirma.c
+++ b/test/mpi/threads/rma/multirma.c
@@ -38,7 +38,7 @@ int main(int argc, char *argv[])
MTest_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &pmode);
if (pmode != MPI_THREAD_MULTIPLE) {
- fprintf(stderr, "Thread Multiple not supported by the MPI implementation\n");
+ fprintf(stderr, "Thread Multiple not supported by the MPI implementation\n");
MPI_Abort(MPI_COMM_WORLD, -1);
}
@@ -49,7 +49,9 @@ int main(int argc, char *argv[])
MPI_Abort(MPI_COMM_WORLD, 1);
}
- errs += MPI_Win_allocate(COUNT * sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win_buf, &win);
+ errs +=
+ MPI_Win_allocate(COUNT * sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win_buf,
+ &win);
errs += MPI_Win_lock_all(0, win);
for (i = 0; i < NUM_THREADS; i++)
diff --git a/test/mpi/threads/spawn/multispawn.c b/test/mpi/threads/spawn/multispawn.c
index 1f124b4..2958df0 100644
--- a/test/mpi/threads/spawn/multispawn.c
+++ b/test/mpi/threads/spawn/multispawn.c
@@ -4,12 +4,12 @@
* (C) 2008 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
-/*
- * This (is a placeholder for a) test that creates 4 threads, each of which
+/*
+ * This (is a placeholder for a) test that creates 4 threads, each of which
* does a concurrent spawn of 4 more processes, for a total of 17 MPI processes
* The resulting intercomms are tested for consistency (to ensure that the
* spawns didn't get confused among the threads).
- *
+ *
* As an option, it will time the Spawn calls. If the spawn calls block the
* calling thread, this may show up in the timing of the calls
*/
@@ -40,47 +40,46 @@ MTEST_THREAD_RETURN_TYPE spawnProcess(void *p)
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
/* The thread number is passed into this routine through the value of the
- argument */
- i = (int)(long)p;
+ * argument */
+ i = (int) (long) p;
/* Synchronize */
MTest_thread_barrier(NTHREADS);
/* Spawn */
- MPI_Comm_spawn( (char*)"./multispawn", MPI_ARGV_NULL, NPERTHREAD,
- MPI_INFO_NULL, 0, MPI_COMM_SELF, &intercomms[i], errcodes );
+ MPI_Comm_spawn((char *) "./multispawn", MPI_ARGV_NULL, NPERTHREAD,
+ MPI_INFO_NULL, 0, MPI_COMM_SELF, &intercomms[i], errcodes);
- MPI_Bcast( &i, 1, MPI_INT, MPI_ROOT, intercomms[i] );
+ MPI_Bcast(&i, 1, MPI_INT, MPI_ROOT, intercomms[i]);
return MTEST_THREAD_RETVAL_IGN;
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int rank, size, i, wasParent = 0;
int provided;
int err;
- MPI_Comm parentcomm;
+ MPI_Comm parentcomm;
MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
- if (provided != MPI_THREAD_MULTIPLE)
- {
- if (rank == 0)
- {
- printf("MPI_Init_thread must return MPI_THREAD_MULTIPLE in order for this test to run.\n");
- fflush(stdout);
- }
- MPI_Finalize();
- return -1;
+ if (provided != MPI_THREAD_MULTIPLE) {
+ if (rank == 0) {
+ printf
+ ("MPI_Init_thread must return MPI_THREAD_MULTIPLE in order for this test to run.\n");
+ fflush(stdout);
+ }
+ MPI_Finalize();
+ return -1;
}
- MPI_Comm_get_parent( &parentcomm );
+ MPI_Comm_get_parent(&parentcomm);
if (parentcomm == MPI_COMM_NULL) {
- wasParent = 1;
+ wasParent = 1;
err = MTest_thread_barrier_init();
if (err) {
@@ -90,15 +89,15 @@ int main( int argc, char *argv[] )
return 1;
}
- for (i=0; i<NTHREADS-1; i++) {
- MTest_Start_thread(spawnProcess, (void *)(long)i);
- }
+ for (i = 0; i < NTHREADS - 1; i++) {
+ MTest_Start_thread(spawnProcess, (void *) (long) i);
+ }
- /* spawn the processes */
- spawnProcess( (void*)(NTHREADS-1) );
+ /* spawn the processes */
+ spawnProcess((void *) (NTHREADS - 1));
- /* Exit the threads (but the spawned processes remain) */
- MTest_Join_threads();
+ /* Exit the threads (but the spawned processes remain) */
+ MTest_Join_threads();
err = MTest_thread_barrier_free();
if (err) {
@@ -108,39 +107,38 @@ int main( int argc, char *argv[] )
return 1;
}
- /* The master thread (this thread) checks the created communicators */
- for (i=0; i<NTHREADS; i++) {
- MPI_Bcast( &i, 1, MPI_INT, MPI_ROOT, intercomms[i] );
- }
+ /* The master thread (this thread) checks the created communicators */
+ for (i = 0; i < NTHREADS; i++) {
+ MPI_Bcast(&i, 1, MPI_INT, MPI_ROOT, intercomms[i]);
+ }
- /* Free the created processes */
- for (i=0; i<NTHREADS; i++) {
- MPI_Comm_disconnect( &intercomms[i] );
- }
+ /* Free the created processes */
+ for (i = 0; i < NTHREADS; i++) {
+ MPI_Comm_disconnect(&intercomms[i]);
+ }
}
else {
- int num, threadnum;
+ int num, threadnum;
+
+ /* I'm the created process */
+ MPI_Bcast(&threadnum, 1, MPI_INT, 0, parentcomm);
- /* I'm the created process */
- MPI_Bcast( &threadnum, 1, MPI_INT, 0, parentcomm );
-
- /* Form an intra comm with my parent */
+ /* Form an intra comm with my parent */
- /* receive from my parent */
- MPI_Bcast( &num, 1, MPI_INT, 0, parentcomm );
+ /* receive from my parent */
+ MPI_Bcast(&num, 1, MPI_INT, 0, parentcomm);
+
+ if (num != threadnum) {
+ fprintf(stderr, "Unexpected thread num (%d != %d)\n", threadnum, num);
+ }
- if (num != threadnum) {
- fprintf( stderr, "Unexpected thread num (%d != %d)\n",
- threadnum, num );
- }
+ /* Let the parent free the intercomms */
+ MPI_Comm_disconnect(&parentcomm);
- /* Let the parent free the intercomms */
- MPI_Comm_disconnect( &parentcomm );
-
}
- if (wasParent)
- MTest_Finalize(0);
+ if (wasParent)
+ MTest_Finalize(0);
MPI_Finalize();
return 0;
diff --git a/test/mpi/threads/spawn/th_taskmaster.c b/test/mpi/threads/spawn/th_taskmaster.c
index 3bb3f58..3c405a1 100644
--- a/test/mpi/threads/spawn/th_taskmaster.c
+++ b/test/mpi/threads/spawn/th_taskmaster.c
@@ -29,28 +29,27 @@ MPI_Comm th_comms[DEFAULT_TASK_WINDOW];
void process_spawn(MPI_Comm * comm, int thread_id);
void process_spawn(MPI_Comm * comm, int thread_id)
{
- CHECK_SUCCESS(MPI_Comm_spawn((char*)"./th_taskmaster", (char **)NULL,
- 1, MPI_INFO_NULL, 0,
- th_comms[thread_id], comm, NULL));
+ CHECK_SUCCESS(MPI_Comm_spawn((char *) "./th_taskmaster", (char **) NULL,
+ 1, MPI_INFO_NULL, 0, th_comms[thread_id], comm, NULL));
}
void process_disconnect(MPI_Comm * comm, int thread_id);
void process_disconnect(MPI_Comm * comm, int thread_id)
{
if (comm_world_rank == 0) {
- CHECK_SUCCESS(MPI_Recv(NULL, 0, MPI_CHAR, 0, 1, *comm, MPI_STATUS_IGNORE));
- CHECK_SUCCESS(MPI_Send(NULL, 0, MPI_CHAR, 0, 1, *comm));
+ CHECK_SUCCESS(MPI_Recv(NULL, 0, MPI_CHAR, 0, 1, *comm, MPI_STATUS_IGNORE));
+ CHECK_SUCCESS(MPI_Send(NULL, 0, MPI_CHAR, 0, 1, *comm));
}
CHECK_SUCCESS(MPI_Comm_disconnect(comm));
}
#ifdef USE_THREADS
-MTEST_THREAD_RETURN_TYPE main_thread(void * arg);
-MTEST_THREAD_RETURN_TYPE main_thread(void * arg)
+MTEST_THREAD_RETURN_TYPE main_thread(void *arg);
+MTEST_THREAD_RETURN_TYPE main_thread(void *arg)
{
MPI_Comm child_comm;
- int thread_id = (int)(size_t)arg;
+ int thread_id = (int) (size_t) arg;
process_spawn(&child_comm, thread_id);
CHECK_SUCCESS(MPI_Comm_set_errhandler(child_comm, MPI_ERRORS_RETURN));
@@ -65,14 +64,14 @@ int main(int argc, char *argv[])
int tasks = 0, provided, i, j;
MPI_Comm parent;
#ifndef USE_THREADS
- MPI_Comm * child;
+ MPI_Comm *child;
#endif /* USE_THREADS */
#ifdef USE_THREADS
CHECK_SUCCESS(MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided));
if (provided != MPI_THREAD_MULTIPLE) {
- fprintf(stderr, "MPI does not provide THREAD_MULTIPLE support\n");
- MPI_Abort(MPI_COMM_WORLD, -1);
+ fprintf(stderr, "MPI does not provide THREAD_MULTIPLE support\n");
+ MPI_Abort(MPI_COMM_WORLD, -1);
}
#else
CHECK_SUCCESS(MPI_Init(&argc, &argv));
@@ -80,27 +79,27 @@ int main(int argc, char *argv[])
CHECK_SUCCESS(MPI_Comm_get_parent(&parent));
- if (parent == MPI_COMM_NULL) { /* Parent communicator */
- if (argc == 2) {
- tasks = atoi(argv[1]);
- }
- else if (argc == 1) {
- tasks = DEFAULT_TASKS;
- }
- else {
- fprintf(stderr, "Usage: %s {number_of_tasks}\n", argv[0]);
- MPI_Abort(MPI_COMM_WORLD, -1);
- }
-
- CHECK_SUCCESS(MPI_Comm_rank(MPI_COMM_WORLD, &comm_world_rank));
- CHECK_SUCCESS(MPI_Comm_size(MPI_COMM_WORLD, &comm_world_size));
+ if (parent == MPI_COMM_NULL) { /* Parent communicator */
+ if (argc == 2) {
+ tasks = atoi(argv[1]);
+ }
+ else if (argc == 1) {
+ tasks = DEFAULT_TASKS;
+ }
+ else {
+ fprintf(stderr, "Usage: %s {number_of_tasks}\n", argv[0]);
+ MPI_Abort(MPI_COMM_WORLD, -1);
+ }
+
+ CHECK_SUCCESS(MPI_Comm_rank(MPI_COMM_WORLD, &comm_world_rank));
+ CHECK_SUCCESS(MPI_Comm_size(MPI_COMM_WORLD, &comm_world_size));
#ifndef USE_THREADS
- child = (MPI_Comm *) malloc(tasks * sizeof(MPI_Comm));
- if (!child) {
- fprintf(stderr, "Unable to allocate memory for child communicators\n");
- MPI_Abort(MPI_COMM_WORLD, -1);
- }
+ child = (MPI_Comm *) malloc(tasks * sizeof(MPI_Comm));
+ if (!child) {
+ fprintf(stderr, "Unable to allocate memory for child communicators\n");
+ MPI_Abort(MPI_COMM_WORLD, -1);
+ }
#endif /* USE_THREADS */
#ifdef USE_THREADS
@@ -108,43 +107,43 @@ int main(int argc, char *argv[])
for (i = 0; i < DEFAULT_TASK_WINDOW; i++)
CHECK_SUCCESS(MPI_Comm_dup(MPI_COMM_WORLD, &th_comms[i]));
- /* Create a thread for each task. Each thread will spawn a
- * child process to perform its task. */
- for (i = 0; i < tasks;) {
- for (j = 0; j < DEFAULT_TASK_WINDOW; j++){
- MTest_Start_thread(main_thread, (void*)(size_t)j);
+ /* Create a thread for each task. Each thread will spawn a
+ * child process to perform its task. */
+ for (i = 0; i < tasks;) {
+ for (j = 0; j < DEFAULT_TASK_WINDOW; j++) {
+ MTest_Start_thread(main_thread, (void *) (size_t) j);
+ }
+ MTest_Join_threads();
+ i += DEFAULT_TASK_WINDOW;
}
- MTest_Join_threads();
- i += DEFAULT_TASK_WINDOW;
- }
for (i = 0; i < DEFAULT_TASK_WINDOW; i++)
CHECK_SUCCESS(MPI_Comm_free(&th_comms[i]));
#else
- /* Directly spawn a child process to perform each task */
- for (i = 0; i < tasks;) {
- for (j = 0; j < DEFAULT_TASK_WINDOW; j++)
- process_spawn(&child[j], -1);
- for (j = 0; j < DEFAULT_TASK_WINDOW; j++)
- process_disconnect(&child[j], -1);
- i += DEFAULT_TASK_WINDOW;
- }
+ /* Directly spawn a child process to perform each task */
+ for (i = 0; i < tasks;) {
+ for (j = 0; j < DEFAULT_TASK_WINDOW; j++)
+ process_spawn(&child[j], -1);
+ for (j = 0; j < DEFAULT_TASK_WINDOW; j++)
+ process_disconnect(&child[j], -1);
+ i += DEFAULT_TASK_WINDOW;
+ }
#endif /* USE_THREADS */
- CHECK_SUCCESS(MPI_Barrier(MPI_COMM_WORLD));
+ CHECK_SUCCESS(MPI_Barrier(MPI_COMM_WORLD));
- if (comm_world_rank == 0)
- printf(" No Errors\n");
+ if (comm_world_rank == 0)
+ printf(" No Errors\n");
}
- else { /* Child communicator */
- /* Do some work here and send a message to the root process in
- * the parent communicator. */
- CHECK_SUCCESS(MPI_Send(NULL, 0, MPI_CHAR, 0, 1, parent));
- CHECK_SUCCESS(MPI_Recv(NULL, 0, MPI_CHAR, 0, 1, parent, MPI_STATUS_IGNORE));
- CHECK_SUCCESS(MPI_Comm_disconnect(&parent));
+ else { /* Child communicator */
+ /* Do some work here and send a message to the root process in
+ * the parent communicator. */
+ CHECK_SUCCESS(MPI_Send(NULL, 0, MPI_CHAR, 0, 1, parent));
+ CHECK_SUCCESS(MPI_Recv(NULL, 0, MPI_CHAR, 0, 1, parent, MPI_STATUS_IGNORE));
+ CHECK_SUCCESS(MPI_Comm_disconnect(&parent));
}
-fn_exit:
+ fn_exit:
MPI_Finalize();
return 0;
diff --git a/test/mpi/threads/util/mtestthread.c b/test/mpi/threads/util/mtestthread.c
index eecf2bb..e091e6a 100644
--- a/test/mpi/threads/util/mtestthread.c
+++ b/test/mpi/threads/util/mtestthread.c
@@ -21,12 +21,12 @@
#include "mpitest.h"
#include "mpithreadtest.h"
-/* This file provides a portability layer for using threads. Currently,
- it supports POSIX threads (pthreads) and Windows threads. Testing has
+/* This file provides a portability layer for using threads. Currently,
+ it supports POSIX threads (pthreads) and Windows threads. Testing has
been performed for pthreads.
*/
-/* We remember all of the threads we create; this similifies terminating
+/* We remember all of the threads we create; this similifies terminating
(joining) them. */
#ifndef MTEST_MAX_THREADS
#define MTEST_MAX_THREADS 16
@@ -38,32 +38,32 @@ static MTEST_THREAD_HANDLE threads[MTEST_MAX_THREADS];
static volatile int nthreads = 0;
#ifdef HAVE_WINDOWS_H
-int MTest_Start_thread(MTEST_THREAD_RETURN_TYPE (*fn)(void *p),void *arg)
+int MTest_Start_thread(MTEST_THREAD_RETURN_TYPE(*fn) (void *p), void *arg)
{
if (nthreads >= MTEST_MAX_THREADS) {
- fprintf( stderr, "Too many threads already created: max is %d\n",
- MTEST_MAX_THREADS );
- return 1;
+ fprintf(stderr, "Too many threads already created: max is %d\n", MTEST_MAX_THREADS);
+ return 1;
}
- threads[nthreads] = CreateThread(NULL, 0,(LPTHREAD_START_ROUTINE)fn, (LPVOID)arg, 0, NULL);
- if (threads[nthreads] == NULL){
+ threads[nthreads] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) fn, (LPVOID) arg, 0, NULL);
+ if (threads[nthreads] == NULL) {
return GetLastError();
}
- else{
+ else {
nthreads++;
}
return 0;
}
-int MTest_Join_threads( void ){
+int MTest_Join_threads(void)
+{
int i, err = 0;
- for (i=0; i<nthreads; i++) {
- if(threads[i] != INVALID_HANDLE_VALUE){
- if(WaitForSingleObject(threads[i], INFINITE) == WAIT_FAILED){
+ for (i = 0; i < nthreads; i++) {
+ if (threads[i] != INVALID_HANDLE_VALUE) {
+ if (WaitForSingleObject(threads[i], INFINITE) == WAIT_FAILED) {
err = GetLastError();
fprintf(stderr, "Error WaitForSingleObject(), err = %d\n", err);
}
- else{
+ else {
CloseHandle(threads[i]);
}
}
@@ -72,40 +72,45 @@ int MTest_Join_threads( void ){
return err;
}
-int MTest_thread_lock_create( MTEST_THREAD_LOCK_TYPE *lock )
+int MTest_thread_lock_create(MTEST_THREAD_LOCK_TYPE * lock)
{
- if(lock == NULL) return -1;
+ if (lock == NULL)
+ return -1;
/* Create an unnamed uninheritable mutex */
*lock = CreateMutex(NULL, FALSE, NULL);
- if(*lock == NULL) return -1;
+ if (*lock == NULL)
+ return -1;
return 0;
}
-int MTest_thread_lock( MTEST_THREAD_LOCK_TYPE *lock )
+int MTest_thread_lock(MTEST_THREAD_LOCK_TYPE * lock)
{
- if(lock == NULL) return -1;
+ if (lock == NULL)
+ return -1;
/* Wait infinitely for the mutex */
- if(WaitForSingleObject(*lock, INFINITE) != WAIT_OBJECT_0){
+ if (WaitForSingleObject(*lock, INFINITE) != WAIT_OBJECT_0) {
return -1;
}
return 0;
}
-int MTest_thread_unlock( MTEST_THREAD_LOCK_TYPE *lock )
+int MTest_thread_unlock(MTEST_THREAD_LOCK_TYPE * lock)
{
- if(lock == NULL) return -1;
- if(ReleaseMutex(*lock) == 0){
+ if (lock == NULL)
+ return -1;
+ if (ReleaseMutex(*lock) == 0) {
return -1;
}
return 0;
}
-int MTest_thread_lock_free( MTEST_THREAD_LOCK_TYPE *lock )
+
+int MTest_thread_lock_free(MTEST_THREAD_LOCK_TYPE * lock)
{
- if(lock != NULL){
- if(CloseHandle(*lock) == 0){
+ if (lock != NULL) {
+ if (CloseHandle(*lock) == 0) {
return -1;
}
}
@@ -113,7 +118,7 @@ int MTest_thread_lock_free( MTEST_THREAD_LOCK_TYPE *lock )
}
#else
-int MTest_Start_thread(MTEST_THREAD_RETURN_TYPE (*fn)(void *p),void *arg)
+int MTest_Start_thread(MTEST_THREAD_RETURN_TYPE(*fn) (void *p), void *arg)
{
int err;
pthread_attr_t attr;
@@ -121,60 +126,65 @@ int MTest_Start_thread(MTEST_THREAD_RETURN_TYPE (*fn)(void *p),void *arg)
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
if (nthreads >= MTEST_MAX_THREADS) {
- fprintf( stderr, "Too many threads already created: max is %d\n",
- MTEST_MAX_THREADS );
- return 1;
+ fprintf(stderr, "Too many threads already created: max is %d\n", MTEST_MAX_THREADS);
+ return 1;
}
- err = pthread_create(threads+nthreads, &attr, fn, arg);
+ err = pthread_create(threads + nthreads, &attr, fn, arg);
if (!err) {
nthreads++;
}
pthread_attr_destroy(&attr);
return err;
}
-int MTest_Join_threads( void )
+
+int MTest_Join_threads(void)
{
int i, rc, err = 0;
- for (i=0; i<nthreads; i++) {
+ for (i = 0; i < nthreads; i++) {
rc = pthread_join(threads[i], 0);
- if (rc) err = rc;
+ if (rc)
+ err = rc;
}
nthreads = 0;
return err;
}
-int MTest_thread_lock_create( MTEST_THREAD_LOCK_TYPE *lock )
+
+int MTest_thread_lock_create(MTEST_THREAD_LOCK_TYPE * lock)
{
int err;
- err = pthread_mutex_init( lock, NULL );
+ err = pthread_mutex_init(lock, NULL);
if (err) {
- perror( "Failed to initialize lock:" );
+ perror("Failed to initialize lock:");
}
return err;
}
-int MTest_thread_lock( MTEST_THREAD_LOCK_TYPE *lock )
+
+int MTest_thread_lock(MTEST_THREAD_LOCK_TYPE * lock)
{
int err;
- err = pthread_mutex_lock( lock );
+ err = pthread_mutex_lock(lock);
if (err) {
- perror( "Failed to acquire lock:" );
+ perror("Failed to acquire lock:");
}
return err;
}
-int MTest_thread_unlock( MTEST_THREAD_LOCK_TYPE *lock )
+
+int MTest_thread_unlock(MTEST_THREAD_LOCK_TYPE * lock)
{
int err;
- err = pthread_mutex_unlock( lock );
+ err = pthread_mutex_unlock(lock);
if (err) {
- perror( "Failed to release lock:" );
+ perror("Failed to release lock:");
}
return err;
}
-int MTest_thread_lock_free( MTEST_THREAD_LOCK_TYPE *lock )
+
+int MTest_thread_lock_free(MTEST_THREAD_LOCK_TYPE * lock)
{
int err;
- err = pthread_mutex_destroy( lock );
+ err = pthread_mutex_destroy(lock);
if (err) {
- perror( "Failed to free lock:" );
+ perror("Failed to free lock:");
}
return err;
}
@@ -184,88 +194,113 @@ int MTest_thread_lock_free( MTEST_THREAD_LOCK_TYPE *lock )
static MTEST_THREAD_LOCK_TYPE barrierLock;
static pthread_barrier_t barrier;
static int bcount = -1;
-int MTest_thread_barrier_init( void )
+int MTest_thread_barrier_init(void)
{
- bcount = -1; /* must reset to force barrier re-creation */
- return MTest_thread_lock_create( &barrierLock );
+ bcount = -1; /* must reset to force barrier re-creation */
+ return MTest_thread_lock_create(&barrierLock);
}
-int MTest_thread_barrier_free( void )
+
+int MTest_thread_barrier_free(void)
{
- MTest_thread_lock_free( &barrierLock );
- return pthread_barrier_destroy( &barrier );
+ MTest_thread_lock_free(&barrierLock);
+ return pthread_barrier_destroy(&barrier);
}
+
/* FIXME this barrier interface should be changed to more closely match the
* pthread interface. Specifically, nt should not be a barrier-time
* parameter but an init-time parameter. The double-checked locking below
* isn't valid according to pthreads, and it isn't guaranteed to be robust
* in the presence of aggressive CPU/compiler optimization. */
-int MTest_thread_barrier( int nt )
+int MTest_thread_barrier(int nt)
{
int err;
- if (nt < 0) nt = nthreads;
+ if (nt < 0)
+ nt = nthreads;
if (bcount != nt) {
- /* One thread needs to initialize the barrier */
- MTest_thread_lock( &barrierLock );
- /* Test again in case another thread already fixed the problem */
- if (bcount != nt) {
- if (bcount > 0) {
- err = pthread_barrier_destroy( &barrier );
- if (err) return err;
- }
- err = pthread_barrier_init( &barrier, NULL, nt );
- if (err) return err;
- bcount = nt;
- }
- err = MTest_thread_unlock( &barrierLock );
- if (err) return err;
+ /* One thread needs to initialize the barrier */
+ MTest_thread_lock(&barrierLock);
+ /* Test again in case another thread already fixed the problem */
+ if (bcount != nt) {
+ if (bcount > 0) {
+ err = pthread_barrier_destroy(&barrier);
+ if (err)
+ return err;
+ }
+ err = pthread_barrier_init(&barrier, NULL, nt);
+ if (err)
+ return err;
+ bcount = nt;
+ }
+ err = MTest_thread_unlock(&barrierLock);
+ if (err)
+ return err;
}
- return pthread_barrier_wait( &barrier );
+ return pthread_barrier_wait(&barrier);
}
#else
static MTEST_THREAD_LOCK_TYPE barrierLock;
-static volatile int phase=0;
-static volatile int c[2] = {-1,-1};
-int MTest_thread_barrier_init( void )
+static volatile int phase = 0;
+static volatile int c[2] = { -1, -1 };
+
+int MTest_thread_barrier_init(void)
{
- return MTest_thread_lock_create( &barrierLock );
+ return MTest_thread_lock_create(&barrierLock);
}
-int MTest_thread_barrier_free( void )
+
+int MTest_thread_barrier_free(void)
{
- return MTest_thread_lock_free( &barrierLock );
+ return MTest_thread_lock_free(&barrierLock);
}
-/* This is a generic barrier implementation. To ensure that tests don't
+
+/* This is a generic barrier implementation. To ensure that tests don't
silently fail, this both prints an error message and returns an error
result on any failure. */
-int MTest_thread_barrier( int nt )
+int MTest_thread_barrier(int nt)
{
volatile int *cntP;
- int err = 0;
+ int err = 0;
- if (nt < 0) nt = nthreads;
+ if (nt < 0)
+ nt = nthreads;
/* Force a write barrier by using lock/unlock */
- err = MTest_thread_lock( &barrierLock );
- if (err) { fprintf( stderr, "Lock failed in barrier!\n" ); return err; }
+ err = MTest_thread_lock(&barrierLock);
+ if (err) {
+ fprintf(stderr, "Lock failed in barrier!\n");
+ return err;
+ }
cntP = &c[phase];
- err = MTest_thread_unlock( &barrierLock );
- if (err) { fprintf( stderr, "Unlock failed in barrier!\n" ); return err; }
+ err = MTest_thread_unlock(&barrierLock);
+ if (err) {
+ fprintf(stderr, "Unlock failed in barrier!\n");
+ return err;
+ }
- /* printf( "[%d] cnt = %d, phase = %d\n", pthread_self(), *cntP, phase ); */
- err = MTest_thread_lock( &barrierLock );
- if (err) { fprintf( stderr, "Lock failed in barrier!\n" ); return err; }
+ /* printf("[%d] cnt = %d, phase = %d\n", pthread_self(), *cntP, phase); */
+ err = MTest_thread_lock(&barrierLock);
+ if (err) {
+ fprintf(stderr, "Lock failed in barrier!\n");
+ return err;
+ }
/* The first thread to enter will reset the counter */
- if (*cntP < 0) *cntP = nt;
- /* printf( "phase = %d, cnt = %d\n", phase, *cntP ); */
+ if (*cntP < 0)
+ *cntP = nt;
+ /* printf("phase = %d, cnt = %d\n", phase, *cntP); */
/* The last thread to enter will force the counter to be negative */
- if (*cntP == 1) {
- /* printf( "[%d] changing phase from %d\n", pthread_self(), phase ); */
- phase = !phase; c[phase] = -1; *cntP = 0;
+ if (*cntP == 1) {
+ /* printf("[%d] changing phase from %d\n", pthread_self(), phase); */
+ phase = !phase;
+ c[phase] = -1;
+ *cntP = 0;
}
/* Really need a write barrier here */
*cntP = *cntP - 1;
- err = MTest_thread_unlock( &barrierLock );
- if (err) { fprintf( stderr, "Unlock failed in barrier!\n" ); return err; }
- while (*cntP > 0) ;
-
+ err = MTest_thread_unlock(&barrierLock);
+ if (err) {
+ fprintf(stderr, "Unlock failed in barrier!\n");
+ return err;
+ }
+ while (*cntP > 0);
+
return err;
}
#endif /* Default barrier routine */
diff --git a/test/mpi/topo/cartcreates.c b/test/mpi/topo/cartcreates.c
index 92365d7..6f1420a 100644
--- a/test/mpi/topo/cartcreates.c
+++ b/test/mpi/topo/cartcreates.c
@@ -8,45 +8,44 @@
#include <stdio.h>
#include "mpitest.h"
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int size, rank;
int dims[2], periods[2];
MPI_Comm comm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
/* Create a new cartesian communicator in a subset of the processes */
- MPI_Comm_size( MPI_COMM_WORLD, &size );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (size < 2) {
- fprintf( stderr, "This test needs at least 2 processes\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "This test needs at least 2 processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- dims[0] = size-1;
+ dims[0] = size - 1;
periods[0] = 1;
- MPI_Cart_create( MPI_COMM_WORLD, 1, dims, periods, 0, &comm );
+ MPI_Cart_create(MPI_COMM_WORLD, 1, dims, periods, 0, &comm);
if (comm != MPI_COMM_NULL) {
- int csize;
- MPI_Comm_size( comm, &csize );
- if (csize != dims[0]) {
- errs++;
- fprintf( stderr,
- "Sizes is wrong in cart communicator. Is %d, should be %d\n",
- csize, dims[0] );
- }
- MPI_Barrier( comm );
-
- MPI_Comm_free( &comm );
- }
+ int csize;
+ MPI_Comm_size(comm, &csize);
+ if (csize != dims[0]) {
+ errs++;
+ fprintf(stderr,
+ "Sizes is wrong in cart communicator. Is %d, should be %d\n", csize, dims[0]);
+ }
+ MPI_Barrier(comm);
+
+ MPI_Comm_free(&comm);
+ }
else if (rank < dims[0]) {
- errs++;
- fprintf( stderr, "Communicator returned is null!" );
+ errs++;
+ fprintf(stderr, "Communicator returned is null!");
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
diff --git a/test/mpi/topo/cartmap1.c b/test/mpi/topo/cartmap1.c
index 1ce5ad8..30d1c56 100644
--- a/test/mpi/topo/cartmap1.c
+++ b/test/mpi/topo/cartmap1.c
@@ -8,57 +8,57 @@
#include <stdio.h>
#include "mpitest.h"
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int dims[2];
int periods[2];
int size, rank, newrank;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
+
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- MPI_Comm_size( MPI_COMM_WORLD, &size );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
-
/* This defines a one dimensional cartision grid with a single point */
periods[0] = 1;
dims[0] = 1;
- MPI_Cart_map( MPI_COMM_WORLD, 1, dims, periods, &newrank );
+ MPI_Cart_map(MPI_COMM_WORLD, 1, dims, periods, &newrank);
if (rank > 0) {
- if (newrank != MPI_UNDEFINED) {
- errs++;
- printf( "rank outside of input communicator not UNDEFINED\n" );
- }
+ if (newrank != MPI_UNDEFINED) {
+ errs++;
+ printf("rank outside of input communicator not UNDEFINED\n");
+ }
}
else {
- if (rank != newrank) {
- errs++;
- printf( "Newrank not defined and should be 0\n" );
- }
+ if (rank != newrank) {
+ errs++;
+ printf("Newrank not defined and should be 0\n");
+ }
}
/* As of MPI 2.1, a 0-dimensional topology is valid (its also a
- point) */
- MPI_Cart_map( MPI_COMM_WORLD, 0, dims, periods, &newrank );
+ * point) */
+ MPI_Cart_map(MPI_COMM_WORLD, 0, dims, periods, &newrank);
if (rank > 0) {
- if (newrank != MPI_UNDEFINED) {
- errs++;
- printf( "rank outside of input communicator not UNDEFINED\n" );
- }
+ if (newrank != MPI_UNDEFINED) {
+ errs++;
+ printf("rank outside of input communicator not UNDEFINED\n");
+ }
}
else {
- /* rank == 0 */
- if (rank != newrank) {
- errs++;
- printf( "Newrank not defined and should be 0\n" );
- }
+ /* rank == 0 */
+ if (rank != newrank) {
+ errs++;
+ printf("Newrank not defined and should be 0\n");
+ }
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/topo/cartshift1.c b/test/mpi/topo/cartshift1.c
index 679f12c..5416b37 100644
--- a/test/mpi/topo/cartshift1.c
+++ b/test/mpi/topo/cartshift1.c
@@ -8,7 +8,7 @@
#include <stdio.h>
#include "mpitest.h"
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int size, rank;
@@ -16,81 +16,77 @@ int main( int argc, char *argv[] )
int dims[2], periods[2];
MPI_Comm comm;
- MTest_Init( &argc, &argv );
-
- MPI_Comm_size( MPI_COMM_WORLD, &size );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- dims[0] = size;
+ MTest_Init(&argc, &argv);
+
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ dims[0] = size;
periods[0] = 1;
- MPI_Cart_create( MPI_COMM_WORLD, 1, dims, periods, 0, &comm );
- MPI_Cart_shift( comm, 0, 1, &source, &dest );
+ MPI_Cart_create(MPI_COMM_WORLD, 1, dims, periods, 0, &comm);
+ MPI_Cart_shift(comm, 0, 1, &source, &dest);
if (source != ((rank - 1 + size) % size)) {
- errs++;
- printf( "source for shift 1 is %d\n", source );
+ errs++;
+ printf("source for shift 1 is %d\n", source);
}
if (dest != ((rank + 1) % size)) {
- errs++;
- printf( "dest for shift 1 is %d\n", dest );
+ errs++;
+ printf("dest for shift 1 is %d\n", dest);
}
- MPI_Cart_shift( comm, 0, 0, &source, &dest );
+ MPI_Cart_shift(comm, 0, 0, &source, &dest);
if (source != rank) {
- errs++;
- printf( "Source for shift 0 is %d\n", source );
+ errs++;
+ printf("Source for shift 0 is %d\n", source);
}
if (dest != rank) {
- errs++;
- printf( "Dest for shift 0 is %d\n", dest );
+ errs++;
+ printf("Dest for shift 0 is %d\n", dest);
}
- MPI_Cart_shift( comm, 0, -1, &source, &dest );
+ MPI_Cart_shift(comm, 0, -1, &source, &dest);
if (source != ((rank + 1) % size)) {
- errs++;
- printf( "source for shift -1 is %d\n", source );
+ errs++;
+ printf("source for shift -1 is %d\n", source);
}
if (dest != ((rank - 1 + size) % size)) {
- errs++;
- printf( "dest for shift -1 is %d\n", dest );
+ errs++;
+ printf("dest for shift -1 is %d\n", dest);
}
/* Now, with non-periodic */
- MPI_Comm_free( &comm );
+ MPI_Comm_free(&comm);
periods[0] = 0;
- MPI_Cart_create( MPI_COMM_WORLD, 1, dims, periods, 0, &comm );
- MPI_Cart_shift( comm, 0, 1, &source, &dest );
- if ((rank > 0 && source != (rank - 1)) ||
- (rank == 0 && source != MPI_PROC_NULL)) {
- errs++;
- printf( "source for non-periodic shift 1 is %d\n", source );
+ MPI_Cart_create(MPI_COMM_WORLD, 1, dims, periods, 0, &comm);
+ MPI_Cart_shift(comm, 0, 1, &source, &dest);
+ if ((rank > 0 && source != (rank - 1)) || (rank == 0 && source != MPI_PROC_NULL)) {
+ errs++;
+ printf("source for non-periodic shift 1 is %d\n", source);
}
- if ((rank < size-1 && dest != rank + 1) ||
- ((rank == size-1) && dest != MPI_PROC_NULL)) {
- errs++;
- printf( "dest for non-periodic shift 1 is %d\n", dest );
+ if ((rank < size - 1 && dest != rank + 1) || ((rank == size - 1) && dest != MPI_PROC_NULL)) {
+ errs++;
+ printf("dest for non-periodic shift 1 is %d\n", dest);
}
- MPI_Cart_shift( comm, 0, 0, &source, &dest );
+ MPI_Cart_shift(comm, 0, 0, &source, &dest);
if (source != rank) {
- errs++;
- printf( "Source for non-periodic shift 0 is %d\n", source );
+ errs++;
+ printf("Source for non-periodic shift 0 is %d\n", source);
}
if (dest != rank) {
- errs++;
- printf( "Dest for non-periodic shift 0 is %d\n", dest );
+ errs++;
+ printf("Dest for non-periodic shift 0 is %d\n", dest);
}
- MPI_Cart_shift( comm, 0, -1, &source, &dest );
- if ((rank < size - 1 && source != rank + 1) ||
- (rank == size - 1 && source != MPI_PROC_NULL)) {
-
- errs++;
- printf( "source for non-periodic shift -1 is %d\n", source );
+ MPI_Cart_shift(comm, 0, -1, &source, &dest);
+ if ((rank < size - 1 && source != rank + 1) || (rank == size - 1 && source != MPI_PROC_NULL)) {
+
+ errs++;
+ printf("source for non-periodic shift -1 is %d\n", source);
}
- if ((rank > 0 && dest != rank - 1) ||
- (rank == 0 && dest != MPI_PROC_NULL)) {
- errs++;
- printf( "dest for non-periodic shift -1 is %d\n", dest );
+ if ((rank > 0 && dest != rank - 1) || (rank == 0 && dest != MPI_PROC_NULL)) {
+ errs++;
+ printf("dest for non-periodic shift -1 is %d\n", dest);
}
- MPI_Comm_free( &comm );
-
- MTest_Finalize( errs );
+ MPI_Comm_free(&comm);
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/topo/cartsuball.c b/test/mpi/topo/cartsuball.c
index 890db5a..5f81799 100644
--- a/test/mpi/topo/cartsuball.c
+++ b/test/mpi/topo/cartsuball.c
@@ -8,47 +8,47 @@
#include <stdio.h>
#include "mpitest.h"
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int size, dims[2], periods[2], remain[2];
int result, rank;
MPI_Comm comm, newcomm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
/* First, create a 1-dim cartesian communicator */
periods[0] = 0;
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
dims[0] = size;
- MPI_Cart_create( MPI_COMM_WORLD, 1, dims, periods, 0, &comm );
-
+ MPI_Cart_create(MPI_COMM_WORLD, 1, dims, periods, 0, &comm);
+
/* Now, extract a communicator with no dimensions */
remain[0] = 0;
- MPI_Cart_sub( comm, remain, &newcomm );
+ MPI_Cart_sub(comm, remain, &newcomm);
MPI_Comm_rank(comm, &rank);
if (rank == 0) {
- /* This should be congruent to MPI_COMM_SELF */
- MPI_Comm_compare( MPI_COMM_SELF, newcomm, &result );
- if (result != MPI_CONGRUENT) {
- errs++;
- printf( "cart sub to size 0 did not give self\n" );
- }
- MPI_Comm_free( &newcomm );
+ /* This should be congruent to MPI_COMM_SELF */
+ MPI_Comm_compare(MPI_COMM_SELF, newcomm, &result);
+ if (result != MPI_CONGRUENT) {
+ errs++;
+ printf("cart sub to size 0 did not give self\n");
+ }
+ MPI_Comm_free(&newcomm);
}
else if (newcomm != MPI_COMM_NULL) {
- errs++;
- printf( "cart sub to size 0 did not give null\n" );
+ errs++;
+ printf("cart sub to size 0 did not give null\n");
}
/* Free the new communicator so that storage leak tests will
- be happy */
- MPI_Comm_free( &comm );
-
- MTest_Finalize( errs );
+ * be happy */
+ MPI_Comm_free(&comm);
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/topo/cartzero.c b/test/mpi/topo/cartzero.c
index c8e601e..370947f 100644
--- a/test/mpi/topo/cartzero.c
+++ b/test/mpi/topo/cartzero.c
@@ -8,83 +8,80 @@
#include <stdio.h>
#include "mpitest.h"
-/*
+/*
Check that the MPI implementation properly handles zero-dimensional
Cartesian communicators - the original standard implies that these
- should be consistent with higher dimensional topologies and thus
+ should be consistent with higher dimensional topologies and thus
these should work with any MPI implementation. MPI 2.1 made this
requirement explicit.
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int size, rank, ndims;
MPI_Comm comm, newcomm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
/* Create a new cartesian communicator in a subset of the processes */
- MPI_Comm_size( MPI_COMM_WORLD, &size );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (size < 2) {
- fprintf( stderr, "This test needs at least 2 processes\n" );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "This test needs at least 2 processes\n");
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
- MPI_Cart_create( MPI_COMM_WORLD, 0, NULL, NULL, 0, &comm );
+ MPI_Cart_create(MPI_COMM_WORLD, 0, NULL, NULL, 0, &comm);
if (comm != MPI_COMM_NULL) {
- int csize;
- MPI_Comm_size( comm, &csize );
- if (csize != 1) {
- errs++;
- fprintf( stderr,
- "Sizes is wrong in cart communicator. Is %d, should be 1\n",
- csize );
- }
-
- /* This function is not meaningful, but should not fail */
- MPI_Dims_create(1, 0, NULL);
-
- ndims = -1;
- MPI_Cartdim_get(comm, &ndims);
- if (ndims != 0) {
- errs++;
- fprintf(stderr, "MPI_Cartdim_get: ndims is %d, should be 0\n", ndims);
- }
-
- /* this function should not fail */
- MPI_Cart_get(comm, 0, NULL, NULL, NULL);
-
- MPI_Cart_rank(comm, NULL, &rank);
- if (rank != 0) {
- errs++;
- fprintf(stderr, "MPI_Cart_rank: rank is %d, should be 0\n", rank);
- }
-
- /* this function should not fail */
- MPI_Cart_coords(comm, 0, 0, NULL);
-
- MPI_Cart_sub(comm, NULL, &newcomm);
- ndims = -1;
- MPI_Cartdim_get(newcomm, &ndims);
- if (ndims != 0) {
- errs++;
- fprintf(stderr,
- "MPI_Cart_sub did not return zero-dimensional communicator\n");
- }
-
- MPI_Barrier( comm );
-
- MPI_Comm_free( &comm );
- MPI_Comm_free( &newcomm );
- }
+ int csize;
+ MPI_Comm_size(comm, &csize);
+ if (csize != 1) {
+ errs++;
+ fprintf(stderr, "Sizes is wrong in cart communicator. Is %d, should be 1\n", csize);
+ }
+
+ /* This function is not meaningful, but should not fail */
+ MPI_Dims_create(1, 0, NULL);
+
+ ndims = -1;
+ MPI_Cartdim_get(comm, &ndims);
+ if (ndims != 0) {
+ errs++;
+ fprintf(stderr, "MPI_Cartdim_get: ndims is %d, should be 0\n", ndims);
+ }
+
+ /* this function should not fail */
+ MPI_Cart_get(comm, 0, NULL, NULL, NULL);
+
+ MPI_Cart_rank(comm, NULL, &rank);
+ if (rank != 0) {
+ errs++;
+ fprintf(stderr, "MPI_Cart_rank: rank is %d, should be 0\n", rank);
+ }
+
+ /* this function should not fail */
+ MPI_Cart_coords(comm, 0, 0, NULL);
+
+ MPI_Cart_sub(comm, NULL, &newcomm);
+ ndims = -1;
+ MPI_Cartdim_get(newcomm, &ndims);
+ if (ndims != 0) {
+ errs++;
+ fprintf(stderr, "MPI_Cart_sub did not return zero-dimensional communicator\n");
+ }
+
+ MPI_Barrier(comm);
+
+ MPI_Comm_free(&comm);
+ MPI_Comm_free(&newcomm);
+ }
else if (rank == 0) {
- errs++;
- fprintf( stderr, "Communicator returned is null!" );
+ errs++;
+ fprintf(stderr, "Communicator returned is null!");
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
diff --git a/test/mpi/topo/dgraph_unwgt.c b/test/mpi/topo/dgraph_unwgt.c
index 0f31e2c..bda3570 100644
--- a/test/mpi/topo/dgraph_unwgt.c
+++ b/test/mpi/topo/dgraph_unwgt.c
@@ -15,27 +15,26 @@
static int validate_dgraph(MPI_Comm dgraph_comm)
{
- int comm_topo;
- int src_sz, dest_sz;
- int wgt_flag, ierr;
- int srcs[RING_NUM_NEIGHBORS], dests[RING_NUM_NEIGHBORS];
- int *src_wgts, *dest_wgts;
+ int comm_topo;
+ int src_sz, dest_sz;
+ int wgt_flag, ierr;
+ int srcs[RING_NUM_NEIGHBORS], dests[RING_NUM_NEIGHBORS];
+ int *src_wgts, *dest_wgts;
- int world_rank, world_size;
- int idx, nbr_sep;
+ int world_rank, world_size;
+ int idx, nbr_sep;
comm_topo = MPI_UNDEFINED;
MPI_Topo_test(dgraph_comm, &comm_topo);
switch (comm_topo) {
- case MPI_DIST_GRAPH :
- break;
- default:
- fprintf(stderr, "dgraph_comm is NOT of type MPI_DIST_GRAPH\n");
- return 0;
+ case MPI_DIST_GRAPH:
+ break;
+ default:
+ fprintf(stderr, "dgraph_comm is NOT of type MPI_DIST_GRAPH\n");
+ return 0;
}
- ierr = MPI_Dist_graph_neighbors_count(dgraph_comm,
- &src_sz, &dest_sz, &wgt_flag);
+ ierr = MPI_Dist_graph_neighbors_count(dgraph_comm, &src_sz, &dest_sz, &wgt_flag);
if (ierr != MPI_SUCCESS) {
fprintf(stderr, "MPI_Dist_graph_neighbors_count() fails!\n");
return 0;
@@ -55,22 +54,20 @@ static int validate_dgraph(MPI_Comm dgraph_comm)
*/
if (src_sz != RING_NUM_NEIGHBORS || dest_sz != RING_NUM_NEIGHBORS) {
fprintf(stderr, "source or destination edge array is not of size %d.\n",
- RING_NUM_NEIGHBORS);
+ RING_NUM_NEIGHBORS);
fprintf(stderr, "src_sz = %d, dest_sz = %d\n", src_sz, dest_sz);
return 0;
}
/*
- src_wgts and dest_wgts could be anything, e.g. NULL, since
- MPI_Dist_graph_neighbors_count() returns MPI_UNWEIGHTED.
- Since this program has a Fortran77 version, and standard Fortran77
- has no pointer and NULL, so use MPI_UNWEIGHTED for the weighted arrays.
- */
- src_wgts = MPI_UNWEIGHTED;
+ * src_wgts and dest_wgts could be anything, e.g. NULL, since
+ * MPI_Dist_graph_neighbors_count() returns MPI_UNWEIGHTED.
+ * Since this program has a Fortran77 version, and standard Fortran77
+ * has no pointer and NULL, so use MPI_UNWEIGHTED for the weighted arrays.
+ */
+ src_wgts = MPI_UNWEIGHTED;
dest_wgts = MPI_UNWEIGHTED;
- ierr = MPI_Dist_graph_neighbors(dgraph_comm,
- src_sz, srcs, src_wgts,
- dest_sz, dests, dest_wgts);
+ ierr = MPI_Dist_graph_neighbors(dgraph_comm, src_sz, srcs, src_wgts, dest_sz, dests, dest_wgts);
if (ierr != MPI_SUCCESS) {
fprintf(stderr, "MPI_Dist_graph_neighbors() fails!\n");
return 0;
@@ -81,92 +78,90 @@ static int validate_dgraph(MPI_Comm dgraph_comm)
*/
/*
- Check if the neighbors returned from MPI are really
- the nearest neighbors within a ring.
- */
+ * Check if the neighbors returned from MPI are really
+ * the nearest neighbors within a ring.
+ */
MPI_Comm_size(MPI_COMM_WORLD, &world_size);
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
-
- for (idx=0; idx < src_sz; idx++) {
+
+ for (idx = 0; idx < src_sz; idx++) {
nbr_sep = abs(srcs[idx] - world_rank);
- if ( nbr_sep != 1 && nbr_sep != (world_size-1) ) {
+ if (nbr_sep != 1 && nbr_sep != (world_size - 1)) {
fprintf(stderr, "srcs[%d]=%d is NOT a neighbor of my rank %d.\n",
- idx, srcs[idx], world_rank);
+ idx, srcs[idx], world_rank);
return 0;
- }
+ }
}
- for (idx=0; idx < dest_sz; idx++) {
+ for (idx = 0; idx < dest_sz; idx++) {
nbr_sep = abs(dests[idx] - world_rank);
- if ( nbr_sep != 1 && nbr_sep != (world_size-1) ) {
+ if (nbr_sep != 1 && nbr_sep != (world_size - 1)) {
fprintf(stderr, "dests[%d]=%d is NOT a neighbor of my rank %d.\n",
- idx, dests[idx], world_rank);
+ idx, dests[idx], world_rank);
return 0;
- }
+ }
}
/*
- fprintf(stderr, "dgraph_comm is of type MPI_DIST_GRAPH "
- "of a bidirectional ring.\n");
- */
+ * fprintf(stderr, "dgraph_comm is of type MPI_DIST_GRAPH "
+ * "of a bidirectional ring.\n");
+ */
return 1;
}
/*
Specify a distributed graph of a bidirectional ring of the MPI_COMM_WORLD,
- i.e. everyone only talks to left and right neighbors.
+ i.e. everyone only talks to left and right neighbors.
*/
int main(int argc, char *argv[])
{
- MPI_Comm dgraph_comm;
- int world_size, world_rank, ierr;
- int errs = 0;
-
- int src_sz, dest_sz;
- int degs[1];
- int srcs[RING_NUM_NEIGHBORS], dests[RING_NUM_NEIGHBORS];
-
+ MPI_Comm dgraph_comm;
+ int world_size, world_rank, ierr;
+ int errs = 0;
+
+ int src_sz, dest_sz;
+ int degs[1];
+ int srcs[RING_NUM_NEIGHBORS], dests[RING_NUM_NEIGHBORS];
+
MTest_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &world_size);
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
- degs[0] = 2;
- srcs[0] = world_rank;
- dests[0] = world_rank-1 < 0 ? world_size-1 : world_rank-1 ;
- dests[1] = world_rank+1 >= world_size ? 0 : world_rank+1 ;
+ degs[0] = 2;
+ srcs[0] = world_rank;
+ dests[0] = world_rank - 1 < 0 ? world_size - 1 : world_rank - 1;
+ dests[1] = world_rank + 1 >= world_size ? 0 : world_rank + 1;
ierr = MPI_Dist_graph_create(MPI_COMM_WORLD, 1, srcs, degs, dests,
- MPI_UNWEIGHTED, MPI_INFO_NULL, 1,
- &dgraph_comm);
- if ( ierr != MPI_SUCCESS ) {
+ MPI_UNWEIGHTED, MPI_INFO_NULL, 1, &dgraph_comm);
+ if (ierr != MPI_SUCCESS) {
fprintf(stderr, "MPI_Dist_graph_create() fails!\n");
MPI_Abort(MPI_COMM_WORLD, 1);
return 1;
}
if (!validate_dgraph(dgraph_comm)) {
- fprintf(stderr, "MPI_Dist_graph_create() does NOT create "
- "a bidirectional ring graph!\n");
+ fprintf(stderr, "MPI_Dist_graph_create() does NOT create " "a bidirectional ring graph!\n");
MPI_Abort(MPI_COMM_WORLD, 1);
return 1;
}
MPI_Comm_free(&dgraph_comm);
-
- src_sz = 2;
- srcs[0] = world_rank-1 < 0 ? world_size-1 : world_rank-1 ;
- srcs[1] = world_rank+1 >= world_size ? 0 : world_rank+1 ;
- dest_sz = 2;
- dests[0] = world_rank-1 < 0 ? world_size-1 : world_rank-1 ;
- dests[1] = world_rank+1 >= world_size ? 0 : world_rank+1 ;
+
+ src_sz = 2;
+ srcs[0] = world_rank - 1 < 0 ? world_size - 1 : world_rank - 1;
+ srcs[1] = world_rank + 1 >= world_size ? 0 : world_rank + 1;
+ dest_sz = 2;
+ dests[0] = world_rank - 1 < 0 ? world_size - 1 : world_rank - 1;
+ dests[1] = world_rank + 1 >= world_size ? 0 : world_rank + 1;
ierr = MPI_Dist_graph_create_adjacent(MPI_COMM_WORLD,
src_sz, srcs, MPI_UNWEIGHTED,
dest_sz, dests, MPI_UNWEIGHTED,
MPI_INFO_NULL, 1, &dgraph_comm);
- if ( ierr != MPI_SUCCESS ) {
+ if (ierr != MPI_SUCCESS) {
fprintf(stderr, "MPI_Dist_graph_create_adjacent() fails!\n");
MPI_Abort(MPI_COMM_WORLD, 1);
return 1;
}
if (!validate_dgraph(dgraph_comm)) {
fprintf(stderr, "MPI_Dist_graph_create_adjacent() does NOT create "
- "a bidirectional ring graph!\n");
+ "a bidirectional ring graph!\n");
MPI_Abort(MPI_COMM_WORLD, 1);
return 1;
}
diff --git a/test/mpi/topo/dims1.c b/test/mpi/topo/dims1.c
index b429776..329be95 100644
--- a/test/mpi/topo/dims1.c
+++ b/test/mpi/topo/dims1.c
@@ -7,138 +7,132 @@
#include <stdio.h>
#include "mpitest.h"
-int prodof( int ndims, const int dims[] );
-int increasing( int ndims, const int dims[] );
+int prodof(int ndims, const int dims[]);
+int increasing(int ndims, const int dims[]);
-int prodof( int ndims, const int dims[] )
+int prodof(int ndims, const int dims[])
{
- int i, prod=1;
- for (i=0; i<ndims; i++)
- prod *= dims[i];
+ int i, prod = 1;
+ for (i = 0; i < ndims; i++)
+ prod *= dims[i];
return prod;
}
-int increasing( int ndims, const int dims[] )
+int increasing(int ndims, const int dims[])
{
- int i, err=0;
- for (i=1; i<ndims; i++) {
- if (dims[i] > dims[i-1]) {
- printf ("%d = dims[%d] > dims[%d] = %d\n", dims[i], i,
- i-1, dims[i-1] );
- err = 1;
- }
+ int i, err = 0;
+ for (i = 1; i < ndims; i++) {
+ if (dims[i] > dims[i - 1]) {
+ printf("%d = dims[%d] > dims[%d] = %d\n", dims[i], i, i - 1, dims[i - 1]);
+ err = 1;
+ }
}
return err;
}
-int main( int argc, char *argv[] )
+
+int main(int argc, char *argv[])
{
int errs = 0;
int dims[4], nnodes, ndims;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- /* Test multiple dims create values. For each, make sure that the
- product of dims is the number of input nodes */
- nnodes = 2*3*5*7*11;
- ndims = 2;
+ /* Test multiple dims create values. For each, make sure that the
+ * product of dims is the number of input nodes */
+ nnodes = 2 * 3 * 5 * 7 * 11;
+ ndims = 2;
dims[0] = dims[1] = 0;
- MPI_Dims_create( nnodes, ndims, dims );
- if (prodof(ndims,dims) != nnodes) {
- errs++;
- printf( "dims create returned the wrong decomposition for %d in %d dims\n",
- nnodes, ndims );
+ MPI_Dims_create(nnodes, ndims, dims);
+ if (prodof(ndims, dims) != nnodes) {
+ errs++;
+ printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
}
- if (increasing( ndims, dims )) {
- errs++;
- printf( "dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n" );
- printf( "dims create returned the wrong decomposition for %d in %d dims\n",
- nnodes, ndims );
+ if (increasing(ndims, dims)) {
+ errs++;
+ printf
+ ("dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n");
+ printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
}
- /* Test multiple dims create values. For each, make sure that the
- product of dims is the number of input nodes */
- nnodes = 2*7;
- ndims = 2;
+ /* Test multiple dims create values. For each, make sure that the
+ * product of dims is the number of input nodes */
+ nnodes = 2 * 7;
+ ndims = 2;
dims[0] = dims[1] = 0;
- MPI_Dims_create( nnodes, ndims, dims );
- if (prodof(ndims,dims) != nnodes) {
- errs++;
- printf( "dims create returned the wrong decomposition for %d in %d dims\n",
- nnodes, ndims );
+ MPI_Dims_create(nnodes, ndims, dims);
+ if (prodof(ndims, dims) != nnodes) {
+ errs++;
+ printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
}
- if (increasing( ndims, dims )) {
- errs++;
- printf( "dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n" );
- printf( "dims create returned the wrong decomposition for %d in %d dims\n",
- nnodes, ndims );
+ if (increasing(ndims, dims)) {
+ errs++;
+ printf
+ ("dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n");
+ printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
}
- nnodes = 2*2*3*3*5*7*11;
- ndims = 2;
+ nnodes = 2 * 2 * 3 * 3 * 5 * 7 * 11;
+ ndims = 2;
dims[0] = dims[1] = 0;
- MPI_Dims_create( nnodes, ndims, dims );
- if (prodof(ndims,dims) != nnodes) {
- errs++;
- printf( "dims create returned the wrong decomposition for %d in %d dims\n",
- nnodes, ndims );
+ MPI_Dims_create(nnodes, ndims, dims);
+ if (prodof(ndims, dims) != nnodes) {
+ errs++;
+ printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
}
- if (increasing( ndims, dims )) {
- errs++;
- printf( "dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n" );
- printf( "dims create returned the wrong decomposition for %d in %d dims\n",
- nnodes, ndims );
+ if (increasing(ndims, dims)) {
+ errs++;
+ printf
+ ("dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n");
+ printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
}
nnodes = 11;
- ndims = 2;
+ ndims = 2;
dims[0] = dims[1] = 0;
- MPI_Dims_create( nnodes, ndims, dims );
- if (prodof(ndims,dims) != nnodes) {
- errs++;
- printf( "dims create returned the wrong decomposition for %d in %d dims\n",
- nnodes, ndims );
+ MPI_Dims_create(nnodes, ndims, dims);
+ if (prodof(ndims, dims) != nnodes) {
+ errs++;
+ printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
}
- if (increasing( ndims, dims )) {
- errs++;
- printf( "dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n" );
- printf( "dims create returned the wrong decomposition for %d in %d dims\n",
- nnodes, ndims );
+ if (increasing(ndims, dims)) {
+ errs++;
+ printf
+ ("dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n");
+ printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
}
- nnodes = 5*7*11;
- ndims = 4;
+ nnodes = 5 * 7 * 11;
+ ndims = 4;
dims[0] = dims[1] = dims[2] = dims[3] = 0;
- MPI_Dims_create( nnodes, ndims, dims );
- if (prodof(ndims,dims) != nnodes) {
- errs++;
- printf( "dims create returned the wrong decomposition for %d in %d dims\n",
- nnodes, ndims );
+ MPI_Dims_create(nnodes, ndims, dims);
+ if (prodof(ndims, dims) != nnodes) {
+ errs++;
+ printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
}
- if (increasing( ndims, dims )) {
- errs++;
- printf( "dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n" );
- printf( "dims create returned the wrong decomposition for %d in %d dims\n",
- nnodes, ndims );
+ if (increasing(ndims, dims)) {
+ errs++;
+ printf
+ ("dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n");
+ printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
}
nnodes = 64;
- ndims = 4;
+ ndims = 4;
dims[0] = dims[1] = dims[2] = dims[3] = 0;
- MPI_Dims_create( nnodes, ndims, dims );
- if (prodof(ndims,dims) != nnodes) {
- errs++;
- printf( "dims create returned the wrong decomposition for %d in %d dims\n",
- nnodes, ndims );
+ MPI_Dims_create(nnodes, ndims, dims);
+ if (prodof(ndims, dims) != nnodes) {
+ errs++;
+ printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
}
- if (increasing( ndims, dims )) {
- errs++;
- printf( "dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n" );
- printf( "dims create returned the wrong decomposition for %d in %d dims\n",
- nnodes, ndims );
+ if (increasing(ndims, dims)) {
+ errs++;
+ printf
+ ("dims create returned a decomposition with increasing dimensions (see MPI-1 standard section 6.5)\n");
+ printf("dims create returned the wrong decomposition for %d in %d dims\n", nnodes, ndims);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/topo/dims2.c b/test/mpi/topo/dims2.c
index aa453eb..b4cbecf 100644
--- a/test/mpi/topo/dims2.c
+++ b/test/mpi/topo/dims2.c
@@ -7,87 +7,83 @@
#include <stdio.h>
#include "mpitest.h"
-int prodof( int, const int[] );
+int prodof(int, const int[]);
/*
* Test edge cases of Dims_create
*/
-int prodof( int ndims, const int dims[] )
+int prodof(int ndims, const int dims[])
{
- int i, prod=1;
- for (i=0; i<ndims; i++)
- prod *= dims[i];
+ int i, prod = 1;
+ for (i = 0; i < ndims; i++)
+ prod *= dims[i];
return prod;
}
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int dims[4], nnodes;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
/* 2 dimensional tests */
- for (nnodes=1; nnodes <= 32; nnodes = nnodes * 2) {
- dims[0] = 0;
- dims[1] = nnodes;
-
- MPI_Dims_create( nnodes, 2, dims );
- if (prodof(2, dims) != nnodes) {
- errs++;
- printf( "Dims_create returned the wrong decomposition. " );
- printf( "Is [%d x %d], should be 1 x %d\n", dims[0], dims[1],
- nnodes );
- }
-
- /* Try calling Dims_create with nothing to do (all dimensions
- specified) */
- dims[0] = 1;
- dims[1] = nnodes;
- MPI_Dims_create( nnodes, 2, dims );
- if (prodof(2, dims) != nnodes) {
- errs++;
- printf( "Dims_create returned the wrong decomposition (all given). " );
- printf( "Is [%d x %d], should be 1 x %d\n", dims[0], dims[1],
- nnodes );
- }
+ for (nnodes = 1; nnodes <= 32; nnodes = nnodes * 2) {
+ dims[0] = 0;
+ dims[1] = nnodes;
+
+ MPI_Dims_create(nnodes, 2, dims);
+ if (prodof(2, dims) != nnodes) {
+ errs++;
+ printf("Dims_create returned the wrong decomposition. ");
+ printf("Is [%d x %d], should be 1 x %d\n", dims[0], dims[1], nnodes);
+ }
+
+ /* Try calling Dims_create with nothing to do (all dimensions
+ * specified) */
+ dims[0] = 1;
+ dims[1] = nnodes;
+ MPI_Dims_create(nnodes, 2, dims);
+ if (prodof(2, dims) != nnodes) {
+ errs++;
+ printf("Dims_create returned the wrong decomposition (all given). ");
+ printf("Is [%d x %d], should be 1 x %d\n", dims[0], dims[1], nnodes);
+ }
}
/* 4 dimensional tests */
- for (nnodes=4; nnodes <= 32; nnodes = nnodes * 2) {
- dims[0] = 0;
- dims[1] = nnodes/2;
- dims[2] = 0;
- dims[3] = 2;
-
- MPI_Dims_create( nnodes, 4, dims );
- if (prodof(4, dims) != nnodes) {
- errs++;
- printf( "Dims_create returned the wrong decomposition. " );
- printf( "Is [%d x %d x %d x %d], should be 1 x %d x 1 x 2\n",
- dims[0], dims[1], dims[2], dims[3],
- nnodes/2 );
- }
-
- /* Try calling Dims_create with nothing to do (all dimensions
- specified) */
- dims[0] = 1;
- dims[1] = nnodes/2;
- dims[2] = 1;
- dims[3] = 2;
- MPI_Dims_create( nnodes, 4, dims );
- if (prodof(4, dims) != nnodes) {
- errs++;
- printf( "Dims_create returned the wrong decomposition (all given). " );
- printf( "Is [%d x %d x %d x %d], should be 1 x %d x 1 x 2\n",
- dims[0], dims[1], dims[2], dims[3],
- nnodes/2 );
- }
+ for (nnodes = 4; nnodes <= 32; nnodes = nnodes * 2) {
+ dims[0] = 0;
+ dims[1] = nnodes / 2;
+ dims[2] = 0;
+ dims[3] = 2;
+
+ MPI_Dims_create(nnodes, 4, dims);
+ if (prodof(4, dims) != nnodes) {
+ errs++;
+ printf("Dims_create returned the wrong decomposition. ");
+ printf("Is [%d x %d x %d x %d], should be 1 x %d x 1 x 2\n",
+ dims[0], dims[1], dims[2], dims[3], nnodes / 2);
+ }
+
+ /* Try calling Dims_create with nothing to do (all dimensions
+ * specified) */
+ dims[0] = 1;
+ dims[1] = nnodes / 2;
+ dims[2] = 1;
+ dims[3] = 2;
+ MPI_Dims_create(nnodes, 4, dims);
+ if (prodof(4, dims) != nnodes) {
+ errs++;
+ printf("Dims_create returned the wrong decomposition (all given). ");
+ printf("Is [%d x %d x %d x %d], should be 1 x %d x 1 x 2\n",
+ dims[0], dims[1], dims[2], dims[3], nnodes / 2);
+ }
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/topo/dims4.c b/test/mpi/topo/dims4.c
index 8284bfa..e0ab8c4 100644
--- a/test/mpi/topo/dims4.c
+++ b/test/mpi/topo/dims4.c
@@ -9,7 +9,7 @@
int main(int argc, char **argv)
{
int nproc = (1000 * 1000 * 1000);
- int ret[3] = {0, 0, 0};
+ int ret[3] = { 0, 0, 0 };
int errs = 0, i, rank;
MPI_Init(&argc, &argv);
diff --git a/test/mpi/topo/distgraph1.c b/test/mpi/topo/distgraph1.c
index de42586..4c0fe49 100644
--- a/test/mpi/topo/distgraph1.c
+++ b/test/mpi/topo/distgraph1.c
@@ -25,7 +25,7 @@ int size, rank;
int **layout;
#define MAX_LAYOUT_NAME_LEN 256
-char graph_layout_name[MAX_LAYOUT_NAME_LEN] = {'\0'};
+char graph_layout_name[MAX_LAYOUT_NAME_LEN] = { '\0' };
static void create_graph_layout(int graph_num)
{
@@ -33,51 +33,51 @@ static void create_graph_layout(int graph_num)
if (rank == 0) {
switch (graph_num) {
- case 0:
- strncpy(graph_layout_name, "deterministic complete graph", MAX_LAYOUT_NAME_LEN);
- for (i = 0; i < size; i++)
- for (j = 0; j < size; j++)
- layout[i][j] = (i + 2) * (j + 1);
- break;
- case 1:
- strncpy(graph_layout_name, "every other edge deleted", MAX_LAYOUT_NAME_LEN);
- for (i = 0; i < size; i++)
- for (j = 0; j < size; j++)
- layout[i][j] = (j % 2 ? (i + 2) * (j + 1) : 0);
- break;
- case 2:
- strncpy(graph_layout_name, "only self-edges", MAX_LAYOUT_NAME_LEN);
- for (i = 0; i < size; i++) {
- for (j = 0; j < size; j++) {
- if (i == rank && j == rank)
- layout[i][j] = 10 * (i + 1);
- else
- layout[i][j] = 0;
- }
+ case 0:
+ strncpy(graph_layout_name, "deterministic complete graph", MAX_LAYOUT_NAME_LEN);
+ for (i = 0; i < size; i++)
+ for (j = 0; j < size; j++)
+ layout[i][j] = (i + 2) * (j + 1);
+ break;
+ case 1:
+ strncpy(graph_layout_name, "every other edge deleted", MAX_LAYOUT_NAME_LEN);
+ for (i = 0; i < size; i++)
+ for (j = 0; j < size; j++)
+ layout[i][j] = (j % 2 ? (i + 2) * (j + 1) : 0);
+ break;
+ case 2:
+ strncpy(graph_layout_name, "only self-edges", MAX_LAYOUT_NAME_LEN);
+ for (i = 0; i < size; i++) {
+ for (j = 0; j < size; j++) {
+ if (i == rank && j == rank)
+ layout[i][j] = 10 * (i + 1);
+ else
+ layout[i][j] = 0;
}
- break;
- case 3:
- strncpy(graph_layout_name, "no edges", MAX_LAYOUT_NAME_LEN);
- for (i = 0; i < size; i++)
- for (j = 0; j < size; j++)
+ }
+ break;
+ case 3:
+ strncpy(graph_layout_name, "no edges", MAX_LAYOUT_NAME_LEN);
+ for (i = 0; i < size; i++)
+ for (j = 0; j < size; j++)
+ layout[i][j] = 0;
+ break;
+ default:
+ strncpy(graph_layout_name, "a random incomplete graph", MAX_LAYOUT_NAME_LEN);
+ srand(graph_num);
+
+ /* Create a connectivity graph; layout[i,j]==w represents an outward
+ * connectivity from i to j with weight w, w==0 is no edge. */
+ for (i = 0; i < size; i++) {
+ for (j = 0; j < size; j++) {
+ /* disable about a third of the edges */
+ if (((rand() * 1.0) / RAND_MAX) < 0.33)
layout[i][j] = 0;
- break;
- default:
- strncpy(graph_layout_name, "a random incomplete graph", MAX_LAYOUT_NAME_LEN);
- srand(graph_num);
-
- /* Create a connectivity graph; layout[i,j]==w represents an outward
- * connectivity from i to j with weight w, w==0 is no edge. */
- for (i = 0; i < size; i++) {
- for (j = 0; j < size; j++) {
- /* disable about a third of the edges */
- if (((rand() * 1.0) / RAND_MAX) < 0.33)
- layout[i][j] = 0;
- else
- layout[i][j] = rand() % MAX_WEIGHT;
- }
+ else
+ layout[i][j] = rand() % MAX_WEIGHT;
}
- break;
+ }
+ break;
}
}
@@ -110,7 +110,7 @@ static int verify_comm(MPI_Comm comm)
}
else {
MPI_Comm_dup(comm, &dupcomm);
- comm = dupcomm; /* caller retains original comm value */
+ comm = dupcomm; /* caller retains original comm value */
}
MPI_Topo_test(comm, &topo_type);
@@ -124,7 +124,8 @@ static int verify_comm(MPI_Comm comm)
if (layout[i][rank])
j++;
if (j != indegree) {
- fprintf(stderr, "indegree does not match, expected=%d got=%d, layout='%s'\n", indegree, j, graph_layout_name);
+ fprintf(stderr, "indegree does not match, expected=%d got=%d, layout='%s'\n", indegree,
+ j, graph_layout_name);
++local_errs;
}
@@ -133,7 +134,8 @@ static int verify_comm(MPI_Comm comm)
if (layout[rank][i])
j++;
if (j != outdegree) {
- fprintf(stderr, "outdegree does not match, expected=%d got=%d, layout='%s'\n", outdegree, j, graph_layout_name);
+ fprintf(stderr, "outdegree does not match, expected=%d got=%d, layout='%s'\n",
+ outdegree, j, graph_layout_name);
++local_errs;
}
@@ -143,7 +145,8 @@ static int verify_comm(MPI_Comm comm)
}
- MPI_Dist_graph_neighbors(comm, indegree, sources, sweights, outdegree, destinations, dweights);
+ MPI_Dist_graph_neighbors(comm, indegree, sources, sweights, outdegree, destinations,
+ dweights);
/* For each incoming and outgoing edge in the matrix, search if
* the query function listed it in the sources. */
@@ -246,12 +249,12 @@ int main(int argc, char *argv[])
for (i = 0; i < NUM_GRAPHS; i++) {
create_graph_layout(i);
if (rank == 0) {
- MTestPrintfMsg( 1, "using graph layout '%s'\n", graph_layout_name );
+ MTestPrintfMsg(1, "using graph layout '%s'\n", graph_layout_name);
}
/* MPI_Dist_graph_create_adjacent */
if (rank == 0) {
- MTestPrintfMsg( 1, "testing MPI_Dist_graph_create_adjacent\n" );
+ MTestPrintfMsg(1, "testing MPI_Dist_graph_create_adjacent\n");
}
indegree = 0;
k = 0;
@@ -295,8 +298,7 @@ int main(int argc, char *argv[])
/* MPI_Dist_graph_create() where each process specifies its
* outgoing edges */
if (rank == 0) {
- MTestPrintfMsg( 1,
- "testing MPI_Dist_graph_create w/ outgoing only\n" );
+ MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ outgoing only\n");
}
sources[0] = rank;
k = 0;
@@ -319,8 +321,7 @@ int main(int argc, char *argv[])
/* MPI_Dist_graph_create() where each process specifies its
* incoming edges */
if (rank == 0) {
- MTestPrintfMsg( 1,
- "testing MPI_Dist_graph_create w/ incoming only\n" );
+ MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ incoming only\n");
}
k = 0;
for (j = 0; j < size; j++) {
@@ -343,8 +344,7 @@ int main(int argc, char *argv[])
/* MPI_Dist_graph_create() where rank 0 specifies the entire
* graph */
if (rank == 0) {
- MTestPrintfMsg( 1,
- "testing MPI_Dist_graph_create w/ rank 0 specifies only\n" );
+ MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ rank 0 specifies only\n");
}
p = 0;
for (j = 0; j < size; j++) {
@@ -369,8 +369,7 @@ int main(int argc, char *argv[])
* graph and all other ranks pass NULL. Can catch implementation
* problems when MPI_UNWEIGHTED==NULL. */
if (rank == 0) {
- MTestPrintfMsg( 1,
- "testing MPI_Dist_graph_create w/ rank 0 specifies only -- NULLs\n");
+ MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ rank 0 specifies only -- NULLs\n");
}
p = 0;
for (j = 0; j < size; j++) {
@@ -412,7 +411,7 @@ int main(int argc, char *argv[])
/* MPI_Dist_graph_create() with no graph */
if (rank == 0) {
- MTestPrintfMsg( 1, "testing MPI_Dist_graph_create w/ no graph\n" );
+ MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ no graph\n");
}
for (reorder = 0; reorder <= 1; reorder++) {
MPI_Dist_graph_create(MPI_COMM_WORLD, 0, sources, degrees,
@@ -425,21 +424,22 @@ int main(int argc, char *argv[])
MPI_Comm_free(&comm);
}
- /* MPI_Dist_graph_create() with no graph -- passing MPI_WEIGHTS_EMPTY
- instead */
- /* NOTE that MPI_WEIGHTS_EMPTY was added in MPI-3 and does not
- appear before then. This part of the test thus requires a check
- on the MPI major version */
+ /* MPI_Dist_graph_create() with no graph -- passing MPI_WEIGHTS_EMPTY
+ * instead */
+ /* NOTE that MPI_WEIGHTS_EMPTY was added in MPI-3 and does not
+ * appear before then. This part of the test thus requires a check
+ * on the MPI major version */
#if MPI_VERSION >= 3
if (rank == 0) {
- MTestPrintfMsg( 1, "testing MPI_Dist_graph_create w/ no graph\n" );
+ MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ no graph\n");
}
for (reorder = 0; reorder <= 1; reorder++) {
MPI_Dist_graph_create(MPI_COMM_WORLD, 0, sources, degrees,
destinations, MPI_WEIGHTS_EMPTY, MPI_INFO_NULL, reorder, &comm);
MPI_Dist_graph_neighbors_count(comm, &check_indegree, &check_outdegree, &check_weighted);
if (!check_weighted) {
- fprintf(stderr, "expected weighted == TRUE for the \"no graph -- MPI_WEIGHTS_EMPTY\" case\n");
+ fprintf(stderr,
+ "expected weighted == TRUE for the \"no graph -- MPI_WEIGHTS_EMPTY\" case\n");
++errs;
}
MPI_Comm_free(&comm);
@@ -448,8 +448,7 @@ int main(int argc, char *argv[])
/* MPI_Dist_graph_create() with no graph -- passing NULLs instead */
if (rank == 0) {
- MTestPrintfMsg( 1,
- "testing MPI_Dist_graph_create w/ no graph -- NULLs\n" );
+ MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ no graph -- NULLs\n");
}
for (reorder = 0; reorder <= 1; reorder++) {
MPI_Dist_graph_create(MPI_COMM_WORLD, 0, NULL, NULL,
@@ -467,8 +466,7 @@ int main(int argc, char *argv[])
/* MPI_Dist_graph_create() with no graph -- passing NULLs+MPI_UNWEIGHTED instead */
if (rank == 0) {
- MTestPrintfMsg( 1,
- "testing MPI_Dist_graph_create w/ no graph -- NULLs+MPI_UNWEIGHTED\n" );
+ MTestPrintfMsg(1, "testing MPI_Dist_graph_create w/ no graph -- NULLs+MPI_UNWEIGHTED\n");
}
for (reorder = 0; reorder <= 1; reorder++) {
MPI_Dist_graph_create(MPI_COMM_WORLD, 0, NULL, NULL,
@@ -477,7 +475,8 @@ int main(int argc, char *argv[])
/* ambiguous if they are equal, only check when they are distinct values. */
if (MPI_UNWEIGHTED != NULL) {
if (check_weighted) {
- fprintf(stderr, "expected weighted == FALSE for the \"no graph -- NULLs+MPI_UNWEIGHTED\" case\n");
+ fprintf(stderr,
+ "expected weighted == FALSE for the \"no graph -- NULLs+MPI_UNWEIGHTED\" case\n");
++errs;
}
}
@@ -486,12 +485,11 @@ int main(int argc, char *argv[])
/* MPI_Dist_graph_create_adjacent() with no graph */
if (rank == 0) {
- MTestPrintfMsg( 1,
- "testing MPI_Dist_graph_create_adjacent w/ no graph\n" );
+ MTestPrintfMsg(1, "testing MPI_Dist_graph_create_adjacent w/ no graph\n");
}
for (reorder = 0; reorder <= 1; reorder++) {
MPI_Dist_graph_create_adjacent(MPI_COMM_WORLD, 0, sources, sweights,
- 0, destinations, dweights, MPI_INFO_NULL, reorder, &comm);
+ 0, destinations, dweights, MPI_INFO_NULL, reorder, &comm);
MPI_Dist_graph_neighbors_count(comm, &check_indegree, &check_outdegree, &check_weighted);
if (!check_weighted) {
fprintf(stderr, "expected weighted == TRUE for the \"no graph\" case\n");
@@ -501,20 +499,22 @@ int main(int argc, char *argv[])
}
/* MPI_Dist_graph_create_adjacent() with no graph -- passing MPI_WEIGHTS_EMPTY instead */
- /* NOTE that MPI_WEIGHTS_EMPTY was added in MPI-3 and does not
- appear before then. This part of the test thus requires a check
- on the MPI major version */
+ /* NOTE that MPI_WEIGHTS_EMPTY was added in MPI-3 and does not
+ * appear before then. This part of the test thus requires a check
+ * on the MPI major version */
#if MPI_VERSION >= 3
if (rank == 0) {
- MTestPrintfMsg( 1,
- "testing MPI_Dist_graph_create_adjacent w/ no graph -- MPI_WEIGHTS_EMPTY\n" );
+ MTestPrintfMsg(1,
+ "testing MPI_Dist_graph_create_adjacent w/ no graph -- MPI_WEIGHTS_EMPTY\n");
}
for (reorder = 0; reorder <= 1; reorder++) {
MPI_Dist_graph_create_adjacent(MPI_COMM_WORLD, 0, sources, MPI_WEIGHTS_EMPTY,
- 0, destinations, MPI_WEIGHTS_EMPTY, MPI_INFO_NULL, reorder, &comm);
+ 0, destinations, MPI_WEIGHTS_EMPTY, MPI_INFO_NULL, reorder,
+ &comm);
MPI_Dist_graph_neighbors_count(comm, &check_indegree, &check_outdegree, &check_weighted);
if (!check_weighted) {
- fprintf(stderr, "expected weighted == TRUE for the \"no graph -- MPI_WEIGHTS_EMPTY\" case\n");
+ fprintf(stderr,
+ "expected weighted == TRUE for the \"no graph -- MPI_WEIGHTS_EMPTY\" case\n");
++errs;
}
MPI_Comm_free(&comm);
@@ -523,12 +523,11 @@ int main(int argc, char *argv[])
/* MPI_Dist_graph_create_adjacent() with no graph -- passing NULLs instead */
if (rank == 0) {
- MTestPrintfMsg( 1,
- "testing MPI_Dist_graph_create_adjacent w/ no graph -- NULLs\n" );
+ MTestPrintfMsg(1, "testing MPI_Dist_graph_create_adjacent w/ no graph -- NULLs\n");
}
for (reorder = 0; reorder <= 1; reorder++) {
MPI_Dist_graph_create_adjacent(MPI_COMM_WORLD, 0, NULL, NULL,
- 0, NULL, NULL, MPI_INFO_NULL, reorder, &comm);
+ 0, NULL, NULL, MPI_INFO_NULL, reorder, &comm);
MPI_Dist_graph_neighbors_count(comm, &check_indegree, &check_outdegree, &check_weighted);
/* ambiguous if they are equal, only check when they are distinct values. */
if (MPI_UNWEIGHTED != NULL) {
@@ -542,17 +541,18 @@ int main(int argc, char *argv[])
/* MPI_Dist_graph_create_adjacent() with no graph -- passing NULLs+MPI_UNWEIGHTED instead */
if (rank == 0) {
- MTestPrintfMsg( 1,
-"testing MPI_Dist_graph_create_adjacent w/ no graph -- NULLs+MPI_UNWEIGHTED\n");
+ MTestPrintfMsg(1,
+ "testing MPI_Dist_graph_create_adjacent w/ no graph -- NULLs+MPI_UNWEIGHTED\n");
}
for (reorder = 0; reorder <= 1; reorder++) {
MPI_Dist_graph_create_adjacent(MPI_COMM_WORLD, 0, NULL, MPI_UNWEIGHTED,
- 0, NULL, MPI_UNWEIGHTED, MPI_INFO_NULL, reorder, &comm);
+ 0, NULL, MPI_UNWEIGHTED, MPI_INFO_NULL, reorder, &comm);
MPI_Dist_graph_neighbors_count(comm, &check_indegree, &check_outdegree, &check_weighted);
/* ambiguous if they are equal, only check when they are distinct values. */
if (MPI_UNWEIGHTED != NULL) {
if (check_weighted) {
- fprintf(stderr, "expected weighted == FALSE for the \"no graph -- NULLs+MPI_UNWEIGHTED\" case\n");
+ fprintf(stderr,
+ "expected weighted == FALSE for the \"no graph -- NULLs+MPI_UNWEIGHTED\" case\n");
++errs;
}
}
diff --git a/test/mpi/topo/graphcr.c b/test/mpi/topo/graphcr.c
index 2bfac48..661e6fc 100644
--- a/test/mpi/topo/graphcr.c
+++ b/test/mpi/topo/graphcr.c
@@ -12,23 +12,23 @@
static char MTEST_Descrip[] = "Create a communicator with a graph that contains no processes";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int *index = 0, *edges = 0;
MPI_Comm comm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
/* MPI 2.1, page 246, lines 29-30 make it clear that this is a valid
- (not erroneous) call that must return MPI_COMM_NULL */
- MPI_Graph_create( MPI_COMM_WORLD, 0, index, edges, 0, &comm );
+ * (not erroneous) call that must return MPI_COMM_NULL */
+ MPI_Graph_create(MPI_COMM_WORLD, 0, index, edges, 0, &comm);
if (comm != MPI_COMM_NULL) {
- errs++;
- fprintf( stderr, "Expected MPI_COMM_NULL from empty graph create\n" );
+ errs++;
+ fprintf(stderr, "Expected MPI_COMM_NULL from empty graph create\n");
}
-
- MTest_Finalize( errs );
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/topo/graphcr2.c b/test/mpi/topo/graphcr2.c
index 6d5fd2a..f8e13b7 100644
--- a/test/mpi/topo/graphcr2.c
+++ b/test/mpi/topo/graphcr2.c
@@ -13,58 +13,58 @@
static char MTEST_Descrip[] = "Create a communicator with a graph that contains null edges and one that contains duplicate edges";
*/
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int *index = 0, *edges = 0;
int rank, size, i, j, crank, csize;
MPI_Comm comm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Comm_size( MPI_COMM_WORLD, &size );
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- index = (int *)malloc( size*sizeof(int) );
- edges = (int *)malloc( size*sizeof(int) );
- for (i=0; i<size; i++) {
- index[i] = 1;
- edges[i] = i;
+ index = (int *) malloc(size * sizeof(int));
+ edges = (int *) malloc(size * sizeof(int));
+ for (i = 0; i < size; i++) {
+ index[i] = 1;
+ edges[i] = i;
}
/* As of MPI 2.1, self edges are permitted */
- MPI_Graph_create( MPI_COMM_WORLD, size, index, edges, 0, &comm );
- MPI_Comm_rank( comm, &crank );
- MPI_Comm_size( comm, &csize );
+ MPI_Graph_create(MPI_COMM_WORLD, size, index, edges, 0, &comm);
+ MPI_Comm_rank(comm, &crank);
+ MPI_Comm_size(comm, &csize);
if (csize != size) {
- errs ++;
- fprintf( stderr, "Graph create with self links has size %d should be %d", csize, size );
+ errs++;
+ fprintf(stderr, "Graph create with self links has size %d should be %d", csize, size);
}
- free( index );
- free( edges );
- MPI_Comm_free( &comm );
+ free(index);
+ free(edges);
+ MPI_Comm_free(&comm);
/* Create a graph with duplicate links */
- index = (int *)malloc( size * sizeof(int) );
- edges = (int *)malloc( size * 2 * sizeof(int) );
+ index = (int *) malloc(size * sizeof(int));
+ edges = (int *) malloc(size * 2 * sizeof(int));
j = 0;
- for (i=0; i<size; i++) {
- index[i] = j + 2;
- edges[j++] = (i + 1) % size;
- edges[j++] = (i + 1) % size;
+ for (i = 0; i < size; i++) {
+ index[i] = j + 2;
+ edges[j++] = (i + 1) % size;
+ edges[j++] = (i + 1) % size;
}
/* As of MPI 2.1, duplicate edges are permitted */
- MPI_Graph_create( MPI_COMM_WORLD, size, index, edges, 0, &comm );
- MPI_Comm_rank( comm, &crank );
- MPI_Comm_size( comm, &csize );
+ MPI_Graph_create(MPI_COMM_WORLD, size, index, edges, 0, &comm);
+ MPI_Comm_rank(comm, &crank);
+ MPI_Comm_size(comm, &csize);
if (csize != size) {
- errs ++;
- fprintf( stderr, "Graph create with duplicate links has size %d should be %d", csize, size );
+ errs++;
+ fprintf(stderr, "Graph create with duplicate links has size %d should be %d", csize, size);
}
- free( index );
- free( edges );
- MPI_Comm_free( &comm );
+ free(index);
+ free(edges);
+ MPI_Comm_free(&comm);
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
diff --git a/test/mpi/topo/graphmap1.c b/test/mpi/topo/graphmap1.c
index 4102db3..a4dd489 100644
--- a/test/mpi/topo/graphmap1.c
+++ b/test/mpi/topo/graphmap1.c
@@ -8,33 +8,33 @@
#include <stdio.h>
#include "mpitest.h"
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int newrank, merr, rank;
int index[2], edges[2];
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
/* Graph map where there are no nodes for this process */
- MPI_Comm_set_errhandler( MPI_COMM_WORLD, MPI_ERRORS_RETURN );
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
/* Here is a singleton graph, containing only the root process */
index[0] = 0;
edges[0] = 0;
- merr = MPI_Graph_map( MPI_COMM_WORLD, 1, index, edges, &newrank );
+ merr = MPI_Graph_map(MPI_COMM_WORLD, 1, index, edges, &newrank);
if (merr) {
- errs++;
- printf( "Graph map returned an error\n" );
- MTestPrintError( merr );
+ errs++;
+ printf("Graph map returned an error\n");
+ MTestPrintError(merr);
}
if (rank != 0 && newrank != MPI_UNDEFINED) {
- errs++;
- printf( "Graph map with no local nodes did not return MPI_UNDEFINED\n" );
+ errs++;
+ printf("Graph map with no local nodes did not return MPI_UNDEFINED\n");
}
-
- MTest_Finalize( errs );
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/topo/neighb_coll.c b/test/mpi/topo/neighb_coll.c
index 0c4a7fd..7d91138 100644
--- a/test/mpi/topo/neighb_coll.c
+++ b/test/mpi/topo/neighb_coll.c
@@ -41,7 +41,7 @@ int main(int argc, char *argv[])
* neighborhood collective routines */
/* (wrap)--> 0 <--> 1 <--> ... <--> p-1 <--(wrap) */
- MPI_Cart_create(MPI_COMM_WORLD, 1, &wsize, periods, /*reorder=*/0, &cart);
+ MPI_Cart_create(MPI_COMM_WORLD, 1, &wsize, periods, /*reorder= */ 0, &cart);
/* allgather */
{
@@ -65,10 +65,10 @@ int main(int argc, char *argv[])
/* allgatherv */
{
- int sendbuf[1] = { wrank };
- int recvbuf[2] = { 0xdeadbeef, 0xdeadbeef };
+ int sendbuf[1] = { wrank };
+ int recvbuf[2] = { 0xdeadbeef, 0xdeadbeef };
int recvcounts[2] = { 1, 1 };
- int displs[2] = { 1, 0};
+ int displs[2] = { 1, 0 };
/* should see one send to each neighbor (rank-1 and rank+1) and one receive
* each from same, but put them in opposite slots in the buffer */
@@ -87,8 +87,8 @@ int main(int argc, char *argv[])
/* alltoall */
{
- int sendbuf[2] = { -(wrank+1), wrank+1 };
- int recvbuf[2] = { 0xdeadbeef, 0xdeadbeef };
+ int sendbuf[2] = { -(wrank + 1), wrank + 1 };
+ int recvbuf[2] = { 0xdeadbeef, 0xdeadbeef };
/* should see one send to each neighbor (rank-1 and rank+1) and one
* receive each from same */
@@ -107,18 +107,17 @@ int main(int argc, char *argv[])
/* alltoallv */
{
- int sendbuf[2] = { -(wrank+1), wrank+1 };
- int recvbuf[2] = { 0xdeadbeef, 0xdeadbeef };
+ int sendbuf[2] = { -(wrank + 1), wrank + 1 };
+ int recvbuf[2] = { 0xdeadbeef, 0xdeadbeef };
int sendcounts[2] = { 1, 1 };
int recvcounts[2] = { 1, 1 };
- int sdispls[2] = { 0, 1 };
- int rdispls[2] = { 1, 0 };
+ int sdispls[2] = { 0, 1 };
+ int rdispls[2] = { 1, 0 };
/* should see one send to each neighbor (rank-1 and rank+1) and one receive
* each from same, but put them in opposite slots in the buffer */
MPI_Neighbor_alltoallv(sendbuf, sendcounts, sdispls, MPI_INT,
- recvbuf, recvcounts, rdispls, MPI_INT,
- cart);
+ recvbuf, recvcounts, rdispls, MPI_INT, cart);
if (wrank == 0)
check(recvbuf[1] == 0xdeadbeef);
@@ -133,20 +132,19 @@ int main(int argc, char *argv[])
/* alltoallw */
{
- int sendbuf[2] = { -(wrank+1), wrank+1 };
- int recvbuf[2] = { 0xdeadbeef, 0xdeadbeef };
- int sendcounts[2] = { 1, 1 };
- int recvcounts[2] = { 1, 1 };
- MPI_Aint sdispls[2] = { 0, sizeof(int) };
- MPI_Aint rdispls[2] = { sizeof(int), 0 };
+ int sendbuf[2] = { -(wrank + 1), wrank + 1 };
+ int recvbuf[2] = { 0xdeadbeef, 0xdeadbeef };
+ int sendcounts[2] = { 1, 1 };
+ int recvcounts[2] = { 1, 1 };
+ MPI_Aint sdispls[2] = { 0, sizeof(int) };
+ MPI_Aint rdispls[2] = { sizeof(int), 0 };
MPI_Datatype sendtypes[2] = { MPI_INT, MPI_INT };
MPI_Datatype recvtypes[2] = { MPI_INT, MPI_INT };
/* should see one send to each neighbor (rank-1 and rank+1) and one receive
* each from same, but put them in opposite slots in the buffer */
MPI_Neighbor_alltoallw(sendbuf, sendcounts, sdispls, sendtypes,
- recvbuf, recvcounts, rdispls, recvtypes,
- cart);
+ recvbuf, recvcounts, rdispls, recvtypes, cart);
if (wrank == 0)
check(recvbuf[1] == 0xdeadbeef);
@@ -176,4 +174,3 @@ int main(int argc, char *argv[])
return 0;
}
-
diff --git a/test/mpi/topo/topodup.c b/test/mpi/topo/topodup.c
index f1c5515..c589edc 100644
--- a/test/mpi/topo/topodup.c
+++ b/test/mpi/topo/topodup.c
@@ -9,7 +9,7 @@
#include <stdlib.h>
#include "mpitest.h"
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0, i, k;
int dims[2], periods[2], wsize;
@@ -18,112 +18,107 @@ int main( int argc, char *argv[] )
int *index, *edges, *outindex, *outedges;
MPI_Comm comm1, comm2;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- MPI_Comm_size( MPI_COMM_WORLD, &wsize );
+ MPI_Comm_size(MPI_COMM_WORLD, &wsize);
- /* Create a cartesian topology, get its characteristics, then
- dup it and check that the new communicator has the same properties */
+ /* Create a cartesian topology, get its characteristics, then
+ * dup it and check that the new communicator has the same properties */
dims[0] = dims[1] = 0;
- MPI_Dims_create( wsize, 2, dims );
+ MPI_Dims_create(wsize, 2, dims);
periods[0] = periods[1] = 0;
- MPI_Cart_create( MPI_COMM_WORLD, 2, dims, periods, 0, &comm1 );
+ MPI_Cart_create(MPI_COMM_WORLD, 2, dims, periods, 0, &comm1);
- MPI_Comm_dup( comm1, &comm2 );
- MPI_Topo_test( comm2, &topo_type );
+ MPI_Comm_dup(comm1, &comm2);
+ MPI_Topo_test(comm2, &topo_type);
if (topo_type != MPI_CART) {
- errs++;
- printf( "Topo type of duped cart was not cart\n" );
+ errs++;
+ printf("Topo type of duped cart was not cart\n");
}
else {
- MPI_Cart_get( comm2, 2, outdims, outperiods, outcoords );
- for (i=0; i<2; i++) {
- if (outdims[i] != dims[i]) {
- errs++;
- printf( "%d = outdims[%d] != dims[%d] = %d\n", outdims[i],
- i, i, dims[i] );
- }
- if (outperiods[i] != periods[i]) {
- errs++;
- printf( "%d = outperiods[%d] != periods[%d] = %d\n",
- outperiods[i], i, i, periods[i] );
- }
- }
+ MPI_Cart_get(comm2, 2, outdims, outperiods, outcoords);
+ for (i = 0; i < 2; i++) {
+ if (outdims[i] != dims[i]) {
+ errs++;
+ printf("%d = outdims[%d] != dims[%d] = %d\n", outdims[i], i, i, dims[i]);
+ }
+ if (outperiods[i] != periods[i]) {
+ errs++;
+ printf("%d = outperiods[%d] != periods[%d] = %d\n",
+ outperiods[i], i, i, periods[i]);
+ }
+ }
}
- MPI_Comm_free( &comm2 );
- MPI_Comm_free( &comm1 );
+ MPI_Comm_free(&comm2);
+ MPI_Comm_free(&comm1);
/* Now do the same with a graph topology */
if (wsize >= 3) {
- index = (int*)malloc(wsize * sizeof(int) );
- edges = (int*)malloc(wsize * 2 * sizeof(int) );
- if (!index || !edges) {
- printf( "Unable to allocate %d words for index or edges\n",
- 3 * wsize );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
- index[0] = 2;
- for (i=1; i<wsize; i++) {
- index[i] = 2 + index[i-1];
- }
- k=0;
- for (i=0; i<wsize; i++) {
- edges[k++] = (i-1+wsize) % wsize;
- edges[k++] = (i+1) % wsize;
- }
- MPI_Graph_create( MPI_COMM_WORLD, wsize, index, edges, 0, &comm1 );
- MPI_Comm_dup( comm1, &comm2 );
- MPI_Topo_test( comm2, &topo_type );
- if (topo_type != MPI_GRAPH) {
- errs++;
- printf( "Topo type of duped graph was not graph\n" );
- }
- else {
- int nnodes, nedges;
- MPI_Graphdims_get( comm2, &nnodes, &nedges );
- if (nnodes != wsize) {
- errs++;
- printf( "Nnodes = %d, should be %d\n", nnodes, wsize );
- }
- if (nedges != 2*wsize) {
- errs++;
- printf( "Nedges = %d, should be %d\n", nedges, 2*wsize );
- }
- outindex = (int*)malloc(wsize * sizeof(int) );
- outedges = (int*)malloc(wsize * 2 * sizeof(int) );
- if (!outindex || !outedges) {
- printf( "Unable to allocate %d words for outindex or outedges\n",
- 3 * wsize );
- MPI_Abort( MPI_COMM_WORLD, 1 );
- }
-
- MPI_Graph_get( comm2, wsize, 2*wsize, outindex, outedges );
- for (i=0; i<wsize; i++) {
- if (index[i] != outindex[i]) {
- printf( "%d = index[%d] != outindex[%d] = %d\n",
- index[i], i, i, outindex[i] );
- errs++;
- }
- }
- for (i=0; i<2*wsize; i++) {
- if (edges[i] != outedges[i]) {
- printf( "%d = edges[%d] != outedges[%d] = %d\n",
- edges[i], i, i, outedges[i] );
- errs++;
- }
- }
- free( outindex );
- free( outedges );
- }
- free( index );
- free( edges );
+ index = (int *) malloc(wsize * sizeof(int));
+ edges = (int *) malloc(wsize * 2 * sizeof(int));
+ if (!index || !edges) {
+ printf("Unable to allocate %d words for index or edges\n", 3 * wsize);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
+ index[0] = 2;
+ for (i = 1; i < wsize; i++) {
+ index[i] = 2 + index[i - 1];
+ }
+ k = 0;
+ for (i = 0; i < wsize; i++) {
+ edges[k++] = (i - 1 + wsize) % wsize;
+ edges[k++] = (i + 1) % wsize;
+ }
+ MPI_Graph_create(MPI_COMM_WORLD, wsize, index, edges, 0, &comm1);
+ MPI_Comm_dup(comm1, &comm2);
+ MPI_Topo_test(comm2, &topo_type);
+ if (topo_type != MPI_GRAPH) {
+ errs++;
+ printf("Topo type of duped graph was not graph\n");
+ }
+ else {
+ int nnodes, nedges;
+ MPI_Graphdims_get(comm2, &nnodes, &nedges);
+ if (nnodes != wsize) {
+ errs++;
+ printf("Nnodes = %d, should be %d\n", nnodes, wsize);
+ }
+ if (nedges != 2 * wsize) {
+ errs++;
+ printf("Nedges = %d, should be %d\n", nedges, 2 * wsize);
+ }
+ outindex = (int *) malloc(wsize * sizeof(int));
+ outedges = (int *) malloc(wsize * 2 * sizeof(int));
+ if (!outindex || !outedges) {
+ printf("Unable to allocate %d words for outindex or outedges\n", 3 * wsize);
+ MPI_Abort(MPI_COMM_WORLD, 1);
+ }
- MPI_Comm_free( &comm2 );
- MPI_Comm_free( &comm1 );
+ MPI_Graph_get(comm2, wsize, 2 * wsize, outindex, outedges);
+ for (i = 0; i < wsize; i++) {
+ if (index[i] != outindex[i]) {
+ printf("%d = index[%d] != outindex[%d] = %d\n", index[i], i, i, outindex[i]);
+ errs++;
+ }
+ }
+ for (i = 0; i < 2 * wsize; i++) {
+ if (edges[i] != outedges[i]) {
+ printf("%d = edges[%d] != outedges[%d] = %d\n", edges[i], i, i, outedges[i]);
+ errs++;
+ }
+ }
+ free(outindex);
+ free(outedges);
+ }
+ free(index);
+ free(edges);
+
+ MPI_Comm_free(&comm2);
+ MPI_Comm_free(&comm1);
}
-
- MTest_Finalize( errs );
+
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/topo/topotest.c b/test/mpi/topo/topotest.c
index 64d8e08..0a42a9a 100644
--- a/test/mpi/topo/topotest.c
+++ b/test/mpi/topo/topotest.c
@@ -8,38 +8,38 @@
#include <stdio.h>
#include "mpitest.h"
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
int topo_type, size, dims[1], periods[1];
MPI_Comm comm;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- /* Check that topo test returns the correct type, including
- MPI_UNDEFINED */
+ /* Check that topo test returns the correct type, including
+ * MPI_UNDEFINED */
- MPI_Topo_test( MPI_COMM_WORLD, &topo_type );
+ MPI_Topo_test(MPI_COMM_WORLD, &topo_type);
if (topo_type != MPI_UNDEFINED) {
- errs++;
- printf( "Topo type of comm world is not UNDEFINED\n" );
+ errs++;
+ printf("Topo type of comm world is not UNDEFINED\n");
}
- MPI_Comm_size( MPI_COMM_WORLD, &size );
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
dims[0] = size;
periods[0] = 0;
- MPI_Cart_create( MPI_COMM_WORLD, 1, dims, periods, 0, &comm );
- MPI_Topo_test( comm, &topo_type );
+ MPI_Cart_create(MPI_COMM_WORLD, 1, dims, periods, 0, &comm);
+ MPI_Topo_test(comm, &topo_type);
if (topo_type != MPI_CART) {
- errs++;
- printf( "Topo type of cart comm is not CART\n" );
+ errs++;
+ printf("Topo type of cart comm is not CART\n");
}
- MPI_Comm_free( &comm );
+ MPI_Comm_free(&comm);
/* FIXME: still need graph example */
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
MPI_Finalize();
return 0;
-
+
}
diff --git a/test/mpi/util/dtypes.c b/test/mpi/util/dtypes.c
index 616088c..7c7082a 100644
--- a/test/mpi/util/dtypes.c
+++ b/test/mpi/util/dtypes.c
@@ -64,8 +64,8 @@ static int basic_only = 0;
int i; _ctype *a; \
if (cnt > *n) {*n = cnt; return; } \
types[cnt] = _mpitype; \
- inbufs[cnt] = (void *)calloc( _count,sizeof(_ctype) ); \
- outbufs[cnt] = (void *)malloc( sizeof(_ctype) * (_count) ); \
+ inbufs[cnt] = (void *)calloc(_count,sizeof(_ctype)); \
+ outbufs[cnt] = (void *)malloc(sizeof(_ctype) * (_count)); \
a = (_ctype *)inbufs[cnt]; for (i=0; i<(_count); i++) a[i] = i; \
a = (_ctype *)outbufs[cnt]; for (i=0; i<(_count); i++) a[i] = 0; \
counts[cnt] = _count; bytesize[cnt] = sizeof(_ctype) * (_count); cnt++; }
@@ -78,17 +78,17 @@ static int basic_only = 0;
int i; _ctype *a; char*myname; \
char _basename[MPI_MAX_OBJECT_NAME]; int _basenamelen;\
if (cnt > *n) {*n = cnt; return; }\
- MPI_Type_contiguous( _count, _mpitype, types + cnt );\
- MPI_Type_commit( types + cnt );\
- inbufs[cnt] = (void *)calloc( _count, sizeof(_ctype) ); \
- outbufs[cnt] = (void *)malloc( sizeof(_ctype) * (_count) ); \
+ MPI_Type_contiguous(_count, _mpitype, types + cnt);\
+ MPI_Type_commit(types + cnt);\
+ inbufs[cnt] = (void *)calloc(_count, sizeof(_ctype)); \
+ outbufs[cnt] = (void *)malloc(sizeof(_ctype) * (_count)); \
a = (_ctype *)inbufs[cnt]; for (i=0; i<(_count); i++) a[i] = i; \
a = (_ctype *)outbufs[cnt]; for (i=0; i<(_count); i++) a[i] = 0; \
myname = (char *)malloc(100);\
- MPI_Type_get_name( _mpitype, _basename, &_basenamelen ); \
- snprintf( myname, 100, "Contig type %s", _basename ); \
- MPI_Type_set_name( types[cnt], myname ); \
- free( myname ); \
+ MPI_Type_get_name(_mpitype, _basename, &_basenamelen); \
+ snprintf(myname, 100, "Contig type %s", _basename); \
+ MPI_Type_set_name(types[cnt], myname); \
+ free(myname); \
counts[cnt] = 1; bytesize[cnt] = sizeof(_ctype) * (_count); cnt++; }
/*
@@ -99,17 +99,17 @@ static int basic_only = 0;
int i; _ctype *a; char *myname; \
char _basename[MPI_MAX_OBJECT_NAME]; int _basenamelen;\
if (cnt > *n) {*n = cnt; return; }\
- MPI_Type_vector( _count, 1, _stride, _mpitype, types + cnt ); \
- MPI_Type_commit( types + cnt );\
- inbufs[cnt] = (void *)calloc( sizeof(_ctype) * (_count) * (_stride),1); \
- outbufs[cnt] = (void *)calloc( sizeof(_ctype) * (_count) * (_stride),1); \
+ MPI_Type_vector(_count, 1, _stride, _mpitype, types + cnt); \
+ MPI_Type_commit(types + cnt);\
+ inbufs[cnt] = (void *)calloc(sizeof(_ctype) * (_count) * (_stride),1); \
+ outbufs[cnt] = (void *)calloc(sizeof(_ctype) * (_count) * (_stride),1); \
a = (_ctype *)inbufs[cnt]; for (i=0; i<(_count); i++) a[i*(_stride)] = i; \
a = (_ctype *)outbufs[cnt]; for (i=0; i<(_count); i++) a[i*(_stride)] = 0; \
myname = (char *)malloc(100);\
- MPI_Type_get_name( _mpitype, _basename, &_basenamelen ); \
- snprintf( myname, 100, "Vector type %s", _basename ); \
- MPI_Type_set_name( types[cnt], myname ); \
- free( myname ); \
+ MPI_Type_get_name(_mpitype, _basename, &_basenamelen); \
+ snprintf(myname, 100, "Vector type %s", _basename); \
+ MPI_Type_set_name(types[cnt], myname); \
+ free(myname); \
counts[cnt] = 1; bytesize[cnt] = sizeof(_ctype) * (_count) * (_stride) ;\
cnt++; }
@@ -120,21 +120,21 @@ static int basic_only = 0;
int i; int *lens, *disp; _ctype *a; char *myname; \
char _basename[MPI_MAX_OBJECT_NAME]; int _basenamelen;\
if (cnt > *n) {*n = cnt; return; }\
- lens = (int *)malloc( (_count) * sizeof(int) ); \
- disp = (int *)malloc( (_count) * sizeof(int) ); \
+ lens = (int *)malloc((_count) * sizeof(int)); \
+ disp = (int *)malloc((_count) * sizeof(int)); \
for (i=0; i<(_count); i++) { lens[i] = 1; disp[i] = i; } \
- MPI_Type_indexed( (_count), lens, disp, _mpitype, types + cnt );\
- free( lens ); free( disp ); \
- MPI_Type_commit( types + cnt );\
- inbufs[cnt] = (void *)calloc( (_count), sizeof(_ctype) ); \
- outbufs[cnt] = (void *)malloc( sizeof(_ctype) * (_count) ); \
+ MPI_Type_indexed((_count), lens, disp, _mpitype, types + cnt);\
+ free(lens); free(disp); \
+ MPI_Type_commit(types + cnt);\
+ inbufs[cnt] = (void *)calloc((_count), sizeof(_ctype)); \
+ outbufs[cnt] = (void *)malloc(sizeof(_ctype) * (_count)); \
a = (_ctype *)inbufs[cnt]; for (i=0; i<(_count); i++) a[i] = i; \
a = (_ctype *)outbufs[cnt]; for (i=0; i<(_count); i++) a[i] = 0; \
myname = (char *)malloc(100);\
- MPI_Type_get_name( _mpitype, _basename, &_basenamelen ); \
- snprintf( myname, 100, "Index type %s", _basename ); \
- MPI_Type_set_name( types[cnt], myname ); \
- free( myname ); \
+ MPI_Type_get_name(_mpitype, _basename, &_basenamelen); \
+ snprintf(myname, 100, "Index type %s", _basename); \
+ MPI_Type_set_name(types[cnt], myname); \
+ free(myname); \
counts[cnt] = 1; bytesize[cnt] = sizeof(_ctype) * (_count); cnt++; }
/* This defines a structure of two basic members; by chosing things like
@@ -147,22 +147,22 @@ static int basic_only = 0;
if (cnt > *n) {*n = cnt; return; } \
b[0] = _mpitype1; b[1] = _mpitype2; b[2] = MPI_UB; \
cnts[0] = 1; cnts[1] = 1; cnts[2] = 1; \
- MPI_Get_address( &(samp.a2), &disp[1] ); \
- MPI_Get_address( &(samp.a1), &disp[0] ); \
- MPI_Get_address( &(samp) + 1, &disp[2] ); \
+ MPI_Get_address(&(samp.a2), &disp[1]); \
+ MPI_Get_address(&(samp.a1), &disp[0]); \
+ MPI_Get_address(&(samp) + 1, &disp[2]); \
disp[1] = disp[1] - disp[0]; disp[2] = disp[2] - disp[0]; disp[0] = 0; \
- MPI_Type_create_struct( 3, cnts, disp, b, types + cnt ); \
- MPI_Type_commit( types + cnt ); \
- inbufs[cnt] = (void *)calloc( sizeof(struct name) * (_count),1); \
- outbufs[cnt] = (void *)calloc( sizeof(struct name) * (_count),1); \
+ MPI_Type_create_struct(3, cnts, disp, b, types + cnt); \
+ MPI_Type_commit(types + cnt); \
+ inbufs[cnt] = (void *)calloc(sizeof(struct name) * (_count),1); \
+ outbufs[cnt] = (void *)calloc(sizeof(struct name) * (_count),1); \
a = (struct name *)inbufs[cnt]; for (i=0; i<(_count); i++) { a[i].a1 = i; \
a[i].a2 = i; } \
a = (struct name *)outbufs[cnt]; for (i=0; i<(_count); i++) { a[i].a1 = 0; \
a[i].a2 = 0; } \
myname = (char *)malloc(100); \
- snprintf( myname, 100, "Struct type %s", _tname ); \
- MPI_Type_set_name( types[cnt], myname ); \
- free( myname ); \
+ snprintf(myname, 100, "Struct type %s", _tname); \
+ MPI_Type_set_name(types[cnt], myname); \
+ free(myname); \
counts[cnt] = (_count); bytesize[cnt] = sizeof(struct name) * (_count);cnt++; }
/* This accomplished the same effect as VECTOR, but allow a count of > 1 */
@@ -174,17 +174,17 @@ static int basic_only = 0;
blens[0] = 1; blens[1] = 1; disps[0] = 0; \
disps[1] = (_stride) * sizeof(_ctype); \
mtypes[0] = _mpitype; mtypes[1] = MPI_UB; \
- MPI_Type_create_struct( 2, blens, disps, mtypes, types + cnt ); \
- MPI_Type_commit( types + cnt ); \
- inbufs[cnt] = (void *)calloc( sizeof(_ctype) * (_count) * (_stride),1);\
- outbufs[cnt] = (void *)calloc( sizeof(_ctype) * (_count) * (_stride),1);\
+ MPI_Type_create_struct(2, blens, disps, mtypes, types + cnt); \
+ MPI_Type_commit(types + cnt); \
+ inbufs[cnt] = (void *)calloc(sizeof(_ctype) * (_count) * (_stride),1);\
+ outbufs[cnt] = (void *)calloc(sizeof(_ctype) * (_count) * (_stride),1);\
a = (_ctype *)inbufs[cnt]; for (i=0; i<(_count); i++) a[i*(_stride)] = i; \
a = (_ctype *)outbufs[cnt]; for (i=0; i<(_count); i++) a[i*(_stride)] = 0; \
myname = (char *)malloc(100); \
- MPI_Type_get_name( _mpitype, _basename, &_basenamelen ); \
- snprintf( myname, 100, "Struct (MPI_UB) type %s", _basename ); \
- MPI_Type_set_name( types[cnt], myname ); \
- free( myname ); \
+ MPI_Type_get_name(_mpitype, _basename, &_basenamelen); \
+ snprintf(myname, 100, "Struct (MPI_UB) type %s", _basename); \
+ MPI_Type_set_name(types[cnt], myname); \
+ free(myname); \
counts[cnt] = (_count); \
bytesize[cnt] = sizeof(_ctype) * (_count) * (_stride);\
cnt++; }
@@ -192,7 +192,7 @@ static int basic_only = 0;
/*
* Set whether only the basic types should be generated
*/
-void MTestDatatype2BasicOnly( void )
+void MTestDatatype2BasicOnly(void)
{
basic_only = 1;
}
@@ -201,119 +201,119 @@ static int nbasic_types = 0;
/* On input, n is the size of the various buffers. On output,
it is the number available types
*/
-void MTestDatatype2Generate( MPI_Datatype *types, void **inbufs, void **outbufs,
- int *counts, int *bytesize, int *n )
+void MTestDatatype2Generate(MPI_Datatype * types, void **inbufs, void **outbufs,
+ int *counts, int *bytesize, int *n)
{
- int cnt = 0; /* Number of defined types */
- int typecnt = 10; /* Number of instances to send in most cases */
- int stride = 9; /* Number of elements in vector to stride */
+ int cnt = 0; /* Number of defined types */
+ int typecnt = 10; /* Number of instances to send in most cases */
+ int stride = 9; /* Number of elements in vector to stride */
/* First, generate an element of each basic type */
- SETUPBASICTYPE(MPI_CHAR,char,typecnt);
- SETUPBASICTYPE(MPI_SHORT,short,typecnt);
- SETUPBASICTYPE(MPI_INT,int,typecnt);
- SETUPBASICTYPE(MPI_LONG,long,typecnt);
- SETUPBASICTYPE(MPI_UNSIGNED_CHAR,unsigned char,typecnt);
- SETUPBASICTYPE(MPI_UNSIGNED_SHORT,unsigned short,typecnt);
- SETUPBASICTYPE(MPI_UNSIGNED,unsigned,typecnt);
- SETUPBASICTYPE(MPI_UNSIGNED_LONG,unsigned long,typecnt);
- SETUPBASICTYPE(MPI_FLOAT,float,typecnt);
- SETUPBASICTYPE(MPI_DOUBLE,double,typecnt);
- SETUPBASICTYPE(MPI_BYTE,char,typecnt);
+ SETUPBASICTYPE(MPI_CHAR, char, typecnt);
+ SETUPBASICTYPE(MPI_SHORT, short, typecnt);
+ SETUPBASICTYPE(MPI_INT, int, typecnt);
+ SETUPBASICTYPE(MPI_LONG, long, typecnt);
+ SETUPBASICTYPE(MPI_UNSIGNED_CHAR, unsigned char, typecnt);
+ SETUPBASICTYPE(MPI_UNSIGNED_SHORT, unsigned short, typecnt);
+ SETUPBASICTYPE(MPI_UNSIGNED, unsigned, typecnt);
+ SETUPBASICTYPE(MPI_UNSIGNED_LONG, unsigned long, typecnt);
+ SETUPBASICTYPE(MPI_FLOAT, float, typecnt);
+ SETUPBASICTYPE(MPI_DOUBLE, double, typecnt);
+ SETUPBASICTYPE(MPI_BYTE, char, typecnt);
#ifdef HAVE_LONG_LONG_INT
- SETUPBASICTYPE(MPI_LONG_LONG_INT,long long,typecnt);
+ SETUPBASICTYPE(MPI_LONG_LONG_INT, long long, typecnt);
#endif
#ifdef HAVE_LONG_DOUBLE
- SETUPBASICTYPE(MPI_LONG_DOUBLE,long double,typecnt);
+ SETUPBASICTYPE(MPI_LONG_DOUBLE, long double, typecnt);
#endif
nbasic_types = cnt;
if (basic_only) {
- *n = cnt;
- return;
+ *n = cnt;
+ return;
}
/* Generate contiguous data items */
- SETUPCONTIGTYPE(MPI_CHAR,char,typecnt);
- SETUPCONTIGTYPE(MPI_SHORT,short,typecnt);
- SETUPCONTIGTYPE(MPI_INT,int,typecnt);
- SETUPCONTIGTYPE(MPI_LONG,long,typecnt);
- SETUPCONTIGTYPE(MPI_UNSIGNED_CHAR,unsigned char,typecnt);
- SETUPCONTIGTYPE(MPI_UNSIGNED_SHORT,unsigned short,typecnt);
- SETUPCONTIGTYPE(MPI_UNSIGNED,unsigned,typecnt);
- SETUPCONTIGTYPE(MPI_UNSIGNED_LONG,unsigned long,typecnt);
- SETUPCONTIGTYPE(MPI_FLOAT,float,typecnt);
- SETUPCONTIGTYPE(MPI_DOUBLE,double,typecnt);
- SETUPCONTIGTYPE(MPI_BYTE,char,typecnt);
+ SETUPCONTIGTYPE(MPI_CHAR, char, typecnt);
+ SETUPCONTIGTYPE(MPI_SHORT, short, typecnt);
+ SETUPCONTIGTYPE(MPI_INT, int, typecnt);
+ SETUPCONTIGTYPE(MPI_LONG, long, typecnt);
+ SETUPCONTIGTYPE(MPI_UNSIGNED_CHAR, unsigned char, typecnt);
+ SETUPCONTIGTYPE(MPI_UNSIGNED_SHORT, unsigned short, typecnt);
+ SETUPCONTIGTYPE(MPI_UNSIGNED, unsigned, typecnt);
+ SETUPCONTIGTYPE(MPI_UNSIGNED_LONG, unsigned long, typecnt);
+ SETUPCONTIGTYPE(MPI_FLOAT, float, typecnt);
+ SETUPCONTIGTYPE(MPI_DOUBLE, double, typecnt);
+ SETUPCONTIGTYPE(MPI_BYTE, char, typecnt);
#ifdef HAVE_LONG_LONG_INT
- SETUPCONTIGTYPE(MPI_LONG_LONG_INT,long long,typecnt);
+ SETUPCONTIGTYPE(MPI_LONG_LONG_INT, long long, typecnt);
#endif
#ifdef HAVE_LONG_DOUBLE
- SETUPCONTIGTYPE(MPI_LONG_DOUBLE,long double,typecnt);
+ SETUPCONTIGTYPE(MPI_LONG_DOUBLE, long double, typecnt);
#endif
/* Generate vector items */
- SETUPVECTORTYPE(MPI_CHAR,char,typecnt,stride,"MPI_CHAR");
- SETUPVECTORTYPE(MPI_SHORT,short,typecnt,stride,"MPI_SHORT");
- SETUPVECTORTYPE(MPI_INT,int,typecnt,stride,"MPI_INT");
- SETUPVECTORTYPE(MPI_LONG,long,typecnt,stride,"MPI_LONG");
- SETUPVECTORTYPE(MPI_UNSIGNED_CHAR,unsigned char,typecnt,stride,"MPI_UNSIGNED_CHAR");
- SETUPVECTORTYPE(MPI_UNSIGNED_SHORT,unsigned short,typecnt,stride,"MPI_UNSIGNED_SHORT");
- SETUPVECTORTYPE(MPI_UNSIGNED,unsigned,typecnt,stride,"MPI_UNSIGNED");
- SETUPVECTORTYPE(MPI_UNSIGNED_LONG,unsigned long,typecnt,stride,"MPI_UNSIGNED_LONG");
- SETUPVECTORTYPE(MPI_FLOAT,float,typecnt,stride,"MPI_FLOAT");
- SETUPVECTORTYPE(MPI_DOUBLE,double,typecnt,stride,"MPI_DOUBLE");
- SETUPVECTORTYPE(MPI_BYTE,char,typecnt,stride,"MPI_BYTE");
+ SETUPVECTORTYPE(MPI_CHAR, char, typecnt, stride, "MPI_CHAR");
+ SETUPVECTORTYPE(MPI_SHORT, short, typecnt, stride, "MPI_SHORT");
+ SETUPVECTORTYPE(MPI_INT, int, typecnt, stride, "MPI_INT");
+ SETUPVECTORTYPE(MPI_LONG, long, typecnt, stride, "MPI_LONG");
+ SETUPVECTORTYPE(MPI_UNSIGNED_CHAR, unsigned char, typecnt, stride, "MPI_UNSIGNED_CHAR");
+ SETUPVECTORTYPE(MPI_UNSIGNED_SHORT, unsigned short, typecnt, stride, "MPI_UNSIGNED_SHORT");
+ SETUPVECTORTYPE(MPI_UNSIGNED, unsigned, typecnt, stride, "MPI_UNSIGNED");
+ SETUPVECTORTYPE(MPI_UNSIGNED_LONG, unsigned long, typecnt, stride, "MPI_UNSIGNED_LONG");
+ SETUPVECTORTYPE(MPI_FLOAT, float, typecnt, stride, "MPI_FLOAT");
+ SETUPVECTORTYPE(MPI_DOUBLE, double, typecnt, stride, "MPI_DOUBLE");
+ SETUPVECTORTYPE(MPI_BYTE, char, typecnt, stride, "MPI_BYTE");
#ifdef HAVE_LONG_LONG_INT
- SETUPVECTORTYPE(MPI_LONG_LONG_INT,long long,typecnt,stride,"MPI_LONG_LONG_INT");
+ SETUPVECTORTYPE(MPI_LONG_LONG_INT, long long, typecnt, stride, "MPI_LONG_LONG_INT");
#endif
#ifdef HAVE_LONG_DOUBLE
- SETUPVECTORTYPE(MPI_LONG_DOUBLE,long double,typecnt,stride,"MPI_LONG_DOUBLE");
+ SETUPVECTORTYPE(MPI_LONG_DOUBLE, long double, typecnt, stride, "MPI_LONG_DOUBLE");
#endif
/* Generate indexed items */
- SETUPINDEXTYPE(MPI_CHAR,char,typecnt,"MPI_CHAR");
- SETUPINDEXTYPE(MPI_SHORT,short,typecnt,"MPI_SHORT");
- SETUPINDEXTYPE(MPI_INT,int,typecnt,"MPI_INT");
- SETUPINDEXTYPE(MPI_LONG,long,typecnt,"MPI_LONG");
- SETUPINDEXTYPE(MPI_UNSIGNED_CHAR,unsigned char,typecnt,"MPI_UNSIGNED_CHAR");
- SETUPINDEXTYPE(MPI_UNSIGNED_SHORT,unsigned short,typecnt,"MPI_UNSIGNED_SHORT");
- SETUPINDEXTYPE(MPI_UNSIGNED,unsigned,typecnt,"MPI_UNSIGNED");
- SETUPINDEXTYPE(MPI_UNSIGNED_LONG,unsigned long,typecnt,"MPI_UNSIGNED_LONG");
- SETUPINDEXTYPE(MPI_FLOAT,float,typecnt,"MPI_FLOAT");
- SETUPINDEXTYPE(MPI_DOUBLE,double,typecnt,"MPI_DOUBLE");
- SETUPINDEXTYPE(MPI_BYTE,char,typecnt,"MPI_BYTE");
+ SETUPINDEXTYPE(MPI_CHAR, char, typecnt, "MPI_CHAR");
+ SETUPINDEXTYPE(MPI_SHORT, short, typecnt, "MPI_SHORT");
+ SETUPINDEXTYPE(MPI_INT, int, typecnt, "MPI_INT");
+ SETUPINDEXTYPE(MPI_LONG, long, typecnt, "MPI_LONG");
+ SETUPINDEXTYPE(MPI_UNSIGNED_CHAR, unsigned char, typecnt, "MPI_UNSIGNED_CHAR");
+ SETUPINDEXTYPE(MPI_UNSIGNED_SHORT, unsigned short, typecnt, "MPI_UNSIGNED_SHORT");
+ SETUPINDEXTYPE(MPI_UNSIGNED, unsigned, typecnt, "MPI_UNSIGNED");
+ SETUPINDEXTYPE(MPI_UNSIGNED_LONG, unsigned long, typecnt, "MPI_UNSIGNED_LONG");
+ SETUPINDEXTYPE(MPI_FLOAT, float, typecnt, "MPI_FLOAT");
+ SETUPINDEXTYPE(MPI_DOUBLE, double, typecnt, "MPI_DOUBLE");
+ SETUPINDEXTYPE(MPI_BYTE, char, typecnt, "MPI_BYTE");
#ifdef HAVE_LONG_LONG_INT
- SETUPINDEXTYPE(MPI_LONG_LONG_INT,long long,typecnt,"MPI_LONG_LONG_INT");
+ SETUPINDEXTYPE(MPI_LONG_LONG_INT, long long, typecnt, "MPI_LONG_LONG_INT");
#endif
#ifdef HAVE_LONG_DOUBLE
- SETUPINDEXTYPE(MPI_LONG_DOUBLE,long double,typecnt,"MPI_LONG_DOUBLE");
+ SETUPINDEXTYPE(MPI_LONG_DOUBLE, long double, typecnt, "MPI_LONG_DOUBLE");
#endif
/* Generate struct items */
- SETUPSTRUCT2TYPE(MPI_CHAR,char,MPI_DOUBLE,double,typecnt,"char-double");
- SETUPSTRUCT2TYPE(MPI_DOUBLE,double,MPI_CHAR,char,typecnt,"double-char");
- SETUPSTRUCT2TYPE(MPI_UNSIGNED,unsigned,MPI_DOUBLE,double,typecnt,"unsigned-double");
- SETUPSTRUCT2TYPE(MPI_FLOAT,float,MPI_LONG,long,typecnt,"float-long");
- SETUPSTRUCT2TYPE(MPI_UNSIGNED_CHAR,unsigned char,MPI_CHAR,char,typecnt,
- "unsigned char-char");
- SETUPSTRUCT2TYPE(MPI_UNSIGNED_SHORT,unsigned short,MPI_DOUBLE,double,
- typecnt,"unsigned short-double");
+ SETUPSTRUCT2TYPE(MPI_CHAR, char, MPI_DOUBLE, double, typecnt, "char-double");
+ SETUPSTRUCT2TYPE(MPI_DOUBLE, double, MPI_CHAR, char, typecnt, "double-char");
+ SETUPSTRUCT2TYPE(MPI_UNSIGNED, unsigned, MPI_DOUBLE, double, typecnt, "unsigned-double");
+ SETUPSTRUCT2TYPE(MPI_FLOAT, float, MPI_LONG, long, typecnt, "float-long");
+ SETUPSTRUCT2TYPE(MPI_UNSIGNED_CHAR, unsigned char, MPI_CHAR, char, typecnt,
+ "unsigned char-char");
+ SETUPSTRUCT2TYPE(MPI_UNSIGNED_SHORT, unsigned short, MPI_DOUBLE, double,
+ typecnt, "unsigned short-double");
/* Generate struct using MPI_UB */
- SETUPSTRUCTTYPEUB(MPI_CHAR,char,typecnt,stride);
- SETUPSTRUCTTYPEUB(MPI_SHORT,short,typecnt,stride);
- SETUPSTRUCTTYPEUB(MPI_INT,int,typecnt,stride);
- SETUPSTRUCTTYPEUB(MPI_LONG,long,typecnt,stride);
- SETUPSTRUCTTYPEUB(MPI_UNSIGNED_CHAR,unsigned char,typecnt,stride);
- SETUPSTRUCTTYPEUB(MPI_UNSIGNED_SHORT,unsigned short,typecnt,stride);
- SETUPSTRUCTTYPEUB(MPI_UNSIGNED,unsigned,typecnt,stride);
- SETUPSTRUCTTYPEUB(MPI_UNSIGNED_LONG,unsigned long,typecnt,stride);
- SETUPSTRUCTTYPEUB(MPI_FLOAT,float,typecnt,stride);
- SETUPSTRUCTTYPEUB(MPI_DOUBLE,double,typecnt,stride);
- SETUPSTRUCTTYPEUB(MPI_BYTE,char,typecnt,stride);
+ SETUPSTRUCTTYPEUB(MPI_CHAR, char, typecnt, stride);
+ SETUPSTRUCTTYPEUB(MPI_SHORT, short, typecnt, stride);
+ SETUPSTRUCTTYPEUB(MPI_INT, int, typecnt, stride);
+ SETUPSTRUCTTYPEUB(MPI_LONG, long, typecnt, stride);
+ SETUPSTRUCTTYPEUB(MPI_UNSIGNED_CHAR, unsigned char, typecnt, stride);
+ SETUPSTRUCTTYPEUB(MPI_UNSIGNED_SHORT, unsigned short, typecnt, stride);
+ SETUPSTRUCTTYPEUB(MPI_UNSIGNED, unsigned, typecnt, stride);
+ SETUPSTRUCTTYPEUB(MPI_UNSIGNED_LONG, unsigned long, typecnt, stride);
+ SETUPSTRUCTTYPEUB(MPI_FLOAT, float, typecnt, stride);
+ SETUPSTRUCTTYPEUB(MPI_DOUBLE, double, typecnt, stride);
+ SETUPSTRUCTTYPEUB(MPI_BYTE, char, typecnt, stride);
/* 60 different entries to this point + 4 for long long and
- 4 for long double */
+ * 4 for long double */
*n = cnt;
}
@@ -322,26 +322,25 @@ void MTestDatatype2Generate( MPI_Datatype *types, void **inbufs, void **outbufs,
indeed, large enough)
*/
#define MAX_TEST 70
-void MTestDatatype2Allocate( MPI_Datatype **types, void ***inbufs,
- void ***outbufs,
- int **counts, int **bytesize, int *n )
+void MTestDatatype2Allocate(MPI_Datatype ** types, void ***inbufs,
+ void ***outbufs, int **counts, int **bytesize, int *n)
{
- *types = (MPI_Datatype *)malloc( MAX_TEST * sizeof(MPI_Datatype) );
- *inbufs = (void **) malloc( MAX_TEST * sizeof(void *) );
- *outbufs = (void **) malloc( MAX_TEST * sizeof(void *) );
- *counts = (int *) malloc( MAX_TEST * sizeof(int) );
- *bytesize = (int *) malloc( MAX_TEST * sizeof(int) );
- *n = MAX_TEST;
+ *types = (MPI_Datatype *) malloc(MAX_TEST * sizeof(MPI_Datatype));
+ *inbufs = (void **) malloc(MAX_TEST * sizeof(void *));
+ *outbufs = (void **) malloc(MAX_TEST * sizeof(void *));
+ *counts = (int *) malloc(MAX_TEST * sizeof(int));
+ *bytesize = (int *) malloc(MAX_TEST * sizeof(int));
+ *n = MAX_TEST;
}
-int MTestDatatype2Check( void *inbuf, void *outbuf, int size_bytes )
+int MTestDatatype2Check(void *inbuf, void *outbuf, int size_bytes)
{
- char *in = (char *)inbuf, *out = (char *)outbuf;
- int i;
- for (i=0; i<size_bytes; i++) {
- if (in[i] != out[i]) {
- return i + 1;
- }
+ char *in = (char *) inbuf, *out = (char *) outbuf;
+ int i;
+ for (i = 0; i < size_bytes; i++) {
+ if (in[i] != out[i]) {
+ return i + 1;
+ }
}
return 0;
}
@@ -349,40 +348,39 @@ int MTestDatatype2Check( void *inbuf, void *outbuf, int size_bytes )
/*
* This is a version of CheckData that prints error messages
*/
-int MtestDatatype2CheckAndPrint( void *inbuf, void *outbuf, int size_bytes,
- char *typename, int typenum )
+int MtestDatatype2CheckAndPrint(void *inbuf, void *outbuf, int size_bytes,
+ char *typename, int typenum)
{
int errloc, world_rank;
- if ((errloc = MTestDatatype2Check( inbuf, outbuf, size_bytes ))) {
- char *p1, *p2;
- MPI_Comm_rank( MPI_COMM_WORLD, &world_rank );
- fprintf( stderr,
- "Error in data with type %s (type %d on %d) at byte %d of %d\n",
- typename, typenum, world_rank, errloc - 1, size_bytes );
- p1 = (char *)inbuf;
- p2 = (char *)outbuf;
- fprintf( stderr,
- "Got %x expected %x\n", p2[errloc-1], p1[errloc-1] );
+ if ((errloc = MTestDatatype2Check(inbuf, outbuf, size_bytes))) {
+ char *p1, *p2;
+ MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
+ fprintf(stderr,
+ "Error in data with type %s (type %d on %d) at byte %d of %d\n",
+ typename, typenum, world_rank, errloc - 1, size_bytes);
+ p1 = (char *) inbuf;
+ p2 = (char *) outbuf;
+ fprintf(stderr, "Got %x expected %x\n", p2[errloc - 1], p1[errloc - 1]);
}
return errloc;
}
-void MTestDatatype2Free( MPI_Datatype *types, void **inbufs, void **outbufs,
- int *counts, int *bytesize, int n )
+void MTestDatatype2Free(MPI_Datatype * types, void **inbufs, void **outbufs,
+ int *counts, int *bytesize, int n)
{
int i;
- for (i=0; i<n; i++) {
- if (inbufs[i])
- free( inbufs[i] );
- if (outbufs[i])
- free( outbufs[i] );
- /* Only if not basic ... */
- if (i >= nbasic_types)
- MPI_Type_free( types + i );
+ for (i = 0; i < n; i++) {
+ if (inbufs[i])
+ free(inbufs[i]);
+ if (outbufs[i])
+ free(outbufs[i]);
+ /* Only if not basic ... */
+ if (i >= nbasic_types)
+ MPI_Type_free(types + i);
}
- free( inbufs );
- free( outbufs );
- free( counts );
- free( bytesize );
+ free(inbufs);
+ free(outbufs);
+ free(counts);
+ free(bytesize);
}
diff --git a/test/mpi/util/mtest.c b/test/mpi/util/mtest.c
index 53c689e..eb23ace 100644
--- a/test/mpi/util/mtest.c
+++ b/test/mpi/util/mtest.c
@@ -39,11 +39,11 @@
* as the error handler. We do *not* set MPI_ERRORS_RETURN because
* the code that makes use of these routines may not check return
* codes.
- *
+ *
*/
-static void MTestRMACleanup( void );
-static void MTestResourceSummary( FILE * );
+static void MTestRMACleanup(void);
+static void MTestResourceSummary(FILE *);
/* Here is where we could put the includes and definitions to enable
memory testing */
@@ -51,9 +51,9 @@ static void MTestResourceSummary( FILE * );
static int dbgflag = 0; /* Flag used for debugging */
static int wrank = -1; /* World rank */
static int verbose = 0; /* Message level (0 is none) */
-static int returnWithVal = 0; /* Allow programs to return with a non-zero
- if there was an error (may cause problems
- with some runtime systems) */
+static int returnWithVal = 0; /* Allow programs to return with a non-zero
+ * if there was an error (may cause problems
+ * with some runtime systems) */
static int usageOutput = 0; /* */
/* Provide backward portability to MPI 1 */
@@ -64,409 +64,438 @@ static int usageOutput = 0; /* */
#define MPI_THREAD_SINGLE 0
#endif
-/*
+/*
* Initialize and Finalize MTest
*/
/*
- Initialize MTest, initializing MPI if necessary.
+ Initialize MTest, initializing MPI if necessary.
Environment Variables:
+ MPITEST_DEBUG - If set (to any value), turns on debugging output
. MPITEST_THREADLEVEL_DEFAULT - If set, use as the default "provided"
- level of thread support. Applies to
+ level of thread support. Applies to
MTest_Init but not MTest_Init_thread.
- MPITEST_VERBOSE - If set to a numeric value, turns on that level of
verbose output. This is used by the routine 'MTestPrintfMsg'
*/
-void MTest_Init_thread( int *argc, char ***argv, int required, int *provided )
+void MTest_Init_thread(int *argc, char ***argv, int required, int *provided)
{
int flag;
char *envval = 0;
- MPI_Initialized( &flag );
+ MPI_Initialized(&flag);
if (!flag) {
- /* Permit an MPI that claims only MPI 1 but includes the
- MPI_Init_thread routine (e.g., IBM MPI) */
+ /* Permit an MPI that claims only MPI 1 but includes the
+ * MPI_Init_thread routine (e.g., IBM MPI) */
#if MPI_VERSION >= 2 || defined(HAVE_MPI_INIT_THREAD)
- MPI_Init_thread( argc, argv, required, provided );
+ MPI_Init_thread(argc, argv, required, provided);
#else
- MPI_Init( argc, argv );
- *provided = -1;
+ MPI_Init(argc, argv);
+ *provided = -1;
#endif
}
/* Check for debugging control */
- if (getenv( "MPITEST_DEBUG" )) {
- dbgflag = 1;
- MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
+ if (getenv("MPITEST_DEBUG")) {
+ dbgflag = 1;
+ MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
}
/* Check for verbose control */
- envval = getenv( "MPITEST_VERBOSE" );
+ envval = getenv("MPITEST_VERBOSE");
if (envval) {
- char *s;
- long val = strtol( envval, &s, 0 );
- if (s == envval) {
- /* This is the error case for strtol */
- fprintf( stderr, "Warning: %s not valid for MPITEST_VERBOSE\n",
- envval );
- fflush( stderr );
- }
- else {
- if (val >= 0) {
- verbose = val;
- }
- else {
- fprintf( stderr, "Warning: %s not valid for MPITEST_VERBOSE\n",
- envval );
- fflush( stderr );
- }
- }
+ char *s;
+ long val = strtol(envval, &s, 0);
+ if (s == envval) {
+ /* This is the error case for strtol */
+ fprintf(stderr, "Warning: %s not valid for MPITEST_VERBOSE\n", envval);
+ fflush(stderr);
+ }
+ else {
+ if (val >= 0) {
+ verbose = val;
+ }
+ else {
+ fprintf(stderr, "Warning: %s not valid for MPITEST_VERBOSE\n", envval);
+ fflush(stderr);
+ }
+ }
}
/* Check for option to return success/failure in the return value of main */
- envval = getenv( "MPITEST_RETURN_WITH_CODE" );
+ envval = getenv("MPITEST_RETURN_WITH_CODE");
if (envval) {
- if (strcmp( envval, "yes" ) == 0 ||
- strcmp( envval, "YES" ) == 0 ||
- strcmp( envval, "true" ) == 0 ||
- strcmp( envval, "TRUE" ) == 0) {
- returnWithVal = 1;
- }
- else if (strcmp( envval, "no" ) == 0 ||
- strcmp( envval, "NO" ) == 0 ||
- strcmp( envval, "false" ) == 0 ||
- strcmp( envval, "FALSE" ) == 0) {
- returnWithVal = 0;
- }
- else {
- fprintf( stderr,
- "Warning: %s not valid for MPITEST_RETURN_WITH_CODE\n",
- envval );
- fflush( stderr );
- }
+ if (strcmp(envval, "yes") == 0 ||
+ strcmp(envval, "YES") == 0 ||
+ strcmp(envval, "true") == 0 || strcmp(envval, "TRUE") == 0) {
+ returnWithVal = 1;
+ }
+ else if (strcmp(envval, "no") == 0 ||
+ strcmp(envval, "NO") == 0 ||
+ strcmp(envval, "false") == 0 || strcmp(envval, "FALSE") == 0) {
+ returnWithVal = 0;
+ }
+ else {
+ fprintf(stderr, "Warning: %s not valid for MPITEST_RETURN_WITH_CODE\n", envval);
+ fflush(stderr);
+ }
}
-
+
/* Print rusage data if set */
- if (getenv( "MPITEST_RUSAGE" )) {
- usageOutput = 1;
+ if (getenv("MPITEST_RUSAGE")) {
+ usageOutput = 1;
}
}
-/*
- * Initialize the tests, using an MPI-1 style init. Supports
+
+/*
+ * Initialize the tests, using an MPI-1 style init. Supports
* MTEST_THREADLEVEL_DEFAULT to test with user-specified thread level
*/
-void MTest_Init( int *argc, char ***argv )
+void MTest_Init(int *argc, char ***argv)
{
int provided;
#if MPI_VERSION >= 2 || defined(HAVE_MPI_INIT_THREAD)
const char *str = 0;
- int threadLevel;
+ int threadLevel;
threadLevel = MPI_THREAD_SINGLE;
- str = getenv( "MTEST_THREADLEVEL_DEFAULT" );
- if (!str) str = getenv( "MPITEST_THREADLEVEL_DEFAULT" );
+ str = getenv("MTEST_THREADLEVEL_DEFAULT");
+ if (!str)
+ str = getenv("MPITEST_THREADLEVEL_DEFAULT");
if (str && *str) {
- if (strcmp(str,"MULTIPLE") == 0 || strcmp(str,"multiple") == 0) {
- threadLevel = MPI_THREAD_MULTIPLE;
- }
- else if (strcmp(str,"SERIALIZED") == 0 ||
- strcmp(str,"serialized") == 0) {
- threadLevel = MPI_THREAD_SERIALIZED;
- }
- else if (strcmp(str,"FUNNELED") == 0 || strcmp(str,"funneled") == 0) {
- threadLevel = MPI_THREAD_FUNNELED;
- }
- else if (strcmp(str,"SINGLE") == 0 || strcmp(str,"single") == 0) {
- threadLevel = MPI_THREAD_SINGLE;
- }
- else {
- fprintf( stderr, "Unrecognized thread level %s\n", str );
- /* Use exit since MPI_Init/Init_thread has not been called. */
- exit(1);
- }
+ if (strcmp(str, "MULTIPLE") == 0 || strcmp(str, "multiple") == 0) {
+ threadLevel = MPI_THREAD_MULTIPLE;
+ }
+ else if (strcmp(str, "SERIALIZED") == 0 || strcmp(str, "serialized") == 0) {
+ threadLevel = MPI_THREAD_SERIALIZED;
+ }
+ else if (strcmp(str, "FUNNELED") == 0 || strcmp(str, "funneled") == 0) {
+ threadLevel = MPI_THREAD_FUNNELED;
+ }
+ else if (strcmp(str, "SINGLE") == 0 || strcmp(str, "single") == 0) {
+ threadLevel = MPI_THREAD_SINGLE;
+ }
+ else {
+ fprintf(stderr, "Unrecognized thread level %s\n", str);
+ /* Use exit since MPI_Init/Init_thread has not been called. */
+ exit(1);
+ }
}
- MTest_Init_thread( argc, argv, threadLevel, &provided );
+ MTest_Init_thread(argc, argv, threadLevel, &provided);
#else
/* If the MPI_VERSION is 1, there is no MPI_THREAD_xxx defined */
- MTest_Init_thread( argc, argv, 0, &provided );
-#endif
+ MTest_Init_thread(argc, argv, 0, &provided);
+#endif
}
/*
- Finalize MTest. errs is the number of errors on the calling process;
+ Finalize MTest. errs is the number of errors on the calling process;
this routine will write the total number of errors over all of MPI_COMM_WORLD
to the process with rank zero, or " No Errors".
It does *not* finalize MPI.
*/
-void MTest_Finalize( int errs )
+void MTest_Finalize(int errs)
{
int rank, toterrs, merr;
- merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- if (merr) MTestPrintError( merr );
+ merr = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ if (merr)
+ MTestPrintError(merr);
- merr = MPI_Reduce( &errs, &toterrs, 1, MPI_INT, MPI_SUM,
- 0, MPI_COMM_WORLD );
- if (merr) MTestPrintError( merr );
+ merr = MPI_Reduce(&errs, &toterrs, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
+ if (merr)
+ MTestPrintError(merr);
if (rank == 0) {
- if (toterrs) {
- printf( " Found %d errors\n", toterrs );
- }
- else {
- printf( " No Errors\n" );
- }
- fflush( stdout );
+ if (toterrs) {
+ printf(" Found %d errors\n", toterrs);
+ }
+ else {
+ printf(" No Errors\n");
+ }
+ fflush(stdout);
}
-
- if (usageOutput)
- MTestResourceSummary( stdout );
+
+ if (usageOutput)
+ MTestResourceSummary(stdout);
/* Clean up any persistent objects that we allocated */
MTestRMACleanup();
}
+
/* ------------------------------------------------------------------------ */
-/* This routine may be used instead of "return 0;" at the end of main;
- it allows the program to use the return value to signal success or failure.
+/* This routine may be used instead of "return 0;" at the end of main;
+ it allows the program to use the return value to signal success or failure.
*/
-int MTestReturnValue( int errors )
+int MTestReturnValue(int errors)
{
- if (returnWithVal) return errors ? 1 : 0;
+ if (returnWithVal)
+ return errors ? 1 : 0;
return 0;
}
+
/* ------------------------------------------------------------------------ */
/*
* Miscellaneous utilities, particularly to eliminate OS dependencies
* from the tests.
- * MTestSleep( seconds )
+ * MTestSleep(seconds)
*/
#ifdef HAVE_WINDOWS_H
#include <windows.h>
-void MTestSleep( int sec )
+void MTestSleep(int sec)
{
- Sleep( 1000 * sec );
+ Sleep(1000 * sec);
}
#else
#include <unistd.h>
-void MTestSleep( int sec )
+void MTestSleep(int sec)
{
- sleep( sec );
+ sleep(sec);
}
#endif
/* Other mtest subfiles read debug setting using this function. */
-void MTestGetDbgInfo(int *_dbgflag, int *_verbose) {
+void MTestGetDbgInfo(int *_dbgflag, int *_verbose)
+{
*_dbgflag = dbgflag;
*_verbose = verbose;
}
/* ----------------------------------------------------------------------- */
-/*
+/*
* Create communicators. Use separate routines for inter and intra
* communicators (there is a routine to give both)
* Note that the routines may return MPI_COMM_NULL, so code should test for
* that return value as well.
- *
+ *
*/
static int interCommIdx = 0;
static int intraCommIdx = 0;
static const char *intraCommName = 0;
static const char *interCommName = 0;
-/*
+/*
* Get an intracommunicator with at least min_size members. If "allowSmaller"
* is true, allow the communicator to be smaller than MPI_COMM_WORLD and
* for this routine to return MPI_COMM_NULL for some values. Returns 0 if
* no more communicators are available.
*/
-int MTestGetIntracommGeneral( MPI_Comm *comm, int min_size, int allowSmaller )
+int MTestGetIntracommGeneral(MPI_Comm * comm, int min_size, int allowSmaller)
{
int size, rank, merr;
- int done=0;
+ int done = 0;
int isBasic = 0;
/* The while loop allows us to skip communicators that are too small.
- MPI_COMM_NULL is always considered large enough */
+ * MPI_COMM_NULL is always considered large enough */
while (!done) {
- isBasic = 0;
- intraCommName = "";
- switch (intraCommIdx) {
- case 0:
- *comm = MPI_COMM_WORLD;
- isBasic = 1;
- intraCommName = "MPI_COMM_WORLD";
- break;
- case 1:
- /* dup of world */
- merr = MPI_Comm_dup(MPI_COMM_WORLD, comm );
- if (merr) MTestPrintError( merr );
- intraCommName = "Dup of MPI_COMM_WORLD";
- break;
- case 2:
- /* reverse ranks */
- merr = MPI_Comm_size( MPI_COMM_WORLD, &size );
- if (merr) MTestPrintError( merr );
- merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- if (merr) MTestPrintError( merr );
- merr = MPI_Comm_split( MPI_COMM_WORLD, 0, size-rank, comm );
- if (merr) MTestPrintError( merr );
- intraCommName = "Rank reverse of MPI_COMM_WORLD";
- break;
- case 3:
- /* subset of world, with reversed ranks */
- merr = MPI_Comm_size( MPI_COMM_WORLD, &size );
- if (merr) MTestPrintError( merr );
- merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- if (merr) MTestPrintError( merr );
- merr = MPI_Comm_split( MPI_COMM_WORLD, ((rank < size/2) ? 1 : MPI_UNDEFINED),
- size-rank, comm );
- if (merr) MTestPrintError( merr );
- intraCommName = "Rank reverse of half of MPI_COMM_WORLD";
- break;
- case 4:
- *comm = MPI_COMM_SELF;
- isBasic = 1;
- intraCommName = "MPI_COMM_SELF";
- break;
- case 5:
- {
- /* Dup of the world using MPI_Intercomm_merge */
- int rleader, isLeft;
- MPI_Comm local_comm, inter_comm;
- MPI_Comm_size(MPI_COMM_WORLD, &size);
- MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- if (size > 1) {
- merr = MPI_Comm_split( MPI_COMM_WORLD, (rank < size/2), rank, &local_comm);
- if (merr) MTestPrintError( merr );
- if (rank == 0) { rleader = size/2; }
- else if (rank == size/2) { rleader = 0; }
- else { rleader = -1; }
- isLeft = rank < size/2;
- merr = MPI_Intercomm_create(local_comm, 0, MPI_COMM_WORLD, rleader, 99, &inter_comm);
- if (merr) MTestPrintError(merr);
- merr = MPI_Intercomm_merge(inter_comm, isLeft, comm);
- if (merr) MTestPrintError(merr);
- MPI_Comm_free(&inter_comm);
- MPI_Comm_free(&local_comm);
- intraCommName = "Dup of WORLD created by MPI_Intercomm_merge";
- } else {
- *comm = MPI_COMM_NULL;
- }
- }
- break;
- case 6:
- {
+ isBasic = 0;
+ intraCommName = "";
+ switch (intraCommIdx) {
+ case 0:
+ *comm = MPI_COMM_WORLD;
+ isBasic = 1;
+ intraCommName = "MPI_COMM_WORLD";
+ break;
+ case 1:
+ /* dup of world */
+ merr = MPI_Comm_dup(MPI_COMM_WORLD, comm);
+ if (merr)
+ MTestPrintError(merr);
+ intraCommName = "Dup of MPI_COMM_WORLD";
+ break;
+ case 2:
+ /* reverse ranks */
+ merr = MPI_Comm_size(MPI_COMM_WORLD, &size);
+ if (merr)
+ MTestPrintError(merr);
+ merr = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ if (merr)
+ MTestPrintError(merr);
+ merr = MPI_Comm_split(MPI_COMM_WORLD, 0, size - rank, comm);
+ if (merr)
+ MTestPrintError(merr);
+ intraCommName = "Rank reverse of MPI_COMM_WORLD";
+ break;
+ case 3:
+ /* subset of world, with reversed ranks */
+ merr = MPI_Comm_size(MPI_COMM_WORLD, &size);
+ if (merr)
+ MTestPrintError(merr);
+ merr = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ if (merr)
+ MTestPrintError(merr);
+ merr = MPI_Comm_split(MPI_COMM_WORLD, ((rank < size / 2) ? 1 : MPI_UNDEFINED),
+ size - rank, comm);
+ if (merr)
+ MTestPrintError(merr);
+ intraCommName = "Rank reverse of half of MPI_COMM_WORLD";
+ break;
+ case 4:
+ *comm = MPI_COMM_SELF;
+ isBasic = 1;
+ intraCommName = "MPI_COMM_SELF";
+ break;
+ case 5:
+ {
+ /* Dup of the world using MPI_Intercomm_merge */
+ int rleader, isLeft;
+ MPI_Comm local_comm, inter_comm;
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ if (size > 1) {
+ merr = MPI_Comm_split(MPI_COMM_WORLD, (rank < size / 2), rank, &local_comm);
+ if (merr)
+ MTestPrintError(merr);
+ if (rank == 0) {
+ rleader = size / 2;
+ }
+ else if (rank == size / 2) {
+ rleader = 0;
+ }
+ else {
+ rleader = -1;
+ }
+ isLeft = rank < size / 2;
+ merr =
+ MPI_Intercomm_create(local_comm, 0, MPI_COMM_WORLD, rleader, 99,
+ &inter_comm);
+ if (merr)
+ MTestPrintError(merr);
+ merr = MPI_Intercomm_merge(inter_comm, isLeft, comm);
+ if (merr)
+ MTestPrintError(merr);
+ MPI_Comm_free(&inter_comm);
+ MPI_Comm_free(&local_comm);
+ intraCommName = "Dup of WORLD created by MPI_Intercomm_merge";
+ }
+ else {
+ *comm = MPI_COMM_NULL;
+ }
+ }
+ break;
+ case 6:
+ {
#if MTEST_HAVE_MIN_MPI_VERSION(3,0)
- /* Even of the world using MPI_Comm_create_group */
- int i;
- MPI_Group world_group, even_group;
- int *excl = NULL;
-
- MPI_Comm_size(MPI_COMM_WORLD, &size);
- MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- if (allowSmaller && (size+1)/2 >= min_size) {
- /* exclude the odd ranks */
- excl = malloc((size/2) * sizeof(int));
- for (i = 0; i < size / 2; i++) excl[i] = (2 * i) + 1;
-
- MPI_Comm_group(MPI_COMM_WORLD, &world_group);
- MPI_Group_excl(world_group, size / 2, excl, &even_group);
- MPI_Group_free(&world_group);
- free(excl);
-
- if (rank % 2 == 0) {
- /* Even processes create a comm. for themselves */
- MPI_Comm_create_group(MPI_COMM_WORLD, even_group, 0, comm);
- intraCommName = "Even of WORLD created by MPI_Comm_create_group";
- } else {
- *comm = MPI_COMM_NULL;
+ /* Even of the world using MPI_Comm_create_group */
+ int i;
+ MPI_Group world_group, even_group;
+ int *excl = NULL;
+
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ if (allowSmaller && (size + 1) / 2 >= min_size) {
+ /* exclude the odd ranks */
+ excl = malloc((size / 2) * sizeof(int));
+ for (i = 0; i < size / 2; i++)
+ excl[i] = (2 * i) + 1;
+
+ MPI_Comm_group(MPI_COMM_WORLD, &world_group);
+ MPI_Group_excl(world_group, size / 2, excl, &even_group);
+ MPI_Group_free(&world_group);
+ free(excl);
+
+ if (rank % 2 == 0) {
+ /* Even processes create a comm. for themselves */
+ MPI_Comm_create_group(MPI_COMM_WORLD, even_group, 0, comm);
+ intraCommName = "Even of WORLD created by MPI_Comm_create_group";
+ }
+ else {
+ *comm = MPI_COMM_NULL;
+ }
+
+ MPI_Group_free(&even_group);
+ }
+ else {
+ *comm = MPI_COMM_NULL;
+ }
+#else
+ *comm = MPI_COMM_NULL;
+#endif
+ }
+ break;
+ case 7:
+ {
+ /* High half of the world using MPI_Comm_create */
+ int ranges[1][3];
+ MPI_Group world_group, high_group;
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ ranges[0][0] = size / 2;
+ ranges[0][1] = size - 1;
+ ranges[0][2] = 1;
+
+ if (allowSmaller && (size + 1) / 2 >= min_size) {
+ MPI_Comm_group(MPI_COMM_WORLD, &world_group);
+ merr = MPI_Group_range_incl(world_group, 1, ranges, &high_group);
+ if (merr)
+ MTestPrintError(merr);
+ merr = MPI_Comm_create(MPI_COMM_WORLD, high_group, comm);
+ if (merr)
+ MTestPrintError(merr);
+ MPI_Group_free(&world_group);
+ MPI_Group_free(&high_group);
+ intraCommName = "High half of WORLD created by MPI_Comm_create";
+ }
+ else {
+ *comm = MPI_COMM_NULL;
+ }
}
+ break;
+ /* These next cases are communicators that include some
+ * but not all of the processes */
+ case 8:
+ case 9:
+ case 10:
+ case 11:
+ {
+ int newsize;
+ merr = MPI_Comm_size(MPI_COMM_WORLD, &size);
+ if (merr)
+ MTestPrintError(merr);
+ newsize = size - (intraCommIdx - 7);
+
+ if (allowSmaller && newsize >= min_size) {
+ merr = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ if (merr)
+ MTestPrintError(merr);
+ merr = MPI_Comm_split(MPI_COMM_WORLD, rank < newsize, rank, comm);
+ if (merr)
+ MTestPrintError(merr);
+ if (rank >= newsize) {
+ merr = MPI_Comm_free(comm);
+ if (merr)
+ MTestPrintError(merr);
+ *comm = MPI_COMM_NULL;
+ }
+ else {
+ intraCommName = "Split of WORLD";
+ }
+ }
+ else {
+ /* Act like default */
+ *comm = MPI_COMM_NULL;
+ intraCommIdx = -1;
+ }
+ }
+ break;
- MPI_Group_free(&even_group);
- } else {
+ /* Other ideas: dup of self, cart comm, graph comm */
+ default:
*comm = MPI_COMM_NULL;
+ intraCommIdx = -1;
+ break;
+ }
+
+ if (*comm != MPI_COMM_NULL) {
+ merr = MPI_Comm_size(*comm, &size);
+ if (merr)
+ MTestPrintError(merr);
+ if (size >= min_size)
+ done = 1;
}
-#else
- *comm = MPI_COMM_NULL;
-#endif
- }
- break;
- case 7:
- {
- /* High half of the world using MPI_Comm_create */
- int ranges[1][3];
- MPI_Group world_group, high_group;
- MPI_Comm_size(MPI_COMM_WORLD, &size);
- MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- ranges[0][0] = size/2;
- ranges[0][1] = size-1;
- ranges[0][2] = 1;
-
- if (allowSmaller && (size+1)/2 >= min_size) {
- MPI_Comm_group(MPI_COMM_WORLD, &world_group);
- merr = MPI_Group_range_incl(world_group, 1, ranges, &high_group);
- if (merr) MTestPrintError(merr);
- merr = MPI_Comm_create(MPI_COMM_WORLD, high_group, comm);
- if (merr) MTestPrintError(merr);
- MPI_Group_free(&world_group);
- MPI_Group_free(&high_group);
- intraCommName = "High half of WORLD created by MPI_Comm_create";
- } else {
- *comm = MPI_COMM_NULL;
- }
- }
- break;
- /* These next cases are communicators that include some
- but not all of the processes */
- case 8:
- case 9:
- case 10:
- case 11:
- {
- int newsize;
- merr = MPI_Comm_size( MPI_COMM_WORLD, &size );
- if (merr) MTestPrintError( merr );
- newsize = size - (intraCommIdx - 7);
-
- if (allowSmaller && newsize >= min_size) {
- merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- if (merr) MTestPrintError( merr );
- merr = MPI_Comm_split( MPI_COMM_WORLD, rank < newsize, rank,
- comm );
- if (merr) MTestPrintError( merr );
- if (rank >= newsize) {
- merr = MPI_Comm_free( comm );
- if (merr) MTestPrintError( merr );
- *comm = MPI_COMM_NULL;
- }
- else {
- intraCommName = "Split of WORLD";
- }
- }
- else {
- /* Act like default */
- *comm = MPI_COMM_NULL;
- intraCommIdx = -1;
- }
- }
- break;
-
- /* Other ideas: dup of self, cart comm, graph comm */
- default:
- *comm = MPI_COMM_NULL;
- intraCommIdx = -1;
- break;
- }
-
- if (*comm != MPI_COMM_NULL) {
- merr = MPI_Comm_size( *comm, &size );
- if (merr) MTestPrintError( merr );
- if (size >= min_size)
- done = 1;
- }
else {
intraCommName = "MPI_COMM_NULL";
isBasic = 1;
@@ -484,253 +513,274 @@ int MTestGetIntracommGeneral( MPI_Comm *comm, int min_size, int allowSmaller )
if (!done && !isBasic && *comm != MPI_COMM_NULL) {
/* avoid leaking communicators */
merr = MPI_Comm_free(comm);
- if (merr) MTestPrintError(merr);
+ if (merr)
+ MTestPrintError(merr);
}
}
return intraCommIdx;
}
-/*
+/*
* Get an intracommunicator with at least min_size members.
*/
-int MTestGetIntracomm( MPI_Comm *comm, int min_size )
+int MTestGetIntracomm(MPI_Comm * comm, int min_size)
{
- return MTestGetIntracommGeneral( comm, min_size, 0 );
+ return MTestGetIntracommGeneral(comm, min_size, 0);
}
/* Return the name of an intra communicator */
-const char *MTestGetIntracommName( void )
+const char *MTestGetIntracommName(void)
{
return intraCommName;
}
-/*
- * Return an intercomm; set isLeftGroup to 1 if the calling process is
+/*
+ * Return an intercomm; set isLeftGroup to 1 if the calling process is
* a member of the "left" group.
*/
-int MTestGetIntercomm( MPI_Comm *comm, int *isLeftGroup, int min_size )
+int MTestGetIntercomm(MPI_Comm * comm, int *isLeftGroup, int min_size)
{
int size, rank, remsize, merr;
- int done=0;
- MPI_Comm mcomm = MPI_COMM_NULL;
+ int done = 0;
+ MPI_Comm mcomm = MPI_COMM_NULL;
MPI_Comm mcomm2 = MPI_COMM_NULL;
int rleader;
/* The while loop allows us to skip communicators that are too small.
- MPI_COMM_NULL is always considered large enough. The size is
- the sum of the sizes of the local and remote groups */
+ * MPI_COMM_NULL is always considered large enough. The size is
+ * the sum of the sizes of the local and remote groups */
while (!done) {
*comm = MPI_COMM_NULL;
*isLeftGroup = 0;
interCommName = "MPI_COMM_NULL";
- switch (interCommIdx) {
- case 0:
- /* Split comm world in half */
- merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- if (merr) MTestPrintError( merr );
- merr = MPI_Comm_size( MPI_COMM_WORLD, &size );
- if (merr) MTestPrintError( merr );
- if (size > 1) {
- merr = MPI_Comm_split( MPI_COMM_WORLD, (rank < size/2), rank,
- &mcomm );
- if (merr) MTestPrintError( merr );
- if (rank == 0) {
- rleader = size/2;
- }
- else if (rank == size/2) {
- rleader = 0;
- }
- else {
- /* Remote leader is signficant only for the processes
- designated local leaders */
- rleader = -1;
- }
- *isLeftGroup = rank < size/2;
- merr = MPI_Intercomm_create( mcomm, 0, MPI_COMM_WORLD, rleader,
- 12345, comm );
- if (merr) MTestPrintError( merr );
- interCommName = "Intercomm by splitting MPI_COMM_WORLD";
- }
- else
- *comm = MPI_COMM_NULL;
- break;
- case 1:
- /* Split comm world in to 1 and the rest */
- merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- if (merr) MTestPrintError( merr );
- merr = MPI_Comm_size( MPI_COMM_WORLD, &size );
- if (merr) MTestPrintError( merr );
- if (size > 1) {
- merr = MPI_Comm_split( MPI_COMM_WORLD, rank == 0, rank,
- &mcomm );
- if (merr) MTestPrintError( merr );
- if (rank == 0) {
- rleader = 1;
- }
- else if (rank == 1) {
- rleader = 0;
- }
- else {
- /* Remote leader is signficant only for the processes
- designated local leaders */
- rleader = -1;
- }
- *isLeftGroup = rank == 0;
- merr = MPI_Intercomm_create( mcomm, 0, MPI_COMM_WORLD,
- rleader, 12346, comm );
- if (merr) MTestPrintError( merr );
- interCommName = "Intercomm by splitting MPI_COMM_WORLD into 1, rest";
- }
- else
- *comm = MPI_COMM_NULL;
- break;
-
- case 2:
- /* Split comm world in to 2 and the rest */
- merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- if (merr) MTestPrintError( merr );
- merr = MPI_Comm_size( MPI_COMM_WORLD, &size );
- if (merr) MTestPrintError( merr );
- if (size > 3) {
- merr = MPI_Comm_split( MPI_COMM_WORLD, rank < 2, rank,
- &mcomm );
- if (merr) MTestPrintError( merr );
- if (rank == 0) {
- rleader = 2;
- }
- else if (rank == 2) {
- rleader = 0;
- }
- else {
- /* Remote leader is signficant only for the processes
- designated local leaders */
- rleader = -1;
- }
- *isLeftGroup = rank < 2;
- merr = MPI_Intercomm_create( mcomm, 0, MPI_COMM_WORLD,
- rleader, 12347, comm );
- if (merr) MTestPrintError( merr );
- interCommName = "Intercomm by splitting MPI_COMM_WORLD into 2, rest";
- }
- else
- *comm = MPI_COMM_NULL;
- break;
-
- case 3:
- /* Split comm world in half, then dup */
- merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- if (merr) MTestPrintError( merr );
- merr = MPI_Comm_size( MPI_COMM_WORLD, &size );
- if (merr) MTestPrintError( merr );
- if (size > 1) {
- merr = MPI_Comm_split( MPI_COMM_WORLD, (rank < size/2), rank,
- &mcomm );
- if (merr) MTestPrintError( merr );
- if (rank == 0) {
- rleader = size/2;
- }
- else if (rank == size/2) {
- rleader = 0;
- }
- else {
- /* Remote leader is signficant only for the processes
- designated local leaders */
- rleader = -1;
- }
- *isLeftGroup = rank < size/2;
- merr = MPI_Intercomm_create( mcomm, 0, MPI_COMM_WORLD, rleader,
- 12345, comm );
- if (merr) MTestPrintError( merr );
+ switch (interCommIdx) {
+ case 0:
+ /* Split comm world in half */
+ merr = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ if (merr)
+ MTestPrintError(merr);
+ merr = MPI_Comm_size(MPI_COMM_WORLD, &size);
+ if (merr)
+ MTestPrintError(merr);
+ if (size > 1) {
+ merr = MPI_Comm_split(MPI_COMM_WORLD, (rank < size / 2), rank, &mcomm);
+ if (merr)
+ MTestPrintError(merr);
+ if (rank == 0) {
+ rleader = size / 2;
+ }
+ else if (rank == size / 2) {
+ rleader = 0;
+ }
+ else {
+ /* Remote leader is signficant only for the processes
+ * designated local leaders */
+ rleader = -1;
+ }
+ *isLeftGroup = rank < size / 2;
+ merr = MPI_Intercomm_create(mcomm, 0, MPI_COMM_WORLD, rleader, 12345, comm);
+ if (merr)
+ MTestPrintError(merr);
+ interCommName = "Intercomm by splitting MPI_COMM_WORLD";
+ }
+ else
+ *comm = MPI_COMM_NULL;
+ break;
+ case 1:
+ /* Split comm world in to 1 and the rest */
+ merr = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ if (merr)
+ MTestPrintError(merr);
+ merr = MPI_Comm_size(MPI_COMM_WORLD, &size);
+ if (merr)
+ MTestPrintError(merr);
+ if (size > 1) {
+ merr = MPI_Comm_split(MPI_COMM_WORLD, rank == 0, rank, &mcomm);
+ if (merr)
+ MTestPrintError(merr);
+ if (rank == 0) {
+ rleader = 1;
+ }
+ else if (rank == 1) {
+ rleader = 0;
+ }
+ else {
+ /* Remote leader is signficant only for the processes
+ * designated local leaders */
+ rleader = -1;
+ }
+ *isLeftGroup = rank == 0;
+ merr = MPI_Intercomm_create(mcomm, 0, MPI_COMM_WORLD, rleader, 12346, comm);
+ if (merr)
+ MTestPrintError(merr);
+ interCommName = "Intercomm by splitting MPI_COMM_WORLD into 1, rest";
+ }
+ else
+ *comm = MPI_COMM_NULL;
+ break;
+
+ case 2:
+ /* Split comm world in to 2 and the rest */
+ merr = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ if (merr)
+ MTestPrintError(merr);
+ merr = MPI_Comm_size(MPI_COMM_WORLD, &size);
+ if (merr)
+ MTestPrintError(merr);
+ if (size > 3) {
+ merr = MPI_Comm_split(MPI_COMM_WORLD, rank < 2, rank, &mcomm);
+ if (merr)
+ MTestPrintError(merr);
+ if (rank == 0) {
+ rleader = 2;
+ }
+ else if (rank == 2) {
+ rleader = 0;
+ }
+ else {
+ /* Remote leader is signficant only for the processes
+ * designated local leaders */
+ rleader = -1;
+ }
+ *isLeftGroup = rank < 2;
+ merr = MPI_Intercomm_create(mcomm, 0, MPI_COMM_WORLD, rleader, 12347, comm);
+ if (merr)
+ MTestPrintError(merr);
+ interCommName = "Intercomm by splitting MPI_COMM_WORLD into 2, rest";
+ }
+ else
+ *comm = MPI_COMM_NULL;
+ break;
+
+ case 3:
+ /* Split comm world in half, then dup */
+ merr = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ if (merr)
+ MTestPrintError(merr);
+ merr = MPI_Comm_size(MPI_COMM_WORLD, &size);
+ if (merr)
+ MTestPrintError(merr);
+ if (size > 1) {
+ merr = MPI_Comm_split(MPI_COMM_WORLD, (rank < size / 2), rank, &mcomm);
+ if (merr)
+ MTestPrintError(merr);
+ if (rank == 0) {
+ rleader = size / 2;
+ }
+ else if (rank == size / 2) {
+ rleader = 0;
+ }
+ else {
+ /* Remote leader is signficant only for the processes
+ * designated local leaders */
+ rleader = -1;
+ }
+ *isLeftGroup = rank < size / 2;
+ merr = MPI_Intercomm_create(mcomm, 0, MPI_COMM_WORLD, rleader, 12345, comm);
+ if (merr)
+ MTestPrintError(merr);
/* avoid leaking after assignment below */
- merr = MPI_Comm_free( &mcomm );
- if (merr) MTestPrintError( merr );
-
- /* now dup, some bugs only occur for dup's of intercomms */
- mcomm = *comm;
- merr = MPI_Comm_dup(mcomm, comm);
- if (merr) MTestPrintError( merr );
- interCommName = "Intercomm by splitting MPI_COMM_WORLD then dup'ing";
- }
- else
- *comm = MPI_COMM_NULL;
- break;
-
- case 4:
- /* Split comm world in half, form intercomm, then split that intercomm */
- merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- if (merr) MTestPrintError( merr );
- merr = MPI_Comm_size( MPI_COMM_WORLD, &size );
- if (merr) MTestPrintError( merr );
- if (size > 1) {
- merr = MPI_Comm_split( MPI_COMM_WORLD, (rank < size/2), rank,
- &mcomm );
- if (merr) MTestPrintError( merr );
- if (rank == 0) {
- rleader = size/2;
- }
- else if (rank == size/2) {
- rleader = 0;
- }
- else {
- /* Remote leader is signficant only for the processes
- designated local leaders */
- rleader = -1;
- }
- *isLeftGroup = rank < size/2;
- merr = MPI_Intercomm_create( mcomm, 0, MPI_COMM_WORLD, rleader,
- 12345, comm );
- if (merr) MTestPrintError( merr );
+ merr = MPI_Comm_free(&mcomm);
+ if (merr)
+ MTestPrintError(merr);
+
+ /* now dup, some bugs only occur for dup's of intercomms */
+ mcomm = *comm;
+ merr = MPI_Comm_dup(mcomm, comm);
+ if (merr)
+ MTestPrintError(merr);
+ interCommName = "Intercomm by splitting MPI_COMM_WORLD then dup'ing";
+ }
+ else
+ *comm = MPI_COMM_NULL;
+ break;
+
+ case 4:
+ /* Split comm world in half, form intercomm, then split that intercomm */
+ merr = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ if (merr)
+ MTestPrintError(merr);
+ merr = MPI_Comm_size(MPI_COMM_WORLD, &size);
+ if (merr)
+ MTestPrintError(merr);
+ if (size > 1) {
+ merr = MPI_Comm_split(MPI_COMM_WORLD, (rank < size / 2), rank, &mcomm);
+ if (merr)
+ MTestPrintError(merr);
+ if (rank == 0) {
+ rleader = size / 2;
+ }
+ else if (rank == size / 2) {
+ rleader = 0;
+ }
+ else {
+ /* Remote leader is signficant only for the processes
+ * designated local leaders */
+ rleader = -1;
+ }
+ *isLeftGroup = rank < size / 2;
+ merr = MPI_Intercomm_create(mcomm, 0, MPI_COMM_WORLD, rleader, 12345, comm);
+ if (merr)
+ MTestPrintError(merr);
/* avoid leaking after assignment below */
- merr = MPI_Comm_free( &mcomm );
- if (merr) MTestPrintError( merr );
-
- /* now split, some bugs only occur for splits of intercomms */
- mcomm = *comm;
- merr = MPI_Comm_rank(mcomm, &rank);
- if (merr) MTestPrintError( merr );
- /* this split is effectively a dup but tests the split code paths */
- merr = MPI_Comm_split(mcomm, 0, rank, comm);
- if (merr) MTestPrintError( merr );
- interCommName = "Intercomm by splitting MPI_COMM_WORLD then then splitting again";
- }
- else
- *comm = MPI_COMM_NULL;
- break;
-
- case 5:
+ merr = MPI_Comm_free(&mcomm);
+ if (merr)
+ MTestPrintError(merr);
+
+ /* now split, some bugs only occur for splits of intercomms */
+ mcomm = *comm;
+ merr = MPI_Comm_rank(mcomm, &rank);
+ if (merr)
+ MTestPrintError(merr);
+ /* this split is effectively a dup but tests the split code paths */
+ merr = MPI_Comm_split(mcomm, 0, rank, comm);
+ if (merr)
+ MTestPrintError(merr);
+ interCommName = "Intercomm by splitting MPI_COMM_WORLD then then splitting again";
+ }
+ else
+ *comm = MPI_COMM_NULL;
+ break;
+
+ case 5:
/* split comm world in half discarding rank 0 on the "left"
* communicator, then form them into an intercommunicator */
- merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- if (merr) MTestPrintError( merr );
- merr = MPI_Comm_size( MPI_COMM_WORLD, &size );
- if (merr) MTestPrintError( merr );
- if (size >= 4) {
- int color = (rank < size/2 ? 0 : 1);
+ merr = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ if (merr)
+ MTestPrintError(merr);
+ merr = MPI_Comm_size(MPI_COMM_WORLD, &size);
+ if (merr)
+ MTestPrintError(merr);
+ if (size >= 4) {
+ int color = (rank < size / 2 ? 0 : 1);
if (rank == 0)
color = MPI_UNDEFINED;
- merr = MPI_Comm_split( MPI_COMM_WORLD, color, rank, &mcomm );
- if (merr) MTestPrintError( merr );
-
- if (rank == 1) {
- rleader = size/2;
- }
- else if (rank == (size/2)) {
- rleader = 1;
- }
- else {
- /* Remote leader is signficant only for the processes
- designated local leaders */
- rleader = -1;
- }
- *isLeftGroup = rank < size/2;
- if (rank != 0) { /* 0's mcomm is MPI_COMM_NULL */
- merr = MPI_Intercomm_create( mcomm, 0, MPI_COMM_WORLD, rleader, 12345, comm );
- if (merr) MTestPrintError( merr );
+ merr = MPI_Comm_split(MPI_COMM_WORLD, color, rank, &mcomm);
+ if (merr)
+ MTestPrintError(merr);
+
+ if (rank == 1) {
+ rleader = size / 2;
}
- interCommName = "Intercomm by splitting MPI_COMM_WORLD (discarding rank 0 in the left group) then MPI_Intercomm_create'ing";
+ else if (rank == (size / 2)) {
+ rleader = 1;
+ }
+ else {
+ /* Remote leader is signficant only for the processes
+ * designated local leaders */
+ rleader = -1;
+ }
+ *isLeftGroup = rank < size / 2;
+ if (rank != 0) { /* 0's mcomm is MPI_COMM_NULL */
+ merr = MPI_Intercomm_create(mcomm, 0, MPI_COMM_WORLD, rleader, 12345, comm);
+ if (merr)
+ MTestPrintError(merr);
+ }
+ interCommName =
+ "Intercomm by splitting MPI_COMM_WORLD (discarding rank 0 in the left group) then MPI_Intercomm_create'ing";
}
else {
*comm = MPI_COMM_NULL;
@@ -741,71 +791,84 @@ int MTestGetIntercomm( MPI_Comm *comm, int *isLeftGroup, int min_size )
/* Split comm world in half then form them into an
* intercommunicator. Then discard rank 0 from each group of the
* intercomm via MPI_Comm_create. */
- merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- if (merr) MTestPrintError( merr );
- merr = MPI_Comm_size( MPI_COMM_WORLD, &size );
- if (merr) MTestPrintError( merr );
- if (size >= 4) {
+ merr = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ if (merr)
+ MTestPrintError(merr);
+ merr = MPI_Comm_size(MPI_COMM_WORLD, &size);
+ if (merr)
+ MTestPrintError(merr);
+ if (size >= 4) {
MPI_Group oldgroup, newgroup;
int ranks[1];
- int color = (rank < size/2 ? 0 : 1);
-
- merr = MPI_Comm_split( MPI_COMM_WORLD, color, rank, &mcomm );
- if (merr) MTestPrintError( merr );
-
- if (rank == 0) {
- rleader = size/2;
- }
- else if (rank == (size/2)) {
- rleader = 0;
- }
- else {
- /* Remote leader is signficant only for the processes
- designated local leaders */
- rleader = -1;
- }
- *isLeftGroup = rank < size/2;
- merr = MPI_Intercomm_create( mcomm, 0, MPI_COMM_WORLD, rleader, 12345, &mcomm2 );
- if (merr) MTestPrintError( merr );
+ int color = (rank < size / 2 ? 0 : 1);
+
+ merr = MPI_Comm_split(MPI_COMM_WORLD, color, rank, &mcomm);
+ if (merr)
+ MTestPrintError(merr);
+
+ if (rank == 0) {
+ rleader = size / 2;
+ }
+ else if (rank == (size / 2)) {
+ rleader = 0;
+ }
+ else {
+ /* Remote leader is signficant only for the processes
+ * designated local leaders */
+ rleader = -1;
+ }
+ *isLeftGroup = rank < size / 2;
+ merr = MPI_Intercomm_create(mcomm, 0, MPI_COMM_WORLD, rleader, 12345, &mcomm2);
+ if (merr)
+ MTestPrintError(merr);
/* We have an intercomm between the two halves of comm world. Now create
* a new intercomm that removes rank 0 on each side. */
merr = MPI_Comm_group(mcomm2, &oldgroup);
- if (merr) MTestPrintError( merr );
+ if (merr)
+ MTestPrintError(merr);
ranks[0] = 0;
merr = MPI_Group_excl(oldgroup, 1, ranks, &newgroup);
- if (merr) MTestPrintError( merr );
+ if (merr)
+ MTestPrintError(merr);
merr = MPI_Comm_create(mcomm2, newgroup, comm);
- if (merr) MTestPrintError( merr );
+ if (merr)
+ MTestPrintError(merr);
merr = MPI_Group_free(&oldgroup);
- if (merr) MTestPrintError( merr );
+ if (merr)
+ MTestPrintError(merr);
merr = MPI_Group_free(&newgroup);
- if (merr) MTestPrintError( merr );
+ if (merr)
+ MTestPrintError(merr);
- interCommName = "Intercomm by splitting MPI_COMM_WORLD then discarding 0 ranks with MPI_Comm_create";
+ interCommName =
+ "Intercomm by splitting MPI_COMM_WORLD then discarding 0 ranks with MPI_Comm_create";
}
else {
*comm = MPI_COMM_NULL;
}
break;
- default:
- *comm = MPI_COMM_NULL;
- interCommIdx = -1;
- break;
- }
-
- if (*comm != MPI_COMM_NULL) {
- merr = MPI_Comm_size( *comm, &size );
- if (merr) MTestPrintError( merr );
- merr = MPI_Comm_remote_size( *comm, &remsize );
- if (merr) MTestPrintError( merr );
- if (size + remsize >= min_size) done = 1;
- }
- else {
- interCommName = "MPI_COMM_NULL";
- done = 1;
+ default:
+ *comm = MPI_COMM_NULL;
+ interCommIdx = -1;
+ break;
+ }
+
+ if (*comm != MPI_COMM_NULL) {
+ merr = MPI_Comm_size(*comm, &size);
+ if (merr)
+ MTestPrintError(merr);
+ merr = MPI_Comm_remote_size(*comm, &remsize);
+ if (merr)
+ MTestPrintError(merr);
+ if (size + remsize >= min_size)
+ done = 1;
+ }
+ else {
+ interCommName = "MPI_COMM_NULL";
+ done = 1;
}
/* we are only done if all processes are done */
@@ -819,17 +882,20 @@ int MTestGetIntercomm( MPI_Comm *comm, int *isLeftGroup, int min_size )
if (!done && *comm != MPI_COMM_NULL) {
/* avoid leaking communicators */
merr = MPI_Comm_free(comm);
- if (merr) MTestPrintError(merr);
+ if (merr)
+ MTestPrintError(merr);
}
/* cleanup for common temp objects */
if (mcomm != MPI_COMM_NULL) {
merr = MPI_Comm_free(&mcomm);
- if (merr) MTestPrintError( merr );
+ if (merr)
+ MTestPrintError(merr);
}
if (mcomm2 != MPI_COMM_NULL) {
merr = MPI_Comm_free(&mcomm2);
- if (merr) MTestPrintError( merr );
+ if (merr)
+ MTestPrintError(merr);
}
}
@@ -840,7 +906,7 @@ int MTestTestIntercomm(MPI_Comm comm)
{
int local_size, remote_size, rank, **bufs, *bufmem, rbuf[2], j;
int errs = 0, wrank, nsize;
- char commname[MPI_MAX_OBJECT_NAME+1];
+ char commname[MPI_MAX_OBJECT_NAME + 1];
MPI_Request *reqs;
MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
@@ -850,57 +916,57 @@ int MTestTestIntercomm(MPI_Comm comm)
MPI_Comm_get_name(comm, commname, &nsize);
MTestPrintfMsg(1, "Testing communication on intercomm '%s', remote_size=%d\n",
- commname, remote_size);
+ commname, remote_size);
- reqs = (MPI_Request *)malloc(remote_size * sizeof(MPI_Request));
+ reqs = (MPI_Request *) malloc(remote_size * sizeof(MPI_Request));
if (!reqs) {
printf("[%d] Unable to allocated %d requests for testing intercomm %s\n",
- wrank, remote_size, commname);
+ wrank, remote_size, commname);
errs++;
return errs;
}
bufs = (int **) malloc(remote_size * sizeof(int *));
if (!bufs) {
printf("[%d] Unable to allocated %d int pointers for testing intercomm %s\n",
- wrank, remote_size, commname);
+ wrank, remote_size, commname);
errs++;
return errs;
}
bufmem = (int *) malloc(remote_size * 2 * sizeof(int));
if (!bufmem) {
printf("[%d] Unable to allocated %d int data for testing intercomm %s\n",
- wrank, 2*remote_size, commname);
+ wrank, 2 * remote_size, commname);
errs++;
return errs;
}
/* Each process sends a message containing its own rank and the
- rank of the destination with a nonblocking send. Because we're using
- nonblocking sends, we need to use different buffers for each isend */
+ * rank of the destination with a nonblocking send. Because we're using
+ * nonblocking sends, we need to use different buffers for each isend */
/* NOTE: the send buffer access restriction was relaxed in MPI-2.2, although
- it doesn't really hurt to keep separate buffers for our purposes */
- for (j=0; j<remote_size; j++) {
- bufs[j] = &bufmem[2*j];
+ * it doesn't really hurt to keep separate buffers for our purposes */
+ for (j = 0; j < remote_size; j++) {
+ bufs[j] = &bufmem[2 * j];
bufs[j][0] = rank;
bufs[j][1] = j;
MPI_Isend(bufs[j], 2, MPI_INT, j, 0, comm, &reqs[j]);
}
MTestPrintfMsg(2, "isends posted, about to recv\n");
- for (j=0; j<remote_size; j++) {
+ for (j = 0; j < remote_size; j++) {
MPI_Recv(rbuf, 2, MPI_INT, j, 0, comm, MPI_STATUS_IGNORE);
if (rbuf[0] != j) {
- printf("[%d] Expected rank %d but saw %d in %s\n",
- wrank, j, rbuf[0], commname);
+ printf("[%d] Expected rank %d but saw %d in %s\n", wrank, j, rbuf[0], commname);
errs++;
}
if (rbuf[1] != rank) {
- printf( "[%d] Expected target rank %d but saw %d from %d in %s\n",
- wrank, rank, rbuf[1], j, commname );
+ printf("[%d] Expected target rank %d but saw %d from %d in %s\n",
+ wrank, rank, rbuf[1], j, commname);
errs++;
}
}
- if (errs) fflush(stdout);
+ if (errs)
+ fflush(stdout);
MTestPrintfMsg(2, "my recvs completed, about to waitall\n");
MPI_Waitall(remote_size, reqs, MPI_STATUSES_IGNORE);
@@ -921,16 +987,17 @@ int MTestTestIntracomm(MPI_Comm comm)
MPI_Comm_size(comm, &size);
/* Set input, output and sol-values */
- for(i = 0; i<16; i++) {
+ for (i = 0; i < 16; i++) {
in[i] = i;
out[i] = 0;
- sol[i] = i*size;
+ sol[i] = i * size;
}
MPI_Allreduce(in, out, 16, MPI_INT, MPI_SUM, comm);
/* Test results */
- for(i = 0; i<16; i++) {
- if(sol[i] != out[i]) errs++;
+ for (i = 0; i < 16; i++) {
+ if (sol[i] != out[i])
+ errs++;
}
return errs;
@@ -940,7 +1007,8 @@ int MTestTestComm(MPI_Comm comm)
{
int is_inter;
- if (comm == MPI_COMM_NULL) return 0;
+ if (comm == MPI_COMM_NULL)
+ return 0;
MPI_Comm_test_inter(comm, &is_inter);
@@ -951,30 +1019,30 @@ int MTestTestComm(MPI_Comm comm)
}
/* Return the name of an intercommunicator */
-const char *MTestGetIntercommName( void )
+const char *MTestGetIntercommName(void)
{
return interCommName;
}
-/* Get a communicator of a given minimum size. Both intra and inter
+/* Get a communicator of a given minimum size. Both intra and inter
communicators are provided */
-int MTestGetComm( MPI_Comm *comm, int min_size )
+int MTestGetComm(MPI_Comm * comm, int min_size)
{
- int idx=0;
+ int idx = 0;
static int getinter = 0;
if (!getinter) {
- idx = MTestGetIntracomm( comm, min_size );
- if (idx == 0) {
- getinter = 1;
- }
+ idx = MTestGetIntracomm(comm, min_size);
+ if (idx == 0) {
+ getinter = 1;
+ }
}
if (getinter) {
- int isLeft;
- idx = MTestGetIntercomm( comm, &isLeft, min_size );
- if (idx == 0) {
- getinter = 0;
- }
+ int isLeft;
+ idx = MTestGetIntercomm(comm, &isLeft, min_size);
+ if (idx == 0) {
+ getinter = 0;
+ }
}
return idx;
@@ -982,103 +1050,106 @@ int MTestGetComm( MPI_Comm *comm, int min_size )
/* Free a communicator. It may be called with a predefined communicator
or MPI_COMM_NULL */
-void MTestFreeComm( MPI_Comm *comm )
+void MTestFreeComm(MPI_Comm * comm)
{
int merr;
- if (*comm != MPI_COMM_WORLD &&
- *comm != MPI_COMM_SELF &&
- *comm != MPI_COMM_NULL) {
- merr = MPI_Comm_free( comm );
- if (merr) MTestPrintError( merr );
+ if (*comm != MPI_COMM_WORLD && *comm != MPI_COMM_SELF && *comm != MPI_COMM_NULL) {
+ merr = MPI_Comm_free(comm);
+ if (merr)
+ MTestPrintError(merr);
}
}
/* ------------------------------------------------------------------------ */
-void MTestPrintError( int errcode )
+void MTestPrintError(int errcode)
{
int errclass, slen;
char string[MPI_MAX_ERROR_STRING];
-
- MPI_Error_class( errcode, &errclass );
- MPI_Error_string( errcode, string, &slen );
- printf( "Error class %d (%s)\n", errclass, string );
- fflush( stdout );
+
+ MPI_Error_class(errcode, &errclass);
+ MPI_Error_string(errcode, string, &slen);
+ printf("Error class %d (%s)\n", errclass, string);
+ fflush(stdout);
}
-void MTestPrintErrorMsg( const char msg[], int errcode )
+
+void MTestPrintErrorMsg(const char msg[], int errcode)
{
int errclass, slen;
char string[MPI_MAX_ERROR_STRING];
-
- MPI_Error_class( errcode, &errclass );
- MPI_Error_string( errcode, string, &slen );
- printf( "%s: Error class %d (%s)\n", msg, errclass, string );
- fflush( stdout );
+
+ MPI_Error_class(errcode, &errclass);
+ MPI_Error_string(errcode, string, &slen);
+ printf("%s: Error class %d (%s)\n", msg, errclass, string);
+ fflush(stdout);
}
+
/* ------------------------------------------------------------------------ */
-/*
+/*
If verbose output is selected and the level is at least that of the
- value of the verbose flag, then perform printf( format, ... );
+ value of the verbose flag, then perform printf(format, ...);
*/
-void MTestPrintfMsg( int level, const char format[], ... )
+void MTestPrintfMsg(int level, const char format[], ...)
{
va_list list;
int n;
if (verbose && level >= verbose) {
- va_start(list,format);
- n = vprintf( format, list );
- va_end(list);
- fflush(stdout);
+ va_start(list, format);
+ n = vprintf(format, list);
+ va_end(list);
+ fflush(stdout);
}
}
+
/* Fatal error. Report and exit */
-void MTestError( const char *msg )
+void MTestError(const char *msg)
{
- fprintf( stderr, "%s\n", msg );
- fflush( stderr );
- MPI_Abort( MPI_COMM_WORLD, 1 );
+ fprintf(stderr, "%s\n", msg);
+ fflush(stderr);
+ MPI_Abort(MPI_COMM_WORLD, 1);
}
+
/* ------------------------------------------------------------------------ */
-static void MTestResourceSummary( FILE *fp )
+static void MTestResourceSummary(FILE * fp)
{
#ifdef HAVE_GETRUSAGE
struct rusage ru;
static int pfThreshold = -2;
int doOutput = 1;
- if (getrusage( RUSAGE_SELF, &ru ) == 0) {
- /* There is an option to generate output only when a resource
- exceeds a threshold. To date, only page faults supported. */
- if (pfThreshold == -2) {
- char *p = getenv("MPITEST_RUSAGE_PF");
- pfThreshold = -1;
- if (p) {
- pfThreshold = strtol( p, 0, 0 );
- }
- }
- if (pfThreshold > 0) {
- doOutput = ru.ru_minflt > pfThreshold;
- }
- if (doOutput) {
- /* Cast values to long in case some system has defined them
- as another integer type */
- fprintf( fp, "RUSAGE: max resident set = %ldKB\n",
- (long)ru.ru_maxrss );
- fprintf( fp, "RUSAGE: page faults = %ld : %ld\n",
- (long)ru.ru_minflt, (long)ru.ru_majflt );
- /* Not every Unix provides useful information for the xxrss fields */
- fprintf( fp, "RUSAGE: memory in text/data/stack = %ld : %ld : %ld\n",
- (long)ru.ru_ixrss, (long)ru.ru_idrss, (long)ru.ru_isrss );
- fprintf( fp, "RUSAGE: I/O in and out = %ld : %ld\n",
- (long)ru.ru_inblock, (long)ru.ru_oublock );
- fprintf( fp, "RUSAGE: context switch = %ld : %ld\n",
- (long)ru.ru_nvcsw, (long)ru.ru_nivcsw );
- }
+ if (getrusage(RUSAGE_SELF, &ru) == 0) {
+ /* There is an option to generate output only when a resource
+ * exceeds a threshold. To date, only page faults supported. */
+ if (pfThreshold == -2) {
+ char *p = getenv("MPITEST_RUSAGE_PF");
+ pfThreshold = -1;
+ if (p) {
+ pfThreshold = strtol(p, 0, 0);
+ }
+ }
+ if (pfThreshold > 0) {
+ doOutput = ru.ru_minflt > pfThreshold;
+ }
+ if (doOutput) {
+ /* Cast values to long in case some system has defined them
+ * as another integer type */
+ fprintf(fp, "RUSAGE: max resident set = %ldKB\n", (long) ru.ru_maxrss);
+ fprintf(fp, "RUSAGE: page faults = %ld : %ld\n",
+ (long) ru.ru_minflt, (long) ru.ru_majflt);
+ /* Not every Unix provides useful information for the xxrss fields */
+ fprintf(fp, "RUSAGE: memory in text/data/stack = %ld : %ld : %ld\n",
+ (long) ru.ru_ixrss, (long) ru.ru_idrss, (long) ru.ru_isrss);
+ fprintf(fp, "RUSAGE: I/O in and out = %ld : %ld\n",
+ (long) ru.ru_inblock, (long) ru.ru_oublock);
+ fprintf(fp, "RUSAGE: context switch = %ld : %ld\n",
+ (long) ru.ru_nvcsw, (long) ru.ru_nivcsw);
+ }
}
else {
- fprintf( fp, "RUSAGE: return error %d\n", errno );
+ fprintf(fp, "RUSAGE: return error %d\n", errno);
}
#endif
}
+
/* ------------------------------------------------------------------------ */
#ifdef HAVE_MPI_WIN_CREATE
/*
@@ -1089,129 +1160,148 @@ static const char *winName;
/* Use an attribute to remember the type of memory allocation (static,
malloc, or MPI_Alloc_mem) */
static int mem_keyval = MPI_KEYVAL_INVALID;
-int MTestGetWin( MPI_Win *win, int mustBePassive )
+int MTestGetWin(MPI_Win * win, int mustBePassive)
{
static char actbuf[1024];
static char *pasbuf;
- char *buf;
- int n, rank, merr;
- MPI_Info info;
+ char *buf;
+ int n, rank, merr;
+ MPI_Info info;
if (mem_keyval == MPI_KEYVAL_INVALID) {
- /* Create the keyval */
- merr = MPI_Win_create_keyval( MPI_WIN_NULL_COPY_FN,
- MPI_WIN_NULL_DELETE_FN,
- &mem_keyval, 0 );
- if (merr) MTestPrintError( merr );
+ /* Create the keyval */
+ merr = MPI_Win_create_keyval(MPI_WIN_NULL_COPY_FN, MPI_WIN_NULL_DELETE_FN, &mem_keyval, 0);
+ if (merr)
+ MTestPrintError(merr);
}
switch (win_index) {
case 0:
- /* Active target window */
- merr = MPI_Win_create( actbuf, 1024, 1, MPI_INFO_NULL, MPI_COMM_WORLD,
- win );
- if (merr) MTestPrintError( merr );
- winName = "active-window";
- merr = MPI_Win_set_attr( *win, mem_keyval, (void *)0 );
- if (merr) MTestPrintError( merr );
- break;
+ /* Active target window */
+ merr = MPI_Win_create(actbuf, 1024, 1, MPI_INFO_NULL, MPI_COMM_WORLD, win);
+ if (merr)
+ MTestPrintError(merr);
+ winName = "active-window";
+ merr = MPI_Win_set_attr(*win, mem_keyval, (void *) 0);
+ if (merr)
+ MTestPrintError(merr);
+ break;
case 1:
- /* Passive target window */
- merr = MPI_Alloc_mem( 1024, MPI_INFO_NULL, &pasbuf );
- if (merr) MTestPrintError( merr );
- merr = MPI_Win_create( pasbuf, 1024, 1, MPI_INFO_NULL, MPI_COMM_WORLD,
- win );
- if (merr) MTestPrintError( merr );
- winName = "passive-window";
- merr = MPI_Win_set_attr( *win, mem_keyval, (void *)2 );
- if (merr) MTestPrintError( merr );
- break;
+ /* Passive target window */
+ merr = MPI_Alloc_mem(1024, MPI_INFO_NULL, &pasbuf);
+ if (merr)
+ MTestPrintError(merr);
+ merr = MPI_Win_create(pasbuf, 1024, 1, MPI_INFO_NULL, MPI_COMM_WORLD, win);
+ if (merr)
+ MTestPrintError(merr);
+ winName = "passive-window";
+ merr = MPI_Win_set_attr(*win, mem_keyval, (void *) 2);
+ if (merr)
+ MTestPrintError(merr);
+ break;
case 2:
- /* Active target; all windows different sizes */
- merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- if (merr) MTestPrintError( merr );
- n = rank * 64;
- if (n)
- buf = (char *)malloc( n );
- else
- buf = 0;
- merr = MPI_Win_create( buf, n, 1, MPI_INFO_NULL, MPI_COMM_WORLD,
- win );
- if (merr) MTestPrintError( merr );
- winName = "active-all-different-win";
- merr = MPI_Win_set_attr( *win, mem_keyval, (void *)1 );
- if (merr) MTestPrintError( merr );
- break;
+ /* Active target; all windows different sizes */
+ merr = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ if (merr)
+ MTestPrintError(merr);
+ n = rank * 64;
+ if (n)
+ buf = (char *) malloc(n);
+ else
+ buf = 0;
+ merr = MPI_Win_create(buf, n, 1, MPI_INFO_NULL, MPI_COMM_WORLD, win);
+ if (merr)
+ MTestPrintError(merr);
+ winName = "active-all-different-win";
+ merr = MPI_Win_set_attr(*win, mem_keyval, (void *) 1);
+ if (merr)
+ MTestPrintError(merr);
+ break;
case 3:
- /* Active target, no locks set */
- merr = MPI_Comm_rank( MPI_COMM_WORLD, &rank );
- if (merr) MTestPrintError( merr );
- n = rank * 64;
- if (n)
- buf = (char *)malloc( n );
- else
- buf = 0;
- merr = MPI_Info_create( &info );
- if (merr) MTestPrintError( merr );
- merr = MPI_Info_set( info, (char*)"nolocks", (char*)"true" );
- if (merr) MTestPrintError( merr );
- merr = MPI_Win_create( buf, n, 1, info, MPI_COMM_WORLD, win );
- if (merr) MTestPrintError( merr );
- merr = MPI_Info_free( &info );
- if (merr) MTestPrintError( merr );
- winName = "active-nolocks-all-different-win";
- merr = MPI_Win_set_attr( *win, mem_keyval, (void *)1 );
- if (merr) MTestPrintError( merr );
- break;
+ /* Active target, no locks set */
+ merr = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ if (merr)
+ MTestPrintError(merr);
+ n = rank * 64;
+ if (n)
+ buf = (char *) malloc(n);
+ else
+ buf = 0;
+ merr = MPI_Info_create(&info);
+ if (merr)
+ MTestPrintError(merr);
+ merr = MPI_Info_set(info, (char *) "nolocks", (char *) "true");
+ if (merr)
+ MTestPrintError(merr);
+ merr = MPI_Win_create(buf, n, 1, info, MPI_COMM_WORLD, win);
+ if (merr)
+ MTestPrintError(merr);
+ merr = MPI_Info_free(&info);
+ if (merr)
+ MTestPrintError(merr);
+ winName = "active-nolocks-all-different-win";
+ merr = MPI_Win_set_attr(*win, mem_keyval, (void *) 1);
+ if (merr)
+ MTestPrintError(merr);
+ break;
default:
- win_index = -1;
+ win_index = -1;
}
win_index++;
return win_index;
}
+
/* Return a pointer to the name associated with a window object */
-const char *MTestGetWinName( void )
+const char *MTestGetWinName(void)
{
return winName;
}
+
/* Free the storage associated with a window object */
-void MTestFreeWin( MPI_Win *win )
+void MTestFreeWin(MPI_Win * win)
{
void *addr;
- int flag, merr;
+ int flag, merr;
- merr = MPI_Win_get_attr( *win, MPI_WIN_BASE, &addr, &flag );
- if (merr) MTestPrintError( merr );
+ merr = MPI_Win_get_attr(*win, MPI_WIN_BASE, &addr, &flag);
+ if (merr)
+ MTestPrintError(merr);
if (!flag) {
- MTestError( "Could not get WIN_BASE from window" );
+ MTestError("Could not get WIN_BASE from window");
}
if (addr) {
- void *val;
- merr = MPI_Win_get_attr( *win, mem_keyval, &val, &flag );
- if (merr) MTestPrintError( merr );
- if (flag) {
- if (val == (void *)1) {
- free( addr );
- }
- else if (val == (void *)2) {
- merr = MPI_Free_mem( addr );
- if (merr) MTestPrintError( merr );
- }
- /* if val == (void *)0, then static data that must not be freed */
- }
+ void *val;
+ merr = MPI_Win_get_attr(*win, mem_keyval, &val, &flag);
+ if (merr)
+ MTestPrintError(merr);
+ if (flag) {
+ if (val == (void *) 1) {
+ free(addr);
+ }
+ else if (val == (void *) 2) {
+ merr = MPI_Free_mem(addr);
+ if (merr)
+ MTestPrintError(merr);
+ }
+ /* if val == (void *)0, then static data that must not be freed */
+ }
}
merr = MPI_Win_free(win);
- if (merr) MTestPrintError( merr );
+ if (merr)
+ MTestPrintError(merr);
}
-static void MTestRMACleanup( void )
+
+static void MTestRMACleanup(void)
{
if (mem_keyval != MPI_KEYVAL_INVALID) {
- MPI_Win_free_keyval( &mem_keyval );
+ MPI_Win_free_keyval(&mem_keyval);
}
}
-#else
-static void MTestRMACleanup( void ) {}
+#else
+static void MTestRMACleanup(void)
+{
+}
#endif
/* ------------------------------------------------------------------------ */
@@ -1225,17 +1315,17 @@ static void MTestRMACleanup( void ) {}
* due to errors in the necessary query functions
*
*/
-int MTestSpawnPossible(int * can_spawn)
+int MTestSpawnPossible(int *can_spawn)
{
- int errs = 0;
+ int errs = 0;
- void * v = NULL;
- int flag = -1;
- int vval = -1;
+ void *v = NULL;
+ int flag = -1;
+ int vval = -1;
int rc;
- rc = MPI_Comm_get_attr( MPI_COMM_WORLD, MPI_UNIVERSE_SIZE, &v, &flag );
- if (rc!=MPI_SUCCESS) {
+ rc = MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_UNIVERSE_SIZE, &v, &flag);
+ if (rc != MPI_SUCCESS) {
/* MPI_UNIVERSE_SIZE keyval missing from MPI_COMM_WORLD attributes */
*can_spawn = -1;
errs++;
@@ -1246,13 +1336,13 @@ int MTestSpawnPossible(int * can_spawn)
int size = -1;
rc = MPI_Comm_size(MPI_COMM_WORLD, &size);
- if (rc!=MPI_SUCCESS) {
+ if (rc != MPI_SUCCESS) {
/* MPI_Comm_size failed for MPI_COMM_WORLD */
*can_spawn = -1;
errs++;
}
- vval = *(int *)v;
+ vval = *(int *) v;
if (vval <= size) {
/* no additional processes can be spawned */
*can_spawn = 0;
@@ -1268,4 +1358,5 @@ int MTestSpawnPossible(int * can_spawn)
}
return errs;
}
+
/* ------------------------------------------------------------------------ */
diff --git a/test/mpi/util/mtestcheck.c b/test/mpi/util/mtestcheck.c
index dde7336..9e0d1c2 100644
--- a/test/mpi/util/mtestcheck.c
+++ b/test/mpi/util/mtestcheck.c
@@ -8,35 +8,36 @@
#include <stdlib.h>
#include "mpitest.h"
-int main( int argc, char *argv[] )
+int main(int argc, char *argv[])
{
int errs = 0;
MPI_Comm comm;
int minsize = 2, csize, count;
- MTest_Init( &argc, &argv );
+ MTest_Init(&argc, &argv);
- while (MTestGetIntracommGeneral( &comm, minsize, 1 )) {
- if (comm == MPI_COMM_NULL) continue;
+ while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
+ if (comm == MPI_COMM_NULL)
+ continue;
- MPI_Comm_size( comm, &csize );
- count = 128000;
- {
- int *ap, *bp;
- int root;
- ap = (int *)malloc( count * sizeof(int) );
- bp = (int *)malloc( count * sizeof(int) );
- root=0;
- MPI_Reduce( ap, bp, count, MPI_INT, MPI_SUM, root, comm );
- free( ap );
- free( bp );
- }
- MTestFreeComm( &comm );
+ MPI_Comm_size(comm, &csize);
+ count = 128000;
+ {
+ int *ap, *bp;
+ int root;
+ ap = (int *) malloc(count * sizeof(int));
+ bp = (int *) malloc(count * sizeof(int));
+ root = 0;
+ MPI_Reduce(ap, bp, count, MPI_INT, MPI_SUM, root, comm);
+ free(ap);
+ free(bp);
+ }
+ MTestFreeComm(&comm);
}
- MTest_Finalize( errs );
+ MTest_Finalize(errs);
- MPI_Finalize();
+ MPI_Finalize();
- return 0;
+ return 0;
}
-----------------------------------------------------------------------
Summary of changes:
test/mpi/attr/attr2type.c | 76 +-
test/mpi/attr/attrdeleteget.c | 15 +-
test/mpi/attr/attrend.c | 63 +-
test/mpi/attr/attrend2.c | 16 +-
test/mpi/attr/attrerr.c | 98 +-
test/mpi/attr/attrerrcomm.c | 111 +-
test/mpi/attr/attrerrtype.c | 108 +-
test/mpi/attr/attric.c | 160 +-
test/mpi/attr/attrorder.c | 151 +-
test/mpi/attr/attrordercomm.c | 151 +-
test/mpi/attr/attrordertype.c | 151 +-
test/mpi/attr/attrt.c | 362 ++--
test/mpi/attr/baseattr2.c | 230 +-
test/mpi/attr/baseattrcomm.c | 140 +-
test/mpi/attr/fkeyval.c | 127 +-
test/mpi/attr/fkeyvalcomm.c | 129 +-
test/mpi/attr/fkeyvaltype.c | 137 +-
test/mpi/attr/keyval_double_free.c | 21 +-
test/mpi/basic/GetOpt.c | 153 +-
test/mpi/basic/GetOpt.h | 10 +-
test/mpi/basic/adapt.c | 2544 ++++++++++----------
test/mpi/basic/netmpi.c | 916 ++++----
test/mpi/basic/patterns.c | 563 ++---
test/mpi/basic/self.c | 6 +-
test/mpi/basic/sendrecv.c | 114 +-
test/mpi/basic/srtest.c | 50 +-
test/mpi/basic/wtime.c | 20 +-
test/mpi/ckpoint/write_ckpoint.c | 22 +-
test/mpi/coll/allgather2.c | 51 +-
test/mpi/coll/allgather3.c | 53 +-
test/mpi/coll/allgatherv2.c | 64 +-
test/mpi/coll/allgatherv3.c | 69 +-
test/mpi/coll/allgatherv4.c | 52 +-
test/mpi/coll/allred.c | 69 +-
test/mpi/coll/allred2.c | 59 +-
test/mpi/coll/allred3.c | 281 ++--
test/mpi/coll/allred4.c | 301 ++--
test/mpi/coll/allred5.c | 70 +-
test/mpi/coll/allred6.c | 88 +-
test/mpi/coll/allredmany.c | 32 +-
test/mpi/coll/alltoall1.c | 141 +-
test/mpi/coll/alltoallv.c | 195 +-
test/mpi/coll/alltoallv0.c | 208 +-
test/mpi/coll/alltoallw1.c | 374 ++--
test/mpi/coll/alltoallw2.c | 216 +-
test/mpi/coll/alltoallw_zeros.c | 50 +-
test/mpi/coll/bcasttest.c | 118 +-
test/mpi/coll/bcastzerotype.c | 2 +-
test/mpi/coll/coll10.c | 64 +-
test/mpi/coll/coll11.c | 118 +-
test/mpi/coll/coll12.c | 105 +-
test/mpi/coll/coll13.c | 67 +-
test/mpi/coll/coll2.c | 86 +-
test/mpi/coll/coll3.c | 131 +-
test/mpi/coll/coll4.c | 78 +-
test/mpi/coll/coll5.c | 79 +-
test/mpi/coll/coll6.c | 132 +-
test/mpi/coll/coll7.c | 87 +-
test/mpi/coll/coll8.c | 47 +-
test/mpi/coll/coll9.c | 49 +-
test/mpi/coll/exscan.c | 97 +-
test/mpi/coll/exscan2.c | 45 +-
test/mpi/coll/gather.c | 96 +-
test/mpi/coll/gather2.c | 121 +-
test/mpi/coll/gather_big.c | 24 +-
test/mpi/coll/iallred.c | 9 +-
test/mpi/coll/ibarrier.c | 14 +-
test/mpi/coll/icallgather.c | 150 +-
test/mpi/coll/icallgatherv.c | 173 +-
test/mpi/coll/icallreduce.c | 109 +-
test/mpi/coll/icalltoall.c | 107 +-
test/mpi/coll/icalltoallv.c | 125 +-
test/mpi/coll/icalltoallw.c | 143 +-
test/mpi/coll/icbarrier.c | 48 +-
test/mpi/coll/icbcast.c | 106 +-
test/mpi/coll/icgather.c | 111 +-
test/mpi/coll/icgatherv.c | 133 +-
test/mpi/coll/icreduce.c | 123 +-
test/mpi/coll/icscatter.c | 129 +-
test/mpi/coll/icscatterv.c | 145 +-
test/mpi/coll/longuser.c | 96 +-
test/mpi/coll/nonblocking.c | 63 +-
test/mpi/coll/nonblocking2.c | 149 +-
test/mpi/coll/nonblocking3.c | 1000 ++++----
test/mpi/coll/op_commutative.c | 13 +-
test/mpi/coll/opband.c | 412 ++--
test/mpi/coll/opbor.c | 448 ++--
test/mpi/coll/opbxor.c | 448 ++--
test/mpi/coll/opland.c | 332 ++--
test/mpi/coll/oplor.c | 335 ++--
test/mpi/coll/oplxor.c | 331 ++--
test/mpi/coll/opmax.c | 207 +-
test/mpi/coll/opmaxloc.c | 491 ++--
test/mpi/coll/opmin.c | 207 +-
test/mpi/coll/opminloc.c | 405 ++--
test/mpi/coll/opprod.c | 427 ++--
test/mpi/coll/opsum.c | 354 ++--
test/mpi/coll/red3.c | 255 +-
test/mpi/coll/red4.c | 293 ++--
test/mpi/coll/red_scat_block.c | 8 +-
test/mpi/coll/red_scat_block2.c | 74 +-
test/mpi/coll/redscat.c | 46 +-
test/mpi/coll/redscat2.c | 76 +-
test/mpi/coll/redscat3.c | 95 +-
test/mpi/coll/redscatbkinter.c | 138 +-
test/mpi/coll/redscatblk3.c | 74 +-
test/mpi/coll/redscatinter.c | 159 +-
test/mpi/coll/reduce.c | 64 +-
test/mpi/coll/reduce_local.c | 29 +-
test/mpi/coll/scantst.c | 112 +-
test/mpi/coll/scatter2.c | 85 +-
test/mpi/coll/scatter3.c | 107 +-
test/mpi/coll/scattern.c | 67 +-
test/mpi/coll/scatterv.c | 143 +-
test/mpi/coll/uoplong.c | 135 +-
test/mpi/comm/cmfree.c | 145 +-
test/mpi/comm/cmsplit.c | 45 +-
test/mpi/comm/cmsplit2.c | 10 +-
test/mpi/comm/cmsplit_type.c | 10 +-
test/mpi/comm/comm_group_rand.c | 4 +-
test/mpi/comm/comm_idup.c | 5 +-
test/mpi/comm/comm_idup_comm.c | 38 +-
test/mpi/comm/comm_idup_iallreduce.c | 184 +-
test/mpi/comm/comm_idup_isend.c | 76 +-
test/mpi/comm/comm_idup_nb.c | 188 +-
test/mpi/comm/commcreate1.c | 158 +-
test/mpi/comm/commname.c | 54 +-
test/mpi/comm/ctxalloc.c | 64 +-
test/mpi/comm/ctxsplit.c | 115 +-
test/mpi/comm/dup.c | 88 +-
test/mpi/comm/dupic.c | 138 +-
test/mpi/comm/ic1.c | 48 +-
test/mpi/comm/ic2.c | 4 +-
test/mpi/comm/iccreate.c | 175 +-
test/mpi/comm/icgroup.c | 59 +-
test/mpi/comm/icm.c | 147 +-
test/mpi/comm/icsplit.c | 163 +-
test/mpi/comm/probe-intercomm.c | 30 +-
test/mpi/datatype/blockindexed-misc.c | 334 ++--
test/mpi/datatype/blockindexed-zero-count.c | 100 +-
test/mpi/datatype/contents.c | 929 ++++----
test/mpi/datatype/contig-zero-count.c | 98 +-
test/mpi/datatype/contigstruct.c | 42 +-
test/mpi/datatype/darray-cyclic.c | 294 ++--
test/mpi/datatype/darray-pack.c | 404 ++--
test/mpi/datatype/dataalign.c | 161 +-
test/mpi/datatype/gaddress.c | 20 +-
test/mpi/datatype/get-elements-pairtype.c | 57 +-
test/mpi/datatype/get-elements.c | 17 +-
test/mpi/datatype/getpartelm.c | 175 +-
test/mpi/datatype/hindexed-zeros.c | 200 +-
test/mpi/datatype/hindexed_block.c | 25 +-
test/mpi/datatype/hindexed_block_contents.c | 8 +-
test/mpi/datatype/hvecblklen.c | 72 +-
test/mpi/datatype/indexed-misc.c | 421 ++--
test/mpi/datatype/large-count.c | 46 +-
test/mpi/datatype/large_type.c | 102 +-
test/mpi/datatype/large_type_sendrec.c | 95 +-
test/mpi/datatype/lbub.c | 1274 ++++++----
test/mpi/datatype/localpack.c | 67 +-
test/mpi/datatype/longdouble.c | 1 -
test/mpi/datatype/lots-of-types.c | 220 +-
test/mpi/datatype/pairtype-pack.c | 174 +-
test/mpi/datatype/pairtype-size-extent.c | 168 +-
test/mpi/datatype/segtest.c | 218 +-
test/mpi/datatype/sendrecvt2.c | 142 +-
test/mpi/datatype/sendrecvt4.c | 229 +-
test/mpi/datatype/simple-commit.c | 48 +-
test/mpi/datatype/simple-pack-external.c | 334 ++--
test/mpi/datatype/simple-pack.c | 250 +--
test/mpi/datatype/simple-resized.c | 115 +-
test/mpi/datatype/simple-size-extent.c | 171 +-
test/mpi/datatype/sizedtypes.c | 88 +-
test/mpi/datatype/slice-pack-external.c | 95 +-
test/mpi/datatype/slice-pack.c | 100 +-
test/mpi/datatype/struct-derived-zeros.c | 32 +-
test/mpi/datatype/struct-empty-el.c | 171 +-
test/mpi/datatype/struct-ezhov.c | 41 +-
test/mpi/datatype/struct-no-real-types.c | 112 +-
test/mpi/datatype/struct-pack.c | 380 ++--
test/mpi/datatype/struct-verydeep.c | 125 +-
test/mpi/datatype/struct-zero-count.c | 99 +-
test/mpi/datatype/structpack2.c | 163 +-
test/mpi/datatype/subarray-pack.c | 842 +++----
test/mpi/datatype/subarray.c | 8 +-
test/mpi/datatype/tfree.c | 123 +-
test/mpi/datatype/tmatchsize.c | 206 +-
test/mpi/datatype/transpose-pack.c | 90 +-
test/mpi/datatype/tresized.c | 95 +-
test/mpi/datatype/tresized2.c | 99 +-
test/mpi/datatype/triangular-pack.c | 91 +-
test/mpi/datatype/typecommit.c | 22 +-
test/mpi/datatype/typefree.c | 10 +-
test/mpi/datatype/typelb.c | 53 +-
test/mpi/datatype/typename.c | 242 +-
test/mpi/datatype/unpack.c | 57 +-
test/mpi/datatype/unusual-noncontigs.c | 378 ++--
test/mpi/datatype/vecblklen.c | 72 +-
test/mpi/datatype/zero-blklen-vector.c | 49 +-
test/mpi/datatype/zeroblks.c | 46 +-
test/mpi/datatype/zeroparms.c | 26 +-
test/mpi/errhan/adderr.c | 63 +-
test/mpi/errhan/commcall.c | 63 +-
.../errhan/dynamic_errcode_predefined_errclass.c | 8 +-
test/mpi/errhan/errfatal.c | 65 +-
test/mpi/errhan/errmsg.c | 12 +-
test/mpi/errhan/errring.c | 21 +-
test/mpi/errhan/errstring.c | 12 +-
test/mpi/errhan/errstring2.c | 10 +-
test/mpi/errhan/predef_eh.c | 15 +-
test/mpi/errors/attr/keyvalmis.c | 173 +-
test/mpi/errors/basic/debabort.c | 18 +-
test/mpi/errors/basic/lefthandles.c | 30 +-
test/mpi/errors/coll/bcastlength.c | 84 +-
test/mpi/errors/coll/noalias.c | 61 +-
test/mpi/errors/coll/noalias2.c | 90 +-
test/mpi/errors/coll/noalias3.c | 89 +-
test/mpi/errors/coll/reduce_local.c | 10 +-
test/mpi/errors/coll/rerr.c | 38 +-
test/mpi/errors/comm/ccreate1.c | 185 +-
test/mpi/errors/comm/cfree.c | 30 +-
test/mpi/errors/comm/manysplit.c | 62 +-
test/mpi/errors/comm/too_many_comms.c | 15 +-
test/mpi/errors/comm/too_many_comms2.c | 19 +-
test/mpi/errors/comm/too_many_comms3.c | 22 +-
test/mpi/errors/comm/userdup.c | 159 +-
test/mpi/errors/datatype/getcnterr.c | 47 +-
test/mpi/errors/f77/io/addsize.h.in | 10 +-
test/mpi/errors/f77/io/iooffset.h.in | 10 +-
test/mpi/errors/faults/collf1.c | 34 +-
test/mpi/errors/faults/collf2.c | 53 +-
test/mpi/errors/faults/pt2ptf1.c | 36 +-
test/mpi/errors/faults/pt2ptf2.c | 103 +-
test/mpi/errors/group/gerr.c | 30 +-
test/mpi/errors/io/file_errhdl.c | 32 +-
test/mpi/errors/io/fileerrret.c | 39 +-
test/mpi/errors/io/openerr.c | 199 +-
test/mpi/errors/pt2pt/errinstatta.c | 127 +-
test/mpi/errors/pt2pt/errinstatts.c | 136 +-
test/mpi/errors/pt2pt/errinstatwa.c | 129 +-
test/mpi/errors/pt2pt/errinstatws.c | 133 +-
test/mpi/errors/pt2pt/proberank.c | 26 +-
test/mpi/errors/pt2pt/truncmsg1.c | 155 +-
test/mpi/errors/pt2pt/truncmsg2.c | 65 +-
test/mpi/errors/rma/cas_type_check.c | 71 +-
test/mpi/errors/rma/win_sync.h | 4 +-
test/mpi/errors/rma/win_sync_complete.c | 14 +-
test/mpi/errors/rma/win_sync_free_at.c | 18 +-
test/mpi/errors/rma/win_sync_free_pt.c | 14 +-
test/mpi/errors/rma/win_sync_lock_at.c | 18 +-
test/mpi/errors/rma/win_sync_lock_fence.c | 14 +-
test/mpi/errors/rma/win_sync_lock_pt.c | 14 +-
test/mpi/errors/rma/win_sync_nested.c | 18 +-
test/mpi/errors/rma/win_sync_op.c | 14 +-
test/mpi/errors/rma/win_sync_unlock.c | 14 +-
test/mpi/errors/rma/winerr.c | 62 +-
test/mpi/errors/rma/winerr2.c | 117 +-
test/mpi/errors/spawn/badport.c | 41 +-
test/mpi/errors/spawn/lookup_name.c | 18 +-
test/mpi/errors/spawn/unpub.c | 20 +-
test/mpi/errors/topo/cartsmall.c | 40 +-
test/mpi/f08/attr/attrlangc.c | 568 +++---
test/mpi/f08/attr/fandcattrc.c | 82 +-
test/mpi/f08/ext/c2f90mult.c | 52 +-
test/mpi/f08/io/c2f902cio.c | 44 +-
test/mpi/f08/io/c2f90multio.c | 48 +-
test/mpi/f08/rma/c2f902cwin.c | 29 +-
test/mpi/f77/attr/attraints.h.in | 10 +-
test/mpi/f77/datatype/bottomc.c | 18 +-
test/mpi/f77/datatype/typeaints.h.in | 10 +-
test/mpi/f77/ext/add1size.h.in | 10 +-
test/mpi/f77/ext/c2f2c.c | 182 +-
test/mpi/f77/ext/c2fmult.c | 52 +-
test/mpi/f77/ext/ctypesfromc.c | 93 +-
test/mpi/f77/io/c2f2cio.c | 44 +-
test/mpi/f77/io/c2fmultio.c | 56 +-
test/mpi/f77/io/ioaint.h.in | 10 +-
test/mpi/f77/io/iodisp.h.in | 10 +-
test/mpi/f77/io/iooffset.h.in | 10 +-
test/mpi/f77/pt2pt/attr1aints.h.in | 10 +-
test/mpi/f77/rma/addsize.h.in | 10 +-
test/mpi/f77/rma/c2f2cwin.c | 41 +-
test/mpi/f77/spawn/type1aint.h.in | 10 +-
test/mpi/f90/attr/attrlangc.c | 598 +++---
test/mpi/f90/attr/fandcattrc.c | 88 +-
test/mpi/f90/f90types/createf90types.c | 170 +-
test/mpi/ft/abort.c | 3 +-
test/mpi/ft/agree.c | 21 +-
test/mpi/ft/agree_shrink.c | 3 +-
test/mpi/ft/anysource.c | 7 +-
test/mpi/ft/barrier.c | 13 +-
test/mpi/ft/bcast.c | 18 +-
test/mpi/ft/die.c | 2 +-
test/mpi/ft/failure_ack.c | 9 +-
test/mpi/ft/gather.c | 15 +-
test/mpi/ft/irecvdead.c | 13 +-
test/mpi/ft/isendalive.c | 9 +-
test/mpi/ft/isenddead.c | 10 +-
test/mpi/ft/multi_isendalive.c | 13 +-
test/mpi/ft/nbccoll.c | 4 +-
test/mpi/ft/recvdead.c | 13 +-
test/mpi/ft/reduce.c | 13 +-
test/mpi/ft/revoke_nofail.c | 5 +-
test/mpi/ft/revoke_shrink.c | 12 +-
test/mpi/ft/scatter.c | 34 +-
test/mpi/ft/sendalive.c | 3 +-
test/mpi/ft/senddead.c | 13 +-
test/mpi/ft/shrink.c | 8 +-
test/mpi/group/glpid.c | 29 +-
test/mpi/group/groupcreate.c | 105 +-
test/mpi/group/groupnullincl.c | 93 +-
test/mpi/group/grouptest.c | 315 ++--
test/mpi/group/grouptest2.c | 233 +-
test/mpi/group/gtranks.c | 178 +-
test/mpi/group/gtranksperf.c | 47 +-
test/mpi/impls/hydra/dummy.c | 2 +-
test/mpi/impls/mpich/mpi_t/collparmt.c | 206 +-
test/mpi/include/dtypes.h | 15 +-
test/mpi/include/mpitest.h | 76 +-
test/mpi/include/mpitestcxx.h | 68 +-
test/mpi/include/mpithreadtest.h | 18 +-
test/mpi/info/infodel.c | 84 +-
test/mpi/info/infodup.c | 87 +-
test/mpi/info/infoenv.c | 3 +-
test/mpi/info/infoget.c | 8 +-
test/mpi/info/infomany.c | 136 +-
test/mpi/info/infomany2.c | 164 +-
test/mpi/info/infoorder.c | 207 +-
test/mpi/info/infotest.c | 42 +-
test/mpi/info/infovallen.c | 66 +-
test/mpi/init/attrself.c | 143 +-
test/mpi/init/exitst1.c | 10 +-
test/mpi/init/exitst2.c | 14 +-
test/mpi/init/exitst3.c | 22 +-
test/mpi/init/finalized.c | 121 +-
test/mpi/init/initstat.c | 25 +-
test/mpi/init/timeout.c | 8 +-
test/mpi/init/version.c | 22 +-
test/mpi/io/async.c | 179 +-
test/mpi/io/async_any.c | 103 +-
test/mpi/io/bigtype.c | 80 +-
test/mpi/io/getextent.c | 19 +-
test/mpi/io/hindexed_io.c | 80 +-
test/mpi/io/i_aggregation1.c | 75 +-
test/mpi/io/i_aggregation2.c | 32 +-
test/mpi/io/i_bigtype.c | 8 +-
test/mpi/io/i_coll_test.c | 65 +-
test/mpi/io/i_darray_read.c | 19 +-
test/mpi/io/i_hindexed.c | 25 +-
test/mpi/io/i_hindexed_io.c | 22 +-
test/mpi/io/i_noncontig.c | 239 +-
test/mpi/io/i_noncontig_coll.c | 58 +-
test/mpi/io/i_noncontig_coll2.c | 72 +-
test/mpi/io/i_rdwrord.c | 10 +-
test/mpi/io/i_setviewcur.c | 3 +-
test/mpi/io/i_types_with_zeros.c | 78 +-
test/mpi/io/rdwrord.c | 54 +-
test/mpi/io/rdwrzero.c | 103 +-
test/mpi/io/resized.c | 90 +-
test/mpi/io/resized2.c | 92 +-
test/mpi/io/setinfo.c | 127 +-
test/mpi/io/setviewcur.c | 129 +-
test/mpi/io/userioerr.c | 54 +-
test/mpi/manual/connectstuff.h | 20 +-
test/mpi/manual/dimsbalanced.c | 79 +-
test/mpi/manual/mpi_t/mpit_test.c | 15 +-
test/mpi/manual/mpi_t/mpit_test2.c | 25 +-
.../mpi_t/nem_fbox_fallback_to_queue_count.c | 32 +-
.../manual/mpi_t/unexpected_recvq_buffer_size.c | 20 +-
test/mpi/manual/segfault.c | 3 +-
test/mpi/manual/singjoin.c | 347 ++--
test/mpi/manual/spawntest_child.c | 69 +-
test/mpi/manual/spawntest_master.c | 90 +-
test/mpi/manual/tchandlers.c | 84 +-
test/mpi/manual/tcutil.c | 135 +-
test/mpi/manual/testconnect.c | 169 +-
test/mpi/manual/testconnectserial.c | 106 +-
test/mpi/mpi_t/cvarwrite.c | 45 +-
test/mpi/mpi_t/getindex.c | 43 +-
test/mpi/mpi_t/mpi_t_str.c | 51 +-
test/mpi/mpi_t/mpit_vars.c | 9 +-
test/mpi/perf/allredtrace.c | 158 +-
test/mpi/perf/commcreatep.c | 93 +-
test/mpi/perf/dtpack.c | 762 +++---
test/mpi/perf/indexperf.c | 195 +-
test/mpi/perf/manyrma.c | 552 +++---
test/mpi/perf/nestvec.c | 200 +-
test/mpi/perf/nestvec2.c | 242 +-
test/mpi/perf/non_zero_root.c | 102 +-
test/mpi/perf/sendrecvl.c | 383 ++--
test/mpi/perf/timer.c | 48 +-
test/mpi/perf/transp-datatype.c | 124 +-
test/mpi/perf/twovec.c | 47 +-
test/mpi/pt2pt/anyall.c | 103 +-
test/mpi/pt2pt/big_count_status.c | 2 +-
test/mpi/pt2pt/bottom.c | 76 +-
test/mpi/pt2pt/bsend1.c | 75 +-
test/mpi/pt2pt/bsend2.c | 75 +-
test/mpi/pt2pt/bsend3.c | 79 +-
test/mpi/pt2pt/bsend4.c | 77 +-
test/mpi/pt2pt/bsend5.c | 87 +-
test/mpi/pt2pt/bsendalign.c | 94 +-
test/mpi/pt2pt/bsendfrag.c | 147 +-
test/mpi/pt2pt/bsendpending.c | 222 +-
test/mpi/pt2pt/cancelanysrc.c | 8 +-
test/mpi/pt2pt/cancelrecv.c | 187 +-
test/mpi/pt2pt/eagerdt.c | 74 +-
test/mpi/pt2pt/greq1.c | 67 +-
test/mpi/pt2pt/icsend.c | 89 +-
test/mpi/pt2pt/inactivereq.c | 150 +-
test/mpi/pt2pt/isendirecv.c | 24 +-
test/mpi/pt2pt/isendself.c | 57 +-
test/mpi/pt2pt/isendselfprobe.c | 38 +-
test/mpi/pt2pt/large_message.c | 95 +-
test/mpi/pt2pt/mprobe.c | 21 +-
test/mpi/pt2pt/pingping.c | 169 +-
test/mpi/pt2pt/probe-unexp.c | 230 +-
test/mpi/pt2pt/probenull.c | 52 +-
test/mpi/pt2pt/pscancel.c | 456 ++--
test/mpi/pt2pt/rcancel.c | 106 +-
test/mpi/pt2pt/rqfreeb.c | 153 +-
test/mpi/pt2pt/rqstatus.c | 123 +-
test/mpi/pt2pt/scancel.c | 452 ++--
test/mpi/pt2pt/scancel2.c | 97 +-
test/mpi/pt2pt/sendall.c | 105 +-
test/mpi/pt2pt/sendflood.c | 218 +-
test/mpi/pt2pt/sendrecv1.c | 124 +-
test/mpi/pt2pt/sendrecv2.c | 155 +-
test/mpi/pt2pt/sendrecv3.c | 126 +-
test/mpi/pt2pt/sendself.c | 207 +-
test/mpi/pt2pt/waitany-null.c | 64 +-
test/mpi/pt2pt/waittestnull.c | 68 +-
test/mpi/rma/acc-loc.c | 7 +-
test/mpi/rma/accfence1.c | 150 +-
test/mpi/rma/accfence2.c | 115 +-
test/mpi/rma/accfence2_am.c | 111 +-
test/mpi/rma/accpscw1.c | 168 +-
test/mpi/rma/adlb_mimic1.c | 46 +-
test/mpi/rma/aint.c | 16 +-
test/mpi/rma/allocmem.c | 48 +-
test/mpi/rma/at_complete.c | 45 +-
test/mpi/rma/attrorderwin.c | 160 +-
test/mpi/rma/baseattrwin.c | 82 +-
test/mpi/rma/compare_and_swap.c | 27 +-
test/mpi/rma/contention_put.c | 110 +-
test/mpi/rma/contention_putget.c | 122 +-
test/mpi/rma/contig_displ.c | 80 +-
test/mpi/rma/epochtest.c | 305 ++--
test/mpi/rma/fence_shm.c | 3 +-
test/mpi/rma/fetch_and_op.c | 99 +-
test/mpi/rma/fetchandadd.c | 82 +-
test/mpi/rma/fetchandadd_am.c | 87 +-
test/mpi/rma/fetchandadd_tree.c | 132 +-
test/mpi/rma/fetchandadd_tree_am.c | 135 +-
test/mpi/rma/fkeyvalwin.c | 77 +-
test/mpi/rma/flush.c | 30 +-
test/mpi/rma/get-struct.c | 146 +-
test/mpi/rma/get_acc_local.c | 19 +-
test/mpi/rma/get_accumulate.c | 158 +-
test/mpi/rma/getfence1.c | 105 +-
test/mpi/rma/getgroup.c | 46 +-
test/mpi/rma/linked_list.c | 67 +-
test/mpi/rma/linked_list_bench_lock_all.c | 84 +-
test/mpi/rma/linked_list_bench_lock_excl.c | 86 +-
test/mpi/rma/linked_list_bench_lock_shr.c | 82 +-
test/mpi/rma/linked_list_fop.c | 77 +-
test/mpi/rma/linked_list_lockall.c | 67 +-
test/mpi/rma/lockcontention.c | 36 +-
test/mpi/rma/lockcontention2.c | 370 ++--
test/mpi/rma/lockcontention3.c | 704 +++---
test/mpi/rma/locknull.c | 49 +-
test/mpi/rma/lockopts.c | 278 +--
test/mpi/rma/manyget.c | 3 +-
test/mpi/rma/mcs-mutex.c | 18 +-
test/mpi/rma/mcs-mutex.h | 2 +-
test/mpi/rma/mixedsync.c | 364 ++--
test/mpi/rma/mutex_bench.c | 82 +-
test/mpi/rma/nb_test.c | 2 +-
test/mpi/rma/nullpscw.c | 46 +-
test/mpi/rma/pscw_ordering.c | 41 +-
test/mpi/rma/put_base.c | 118 +-
test/mpi/rma/put_bottom.c | 106 +-
test/mpi/rma/putfence1.c | 107 +-
test/mpi/rma/putfidx.c | 133 +-
test/mpi/rma/putpscw1.c | 167 +-
test/mpi/rma/req_example.c | 22 +-
test/mpi/rma/reqops.c | 82 +-
test/mpi/rma/rmanull.c | 204 +-
test/mpi/rma/rmazero.c | 190 +-
test/mpi/rma/selfrma.c | 118 +-
test/mpi/rma/squelch.h | 6 +-
test/mpi/rma/strided_acc_indexed.c | 109 +-
test/mpi/rma/strided_acc_onelock.c | 48 +-
test/mpi/rma/strided_acc_subarray.c | 107 +-
test/mpi/rma/strided_get_indexed.c | 73 +-
test/mpi/rma/strided_getacc_indexed.c | 127 +-
test/mpi/rma/strided_getacc_indexed_shared.c | 125 +-
test/mpi/rma/strided_putget_indexed.c | 107 +-
test/mpi/rma/strided_putget_indexed_shared.c | 105 +-
test/mpi/rma/test1.c | 72 +-
test/mpi/rma/test1_am.c | 70 +-
test/mpi/rma/test1_dt.c | 48 +-
test/mpi/rma/test2.c | 48 +-
test/mpi/rma/test2_am.c | 48 +-
test/mpi/rma/test3.c | 38 +-
test/mpi/rma/test3_am.c | 35 +-
test/mpi/rma/test4.c | 48 +-
test/mpi/rma/test4_am.c | 50 +-
test/mpi/rma/test5.c | 42 +-
test/mpi/rma/test5_am.c | 42 +-
test/mpi/rma/transpose1.c | 60 +-
test/mpi/rma/transpose2.c | 70 +-
test/mpi/rma/transpose3.c | 70 +-
test/mpi/rma/transpose4.c | 48 +-
test/mpi/rma/transpose5.c | 67 +-
test/mpi/rma/transpose6.c | 83 +-
test/mpi/rma/transpose7.c | 63 +-
test/mpi/rma/win_dynamic_acc.c | 25 +-
test/mpi/rma/win_flavors.c | 90 +-
test/mpi/rma/win_info.c | 35 +-
test/mpi/rma/win_large_shm.c | 22 +-
test/mpi/rma/win_shared.c | 30 +-
test/mpi/rma/win_shared_noncontig.c | 27 +-
test/mpi/rma/win_shared_noncontig_put.c | 43 +-
test/mpi/rma/win_shared_zerobyte.c | 3 +-
test/mpi/rma/wincall.c | 58 +-
test/mpi/rma/window_creation.c | 56 +-
test/mpi/rma/winname.c | 34 +-
test/mpi/rma/wintest.c | 44 +-
test/mpi/spawn/concurrent_spawns.c | 71 +-
test/mpi/spawn/disconnect.c | 66 +-
test/mpi/spawn/disconnect2.c | 83 +-
test/mpi/spawn/disconnect3.c | 83 +-
test/mpi/spawn/disconnect_reconnect.c | 120 +-
test/mpi/spawn/disconnect_reconnect2.c | 141 +-
test/mpi/spawn/disconnect_reconnect3.c | 128 +-
test/mpi/spawn/join.c | 61 +-
test/mpi/spawn/multiple_ports.c | 176 +-
test/mpi/spawn/multiple_ports2.c | 250 +-
test/mpi/spawn/namepub.c | 121 +-
test/mpi/spawn/pgroup_connect_test.c | 198 +-
test/mpi/spawn/pgroup_intercomm_test.c | 178 +-
test/mpi/spawn/selfconacc.c | 159 +-
test/mpi/spawn/spaconacc.c | 120 +-
test/mpi/spawn/spaconacc2.c | 105 +-
test/mpi/spawn/spaiccreate.c | 59 +-
test/mpi/spawn/spaiccreate2.c | 57 +-
test/mpi/spawn/spawn1.c | 69 +-
test/mpi/spawn/spawn2.c | 108 +-
test/mpi/spawn/spawnargv.c | 80 +-
test/mpi/spawn/spawninfo1.c | 101 +-
test/mpi/spawn/spawnintra.c | 128 +-
test/mpi/spawn/spawnmanyarg.c | 138 +-
test/mpi/spawn/spawnminfo1.c | 119 +-
test/mpi/spawn/spawnmult2.c | 57 +-
test/mpi/spawn/taskmaster.c | 129 +-
test/mpi/template.c | 107 +-
test/mpi/threads/coll/allred.c | 14 +-
test/mpi/threads/coll/iallred.c | 14 +-
test/mpi/threads/comm/comm_create_group_threads.c | 35 +-
test/mpi/threads/comm/comm_create_threads.c | 18 +-
test/mpi/threads/comm/comm_dup_deadlock.c | 37 +-
test/mpi/threads/comm/comm_idup.c | 37 +-
test/mpi/threads/comm/ctxdup.c | 74 +-
test/mpi/threads/comm/ctxidup.c | 58 +-
test/mpi/threads/comm/dup_leak_test.c | 13 +-
test/mpi/threads/comm/idup_comm_gen.c | 41 +-
test/mpi/threads/comm/idup_nb.c | 140 +-
test/mpi/threads/init/initth.c | 10 +-
test/mpi/threads/mpi_t/mpit_threading.c | 7 +-
test/mpi/threads/pt2pt/greq_test.c | 49 +-
test/mpi/threads/pt2pt/greq_wait.c | 49 +-
test/mpi/threads/pt2pt/ibsend.c | 20 +-
test/mpi/threads/pt2pt/multisend.c | 44 +-
test/mpi/threads/pt2pt/multisend2.c | 84 +-
test/mpi/threads/pt2pt/multisend3.c | 132 +-
test/mpi/threads/pt2pt/multisend4.c | 118 +-
test/mpi/threads/pt2pt/sendselfth.c | 21 +-
test/mpi/threads/pt2pt/threaded_sr.c | 109 +-
test/mpi/threads/pt2pt/threads.c | 35 +-
test/mpi/threads/rma/multiget.c | 8 +-
test/mpi/threads/rma/multirma.c | 6 +-
test/mpi/threads/spawn/multispawn.c | 102 +-
test/mpi/threads/spawn/th_taskmaster.c | 111 +-
test/mpi/threads/util/mtestthread.c | 227 +-
test/mpi/topo/cartcreates.c | 45 +-
test/mpi/topo/cartmap1.c | 54 +-
test/mpi/topo/cartshift1.c | 100 +-
test/mpi/topo/cartsuball.c | 40 +-
test/mpi/topo/cartzero.c | 111 +-
test/mpi/topo/dgraph_unwgt.c | 127 +-
test/mpi/topo/dims1.c | 178 +-
test/mpi/topo/dims2.c | 118 +-
test/mpi/topo/dims4.c | 2 +-
test/mpi/topo/distgraph1.c | 174 +-
test/mpi/topo/graphcr.c | 16 +-
test/mpi/topo/graphcr2.c | 64 +-
test/mpi/topo/graphmap1.c | 26 +-
test/mpi/topo/neighb_coll.c | 39 +-
test/mpi/topo/topodup.c | 181 +-
test/mpi/topo/topotest.c | 30 +-
test/mpi/util/dtypes.c | 336 ++--
test/mpi/util/mtest.c | 1571 +++++++------
test/mpi/util/mtestcheck.c | 41 +-
604 files changed, 34259 insertions(+), 34339 deletions(-)
hooks/post-receive
--
MPICH primary repository
More information about the commits
mailing list