@@ -514,6 +514,37 @@ static int ompi_mtl_ofi_init_regular_ep(struct fi_info * prov, int universe_size
514
514
return ret ;
515
515
}
516
516
517
+ #if OPAL_CUDA_SUPPORT && HAVE_DECL_FI_OPT_FI_HMEM_P2P
518
+ /*
519
+ * Set the FI_HMEM peer to peer option to ENABLED. This notifies Libfabric
520
+ * that the provider can decide whether to use device peer to peer support
521
+ * for network transfers, and allows copies if p2p is not supported.
522
+ *
523
+ * Note that this option may not be supported by the provider, so continue
524
+ * if FI_HMEM is supported by the provider but it does not support this
525
+ * setopt option. This setopt parameter was introduced in Libfabric 1.14.
526
+ *
527
+ * The version check is needed as one of the Libfabric setopt handlers
528
+ * incorrectly assumed all option values are size_t, which was also fixed
529
+ * in 1.14.
530
+ */
531
+ int setopt_val = FI_HMEM_P2P_ENABLED ;
532
+
533
+ if (FI_VERSION_GE (fi_version (), FI_VERSION (1 , 14 ))) {
534
+ ret = fi_setopt (& ompi_mtl_ofi .sep -> fid ,
535
+ FI_OPT_ENDPOINT , FI_OPT_FI_HMEM_P2P ,
536
+ & setopt_val , sizeof (setopt_val ));
537
+
538
+ if (!(0 == ret || - FI_ENOPROTOOPT == ret )) {
539
+ opal_show_help ("help-mtl-ofi.txt" , "OFI call fail" , true,
540
+ "fi_setopt" ,
541
+ ompi_process_info .nodename , __FILE__ , __LINE__ ,
542
+ fi_strerror (- ret ), - ret );
543
+ return ret ;
544
+ }
545
+ }
546
+ #endif /* OPAL_CUDA_SUPPORT && FI_OPT_FI_HMEM_P2P */
547
+
517
548
/**
518
549
* Create the objects that will be bound to the endpoint.
519
550
* The objects include:
0 commit comments