|
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_seek_shared = PMPI_File_seek_shared
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
|
|
Packit Service |
c5cf8c |
#pragma _HP_SECONDARY_DEF PMPI_File_seek_shared MPI_File_seek_shared
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_CRI_DUP)
|
|
Packit Service |
c5cf8c |
#pragma _CRI duplicate MPI_File_seek_shared as PMPI_File_seek_shared
|
|
Packit Service |
c5cf8c |
/* end of weak pragmas */
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_WEAK_ATTRIBUTE)
|
|
Packit Service |
c5cf8c |
int MPI_File_seek_shared(MPI_File fh, MPI_Offset offset, int whence)
|
|
Packit Service |
c5cf8c |
__attribute__ ((weak, alias("PMPI_File_seek_shared")));
|
|
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 |
/*@
|
|
Packit Service |
c5cf8c |
MPI_File_seek_shared - Updates the shared file pointer
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Input Parameters:
|
|
Packit Service |
c5cf8c |
. fh - file handle (handle)
|
|
Packit Service |
c5cf8c |
. offset - file offset (integer)
|
|
Packit Service |
c5cf8c |
. whence - update mode (state)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
.N fortran
|
|
Packit Service |
c5cf8c |
@*/
|
|
Packit Service |
c5cf8c |
int MPI_File_seek_shared(MPI_File fh, MPI_Offset offset, int whence)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int error_code = MPI_SUCCESS, tmp_whence, myrank;
|
|
Packit Service |
c5cf8c |
static char myname[] = "MPI_FILE_SEEK_SHARED";
|
|
Packit Service |
c5cf8c |
MPI_Offset curr_offset, eof_offset, tmp_offset;
|
|
Packit Service |
c5cf8c |
ADIO_File adio_fh;
|
|
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_NOT_SEQUENTIAL_MODE(adio_fh, myname, error_code);
|
|
Packit Service |
c5cf8c |
MPIO_CHECK_FS_SUPPORTS_SHARED(adio_fh, myname, error_code);
|
|
Packit Service |
c5cf8c |
/* --END ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
tmp_offset = offset;
|
|
Packit Service |
c5cf8c |
MPI_Bcast(&tmp_offset, 1, ADIO_OFFSET, 0, adio_fh->comm);
|
|
Packit Service |
c5cf8c |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
if (tmp_offset != offset) {
|
|
Packit Service |
c5cf8c |
error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
|
|
Packit Service |
c5cf8c |
myname, __LINE__, MPI_ERR_ARG, "**notsame", 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 |
tmp_whence = whence;
|
|
Packit Service |
c5cf8c |
MPI_Bcast(&tmp_whence, 1, MPI_INT, 0, adio_fh->comm);
|
|
Packit Service |
c5cf8c |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
if (tmp_whence != whence) {
|
|
Packit Service |
c5cf8c |
error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
|
|
Packit Service |
c5cf8c |
myname, __LINE__, MPI_ERR_ARG, "**iobadwhence", 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 |
ADIOI_TEST_DEFERRED(adio_fh, "MPI_File_seek_shared", &error_code);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Comm_rank(adio_fh->comm, &myrank);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (!myrank) {
|
|
Packit Service |
c5cf8c |
switch (whence) {
|
|
Packit Service |
c5cf8c |
case MPI_SEEK_SET:
|
|
Packit Service |
c5cf8c |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
if (offset < 0) {
|
|
Packit Service |
c5cf8c |
error_code = MPIO_Err_create_code(MPI_SUCCESS,
|
|
Packit Service |
c5cf8c |
MPIR_ERR_RECOVERABLE,
|
|
Packit Service |
c5cf8c |
myname, __LINE__,
|
|
Packit Service |
c5cf8c |
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 |
break;
|
|
Packit Service |
c5cf8c |
case MPI_SEEK_CUR:
|
|
Packit Service |
c5cf8c |
/* get current location of shared file pointer */
|
|
Packit Service |
c5cf8c |
ADIO_Get_shared_fp(adio_fh, 0, &curr_offset, &error_code);
|
|
Packit Service |
c5cf8c |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
if (error_code != MPI_SUCCESS) {
|
|
Packit Service |
c5cf8c |
error_code = MPIO_Err_create_code(MPI_SUCCESS,
|
|
Packit Service |
c5cf8c |
MPIR_ERR_FATAL,
|
|
Packit Service |
c5cf8c |
myname, __LINE__,
|
|
Packit Service |
c5cf8c |
MPI_ERR_INTERN, "**iosharedfailed", 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 |
offset += curr_offset;
|
|
Packit Service |
c5cf8c |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
if (offset < 0) {
|
|
Packit Service |
c5cf8c |
error_code = MPIO_Err_create_code(MPI_SUCCESS,
|
|
Packit Service |
c5cf8c |
MPIR_ERR_RECOVERABLE,
|
|
Packit Service |
c5cf8c |
myname, __LINE__,
|
|
Packit Service |
c5cf8c |
MPI_ERR_ARG, "**ionegoffset", 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 |
break;
|
|
Packit Service |
c5cf8c |
case MPI_SEEK_END:
|
|
Packit Service |
c5cf8c |
/* find offset corr. to end of file */
|
|
Packit Service |
c5cf8c |
ADIOI_Get_eof_offset(adio_fh, &eof_offset);
|
|
Packit Service |
c5cf8c |
offset += eof_offset;
|
|
Packit Service |
c5cf8c |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
if (offset < 0) {
|
|
Packit Service |
c5cf8c |
error_code = MPIO_Err_create_code(MPI_SUCCESS,
|
|
Packit Service |
c5cf8c |
MPIR_ERR_RECOVERABLE,
|
|
Packit Service |
c5cf8c |
myname, __LINE__,
|
|
Packit Service |
c5cf8c |
MPI_ERR_ARG, "**ionegoffset", 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 |
break;
|
|
Packit Service |
c5cf8c |
default:
|
|
Packit Service |
c5cf8c |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
error_code = MPIO_Err_create_code(MPI_SUCCESS,
|
|
Packit Service |
c5cf8c |
MPIR_ERR_RECOVERABLE,
|
|
Packit Service |
c5cf8c |
myname, __LINE__, MPI_ERR_ARG,
|
|
Packit Service |
c5cf8c |
"**iobadwhence", 0);
|
|
Packit Service |
c5cf8c |
error_code = MPIO_Err_return_file(adio_fh, error_code);
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
/* --END ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
ADIO_Set_shared_fp(adio_fh, offset, &error_code);
|
|
Packit Service |
c5cf8c |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
if (error_code != MPI_SUCCESS) {
|
|
Packit Service |
c5cf8c |
error_code = MPIO_Err_create_code(MPI_SUCCESS,
|
|
Packit Service |
c5cf8c |
MPIR_ERR_FATAL,
|
|
Packit Service |
c5cf8c |
myname, __LINE__,
|
|
Packit Service |
c5cf8c |
MPI_ERR_INTERN, "**iosharedfailed", 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 |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* FIXME: explain why the barrier is necessary */
|
|
Packit Service |
c5cf8c |
MPI_Barrier(adio_fh->comm);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
error_code = MPI_SUCCESS;
|
|
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 |
}
|