5
5
#include "efa_hmem.h"
6
6
#include "rdm/efa_rdm_pkt_type.h"
7
7
8
+ struct efa_hmem_info g_efa_hmem_info [OFI_HMEM_MAX ];
9
+
8
10
#if HAVE_CUDA || HAVE_NEURON
9
- static size_t efa_max_eager_msg_size_with_largest_header (struct efa_domain * efa_domain ) {
11
+ static size_t efa_max_eager_msg_size_with_largest_header () {
10
12
int mtu_size ;
11
13
12
- mtu_size = efa_domain -> device -> rdm_info -> ep_attr -> max_msg_size ;
14
+ mtu_size = g_device_list [ 0 ]. rdm_info -> ep_attr -> max_msg_size ;
13
15
14
16
return mtu_size - efa_rdm_pkt_type_get_max_hdr_size ();
15
17
}
16
18
#else
17
- static size_t efa_max_eager_msg_size_with_largest_header (struct efa_domain * efa_domain ) {
19
+ static size_t efa_max_eager_msg_size_with_largest_header () {
18
20
return 0 ;
19
21
}
20
22
#endif
@@ -23,14 +25,13 @@ static size_t efa_max_eager_msg_size_with_largest_header(struct efa_domain *efa_
23
25
* @brief Initialize the various protocol thresholds tracked in efa_hmem_info
24
26
* according to the given FI_HMEM interface.
25
27
*
26
- * @param[in,out] efa_domain Pointer to struct efa_domain
27
28
* @param[in] iface The FI_HMEM interface to initialize
28
29
*
29
30
* @return 0
30
31
*/
31
- static int efa_domain_hmem_info_init_protocol_thresholds (struct efa_domain * efa_domain , enum fi_hmem_iface iface )
32
+ static int efa_domain_hmem_info_init_protocol_thresholds (enum fi_hmem_iface iface )
32
33
{
33
- struct efa_hmem_info * info = & efa_domain -> hmem_info [iface ];
34
+ struct efa_hmem_info * info = g_efa_hmem_info [iface ];
34
35
size_t tmp_value ;
35
36
36
37
/* Fall back to FI_HMEM_SYSTEM initialization logic when p2p is
@@ -53,8 +54,8 @@ static int efa_domain_hmem_info_init_protocol_thresholds(struct efa_domain *efa_
53
54
case FI_HMEM_CUDA :
54
55
info -> runt_size = EFA_DEFAULT_RUNT_SIZE ;
55
56
info -> max_medium_msg_size = 0 ;
56
- info -> min_read_msg_size = efa_max_eager_msg_size_with_largest_header (efa_domain ) + 1 ;
57
- info -> min_read_write_size = efa_max_eager_msg_size_with_largest_header (efa_domain ) + 1 ;
57
+ info -> min_read_msg_size = efa_max_eager_msg_size_with_largest_header () + 1 ;
58
+ info -> min_read_write_size = efa_max_eager_msg_size_with_largest_header () + 1 ;
58
59
fi_param_get_size_t (& efa_prov , "runt_size" , & info -> runt_size );
59
60
fi_param_get_size_t (& efa_prov , "inter_min_read_message_size" , & info -> min_read_msg_size );
60
61
fi_param_get_size_t (& efa_prov , "inter_min_read_write_size" , & info -> min_read_write_size );
@@ -68,8 +69,8 @@ static int efa_domain_hmem_info_init_protocol_thresholds(struct efa_domain *efa_
68
69
case FI_HMEM_NEURON :
69
70
info -> runt_size = EFA_NEURON_RUNT_SIZE ;
70
71
info -> max_medium_msg_size = 0 ;
71
- info -> min_read_msg_size = efa_max_eager_msg_size_with_largest_header (efa_domain ) + 1 ;
72
- info -> min_read_write_size = efa_max_eager_msg_size_with_largest_header (efa_domain ) + 1 ;
72
+ info -> min_read_msg_size = efa_max_eager_msg_size_with_largest_header () + 1 ;
73
+ info -> min_read_write_size = efa_max_eager_msg_size_with_largest_header () + 1 ;
73
74
fi_param_get_size_t (& efa_prov , "runt_size" , & info -> runt_size );
74
75
fi_param_get_size_t (& efa_prov , "inter_min_read_message_size" , & info -> min_read_msg_size );
75
76
fi_param_get_size_t (& efa_prov , "inter_min_read_write_size" , & info -> min_read_write_size );
@@ -105,7 +106,7 @@ static int efa_domain_hmem_info_init_protocol_thresholds(struct efa_domain *efa_
105
106
return 0 ;
106
107
}
107
108
108
- static inline void efa_domain_hmem_info_check_p2p_support_cuda (struct efa_hmem_info * info ) {
109
+ static inline void efa_hmem_info_check_p2p_support_cuda (struct efa_hmem_info * info ) {
109
110
#if HAVE_CUDA
110
111
cudaError_t cuda_ret ;
111
112
void * ptr = NULL ;
@@ -168,7 +169,7 @@ static inline void efa_domain_hmem_info_check_p2p_support_cuda(struct efa_hmem_i
168
169
return ;
169
170
}
170
171
171
- static inline void efa_domain_hmem_info_check_p2p_support_neuron (struct efa_hmem_info * info ) {
172
+ static inline void efa_hmem_info_check_p2p_support_neuron (struct efa_hmem_info * info ) {
172
173
#if HAVE_NEURON
173
174
struct ibv_mr * ibv_mr = NULL ;
174
175
int ibv_access = IBV_ACCESS_LOCAL_WRITE ;
@@ -239,13 +240,12 @@ static inline void efa_domain_hmem_info_check_p2p_support_neuron(struct efa_hmem
239
240
/**
240
241
* @brief Initialize the efa_hmem_info state for iface
241
242
*
242
- * @param[in,out] efa_domain Pointer to struct efa_domain
243
243
* @param[in] iface HMEM interface
244
244
*/
245
245
static void
246
- efa_domain_hmem_info_init_iface ( struct efa_domain * efa_domain , enum fi_hmem_iface iface )
246
+ efa_hmem_info_init_iface ( enum fi_hmem_iface iface )
247
247
{
248
- struct efa_hmem_info * info = & efa_domain -> hmem_info [iface ];
248
+ struct efa_hmem_info * info = g_efa_hmem_info [iface ];
249
249
250
250
if (!ofi_hmem_is_initialized (iface )) {
251
251
EFA_INFO (FI_LOG_DOMAIN , "%s is not initialized\n" ,
@@ -262,17 +262,16 @@ efa_domain_hmem_info_init_iface(struct efa_domain *efa_domain, enum fi_hmem_ifac
262
262
}
263
263
264
264
info -> initialized = true;
265
- info -> p2p_disabled_by_user = (iface == FI_HMEM_SYSTEM ) ? false : ofi_hmem_p2p_disabled ();
266
265
267
266
if (iface == FI_HMEM_SYNAPSEAI || iface == FI_HMEM_SYSTEM ) {
268
267
info -> p2p_supported_by_device = true;
269
- } else if (info -> p2p_disabled_by_user ) {
268
+ } else if (ofi_hmem_p2p_disabled () ) {
270
269
info -> p2p_supported_by_device = false;
271
270
} else {
272
271
if (iface == FI_HMEM_CUDA )
273
- efa_domain_hmem_info_check_p2p_support_cuda (info );
272
+ efa_hmem_info_check_p2p_support_cuda (info );
274
273
if (iface == FI_HMEM_NEURON )
275
- efa_domain_hmem_info_check_p2p_support_neuron (info );
274
+ efa_hmem_info_check_p2p_support_neuron (info );
276
275
if (!info -> p2p_supported_by_device )
277
276
EFA_INFO (FI_LOG_DOMAIN , "%s P2P support is not available.\n" , fi_tostr (& iface , FI_TYPE_HMEM_IFACE ));
278
277
}
@@ -283,20 +282,18 @@ efa_domain_hmem_info_init_iface(struct efa_domain *efa_domain, enum fi_hmem_ifac
283
282
* memory, therefore p2p is not required.
284
283
*/
285
284
if (iface == FI_HMEM_CUDA &&
286
- FI_VERSION_GE (efa_domain -> util_domain . fabric -> fabric_fid .api_version , FI_VERSION (1 , 18 )))
285
+ FI_VERSION_GE (g_device_list [ 0 ]. rdm_info -> fabric_attr .api_version , FI_VERSION (1 , 18 )))
287
286
info -> p2p_required_by_impl = !hmem_ops [iface ].initialized ;
288
287
if (iface == FI_HMEM_SYSTEM )
289
288
info -> p2p_required_by_impl = false;
290
289
291
- efa_domain_hmem_info_init_protocol_thresholds (efa_domain , iface );
290
+ efa_domain_hmem_info_init_protocol_thresholds (iface );
292
291
}
293
292
294
293
/**
295
294
* @brief Validate an FI_OPT_FI_HMEM_P2P (FI_OPT_ENDPOINT) option for a
296
295
* specified HMEM interface.
297
- * Also update hmem_info[iface]->p2p_disabled_by_user accordingly.
298
296
*
299
- * @param[in,out] domain The efa_domain struct which contains an efa_hmem_info array
300
297
* @param[in] iface The fi_hmem_iface enum of the FI_HMEM interface to validate
301
298
* @param[in] p2p_opt The P2P option to validate
302
299
*
@@ -305,9 +302,9 @@ efa_domain_hmem_info_init_iface(struct efa_domain *efa_domain, enum fi_hmem_ifac
305
302
* -FI_ENODATA if the given HMEM interface was not initialized
306
303
* -FI_EINVAL if p2p_opt is not a valid FI_OPT_FI_HMEM_P2P option
307
304
*/
308
- int efa_domain_hmem_validate_p2p_opt (struct efa_domain * efa_domain , enum fi_hmem_iface iface , int p2p_opt )
305
+ int efa_domain_hmem_validate_p2p_opt (enum fi_hmem_iface iface , int p2p_opt )
309
306
{
310
- struct efa_hmem_info * info = & efa_domain -> hmem_info [iface ];
307
+ struct efa_hmem_info * info = g_efa_hmem_info [iface ];
311
308
312
309
if (OFI_UNLIKELY (!info -> initialized ))
313
310
return - FI_ENODATA ;
@@ -317,7 +314,6 @@ int efa_domain_hmem_validate_p2p_opt(struct efa_domain *efa_domain, enum fi_hmem
317
314
if (OFI_UNLIKELY (ofi_hmem_p2p_disabled ()) || !info -> p2p_supported_by_device )
318
315
return - FI_EOPNOTSUPP ;
319
316
320
- info -> p2p_disabled_by_user = false;
321
317
return 0 ;
322
318
/*
323
319
* According to fi_setopt() document:
@@ -334,43 +330,39 @@ int efa_domain_hmem_validate_p2p_opt(struct efa_domain *efa_domain, enum fi_hmem
334
330
if (OFI_UNLIKELY (ofi_hmem_p2p_disabled ()))
335
331
return - FI_EOPNOTSUPP ;
336
332
337
- info -> p2p_disabled_by_user = false;
338
333
return 0 ;
339
334
340
335
case FI_HMEM_P2P_DISABLED :
341
336
if (info -> p2p_required_by_impl )
342
337
return - FI_EOPNOTSUPP ;
343
338
344
- info -> p2p_disabled_by_user = true;
345
339
return 0 ;
346
340
}
347
341
348
342
return - FI_EINVAL ;
349
343
}
350
344
351
345
/**
352
- * @brief Initialize the hmem_info structs for
346
+ * @brief Initialize the g_efa_hmem_info structs for
353
347
* all of the HMEM devices. The device hmem_info
354
348
* struct will be used to determine which efa transfer
355
349
* protocol should be selected.
356
350
*
357
- * @param[in,out] efa_domain Pointer to struct efa_domain to be initialized
358
- *
359
351
* @return 0 on success
360
352
* negative libfabric error code on an unexpected error
361
353
*/
362
- int efa_domain_hmem_info_init_all ( struct efa_domain * efa_domain )
354
+ int efa_hmem_info_initialize ( )
363
355
{
364
356
int ret = 0 , i = 0 ;
365
357
366
358
if (g_device_cnt <= 0 ) {
367
359
return - FI_ENODEV ;
368
360
}
369
361
370
- memset (efa_domain -> hmem_info , 0 , OFI_HMEM_MAX * sizeof (struct efa_hmem_info ));
362
+ memset (g_efa_hmem_info , 0 , OFI_HMEM_MAX * sizeof (struct efa_hmem_info ));
371
363
372
364
EFA_HMEM_IFACE_FOREACH (i ) {
373
- efa_domain_hmem_info_init_iface ( efa_domain , efa_hmem_ifaces [i ]);
365
+ efa_hmem_info_init_iface ( efa_hmem_ifaces [i ]);
374
366
}
375
367
376
368
return ret ;
0 commit comments