This source file includes following definitions.
- add_pending
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 #ifndef MCA_BTL_SMCUDA_FIFO_H
25 #define MCA_BTL_SMCUDA_FIFO_H
26
27 #include "btl_smcuda.h"
28 #include "btl_smcuda_endpoint.h"
29
30 static void
31 add_pending(struct mca_btl_base_endpoint_t *ep, void *data, bool resend)
32 {
33 btl_smcuda_pending_send_item_t *si;
34 opal_free_list_item_t *i;
35 i = opal_free_list_get (&mca_btl_smcuda_component.pending_send_fl);
36
37
38 assert(i != NULL);
39
40 si = (btl_smcuda_pending_send_item_t*)i;
41 si->data = data;
42
43 OPAL_THREAD_ADD_FETCH32(&mca_btl_smcuda_component.num_pending_sends, +1);
44
45
46
47 OPAL_THREAD_LOCK(&ep->endpoint_lock);
48 if (resend)
49 opal_list_prepend(&ep->pending_sends, (opal_list_item_t*)si);
50 else
51 opal_list_append(&ep->pending_sends, (opal_list_item_t*)si);
52 OPAL_THREAD_UNLOCK(&ep->endpoint_lock);
53 }
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82 #define FIFO_MAP(x) ((x) & (mca_btl_smcuda_component.nfifos - 1))
83 #define FIFO_MAP_NUM(n) ( (mca_btl_smcuda_component.nfifos) < (n) ? (mca_btl_smcuda_component.nfifos) : (n) )
84
85
86 #define MCA_BTL_SMCUDA_FIFO_WRITE(endpoint_peer, my_smp_rank, \
87 peer_smp_rank, hdr, resend, retry_pending_sends, rc) \
88 do { \
89 sm_fifo_t* fifo = &(mca_btl_smcuda_component.fifo[peer_smp_rank][FIFO_MAP(my_smp_rank)]); \
90 \
91 if ( retry_pending_sends ) { \
92 if ( 0 < opal_list_get_size(&endpoint_peer->pending_sends) ) { \
93 btl_smcuda_process_pending_sends(endpoint_peer); \
94 } \
95 } \
96 \
97 opal_atomic_lock(&(fifo->head_lock)); \
98 \
99 if(sm_fifo_write(hdr, fifo) != OPAL_SUCCESS) { \
100 add_pending(endpoint_peer, hdr, resend); \
101 rc = OPAL_ERR_RESOURCE_BUSY; \
102 } else { \
103 MCA_BTL_SMCUDA_SIGNAL_PEER(endpoint_peer); \
104 rc = OPAL_SUCCESS; \
105 } \
106 opal_atomic_unlock(&(fifo->head_lock)); \
107 } while(0)
108
109 #endif