1 /*
2  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3  *                         University Research and Technology
4  *                         Corporation.  All rights reserved.
5  * Copyright (c) 2004-2006 The University of Tennessee and The University
6  *                         of Tennessee Research Foundation.  All rights
7  *                         reserved.
8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9  *                         University of Stuttgart.  All rights reserved.
10  * Copyright (c) 2004-2005 The Regents of the University of California.
11  *                         All rights reserved.
12  * Copyright (c) 2008-2020 University of Houston. All rights reserved.
13  * Copyright (c) 2018      Research Organization for Information Science
14  *                         and Technology (RIST). All rights reserved.
15  * $COPYRIGHT$
16  *
17  * Additional copyrights may follow
18  *
19  * $HEADER$
20  */
21 
22 #ifndef MCA_FBTL_POSIX_H
23 #define MCA_FBTL_POSIX_H
24 
25 #include "ompi_config.h"
26 #include "ompi/mca/mca.h"
27 #include "ompi/mca/fbtl/fbtl.h"
28 #include "ompi/mca/common/ompio/common_ompio.h"
29 #include "ompi/mca/common/ompio/common_ompio_request.h"
30 
31 extern int mca_fbtl_posix_priority;
32 extern bool mca_fbtl_posix_read_datasieving;
33 extern bool mca_fbtl_posix_write_datasieving;
34 extern size_t mca_fbtl_posix_max_block_size;
35 extern size_t mca_fbtl_posix_max_gap_size;
36 extern size_t mca_fbtl_posix_max_tmpbuf_size;
37 
38 BEGIN_C_DECLS
39 
40 int mca_fbtl_posix_component_init_query(bool enable_progress_threads,
41                                         bool enable_mpi_threads);
42 struct mca_fbtl_base_module_1_0_0_t *
43 mca_fbtl_posix_component_file_query (ompio_file_t *file, int *priority);
44 int mca_fbtl_posix_component_file_unquery (ompio_file_t *file);
45 
46 int mca_fbtl_posix_module_init (ompio_file_t *file);
47 int mca_fbtl_posix_module_finalize (ompio_file_t *file);
48 
49 extern int fbtl_posix_max_aio_active_reqs;
50 
51 OMPI_MODULE_DECLSPEC extern mca_fbtl_base_component_2_0_0_t mca_fbtl_posix_component;
52 /*
53  * ******************************************************************
54  * ********* functions which are implemented in this module *********
55  * ******************************************************************
56  */
57 
58 ssize_t mca_fbtl_posix_preadv (ompio_file_t *file );
59 ssize_t mca_fbtl_posix_pwritev (ompio_file_t *file );
60 ssize_t mca_fbtl_posix_ipreadv (ompio_file_t *file,
61                                ompi_request_t *request);
62 ssize_t mca_fbtl_posix_ipwritev (ompio_file_t *file,
63                                 ompi_request_t *request);
64 
65 bool mca_fbtl_posix_progress     ( mca_ompio_request_t *req);
66 void mca_fbtl_posix_request_free ( mca_ompio_request_t *req);
67 
68 int mca_fbtl_posix_lock ( struct flock *lock, ompio_file_t *fh, int op,
69                           OMPI_MPI_OFFSET_TYPE iov_offset, off_t len, int flags);
70 void  mca_fbtl_posix_unlock ( struct flock *lock, ompio_file_t *fh );
71 
72 
73 struct mca_fbtl_posix_request_data_t {
74     int            aio_req_count;       /* total number of aio reqs */
75     int            aio_open_reqs;       /* number of unfinished reqs */
76     int            aio_req_type;        /* read or write */
77     int            aio_req_chunks;      /* max. no. of aio reqs that can be posted at once*/
78     int            aio_first_active_req; /* first active posted req */
79     int            aio_last_active_req;  /* last currently active poted req */
80     struct aiocb       *aio_reqs;       /* pointer array of req structures */
81     int          *aio_req_status;       /* array of statuses */
82     ssize_t        aio_total_len;       /* total amount of data written */
83     struct flock   aio_lock;            /* lock used for certain file systems */
84     ompio_file_t  *aio_fh;       /* pointer back to the mca_io_ompio_fh structure */
85 };
86 typedef struct mca_fbtl_posix_request_data_t mca_fbtl_posix_request_data_t;
87 
88 /* Right now statically defined, will become a configure check */
89 #define FBTL_POSIX_HAVE_AIO 1
90 
91 /* define constants for AIO requests */
92 #define FBTL_POSIX_READ 1
93 #define FBTL_POSIX_WRITE 2
94 
95 
96 /*
97  * ******************************************************************
98  * ************ functions implemented in this module end ************
99  * ******************************************************************
100  */
101 
102 END_C_DECLS
103 
104 #endif /* MCA_FBTL_POSIX_H */
105