1 /*
2  * Copyright (C) by Argonne National Laboratory
3  *     See COPYRIGHT in top-level directory
4  */
5 
6 #ifndef MPIDIG_AM_H_INCLUDED
7 #define MPIDIG_AM_H_INCLUDED
8 
9 #define MPIDI_AM_HANDLERS_MAX (64)
10 
11 enum {
12     MPIDIG_SEND = 0,
13 
14     MPIDIG_SEND_CTS,    /* CTS (clear to send) for send message */
15     MPIDIG_SEND_DATA,   /* data for send message */
16 
17     MPIDIG_SSEND_ACK,
18 
19     MPIDIG_PUT_REQ,
20     MPIDIG_PUT_ACK,
21     MPIDIG_PUT_DT_REQ,
22     MPIDIG_PUT_DAT_REQ,
23     MPIDIG_PUT_DT_ACK,
24 
25     MPIDIG_GET_REQ,
26     MPIDIG_GET_ACK,
27 
28     MPIDIG_ACC_REQ,
29     MPIDIG_ACC_ACK,
30     MPIDIG_ACC_DT_REQ,
31     MPIDIG_ACC_DAT_REQ,
32     MPIDIG_ACC_DT_ACK,
33 
34     MPIDIG_GET_ACC_REQ,
35     MPIDIG_GET_ACC_ACK,
36     MPIDIG_GET_ACC_DT_REQ,
37     MPIDIG_GET_ACC_DAT_REQ,
38     MPIDIG_GET_ACC_DT_ACK,
39 
40     MPIDIG_CSWAP_REQ,
41     MPIDIG_CSWAP_ACK,
42     MPIDIG_FETCH_OP,
43 
44     MPIDIG_WIN_COMPLETE,
45     MPIDIG_WIN_POST,
46     MPIDIG_WIN_LOCK,
47     MPIDIG_WIN_LOCK_ACK,
48     MPIDIG_WIN_UNLOCK,
49     MPIDIG_WIN_UNLOCK_ACK,
50     MPIDIG_WIN_LOCKALL,
51     MPIDIG_WIN_LOCKALL_ACK,
52     MPIDIG_WIN_UNLOCKALL,
53     MPIDIG_WIN_UNLOCKALL_ACK,
54 
55     MPIDIG_COMM_ABORT,
56 
57     MPIDI_OFI_INTERNAL_HANDLER_CONTROL,
58 
59     MPIDIG_HANDLER_STATIC_MAX
60 };
61 
62 typedef int (*MPIDIG_am_target_cmpl_cb) (MPIR_Request * req);
63 typedef int (*MPIDIG_am_origin_cb) (MPIR_Request * req);
64 
65 /* Target message callback, or handler function
66  *
67  * If req on input is NULL, the callback may allocate a request object. If a request
68  * object is returned, the caller is expected to transfer the payload to the request,
69  * and call target_cmpl_cb upon complete.
70  *
71  * If is_async is false/0, a request object will never be returned.
72  */
73 typedef int (*MPIDIG_am_target_msg_cb) (int handler_id, void *am_hdr,
74                                         void *data, MPI_Aint data_sz,
75                                         int is_local, int is_async, MPIR_Request ** req);
76 
77 typedef struct MPIDIG_global_t {
78     MPIDIG_am_target_msg_cb target_msg_cbs[MPIDI_AM_HANDLERS_MAX];
79     MPIDIG_am_origin_cb origin_cbs[MPIDI_AM_HANDLERS_MAX];
80     /* Control parameters for global progress of RMA target-side active messages.
81      * TODO: performance loss need be studied since we add atomic operations
82      * in RMA sync and callback routines.*/
83     MPL_atomic_int_t rma_am_flag;       /* Indicates whether any incoming RMA target-side active
84                                          * messages has been received.
85                                          * Set inside each target callback.*/
86     MPIR_cc_t rma_am_poll_cntr;
87 } MPIDIG_global_t;
88 extern MPIDIG_global_t MPIDIG_global;
89 
90 void MPIDIG_am_reg_cb(int handler_id,
91                       MPIDIG_am_origin_cb origin_cb, MPIDIG_am_target_msg_cb target_msg_cb);
92 int MPIDIG_am_reg_cb_dynamic(MPIDIG_am_origin_cb origin_cb, MPIDIG_am_target_msg_cb target_msg_cb);
93 
94 int MPIDIG_am_init(void);
95 void MPIDIG_am_finalize(void);
96 
97 /* am protocol prototypes */
98 
99 void MPIDIG_am_comm_abort_init(void);
100 int MPIDIG_am_comm_abort(MPIR_Comm * comm, int exit_code);
101 
102 int MPIDIG_am_check_init(void);
103 
104 #endif /* MPIDIG_AM_H_INCLUDED */
105