-: 0:Source:/home/MPI/testing/mpich2/mpich2/src/mpid/common/datatype/dataloop/dataloop_create_vector.c
-: 0:Graph:dataloop_create_vector.gcno
-: 0:Data:dataloop_create_vector.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 "./dataloop.h"
-: 9:
-: 10:/*@
-: 11: Dataloop_create_vector
-: 12:
-: 13: Arguments:
-: 14:+ int icount
-: 15:. int iblocklength
-: 16:. MPI_Aint astride
-: 17:. int strideinbytes
-: 18:. MPI_Datatype oldtype
-: 19:. DLOOP_Dataloop **dlp_p
-: 20:. int *dlsz_p
-: 21:. int *dldepth_p
-: 22:- int flag
-: 23:
-: 24: Returns 0 on success, -1 on failure.
-: 25:
-: 26:@*/
-: 27:int PREPEND_PREFIX(Dataloop_create_vector)(int icount,
-: 28: int iblocklength,
-: 29: MPI_Aint astride,
-: 30: int strideinbytes,
-: 31: DLOOP_Type oldtype,
-: 32: DLOOP_Dataloop **dlp_p,
-: 33: int *dlsz_p,
-: 34: int *dldepth_p,
-: 35: int flag)
39422: 36:{
-: 37: int err, is_builtin;
-: 38: int new_loop_sz, new_loop_depth;
-: 39:
-: 40: DLOOP_Count count, blocklength;
-: 41: DLOOP_Offset stride;
-: 42: DLOOP_Dataloop *new_dlp;
-: 43:
39422: 44: count = (DLOOP_Count) icount; /* avoid subsequent casting */
39422: 45: blocklength = (DLOOP_Count) iblocklength;
39422: 46: stride = (DLOOP_Offset) astride;
-: 47:
-: 48: /* if count or blocklength are zero, handle with contig code,
-: 49: * call it a int
-: 50: */
39422: 51: if (count == 0 || blocklength == 0)
-: 52: {
-: 53:
|
#####: 54: err = PREPEND_PREFIX(Dataloop_create_contiguous)(0,
-: 55: MPI_INT,
-: 56: dlp_p,
-: 57: dlsz_p,
-: 58: dldepth_p,
-: 59: flag);
#####: 60: return err;
-: 61: }
-: 62:
-: 63: /* optimization:
-: 64: *
-: 65: * if count == 1, store as a contiguous rather than a vector dataloop.
-: 66: */
|
39422: 67: if (count == 1) {
2240: 68: err = PREPEND_PREFIX(Dataloop_create_contiguous)(iblocklength,
-: 69: oldtype,
-: 70: dlp_p,
-: 71: dlsz_p,
-: 72: dldepth_p,
-: 73: flag);
2240: 74: return err;
-: 75: }
-: 76:
37182: 77: is_builtin = (DLOOP_Handle_hasloop_macro(oldtype)) ? 0 : 1;
-: 78:
37182: 79: if (is_builtin) {
35946: 80: new_loop_sz = sizeof(DLOOP_Dataloop);
35946: 81: new_loop_depth = 1;
-: 82: }
-: 83: else {
1236: 84: int old_loop_sz = 0, old_loop_depth = 0;
-: 85:
1236: 86: DLOOP_Handle_get_loopsize_macro(oldtype, old_loop_sz, flag);
1236: 87: DLOOP_Handle_get_loopdepth_macro(oldtype, old_loop_depth, flag);
-: 88:
-: 89: /* TODO: ACCOUNT FOR PADDING IN LOOP_SZ HERE */
1236: 90: new_loop_sz = sizeof(DLOOP_Dataloop) + old_loop_sz;
1236: 91: new_loop_depth = old_loop_depth + 1;
-: 92: }
-: 93:
-: 94:
37182: 95: if (is_builtin) {
35946: 96: DLOOP_Offset basic_sz = 0;
-: 97:
35946: 98: PREPEND_PREFIX(Dataloop_alloc)(DLOOP_KIND_VECTOR,
-: 99: count,
-: 100: &new_dlp,
-: 101: &new_loop_sz);
|
-: 102: /* --BEGIN ERROR HANDLING-- */
35946: 103: if (!new_dlp) return -1;
-: 104: /* --END ERROR HANDLING-- */
-: 105:
|
35946: 106: DLOOP_Handle_get_size_macro(oldtype, basic_sz);
35946: 107: new_dlp->kind = DLOOP_KIND_VECTOR | DLOOP_FINAL_MASK;
-: 108:
35946: 109: if (flag == DLOOP_DATALOOP_ALL_BYTES)
-: 110: {
-: 111:
|
#####: 112: blocklength *= basic_sz;
#####: 113: new_dlp->el_size = 1;
#####: 114: new_dlp->el_extent = 1;
#####: 115: new_dlp->el_type = MPI_BYTE;
-: 116:
#####: 117: if(!strideinbytes)
-: 118: /* the stride was specified in units of oldtype, now
-: 119: that we're using bytes, rather than oldtype, we
-: 120: need to update stride. */
#####: 121: stride *= basic_sz;
-: 122: }
-: 123: else
-: 124: {
|
35946: 125: new_dlp->el_size = basic_sz;
35946: 126: new_dlp->el_extent = new_dlp->el_size;
35946: 127: new_dlp->el_type = oldtype;
-: 128: }
-: 129: }
-: 130: else /* user-defined base type (oldtype) */ {
-: 131: DLOOP_Dataloop *old_loop_ptr;
1236: 132: int old_loop_sz = 0;
-: 133:
1236: 134: DLOOP_Handle_get_loopptr_macro(oldtype, old_loop_ptr, flag);
1236: 135: DLOOP_Handle_get_loopsize_macro(oldtype, old_loop_sz, flag);
-: 136:
1236: 137: PREPEND_PREFIX(Dataloop_alloc_and_copy)(DLOOP_KIND_VECTOR,
-: 138: count,
-: 139: old_loop_ptr,
-: 140: old_loop_sz,
-: 141: &new_dlp,
-: 142: &new_loop_sz);
|
-: 143: /* --BEGIN ERROR HANDLING-- */
1236: 144: if (!new_dlp) return -1;
-: 145: /* --END ERROR HANDLING-- */
-: 146:
|
1236: 147: new_dlp->kind = DLOOP_KIND_VECTOR;
1236: 148: DLOOP_Handle_get_size_macro(oldtype, new_dlp->el_size);
1236: 149: DLOOP_Handle_get_extent_macro(oldtype, new_dlp->el_extent);
1236: 150: DLOOP_Handle_get_basic_type_macro(oldtype, new_dlp->el_type);
-: 151: }
-: 152:
-: 153: /* vector-specific members
-: 154: *
-: 155: * stride stored in dataloop is always in bytes for local rep of type
-: 156: */
37182: 157: new_dlp->loop_params.v_t.count = count;
37182: 158: new_dlp->loop_params.v_t.blocksize = blocklength;
37182: 159: new_dlp->loop_params.v_t.stride = (strideinbytes) ? stride :
-: 160: stride * new_dlp->el_extent;
-: 161:
37182: 162: *dlp_p = new_dlp;
37182: 163: *dlsz_p = new_loop_sz;
37182: 164: *dldepth_p = new_loop_depth;
-: 165:
37182: 166: return 0;
-: 167:}
|