summaryrefslogtreecommitdiffstats
path: root/src/H5FDsubfiling/H5FDioc.h
blob: 2b68d9c485ad44e9a82c8cceab685320c9281851 (plain)
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
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by The HDF Group.                                               *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF5.  The full HDF5 copyright notice, including     *
 * terms governing use, modification, and redistribution, is contained in    *
 * the COPYING file, which can be found at the root of the source code       *
 * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.  *
 * If you do not have access to either file, you may request a copy from     *
 * help@hdfgroup.org.                                                        *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/*
 * Purpose:	The public header file for the "I/O concentrator" driver.
 * This provides a similar functionality to that of the subfiling driver
 * but introduces the necessary file access functionality via a multi-
 * threading MPI service
 */

#ifndef H5FDioc_H
#define H5FDioc_H

#include "H5FDsubfiling.h"

#ifdef H5_HAVE_IOC_VFD
/**
 * \def H5FD_IOC
 * Macro that returns the identifier for the #H5FD_IOC driver. \hid_t{file driver}
 */
#define H5FD_IOC (H5FDperform_init(H5FD_ioc_init))
#else
#define H5FD_IOC (H5I_INVALID_HID)
#endif

/**
 * \def H5FD_IOC_NAME
 * The canonical name for the #H5FD_IOC driver
 */
#define H5FD_IOC_NAME "ioc"

#ifdef H5_HAVE_IOC_VFD

#ifndef H5FD_IOC_FAPL_MAGIC
/**
 * \def H5FD_IOC_CURR_FAPL_VERSION
 * The version number of the H5FD_ioc_config_t configuration
 * structure for the #H5FD_IOC driver
 */
#define H5FD_IOC_CURR_FAPL_VERSION 1
/**
 * \def H5FD_IOC_FAPL_MAGIC
 * Unique number used to distinguish the #H5FD_IOC driver from other HDF5 file drivers
 */
#define H5FD_IOC_FAPL_MAGIC 0xFED21331
#endif

/**
 * \def H5FD_IOC_DEFAULT_THREAD_POOL_SIZE
 * The default number of I/O concentrator worker threads
 */
#define H5FD_IOC_DEFAULT_THREAD_POOL_SIZE 4

/*
 * Environment variables interpreted by the IOC VFD
 */

/**
 * \def H5FD_IOC_THREAD_POOL_SIZE
 * Macro for name of the environment variable that controls/overrides
 * the number of I/O concentrator worker threads
 *
 * The value set for this environment variable is interpreted as an
 * int value and must be > 0.
 */
#define H5FD_IOC_THREAD_POOL_SIZE "H5FD_IOC_THREAD_POOL_SIZE"

//! <!-- [H5FD_ioc_config_t_snip] -->
/**
 * \struct H5FD_ioc_config_t
 * \brief Configuration structure for H5Pset_fapl_ioc() / H5Pget_fapl_ioc()
 *
 * \details H5FD_ioc_config_t is a public structure that is used to pass
 *          configuration data to the #H5FD_IOC driver via a File Access
 *          Property List. A pointer to an instance of this structure is
 *          a parameter to H5Pset_fapl_ioc() and H5Pget_fapl_ioc().
 *
 * \var uint32_t H5FD_ioc_config_t::magic
 *      A somewhat unique number which distinguishes the #H5FD_IOC driver
 *      from other drivers. Used in combination with a version number, it
 *      can help to validate a user-generated File Access Property List.
 *      This field should be set to #H5FD_IOC_FAPL_MAGIC.
 *
 * \var uint32_t H5FD_ioc_config_t::version
 *      Version number of the H5FD_ioc_config_t structure. Any instance passed
 *      to H5Pset_fapl_ioc() / H5Pget_fapl_ioc() must have a recognized version
 *      number or an error will be raised. Currently, this field should be set
 *      to #H5FD_IOC_CURR_FAPL_VERSION.
 *
 * \var int32_t H5FD_ioc_config_t::thread_pool_size
 *      The number of I/O concentrator worker threads to use.
 *
 *      This value can also be set or adjusted with the #H5FD_IOC_THREAD_POOL_SIZE
 *      environment variable.
 *
 */
typedef struct H5FD_ioc_config_t {
    uint32_t magic;            /* Must be set to H5FD_IOC_FAPL_MAGIC */
    uint32_t version;          /* Must be set to H5FD_IOC_CURR_FAPL_VERSION */
    int32_t  thread_pool_size; /* Number of I/O concentrator worker threads to use */
} H5FD_ioc_config_t;
//! <!-- [H5FD_ioc_config_t_snip] -->

#ifdef __cplusplus
extern "C" {
#endif

/**
 * \brief Internal routine to initialize #H5FD_IOC driver. Not meant to be
 *        called directly by an HDF5 application
 */
H5_DLL hid_t H5FD_ioc_init(void);
/**
 * \ingroup FAPL
 *
 * \brief Modifies the specified File Access Property List to use the #H5FD_IOC driver
 *
 * \fapl_id
 * \param[in] vfd_config Pointer to #H5FD_IOC driver configuration structure. May be NULL.
 * \returns \herr_t
 *
 * \details H5Pset_fapl_ioc() modifies the File Access Property List to use the
 *          #H5FD_IOC driver.
 *
 *          The #H5FD_IOC driver is a reference implementation of an "I/O concentrator"
 *          file driver that works in conjunction with the #H5FD_SUBFILING driver and
 *          provides the I/O backend for servicing I/O requests to subfiles.
 *
 *          Typically, an HDF5 application won't need to call this routine directly.
 *          The #H5FD_IOC driver is usually set up as a side effect of an HDF5 application
 *          using the #H5FD_SUBFILING driver, but this routine is provided in case the
 *          application wishes to manually configure the #H5FD_IOC driver.
 *
 * \note The \p vfd_config parameter may be NULL. In this case, the driver will
 *       be setup with default settings. Note that in this case, it is assumed
 *       the parent #H5FD_SUBFILING driver was also setup with default settings.
 *       If the two drivers differ in configuration settings, application behavior
 *       may not be as expected.
 *
 * \since 1.13.2
 *
 */
H5_DLL herr_t H5Pset_fapl_ioc(hid_t fapl_id, H5FD_ioc_config_t *vfd_config);
/**
 * \ingroup FAPL
 *
 * \brief Queries a File Access Property List for #H5FD_IOC file driver properties
 *
 * \fapl_id
 * \param[out] config_out Pointer to H5FD_ioc_config_t structure through which the
 *                        #H5FD_IOC file driver properties will be returned.
 *
 * \returns \herr_t
 *
 * \details H5Pget_fapl_ioc() queries the specified File Access Property List for
 *          #H5FD_IOC driver properties as set by H5Pset_fapl_ioc(). If the #H5FD_IOC
 *          driver has not been set on the File Access Property List, a default
 *          configuration is returned. An HDF5 application may use this functionality
 *          to manually configure the #H5FD_IOC driver by calling H5Pget_fapl_ioc()
 *          on a newly-created File Access Property List, adjusting the default
 *          values and then calling H5Pset_fapl_ioc() with the configured
 *          H5FD_ioc_config_t structure.
 *
 * \since 1.13.2
 *
 */
H5_DLL herr_t H5Pget_fapl_ioc(hid_t fapl_id, H5FD_ioc_config_t *config_out);
/**
 * \brief Internal routine for managing exclusive access to critical sections
 *        by the #H5FD_IOC driver's worker threads. Not meant to be called
 *        directly by an HDF5 application
 */
H5_DLL void H5FD_ioc_begin_thread_exclusive(void);
/**
 * \brief Internal routine for managing exclusive access to critical sections
 *        by the #H5FD_IOC driver's worker threads. Not meant to be called
 *        directly by an HDF5 application
 */
H5_DLL void H5FD_ioc_end_thread_exclusive(void);

#ifdef __cplusplus
}
#endif

#endif /* H5_HAVE_IOC_VFD */

#endif