Multi-ApplicationOnlineProfiling  2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
VMPI_stream.h
Go to the documentation of this file.
1 /* ############################ MALP License ############################## */
2 /* # Fri Jan 18 14:00:00 CET 2013 # */
3 /* # Copyright or (C) or Copr. Commissariat a l'Energie Atomique # */
4 /* # # */
5 /* # This software is governed by the CeCILL-C license under French law # */
6 /* # and abiding by the rules of distribution of free software. You can # */
7 /* # use, modify and/ or redistribute the software under the terms of # */
8 /* # the CeCILL-C license as circulated by CEA, CNRS and INRIA at the # */
9 /* # following URL http://www.cecill.info. # */
10 /* # # */
11 /* # The fact that you are presently reading this means that you have # */
12 /* # had knowledge of the CeCILL-C license and that you accept its # */
13 /* # terms. # */
14 /* # # */
15 /* # Authors: # */
16 /* # - BESNARD Jean-Baptiste jean-baptiste.besnard@cea.fr # */
17 /* # # */
18 /* ######################################################################## */
19 
20 
21 
22 #ifndef VMPI_STREAMS
23 #define VMPI_STREAMS
24 
25 #include <mpi.h>
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #include <stdlib.h>
32 #include <VMPI.h>
33 #include <Spinlock.h>
34 
39 typedef enum
40 {
45 
50 typedef enum
51 {
56 
57 
62 typedef enum
63 {
68 
74 {
75  int target;
76  int remote_tag;
77  int local_tag;
78  int state;
79 };
80 
85 #define VMPI_STREAM_MAX_ASYNC 10
86 
96 typedef struct
97 {
98  struct _VMPI_Stream *in;
99  int current_in;
100  int in_count;
102  struct _VMPI_Stream *out;
104  int out_count;
106  size_t block_size;
108  char **r_tmp_buffers;
110  MPI_Request *r_req;
111  MPI_Status *r_stat;
115  char *w_tmp_buffers[VMPI_STREAM_MAX_ASYNC];
116  MPI_Request w_req[VMPI_STREAM_MAX_ASYNC];
117  MPI_Status w_stat[VMPI_STREAM_MAX_ASYNC];
123 }VMPI_Stream;
124 
133 int VMPI_Stream_init( VMPI_Stream *st, size_t block_size, VMPI_Stream_load_balance lb);
134 
143 int VMPI_Stream_open( VMPI_Stream *st, int dest, char *mode );
144 
153 int VMPI_Stream_open_map( VMPI_Stream *st, VMPI_Map *map, char *mode );
154 
161 int VMPI_Stream_close( VMPI_Stream * st );
162 
163 
174 int VMPI_Stream_join(VMPI_Stream * dest, VMPI_Stream * src);
175 
198 int VMPI_Stream_read( VMPI_Stream * st, char *buff, unsigned int block_count, VMPI_Stream_blocking block );
199 
208 int VMPI_Stream_write( VMPI_Stream * st, char *buff, unsigned int block_count );
209 
217 
225 
232 static inline int VMPI_Stream_read_count( VMPI_Stream * st )
233 {
234  return st->in_count;
235 }
236 
243 static inline int VMPI_Stream_write_count( VMPI_Stream * st )
244 {
245  return st->out_count;
246 }
247 
248 #ifdef __cplusplus
249 }
250 #endif
251 
252 #endif /* VMPI_STREAMS */
253 
All Calls are blocking ones.
Definition: VMPI_stream.h:64
int target
Target task.
Definition: VMPI_stream.h:75
#define VMPI_STREAM_MAX_ASYNC
Maximum number of asynchronous cells.
Definition: VMPI_stream.h:85
char ** r_tmp_buffers
Temporary buffer for input.
Definition: VMPI_stream.h:108
Defines a map.
Definition: VMPI.h:287
struct _VMPI_Stream * in
Input streams.
Definition: VMPI_stream.h:98
int VMPI_Stream_test_write(VMPI_Stream *st)
Is this stream ready for writing ?
Definition: VMPI_stream.c:683
struct _VMPI_Stream * out
Output streams.
Definition: VMPI_stream.h:102
int out_count
Number of outputs.
Definition: VMPI_stream.h:104
int VMPI_Stream_open_map(VMPI_Stream *st, VMPI_Map *map, char *mode)
Open a stream according to a mapping.
Definition: VMPI_stream.c:303
int VMPI_Stream_test_read(VMPI_Stream *st)
Is this stream ready for read ?
Definition: VMPI_stream.c:655
Send or receive from a random one.
Definition: VMPI_stream.h:42
int current_out
Current output stream.
Definition: VMPI_stream.h:103
int w_req_count
Number of output requests.
Definition: VMPI_stream.h:118
READ and WRITE.
Definition: VMPI_stream.h:54
int * r_current_buff
Current buffer.
Definition: VMPI_stream.h:109
MALP_Spinlock lock
Spinlock.
Definition: VMPI_stream.h:122
Internal declaration of a stream endpoint.
Definition: VMPI_stream.h:73
static int VMPI_Stream_read_count(VMPI_Stream *st)
Get the number of input streams.
Definition: VMPI_stream.h:232
VMPI_Stream_load_balance
Defines the load ballancing modes available to MPI_Streams.
Definition: VMPI_stream.h:39
int in_count
Number of inputs.
Definition: VMPI_stream.h:100
VMPI_Stream_mode
Defines MPI_Stream mode.
Definition: VMPI_stream.h:50
int local_tag
Local unique tag.
Definition: VMPI_stream.h:77
volatile unsigned int MALP_Spinlock
The type of spinlocks in MALP.
Definition: Spinlock.h:63
VMPI_Stream_load_balance lb
Load balancing policy.
Definition: VMPI_stream.h:120
static int VMPI_Stream_write_count(VMPI_Stream *st)
Get the number of output streams.
Definition: VMPI_stream.h:243
int VMPI_Stream_init(VMPI_Stream *st, size_t block_size, VMPI_Stream_load_balance lb)
Initializes a stream should be called before any *open call.
Definition: VMPI_stream.c:26
If no data are available or endpoint not ready call might return VMPI_EAGAIN.
Definition: VMPI_stream.h:65
VMPI_Stream_blocking
Defines call mode.
Definition: VMPI_stream.h:62
MPI_Request * r_req
Input requests.
Definition: VMPI_stream.h:110
int VMPI_Stream_close(VMPI_Stream *st)
Closes a stream and sends EOF to remote endpoints.
Definition: VMPI_stream.c:316
Send or receive from each turn by turn.
Definition: VMPI_stream.h:43
int VMPI_Stream_join(VMPI_Stream *dest, VMPI_Stream *src)
Join two streams in the same set.
Definition: VMPI_stream.c:187
int state
Been closed or not.
Definition: VMPI_stream.h:78
int VMPI_Stream_open(VMPI_Stream *st, int dest, char *mode)
Open a stream to dest rank, dest should do the symmetrical call.
Definition: VMPI_stream.c:221
int r_req_count
Number of input requests.
Definition: VMPI_stream.h:112
int VMPI_Stream_read(VMPI_Stream *st, char *buff, unsigned int block_count, VMPI_Stream_blocking block)
Read data from a VMPI_Stream.
Definition: VMPI_stream.c:493
int current_in
Current input stream.
Definition: VMPI_stream.h:99
MPI_Status * r_stat
Input statuses.
Definition: VMPI_stream.h:111
int VMPI_Stream_write(VMPI_Stream *st, char *buff, unsigned int block_count)
Write data to a VMPI_Stream.
Definition: VMPI_stream.c:395
int remote_tag
Remote unique tag.
Definition: VMPI_stream.h:76
Always send or receive from the same.
Definition: VMPI_stream.h:41
size_t block_size
Size of a data block.
Definition: VMPI_stream.h:106
Defines a MPI stream.
Definition: VMPI_stream.h:96