2004-01-16 02:57:16 +03:00
|
|
|
/*
|
2004-11-22 04:38:40 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
|
|
* All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
|
|
* All rights reserved.
|
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-01-16 02:57:16 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#ifndef OMPI_FILE_H
|
|
|
|
#define OMPI_FILE_H
|
2004-01-16 02:57:16 +03:00
|
|
|
|
|
|
|
#include "mpi.h"
|
2004-03-19 03:00:09 +03:00
|
|
|
#include "errhandler/errhandler.h"
|
2004-08-14 05:56:05 +04:00
|
|
|
#include "threads/mutex.h"
|
2004-03-17 21:45:16 +03:00
|
|
|
#include "mca/io/io.h"
|
2004-01-16 02:57:16 +03:00
|
|
|
|
2004-08-14 05:56:05 +04:00
|
|
|
/*
|
|
|
|
* Flags
|
|
|
|
*/
|
|
|
|
#define OMPI_FILE_ISCLOSED 0x00000001
|
|
|
|
#define OMPI_FILE_HIDDEN 0x00000002
|
|
|
|
|
2004-10-21 02:31:03 +04:00
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2004-08-14 05:56:05 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Back-end structure for MPI_File
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
struct ompi_file_t {
|
2004-09-14 14:55:10 +04:00
|
|
|
/** Base of OBJ_* interface */
|
2004-08-14 05:56:05 +04:00
|
|
|
ompi_object_t super;
|
|
|
|
|
2004-09-14 14:55:10 +04:00
|
|
|
/** Communicator that this file was created with */
|
2004-11-05 10:52:30 +03:00
|
|
|
struct ompi_communicator_t *f_comm;
|
2004-01-16 02:57:16 +03:00
|
|
|
|
2004-09-14 14:55:10 +04:00
|
|
|
/** Filename that this file was created with */
|
2004-08-14 05:56:05 +04:00
|
|
|
char *f_filename;
|
2004-01-16 02:57:16 +03:00
|
|
|
|
2004-09-14 14:55:10 +04:00
|
|
|
/** Amode that this file was created with */
|
2004-08-14 05:56:05 +04:00
|
|
|
int f_amode;
|
2004-09-14 14:55:10 +04:00
|
|
|
|
|
|
|
/** MPI_Info that this file was created with */
|
2004-11-05 10:52:30 +03:00
|
|
|
struct ompi_info_t *f_info;
|
2004-09-14 14:55:10 +04:00
|
|
|
|
|
|
|
/** Bit flags */
|
2004-08-14 05:56:05 +04:00
|
|
|
int32_t f_flags;
|
2004-01-16 02:57:16 +03:00
|
|
|
|
2004-09-14 14:55:10 +04:00
|
|
|
/** Index in Fortran <-> C translation array */
|
2004-08-14 05:56:05 +04:00
|
|
|
int f_f_to_c_index;
|
2004-03-19 03:00:09 +03:00
|
|
|
|
2004-09-14 14:55:10 +04:00
|
|
|
/** Error handler. This field does not have the "f_" prefix so
|
|
|
|
that the OMPI_ERRHDL_* macros can find it, regardless of
|
|
|
|
whether it's a comm, window, or file. */
|
2004-11-05 10:52:30 +03:00
|
|
|
struct ompi_errhandler_t *error_handler;
|
2004-09-14 14:55:10 +04:00
|
|
|
|
|
|
|
/** Type of the error handler. This field does not have the "f_"
|
|
|
|
prefix for the same reason as the field error_handler. */
|
|
|
|
ompi_errhandler_type_t errhandler_type;
|
2004-08-14 05:56:05 +04:00
|
|
|
|
2004-09-14 14:55:10 +04:00
|
|
|
/** Indicate what version of the IO component we're using (this
|
|
|
|
indicates what member to look at in the union, below) */
|
|
|
|
mca_io_base_version_t f_io_version;
|
|
|
|
|
|
|
|
/** The selected module (note that this is a union) */
|
|
|
|
mca_io_base_modules_t f_io_selected_module;
|
|
|
|
|
|
|
|
/** Allow the selected module to cache data on the file */
|
|
|
|
struct mca_io_base_file_t *f_io_selected_data;
|
|
|
|
|
|
|
|
/* JMS: also put io request freelist here */
|
2004-01-16 02:57:16 +03:00
|
|
|
};
|
2004-08-14 05:56:05 +04:00
|
|
|
/**
|
|
|
|
* Convenience typedef
|
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
typedef struct ompi_file_t ompi_file_t;
|
2004-01-16 02:57:16 +03:00
|
|
|
|
2004-08-14 05:56:05 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Back-end instances for MPI_FILE_NULL
|
|
|
|
*/
|
2004-10-22 20:06:05 +04:00
|
|
|
OMPI_DECLSPEC extern ompi_file_t ompi_mpi_file_null;
|
2004-08-14 05:56:05 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fortran to C conversion table
|
|
|
|
*/
|
2004-10-22 20:06:05 +04:00
|
|
|
OMPI_DECLSPEC extern ompi_pointer_array_t ompi_file_f_to_c_table;
|
2004-08-14 05:56:05 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize MPI_File handling.
|
|
|
|
*
|
|
|
|
* @retval OMPI_SUCCESS Always.
|
|
|
|
*
|
|
|
|
* Invoked during ompi_mpi_init().
|
|
|
|
*/
|
|
|
|
int ompi_file_init(void);
|
|
|
|
|
|
|
|
/**
|
2004-09-14 14:55:10 +04:00
|
|
|
* Back-end to MPI_FILE_OPEN: create a file handle, select an io
|
|
|
|
* component to use, and have that componet open the file.
|
2004-08-14 05:56:05 +04:00
|
|
|
*
|
|
|
|
* @param comm Communicator
|
|
|
|
* @param filename String filename
|
|
|
|
* @param amode Mode flags
|
|
|
|
* @param info Info
|
|
|
|
* @param fh Output file handle
|
|
|
|
*
|
|
|
|
* @retval OMPI_SUCCESS Upon success
|
|
|
|
* @retval OMPI_ERR* Upon error
|
|
|
|
*
|
|
|
|
* Create a file handle and select an io module to be paired with
|
2004-09-14 14:55:10 +04:00
|
|
|
* it. There is a corresponding ompi_file_close() function; it
|
|
|
|
* mainly calls OBJ_RELEASE() but also does some other error
|
|
|
|
* handling as well.
|
2004-08-14 05:56:05 +04:00
|
|
|
*/
|
2004-11-05 10:52:30 +03:00
|
|
|
int ompi_file_open(struct ompi_communicator_t *comm, char *filename,
|
|
|
|
int amode, struct ompi_info_t *info,
|
2004-08-14 05:56:05 +04:00
|
|
|
ompi_file_t **fh);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Atomicly set a name on a file handle.
|
|
|
|
*
|
|
|
|
* @param file MPI_File handle to set the name on
|
|
|
|
* @param name NULL-terminated string to use
|
|
|
|
*
|
|
|
|
* @returns OMPI_SUCCESS Always.
|
|
|
|
*
|
|
|
|
* At most (MPI_MAX_OBJECT_NAME-1) characters will be copied over to
|
|
|
|
* the file name's name. This function is performed atomically -- a
|
|
|
|
* lock is used to ensure that there are not multiple writers to the
|
|
|
|
* name to ensure that we don't end up with an erroneous name (e.g.,
|
|
|
|
* a name without a \0 at the end). After invoking this function,
|
|
|
|
* ompi_file_is_name_set() will return true.
|
|
|
|
*/
|
|
|
|
int ompi_file_set_name(ompi_file_t *file, char *name);
|
2004-09-14 14:55:10 +04:00
|
|
|
|
2004-08-14 05:56:05 +04:00
|
|
|
/**
|
2004-09-14 14:55:10 +04:00
|
|
|
* Back-end to MPI_FILE_CLOSE: destroy an ompi_file_t handle and
|
|
|
|
* close the file.
|
2004-08-14 05:56:05 +04:00
|
|
|
*
|
2004-09-14 14:55:10 +04:00
|
|
|
* @param file Pointer to ompi_file_t
|
2004-08-14 05:56:05 +04:00
|
|
|
*
|
|
|
|
* @returns OMPI_SUCCESS Always.
|
|
|
|
*
|
2004-09-14 14:55:10 +04:00
|
|
|
* This is the preferred mechanism for freeing an ompi_file_t.
|
|
|
|
* Although the main action that it performs is OBJ_RELEASE(), it
|
|
|
|
* also does some additional handling for error checking, etc.
|
2004-08-14 05:56:05 +04:00
|
|
|
*/
|
|
|
|
int ompi_file_close(ompi_file_t **file);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tear down MPI_File handling.
|
|
|
|
*
|
|
|
|
* @retval OMPI_SUCCESS Always.
|
|
|
|
*
|
|
|
|
* Invoked during ompi_mpi_finalize().
|
|
|
|
*/
|
|
|
|
int ompi_file_finalize(void);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check to see if an MPI_File handle is valid.
|
|
|
|
*
|
|
|
|
* @param file The MPI file handle
|
|
|
|
*
|
|
|
|
* @retval true If the file handle is not valid
|
|
|
|
* @retval false If the file handle is valid
|
|
|
|
*
|
|
|
|
* This is a convenience function, mainly for error checking in
|
|
|
|
* top-level MPI API functions.
|
|
|
|
*/
|
|
|
|
static inline bool ompi_file_invalid(ompi_file_t *file)
|
|
|
|
{
|
|
|
|
return (NULL == file ||
|
|
|
|
&ompi_mpi_file_null == file ||
|
|
|
|
0 != (file->f_flags & OMPI_FILE_ISCLOSED));
|
|
|
|
}
|
|
|
|
|
2004-10-21 02:31:03 +04:00
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
2004-06-07 19:33:53 +04:00
|
|
|
#endif /* OMPI_FILE_H */
|