1
1

Updates and fixes to make MPI_PACK / MPI_UNPACK *really* work :-)

This commit was SVN r2390.
Этот коммит содержится в:
Jeff Squyres 2004-08-30 07:52:09 +00:00
родитель c9badff0c9
Коммит 95c87a5d72
2 изменённых файлов: 29 добавлений и 27 удалений

Просмотреть файл

@ -46,29 +46,30 @@ int MPI_Pack(void *inbuf, int incount, MPI_Datatype datatype,
local_convertor = OBJ_NEW(ompi_convertor_t); local_convertor = OBJ_NEW(ompi_convertor_t);
ompi_convertor_init_for_send(local_convertor, 0, datatype, incount, ompi_convertor_init_for_send(local_convertor, 0, datatype, incount,
inbuf, 0); inbuf, 0);
/* how long is the data ? Can we put it in the user buffer */ /* Check for truncation */
ompi_convertor_get_packed_size(local_convertor, &size); ompi_convertor_get_packed_size(local_convertor, &size);
if( (outsize - (*position)) < size) { if (*position + size >= outsize) {
OBJ_RELEASE(local_convertor); OBJ_RELEASE(local_convertor);
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME); return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TRUNCATE, FUNC_NAME);
} }
/* Prepare the iovec withh all informations */ /* Prepare the iovec with all informations */
invec.iov_base = (char*)outbuf + (*position);
/* If the position is not ZERO we already start invec.iov_base = (char*) outbuf + (*position);
* the packing for this datatype.
*/
invec.iov_len = outsize - (*position); invec.iov_len = outsize - (*position);
/* Do the actual packing */ /* Do the actual packing */
rc = ompi_convertor_pack(local_convertor, &invec, 1); rc = ompi_convertor_pack(local_convertor, &invec, 1);
*position += local_convertor->bConverted; *position += local_convertor->bConverted;
/* All done */
OBJ_RELEASE(local_convertor); OBJ_RELEASE(local_convertor);
OMPI_ERRHANDLER_RETURN(rc, comm, MPI_ERR_UNKNOWN, FUNC_NAME);
/* All done. Note that the convertor returns 1 upon success, not
OMPI_SUCCESS. */
OMPI_ERRHANDLER_RETURN((rc == 1) ? OMPI_SUCCESS : OMPI_ERROR,
comm, MPI_ERR_UNKNOWN, FUNC_NAME);
} }

Просмотреть файл

@ -52,29 +52,30 @@ int MPI_Unpack(void *inbuf, int insize, int *position,
local_convertor = OBJ_NEW(ompi_convertor_t); local_convertor = OBJ_NEW(ompi_convertor_t);
ompi_convertor_init_for_recv(local_convertor, 0, datatype, outcount, ompi_convertor_init_for_recv(local_convertor, 0, datatype, outcount,
inbuf, 0); outbuf, 0);
/* how long is the data ? Can we put it in the user buffer */ /* Check for truncation */
ompi_convertor_get_packed_size(local_convertor, &size); ompi_convertor_get_packed_size(local_convertor, &size);
if ((outcount - (*position)) < size) { if (*position + size >= insize) {
OBJ_RELEASE(local_convertor); OBJ_RELEASE(local_convertor);
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME); return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TRUNCATE, FUNC_NAME);
} }
/* Prepare the iovec withh all informations */ /* Prepare the iovec with all informations */
outvec.iov_base = (char*) inbuf + (*position);
/* If the position is not ZERO we already start outvec.iov_base = (char*) inbuf + (*position);
* the packing for this datatype.
*/
outvec.iov_len = insize - (*position); outvec.iov_len = insize - (*position);
/* Do the actual unpacking */ /* Do the actual unpacking */
rc = ompi_convertor_unpack(local_convertor, &outvec, 1); rc = ompi_convertor_unpack(local_convertor, &outvec, 1);
*position += local_convertor->bConverted; *position += local_convertor->bConverted;
/* All done */
OBJ_RELEASE(local_convertor); OBJ_RELEASE(local_convertor);
OMPI_ERRHANDLER_RETURN(rc, comm, MPI_ERR_UNKNOWN, FUNC_NAME);
/* All done. Note that the convertor returns 1 upon success, not
OMPI_SUCCESS. */
OMPI_ERRHANDLER_RETURN((rc == 1) ? OMPI_SUCCESS : OMPI_ERROR,
comm, MPI_ERR_UNKNOWN, FUNC_NAME);
} }