void MPIDI_Datatype_printf(MPI_Datatype type, int depth, MPI_Aint displacement, int blocklength, int header) { #ifdef MPL_USE_DBG_LOGGING char *string; MPI_Aint size; MPI_Aint extent, true_lb, true_ub, lb, ub, sticky_lb, sticky_ub; if (HANDLE_GET_KIND(type) == HANDLE_KIND_BUILTIN) { string = MPIDU_Datatype_builtin_to_string(type); if (type == MPI_LB) sticky_lb = 1; else sticky_lb = 0; if (type == MPI_UB) sticky_ub = 1; else sticky_ub = 0; } else { MPIDU_Datatype *type_ptr; MPIDU_Datatype_get_ptr(type, type_ptr); string = MPIDU_Datatype_combiner_to_string(type_ptr->contents->combiner); sticky_lb = type_ptr->has_sticky_lb; sticky_ub = type_ptr->has_sticky_ub; } MPIDU_Datatype_get_size_macro(type, size); MPIR_Type_get_true_extent_impl(type, &true_lb, &extent); true_ub = extent + true_lb; MPIR_Type_get_extent_impl(type, &lb, &extent); ub = extent + lb; if (header == 1) { /* 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 */ MPL_DBG_OUT(MPIR_DBG_DATATYPE,"------------------------------------------------------------------------------------------------------------------------------------------\n"); MPL_DBG_OUT(MPIR_DBG_DATATYPE,"depth type size extent true_lb true_ub lb(s) ub(s) disp blklen\n"); MPL_DBG_OUT(MPIR_DBG_DATATYPE,"------------------------------------------------------------------------------------------------------------------------------------------\n"); } MPL_DBG_OUT_FMT(MPIR_DBG_DATATYPE,(MPL_DBG_FDEST,"%5d %21s %11d " MPI_AINT_FMT_DEC_SPEC " " MPI_AINT_FMT_DEC_SPEC " " MPI_AINT_FMT_DEC_SPEC " " MPI_AINT_FMT_DEC_SPEC "(" MPI_AINT_FMT_DEC_SPEC ") " MPI_AINT_FMT_DEC_SPEC "(" MPI_AINT_FMT_DEC_SPEC ") " MPI_AINT_FMT_DEC_SPEC " %11d", depth, string, (int) size, (MPI_Aint) extent, (MPI_Aint) true_lb, (MPI_Aint) true_ub, (MPI_Aint) lb, (MPI_Aint) sticky_lb, (MPI_Aint) ub, (MPI_Aint) sticky_ub, (MPI_Aint) displacement, (int) blocklength)); #endif return; }
int MPIR_Type_contiguous_x_impl(MPI_Count count, MPI_Datatype oldtype, MPI_Datatype *newtype) { /* to make 'count' fit MPI-3 type processing routines (which take integer * counts), we construct a type consisting of N INT_MAX chunks followed by * a remainder. e.g for a count of 4000000000 bytes you would end up with * one 2147483647-byte chunk followed immediately by a 1852516353-byte * chunk */ MPI_Datatype chunks, remainder; MPI_Aint lb, extent, disps[2]; int blocklens[2]; MPI_Datatype types[2]; int mpi_errno; /* truly stupendously large counts will overflow an integer with this math, * but that is a problem for a few decades from now. Sorry, few decades * from now! */ MPIR_Assert(count/INT_MAX == (int)(count/INT_MAX)); int c = (int)(count/INT_MAX); /* OK to cast until 'count' is 256 bits */ int r = count%INT_MAX; mpi_errno = MPIR_Type_vector_impl(c, INT_MAX, INT_MAX, oldtype, &chunks); if (mpi_errno != MPI_SUCCESS) goto fn_fail; mpi_errno = MPIR_Type_contiguous_impl(r, oldtype, &remainder); if (mpi_errno != MPI_SUCCESS) goto fn_fail; MPIR_Type_get_extent_impl(oldtype, &lb, &extent); blocklens[0] = 1; blocklens[1] = 1; disps[0] = 0; disps[1] = c*extent*INT_MAX; types[0] = chunks; types[1] = remainder; mpi_errno = MPIR_Type_create_struct_impl(2, blocklens, disps, types, newtype); MPIR_Type_free_impl(&chunks); MPIR_Type_free_impl(&remainder); fn_exit: return mpi_errno; fn_fail: goto fn_exit; }
/*@ MPI_Type_get_extent - Get the lower bound and extent for a Datatype Input Parameters: . datatype - datatype to get information on (handle) Output Parameters: + lb - lower bound of datatype (address integer) - extent - extent of datatype (address integer) .N SignalSafe .N Fortran .N Errors .N MPI_SUCCESS .N MPI_ERR_ARG .N MPI_ERR_TYPE @*/ int MPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint *lb, MPI_Aint *extent) { int mpi_errno = MPI_SUCCESS; MPIR_FUNC_TERSE_STATE_DECL(MPID_STATE_MPI_TYPE_GET_EXTENT); MPIR_ERRTEST_INITIALIZED_ORDIE(); MPIR_FUNC_TERSE_ENTER(MPID_STATE_MPI_TYPE_GET_EXTENT); /* Validate parameters, especially handles needing to be converted */ # ifdef HAVE_ERROR_CHECKING { MPID_BEGIN_ERROR_CHECKS; { MPIR_ERRTEST_DATATYPE(datatype, "datatype", mpi_errno); } MPID_END_ERROR_CHECKS; } # endif /* Validate parameters and objects (post conversion) */ # ifdef HAVE_ERROR_CHECKING { MPID_BEGIN_ERROR_CHECKS; { MPIR_Datatype *datatype_ptr = NULL; /* Convert MPI object handles to object pointers */ MPID_Datatype_get_ptr(datatype, datatype_ptr); /* Validate datatype_ptr */ MPIR_Datatype_valid_ptr(datatype_ptr, mpi_errno); if (mpi_errno) goto fn_fail; } MPID_END_ERROR_CHECKS; } # endif /* HAVE_ERROR_CHECKING */ /* ... body of routine ... */ MPIR_Type_get_extent_impl(datatype, lb, extent); /* ... end of body of routine ... */ #ifdef HAVE_ERROR_CHECKING fn_exit: #endif MPIR_FUNC_TERSE_EXIT(MPID_STATE_MPI_TYPE_GET_EXTENT); return mpi_errno; /* --BEGIN ERROR HANDLING-- */ # ifdef HAVE_ERROR_CHECKING fn_fail: { mpi_errno = MPIR_Err_create_code( mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER, "**mpi_type_get_extent", "**mpi_type_get_extent %D %p %p", datatype, lb, extent); } mpi_errno = MPIR_Err_return_comm(NULL, FCNAME, mpi_errno); goto fn_exit; # endif /* --END ERROR HANDLING-- */ }