Mercury
na_ssm.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Argonne National Laboratory, Department of Energy,
3  *                    UChicago Argonne, LLC and The HDF Group.
4  * All rights reserved.
5  *
6  * The full copyright notice, including terms governing use, modification,
7  * and redistribution, is contained in the COPYING file that can be
8  * found at the root of the source code distribution tree.
9  */
10 
11 #ifndef NA_SSM_H
12 #define NA_SSM_H
13 
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <stdbool.h>
17 #include <string.h>
18 #include <sys/time.h>
19 #include <sys/uio.h>
20 #include <unistd.h>
21 #include <assert.h>
22 
23 #include "na.h"
24 #include "na_private.h"
25 #include "na_error.h"
26 
27 #include "mercury_hash_table.h"
28 #include "mercury_list.h"
29 #include "mercury_queue.h"
30 #include "mercury_thread.h"
31 #include "mercury_thread_mutex.h"
33 #include "mercury_time.h"
34 
35 #include <ssm/dumb.h>
36 #include <ssm.h>
37 #include <ssmptcp.h>
38 
39 #if (__GNUC__)
40 #define __likely(x) __builtin_expect(!!(x), 1)
41 #define __unlikely(x) __builtin_expect(!!(x), 0)
42 #else
43 #define __likely(x) (x)
44 #define __unlikely(x) (x)
45 #endif
46 
47 #define NA_SSM_UNEXPECTED_SIZE 1024*1024*64
48 #define NA_SSM_EXPECTED_SIZE 1024*1024*64
49 #define NA_SSM_UNEXPECTED_BUFFERCOUNT 64
50 #define NA_SSM_TAG_UNEXPECTED_OFFSET 0
51 #define NA_SSM_TAG_EXPECTED_OFFSET (((ssm_bits)1)<<62)
52 #define NA_SSM_TAG_RMA_OFFSET (((ssm_bits)1)<<63)
53 #define NA_SSM_MAX_ADDRESS_LENGTH 64
54 
55 #define NA_SSM_NEXT_UNEXPBUF_POS(n) (((n)+(1))%(NA_SSM_UNEXPECTED_BUFFERCOUNT))
56 
57 #define NA_SSM_PRIVATE_DATA(a) ((struct na_ssm_private_data *) (a)->private_data)
58 
59 #define NA_SSM_MARK_OPID_COMPLETE(a) ((a)->status = SSM_STATUS_COMPLETED)
60 #define NA_SSM_MARK_OPID_CANCELED(a) ((a)->status = SSM_STATUS_CANCELED)
61 
62 /* Buffers for unexpected data */
64  char *buf;
65  ssm_me me;
66  ssm_cb_t cb;
67  ssm_mr mr;
68  ssm_bits bits;
69  ssm_status status;
70  ssm_Haddr addr;
71  uint64_t bytes;
72 };
73 
75  ssm_id ssm;
76  ssm_Itp itp;
81  ssm_me unexpected_me;
82  ssm_bits cur_bits;
84 
88 
89 #ifdef NA_HAS_CLIENT_THREAD
90  hg_thread_mutex_t finalizing_mutex;
91  bool finalizing;
92  hg_thread_t progress_service;
93 #endif
94 
97 
101 
105 };
106 
107 struct na_ssm_addr {
108  ssm_Haddr addr;
109 };
110 
112  ssm_mr mr;
113  ssm_bits matchbits;
114  void *buf;
115  unsigned long buf_size;
116  ssm_me me;
117  ssm_cb_t cb;
118  unsigned long flag;
119 };
120 
121 typedef int ssm_size_t;
122 typedef unsigned long ssm_msg_tag_t;
123 
124 typedef enum na_ssm_status {
130 
132  ssm_mr memregion;
133  ssm_bits matchbits;
134 };
135 
137  ssm_mr memregion;
138  ssm_cb_t callback;
139  ssm_bits matchbits;
140 };
141 
142 struct ssm_get {
143  ssm_mr memregion;
144  ssm_md memdesc;
145 };
146 
148  ssm_mr memregion;
149  ssm_me matchentry;
150  ssm_bits matchbits;
153 };
154 
156  ssm_mr memregion;
159 };
160 
161 struct na_ssm_opid {
165  void *user_arg;
168  ssm_tx transaction;
171  ssm_cb_t ssm_callback;
172 
173  union {
178  struct ssm_get get;
179  } info;
180 };
181 
182 #endif /* NA_SSM_H */
hg_thread_mutex_t opid_wait_queue_mutex
Definition: na_ssm.h:96
struct ssm_msg_recv_expected recv_expected
Definition: na_ssm.h:176
pthread_t hg_thread_t
na_cb_type_t requesttype
Definition: na_ssm.h:162
ssm_bits matchbits
Definition: na_ssm.h:139
hg_thread_cond_t comp_req_cond
Definition: na_ssm.h:87
ssm_me unexpected_me
Definition: na_ssm.h:81
ssm_status status
Definition: na_ssm.h:69
struct ssm_msg_recv_unexpected recv_unexpected
Definition: na_ssm.h:177
hg_thread_cond_t unexpected_msg_queue_cond
Definition: na_ssm.h:100
unsigned long flag
Definition: na_ssm.h:118
ssm_bits matchbits
Definition: na_ssm.h:113
ssm_mr memregion
Definition: na_ssm.h:143
enum na_return na_return_t
hg_thread_cond_t unexpected_msg_complete_cond
Definition: na_ssm.h:104
struct ssm_msg_send_expected send_expected
Definition: na_ssm.h:175
enum na_ssm_status na_ssm_status_t
na_uint64_t na_size_t
Definition: na.h:21
Definition: na.h:92
union na_ssm_opid::@1 info
void * user_arg
Definition: na_ssm.h:165
struct na_ssm_private_data * ssm_data
Definition: na_ssm.h:166
ssm_cb_t unexpected_callback
Definition: na_ssm.h:80
hg_thread_mutex_t unexpected_msg_queue_mutex
Definition: na_ssm.h:99
struct ssm_msg_send_unexpected send_unexpected
Definition: na_ssm.h:174
ssm_bits cur_bits
Definition: na_ssm.h:82
enum na_cb_type na_cb_type_t
pthread_mutex_t hg_thread_mutex_t
hg_thread_mutex_t request_mutex
Definition: na_ssm.h:86
na_context_t * user_context
Definition: na_ssm.h:164
unsigned long buf_size
Definition: na_ssm.h:115
ssm_md memdesc
Definition: na_ssm.h:144
na_size_t input_buffer_size
Definition: na_ssm.h:158
na_ssm_status
Definition: na_ssm.h:124
Doubly-linked list.
int ssm_size_t
Definition: na_ssm.h:121
hg_thread_mutex_t gen_matchbits
Definition: na_ssm.h:83
ssm_cb_t ssm_callback
Definition: na_ssm.h:171
hg_queue_t * unexpected_msg_queue
Definition: na_ssm.h:98
hg_queue_t * unexpected_msg_complete_queue
Definition: na_ssm.h:102
pthread_cond_t hg_thread_cond_t
hg_queue_t * opid_wait_queue
Definition: na_ssm.h:95
na_size_t input_buffer_size
Definition: na_ssm.h:152
struct hg_queue hg_queue_t
A double-ended queue.
Definition: mercury_queue.h:54
hg_thread_cond_t unexp_buf_cond
Definition: na_ssm.h:85
na_ssm_status_t status
Definition: na_ssm.h:169
na_return_t result
Definition: na_ssm.h:170
struct na_cb_info * cbinfo
Definition: na_ssm.h:167
ssm_cb_t cb
Definition: na_ssm.h:117
na_return_t(* na_cb_t)(const struct na_cb_info *callback_info)
Definition: na.h:103
ssm_cb_t callback
Definition: na_ssm.h:138
ssm_tx transaction
Definition: na_ssm.h:168
ssm_bits matchbits
Definition: na_ssm.h:150
ssm_Haddr addr
Definition: na_ssm.h:108
unsigned long ssm_msg_tag_t
Definition: na_ssm.h:122
hg_thread_mutex_t unexpected_msg_complete_mutex
Definition: na_ssm.h:103
int unexpbuf_availpos
Definition: na_ssm.h:79
struct ssm_get get
Definition: na_ssm.h:178
na_cb_t user_callback
Definition: na_ssm.h:163