-:    0:Source:/home/MPI/testing/mpich2/mpich2/src/mpid/common/datatype/mpid_type_debug.c
        -:    0:Graph:mpid_type_debug.gcno
        -:    0:Data:mpid_type_debug.gcda
        -:    0:Runs:3459
        -:    0:Programs:899
        -:    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 "mpid_dataloop.h"
        -:   10:#include <stdlib.h>
        -:   11:#include <limits.h>
        -:   12:
        -:   13:/* MPI datatype debugging helper routines.
        -:   14: *
        -:   15: * The one you want to call is:
        -:   16: *   MPIDU_Datatype_debug(MPI_Datatype type, int array_ct)
        -:   17: *
        -:   18: * The "array_ct" value tells the call how many array values to print
        -:   19: * for struct, indexed, and blockindexed types.
        -:   20: *
        -:   21: */
        -:   22:
        -:   23:
        -:   24:void MPIDI_Datatype_dot_printf(MPI_Datatype type, int depth, int header);
        -:   25:void MPIDI_Dataloop_dot_printf(MPID_Dataloop *loop_p, int depth, int header);
        -:   26:void MPIDI_Datatype_contents_printf(MPI_Datatype type, int depth, int acount);
        -:   27:static char *MPIDI_Datatype_depth_spacing(int depth) ATTRIBUTE((unused));
        -:   28:
        -:   29:/* note: this isn't really "error handling" per se, but leave these comments
        -:   30: * because Bill uses them for coverage analysis.
        -:   31: */
        -:   32:
        -:   33:/* --BEGIN ERROR HANDLING-- */
        -:   34:void MPIDI_Datatype_dot_printf(MPI_Datatype type,
        -:   35:			       int depth,
        -:   36:			       int header)
    #####:   37:{
    #####:   38:    if (HANDLE_GET_KIND(type) == HANDLE_KIND_BUILTIN) {
        -:   39:	MPIU_DBG_OUT(DATATYPE,
        -:   40:			 "MPIDI_Datatype_dot_printf: type is a basic");
    #####:   41:	return;
        -:   42:    }
        -:   43:    else {
        -:   44:	MPID_Datatype *dt_p;
        -:   45:	MPID_Dataloop *loop_p;
        -:   46:
    #####:   47:	MPID_Datatype_get_ptr(type, dt_p);
    #####:   48:	loop_p = dt_p->dataloop;
        -:   49:
    #####:   50:	MPIDI_Dataloop_dot_printf(loop_p, depth, header);
    #####:   51:	return;
        -:   52:    }
        -:   53:}
        -:   54:
        -:   55:void MPIDI_Dataloop_dot_printf(MPID_Dataloop *loop_p,
        -:   56:			       int depth,
        -:   57:			       int header)
    #####:   58:{
        -:   59:    int i;
        -:   60:
    #####:   61:    if (loop_p == NULL) {
        -:   62:	MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,"<null dataloop>\n"));
    #####:   63:	return;
        -:   64:    }
        -:   65:
        -:   66:    if (header) {
        -:   67:	MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,
        -:   68:				   "digraph %p {   {", loop_p));
        -:   69:    }
        -:   70:
    #####:   71:    switch (loop_p->kind & DLOOP_KIND_MASK) {
        -:   72:	case DLOOP_KIND_CONTIG:
        -:   73:	    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,
        -:   74:	    "      dl%d [shape = record, label = \"contig |{ ct = %d; el_sz = " MPI_AINT_FMT_DEC_SPEC "; el_ext = " MPI_AINT_FMT_DEC_SPEC " }\"];",
        -:   75:			    depth,
        -:   76:			    (int) loop_p->loop_params.c_t.count,
        -:   77:			    (MPI_Aint) loop_p->el_size,
        -:   78:			    (MPI_Aint) loop_p->el_extent));
        -:   79:	    break;
        -:   80:	case DLOOP_KIND_VECTOR:
        -:   81:	    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,
        -:   82:	    "      dl%d [shape = record, label = \"vector |{ ct = %d; blk = %d; str = " MPI_AINT_FMT_DEC_SPEC "; el_sz = " MPI_AINT_FMT_DEC_SPEC "; el_ext =  "MPI_AINT_FMT_DEC_SPEC " }\"];",
        -:   83:			    depth,
        -:   84:			    (int) loop_p->loop_params.v_t.count,
        -:   85:			    (int) loop_p->loop_params.v_t.blocksize,
        -:   86:			    (MPI_Aint) loop_p->loop_params.v_t.stride,
        -:   87:			    (MPI_Aint) loop_p->el_size,
        -:   88:			    (MPI_Aint) loop_p->el_extent));
        -:   89:	    break;
        -:   90:	case DLOOP_KIND_INDEXED:
        -:   91:	    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,
        -:   92:	    "      dl%d [shape = record, label = \"indexed |{ ct = %d; tot_blks = %d; regions = ",
        -:   93:			    depth,
        -:   94:			    (int) loop_p->loop_params.i_t.count,
        -:   95:			    (int) loop_p->loop_params.i_t.total_blocks));
        -:   96:
        -:   97:	    /* 3 picked as arbitrary cutoff */
    #####:   98:	    for (i=0; i < 3 && i < loop_p->loop_params.i_t.count; i++) {
    #####:   99:		if (i + 1 < loop_p->loop_params.i_t.count) {
        -:  100:		    /* more regions after this one */
        -:  101:		    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,
        -:  102:		    "(" MPI_AINT_FMT_DEC_SPEC ", %d), ",
        -:  103:			  (MPI_Aint) loop_p->loop_params.i_t.offset_array[i],
        -:  104:		          (int) loop_p->loop_params.i_t.blocksize_array[i]));
        -:  105:		}
        -:  106:		else {
        -:  107:		    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,
        -:  108:		           "(" MPI_AINT_FMT_DEC_SPEC ", %d); ",
        -:  109:		           (MPI_Aint) loop_p->loop_params.i_t.offset_array[i],
        -:  110:			   (int) loop_p->loop_params.i_t.blocksize_array[i]));
        -:  111:		}
        -:  112:	    }
    #####:  113:	    if (i < loop_p->loop_params.i_t.count) {
        -:  114:		MPIU_DBG_OUT(DATATYPE,"...; ");
        -:  115:	    }
        -:  116:
        -:  117:	    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,
        -:  118:				       "el_sz = " MPI_AINT_FMT_DEC_SPEC "; el_ext = " MPI_AINT_FMT_DEC_SPEC " }\"];\n",
        -:  119:				       (MPI_Aint) loop_p->el_size,
        -:  120:				       (MPI_Aint) loop_p->el_extent));
    #####:  121:	    break;
        -:  122:	case DLOOP_KIND_BLOCKINDEXED:
        -:  123:	    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,
        -:  124:	    "      dl%d [shape = record, label = \"blockindexed |{ ct = %d; blk = %d; disps = ",
        -:  125:			    depth,
        -:  126:			    (int) loop_p->loop_params.bi_t.count,
        -:  127:			    (int) loop_p->loop_params.bi_t.blocksize));
        -:  128:
        -:  129:	    /* 3 picked as arbitrary cutoff */
    #####:  130:	    for (i=0; i < 3 && i < loop_p->loop_params.bi_t.count; i++) {
    #####:  131:		if (i + 1 < loop_p->loop_params.bi_t.count) {
        -:  132:		    /* more regions after this one */
        -:  133:		    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,
        -:  134:		        MPI_AINT_FMT_DEC_SPEC ", ",
        -:  135:			(MPI_Aint) loop_p->loop_params.bi_t.offset_array[i]));
        -:  136:		}
        -:  137:		else {
        -:  138:		    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,
        -:  139:		         MPI_AINT_FMT_DEC_SPEC "; ",
        -:  140:		         (MPI_Aint) loop_p->loop_params.bi_t.offset_array[i]));
        -:  141:		}
        -:  142:	    }
    #####:  143:	    if (i < loop_p->loop_params.bi_t.count) {
        -:  144:		MPIU_DBG_OUT(DATATYPE,"...; ");
        -:  145:	    }
        -:  146:
        -:  147:	    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,
        -:  148:				      "el_sz = " MPI_AINT_FMT_DEC_SPEC "; el_ext = " MPI_AINT_FMT_DEC_SPEC " }\"];",
        -:  149:				       (MPI_Aint) loop_p->el_size,
        -:  150:				       (MPI_Aint) loop_p->el_extent));
    #####:  151:	    break;
        -:  152:	case DLOOP_KIND_STRUCT:
        -:  153:	    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,
        -:  154:	    "      dl%d [shape = record, label = \"struct | {ct = %d; blks = ",
        -:  155:			    depth,
        -:  156:			    (int) loop_p->loop_params.s_t.count));
    #####:  157:	    for (i=0; i < 3 && i < loop_p->loop_params.s_t.count; i++) {
    #####:  158:		if (i + 1 < loop_p->loop_params.s_t.count) {
        -:  159:		    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,"%d, ",
        -:  160:			    (int) loop_p->loop_params.s_t.blocksize_array[i]));
        -:  161:		}
        -:  162:		else {
        -:  163:		    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,"%d; ",
        -:  164:			    (int) loop_p->loop_params.s_t.blocksize_array[i]));
        -:  165:		}
        -:  166:	    }
    #####:  167:	    if (i < loop_p->loop_params.s_t.count) {
        -:  168:		MPIU_DBG_OUT(DATATYPE,"...; disps = ");
        -:  169:	    }
        -:  170:	    else {
        -:  171:		MPIU_DBG_OUT(DATATYPE,"disps = ");
        -:  172:	    }
        -:  173:
    #####:  174:	    for (i=0; i < 3 && i < loop_p->loop_params.s_t.count; i++) {
    #####:  175:		if (i + 1 < loop_p->loop_params.s_t.count) {
        -:  176:		    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,MPI_AINT_FMT_DEC_SPEC ", ",
        -:  177:			    (MPI_Aint) loop_p->loop_params.s_t.offset_array[i]));
        -:  178:		}
        -:  179:		else {
        -:  180:		    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,MPI_AINT_FMT_DEC_SPEC "; ",
        -:  181:			    (MPI_Aint) loop_p->loop_params.s_t.offset_array[i]));
        -:  182:		}
        -:  183:	    }
    #####:  184:	    if (i < loop_p->loop_params.s_t.count) {
        -:  185:		MPIU_DBG_OUT(DATATYPE,"... }\"];");
        -:  186:	    }
        -:  187:	    else {
        -:  188:		MPIU_DBG_OUT(DATATYPE,"}\"];");
        -:  189:	    }
    #####:  190:	    break;
        -:  191:	default:
    #####:  192:	    MPIU_Assert(0);
        -:  193:    }
        -:  194:
    #####:  195:    if (!(loop_p->kind & DLOOP_FINAL_MASK)) {
        -:  196:	/* more loops to go; recurse */
        -:  197:	MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,
        -:  198:				   "      dl%d -> dl%d;\n", depth, depth + 1));
    #####:  199:	switch (loop_p->kind & DLOOP_KIND_MASK) {
        -:  200:	    case DLOOP_KIND_CONTIG:
    #####:  201:		MPIDI_Dataloop_dot_printf(loop_p->loop_params.c_t.dataloop, depth + 1, 0);
    #####:  202:		break;
        -:  203:	    case DLOOP_KIND_VECTOR:
    #####:  204:		MPIDI_Dataloop_dot_printf(loop_p->loop_params.v_t.dataloop, depth + 1, 0);
    #####:  205:		break;
        -:  206:	    case DLOOP_KIND_INDEXED:
    #####:  207:		MPIDI_Dataloop_dot_printf(loop_p->loop_params.i_t.dataloop, depth + 1, 0);
    #####:  208:		break;
        -:  209:	    case DLOOP_KIND_BLOCKINDEXED:
    #####:  210:		MPIDI_Dataloop_dot_printf(loop_p->loop_params.bi_t.dataloop, depth + 1, 0);
    #####:  211:		break;
        -:  212:	    case DLOOP_KIND_STRUCT:
    #####:  213:		for (i=0; i < loop_p->loop_params.s_t.count; i++) {
    #####:  214:		    MPIDI_Dataloop_dot_printf(loop_p->loop_params.s_t.dataloop_array[i],
        -:  215:					      depth + 1, 0);
        -:  216:		}
        -:  217:		break;
        -:  218:	    default:
        -:  219:		MPIU_DBG_OUT(DATATYPE,"      < unsupported type >");
        -:  220:	}
        -:  221:    }
        -:  222:
        -:  223:
        -:  224:    if (header) {
        -:  225:	MPIU_DBG_OUT(DATATYPE,"   }\n}");
        -:  226:    }
        -:  227:    return;
        -:  228:}
        -:  229:
        -:  230:void MPIDI_Datatype_printf(MPI_Datatype type,
        -:  231:			   int depth,
        -:  232:			   MPI_Aint displacement,
        -:  233:			   int blocklength,
        -:  234:			   int header)
    #####:  235:{
        -:  236:    char *string;
        -:  237:    int size;
        -:  238:    MPI_Aint extent, true_lb, true_ub, lb, ub, sticky_lb, sticky_ub;
    #####:  239:    MPIU_THREADPRIV_DECL;
        -:  240:
    #####:  241:    MPIU_THREADPRIV_GET;
        -:  242:
    #####:  243:    if (HANDLE_GET_KIND(type) == HANDLE_KIND_BUILTIN) {
    #####:  244:	string = MPIDU_Datatype_builtin_to_string(type);
    #####:  245:	if (type == MPI_LB) sticky_lb = 1;
    #####:  246:	else sticky_lb = 0;
    #####:  247:	if (type == MPI_UB) sticky_ub = 1;
    #####:  248:	else sticky_ub = 0;
        -:  249:    }
        -:  250:    else {
        -:  251:	MPID_Datatype *type_ptr;
        -:  252:
    #####:  253:	MPID_Datatype_get_ptr(type, type_ptr);
    #####:  254:	string = MPIDU_Datatype_combiner_to_string(type_ptr->contents->combiner);
    #####:  255:	sticky_lb = type_ptr->has_sticky_lb;
    #####:  256:	sticky_ub = type_ptr->has_sticky_ub;
        -:  257:    }
        -:  258:
    #####:  259:    MPIR_Nest_incr();
    #####:  260:    NMPI_Type_size(type, &size);
    #####:  261:    NMPI_Type_get_true_extent(type, &true_lb, &extent);
    #####:  262:    true_ub = extent + true_lb;
    #####:  263:    NMPI_Type_get_extent(type, &lb, &extent);
    #####:  264:    ub = extent + lb;
    #####:  265:    MPIR_Nest_decr();
        -:  266:
        -:  267:    if (header == 1) {
        -:  268:	/*               012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 */
        -:  269:	MPIU_DBG_OUT(DATATYPE,"------------------------------------------------------------------------------------------------------------------------------------------\n");
        -:  270:	MPIU_DBG_OUT(DATATYPE,"depth                   type         size       extent      true_lb      true_ub           lb(s)           ub(s)         disp       blklen\n");
        -:  271:	MPIU_DBG_OUT(DATATYPE,"------------------------------------------------------------------------------------------------------------------------------------------\n");
        -:  272:    }
        -:  273:    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_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",
        -:  274:		    depth,
        -:  275:		    string,
        -:  276:		    (int) size,
        -:  277:		    (MPI_Aint) extent,
        -:  278:		    (MPI_Aint) true_lb,
        -:  279:		    (MPI_Aint) true_ub,
        -:  280:		    (MPI_Aint) lb,
        -:  281:		    (MPI_Aint) sticky_lb,
        -:  282:		    (MPI_Aint) ub,
        -:  283:		    (MPI_Aint) sticky_ub,
        -:  284:		    (MPI_Aint) displacement,
        -:  285:		    (int) blocklength));
        -:  286:    return;
        -:  287:}
        -:  288:/* --END ERROR HANDLING-- */
        -:  289:
        -:  290:/* longest string is 21 characters */
        -:  291:char *MPIDU_Datatype_builtin_to_string(MPI_Datatype type)
      516:  292:{
        -:  293:    static char t_char[]             = "MPI_CHAR";
        -:  294:    static char t_uchar[]            = "MPI_UNSIGNED_CHAR";
        -:  295:    static char t_byte[]             = "MPI_BYTE";
        -:  296:    static char t_wchar_t[]          = "MPI_WCHAR";
        -:  297:    static char t_short[]            = "MPI_SHORT";
        -:  298:    static char t_ushort[]           = "MPI_UNSIGNED_SHORT";
        -:  299:    static char t_int[]              = "MPI_INT";
        -:  300:    static char t_uint[]             = "MPI_UNSIGNED";
        -:  301:    static char t_long[]             = "MPI_LONG";
        -:  302:    static char t_ulong[]            = "MPI_UNSIGNED_LONG";
        -:  303:    static char t_float[]            = "MPI_FLOAT";
        -:  304:    static char t_double[]           = "MPI_DOUBLE";
        -:  305:    static char t_longdouble[]       = "MPI_LONG_DOUBLE";
        -:  306:    static char t_longlongint[]      = "MPI_LONG_LONG_INT";
        -:  307:    static char t_longlong[]         = "MPI_LONG_LONG";
        -:  308:    static char t_ulonglong[]        = "MPI_UNSIGNED_LONG_LONG";
        -:  309:    static char t_schar[]            = "MPI_SIGNED_CHAR";
        -:  310:
        -:  311:    static char t_packed[]           = "MPI_PACKED";
        -:  312:    static char t_lb[]               = "MPI_LB";
        -:  313:    static char t_ub[]               = "MPI_UB";
        -:  314:
        -:  315:    static char t_floatint[]         = "MPI_FLOAT_INT";
        -:  316:    static char t_doubleint[]        = "MPI_DOUBLE_INT";
        -:  317:    static char t_longint[]          = "MPI_LONG_INT";
        -:  318:    static char t_shortint[]         = "MPI_SHORT_INT";
        -:  319:    static char t_2int[]             = "MPI_2INT";
        -:  320:    static char t_longdoubleint[]    = "MPI_LONG_DOUBLE_INT";
        -:  321:
        -:  322:    static char t_complex[]          = "MPI_COMPLEX";
        -:  323:    static char t_doublecomplex[]    = "MPI_DOUBLE_COMPLEX";
        -:  324:    static char t_logical[]          = "MPI_LOGICAL";
        -:  325:    static char t_real[]             = "MPI_REAL";
        -:  326:    static char t_doubleprecision[]  = "MPI_DOUBLE_PRECISION";
        -:  327:    static char t_integer[]          = "MPI_INTEGER";
        -:  328:    static char t_2integer[]         = "MPI_2INTEGER";
        -:  329:    static char t_2complex[]         = "MPI_2COMPLEX";
        -:  330:    static char t_2doublecomplex[]   = "MPI_2DOUBLE_COMPLEX";
        -:  331:    static char t_2real[]            = "MPI_2REAL";
        -:  332:    static char t_2doubleprecision[] = "MPI_2DOUBLE_PRECISION";
        -:  333:    static char t_character[]        = "MPI_CHARACTER";
        -:  334:
      516:  335:    if (type == MPI_CHAR)              return t_char;
      440:  336:    if (type == MPI_UNSIGNED_CHAR)     return t_uchar;
      434:  337:    if (type == MPI_SIGNED_CHAR)       return t_schar;
      434:  338:    if (type == MPI_BYTE)              return t_byte;
      362:  339:    if (type == MPI_WCHAR)             return t_wchar_t;
      362:  340:    if (type == MPI_SHORT)             return t_short;
      281:  341:    if (type == MPI_UNSIGNED_SHORT)    return t_ushort;
      275:  342:    if (type == MPI_INT)               return t_int;
       99:  343:    if (type == MPI_UNSIGNED)          return t_uint;
       93:  344:    if (type == MPI_LONG)              return t_long;
       87:  345:    if (type == MPI_UNSIGNED_LONG)     return t_ulong;
       81:  346:    if (type == MPI_FLOAT)             return t_float;
       47:  347:    if (type == MPI_DOUBLE)            return t_double;
       13:  348:    if (type == MPI_LONG_DOUBLE)       return t_longdouble;
        7:  349:    if (type == MPI_LONG_LONG_INT)     return t_longlongint;
        7:  350:    if (type == MPI_LONG_LONG)         return t_longlong;
        7:  351:    if (type == MPI_UNSIGNED_LONG_LONG) return t_ulonglong;
        -:  352:	
        7:  353:    if (type == MPI_PACKED)            return t_packed;
        1:  354:    if (type == MPI_LB)                return t_lb;
        1:  355:    if (type == MPI_UB)                return t_ub;
        -:  356:	
        1:  357:    if (type == MPI_FLOAT_INT)         return t_floatint;
        1:  358:    if (type == MPI_DOUBLE_INT)        return t_doubleint;
        1:  359:    if (type == MPI_LONG_INT)          return t_longint;
        1:  360:    if (type == MPI_SHORT_INT)         return t_shortint;
        1:  361:    if (type == MPI_2INT)              return t_2int;
        1:  362:    if (type == MPI_LONG_DOUBLE_INT)   return t_longdoubleint;
        -:  363:	
        1:  364:    if (type == MPI_COMPLEX)           return t_complex;
        1:  365:    if (type == MPI_DOUBLE_COMPLEX)    return t_doublecomplex;
        1:  366:    if (type == MPI_LOGICAL)           return t_logical;
        1:  367:    if (type == MPI_REAL)              return t_real;
    #####:  368:    if (type == MPI_DOUBLE_PRECISION)  return t_doubleprecision;
    #####:  369:    if (type == MPI_INTEGER)           return t_integer;
    #####:  370:    if (type == MPI_2INTEGER)          return t_2integer;
    #####:  371:    if (type == MPI_2COMPLEX)          return t_2complex;
    #####:  372:    if (type == MPI_2DOUBLE_COMPLEX)   return t_2doublecomplex;
    #####:  373:    if (type == MPI_2REAL)             return t_2real;
    #####:  374:    if (type == MPI_2DOUBLE_PRECISION) return t_2doubleprecision;
    #####:  375:    if (type == MPI_CHARACTER)         return t_character;
        -:  376:
    #####:  377:    return NULL;
        -:  378:}
        -:  379:
        -:  380:/* MPIDU_Datatype_combiner_to_string(combiner)
        -:  381: *
        -:  382: * Converts a numeric combiner into a pointer to a string used for printing.
        -:  383: *
        -:  384: * longest string is 16 characters.
        -:  385: */
        -:  386:char *MPIDU_Datatype_combiner_to_string(int combiner)
       13:  387:{
        -:  388:    static char c_named[]    = "named";
        -:  389:    static char c_contig[]   = "contig";
        -:  390:    static char c_vector[]   = "vector";
        -:  391:    static char c_hvector[]  = "hvector";
        -:  392:    static char c_indexed[]  = "indexed";
        -:  393:    static char c_hindexed[] = "hindexed";
        -:  394:    static char c_struct[]   = "struct";
        -:  395:    static char c_dup[]              = "dup";
        -:  396:    static char c_hvector_integer[]  = "hvector_integer";
        -:  397:    static char c_hindexed_integer[] = "hindexed_integer";
        -:  398:    static char c_indexed_block[]    = "indexed_block";
        -:  399:    static char c_struct_integer[]   = "struct_integer";
        -:  400:    static char c_subarray[]         = "subarray";
        -:  401:    static char c_darray[]           = "darray";
        -:  402:    static char c_f90_real[]         = "f90_real";
        -:  403:    static char c_f90_complex[]      = "f90_complex";
        -:  404:    static char c_f90_integer[]      = "f90_integer";
        -:  405:    static char c_resized[]          = "resized";
        -:  406:
       13:  407:    if (combiner == MPI_COMBINER_NAMED)      return c_named;
       13:  408:    if (combiner == MPI_COMBINER_CONTIGUOUS) return c_contig;
        5:  409:    if (combiner == MPI_COMBINER_VECTOR)     return c_vector;
        5:  410:    if (combiner == MPI_COMBINER_HVECTOR)    return c_hvector;
        5:  411:    if (combiner == MPI_COMBINER_INDEXED)    return c_indexed;
        4:  412:    if (combiner == MPI_COMBINER_HINDEXED)   return c_hindexed;
        4:  413:    if (combiner == MPI_COMBINER_STRUCT)     return c_struct;
        4:  414:    if (combiner == MPI_COMBINER_DUP)              return c_dup;
    #####:  415:    if (combiner == MPI_COMBINER_HVECTOR_INTEGER)  return c_hvector_integer;
    #####:  416:    if (combiner == MPI_COMBINER_HINDEXED_INTEGER) return c_hindexed_integer;
    #####:  417:    if (combiner == MPI_COMBINER_INDEXED_BLOCK)    return c_indexed_block;
    #####:  418:    if (combiner == MPI_COMBINER_STRUCT_INTEGER)   return c_struct_integer;
    #####:  419:    if (combiner == MPI_COMBINER_SUBARRAY)         return c_subarray;
    #####:  420:    if (combiner == MPI_COMBINER_DARRAY)           return c_darray;
    #####:  421:    if (combiner == MPI_COMBINER_F90_REAL)         return c_f90_real;
    #####:  422:    if (combiner == MPI_COMBINER_F90_COMPLEX)      return c_f90_complex;
    #####:  423:    if (combiner == MPI_COMBINER_F90_INTEGER)      return c_f90_integer;
    #####:  424:    if (combiner == MPI_COMBINER_RESIZED)          return c_resized;
        -:  425:
    #####:  426:    return NULL;
        -:  427:}
        -:  428:
        -:  429:/* --BEGIN ERROR HANDLING-- */
        -:  430:void MPIDU_Datatype_debug(MPI_Datatype type,
        -:  431:			  int array_ct)
    #####:  432:{
        -:  433:    int is_builtin;
        -:  434:    MPID_Datatype *dtp;
        -:  435:
    #####:  436:    is_builtin = (HANDLE_GET_KIND(type) == HANDLE_KIND_BUILTIN);
        -:  437:
        -:  438:    /* can get a NULL type a number of different ways, including not having
        -:  439:     * fortran support included.
        -:  440:     */
    #####:  441:    if (type == MPI_DATATYPE_NULL) {
        -:  442:	MPIU_DBG_OUT_FMT(DATATYPE,
        -:  443:			 (MPIU_DBG_FDEST,
        -:  444:			  "# MPIU_Datatype_debug: MPI_Datatype = MPI_DATATYPE_NULL"));
    #####:  445:	return;
        -:  446:    }
        -:  447:
        -:  448:    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,
        -:  449:	       "# MPIU_Datatype_debug: MPI_Datatype = 0x%0x (%s)", type,
        -:  450:	       (is_builtin) ? MPIDU_Datatype_builtin_to_string(type) :
        -:  451:	        "derived"));
        -:  452:
    #####:  453:    if (is_builtin) return;
        -:  454:
    #####:  455:    MPID_Datatype_get_ptr(type, dtp);
    #####:  456:    MPIU_Assert(dtp != NULL);
        -:  457:
        -:  458:    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,
        -:  459:      "# Size = %d, Extent = " MPI_AINT_FMT_DEC_SPEC ", LB = " MPI_AINT_FMT_DEC_SPEC "%s, UB = " MPI_AINT_FMT_DEC_SPEC "%s, Extent = " MPI_AINT_FMT_DEC_SPEC ", Element Size = " MPI_AINT_FMT_DEC_SPEC " (%s), %s",
        -:  460:		    (int) dtp->size,
        -:  461:		    (MPI_Aint) dtp->extent,
        -:  462:		    (MPI_Aint) dtp->lb,
        -:  463:		    (dtp->has_sticky_lb) ? "(sticky)" : "",
        -:  464:		    (MPI_Aint) dtp->ub,
        -:  465:		    (dtp->has_sticky_ub) ? "(sticky)" : "",
        -:  466:		    (MPI_Aint) dtp->extent,
        -:  467:		    (MPI_Aint) dtp->element_size,
        -:  468:		    dtp->element_size == -1 ? "multiple types" :
        -:  469:		    MPIDU_Datatype_builtin_to_string(dtp->eltype),
        -:  470:		    dtp->is_contig ? "is N contig" : "is not N contig"));
        -:  471:
        -:  472:    MPIU_DBG_OUT(DATATYPE,"# Contents:");
    #####:  473:    MPIDI_Datatype_contents_printf(type, 0, array_ct);
        -:  474:
        -:  475:    MPIU_DBG_OUT(DATATYPE,"# Dataloop:");
    #####:  476:    MPIDI_Datatype_dot_printf(type, 0, 1);
        -:  477:}
        -:  478:
        -:  479:static char *MPIDI_Datatype_depth_spacing(int depth)
        -:  480:{
        -:  481:    static char d0[] = "";
        -:  482:    static char d1[] = "  ";
        -:  483:    static char d2[] = "    ";
        -:  484:    static char d3[] = "      ";
        -:  485:    static char d4[] = "        ";
        -:  486:    static char d5[] = "          ";
        -:  487:
        -:  488:    switch (depth) {
        -:  489:	case 0: return d0;
        -:  490:	case 1: return d1;
        -:  491:	case 2: return d2;
        -:  492:	case 3: return d3;
        -:  493:	case 4: return d4;
        -:  494:	default: return d5;
        -:  495:    }
        -:  496:}
        -:  497:
        -:  498:#define __mpidi_datatype_free_and_return { \
        -:  499: if (cp->nr_ints  > 0) MPIU_Free(ints);   \
        -:  500: if (cp->nr_aints > 0) MPIU_Free(aints);   \
        -:  501: if (cp->nr_types > 0) MPIU_Free(types);   \
        -:  502: return;                                 }
        -:  503:
        -:  504:void MPIDI_Datatype_contents_printf(MPI_Datatype type,
        -:  505:				    int depth,
        -:  506:				    int acount)
    #####:  507:{
        -:  508:    int i;
        -:  509:    MPID_Datatype *dtp;
        -:  510:    MPID_Datatype_contents *cp;
        -:  511:
    #####:  512:    MPI_Aint *aints = NULL;
    #####:  513:    MPI_Datatype *types = NULL;
    #####:  514:    int *ints = NULL;
        -:  515:
    #####:  516:    if (HANDLE_GET_KIND(type) == HANDLE_KIND_BUILTIN) {
        -:  517:	MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,"# %stype: %s\n",
        -:  518:			MPIDI_Datatype_depth_spacing(depth),
        -:  519:			MPIDU_Datatype_builtin_to_string(type)));
    #####:  520:	return;
        -:  521:    }
        -:  522:
    #####:  523:    MPID_Datatype_get_ptr(type, dtp);
    #####:  524:    cp = dtp->contents;
        -:  525:
    #####:  526:    if (cp == NULL) {
        -:  527:	MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,"# <NULL>\n"));
    #####:  528:	return;
        -:  529:    }
        -:  530:
    #####:  531:    if (cp->nr_ints > 0)
        -:  532:    {
    #####:  533:      ints = (int *) MPIU_Malloc(cp->nr_ints * sizeof(int));
    #####:  534:      MPIDI_Datatype_get_contents_ints(cp, ints);
        -:  535:    }
        -:  536:
    #####:  537:    if (cp->nr_aints > 0) {
    #####:  538:      aints = (MPI_Aint *) MPIU_Malloc(cp->nr_aints * sizeof(MPI_Aint));
    #####:  539:      MPIDI_Datatype_get_contents_aints(cp, aints);
        -:  540:    }
        -:  541:
    #####:  542:    if (cp->nr_types > 0) {
    #####:  543:      types = (MPI_Datatype *) MPIU_Malloc(cp->nr_types * sizeof(MPI_Datatype));
    #####:  544:      MPIDI_Datatype_get_contents_types(cp, types);
        -:  545:    }
        -:  546:
        -:  547:
        -:  548:    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,"# %scombiner: %s",
        -:  549:		    MPIDI_Datatype_depth_spacing(depth),
        -:  550:		    MPIDU_Datatype_combiner_to_string(cp->combiner)));
        -:  551:
    #####:  552:    switch (cp->combiner) {
        -:  553:	case MPI_COMBINER_NAMED:
        -:  554:	case MPI_COMBINER_DUP:
    #####:  555:	    __mpidi_datatype_free_and_return;
        -:  556:	case MPI_COMBINER_RESIZED:
        -:  557:	    /* not done */
    #####:  558:	    __mpidi_datatype_free_and_return;
        -:  559:	case MPI_COMBINER_CONTIGUOUS:
        -:  560:	    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,"# %scontig ct = %d\n",
        -:  561:			    MPIDI_Datatype_depth_spacing(depth),
        -:  562:				       *ints));
    #####:  563:	    MPIDI_Datatype_contents_printf(*types,
        -:  564:					   depth + 1,
        -:  565:					   acount);
    #####:  566:	    __mpidi_datatype_free_and_return;
        -:  567:	case MPI_COMBINER_VECTOR:
        -:  568:	    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,
        -:  569:	                "# %svector ct = %d, blk = %d, str = %d\n",
        -:  570:			MPIDI_Datatype_depth_spacing(depth),
        -:  571:			    ints[0],
        -:  572:			    ints[1],
        -:  573:			    ints[2]));
    #####:  574:	    MPIDI_Datatype_contents_printf(*types,
        -:  575:					   depth + 1,
        -:  576:					   acount);
    #####:  577:	    __mpidi_datatype_free_and_return;
        -:  578:        case MPI_COMBINER_HVECTOR:
        -:  579:	    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,
        -:  580:	                  "# %shvector ct = %d, blk = %d, str = " MPI_AINT_FMT_DEC_SPEC "\n",
        -:  581:			    MPIDI_Datatype_depth_spacing(depth),
        -:  582:			    ints[0],
        -:  583:			    ints[1],
        -:  584:			    (MPI_Aint) aints[0]));
    #####:  585:	    MPIDI_Datatype_contents_printf(*types,
        -:  586:					   depth + 1,
        -:  587:					   acount);
    #####:  588:	    __mpidi_datatype_free_and_return;
        -:  589:	case MPI_COMBINER_INDEXED:
        -:  590:	    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,"# %sindexed ct = %d:",
        -:  591:			    MPIDI_Datatype_depth_spacing(depth),
        -:  592:			    ints[0]));
    #####:  593:	    for (i=0; i < acount && i < ints[0]; i++) {
        -:  594:		MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,
        -:  595:		         "# %s  indexed [%d]: blk = %d, disp = %d\n",
        -:  596:				MPIDI_Datatype_depth_spacing(depth),
        -:  597:				i,
        -:  598:				ints[i+1],
        -:  599:				ints[i+(cp->nr_ints/2)+1]));
    #####:  600:		MPIDI_Datatype_contents_printf(*types,
        -:  601:					       depth + 1,
        -:  602:					       acount);
        -:  603:	    }
    #####:  604:	    __mpidi_datatype_free_and_return;
        -:  605:	case MPI_COMBINER_HINDEXED:
        -:  606:	    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,"# %shindexed ct = %d:",
        -:  607:			    MPIDI_Datatype_depth_spacing(depth),
        -:  608:			    ints[0]));
    #####:  609:	    for (i=0; i < acount && i < ints[0]; i++) {
        -:  610:		MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,
        -:  611:		            "# %s  hindexed [%d]: blk = %d, disp = " MPI_AINT_FMT_DEC_SPEC "\n",
        -:  612:				MPIDI_Datatype_depth_spacing(depth),
        -:  613:				i,
        -:  614:				(int) ints[i+1],
        -:  615:				(MPI_Aint) aints[i]));
    #####:  616:		MPIDI_Datatype_contents_printf(*types,
        -:  617:					       depth + 1,
        -:  618:					       acount);
        -:  619:	    }
    #####:  620:	    __mpidi_datatype_free_and_return;
        -:  621:	case MPI_COMBINER_STRUCT:
        -:  622:	    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,"# %sstruct ct = %d:",
        -:  623:			    MPIDI_Datatype_depth_spacing(depth),
        -:  624:			    (int) ints[0]));
    #####:  625:	    for (i=0; i < acount && i < ints[0]; i++) {
        -:  626:		MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,
        -:  627:		           "# %s  struct[%d]: blk = %d, disp = " MPI_AINT_FMT_DEC_SPEC "\n",
        -:  628:				MPIDI_Datatype_depth_spacing(depth),
        -:  629:				i,
        -:  630:				(int) ints[i+1],
        -:  631:				(MPI_Aint) aints[i]));
    #####:  632:		MPIDI_Datatype_contents_printf(types[i],
        -:  633:					       depth + 1,
        -:  634:					       acount);
        -:  635:	    }
    #####:  636:	    __mpidi_datatype_free_and_return;
        -:  637:	default:
        -:  638:	    MPIU_DBG_OUT_FMT(DATATYPE,(MPIU_DBG_FDEST,"# %sunhandled combiner",
        -:  639:			MPIDI_Datatype_depth_spacing(depth)));
    #####:  640:	    __mpidi_datatype_free_and_return;
        -:  641:    }
        -:  642:}
        -:  643:/* --END ERROR HANDLING-- */