openmpi  3.1.6
About: Open MPI is a high performance Message Passing Interface (MPI) library project combining technologies and resources from several other projects (FT-MPI, LA-MPI, LAM/MPI, and PACX-MPI) in order to build the best MPI library available. 3.x series.
  Fossies Dox: openmpi-3.1.6.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

request.h
Go to the documentation of this file.
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2 /*
3  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
4  * University Research and Technology
5  * Corporation. All rights reserved.
6  * Copyright (c) 2004-2016 The University of Tennessee and The University
7  * of Tennessee Research Foundation. All rights
8  * reserved.
9  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
10  * University of Stuttgart. All rights reserved.
11  * Copyright (c) 2004-2005 The Regents of the University of California.
12  * All rights reserved.
13  * Copyright (c) 2006-2017 Cisco Systems, Inc. All rights reserved
14  * Copyright (c) 2009-2012 Oracle and/or its affiliates. All rights reserved.
15  * Copyright (c) 2012 Oak Ridge National Labs. All rights reserved.
16  * Copyright (c) 2015-2016 Los Alamos National Security, LLC. All rights
17  * reserved.
18  * $COPYRIGHT$
19  *
20  * Additional copyrights may follow
21  *
22  * $HEADER$
23  */
30 #ifndef OMPI_REQUEST_H
31 #define OMPI_REQUEST_H
32 
33 #include "ompi_config.h"
34 #include "mpi.h"
37 #include "opal/threads/condition.h"
38 #include "opal/threads/wait_sync.h"
39 #include "ompi/constants.h"
40 
42 
47 
48 /*
49  * The following include pulls in shared typedefs with debugger plugins.
50  * For more information on why we do this see the Notice to developers
51  * comment at the top of the ompi_msgq_dll.c file.
52  */
53 
54 #include "request_dbg.h"
55 
56 struct ompi_request_t;
57 
73 typedef int (*ompi_request_start_fn_t)(
74  size_t count,
75  struct ompi_request_t ** requests
76 );
77 
78 /*
79  * Required function to free the request and any associated resources.
80  */
81 typedef int (*ompi_request_free_fn_t)(struct ompi_request_t** rptr);
82 
83 /*
84  * Optional function to cancel a pending request.
85  */
86 typedef int (*ompi_request_cancel_fn_t)(struct ompi_request_t* request, int flag);
87 
88 /*
89  * Optional function called when the request is completed from the MPI
90  * library perspective. This function is allowed to release the request if
91  * the request will not be used with ompi_request_wait* or ompi_request_test.
92  * If the function reposts (using start) a request or calls ompi_request_free()
93  * on the request it *MUST* return 1. It should return 0 otherwise.
94  */
96 
100 struct ompi_communicator_t;
101 
105 struct ompi_win_t;
106 
110 struct ompi_file_t;
111 
115 typedef union ompi_mpi_object_t {
117  struct ompi_file_t *file;
118  struct ompi_win_t *win;
120 
127  ompi_status_public_t req_status;
128  volatile void *req_complete;
138 };
139 
143 typedef struct ompi_request_t ompi_request_t;
144 
145 
151 #define PREDEFINED_REQUEST_PAD 256
152 
154  struct ompi_request_t request;
156 };
157 
159 
166 #define OMPI_REQUEST_INIT(request, persistent) \
167  do { \
168  (request)->req_complete = \
169  (persistent) ? REQUEST_COMPLETED : REQUEST_PENDING; \
170  (request)->req_state = OMPI_REQUEST_INACTIVE; \
171  (request)->req_persistent = (persistent); \
172  (request)->req_complete_cb = NULL; \
173  (request)->req_complete_cb_data = NULL; \
174  } while (0);
175 
176 
177 #define REQUEST_COMPLETE(req) (REQUEST_COMPLETED == (req)->req_complete)
178 
193 #define OMPI_REQUEST_FINI(request) \
194 do { \
195  (request)->req_state = OMPI_REQUEST_INVALID; \
196  if (MPI_UNDEFINED != (request)->req_f_to_c_index) { \
197  opal_pointer_array_set_item(&ompi_request_f_to_c_table, \
198  (request)->req_f_to_c_index, NULL); \
199  (request)->req_f_to_c_index = MPI_UNDEFINED; \
200  } \
201 } while (0);
202 
214 typedef int (*ompi_request_test_fn_t)(ompi_request_t ** rptr,
215  int *completed,
216  ompi_status_public_t * status );
230 typedef int (*ompi_request_test_any_fn_t)(size_t count,
232  int *index,
233  int *completed,
234  ompi_status_public_t * status);
249 typedef int (*ompi_request_test_all_fn_t)(size_t count,
251  int *completed,
252  ompi_status_public_t * statuses);
264 typedef int (*ompi_request_test_some_fn_t)(size_t count,
266  int * outcount,
267  int * indices,
268  ompi_status_public_t * statuses);
277 typedef int (*ompi_request_wait_fn_t)(ompi_request_t ** req_ptr,
278  ompi_status_public_t * status);
289 typedef int (*ompi_request_wait_any_fn_t)(size_t count,
291  int *index,
292  ompi_status_public_t * status);
302 typedef int (*ompi_request_wait_all_fn_t)(size_t count,
304  ompi_status_public_t * statuses);
316 typedef int (*ompi_request_wait_some_fn_t)(size_t count,
318  int * outcount,
319  int * indices,
320  ompi_status_public_t * statuses);
321 
325 typedef struct ompi_request_fns_t {
335 
343 OMPI_DECLSPEC extern ompi_status_public_t ompi_status_empty;
345 
349 int ompi_request_init(void);
350 
356 
360 int ompi_request_finalize(void);
361 
366 {
367  if (request->req_cancel != NULL) {
368  return request->req_cancel(request, true);
369  }
370  return OMPI_SUCCESS;
371 }
372 
379 {
380  return (*request)->req_free(request);
381 }
382 
383 #define ompi_request_test (ompi_request_functions.req_test)
384 #define ompi_request_test_any (ompi_request_functions.req_test_any)
385 #define ompi_request_test_all (ompi_request_functions.req_test_all)
386 #define ompi_request_test_some (ompi_request_functions.req_test_some)
387 #define ompi_request_wait (ompi_request_functions.req_wait)
388 #define ompi_request_wait_any (ompi_request_functions.req_wait_any)
389 #define ompi_request_wait_all (ompi_request_functions.req_wait_all)
390 #define ompi_request_wait_some (ompi_request_functions.req_wait_some)
391 
397 {
398  if (opal_using_threads () && !REQUEST_COMPLETE(req)) {
399  ompi_wait_sync_t sync;
400  WAIT_SYNC_INIT(&sync, 1);
401 
403  SYNC_WAIT(&sync);
404  } else {
405  /* completed before we had a chance to swap in the sync object */
406  WAIT_SYNC_SIGNALLED(&sync);
407  }
408 
409  assert(REQUEST_COMPLETE(req));
410  WAIT_SYNC_RELEASE(&sync);
411  } else {
412  while(!REQUEST_COMPLETE(req)) {
413  opal_progress();
414  }
415  }
416 }
417 
431 static inline int ompi_request_complete(ompi_request_t* request, bool with_signal)
432 {
433  int rc = 0;
434 
435  if( NULL != request->req_complete_cb) {
436  rc = request->req_complete_cb( request );
437  request->req_complete_cb = NULL;
438  }
439 
440  if (0 == rc) {
441  if( OPAL_LIKELY(with_signal) ) {
443  ompi_wait_sync_t *tmp_sync = (ompi_wait_sync_t *) OPAL_ATOMIC_SWAP_PTR(&request->req_complete,
445  /* In the case where another thread concurrently changed the request to REQUEST_PENDING */
446  if( REQUEST_PENDING != tmp_sync )
447  wait_sync_update(tmp_sync, 1, request->req_status.MPI_ERROR);
448  }
449  } else
450  request->req_complete = REQUEST_COMPLETED;
451  }
452 
453  return OMPI_SUCCESS;
454 }
455 
457 
458 #endif
ompi_request_t::req_complete_cb
ompi_request_complete_fn_t req_complete_cb
Called when the request is MPI completed.
Definition: request.h:135
ompi_request_t
struct ompi_request_t ompi_request_t
Convenience typedef.
Definition: request.h:143
ompi_mpi_object_t::file
struct ompi_file_t * file
Definition: request.h:117
ompi_request_t::req_type
ompi_request_type_t req_type
Enum indicating the type of the request.
Definition: request.h:126
ompi_request_t::req_status
ompi_status_public_t req_status
Completion status.
Definition: request.h:127
opal_progress
void opal_progress(void)
Progress all pending events.
Definition: opal_progress.c:220
ompi_request_test_some_fn_t
int(* ompi_request_test_some_fn_t)(size_t count, ompi_request_t **requests, int *outcount, int *indices, ompi_status_public_t *statuses)
Non-blocking test for some of N requests to complete.
Definition: request.h:264
WAIT_SYNC_SIGNALLED
#define WAIT_SYNC_SIGNALLED(sync)
Definition: wait_sync.h:75
OPAL_ATOMIC_CMPSET_PTR
#define OPAL_ATOMIC_CMPSET_PTR
Definition: thread_usage.h:165
ompi_wait_sync_t
Definition: wait_sync.h:28
ompi_request_type_t
ompi_request_type_t
Enum inidicating the type of the request.
Definition: request_dbg.h:22
opal_pointer_array.h
ompi_request_free_fn_t
int(* ompi_request_free_fn_t)(struct ompi_request_t **rptr)
Definition: request.h:81
ompi_request_f_to_c_table
opal_pointer_array_t ompi_request_f_to_c_table
Globals used for tracking requests and request completion.
Definition: request.c:35
ompi_request_init
int ompi_request_init(void)
Initialize the MPI_Request subsystem; invoked during MPI_INIT.
Definition: request.c:106
ompi_request_fns_t::req_test_any
ompi_request_test_any_fn_t req_test_any
Definition: request.h:327
ompi_request_test_fn_t
int(* ompi_request_test_fn_t)(ompi_request_t **rptr, int *completed, ompi_status_public_t *status)
Non-blocking test for request completion.
Definition: request.h:214
ompi_request_fns_t::req_wait_all
ompi_request_wait_all_fn_t req_wait_all
Definition: request.h:332
opal_free_list_item_t
Definition: opal_free_list.h:101
ompi_request_persistent_proc_null_free
int ompi_request_persistent_proc_null_free(ompi_request_t **request)
Free a persistent request to a MPI_PROC_NULL peer (there's no freelist to put it back to,...
Definition: request.c:89
ompi_request_t::req_persistent
bool req_persistent
flag indicating if the this is a persistent request
Definition: request.h:130
ompi_request_cancel_fn_t
int(* ompi_request_cancel_fn_t)(struct ompi_request_t *request, int flag)
Definition: request.h:86
ompi_request_t::req_mpi_object
ompi_mpi_object_t req_mpi_object
Pointer to MPI object that created this request.
Definition: request.h:137
wait_sync_update
static void wait_sync_update(ompi_wait_sync_t *sync, int updates, int status)
Update the status of the synchronization primitive.
Definition: wait_sync.h:109
BEGIN_C_DECLS
#define BEGIN_C_DECLS
code that should be in ompi_config_bottom.h regardless of build status
Definition: opal_config_bottom.h:85
ompi_request_fns_t::req_test_all
ompi_request_test_all_fn_t req_test_all
Definition: request.h:328
ompi_request_null_addr
ompi_predefined_request_t * ompi_request_null_addr
Definition: request.c:37
OMPI_SUCCESS
@ OMPI_SUCCESS
Definition: constants.h:35
ompi_communicator_t
Definition: communicator.h:134
ompi_mpi_object_t::comm
struct ompi_communicator_t * comm
Definition: request.h:116
request_dbg.h
ompi_request_fns_t
Replaceable request functions.
Definition: request.h:325
ompi_request_t::req_complete_cb_data
void * req_complete_cb_data
Definition: request.h:136
ompi_request_fns_t::req_wait_some
ompi_request_wait_some_fn_t req_wait_some
Definition: request.h:333
constants.h
ompi_request_fns_t::req_wait_any
ompi_request_wait_any_fn_t req_wait_any
Definition: request.h:331
ompi_request_finalize
int ompi_request_finalize(void)
Shut down the MPI_Request subsystem; invoked during MPI_FINALIZE.
Definition: request.c:179
ompi_request_wait_any_fn_t
int(* ompi_request_wait_any_fn_t)(size_t count, ompi_request_t **requests, int *index, ompi_status_public_t *status)
Wait (blocking-mode) for one of N requests to complete.
Definition: request.h:289
condition.h
ompi_request_fns_t
struct ompi_request_fns_t ompi_request_fns_t
Replaceable request functions.
requests
static opal_list_t requests
Definition: dfs_app.c:97
ompi_predefined_request_t::padding
char padding[256 - sizeof(ompi_request_t)]
Definition: request.h:155
OPAL_ATOMIC_SWAP_PTR
#define OPAL_ATOMIC_SWAP_PTR
Definition: thread_usage.h:171
request
Definition: evdns.c:171
opal_using_threads
#define opal_using_threads()
Check and see if the process is using multiple threads.
Definition: thread_usage.h:66
ompi_request_t::req_complete
volatile void * req_complete
Flag indicating wether request has completed.
Definition: request.h:128
ompi_request_fns_t::req_wait
ompi_request_wait_fn_t req_wait
Definition: request.h:330
ompi_request_wait_fn_t
int(* ompi_request_wait_fn_t)(ompi_request_t **req_ptr, ompi_status_public_t *status)
Wait (blocking-mode) for one requests to complete.
Definition: request.h:277
ompi_request_functions
ompi_request_fns_t ompi_request_functions
Definition: request.c:40
ompi_request_wait_completion
static void ompi_request_wait_completion(ompi_request_t *req)
Wait a particular request for completion.
Definition: request.h:396
ompi_request_t
Main top-level request struct definition.
Definition: request.h:124
ompi_predefined_request_t
Definition: request.h:153
ompi_request_state_t
ompi_request_state_t
Enum indicating the state of the request.
Definition: request_dbg.h:37
ompi_request_fns_t::req_test
ompi_request_test_fn_t req_test
Definition: request.h:326
ompi_request_empty
ompi_request_t ompi_request_empty
Definition: request.c:38
ompi_request_t::super
opal_free_list_item_t super
Base type.
Definition: request.h:125
ompi_mpi_object_t::win
struct ompi_win_t * win
Definition: request.h:118
ompi_request_t::req_f_to_c_index
int req_f_to_c_index
Index in Fortran <-> C translation array.
Definition: request.h:131
ompi_request_wait_all_fn_t
int(* ompi_request_wait_all_fn_t)(size_t count, ompi_request_t **requests, ompi_status_public_t *statuses)
Wait (blocking-mode) for all of N requests to complete.
Definition: request.h:302
ompi_request_t::req_cancel
ompi_request_cancel_fn_t req_cancel
Optional function to cancel the request.
Definition: request.h:134
count
void int count
Definition: op.c:237
ompi_request_free
static int ompi_request_free(ompi_request_t **request)
Free a request.
Definition: request.h:378
PREDEFINED_REQUEST_PAD
#define PREDEFINED_REQUEST_PAD
Padded struct to maintain back compatibiltiy.
Definition: request.h:151
flag
*f90 Inc All rights reserved LLC All rights ! reserved & flag
Definition: attr-fn-int-callback-interfaces.h:26
ompi_request_test_any_fn_t
int(* ompi_request_test_any_fn_t)(size_t count, ompi_request_t **requests, int *index, int *completed, ompi_status_public_t *status)
Non-blocking test for request completion.
Definition: request.h:230
ompi_request_t::req_start
ompi_request_start_fn_t req_start
Called by MPI_START and MPI_STARTALL.
Definition: request.h:132
ompi_request_null
ompi_predefined_request_t ompi_request_null
Definition: request.c:36
OPAL_LIKELY
#define OPAL_LIKELY(expression)
Definition: prefetch.h:46
REQUEST_PENDING
#define REQUEST_PENDING
Definition: wait_sync.h:40
REQUEST_COMPLETE
#define REQUEST_COMPLETE(req)
Definition: request.h:177
wait_sync.h
ompi_request_start_fn_t
int(* ompi_request_start_fn_t)(size_t count, struct ompi_request_t **requests)
Initiate one or more persistent requests.
Definition: request.h:73
ompi_file_t
Back-end structure for MPI_File.
Definition: file.h:48
REQUEST_COMPLETED
#define REQUEST_COMPLETED
Definition: wait_sync.h:41
WAIT_SYNC_RELEASE
#define WAIT_SYNC_RELEASE(sync)
Definition: wait_sync.h:51
opal_pointer_array_t
dynamic pointer array
Definition: opal_pointer_array.h:43
completed
static void completed(int index, orte_job_t *jdata, int ret, void *cbdata)
Definition: orterun.c:121
ompi_mpi_object_t
union ompi_mpi_object_t ompi_mpi_object_t
Union for holding several different MPI pointer types on the request.
ompi_mpi_object_t
Union for holding several different MPI pointer types on the request.
Definition: request.h:115
WAIT_SYNC_INIT
#define WAIT_SYNC_INIT(sync, c)
Definition: wait_sync.h:90
ompi_request_t::req_free
ompi_request_free_fn_t req_free
Called by free.
Definition: request.h:133
SYNC_WAIT
#define SYNC_WAIT(sync)
Definition: wait_sync.h:41
ompi_request_wait_some_fn_t
int(* ompi_request_wait_some_fn_t)(size_t count, ompi_request_t **requests, int *outcount, int *indices, ompi_status_public_t *statuses)
Wait (blocking-mode) for some of N requests to complete.
Definition: request.h:316
ompi_request_complete
static int ompi_request_complete(ompi_request_t *request, bool with_signal)
Signal or mark a request as complete.
Definition: request.h:431
ompi_config.h
ompi_request_t::req_state
volatile ompi_request_state_t req_state
enum indicate state of the request
Definition: request.h:129
ompi_request_test_all_fn_t
int(* ompi_request_test_all_fn_t)(size_t count, ompi_request_t **requests, int *completed, ompi_status_public_t *statuses)
Non-blocking test for request completion.
Definition: request.h:249
opal_free_list.h
END_C_DECLS
#define END_C_DECLS
Definition: opal_config_bottom.h:86
ompi_request_complete_fn_t
int(* ompi_request_complete_fn_t)(struct ompi_request_t *request)
Definition: request.h:95
OBJ_CLASS_DECLARATION
BEGIN_C_DECLS OBJ_CLASS_DECLARATION(ompi_request_t)
Request class.
ompi_win_t
Definition: win.h:77
ompi_status_empty
ompi_status_public_t ompi_status_empty
Definition: request.c:39
OMPI_DECLSPEC
#define OMPI_DECLSPEC
Definition: ompi_config.h:52
NULL
#define NULL
Copyright (C) 2000-2004 by Etnus, LLC.
Definition: ompi_msgq_dll.c:136
ompi_request_cancel
static int ompi_request_cancel(ompi_request_t *request)
Cancel a pending request.
Definition: request.h:365
ompi_request_fns_t::req_test_some
ompi_request_test_some_fn_t req_test_some
Definition: request.h:329