2004-01-29 21:21:55 +03:00
|
|
|
/*
|
|
|
|
* $HEADERS$
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "ompi_config.h"
|
2004-01-29 21:21:55 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "mpi.h"
|
2004-03-17 21:45:16 +03:00
|
|
|
#include "mpi/c/bindings.h"
|
2004-05-08 03:44:49 +04:00
|
|
|
#include "datatype/datatype.h"
|
|
|
|
#include "errhandler/errhandler.h"
|
|
|
|
#include "communicator/communicator.h"
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "class/ompi_object.h"
|
2004-01-29 21:21:55 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#if OMPI_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES
|
2004-01-29 21:21:55 +03:00
|
|
|
#pragma weak MPI_Unpack = PMPI_Unpack
|
|
|
|
#endif
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#if OMPI_PROFILING_DEFINES
|
2004-04-20 22:50:43 +04:00
|
|
|
#include "mpi/c/profile/defines.h"
|
|
|
|
#endif
|
|
|
|
|
2004-06-24 20:47:00 +04:00
|
|
|
static const char FUNC_NAME[] = "MPI_Unpack";
|
2004-05-08 03:44:49 +04:00
|
|
|
|
|
|
|
|
2004-01-29 21:21:55 +03:00
|
|
|
int MPI_Unpack(void *inbuf, int insize, int *position,
|
|
|
|
void *outbuf, int outcount, MPI_Datatype datatype,
|
2004-05-08 03:44:49 +04:00
|
|
|
MPI_Comm comm)
|
|
|
|
{
|
|
|
|
int size, rc;
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_convertor_t *local_convertor;
|
2004-05-08 03:44:49 +04:00
|
|
|
struct iovec outvec;
|
|
|
|
|
|
|
|
if (MPI_PARAM_CHECK) {
|
2004-07-30 06:58:53 +04:00
|
|
|
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
|
|
|
|
if (ompi_comm_invalid(comm)) {
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
|
2004-07-30 06:58:53 +04:00
|
|
|
FUNC_NAME);
|
2004-05-08 03:44:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((NULL == inbuf) || (NULL == outbuf) || (NULL == position)) {
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
|
2004-05-08 03:44:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (outcount < 0) {
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME);
|
2004-05-08 03:44:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (MPI_DATATYPE_NULL == datatype) {
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME);
|
2004-05-08 03:44:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-30 02:45:06 +04:00
|
|
|
local_convertor = OBJ_NEW(ompi_convertor_t);
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_convertor_init_for_recv(local_convertor, 0, datatype, outcount,
|
2004-08-30 11:52:09 +04:00
|
|
|
outbuf, 0);
|
2004-05-08 03:44:49 +04:00
|
|
|
|
2004-08-30 11:52:09 +04:00
|
|
|
/* Check for truncation */
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_convertor_get_packed_size(local_convertor, &size);
|
2004-09-16 18:36:38 +04:00
|
|
|
if (*position + size > insize) {
|
2004-08-30 02:45:06 +04:00
|
|
|
OBJ_RELEASE(local_convertor);
|
2004-08-30 11:52:09 +04:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TRUNCATE, FUNC_NAME);
|
2004-05-08 03:44:49 +04:00
|
|
|
}
|
|
|
|
|
2004-08-30 11:52:09 +04:00
|
|
|
/* Prepare the iovec with all informations */
|
2004-05-08 03:44:49 +04:00
|
|
|
|
2004-08-30 11:52:09 +04:00
|
|
|
outvec.iov_base = (char*) inbuf + (*position);
|
2004-05-08 03:44:49 +04:00
|
|
|
outvec.iov_len = insize - (*position);
|
|
|
|
|
|
|
|
/* Do the actual unpacking */
|
2004-08-30 11:52:09 +04:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
rc = ompi_convertor_unpack(local_convertor, &outvec, 1);
|
2004-05-08 03:44:49 +04:00
|
|
|
*position += local_convertor->bConverted;
|
2004-08-30 11:52:09 +04:00
|
|
|
OBJ_RELEASE(local_convertor);
|
2004-05-08 03:44:49 +04:00
|
|
|
|
2004-08-30 11:52:09 +04:00
|
|
|
/* All done. Note that the convertor returns 1 upon success, not
|
|
|
|
OMPI_SUCCESS. */
|
2004-05-08 03:44:49 +04:00
|
|
|
|
2004-08-30 11:52:09 +04:00
|
|
|
OMPI_ERRHANDLER_RETURN((rc == 1) ? OMPI_SUCCESS : OMPI_ERROR,
|
|
|
|
comm, MPI_ERR_UNKNOWN, FUNC_NAME);
|
2004-01-29 21:21:55 +03:00
|
|
|
}
|