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-2016 University of Houston. All rights reserved.
13 * Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
14 * Copyright (c) 2015-2018 Research Organization for Information Science
15 * and Technology (RIST). All rights reserved.
16 * Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
17 * $COPYRIGHT$
18 *
19 * Additional copyrights may follow
20 *
21 * $HEADER$
22 */
23
24 #ifndef MCA_SHAREDFP_sm_H
25 #define MCA_SHAREDFP_sm_H
26
27 #include "ompi_config.h"
28 #include "ompi/mca/mca.h"
29 #include "ompi/mca/sharedfp/sharedfp.h"
30 #include "ompi/mca/common/ompio/common_ompio.h"
31 #include <semaphore.h>
32
33 BEGIN_C_DECLS
34
35 int mca_sharedfp_sm_component_init_query(bool enable_progress_threads,
36 bool enable_mpi_threads);
37 struct mca_sharedfp_base_module_1_0_0_t *
38 mca_sharedfp_sm_component_file_query (ompio_file_t *file, int *priority);
39 int mca_sharedfp_sm_component_file_unquery (ompio_file_t *file);
40
41 int mca_sharedfp_sm_module_init (ompio_file_t *file);
42 int mca_sharedfp_sm_module_finalize (ompio_file_t *file);
43
44 extern int mca_sharedfp_sm_priority;
45 extern int mca_sharedfp_sm_verbose;
46
47 OMPI_MODULE_DECLSPEC extern mca_sharedfp_base_component_2_0_0_t mca_sharedfp_sm_component;
48 /*
49 * ******************************************************************
50 * ********* functions which are implemented in this module *********
51 * ******************************************************************
52 */
53 /*IMPORANT: Update here when implementing functions from sharedfp API*/
54 int mca_sharedfp_sm_seek (ompio_file_t *fh,
55 OMPI_MPI_OFFSET_TYPE offset, int whence);
56 int mca_sharedfp_sm_get_position (ompio_file_t *fh,
57 OMPI_MPI_OFFSET_TYPE * offset);
58 int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
59 const char* filename,
60 int amode,
61 struct opal_info_t *info,
62 ompio_file_t *fh);
63 int mca_sharedfp_sm_file_close (ompio_file_t *fh);
64 int mca_sharedfp_sm_read (ompio_file_t *fh,
65 void *buf, int count, MPI_Datatype datatype, MPI_Status *status);
66 int mca_sharedfp_sm_read_ordered (ompio_file_t *fh,
67 void *buf, int count, struct ompi_datatype_t *datatype,
68 ompi_status_public_t *status
69 );
70 int mca_sharedfp_sm_read_ordered_begin (ompio_file_t *fh,
71 void *buf,
72 int count,
73 struct ompi_datatype_t *datatype);
74 int mca_sharedfp_sm_read_ordered_end (ompio_file_t *fh,
75 void *buf,
76 ompi_status_public_t *status);
77 int mca_sharedfp_sm_iread (ompio_file_t *fh,
78 void *buf,
79 int count,
80 struct ompi_datatype_t *datatype,
81 ompi_request_t **request);
82 int mca_sharedfp_sm_write (ompio_file_t *fh,
83 const void *buf,
84 int count,
85 struct ompi_datatype_t *datatype,
86 ompi_status_public_t *status);
87 int mca_sharedfp_sm_write_ordered (ompio_file_t *fh,
88 const void *buf,
89 int count,
90 struct ompi_datatype_t *datatype,
91 ompi_status_public_t *status);
92 int mca_sharedfp_sm_write_ordered_begin (ompio_file_t *fh,
93 const void *buf,
94 int count,
95 struct ompi_datatype_t *datatype);
96 int mca_sharedfp_sm_write_ordered_end (ompio_file_t *fh,
97 const void *buf,
98 ompi_status_public_t *status);
99 int mca_sharedfp_sm_iwrite (ompio_file_t *fh,
100 const void *buf,
101 int count,
102 struct ompi_datatype_t *datatype,
103 ompi_request_t **request);
104 /*--------------------------------------------------------------*
105 *Structures and definitions only for this component
106 *--------------------------------------------------------------*/
107 struct mca_sharedfp_sm_offset{
108 sem_t mutex; /* the mutex: a POSIX memory-based unnamed semaphore */
109 long long offset; /* and the shared file pointer offset */
110 };
111
112 /*This structure will hang off of the mca_sharedfp_base_data_t's
113 *selected_module_data attribute
114 */
115 struct mca_sharedfp_sm_data
116 {
117 struct mca_sharedfp_sm_offset * sm_offset_ptr;
118 /*save filename so that we can remove the file on close*/
119 char * sm_filename;
120 /* The mutex: it will either point to a POSIX memory-based named
121 semaphore, or it will point to the a POSIX memory-based unnamed
122 semaphore located in sm_offset_ptr->mutex. */
123 sem_t *mutex;
124 char *sem_name; /* Name of the semaphore */
125 };
126
127 typedef struct mca_sharedfp_sm_data sm_data;
128
129
130 int mca_sharedfp_sm_request_position (ompio_file_t *fh,
131 int bytes_requested,
132 OMPI_MPI_OFFSET_TYPE * offset);
133 /*
134 * ******************************************************************
135 * ************ functions implemented in this module end ************
136 * ******************************************************************
137 */
138
139 END_C_DECLS
140
141 #endif /* MCA_SHAREDFP_sm_H */