|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* (C) 2001 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include "mpiimpl.h"
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* -- Begin Profiling Symbol Block for routine MPI_Win_get_attr */
|
|
Packit Service |
c5cf8c |
#if defined(HAVE_PRAGMA_WEAK)
|
|
Packit Service |
c5cf8c |
#pragma weak MPI_Win_get_attr = PMPI_Win_get_attr
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
|
|
Packit Service |
c5cf8c |
#pragma _HP_SECONDARY_DEF PMPI_Win_get_attr MPI_Win_get_attr
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_CRI_DUP)
|
|
Packit Service |
c5cf8c |
#pragma _CRI duplicate MPI_Win_get_attr as PMPI_Win_get_attr
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_WEAK_ATTRIBUTE)
|
|
Packit Service |
c5cf8c |
int MPI_Win_get_attr(MPI_Win win, int win_keyval, void *attribute_val, int *flag)
|
|
Packit Service |
c5cf8c |
__attribute__ ((weak, alias("PMPI_Win_get_attr")));
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
/* -- End Profiling Symbol Block */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build
|
|
Packit Service |
c5cf8c |
the MPI routines */
|
|
Packit Service |
c5cf8c |
#ifndef MPICH_MPI_FROM_PMPI
|
|
Packit Service |
c5cf8c |
#undef MPI_Win_get_attr
|
|
Packit Service |
c5cf8c |
#define MPI_Win_get_attr PMPI_Win_get_attr
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#undef FUNCNAME
|
|
Packit Service |
c5cf8c |
#define FUNCNAME MPII_Win_get_attr
|
|
Packit Service |
c5cf8c |
#undef FCNAME
|
|
Packit Service |
c5cf8c |
#define FCNAME MPL_QUOTE(FUNCNAME)
|
|
Packit Service |
c5cf8c |
int MPII_Win_get_attr(MPI_Win win, int win_keyval, void *attribute_val,
|
|
Packit Service |
c5cf8c |
int *flag, MPIR_Attr_type outAttrType)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int mpi_errno = MPI_SUCCESS;
|
|
Packit Service |
c5cf8c |
MPIR_Win *win_ptr = NULL;
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_STATE_DECL(MPID_STATE_MPIR_WIN_GET_ATTR);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_ERRTEST_INITIALIZED_ORDIE();
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPID_THREAD_CS_ENTER(GLOBAL, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX);
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_ENTER(MPID_STATE_MPIR_WIN_GET_ATTR);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Validate parameters, especially handles needing to be converted */
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_ERROR_CHECKING
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
MPID_BEGIN_ERROR_CHECKS;
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
MPIR_ERRTEST_WIN(win, mpi_errno);
|
|
Packit Service |
c5cf8c |
MPIR_ERRTEST_KEYVAL(win_keyval, MPIR_WIN, "window", mpi_errno);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPID_END_ERROR_CHECKS;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Convert MPI object handles to object pointers */
|
|
Packit Service |
c5cf8c |
MPIR_Win_get_ptr(win, win_ptr);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Validate parameters and objects (post conversion) */
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_ERROR_CHECKING
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
MPID_BEGIN_ERROR_CHECKS;
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
/* Validate win_ptr */
|
|
Packit Service |
c5cf8c |
MPIR_Win_valid_ptr(win_ptr, mpi_errno);
|
|
Packit Service |
c5cf8c |
/* If win_ptr is not valid, it will be reset to null */
|
|
Packit Service |
c5cf8c |
MPIR_ERRTEST_ARGNULL(attribute_val, "attribute_val", mpi_errno);
|
|
Packit Service |
c5cf8c |
MPIR_ERRTEST_ARGNULL(flag, "flag", mpi_errno);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPID_END_ERROR_CHECKS;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
#endif /* HAVE_ERROR_CHECKING */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* ... body of routine ... */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Check for builtin attribute */
|
|
Packit Service |
c5cf8c |
/* This code is ok for correct programs, but it would be better
|
|
Packit Service |
c5cf8c |
* to copy the values from the per-process block and pass the user
|
|
Packit Service |
c5cf8c |
* a pointer to a copy */
|
|
Packit Service |
c5cf8c |
/* Note that if we are called from Fortran, we must return the values,
|
|
Packit Service |
c5cf8c |
* not the addresses, of these attributes */
|
|
Packit Service |
c5cf8c |
if (HANDLE_GET_KIND(win_keyval) == HANDLE_KIND_BUILTIN) {
|
|
Packit Service |
c5cf8c |
void **attr_val_p = (void **) attribute_val;
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_FORTRAN_BINDING
|
|
Packit Service |
c5cf8c |
/* Note that this routine only has a Fortran 90 binding,
|
|
Packit Service |
c5cf8c |
* so the attribute value is an address-sized int */
|
|
Packit Service |
c5cf8c |
intptr_t *attr_int = (intptr_t *) attribute_val;
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
*flag = 1;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* The C versions of the attributes return the address of a
|
|
Packit Service |
c5cf8c |
* *COPY* of the value (to prevent the user from changing it)
|
|
Packit Service |
c5cf8c |
* and the Fortran versions provide the actual value (as a Fint)
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
switch (win_keyval) {
|
|
Packit Service |
c5cf8c |
case MPI_WIN_BASE:
|
|
Packit Service |
c5cf8c |
*attr_val_p = win_ptr->base;
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
case MPI_WIN_SIZE:
|
|
Packit Service |
c5cf8c |
win_ptr->copySize = win_ptr->size;
|
|
Packit Service |
c5cf8c |
*attr_val_p = &win_ptr->copySize;
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
case MPI_WIN_DISP_UNIT:
|
|
Packit Service |
c5cf8c |
win_ptr->copyDispUnit = win_ptr->disp_unit;
|
|
Packit Service |
c5cf8c |
*attr_val_p = &win_ptr->copyDispUnit;
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
case MPI_WIN_CREATE_FLAVOR:
|
|
Packit Service |
c5cf8c |
win_ptr->copyCreateFlavor = win_ptr->create_flavor;
|
|
Packit Service |
c5cf8c |
*attr_val_p = &win_ptr->copyCreateFlavor;
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
case MPI_WIN_MODEL:
|
|
Packit Service |
c5cf8c |
win_ptr->copyModel = win_ptr->model;
|
|
Packit Service |
c5cf8c |
*attr_val_p = &win_ptr->copyModel;
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_FORTRAN_BINDING
|
|
Packit Service |
c5cf8c |
case MPII_ATTR_C_TO_FORTRAN(MPI_WIN_BASE):
|
|
Packit Service |
c5cf8c |
/* The Fortran routine that matches this routine should
|
|
Packit Service |
c5cf8c |
* provide an address-sized integer, not an MPI_Fint */
|
|
Packit Service |
c5cf8c |
*attr_int = MPIR_VOID_PTR_CAST_TO_MPI_AINT(win_ptr->base);
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
case MPII_ATTR_C_TO_FORTRAN(MPI_WIN_SIZE):
|
|
Packit Service |
c5cf8c |
/* We do not need to copy because we return the value,
|
|
Packit Service |
c5cf8c |
* not a pointer to the value */
|
|
Packit Service |
c5cf8c |
*attr_int = win_ptr->size;
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
case MPII_ATTR_C_TO_FORTRAN(MPI_WIN_DISP_UNIT):
|
|
Packit Service |
c5cf8c |
/* We do not need to copy because we return the value,
|
|
Packit Service |
c5cf8c |
* not a pointer to the value */
|
|
Packit Service |
c5cf8c |
*attr_int = win_ptr->disp_unit;
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
case MPII_ATTR_C_TO_FORTRAN(MPI_WIN_CREATE_FLAVOR):
|
|
Packit Service |
c5cf8c |
*attr_int = win_ptr->create_flavor;
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
case MPII_ATTR_C_TO_FORTRAN(MPI_WIN_MODEL):
|
|
Packit Service |
c5cf8c |
*attr_int = win_ptr->model;
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
default:
|
|
Packit Service |
c5cf8c |
MPIR_Assert(FALSE);
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
MPIR_Attribute *p = win_ptr->attributes;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
*flag = 0;
|
|
Packit Service |
c5cf8c |
while (p) {
|
|
Packit Service |
c5cf8c |
if (p->keyval->handle == win_keyval) {
|
|
Packit Service |
c5cf8c |
*flag = 1;
|
|
Packit Service |
c5cf8c |
if (outAttrType == MPIR_ATTR_PTR) {
|
|
Packit Service |
c5cf8c |
if (p->attrType == MPIR_ATTR_INT) {
|
|
Packit Service |
c5cf8c |
/* This is the tricky case: if the system is
|
|
Packit Service |
c5cf8c |
* bigendian, and we have to return a pointer to
|
|
Packit Service |
c5cf8c |
* an int, then we may need to point to the
|
|
Packit Service |
c5cf8c |
* correct location in the word. */
|
|
Packit Service |
c5cf8c |
#if defined(WORDS_LITTLEENDIAN) || (SIZEOF_VOID_P == SIZEOF_INT)
|
|
Packit Service |
c5cf8c |
*(void **) attribute_val = &(p->value);
|
|
Packit Service |
c5cf8c |
#else
|
|
Packit Service |
c5cf8c |
int *p_loc = (int *) &(p->value);
|
|
Packit Service |
c5cf8c |
#if SIZEOF_VOID_P == 2 * SIZEOF_INT
|
|
Packit Service |
c5cf8c |
p_loc++;
|
|
Packit Service |
c5cf8c |
#else
|
|
Packit Service |
c5cf8c |
#error Expected sizeof(void*) to be either sizeof(int) or 2*sizeof(int)
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
*(void **) attribute_val = p_loc;
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
} else if (p->attrType == MPIR_ATTR_AINT) {
|
|
Packit Service |
c5cf8c |
*(void **) attribute_val = &(p->value);
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
*(void **) attribute_val = (void *) (intptr_t) (p->value);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
} else
|
|
Packit Service |
c5cf8c |
*(void **) attribute_val = (void *) (intptr_t) (p->value);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
p = p->next;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* ... end of body of routine ... */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_ERROR_CHECKING
|
|
Packit Service |
c5cf8c |
fn_exit:
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_EXIT(MPID_STATE_MPIR_WIN_GET_ATTR);
|
|
Packit Service |
c5cf8c |
MPID_THREAD_CS_EXIT(GLOBAL, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX);
|
|
Packit Service |
c5cf8c |
return mpi_errno;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_ERROR_CHECKING
|
|
Packit Service |
c5cf8c |
fn_fail:
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
mpi_errno =
|
|
Packit Service |
c5cf8c |
MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER,
|
|
Packit Service |
c5cf8c |
"**mpir_wingetattr", "**mpir_wingetattr %W %d %p %p", win,
|
|
Packit Service |
c5cf8c |
win_keyval, attribute_val, flag);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
mpi_errno = MPIR_Err_return_win(win_ptr, FCNAME, mpi_errno);
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
/* --END ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#undef FUNCNAME
|
|
Packit Service |
c5cf8c |
#define FUNCNAME MPI_Win_get_attr
|
|
Packit Service |
c5cf8c |
#undef FCNAME
|
|
Packit Service |
c5cf8c |
#define FCNAME MPL_QUOTE(FUNCNAME)
|
|
Packit Service |
c5cf8c |
/*@
|
|
Packit Service |
c5cf8c |
MPI_Win_get_attr - Get attribute cached on an MPI window object
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Input Parameters:
|
|
Packit Service |
c5cf8c |
+ win - window to which the attribute is attached (handle)
|
|
Packit Service |
c5cf8c |
- win_keyval - key value (integer)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Output Parameters:
|
|
Packit Service |
c5cf8c |
+ attribute_val - attribute value, unless flag is false
|
|
Packit Service |
c5cf8c |
- flag - false if no attribute is associated with the key (logical)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Notes:
|
|
Packit Service |
c5cf8c |
The following attributes are predefined for all MPI Window objects\:
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
+ MPI_WIN_BASE - window base address.
|
|
Packit Service |
c5cf8c |
. MPI_WIN_SIZE - window size, in bytes.
|
|
Packit Service |
c5cf8c |
- MPI_WIN_DISP_UNIT - displacement unit associated with the window.
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
.N ThreadSafe
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
.N Fortran
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
.N Errors
|
|
Packit Service |
c5cf8c |
.N MPI_SUCCESS
|
|
Packit Service |
c5cf8c |
.N MPI_ERR_WIN
|
|
Packit Service |
c5cf8c |
.N MPI_ERR_KEYVAL
|
|
Packit Service |
c5cf8c |
.N MPI_ERR_OTHER
|
|
Packit Service |
c5cf8c |
@*/
|
|
Packit Service |
c5cf8c |
int MPI_Win_get_attr(MPI_Win win, int win_keyval, void *attribute_val, int *flag)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int mpi_errno = MPI_SUCCESS;
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_ERROR_CHECKING
|
|
Packit Service |
c5cf8c |
MPIR_Win *win_ptr = NULL;
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_STATE_DECL(MPID_STATE_MPI_WIN_GET_ATTR);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_ERRTEST_INITIALIZED_ORDIE();
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_ENTER(MPID_STATE_MPI_WIN_GET_ATTR);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* ... body of routine ... */
|
|
Packit Service |
c5cf8c |
mpi_errno = MPII_Win_get_attr(win, win_keyval, attribute_val, flag, MPIR_ATTR_PTR);
|
|
Packit Service |
c5cf8c |
if (mpi_errno)
|
|
Packit Service |
c5cf8c |
goto fn_fail;
|
|
Packit Service |
c5cf8c |
/* ... end of body of routine ... */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
fn_exit:
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_EXIT(MPID_STATE_MPI_WIN_GET_ATTR);
|
|
Packit Service |
c5cf8c |
return mpi_errno;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
fn_fail:
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_ERROR_CHECKING
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
mpi_errno =
|
|
Packit Service |
c5cf8c |
MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER,
|
|
Packit Service |
c5cf8c |
"**mpi_win_get_attr", "**mpi_win_get_attr %W %d %p %p", win,
|
|
Packit Service |
c5cf8c |
win_keyval, attribute_val, flag);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPIR_Win_get_ptr(win, win_ptr);
|
|
Packit Service |
c5cf8c |
mpi_errno = MPIR_Err_return_win(win_ptr, FCNAME, mpi_errno);
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
/* --END ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
}
|