include_directories(BEFORE "${CMAKE_HOME_DIRECTORY}/include/smpi")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../include/")
- foreach(file attr2type attrend2 attrend attrerr attrerrcomm attrerrtype attrorder attrordercomm attrordertype attrt
+ foreach(file attr2type attrdeleteget attrend2 attrend attrerr attrerrcomm attrerrtype attrorder attrordercomm attrordertype attrt
baseattr2 baseattrcomm fkeyval) #attric fkeyvalcomm fkeyvaltype keyval_double_free
add_executable(${file} ${file}.c)
target_link_libraries(${file} simgrid mtest_c)
SET_TESTS_PROPERTIES(test-smpi-mpich3-attr-raw PROPERTIES PASS_REGULAR_EXPRESSION "tests passed!")
endif()
-foreach(file attr2type attrend2 attrend attrerr attrerrcomm attrerrtype attrorder attrordercomm attrordertype attrt
- baseattr2 baseattrcomm fkeyval attric fkeyvalcomm fkeyvaltype keyval_double_free)
+foreach(file attr2type attrdeleteget attrend2 attrend attrerr attrerrcomm attrerrtype attrorder attrordercomm attrordertype attrt
+ baseattr2 baseattrcomm fkeyval attric fkeyvalcomm fkeyvaltype keyval_double_free keyval_double_free_comm keyval_double_free_type keyval_double_free_win)
set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${file}.c)
endforeach()
set(examples_src ${examples_src} PARENT_SCOPE)
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;
int main(int argc, char *argv[])
{
- int mpi_errno;
MPI_Datatype type, duptype;
int rank;
MPI_Init(&argc, &argv);
-
- MPI_Comm_rank( MPI_COMM_WORLD, &rank );
+
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
foo_initialize();
- mpi_errno = MPI_Type_contiguous(2, MPI_INT, &type);
+ MPI_Type_contiguous(2, MPI_INT, &type);
- mpi_errno = MPI_Type_set_attr(type, foo_keyval, NULL);
+ MPI_Type_set_attr(type, foo_keyval, NULL);
- mpi_errno = MPI_Type_dup(type, &duptype);
+ MPI_Type_dup(type, &duptype);
my_func = "Free of type";
- mpi_errno = MPI_Type_free(&type);
+ MPI_Type_free(&type);
my_func = "free of duptype";
- mpi_errno = MPI_Type_free(&duptype);
+ MPI_Type_free(&duptype);
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 if(mpi_errno!=MPI_SUCCESS){
- printf( " Output fail - Found %d errors\n", errs );
- }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();
}
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;
}
int foo_initialize(void)
{
- int mpi_errno;
-
/* create keyval for use later */
- mpi_errno = MPI_Type_create_keyval(foo_copy_attr_function,
- foo_delete_attr_function,
- &foo_keyval,
- NULL);
- if (mpi_errno==MPI_SUCCESS && verbose) printf("created keyval\n");
+ MPI_Type_create_keyval(foo_copy_attr_function,
+ foo_delete_attr_function, &foo_keyval, NULL);
+ if (verbose)
+ printf("created keyval\n");
return 0;
}
void foo_finalize(void)
{
- int mpi_errno;
-
/* remove keyval */
- mpi_errno = MPI_Type_free_keyval(&foo_keyval);
+ MPI_Type_free_keyval(&foo_keyval);
- if (mpi_errno==MPI_SUCCESS && verbose) printf("freed keyval\n");
+ if (verbose)
+ printf("freed keyval\n");
return;
}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ *
+ * (C) 2013 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include <stdio.h>
+#include "mpi.h"
+#include "mpitest.h"
+
+int key = MPI_KEYVAL_INVALID;
+char a[100];
+
+int delete_fn(MPI_Comm, int, void *, void *);
+
+int main(int argc, char **argv)
+{
+ MPI_Comm scomm;
+ int errs = 0;
+
+ MTest_Init(&argc, &argv);
+ MPI_Comm_split(MPI_COMM_WORLD, 1, 0, &scomm);
+ 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);
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
+}
+
+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;
+ 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);
+ if (err != MPI_SUCCESS) {
+ printf("MPI_Comm_get_attr returned error %d, presumably due to invalid communicator\n",
+ err);
+ (*errs)++;
+ }
+#endif
+ return 0;
+}
* 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>
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;
}
-
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/*
*
- * (C) 2008 by Argonne National Laboratory.
+ * (C) 2009 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
/*
* assuming a decent hash function is used. */
#define NUM_TEST_ATTRS (20)
-static __attribute__((unused)) int exit_keys[NUM_TEST_ATTRS]; /* init to MPI_KEYVAL_INVALID */
-static __attribute__((unused)) int was_called[NUM_TEST_ATTRS];
+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)
{
- int wrank;
+ int errs = 0, wrank;
+ int i;
MTest_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
#if MTEST_HAVE_MIN_MPI_VERSION(2,2)
- int errs = 0;
- int i;
for (i = 0; i < NUM_TEST_ATTRS; ++i) {
exit_keys[i] = MPI_KEYVAL_INVALID;
was_called[i] = 0;
/* 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 */
}
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");
{
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);
return MPI_SUCCESS;
}
-
#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;
}
/* 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 );
- exit(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;
}
-
#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;
}
/* 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 );
- exit(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;
}
-
#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;
}
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 );
- exit(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;
}
#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 );
- exit(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 );
- exit(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 );
- exit(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 );
- exit(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;
}
-
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, "Attribute 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;
}
-
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, "Attribute 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;
}
-
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, "Attribute 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;
}
-
#include "mpi.h"
#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 * );
+/* #define DEBUG */
+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 );
- exit(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];
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 );
- exit(3001);
+ errs++;
+ printf("incorrect rank in world comm: %d\n", rank);
+ MPI_Abort(MPI_COMM_WORLD, 3001);
}
n = world_size / 2;
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 );
- exit(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( "rank : %d incorrect lo comm:\n", rank ); fflush(stdout);
- MPI_Abort(MPI_COMM_WORLD, 3003 );
- exit(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 );
- exit(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 );
- exit(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 );
- exit(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 );
- exit(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 );
- exit(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 );
- exit(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 );
- exit(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 );
- exit(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;
}
-
#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);
}
#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;
}
*/
/* 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;
}
*/
/* 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;
-
+
}
*/
/* 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;
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;
-
+
}
/* 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;
}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ *
+ * (C) 2009 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+#include <mpi.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "mpitest.h"
+
+/* tests multiple invocations of MPI_Comm_free_keyval 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)
+{
+ MPI_Comm_free_keyval(&keyval);
+ return MPI_SUCCESS;
+}
+
+int main(int argc, char **argv)
+{
+ MPI_Comm duped;
+ int keyval = MPI_KEYVAL_INVALID;
+ int keyval_copy = MPI_KEYVAL_INVALID;
+ int errs = 0;
+
+ MTest_Init(&argc, &argv);
+ MPI_Comm_dup(MPI_COMM_SELF, &duped);
+
+ MPI_Comm_create_keyval(MPI_NULL_COPY_FN, delete_fn, &keyval, NULL);
+ keyval_copy = keyval;
+
+ MPI_Comm_set_attr(MPI_COMM_SELF, keyval, NULL);
+ MPI_Comm_set_attr(duped, keyval, NULL);
+
+ MPI_Comm_free(&duped); /* first MPI_Comm_free_keyval */
+ MPI_Comm_free_keyval(&keyval); /* second MPI_Comm_free_keyval */
+ MPI_Comm_free_keyval(&keyval_copy); /* third MPI_Comm_free_keyval */
+ MTest_Finalize(errs);
+ MPI_Finalize(); /* fourth MPI_Comm_free_keyval */
+ return 0;
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ *
+ * (C) 2015 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+#include <mpi.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "mpitest.h"
+
+/* tests multiple invocations of MPI_Type_free_keyval 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)
+{
+ MPI_Type_free_keyval(&keyval);
+ return MPI_SUCCESS;
+}
+
+int main(int argc, char **argv)
+{
+ MPI_Datatype type;
+ MPI_Datatype type_dup;
+ int keyval = MPI_KEYVAL_INVALID;
+ int keyval_copy = MPI_KEYVAL_INVALID;
+ int errs = 0;
+
+ MTest_Init(&argc, &argv);
+ MPI_Type_dup(MPI_INT, &type);
+ MPI_Type_dup(MPI_INT, &type_dup);
+
+ MPI_Type_create_keyval(MPI_NULL_COPY_FN, delete_fn, &keyval, NULL);
+ keyval_copy = keyval;
+ MPI_Type_set_attr(type, keyval, NULL);
+ MPI_Type_set_attr(type_dup, keyval, NULL);
+
+ MPI_Type_free(&type); /* first MPI_Type_free_keyval */
+ MPI_Type_free_keyval(&keyval); /* second MPI_Type_free_keyval */
+ MPI_Type_free_keyval(&keyval_copy); /* third MPI_Type_free_keyval */
+ MPI_Type_free(&type_dup); /* fourth MPI_Type_free_keyval */
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
+}
--- /dev/null
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ *
+ * (C) 2015 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+#include <mpi.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "mpitest.h"
+
+#define NUM_WIN 2
+#define DATA_SZ sizeof(int)
+
+/* tests multiple invocations of MPI_Win_free_keyval 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)
+{
+ MPI_Win_free_keyval(&keyval);
+ return MPI_SUCCESS;
+}
+
+int main(int argc, char **argv)
+{
+ void *base_ptr[NUM_WIN];
+ MPI_Win windows[NUM_WIN];
+ int keyval = MPI_KEYVAL_INVALID;
+ int keyval_copy = MPI_KEYVAL_INVALID;
+ int errs = 0;
+
+ MTest_Init(&argc, &argv);
+ MPI_Alloc_mem(DATA_SZ, MPI_INFO_NULL, &base_ptr[0]);
+ MPI_Win_create(base_ptr[0], DATA_SZ, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &windows[0]);
+ MPI_Alloc_mem(DATA_SZ, MPI_INFO_NULL, &base_ptr[1]);
+ MPI_Win_create(base_ptr[1], DATA_SZ, 1, MPI_INFO_NULL, MPI_COMM_WORLD, &windows[1]);
+
+ MPI_Win_create_keyval(MPI_NULL_COPY_FN, delete_fn, &keyval, NULL);
+ keyval_copy = keyval;
+
+ MPI_Win_set_attr(windows[0], keyval, NULL);
+ MPI_Win_set_attr(windows[1], keyval, NULL);
+
+ MPI_Win_free(&windows[0]); /* first MPI_Win_free_keyval */
+ MPI_Free_mem(base_ptr[0]);
+ MPI_Win_free_keyval(&keyval); /* second MPI_Win_free_keyval */
+ MPI_Win_free_keyval(&keyval_copy); /* third MPI_Win_free_keyval */
+ MPI_Win_free(&windows[1]); /* fourth MPI_Win_free_keyval */
+ MPI_Free_mem(base_ptr[1]);
+ MTest_Finalize(errs);
+ MPI_Finalize();
+ return 0;
+}
+
#attrend2 5
attrerrcomm 1
attrerrtype 1
+attrdeleteget 1
attr2type 1
attrorder 1
attrordercomm 1