|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/* (C) 2012 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include "mpioimpl.h"
|
|
Packit Service |
c5cf8c |
#include "mpiu_external32.h"
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_WEAK_SYMBOLS
|
|
Packit Service |
c5cf8c |
/* Include mapping from MPI->PMPI */
|
|
Packit Service |
c5cf8c |
#define MPIO_BUILD_PROFILING
|
|
Packit Service |
c5cf8c |
#include "mpioprof.h"
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int MPIU_write_external32_conversion_fn(const void *userbuf, MPI_Datatype datatype,
|
|
Packit Service |
c5cf8c |
int count, void *filebuf)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int position_i = 0;
|
|
Packit Service |
c5cf8c |
MPI_Aint position = 0;
|
|
Packit Service |
c5cf8c |
MPI_Aint bytes = 0;
|
|
Packit Service |
c5cf8c |
int mpi_errno = MPI_SUCCESS;
|
|
Packit Service |
c5cf8c |
int is_contig = 0;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
ADIOI_Datatype_iscontig(datatype, &is_contig);
|
|
Packit Service |
c5cf8c |
mpi_errno = MPI_Pack_external_size("external32", count, datatype, &bytes);
|
|
Packit Service |
c5cf8c |
if (mpi_errno != MPI_SUCCESS)
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (is_contig) {
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_MPIIO_CONST
|
|
Packit Service |
c5cf8c |
mpi_errno = MPI_Pack_external("external32", userbuf, count,
|
|
Packit Service |
c5cf8c |
datatype, filebuf, bytes, &position);
|
|
Packit Service |
c5cf8c |
#else
|
|
Packit Service |
c5cf8c |
mpi_errno = MPI_Pack_external("external32", (void *) userbuf, count,
|
|
Packit Service |
c5cf8c |
datatype, filebuf, bytes, &position);
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
if (mpi_errno != MPI_SUCCESS)
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
void *tmp_buf = NULL;
|
|
Packit Service |
c5cf8c |
tmp_buf = ADIOI_Malloc(bytes);
|
|
Packit Service |
c5cf8c |
if (!tmp_buf) {
|
|
Packit Service |
c5cf8c |
mpi_errno = MPI_ERR_NO_MEM;
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_MPIIO_CONST
|
|
Packit Service |
c5cf8c |
mpi_errno = MPI_Pack_external("external32", userbuf, count,
|
|
Packit Service |
c5cf8c |
datatype, tmp_buf, bytes, &position);
|
|
Packit Service |
c5cf8c |
#else
|
|
Packit Service |
c5cf8c |
mpi_errno = MPI_Pack_external("external32", (void *) userbuf, count,
|
|
Packit Service |
c5cf8c |
datatype, tmp_buf, bytes, &position);
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
if (mpi_errno != MPI_SUCCESS) {
|
|
Packit Service |
c5cf8c |
ADIOI_Free(tmp_buf);
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
mpi_errno = MPI_Unpack(tmp_buf, bytes, &position_i, filebuf, count,
|
|
Packit Service |
c5cf8c |
datatype, MPI_COMM_WORLD);
|
|
Packit Service |
c5cf8c |
if (mpi_errno != MPI_SUCCESS) {
|
|
Packit Service |
c5cf8c |
ADIOI_Free(tmp_buf);
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
ADIOI_Free(tmp_buf);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
fn_exit:
|
|
Packit Service |
c5cf8c |
return mpi_errno;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int MPIU_read_external32_conversion_fn(void *userbuf, MPI_Datatype datatype,
|
|
Packit Service |
c5cf8c |
int count, void *filebuf)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int position_i = 0;
|
|
Packit Service |
c5cf8c |
MPI_Aint position = 0;
|
|
Packit Service |
c5cf8c |
MPI_Aint bytes = 0;
|
|
Packit Service |
c5cf8c |
int mpi_errno = MPI_SUCCESS;
|
|
Packit Service |
c5cf8c |
int is_contig = 0;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
ADIOI_Datatype_iscontig(datatype, &is_contig);
|
|
Packit Service |
c5cf8c |
mpi_errno = MPI_Pack_external_size("external32", count, datatype, &bytes);
|
|
Packit Service |
c5cf8c |
if (mpi_errno != MPI_SUCCESS)
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (is_contig) {
|
|
Packit Service |
c5cf8c |
mpi_errno = MPI_Unpack_external("external32", filebuf, bytes,
|
|
Packit Service |
c5cf8c |
&position, userbuf, count, datatype);
|
|
Packit Service |
c5cf8c |
if (mpi_errno != MPI_SUCCESS)
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
void *tmp_buf = NULL;
|
|
Packit Service |
c5cf8c |
tmp_buf = ADIOI_Malloc(bytes);
|
|
Packit Service |
c5cf8c |
if (!tmp_buf) {
|
|
Packit Service |
c5cf8c |
mpi_errno = MPI_ERR_NO_MEM;
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
mpi_errno = MPI_Pack(filebuf, count, datatype, tmp_buf, bytes, &position_i, MPI_COMM_WORLD);
|
|
Packit Service |
c5cf8c |
if (mpi_errno != MPI_SUCCESS) {
|
|
Packit Service |
c5cf8c |
ADIOI_Free(tmp_buf);
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
mpi_errno = MPI_Unpack_external("external32", tmp_buf, bytes,
|
|
Packit Service |
c5cf8c |
&position, userbuf, count, datatype);
|
|
Packit Service |
c5cf8c |
if (mpi_errno != MPI_SUCCESS) {
|
|
Packit Service |
c5cf8c |
ADIOI_Free(tmp_buf);
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
ADIOI_Free(tmp_buf);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
fn_exit:
|
|
Packit Service |
c5cf8c |
return mpi_errno;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int MPIU_datatype_full_size(MPI_Datatype datatype, MPI_Aint * size)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int error_code = MPI_SUCCESS;
|
|
Packit Service |
c5cf8c |
MPI_Aint true_extent = 0;
|
|
Packit Service |
c5cf8c |
MPI_Aint true_lb = 0;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
error_code = MPI_Type_get_true_extent(datatype, &true_lb, &true_extent);
|
|
Packit Service |
c5cf8c |
if (error_code != MPI_SUCCESS)
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
*size = true_extent;
|
|
Packit Service |
c5cf8c |
fn_exit:
|
|
Packit Service |
c5cf8c |
return error_code;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* given a buffer, count, and datatype, return an apropriately allocated, sized
|
|
Packit Service |
c5cf8c |
* and external32-formatted buffer, suitable for handing off to a subsequent
|
|
Packit Service |
c5cf8c |
* write routine. Caller is responsible for freeing 'newbuf' */
|
|
Packit Service |
c5cf8c |
int MPIU_external32_buffer_setup(const void *buf, int count, MPI_Datatype type, void **newbuf)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Aint datatype_size = 0, bytes = 0;
|
|
Packit Service |
c5cf8c |
int error_code;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
error_code = MPIU_datatype_full_size(type, &datatype_size);
|
|
Packit Service |
c5cf8c |
if (error_code != MPI_SUCCESS)
|
|
Packit Service |
c5cf8c |
return error_code;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
bytes = datatype_size * count;
|
|
Packit Service |
c5cf8c |
*newbuf = ADIOI_Malloc(bytes);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
error_code = MPIU_write_external32_conversion_fn(buf, type, count, *newbuf);
|
|
Packit Service |
c5cf8c |
if (error_code != MPI_SUCCESS) {
|
|
Packit Service |
c5cf8c |
ADIOI_Free(*newbuf);
|
|
Packit Service |
c5cf8c |
return error_code;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
return MPI_SUCCESS;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* vim: ts=8 sts=4 sw=4 noexpandtab
|
|
Packit Service |
c5cf8c |
*/
|