Skip to content

Commit b13cf9b

Browse files
authored
UCT/GDA: Move peermem check outside the loop. (#11001)
UCT/GDA: Move outside the loop.
1 parent c6542d7 commit b13cf9b

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

src/uct/ib/mlx5/gdaki/gdaki.c

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,25 @@ uct_gdaki_query_tl_devices(uct_md_h tl_md,
656656
ucs_sys_dev_distance_t dist;
657657
int i, num_gpus;
658658

659+
/*
660+
* Save the result of peermem driver check in a global flag to avoid
661+
* printing diag message for each MD.
662+
*/
663+
if (peermem_loaded == -1) {
664+
peermem_loaded = !!(md->super.reg_mem_types &
665+
UCS_BIT(UCS_MEMORY_TYPE_CUDA));
666+
if (peermem_loaded == 0) {
667+
ucs_diag("GDAKI not supported, please load "
668+
"Nvidia peermem driver by running "
669+
"\"modprobe nvidia_peermem\"");
670+
}
671+
}
672+
673+
if (peermem_loaded == 0) {
674+
status = UCS_ERR_NO_DEVICE;
675+
goto out;
676+
}
677+
659678
status = UCT_CUDADRV_FUNC_LOG_ERR(cuDeviceGetCount(&num_gpus));
660679
if (status != UCS_OK) {
661680
return status;
@@ -693,25 +712,6 @@ uct_gdaki_query_tl_devices(uct_md_h tl_md,
693712
goto err;
694713
}
695714

696-
/*
697-
* Save the result of peermem driver check in a global flag to avoid
698-
* printing diag message for each GPU and MD.
699-
*/
700-
if (peermem_loaded == -1) {
701-
peermem_loaded = !!(md->super.reg_mem_types &
702-
UCS_BIT(UCS_MEMORY_TYPE_CUDA));
703-
if (peermem_loaded == 0) {
704-
ucs_diag("GDAKI not supported, please load "
705-
"Nvidia peermem driver by running "
706-
"\"modprobe nvidia_peermem\"");
707-
}
708-
}
709-
710-
if (peermem_loaded == 0) {
711-
status = UCS_ERR_NO_DEVICE;
712-
goto err;
713-
}
714-
715715
uct_cuda_base_get_sys_dev(device, &dev);
716716
status = ucs_topo_get_distance(dev, md->super.dev.sys_dev, &dist);
717717
if (status != UCS_OK) {
@@ -738,6 +738,7 @@ uct_gdaki_query_tl_devices(uct_md_h tl_md,
738738

739739
err:
740740
ucs_free(tl_devices);
741+
out:
741742
return status;
742743
}
743744

0 commit comments

Comments
 (0)