@@ -227,34 +227,6 @@ struct ucx_perf_context {
227227 };
228228};
229229
230- static inline ucs_status_t
231- ucx_perf_get_device_index (const ucx_perf_context_t * perf ,
232- unsigned group_index , unsigned device_count ,
233- unsigned * device_index_p )
234- {
235- int device_id = (group_index == 0 ) ? perf -> params .recv_device_id :
236- perf -> params .send_device_id ;
237-
238- if (device_count == 0 ) {
239- ucs_error ("no accelerator devices available" );
240- return UCS_ERR_NO_DEVICE ;
241- }
242-
243- if (device_id == UCX_PERF_MEM_DEV_DEFAULT ) {
244- * device_index_p = group_index % device_count ;
245- return UCS_OK ;
246- }
247-
248- if ((device_id < 0 ) || ((unsigned )device_id >= device_count )) {
249- ucs_error ("device index %d is invalid for %u available devices" ,
250- device_id , device_count );
251- return UCS_ERR_NO_DEVICE ;
252- }
253-
254- * device_index_p = device_id ;
255- return UCS_OK ;
256- }
257-
258230struct ucx_perf_thread_context {
259231 pthread_t pt ;
260232 int tid ;
@@ -365,6 +337,37 @@ ucx_perf_mem_alloc_name(const ucx_perf_params_t *params, int is_send)
365337 return ucs_memory_type_names [mem_type ];
366338}
367339
340+ static inline ucs_status_t
341+ ucx_perf_get_device_index (const ucx_perf_context_t * perf ,
342+ unsigned group_index , unsigned device_count ,
343+ const char * device_type ,
344+ unsigned * device_index_p )
345+ {
346+ int device_id ;
347+
348+ device_id = (group_index == 0 ) ? perf -> params .recv_device_id :
349+ perf -> params .send_device_id ;
350+
351+ if (device_count == 0 ) {
352+ ucs_error ("no %s devices available" , device_type );
353+ return UCS_ERR_NO_DEVICE ;
354+ }
355+
356+ if (device_id == UCX_PERF_MEM_DEV_DEFAULT ) {
357+ * device_index_p = group_index % device_count ;
358+ return UCS_OK ;
359+ }
360+
361+ if ((device_id < 0 ) || ((unsigned )device_id >= device_count )) {
362+ ucs_error ("%s device index %d is invalid for %u available devices" ,
363+ device_type , device_id , device_count );
364+ return UCS_ERR_NO_DEVICE ;
365+ }
366+
367+ * device_index_p = device_id ;
368+ return UCS_OK ;
369+ }
370+
368371static UCS_F_ALWAYS_INLINE int ucx_perf_context_done (ucx_perf_context_t * perf )
369372{
370373 return ucs_unlikely ((perf -> current .iters >= perf -> max_iter ) ||
0 commit comments