rptl.h 5.7 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/*
 *  (C) 2014 by Argonne National Laboratory.
 *      See COPYRIGHT in top-level directory.
 */

#if !defined RPTL_H_INCLUDED
#define RPTL_H_INCLUDED

#if !defined HAVE_MACRO_VA_ARGS
#error "portals requires VA_ARGS support"
#endif /* HAVE_MACRO_VA_ARGS */

#if defined HAVE__FUNC__
#define RPTLU_FUNC __func__
#elif defined HAVE_CAP__FUNC__
#define RPTLU_FUNC __FUNC__
#elif defined HAVE__FUNCTION__
#define RPTLU_FUNC __FUNCTION__
#else
#define RPTLU_FUNC "Unknown"
#endif

#define RPTLU_ERR_POP(ret, ...)                                         \
    {                                                                   \
        if (ret) {                                                      \
            MPIU_Error_printf("%s (%d): ", RPTLU_FUNC, __LINE__);       \
            MPIU_Error_printf(__VA_ARGS__);                             \
            goto fn_fail;                                               \
        }                                                               \
    }

33
struct rptl_target;
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
struct rptl_op {
    enum {
        RPTL_OP_PUT,
        RPTL_OP_GET
    } op_type;

    enum {
        RPTL_OP_STATE_QUEUED,
        RPTL_OP_STATE_ISSUED,
        RPTL_OP_STATE_NACKED
    } state;

    union {
        struct {
            ptl_handle_md_t md_handle;
            ptl_size_t local_offset;
            ptl_size_t length;
            ptl_ack_req_t ack_req;
            ptl_process_t target_id;
            ptl_pt_index_t pt_index;
            ptl_match_bits_t match_bits;
            ptl_size_t remote_offset;
            void *user_ptr;
            ptl_hdr_data_t hdr_data;

            /* internal variables store events */
            ptl_event_t *send;
            ptl_event_t *ack;
            int flow_control;
        } put;
        struct {
            ptl_handle_md_t md_handle;
            ptl_size_t local_offset;
            ptl_size_t length;
            ptl_process_t target_id;
            ptl_pt_index_t pt_index;
            ptl_match_bits_t match_bits;
            ptl_size_t remote_offset;
            void *user_ptr;
        } get;
    } u;

    int events_ready;
77
    struct rptl_target *target;
78
79
80
81
82
83
84
85
86
87
88
89

    struct rptl_op *next;
    struct rptl_op *prev;
};

#define RPTL_CONTROL_MSG_PAUSE       (0)
#define RPTL_CONTROL_MSG_PAUSE_ACK   (1)
#define RPTL_CONTROL_MSG_UNPAUSE     (2)

struct rptl {
    /* local portal state */
    enum {
90
        RPTL_LOCAL_STATE_ACTIVE,
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
        RPTL_LOCAL_STATE_AWAITING_PAUSE_ACKS
    } local_state;
    uint64_t pause_ack_counter;

    struct {
        ptl_handle_eq_t eq;
        ptl_pt_index_t pt;      /* primary pt for data exchange */

        /* ob_max_count refers to the number of messages that were in
         * the overflow buffer when the pt was disabled */
        uint64_t ob_max_count;

        /* ob_curr_count refers to the current tally of messages in
         * the overflow buffer.  if we are in disabled state, when
         * this count reaches half of the maximum count, we are ready
         * to reenable the PT. */
        uint64_t ob_curr_count;
    } data;

    struct {
        ptl_pt_index_t pt;      /* pt for control messages */

        /* the remaining contents of the control structure are only
         * valid when the control.pt field is not PTL_PT_ANY */
        ptl_handle_me_t *me;
        int me_idx;
    } control;

    ptl_handle_ni_t ni;
    ptl_handle_eq_t eq;
    ptl_handle_md_t md;

    struct rptl *next;
    struct rptl *prev;
};

127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#define RPTL_OP_POOL_SEGMENT_COUNT  (1024)

struct rptl_target {
    ptl_process_t id;

    enum rptl_target_state {
        RPTL_TARGET_STATE_ACTIVE,
        RPTL_TARGET_STATE_DISABLED,
        RPTL_TARGET_STATE_RECEIVED_PAUSE,
        RPTL_TARGET_STATE_PAUSE_ACKED
    } state;

    /* when we get a pause message, we need to know which rptl it came
     * in on, so we can figure out what the corresponding target
     * portal is.  for this, we store the local rptl */
    struct rptl *rptl;

    struct rptl_op_pool_segment {
        struct rptl_op op[RPTL_OP_POOL_SEGMENT_COUNT];
        struct rptl_op_pool_segment *next;
        struct rptl_op_pool_segment *prev;
    } *op_segment_list;
    struct rptl_op *op_pool;

    struct rptl_op *data_op_list;
    struct rptl_op *control_op_list;

    struct rptl_target *next;
    struct rptl_target *prev;
};

158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
int MPID_nem_ptl_rptl_init(int world_size, uint64_t max_origin_events,
                           int (*get_target_info) (int rank, ptl_process_t * id,
                                                   ptl_pt_index_t local_data_pt,
                                                   ptl_pt_index_t * target_data_pt,
                                                   ptl_pt_index_t * target_control_pt));

int MPID_nem_ptl_rptl_drain_eq(int eq_count, ptl_handle_eq_t *eq);

int MPID_nem_ptl_rptl_ptinit(ptl_handle_ni_t ni_handle, ptl_handle_eq_t eq_handle, ptl_pt_index_t data_pt,
                             ptl_pt_index_t control_pt);

int MPID_nem_ptl_rptl_ptfini(ptl_pt_index_t pt_index);

int MPID_nem_ptl_rptl_put(ptl_handle_md_t md_handle, ptl_size_t local_offset, ptl_size_t length,
                          ptl_ack_req_t ack_req, ptl_process_t target_id, ptl_pt_index_t pt_index,
                          ptl_match_bits_t match_bits, ptl_size_t remote_offset, void *user_ptr,
                          ptl_hdr_data_t hdr_data, int flow_control);

int MPID_nem_ptl_rptl_get(ptl_handle_md_t md_handle, ptl_size_t local_offset, ptl_size_t length,
                          ptl_process_t target_id, ptl_pt_index_t pt_index,
                          ptl_match_bits_t match_bits, ptl_size_t remote_offset, void *user_ptr);

int MPID_nem_ptl_rptl_eqget(ptl_handle_eq_t eq_handle, ptl_event_t * event);

#endif /* RPTL_H_INCLUDED */