-: 0:Source:/home/MPI/testing/mpich2/mpich2/src/mpi/attr/type_get_attr.c
-: 0:Graph:type_get_attr.gcno
-: 0:Data:type_get_attr.gcda
-: 0:Runs:513
-: 0:Programs:140
-: 1:/* -*- Mode: C; c-basic-offset:4 ; -*- */
-: 2:/*
-: 3: *
-: 4: * (C) 2001 by Argonne National Laboratory.
-: 5: * See COPYRIGHT in top-level directory.
-: 6: */
-: 7:
-: 8:#include "mpiimpl.h"
-: 9:#include "attr.h"
-: 10:
-: 11:/* -- Begin Profiling Symbol Block for routine MPI_Type_get_attr */
-: 12:#if defined(HAVE_PRAGMA_WEAK)
-: 13:#pragma weak MPI_Type_get_attr = PMPI_Type_get_attr
-: 14:#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
-: 15:#pragma _HP_SECONDARY_DEF PMPI_Type_get_attr MPI_Type_get_attr
-: 16:#elif defined(HAVE_PRAGMA_CRI_DUP)
-: 17:#pragma _CRI duplicate MPI_Type_get_attr as PMPI_Type_get_attr
-: 18:#endif
-: 19:/* -- End Profiling Symbol Block */
-: 20:
-: 21:/* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build
-: 22: the MPI routines */
-: 23:#ifndef MPICH_MPI_FROM_PMPI
-: 24:#undef MPI_Type_get_attr
-: 25:#define MPI_Type_get_attr PMPI_Type_get_attr
-: 26:
-: 27:#undef FUNCNAME
-: 28:#define FUNCNAME MPIR_TypeGetAttr
-: 29:
-: 30:int MPIR_TypeGetAttr( MPI_Datatype type, int type_keyval, void *attribute_val,
-: 31: int *flag, MPIR_AttrType outAttrType )
34: 32:{
|
-: 33:#ifdef HAVE_ERROR_CHECKING
-: 34: static const char FCNAME[] = "MPI_Type_get_attr";
-: 35:#endif
|
34: 36: int mpi_errno = MPI_SUCCESS;
34: 37: MPID_Datatype *type_ptr = NULL;
-: 38: MPID_Attribute *p;
34: 39: MPIU_THREADPRIV_DECL;
-: 40: MPID_MPI_STATE_DECL(MPID_STATE_MPIR_TYPE_GET_ATTR);
-: 41:
34: 42: MPIR_ERRTEST_INITIALIZED_ORDIE();
-: 43:
34: 44: MPIU_THREAD_CS_ENTER(ALLFUNC,);
-: 45: MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_TYPE_GET_ATTR);
-: 46:
-: 47: /* Validate parameters, especially handles needing to be converted */
|
-: 48:# ifdef HAVE_ERROR_CHECKING
-: 49: {
-: 50: MPID_BEGIN_ERROR_CHECKS;
-: 51: {
34: 52: MPIR_ERRTEST_DATATYPE(type, "datatype", mpi_errno);
34: 53: MPIR_ERRTEST_KEYVAL(type_keyval, MPID_DATATYPE, "datatype", mpi_errno);
-: 54:# ifdef NEEDS_POINTER_ALIGNMENT_ADJUST
-: 55: /* A common user error is to pass the address of a 4-byte
-: 56: int when the address of a pointer (or an address-sized int)
-: 57: should have been used. We can test for this specific
-: 58: case. Note that this code assumes sizeof(MPIR_Pint) is
-: 59: a power of 2. */
-: 60: if ((MPIR_Pint)attribute_val & (sizeof(MPIR_Pint)-1)) {
-: 61: MPIU_ERR_SET(mpi_errno,MPI_ERR_ARG,"**attrnotptr");
-: 62: }
-: 63:# endif
34: 64: if (mpi_errno != MPI_SUCCESS) goto fn_fail;
-: 65: }
-: 66: MPID_END_ERROR_CHECKS;
-: 67: }
-: 68:# endif
-: 69:
-: 70: /* Convert MPI object handles to object pointers */
|
34: 71: MPID_Datatype_get_ptr( type, type_ptr );
-: 72:
-: 73: /* Validate parameters and objects (post conversion) */
|
-: 74:# ifdef HAVE_ERROR_CHECKING
-: 75: {
-: 76: MPID_BEGIN_ERROR_CHECKS;
-: 77: {
-: 78: /* Validate datatype pointer */
34: 79: MPID_Datatype_valid_ptr( type_ptr, mpi_errno );
-: 80: /* If type_ptr is not valid, it will be reset to null */
34: 81: if (mpi_errno) goto fn_fail;
-: 82: }
-: 83: MPID_END_ERROR_CHECKS;
-: 84: }
-: 85:# endif /* HAVE_ERROR_CHECKING */
-: 86:
-: 87: /* ... body of routine ... */
-: 88:
|
34: 89: *flag = 0;
34: 90: p = type_ptr->attributes;
77: 91: while (p) {
27: 92: if (p->keyval->handle == type_keyval) {
18: 93: *flag = 1;
18: 94: if (outAttrType == MPIR_ATTR_PTR) {
9: 95: if (p->attrType == MPIR_ATTR_INT) {
-: 96: /* This is the tricky case: if the system is
-: 97: bigendian, and we have to return a pointer to
-: 98: an int, then we may need to point to the
-: 99: correct location in the word. */
-: 100:#if defined(WORDS_LITTLEENDIAN) || (SIZEOF_VOID_P == SIZEOF_INT)
|
#####: 101: *(void**)attribute_val = &(p->value);
-: 102:#else
-: 103: int *p_loc = (int *)&(p->value);
-: 104:#if SIZEOF_VOID_P == 2 * SIZEOF_INT
-: 105: p_loc++;
-: 106:#else
-: 107:#error Expected sizeof(void*) to be either sizeof(int) or 2*sizeof(int)
-: 108:#endif
-: 109: *(void **)attribute_val = p_loc;
-: 110:#endif
-: 111: }
|
9: 112: else if (p->attrType == MPIR_ATTR_AINT) {
|
#####: 113: *(void**)attribute_val = &(p->value);
-: 114: }
-: 115: else {
|
9: 116: *(void**)attribute_val = (void *)(p->value);
-: 117: }
-: 118: }
-: 119: else
9: 120: *(void**)attribute_val = (void *)(p->value);
-: 121:
-: 122: break;
-: 123: }
9: 124: p = p->next;
-: 125: }
-: 126:
-: 127: /* ... end of body of routine ... */
-: 128:
|
-: 129:#ifdef HAVE_ERROR_CHECKING
34: 130: fn_exit:
-: 131:#endif
-: 132: MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_TYPE_GET_ATTR);
|
34: 133: MPIU_THREAD_CS_EXIT(ALLFUNC,);
34: 134: return mpi_errno;
-: 135:
|
-: 136: /* --BEGIN ERROR HANDLING-- */
-: 137:# ifdef HAVE_ERROR_CHECKING
#####: 138: fn_fail:
-: 139: {
#####: 140: mpi_errno = MPIR_Err_create_code(
-: 141: mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER,
-: 142: "**mpir_type_get_attr",
-: 143: "**mpir_type_get_attr %D %d %p %p",
-: 144: type, type_keyval, attribute_val, flag);
-: 145: }
#####: 146: mpi_errno = MPIR_Err_return_comm( NULL, FCNAME, mpi_errno );
#####: 147: goto fn_exit;
-: 148:# endif
-: 149: /* --END ERROR HANDLING-- */
-: 150:}
-: 151:#endif
-: 152:
-: 153:#undef FUNCNAME
-: 154:#define FUNCNAME MPI_Type_get_attr
-: 155:#undef FCNAME
-: 156:#define FCNAME MPIU_QUOTE(FUNCNAME)
-: 157:
-: 158:/*@
-: 159: MPI_Type_get_attr - Retrieves attribute value by key
-: 160:
-: 161: Input Parameters:
-: 162:+ type - datatype to which the attribute is attached (handle)
-: 163:- type_keyval - key value (integer)
-: 164:
-: 165: Output Parameters:
-: 166:+ attribute_val - attribute value, unless flag = false
-: 167:- flag - false if no attribute is associated with the key (logical)
-: 168:
-: 169: Notes:
-: 170: Attributes must be extracted from the same language as they were inserted
-: 171: in with 'MPI_Type_set_attr'. The notes for C and Fortran below explain
-: 172: why.
-: 173:
-: 174:Notes for C:
-: 175: Even though the 'attr_value' arguement is declared as 'void *', it is
-: 176: really the address of a void pointer. See the rationale in the
-: 177: standard for more details.
-: 178:
-: 179:.N ThreadSafe
-: 180:
-: 181:.N Fortran
-: 182:
-: 183:.N Errors
-: 184:.N MPI_SUCCESS
-: 185:.N MPI_ERR_KEYVAL
-: 186:.N MPI_ERR_ARG
-: 187:@*/
-: 188:int MPI_Type_get_attr(MPI_Datatype type, int type_keyval, void *attribute_val,
-: 189: int *flag)
|
18: 190:{
18: 191: int mpi_errno = MPI_SUCCESS;
-: 192: MPID_MPI_STATE_DECL(MPID_STATE_MPI_TYPE_GET_ATTR);
-: 193:
18: 194: MPIR_ERRTEST_INITIALIZED_ORDIE();
-: 195:
-: 196: MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_TYPE_GET_ATTR);
-: 197:
-: 198: /* ... body of routine ... */
18: 199: mpi_errno = MPIR_TypeGetAttr( type, type_keyval, attribute_val, flag,
-: 200: MPIR_ATTR_PTR );
|
18: 201: if (mpi_errno) goto fn_fail;
-: 202:
-: 203: /* ... end of body of routine ... */
-: 204:
|
18: 205: fn_exit:
|
-: 206: MPID_MPI_FUNC_EXIT(MPID_STATE_MPI_TYPE_GET_ATTR);
|
18: 207: return mpi_errno;
-: 208:
|
-: 209: /* --BEGIN ERROR HANDLING-- */
#####: 210: fn_fail:
-: 211:#ifdef HAVE_ERROR_CHECKING
-: 212: {
#####: 213: mpi_errno = MPIR_Err_create_code(
-: 214: mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER,
-: 215: "**mpi_type_get_attr",
-: 216: "**mpi_type_get_attr %D %d %p %p",
-: 217: type, type_keyval, attribute_val, flag);
-: 218: }
#####: 219: mpi_errno = MPIR_Err_return_comm( NULL, FCNAME, mpi_errno );
-: 220:#endif
#####: 221: goto fn_exit;
-: 222: /* --END ERROR HANDLING-- */
-: 223:}
|