Пример #1
0
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;
}
Пример #2
0
/*
 * You must configure MPICH2 with the logging option enabled (--enable-g=log)
 * for these routines to print - in which case, they use the same options
 * as the logging code, including print to file and control by class (DATATYPE)
 */
void MPIDU_Datatype_debug(MPI_Datatype type,
			  int array_ct)
{
    int is_builtin;
    MPIDU_Datatype *dtp ATTRIBUTE((unused));

    is_builtin = (HANDLE_GET_KIND(type) == HANDLE_KIND_BUILTIN);

    /* can get a NULL type a number of different ways, including not having
     * fortran support included.
     */
    if (type == MPI_DATATYPE_NULL) {
	MPL_DBG_OUT_FMT(MPIR_DBG_DATATYPE,
			 (MPL_DBG_FDEST,
			  "# MPIU_Datatype_debug: MPI_Datatype = MPI_DATATYPE_NULL"));
	return;
    }

    MPL_DBG_OUT_FMT(MPIR_DBG_DATATYPE,(MPL_DBG_FDEST,
	       "# MPIU_Datatype_debug: MPI_Datatype = 0x%0x (%s)", type,
	       (is_builtin) ? MPIDU_Datatype_builtin_to_string(type) :
	        "derived"));

    if (is_builtin) return;

    MPIDU_Datatype_get_ptr(type, dtp);
    MPIR_Assert(dtp != NULL);

    MPL_DBG_OUT_FMT(MPIR_DBG_DATATYPE,(MPL_DBG_FDEST,
      "# Size = " MPI_AINT_FMT_DEC_SPEC ", 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",
		    (MPI_Aint) dtp->size,
		    (MPI_Aint) dtp->extent,
		    (MPI_Aint) dtp->lb,
		    (dtp->has_sticky_lb) ? "(sticky)" : "",
		    (MPI_Aint) dtp->ub,
		    (dtp->has_sticky_ub) ? "(sticky)" : "",
		    (MPI_Aint) dtp->extent,
		    (MPI_Aint) dtp->builtin_element_size,
		    dtp->builtin_element_size == -1 ? "multiple types" :
		    MPIDU_Datatype_builtin_to_string(dtp->basic_type),
		    dtp->is_contig ? "is N contig" : "is not N contig"));

    MPL_DBG_OUT(MPIR_DBG_DATATYPE,"# Contents:");
    MPIDI_Datatype_contents_printf(type, 0, array_ct);

    MPL_DBG_OUT(MPIR_DBG_DATATYPE,"# Dataloop:");
    MPIDI_Datatype_dot_printf(type, 0, 1);
}
Пример #3
0
/* --BEGIN ERROR HANDLING-- */
void MPIDI_Datatype_dot_printf(MPI_Datatype type,
			       int depth,
			       int header)
{
    if (HANDLE_GET_KIND(type) == HANDLE_KIND_BUILTIN) {
	MPL_DBG_OUT(MPIR_DBG_DATATYPE,
			 "MPIDI_Datatype_dot_printf: type is a basic");
	return;
    }
    else {
	MPIDU_Datatype *dt_p;
	MPIDU_Dataloop *loop_p;

	MPIDU_Datatype_get_ptr(type, dt_p);
	loop_p = dt_p->dataloop;

	MPIDI_Dataloop_dot_printf(loop_p, depth, header);
	return;
    }
}
Пример #4
0
static int DLOOP_Dataloop_create_flattened_struct(DLOOP_Count count,
						  const int *blklens,
						  const MPI_Aint *disps,
						  const DLOOP_Type *oldtypes,
						  DLOOP_Dataloop **dlp_p,
						  MPI_Aint *dlsz_p,
						  int *dldepth_p,
						  int flag)
{
    /* arbitrary types, convert to bytes and use indexed */
    int i, err, nr_blks = 0;
    DLOOP_Size *tmp_blklens;
    MPI_Aint *tmp_disps; /* since we're calling another fn that takes
			    this type as an input parameter */
    DLOOP_Offset bytes;
    DLOOP_Segment *segp;

    int first_ind;
    DLOOP_Size last_ind;

    segp = MPIR_Segment_alloc();
    /* --BEGIN ERROR HANDLING-- */
    if (!segp) {
	return DLOOP_Dataloop_create_struct_memory_error();
    }
    /* --END ERROR HANDLING-- */

    /* use segment code once to count contiguous regions */
    for (i=0; i < count; i++)
    {
	int is_basic;

	/* ignore type elements with a zero blklen */
	if (blklens[i] == 0) continue;

	is_basic = (DLOOP_Handle_hasloop_macro(oldtypes[i])) ? 0 : 1;

	if (is_basic && (oldtypes[i] != MPI_LB &&
			 oldtypes[i] != MPI_UB))
	{
	    nr_blks++;
	}
        else /* derived type; get a count of contig blocks */
        {
            DLOOP_Count tmp_nr_blks, sz;

            DLOOP_Handle_get_size_macro(oldtypes[i], sz);

            /* if the derived type has some data to contribute,
             * add to flattened representation */
            if (sz > 0) {
                err = MPIR_Segment_init(NULL,
                                                   (DLOOP_Count) blklens[i],
                                                   oldtypes[i],
                                                   segp,
                                                   flag);
                if (err) return err;

                bytes = SEGMENT_IGNORE_LAST;

                MPIR_Segment_count_contig_blocks(segp,
                                                            0,
                                                            &bytes,
                                                            &tmp_nr_blks);

                nr_blks += tmp_nr_blks;
            }
        }
    }

    /* it's possible for us to get to this point only to realize that
     * there isn't any data in this type. in that case do what we always
     * do: store a simple contig of zero ints and call it done.
     */
    if (nr_blks == 0) {
	MPIR_Segment_free(segp);
	err = MPIR_Dataloop_create_contiguous(0,
							 MPI_INT,
							 dlp_p,
							 dlsz_p,
							 dldepth_p,
							 flag);
	return err;

    }

    nr_blks += 2; /* safety measure */

    tmp_blklens = (DLOOP_Size *) DLOOP_Malloc(nr_blks * sizeof(DLOOP_Size), MPL_MEM_DATATYPE);
    /* --BEGIN ERROR HANDLING-- */
    if (!tmp_blklens) {
	MPIR_Segment_free(segp);
	return DLOOP_Dataloop_create_struct_memory_error();
    }
    /* --END ERROR HANDLING-- */


    tmp_disps = (MPI_Aint *) DLOOP_Malloc(nr_blks * sizeof(MPI_Aint), MPL_MEM_DATATYPE);
    /* --BEGIN ERROR HANDLING-- */
    if (!tmp_disps) {
	DLOOP_Free(tmp_blklens);
	MPIR_Segment_free(segp);
	return DLOOP_Dataloop_create_struct_memory_error();
    }
    /* --END ERROR HANDLING-- */

    /* use segment code again to flatten the type */
    first_ind = 0;
    for (i=0; i < count; i++)
    {
	int is_basic;
	DLOOP_Count sz = -1;

	is_basic = (DLOOP_Handle_hasloop_macro(oldtypes[i])) ? 0 : 1;
	if (!is_basic) DLOOP_Handle_get_size_macro(oldtypes[i], sz);

	/* we're going to use the segment code to flatten the type.
	 * we put in our displacement as the buffer location, and use
	 * the blocklength as the count value to get N contiguous copies
	 * of the type.
	 *
	 * Note that we're going to get back values in bytes, so that will
	 * be our new element type.
	 */
	if (oldtypes[i] != MPI_UB &&
	    oldtypes[i] != MPI_LB &&
	    blklens[i] != 0 &&
	    (is_basic || sz > 0))
	{
	    err = MPIR_Segment_init((char *) DLOOP_OFFSET_CAST_TO_VOID_PTR disps[i],
					 (DLOOP_Count) blklens[i],
					 oldtypes[i],
					 segp,
					 0 /* homogeneous */);
            if (err) return err;

	    last_ind = nr_blks - first_ind;
	    bytes = SEGMENT_IGNORE_LAST;
	    MPIR_Segment_mpi_flatten(segp,
						0,
						&bytes,
						&tmp_blklens[first_ind],
						&tmp_disps[first_ind],
						&last_ind);
            if (err) return err;
	    first_ind += last_ind;
	}
    }
    nr_blks = first_ind;

#if 0
    if (MPL_DBG_SELECTED(MPIR_DBG_DATATYPE,VERBOSE)) {
	MPL_DBG_OUT(MPIR_DBG_DATATYPE,"--- start of flattened type ---");
        for (i=0; i < nr_blks; i++) {
	MPL_DBG_OUT_FMT(MPIR_DBG_DATATYPE,(MPL_DBG_FDEST,
				   "a[%d] = (%d, " DLOOP_OFFSET_FMT_DEC_SPEC ")", i,
				   tmp_blklens[i], tmp_disps[i]));
	}
	MPL_DBG_OUT(MPIR_DBG_DATATYPE,"--- end of flattened type ---");
    }
#endif

    MPIR_Segment_free(segp);

    err = MPIR_Dataloop_create_indexed(nr_blks,
						  tmp_blklens,
						  tmp_disps,
						  1, /* disp in bytes */
						  MPI_BYTE,
						  dlp_p,
						  dlsz_p,
						  dldepth_p,
						  flag);

    DLOOP_Free(tmp_blklens);
    DLOOP_Free(tmp_disps);

    return err;
}
Пример #5
0
void MPIDI_Dataloop_dot_printf(MPIDU_Dataloop *loop_p,
			       int depth,
			       int header)
{
    int i;

    if (loop_p == NULL) {
	MPL_DBG_OUT_FMT(MPIR_DBG_DATATYPE,(MPL_DBG_FDEST,"<null dataloop>\n"));
	return;
    }

    if (header) {
	MPL_DBG_OUT_FMT(MPIR_DBG_DATATYPE,(MPL_DBG_FDEST,
		    /* graphviz does not like the 0xNNN format */
				   "digraph %lld {   {", (long long int)loop_p));
    }

    switch (loop_p->kind & DLOOP_KIND_MASK) {
	case DLOOP_KIND_CONTIG:
	    MPL_DBG_OUT_FMT(MPIR_DBG_DATATYPE,(MPL_DBG_FDEST,
	    "      dl%d [shape = record, label = \"contig |{ ct = %d; el_sz = " MPI_AINT_FMT_DEC_SPEC "; el_ext = " MPI_AINT_FMT_DEC_SPEC " }\"];",
			    depth,
			    (int) loop_p->loop_params.c_t.count,
			    (MPI_Aint) loop_p->el_size,
			    (MPI_Aint) loop_p->el_extent));
	    break;
	case DLOOP_KIND_VECTOR:
	    MPL_DBG_OUT_FMT(MPIR_DBG_DATATYPE,(MPL_DBG_FDEST,
	    "      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 " }\"];",
			    depth,
			    (int) loop_p->loop_params.v_t.count,
			    (int) loop_p->loop_params.v_t.blocksize,
			    (MPI_Aint) loop_p->loop_params.v_t.stride,
			    (MPI_Aint) loop_p->el_size,
			    (MPI_Aint) loop_p->el_extent));
	    break;
	case DLOOP_KIND_INDEXED:
	    MPL_DBG_OUT_FMT(MPIR_DBG_DATATYPE,(MPL_DBG_FDEST,
	    "      dl%d [shape = record, label = \"indexed |{ ct = %d; tot_blks = %d; regions = ",
			    depth,
			    (int) loop_p->loop_params.i_t.count,
			    (int) loop_p->loop_params.i_t.total_blocks));

	    for (i=0; i < NR_TYPE_CUTOFF && i < loop_p->loop_params.i_t.count; i++) {
		if (i + 1 < loop_p->loop_params.i_t.count) {
		    /* more regions after this one */
		    MPL_DBG_OUT_FMT(MPIR_DBG_DATATYPE,(MPL_DBG_FDEST,
		    "\\n(" MPI_AINT_FMT_DEC_SPEC ", %d), ",
			  (MPI_Aint) loop_p->loop_params.i_t.offset_array[i],
		          (int) loop_p->loop_params.i_t.blocksize_array[i]));
		}
		else {
		    MPL_DBG_OUT_FMT(MPIR_DBG_DATATYPE,(MPL_DBG_FDEST,
		           "\\n(" MPI_AINT_FMT_DEC_SPEC ", %d); ",
		           (MPI_Aint) loop_p->loop_params.i_t.offset_array[i],
			   (int) loop_p->loop_params.i_t.blocksize_array[i]));
		}
	    }
	    if (i < loop_p->loop_params.i_t.count) {
		MPL_DBG_OUT(MPIR_DBG_DATATYPE,"\\n...; ");
	    }

	    MPL_DBG_OUT_FMT(MPIR_DBG_DATATYPE,(MPL_DBG_FDEST,
				       "\\nel_sz = " MPI_AINT_FMT_DEC_SPEC "; el_ext = " MPI_AINT_FMT_DEC_SPEC " }\"];\n",
				       (MPI_Aint) loop_p->el_size,
				       (MPI_Aint) loop_p->el_extent));
	    break;
	case DLOOP_KIND_BLOCKINDEXED:
	    MPL_DBG_OUT_FMT(MPIR_DBG_DATATYPE,(MPL_DBG_FDEST,
	    "      dl%d [shape = record, label = \"blockindexed |{ ct = %d; blk = %d; disps = ",
			    depth,
			    (int) loop_p->loop_params.bi_t.count,
			    (int) loop_p->loop_params.bi_t.blocksize));

	    for (i=0; i < NR_TYPE_CUTOFF && i < loop_p->loop_params.bi_t.count; i++) {
		if (i + 1 < loop_p->loop_params.bi_t.count) {
		    /* more regions after this one */
		    MPL_DBG_OUT_FMT(MPIR_DBG_DATATYPE,(MPL_DBG_FDEST,
		        MPI_AINT_FMT_DEC_SPEC ",\\n ",
			(MPI_Aint) loop_p->loop_params.bi_t.offset_array[i]));
		}
		else {
		    MPL_DBG_OUT_FMT(MPIR_DBG_DATATYPE,(MPL_DBG_FDEST,
		         MPI_AINT_FMT_DEC_SPEC "; ",
		         (MPI_Aint) loop_p->loop_params.bi_t.offset_array[i]));
		}
	    }
	    if (i < loop_p->loop_params.bi_t.count) {
		MPL_DBG_OUT(MPIR_DBG_DATATYPE,"...; ");
	    }

	    MPL_DBG_OUT_FMT(MPIR_DBG_DATATYPE,(MPL_DBG_FDEST,
				      "\\nel_sz = " MPI_AINT_FMT_DEC_SPEC "; el_ext = " MPI_AINT_FMT_DEC_SPEC " }\"];",
				       (MPI_Aint) loop_p->el_size,
				       (MPI_Aint) loop_p->el_extent));
	    break;
	case DLOOP_KIND_STRUCT:
	    MPL_DBG_OUT_FMT(MPIR_DBG_DATATYPE,(MPL_DBG_FDEST,
	    "      dl%d [shape = record, label = \"struct | {ct = %d; blks = ",
			    depth,
			    (int) loop_p->loop_params.s_t.count));
	    for (i=0; i < NR_TYPE_CUTOFF && i < loop_p->loop_params.s_t.count; i++) {
		if (i + 1 < loop_p->loop_params.s_t.count) {
		    MPL_DBG_OUT_FMT(MPIR_DBG_DATATYPE,(MPL_DBG_FDEST,"%d, ",
			    (int) loop_p->loop_params.s_t.blocksize_array[i]));
		}
		else {
		    MPL_DBG_OUT_FMT(MPIR_DBG_DATATYPE,(MPL_DBG_FDEST,"%d; ",
			    (int) loop_p->loop_params.s_t.blocksize_array[i]));
		}
	    }
	    if (i < loop_p->loop_params.s_t.count) {
		MPL_DBG_OUT(MPIR_DBG_DATATYPE,"...; disps = ");
	    }
	    else {
		MPL_DBG_OUT(MPIR_DBG_DATATYPE,"disps = ");
	    }

	    for (i=0; i < NR_TYPE_CUTOFF && i < loop_p->loop_params.s_t.count; i++) {
		if (i + 1 < loop_p->loop_params.s_t.count) {
		    MPL_DBG_OUT_FMT(MPIR_DBG_DATATYPE,(MPL_DBG_FDEST,MPI_AINT_FMT_DEC_SPEC ", ",
			    (MPI_Aint) loop_p->loop_params.s_t.offset_array[i]));
		}
		else {
		    MPL_DBG_OUT_FMT(MPIR_DBG_DATATYPE,(MPL_DBG_FDEST,MPI_AINT_FMT_DEC_SPEC "; ",
			    (MPI_Aint) loop_p->loop_params.s_t.offset_array[i]));
		}
	    }
	    if (i < loop_p->loop_params.s_t.count) {
		MPL_DBG_OUT(MPIR_DBG_DATATYPE,"... }\"];");
	    }
	    else {
		MPL_DBG_OUT(MPIR_DBG_DATATYPE,"}\"];");
	    }
	    break;
	default:
	    MPIR_Assert(0);
    }

    if (!(loop_p->kind & DLOOP_FINAL_MASK)) {
	/* more loops to go; recurse */
	MPL_DBG_OUT_FMT(MPIR_DBG_DATATYPE,(MPL_DBG_FDEST,
				   "      dl%d -> dl%d;\n", depth, depth + 1));
	switch (loop_p->kind & DLOOP_KIND_MASK) {
	    case DLOOP_KIND_CONTIG:
		MPIDI_Dataloop_dot_printf(loop_p->loop_params.c_t.dataloop, depth + 1, 0);
		break;
	    case DLOOP_KIND_VECTOR:
		MPIDI_Dataloop_dot_printf(loop_p->loop_params.v_t.dataloop, depth + 1, 0);
		break;
	    case DLOOP_KIND_INDEXED:
		MPIDI_Dataloop_dot_printf(loop_p->loop_params.i_t.dataloop, depth + 1, 0);
		break;
	    case DLOOP_KIND_BLOCKINDEXED:
		MPIDI_Dataloop_dot_printf(loop_p->loop_params.bi_t.dataloop, depth + 1, 0);
		break;
	    case DLOOP_KIND_STRUCT:
		for (i=0; i < loop_p->loop_params.s_t.count; i++) {
		    MPIDI_Dataloop_dot_printf(loop_p->loop_params.s_t.dataloop_array[i],
					      depth + 1, 0);
		}
		break;
	    default:
		MPL_DBG_OUT(MPIR_DBG_DATATYPE,"      < unsupported type >");
	}
    }


    if (header) {
	MPL_DBG_OUT(MPIR_DBG_DATATYPE,"   }\n}");
    }
    return;
}