|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* Copyright (C) 1997 University of Chicago.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT notice in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include "mpioimpl.h"
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_WEAK_SYMBOLS
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#if defined(HAVE_PRAGMA_WEAK)
|
|
Packit Service |
c5cf8c |
#pragma weak MPI_File_read = PMPI_File_read
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
|
|
Packit Service |
c5cf8c |
#pragma _HP_SECONDARY_DEF PMPI_File_read MPI_File_read
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_CRI_DUP)
|
|
Packit Service |
c5cf8c |
#pragma _CRI duplicate MPI_File_read as PMPI_File_read
|
|
Packit Service |
c5cf8c |
/* end of weak pragmas */
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_WEAK_ATTRIBUTE)
|
|
Packit Service |
c5cf8c |
int MPI_File_read(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Status * status)
|
|
Packit Service |
c5cf8c |
__attribute__ ((weak, alias("PMPI_File_read")));
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
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 |
/* status object not filled currently */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/*@
|
|
Packit Service |
c5cf8c |
MPI_File_read - Read using individual file pointer
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Input Parameters:
|
|
Packit Service |
c5cf8c |
. fh - file handle (handle)
|
|
Packit Service |
c5cf8c |
. count - number of elements in buffer (nonnegative integer)
|
|
Packit Service |
c5cf8c |
. datatype - datatype of each buffer element (handle)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Output Parameters:
|
|
Packit Service |
c5cf8c |
. buf - initial address of buffer (choice)
|
|
Packit Service |
c5cf8c |
. status - status object (Status)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
.N fortran
|
|
Packit Service |
c5cf8c |
@*/
|
|
Packit Service |
c5cf8c |
int MPI_File_read(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Status * status)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int error_code;
|
|
Packit Service |
c5cf8c |
static char myname[] = "MPI_FILE_READ";
|
|
Packit Service |
c5cf8c |
#ifdef MPI_hpux
|
|
Packit Service |
c5cf8c |
int fl_xmpi;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
HPMP_IO_START(fl_xmpi, BLKMPIFILEREAD, TRDTBLOCK, fh, datatype, count);
|
|
Packit Service |
c5cf8c |
#endif /* MPI_hpux */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
error_code = MPIOI_File_read(fh, (MPI_Offset) 0, ADIO_INDIVIDUAL, buf,
|
|
Packit Service |
c5cf8c |
count, datatype, myname, status);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#ifdef MPI_hpux
|
|
Packit Service |
c5cf8c |
HPMP_IO_END(fl_xmpi, fh, datatype, count);
|
|
Packit Service |
c5cf8c |
#endif /* MPI_hpux */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
return error_code;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* prevent multiple definitions of this routine */
|
|
Packit Service |
c5cf8c |
#ifdef MPIO_BUILD_PROFILING
|
|
Packit Service |
c5cf8c |
int MPIOI_File_read(MPI_File fh,
|
|
Packit Service |
c5cf8c |
MPI_Offset offset,
|
|
Packit Service |
c5cf8c |
int file_ptr_type,
|
|
Packit Service |
c5cf8c |
void *buf, int count, MPI_Datatype datatype, char *myname, MPI_Status * status)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int error_code, buftype_is_contig, filetype_is_contig;
|
|
Packit Service |
c5cf8c |
MPI_Count datatype_size;
|
|
Packit Service |
c5cf8c |
ADIO_File adio_fh;
|
|
Packit Service |
c5cf8c |
ADIO_Offset off, bufsize;
|
|
Packit Service |
c5cf8c |
void *xbuf = NULL, *e32_buf = NULL;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
ROMIO_THREAD_CS_ENTER();
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
adio_fh = MPIO_File_resolve(fh);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
MPIO_CHECK_FILE_HANDLE(adio_fh, myname, error_code);
|
|
Packit Service |
c5cf8c |
MPIO_CHECK_COUNT(adio_fh, count, myname, error_code);
|
|
Packit Service |
c5cf8c |
MPIO_CHECK_DATATYPE(adio_fh, datatype, myname, error_code);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (file_ptr_type == ADIO_EXPLICIT_OFFSET && offset < 0) {
|
|
Packit Service |
c5cf8c |
error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
|
|
Packit Service |
c5cf8c |
myname, __LINE__, MPI_ERR_ARG, "**iobadoffset", 0);
|
|
Packit Service |
c5cf8c |
error_code = MPIO_Err_return_file(adio_fh, error_code);
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
/* --END ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Type_size_x(datatype, &datatype_size);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
MPIO_CHECK_COUNT_SIZE(adio_fh, count, datatype_size, myname, error_code);
|
|
Packit Service |
c5cf8c |
/* --END ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (count * datatype_size == 0) {
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_STATUS_SET_BYTES
|
|
Packit Service |
c5cf8c |
MPIR_Status_set_bytes(status, datatype, 0);
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
error_code = MPI_SUCCESS;
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
MPIO_CHECK_INTEGRAL_ETYPE(adio_fh, count, datatype_size, myname, error_code);
|
|
Packit Service |
c5cf8c |
MPIO_CHECK_READABLE(adio_fh, myname, error_code);
|
|
Packit Service |
c5cf8c |
MPIO_CHECK_NOT_SEQUENTIAL_MODE(adio_fh, myname, error_code);
|
|
Packit Service |
c5cf8c |
/* --END ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
ADIOI_Datatype_iscontig(datatype, &buftype_is_contig);
|
|
Packit Service |
c5cf8c |
ADIOI_Datatype_iscontig(adio_fh->filetype, &filetype_is_contig);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
ADIOI_TEST_DEFERRED(adio_fh, myname, &error_code);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
xbuf = buf;
|
|
Packit Service |
c5cf8c |
if (adio_fh->is_external32) {
|
|
Packit Service |
c5cf8c |
MPI_Aint e32_size = 0;
|
|
Packit Service |
c5cf8c |
error_code = MPIU_datatype_full_size(datatype, &e32_size);
|
|
Packit Service |
c5cf8c |
if (error_code != MPI_SUCCESS)
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
e32_buf = ADIOI_Malloc(e32_size * count);
|
|
Packit Service |
c5cf8c |
xbuf = e32_buf;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (buftype_is_contig && filetype_is_contig) {
|
|
Packit Service |
c5cf8c |
/* convert count and offset to bytes */
|
|
Packit Service |
c5cf8c |
bufsize = datatype_size * count;
|
|
Packit Service |
c5cf8c |
if (file_ptr_type == ADIO_EXPLICIT_OFFSET) {
|
|
Packit Service |
c5cf8c |
off = adio_fh->disp + adio_fh->etype_size * offset;
|
|
Packit Service |
c5cf8c |
} else { /* ADIO_INDIVIDUAL */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
off = adio_fh->fp_ind;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* if atomic mode requested, lock (exclusive) the region, because
|
|
Packit Service |
c5cf8c |
* there could be a concurrent noncontiguous request.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
if ((adio_fh->atomicity) && ADIO_Feature(adio_fh, ADIO_LOCKS)) {
|
|
Packit Service |
c5cf8c |
ADIOI_WRITE_LOCK(adio_fh, off, SEEK_SET, bufsize);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
ADIO_ReadContig(adio_fh, xbuf, count, datatype, file_ptr_type, off, status, &error_code);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if ((adio_fh->atomicity) && ADIO_Feature(adio_fh, ADIO_LOCKS)) {
|
|
Packit Service |
c5cf8c |
ADIOI_UNLOCK(adio_fh, off, SEEK_SET, bufsize);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
ADIO_ReadStrided(adio_fh, xbuf, count, datatype, file_ptr_type,
|
|
Packit Service |
c5cf8c |
offset, status, &error_code);
|
|
Packit Service |
c5cf8c |
/* For strided and atomic mode, locking is done in ADIO_ReadStrided */
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
if (error_code != MPI_SUCCESS)
|
|
Packit Service |
c5cf8c |
error_code = MPIO_Err_return_file(adio_fh, error_code);
|
|
Packit Service |
c5cf8c |
/* --END ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (e32_buf != NULL) {
|
|
Packit Service |
c5cf8c |
error_code = MPIU_read_external32_conversion_fn(buf, datatype, count, e32_buf);
|
|
Packit Service |
c5cf8c |
ADIOI_Free(e32_buf);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
fn_exit:
|
|
Packit Service |
c5cf8c |
ROMIO_THREAD_CS_EXIT();
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
return error_code;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
#endif
|