diff --git a/opal/mca/common/verbs/common_verbs_basics.c b/opal/mca/common/verbs/common_verbs_basics.c index e79a16d6a8c..145c95b2eea 100644 --- a/opal/mca/common/verbs/common_verbs_basics.c +++ b/opal/mca/common/verbs/common_verbs_basics.c @@ -20,6 +20,9 @@ #ifdef HAVE_UNISTD_H #include #endif +#ifdef HAVE_DIRENT_H +#include +#endif /* This is crummy, but doesn't work on all platforms with all compilers. Specifically, trying to include it @@ -43,25 +46,45 @@ const char *ibv_get_sysfs_path(void); bool opal_common_verbs_check_basics(void) { + bool ret = false; + char *file = NULL; #if defined(__linux__) - int rc; - char *file; + int rc, ndevs = -2; /* for . and .. */ struct stat s; + struct dirent *dp; + DIR *dir = NULL; /* Check to see if $sysfsdir/class/infiniband/ exists */ asprintf(&file, "%s/class/infiniband", ibv_get_sysfs_path()); if (NULL == file) { - return false; + goto fn_exit; } + + /* okay, let's see if here are actually devices there or + * are we just being faked out */ + rc = stat(file, &s); - free(file); - if (0 != rc || !S_ISDIR(s.st_mode)) { - return false; + if (0 != rc) { + goto fn_exit; + } + + if (S_ISDIR(s.st_mode)) { + dir = opendir(file); + if (NULL != dir) { + while ((dp = readdir(dir)) != NULL) ndevs++; + closedir(dir); + } + ret = (0 < ndevs) ? true : false; + } else { + ret = false; } + #endif + fn_exit: + if (NULL != file) + free(file); - /* It exists and is a directory -- good enough */ - return true; + return ret; } int opal_common_verbs_fork_test(void) diff --git a/orte/mca/oob/ud/oob_ud_component.c b/orte/mca/oob/ud/oob_ud_component.c index 1c2d23daf2e..8d3350f4ad9 100644 --- a/orte/mca/oob/ud/oob_ud_component.c +++ b/orte/mca/oob/ud/oob_ud_component.c @@ -173,15 +173,25 @@ static int mca_oob_ud_component_register (void) } static int mca_oob_ud_component_available(void) { + int ret; opal_output_verbose(5, orte_oob_base_framework.framework_output, "oob:ud: component_available called"); - /* set the module event base - this is where we would spin off a separate - * progress thread if so desired */ - mca_oob_ud_module.ev_base = orte_event_base; + /* + * check if we actually have HCAs on this node, + * if not, no way we can use ud. + */ + if (opal_common_verbs_check_basics()) { + /* set the module event base - this is where we would spin off a separate + * progress thread if so desired */ + mca_oob_ud_module.ev_base = orte_event_base; + ret = ORTE_SUCCESS; + } else { + ret = ORTE_ERR_NOT_AVAILABLE; + } - return ORTE_SUCCESS; + return ret; } static int port_mtus[] = {0, 256, 512, 1024, 2048, 4096};