3 /* smpi_mpi_dt.c -- MPI primitives to handle datatypes */
5 /* Note: a very incomplete implementation */
7 /* Copyright (c) 2009 Stephane Genaud. */
8 /* All rights reserved. */
10 /* This program is free software; you can redistribute it and/or modify it
11 * * under the terms of the license (GNU LGPL) which comes with this package. */
19 #include "smpi_mpi_dt_private.h"
21 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_mpi_dt, smpi,
22 "Logging specific to SMPI (datatype)");
26 * Get the lower bound and extent for a Datatype
27 * The extent of a datatype is defined to be the span from the first byte to the last byte
28 * occupied by entries in this datatype, rounded up to satisfy alignment requirements (epsilon).
30 * For typemap T = {(t_0,disp_0), ..., (t_n-1,disp_n-1)}
31 * lb(T) = min_j disp_j
32 * ub(T) = max_j (disp_j+sizeof(t_j)) + epsilon
33 * extent(T) = ub(T) - lb(T)
35 * FIXME: this an incomplete implementation as we do not support yet MPI_Type_commit.
36 * Hence, this can be called only for primitive type MPI_INT, MPI_DOUBLE, ...
38 * remark: MPI-1 has also the deprecated
39 * int MPI_Type_extent(MPI_Datatype datatype, *MPI_Aint *extent);
42 int smpi_mpi_type_get_extent(MPI_Datatype datatype, MPI_Aint *lb, MPI_Aint *extent) {
44 if ( DT_FLAG_COMMITED != (datatype-> flags & DT_FLAG_COMMITED) )
45 return( MPI_ERR_TYPE );
47 *extent = datatype->ub - datatype->lb;
48 return( MPI_SUCCESS );
51 * query the size of the type
53 int SMPI_MPI_Type_size(MPI_Datatype datatype, size_t * size)
55 int retval = MPI_SUCCESS;
59 if (NULL == datatype) {
60 retval = MPI_ERR_TYPE;
61 } else if (NULL == size) {
64 *size = datatype->size;
75 * query extent and lower bound of the type
77 int SMPI_MPI_Type_get_extent( MPI_Datatype datatype, int *lb, int *extent)
79 return( smpi_mpi_type_get_extent( datatype, lb, extent));
82 /* Deprecated Functions.
83 * The MPI-2 standard deprecated a number of routines because MPI-2 provides better versions.
84 * This routine is one of those that was deprecated. The routine may continue to be used, but
85 * new code should use the replacement routine. The replacement for this routine is MPI_Type_Get_extent.
87 int SMPI_MPI_Type_ub( MPI_Datatype datatype, MPI_Aint *displacement)
89 if ( DT_FLAG_COMMITED != (datatype->flags & DT_FLAG_COMMITED) )
90 return( MPI_ERR_TYPE );
91 *displacement = datatype->ub;
92 return( MPI_SUCCESS );
94 int SMPI_MPI_Type_lb( MPI_Datatype datatype, MPI_Aint *displacement)
96 if ( DT_FLAG_COMMITED != (datatype->flags & DT_FLAG_COMMITED) )
97 return( MPI_ERR_TYPE );
98 *displacement = datatype->lb;
99 return( MPI_SUCCESS );