int MPI_Type_vector(int count, int length, int stride, MPI_Datatype oldtype, MPI_Datatype *newtype) { struct mpifake_dtype *ntype; ntype = *newtype = malloc(sizeof(struct mpifake_dtype)); ntype->format = LAM_DTVECTOR; /* initialize defaults */ ntype->upper = 0; ntype->lower = 0; ntype->size = 0; ntype->count = count; ntype->length = length; ntype->stride = stride; ntype->dtype = oldtype; mpifake_dtblock(ntype, oldtype, length, 0); ntype->size *= count; stride *= (oldtype->upper - oldtype->lower) * (count - 1); if (stride > 0) { ntype->upper += stride; } else { ntype->lower += stride; } return MPI_SUCCESS; }
int MPI_Type_contiguous(int count, MPI_Datatype oldtype, MPI_Datatype *newtype) { struct mpifake_dtype *ntype; ntype = *newtype = malloc(sizeof(struct mpifake_dtype)); ntype->format = LAM_DTCONTIG; /* initialize defaults */ ntype->upper = 0; ntype->lower = 0; ntype->size = 0; ntype->count = count; ntype->dtype = oldtype; mpifake_dtblock(ntype, oldtype, count, 0); return MPI_SUCCESS; }
int MPI_Type_struct(int count, int *lengths, MPI_Aint *disps, MPI_Datatype *oldtypes, MPI_Datatype *newtype) { int i; struct mpifake_dtype *ntype; ntype = *newtype = static_cast<MPI_Datatype>(malloc(sizeof(struct mpifake_dtype))); ntype->format = LAM_DTSTRUCT; /* initialize defaults */ ntype->upper = 0; ntype->lower = 0; ntype->size = 0; ntype->count = count; if (count > 0) { ntype->dtypes = static_cast<mpifake_dtype**> (malloc(count * (sizeof(MPI_Datatype)+sizeof(int)+sizeof(int)))); ntype->disps = (int *)((char *)ntype->dtypes + count*sizeof(MPI_Datatype)); ntype->lengths = (int *)((char *)ntype->disps + count*sizeof(int)); } else { ntype->size = 0; } for (i=0;i<count;i++) { ntype->disps[i] = disps[i]; ntype->lengths[i] = lengths[i]; ntype->dtypes[i] = oldtypes[i]; mpifake_dtblock(ntype, oldtypes[i], lengths[i], disps[i]); } return MPI_SUCCESS; }