@@ -132,8 +132,11 @@ struct cq_event_list
132
132
struct cq_manual_progress
133
133
{
134
134
struct fid_cq * cq_signal ;
135
- pthread_mutex_t cq_event_list_mutex ;
135
+
136
136
struct cq_event_list * cq_event_list ;
137
+ pthread_mutex_t cq_event_list_mutex ;
138
+ pthread_cond_t cq_even_list_signal ;
139
+ char cq_event_list_filled ;
137
140
138
141
CP_Services Svcs ;
139
142
void * Stream ;
@@ -156,46 +159,43 @@ void cq_manual_progress_push(struct cq_manual_progress *self, struct cq_event_li
156
159
}
157
160
head -> next = item ;
158
161
}
162
+ self -> cq_event_list_filled = 1 ;
159
163
pthread_mutex_unlock (& self -> cq_event_list_mutex );
164
+ pthread_cond_signal (& self -> cq_even_list_signal );
160
165
}
161
166
162
167
struct fi_cq_data_entry * cq_manual_progress_pop (struct cq_manual_progress * self )
163
168
{
164
169
struct fi_cq_data_entry * res ;
165
170
pthread_mutex_lock (& self -> cq_event_list_mutex );
166
- if (!self -> cq_event_list )
171
+ while (!self -> cq_event_list_filled )
167
172
{
168
- res = NULL ;
169
- }
170
- else
171
- {
172
- struct cq_event_list * head = self -> cq_event_list ;
173
- res = head -> value ;
174
- self -> cq_event_list = head -> next ;
175
- free (head );
173
+ pthread_cond_wait (& self -> cq_even_list_signal , & self -> cq_event_list_mutex );
176
174
}
175
+ assert (self -> cq_event_list );
176
+ struct cq_event_list * head = self -> cq_event_list ;
177
+ res = head -> value ;
178
+ self -> cq_event_list = head -> next ;
179
+ self -> cq_event_list_filled = self -> cq_event_list ? 1 : 0 ;
177
180
pthread_mutex_unlock (& self -> cq_event_list_mutex );
181
+ free (head );
178
182
return res ;
179
183
}
180
184
181
- #define SST_BACKOFF_SECONDS_MAX 5
182
-
183
185
static void * make_progress (void * params_ )
184
186
{
185
187
struct cq_manual_progress * params = (struct cq_manual_progress * )params_ ;
186
188
size_t const batch_size = 100 ;
187
- struct fi_cq_data_entry * CQEntries = malloc ( batch_size * sizeof ( struct fi_cq_data_entry )) ;
189
+ struct fi_cq_data_entry CQEntries [ batch_size ] ;
188
190
189
191
while (params -> do_continue )
190
192
{
191
193
/*
192
194
* The main purpose of this worker thread is to make repeated blocking calls to the blocking
193
- * fi_cq_sread() with a timeout of 5 seconds . Some providers don't make progress in a timely
194
- * fashion otherwise (e.g. shm).
195
+ * fi_cq_sread(). Some providers don't make progress in a timely fashion otherwise (e.g.
196
+ * shm).
195
197
*/
196
- printf ("Going into fi_cq_sread()\n" );
197
198
ssize_t rc = fi_cq_sread (params -> cq_signal , (void * )CQEntries , batch_size , NULL , -1 );
198
- printf ("fi_cq_sread()=%ld\n" , rc );
199
199
if (rc < 1 )
200
200
{
201
201
struct fi_cq_err_entry error = {.err = 0 };
@@ -222,8 +222,6 @@ static void *make_progress(void *params_)
222
222
}
223
223
}
224
224
}
225
- free (CQEntries );
226
- printf ("Returning from thread\n" );
227
225
return NULL ;
228
226
}
229
227
@@ -259,22 +257,10 @@ struct fabric_state
259
257
void cq_read (struct fabric_state * fabric , struct fi_cq_data_entry * CQEntry )
260
258
{
261
259
unsigned int current_backoff_seconds = 0 ;
262
- while (1 )
263
- {
264
- struct fi_cq_data_entry * res = cq_manual_progress_pop (fabric -> cq_manual_progress );
265
- if (res == NULL )
266
- {
267
- sleep (current_backoff_seconds );
268
- if (current_backoff_seconds < SST_BACKOFF_SECONDS_MAX )
269
- {
270
- ++ current_backoff_seconds ;
271
- }
272
- continue ;
273
- }
274
- memcpy (CQEntry , res , sizeof (struct fi_cq_data_entry ));
275
- free (res );
276
- return ;
277
- }
260
+ struct fi_cq_data_entry * res = cq_manual_progress_pop (fabric -> cq_manual_progress );
261
+ memcpy (CQEntry , res , sizeof (struct fi_cq_data_entry ));
262
+ free (res );
263
+ return ;
278
264
}
279
265
280
266
/*
@@ -670,9 +656,11 @@ static void init_fabric(struct fabric_state *fabric, struct _SstParams *Params,
670
656
return ;
671
657
}
672
658
manual_progress -> cq_event_list = NULL ;
659
+ manual_progress -> cq_event_list_filled = 0 ;
673
660
manual_progress -> Svcs = Svcs ;
674
661
manual_progress -> Stream = CP_Stream ;
675
662
manual_progress -> do_continue = 1 ;
663
+ pthread_cond_init (& manual_progress -> cq_even_list_signal , NULL );
676
664
677
665
fabric -> cq_manual_progress = manual_progress ;
678
666
@@ -1559,7 +1547,6 @@ static DP_WSR_Stream RdmaInitWriterPerReader(CP_Services Svcs, DP_WS_Stream WS_S
1559
1547
& WSR_Stream -> rrmr , Fabric -> ctx , Fabric -> signal ,
1560
1548
Fabric -> info -> domain_attr -> mr_mode );
1561
1549
ReaderRollHandle -> Key = fi_mr_key (WSR_Stream -> rrmr );
1562
- printf ("Key: %lu\n" , ReaderRollHandle -> Key );
1563
1550
1564
1551
WSR_Stream -> WriterContactInfo = ContactInfo ;
1565
1552
0 commit comments