|
Packit |
0848f5 |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit |
0848f5 |
/*
|
|
Packit |
0848f5 |
*
|
|
Packit |
0848f5 |
* (C) 2001 by Argonne National Laboratory.
|
|
Packit |
0848f5 |
* See COPYRIGHT in top-level directory.
|
|
Packit |
0848f5 |
*/
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* style: allow:fprintf:10 sig:0 */
|
|
Packit |
0848f5 |
#include <stdio.h>
|
|
Packit |
0848f5 |
#include "mpi.h"
|
|
Packit |
0848f5 |
#include "../../include/mpitestconf.h"
|
|
Packit |
0848f5 |
#include <string.h>
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/*
|
|
Packit |
0848f5 |
Name mapping. All routines are created with names that are lower case
|
|
Packit |
0848f5 |
with a single trailing underscore. This matches many compilers.
|
|
Packit |
0848f5 |
We use #define to change the name for Fortran compilers that do
|
|
Packit |
0848f5 |
not use the lowercase/underscore pattern
|
|
Packit |
0848f5 |
*/
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
#ifdef F77_NAME_UPPER
|
|
Packit |
0848f5 |
#define chkcomm2inc_ CHKCOMM2INC
|
|
Packit |
0848f5 |
#define chkckeyvals_ CHKCKEYVALS
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
#elif defined(F77_NAME_LOWER) || defined(F77_NAME_MIXED)
|
|
Packit |
0848f5 |
/* Mixed is ok because we use lowercase in all uses */
|
|
Packit |
0848f5 |
#define chkcomm2inc_ chkcomm2inc
|
|
Packit |
0848f5 |
#define chkckeyvals_ chkckeyvals
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
#elif defined(F77_NAME_LOWER_2USCORE) || defined(F77_NAME_LOWER_USCORE) || \
|
|
Packit |
0848f5 |
defined(F77_NAME_MIXED_USCORE)
|
|
Packit |
0848f5 |
/* Else leave name alone (routines have no underscore, so both
|
|
Packit |
0848f5 |
of these map to a lowercase, single underscore) */
|
|
Packit |
0848f5 |
#else
|
|
Packit |
0848f5 |
#error 'Unrecognized Fortran name mapping'
|
|
Packit |
0848f5 |
#endif
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
int chkcomm2inc_(int *keyval, const int *expected, int *ierr);
|
|
Packit |
0848f5 |
int chkcomm2inc_(int *keyval, const int *expected, int *ierr)
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
int flag;
|
|
Packit |
0848f5 |
MPI_Aint *val;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* See Example 16.19 in MPI 2.2, part B. The use of MPI_Aint *val
|
|
Packit |
0848f5 |
* and the address of val in the get_attr call is correct, as is
|
|
Packit |
0848f5 |
* the use of *val to access the value. */
|
|
Packit |
0848f5 |
MPI_Comm_get_attr(MPI_COMM_WORLD, *keyval, &val, &flag;;
|
|
Packit |
0848f5 |
if (!flag) {
|
|
Packit |
0848f5 |
*ierr = 1;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
else {
|
|
Packit |
0848f5 |
if (*val != *expected) {
|
|
Packit |
0848f5 |
/* In some cases, using printf from a c routine linked
|
|
Packit |
0848f5 |
* with a Fortran routine can cause linking difficulties.
|
|
Packit |
0848f5 |
* To avoid problems in running the tests, this print
|
|
Packit |
0848f5 |
* is commented out */
|
|
Packit |
0848f5 |
/* printf("Val = %x, expected = %d\n", val, *expected); */
|
|
Packit |
0848f5 |
*ierr = *ierr + 1;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
return 0;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* Attribute delete and copy functions for each type */
|
|
Packit |
0848f5 |
int myCommCopyfn(MPI_Comm comm, int keyval, void *extra_state,
|
|
Packit |
0848f5 |
void *attr_val_in, void *attr_val_out, int *flag);
|
|
Packit |
0848f5 |
int myCommCopyfn(MPI_Comm comm, int keyval, void *extra_state,
|
|
Packit |
0848f5 |
void *attr_val_in, void *attr_val_out, int *flag)
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
*(void **) attr_val_out = (char *) attr_val_in + 2;
|
|
Packit |
0848f5 |
*flag = 1;
|
|
Packit |
0848f5 |
return MPI_SUCCESS;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
int myCommDelfn(MPI_Comm comm, int keyval, void *attr_val, void *extra_state);
|
|
Packit |
0848f5 |
int myCommDelfn(MPI_Comm comm, int keyval, void *attr_val, void *extra_state)
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
return MPI_SUCCESS;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
int myTypeCopyfn(MPI_Datatype dtype, int keyval, void *extra_state,
|
|
Packit |
0848f5 |
void *attr_val_in, void *attr_val_out, int *flag);
|
|
Packit |
0848f5 |
int myTypeCopyfn(MPI_Datatype dtype, int keyval, void *extra_state,
|
|
Packit |
0848f5 |
void *attr_val_in, void *attr_val_out, int *flag)
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
*(void **) attr_val_out = (char *) attr_val_in + 2;
|
|
Packit |
0848f5 |
*flag = 1;
|
|
Packit |
0848f5 |
return MPI_SUCCESS;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
int myTypeDelfn(MPI_Datatype dtype, int keyval, void *attr_val, void *extra_state);
|
|
Packit |
0848f5 |
int myTypeDelfn(MPI_Datatype dtype, int keyval, void *attr_val, void *extra_state)
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
return MPI_SUCCESS;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
int myWinCopyfn(MPI_Win win, int keyval, void *extra_state,
|
|
Packit |
0848f5 |
void *attr_val_in, void *attr_val_out, int *flag);
|
|
Packit |
0848f5 |
int myWinCopyfn(MPI_Win win, int keyval, void *extra_state,
|
|
Packit |
0848f5 |
void *attr_val_in, void *attr_val_out, int *flag)
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
*(void **) attr_val_out = (char *) attr_val_in + 2;
|
|
Packit |
0848f5 |
*flag = 1;
|
|
Packit |
0848f5 |
return MPI_SUCCESS;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
int myWinDelfn(MPI_Win win, int keyval, void *attr_val, void *extra_state);
|
|
Packit |
0848f5 |
int myWinDelfn(MPI_Win win, int keyval, void *attr_val, void *extra_state)
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
return MPI_SUCCESS;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
int chkckeyvals_(int *comm_keyval, int *type_keyval, int *win_keyval);
|
|
Packit |
0848f5 |
int chkckeyvals_(int *comm_keyval, int *type_keyval, int *win_keyval)
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
MPI_Comm_create_keyval(myCommCopyfn, myCommDelfn, comm_keyval, 0);
|
|
Packit |
0848f5 |
MPI_Type_create_keyval(myTypeCopyfn, myTypeDelfn, type_keyval, 0);
|
|
Packit |
0848f5 |
MPI_Win_create_keyval(myWinCopyfn, myWinDelfn, win_keyval, 0);
|
|
Packit |
0848f5 |
return 0;
|
|
Packit |
0848f5 |
}
|