-: 0:Source:/home/MPI/testing/mpich2/mpich2/src/mpi/datatype/pack_external.c
-: 0:Graph:pack_external.gcno
-: 0:Data:pack_external.gcda
-: 0:Runs:510
-: 0:Programs:137
-: 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:
-: 10:/* -- Begin Profiling Symbol Block for routine MPI_Pack_external */
-: 11:#if defined(HAVE_PRAGMA_WEAK)
-: 12:#pragma weak MPI_Pack_external = PMPI_Pack_external
-: 13:#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
-: 14:#pragma _HP_SECONDARY_DEF PMPI_Pack_external MPI_Pack_external
-: 15:#elif defined(HAVE_PRAGMA_CRI_DUP)
-: 16:#pragma _CRI duplicate MPI_Pack_external as PMPI_Pack_external
-: 17:#endif
-: 18:/* -- End Profiling Symbol Block */
-: 19:
-: 20:/* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build
-: 21: the MPI routines */
-: 22:#ifndef MPICH_MPI_FROM_PMPI
-: 23:#undef MPI_Pack_external
-: 24:#define MPI_Pack_external PMPI_Pack_external
-: 25:
-: 26:#endif
-: 27:
-: 28:#undef FUNCNAME
-: 29:#define FUNCNAME MPI_Pack_external
-: 30:
-: 31:/*@
-: 32: MPI_Pack_external - Packs a datatype into contiguous memory, using the
-: 33: external32 format
-: 34:
-: 35: Input Parameters:
-: 36:+ datarep - data representation (string)
-: 37:. inbuf - input buffer start (choice)
-: 38:. incount - number of input data items (integer)
-: 39:. datatype - datatype of each input data item (handle)
-: 40:- outcount - output buffer size, in bytes (address integer)
-: 41:
-: 42: Output Parameter:
-: 43:. outbuf - output buffer start (choice)
-: 44:
-: 45: Input/Output Parameter:
-: 46:. position - current position in buffer, in bytes (address integer)
-: 47:
-: 48:.N ThreadSafe
-: 49:
-: 50:.N Fortran
-: 51:
-: 52:.N Errors
-: 53:.N MPI_SUCCESS
-: 54:.N MPI_ERR_TYPE
-: 55:.N MPI_ERR_ARG
-: 56:.N MPI_ERR_COUNT
-: 57:@*/
-: 58:int MPI_Pack_external(char *datarep,
-: 59: void *inbuf,
-: 60: int incount,
-: 61: MPI_Datatype datatype,
-: 62: void *outbuf,
-: 63: MPI_Aint outcount,
-: 64: MPI_Aint *position)
4: 65:{
-: 66: static const char FCNAME[] = "MPI_Pack_external";
4: 67: int mpi_errno = MPI_SUCCESS;
-: 68: MPI_Aint first, last;
-: 69:
-: 70: MPID_Segment *segp;
-: 71: MPID_MPI_STATE_DECL(MPID_STATE_MPI_PACK_EXTERNAL);
-: 72:
4: 73: MPIR_ERRTEST_INITIALIZED_ORDIE();
-: 74:
-: 75: MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_PACK_EXTERNAL);
-: 76:
-: 77: /* Validate parameters and objects (post conversion) */
|
-: 78:# ifdef HAVE_ERROR_CHECKING
-: 79: {
-: 80: MPID_BEGIN_ERROR_CHECKS;
-: 81: {
4: 82: MPIR_ERRTEST_COUNT(incount, mpi_errno);
4: 83: MPIR_ERRTEST_COUNT(outcount, mpi_errno);
-: 84: /* NOTE: inbuf could be null (MPI_BOTTOM) */
4: 85: if (incount > 0) {
4: 86: MPIR_ERRTEST_ARGNULL(outbuf, "output buffer", mpi_errno);
-: 87: }
4: 88: MPIR_ERRTEST_ARGNULL(position, "position", mpi_errno);
4: 89: if (mpi_errno != MPI_SUCCESS) goto fn_fail;
-: 90:
4: 91: MPIR_ERRTEST_DATATYPE(datatype, "datatype", mpi_errno);
4: 92: if (mpi_errno == MPI_SUCCESS) {
4: 93: if (HANDLE_GET_KIND(datatype) != HANDLE_KIND_BUILTIN) {
#####: 94: MPID_Datatype *datatype_ptr = NULL;
-: 95:
#####: 96: MPID_Datatype_get_ptr(datatype, datatype_ptr);
#####: 97: MPID_Datatype_valid_ptr(datatype_ptr, mpi_errno);
#####: 98: MPID_Datatype_committed_ptr(datatype_ptr, mpi_errno);
-: 99: }
-: 100: }
4: 101: if (mpi_errno != MPI_SUCCESS) goto fn_fail;
-: 102: }
-: 103: MPID_END_ERROR_CHECKS;
-: 104: }
-: 105:# endif /* HAVE_ERROR_CHECKING */
-: 106:
-: 107: /* ... body of routine ... */
|
4: 108: if (incount == 0) {
|
#####: 109: goto fn_exit;
-: 110: }
-: 111:
|
4: 112: segp = MPID_Segment_alloc();
|
-: 113: /* --BEGIN ERROR HANDLING-- */
4: 114: if (segp == NULL)
-: 115: {
#####: 116: mpi_errno = MPIR_Err_create_code(MPI_SUCCESS,
-: 117: MPIR_ERR_RECOVERABLE,
-: 118: FCNAME,
-: 119: __LINE__,
-: 120: MPI_ERR_OTHER,
-: 121: "**nomem",
-: 122: "**nomem %s",
-: 123: "MPID_Segment");
#####: 124: goto fn_fail;
-: 125: }
-: 126: /* --END ERROR HANDLING-- */
|
4: 127: mpi_errno = MPID_Segment_init(inbuf, incount, datatype, segp, 1);
|
4: 128: if (mpi_errno != MPI_SUCCESS) goto fn_fail;
-: 129:
-: 130: /* NOTE: the use of buffer values and positions in MPI_Pack_external and
-: 131: * in MPID_Segment_pack_external are quite different. See code or docs
-: 132: * or something.
-: 133: */
|
4: 134: first = 0;
4: 135: last = SEGMENT_IGNORE_LAST;
-: 136:
-: 137: /* Ensure that pointer increment fits in a pointer */
-: 138: MPID_Ensure_Aint_fits_in_pointer((MPI_VOID_PTR_CAST_TO_MPI_AINT outbuf) + *position);
-: 139:
4: 140: MPID_Segment_pack_external32(segp,
-: 141: first,
-: 142: &last,
-: 143: (void *)((char *) outbuf + *position));
-: 144:
4: 145: *position += last;
-: 146:
4: 147: MPID_Segment_free(segp);
-: 148:
-: 149: /* ... end of body of routine ... */
-: 150:
4: 151: fn_exit:
|
-: 152: MPID_MPI_FUNC_EXIT(MPID_STATE_MPI_PACK_EXTERNAL);
|
4: 153: return mpi_errno;
-: 154:
|
#####: 155: fn_fail:
-: 156: /* --BEGIN ERROR HANDLING-- */
-: 157:# ifdef HAVE_ERROR_CHECKING
-: 158: {
#####: 159: mpi_errno = MPIR_Err_create_code(
-: 160: mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER, "**mpi_pack_external",
-: 161: "**mpi_pack_external %s %p %d %D %p %d %p", datarep, inbuf, incount, datatype, outbuf, outcount, position);
-: 162: }
-: 163:# endif
#####: 164: mpi_errno = MPIR_Err_return_comm(0, FCNAME, mpi_errno);
#####: 165: goto fn_exit;
-: 166: /* --END ERROR HANDLING-- */
-: 167:}
|