File: file.h

package info (click to toggle)
openmpi 5.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 202,312 kB
  • sloc: ansic: 612,441; makefile: 42,495; sh: 11,230; javascript: 9,244; f90: 7,052; java: 6,404; perl: 5,154; python: 1,856; lex: 740; fortran: 61; cpp: 20; tcl: 12
file content (210 lines) | stat: -rw-r--r-- 6,670 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
 *                         University Research and Technology
 *                         Corporation.  All rights reserved.
 * Copyright (c) 2004-2007 The University of Tennessee and The University
 *                         of Tennessee Research Foundation.  All rights
 *                         reserved.
 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
 *                         University of Stuttgart.  All rights reserved.
 * Copyright (c) 2004-2005 The Regents of the University of California.
 *                         All rights reserved.
 * Copyright (c) 2009      Sun Microsystems, Inc.  All rights reserved.
 * Copyright (c) 2009-2017 Cisco Systems, Inc.  All rights reserved
 * Copyright (c) 2015-2017 Research Organization for Information Science
 *                         and Technology (RIST). All rights reserved.
 * Copyright (c) 2016      University of Houston. All rights reserved.
 * Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
 * Copyright (c) 2018      Triad National Security, LLC. All rights
 *                         reserved.
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 */

#ifndef OMPI_FILE_H
#define OMPI_FILE_H

#include "ompi_config.h"
#include "mpi.h"
#include "opal/class/opal_list.h"
#include "ompi/errhandler/errhandler.h"
#include "opal/mca/threads/mutex.h"
#include "opal/util/info_subscriber.h"
#include "ompi/mca/io/io.h"

/*
 * Flags
 */
#define OMPI_FILE_ISCLOSED     0x00000001
#define OMPI_FILE_HIDDEN       0x00000002

BEGIN_C_DECLS

/**
 * Back-end structure for MPI_File
 */
struct ompi_file_t {
    /** Base of OBJ_* interface */
    opal_infosubscriber_t super;

    /** Communicator that this file was created with */
    struct ompi_communicator_t *f_comm;

    /** Filename that this file was created with */
    char *f_filename;

    /** Amode that this file was created with */
    int f_amode;

    /** Bit flags */
    int32_t f_flags;

    /** Index in Fortran <-> C translation array */
    int f_f_to_c_index;

    /** 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. */
    struct ompi_errhandler_t *error_handler;

    /** 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;

    /** 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;

    /** Mutex to be used to protect access to the selected component
        on a per file-handle basis */
    opal_mutex_t f_lock;

    /** The selected component (note that this is a union) -- we need
        this to add and remove the component from the list of
        components currently in use by the io framework for
        progression porpoises. */
    mca_io_base_components_t f_io_selected_component;

    /** 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;
};
/**
 * Convenience typedef
 */
typedef struct ompi_file_t ompi_file_t;

/**
 * Padded struct to maintain back compatibility.
 * See ompi/communicator/communicator.h comments with struct ompi_communicator_t
 * for full explanation why we chose the following padding construct for predefines.
 */
#define PREDEFINED_FILE_PAD 1536

struct ompi_predefined_file_t {
    struct ompi_file_t file;
    char padding[PREDEFINED_FILE_PAD - sizeof(ompi_file_t)];
};
typedef struct ompi_predefined_file_t ompi_predefined_file_t;

/**
 * Back-end instances for MPI_FILE_NULL (_addr flavor is for F03 bindings)
 */
OMPI_DECLSPEC extern ompi_predefined_file_t  ompi_mpi_file_null;
OMPI_DECLSPEC extern ompi_predefined_file_t  *ompi_mpi_file_null_addr;


/**
 * Fortran to C conversion table
 */
extern opal_pointer_array_t ompi_file_f_to_c_table;

/**
 * Initialize MPI_File handling.
 *
 * @retval OMPI_SUCCESS Always.
 *
 * Invoked during ompi_mpi_init().
 */
int ompi_file_init(void);

/**
 * Back-end to MPI_FILE_OPEN: create a file handle, select an io
 * component to use, and have that component open the file.
 *
 * @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
 * it.  There is a corresponding ompi_file_close() function; it
 * mainly calls OBJ_RELEASE() but also does some other error
 * handling as well.
 */
int ompi_file_open(struct ompi_communicator_t *comm, const char *filename,
                   int amode, struct opal_info_t *info,
                   ompi_file_t **fh);

/**
 * Atomically 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);

/**
 * Back-end to MPI_FILE_CLOSE: destroy an ompi_file_t handle and
 * close the file.
 *
 * @param file Pointer to ompi_file_t
 *
 * @returns OMPI_SUCCESS Always.
 *
 * 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.
 */
int ompi_file_close(ompi_file_t **file);

/**
 * 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 == file ||
            0 != (file->f_flags & OMPI_FILE_ISCLOSED));
}

END_C_DECLS

#endif /* OMPI_FILE_H */