Skip to content

Commit 4d026e2

Browse files
author
rhc54
committed
Merge pull request #1661 from matcabral/master
PSM and PSM2 MTLs to detect drivers and link
2 parents f8facb1 + 4071719 commit 4d026e2

File tree

4 files changed

+86
-8
lines changed

4 files changed

+86
-8
lines changed

config/ompi_check_psm.m4

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ dnl Copyright (c) 2015 Research Organization for Information Science
1616
dnl and Technology (RIST). All rights reserved.
1717
dnl Copyright (c) 2016 Los Alamos National Security, LLC. All rights
1818
dnl reserved.
19+
dnl Copyright (c) 2016 Intel Corporation. All rights reserved.
20+
dnl
1921
dnl $COPYRIGHT$
2022
dnl
2123
dnl Additional copyrights may follow
@@ -68,6 +70,13 @@ AC_DEFUN([OMPI_CHECK_PSM],[
6870
[AC_MSG_WARN([PSM driver does not currently support progress threads. Disabling BTL.])
6971
ompi_check_psm_happy="no"])
7072

73+
AS_IF([test "$ompi_check_psm_happy" = "yes"],
74+
[AC_CHECK_HEADERS(
75+
glob.h,
76+
[],
77+
[AC_MSG_WARN([glob.h not found. Can not build component.])
78+
ompi_check_psm_happy="no"])])
79+
7180
OPAL_SUMMARY_ADD([[Transports]],[[Intel TrueScale (PSM)]],[$1],[$ompi_check_psm_happy])
7281
fi
7382

config/ompi_check_psm2.m4

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# All rights reserved.
1313
# Copyright (c) 2006 QLogic Corp. All rights reserved.
1414
# Copyright (c) 2009-2016 Cisco Systems, Inc. All rights reserved.
15-
# Copyright (c) 2014 Intel Corporation. All rights reserved.
15+
# Copyright (c) 2016 Intel Corporation. All rights reserved.
1616
# Copyright (c) 2015 Research Organization for Information Science
1717
# and Technology (RIST). All rights reserved.
1818
# Copyright (c) 2016 Los Alamos National Security, LLC. All rights
@@ -69,6 +69,13 @@ AC_DEFUN([OMPI_CHECK_PSM2],[
6969
[AC_MSG_WARN([PSM2 driver does not currently support progress threads. Disabling MTL.])
7070
ompi_check_psm2_happy="no"])
7171

72+
AS_IF([test "$ompi_check_psm2_happy" = "yes"],
73+
[AC_CHECK_HEADERS(
74+
glob.h,
75+
[],
76+
[AC_MSG_WARN([glob.h not found. Can not build component.])
77+
ompi_check_psm2_happy="no"])])
78+
7279
OPAL_SUMMARY_ADD([[Transports]],[[Intel Omnipath (PSM2)]],[$1],[$ompi_check_psm2_happy])
7380
fi
7481

ompi/mca/mtl/psm/mtl_psm_component.c

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <sys/types.h>
3838
#include <sys/stat.h>
3939
#include <unistd.h>
40+
#include <glob.h>
4041

4142
static int param_priority;
4243

@@ -185,12 +186,41 @@ ompi_mtl_psm_component_open(void)
185186
}
186187

187188
/* Component available only if Truescale hardware is present */
188-
if (0 == stat("/dev/ipath", &st)) {
189-
return OMPI_SUCCESS;
189+
if (0 != stat("/dev/ipath", &st)) {
190+
return OPAL_ERR_NOT_AVAILABLE;
191+
}
192+
193+
/* Component available only if at least one qib port is ACTIVE */
194+
bool foundOnlineQibPort = false;
195+
size_t i;
196+
char portState[128];
197+
FILE *devFile;
198+
glob_t globbuf;
199+
globbuf.gl_offs = 0;
200+
if (glob("/sys/class/infiniband/qib*/ports/*/state",
201+
GLOB_DOOFFS, NULL, &globbuf) != 0) {
202+
return OPAL_ERR_NOT_AVAILABLE;
203+
}
204+
205+
for (i=0;i < globbuf.gl_pathc; i++) {
206+
devFile = fopen(globbuf.gl_pathv[i], "r");
207+
fgets(portState, sizeof(portState), devFile);
208+
fclose(devFile);
209+
210+
if (strstr(portState, "ACTIVE") != NULL) {
211+
/* Found at least one ACTIVE port */
212+
foundOnlineQibPort = true;
213+
break;
214+
}
190215
}
191-
else {
216+
217+
globfree(&globbuf);
218+
219+
if (!foundOnlineQibPort) {
192220
return OPAL_ERR_NOT_AVAILABLE;
193221
}
222+
223+
return OMPI_SUCCESS;
194224
}
195225

196226
static int

ompi/mca/mtl/psm2/mtl_psm2_component.c

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <sys/types.h>
3838
#include <sys/stat.h>
3939
#include <unistd.h>
40+
#include <glob.h>
4041

4142
static int param_priority;
4243

@@ -101,15 +102,46 @@ ompi_mtl_psm2_component_register(void)
101102
static int
102103
ompi_mtl_psm2_component_open(void)
103104
{
104-
struct stat st;
105+
glob_t globbuf;
106+
globbuf.gl_offs = 0;
105107

106108
/* Component available only if Omni-Path hardware is present */
107-
if (0 == stat("/dev/hfi1", &st)) {
108-
return OMPI_SUCCESS;
109+
if ((glob("/dev/hfi1_[0-9]", GLOB_DOOFFS, NULL, &globbuf) != 0) &&
110+
(glob("/dev/hfi1_[0-9][0-9]", GLOB_APPEND, NULL, &globbuf) != 0)) {
111+
return OPAL_ERR_NOT_AVAILABLE;
112+
}
113+
114+
globfree(&globbuf);
115+
116+
/* Component available only if at least one hfi1 port is ACTIVE */
117+
bool foundOnlineHfi1Port = false;
118+
size_t i;
119+
char portState[128];
120+
FILE *devFile;
121+
if (glob("/sys/class/infiniband/hfi1_*/ports/*/state",
122+
GLOB_DOOFFS, NULL, &globbuf) != 0) {
123+
return OPAL_ERR_NOT_AVAILABLE;
124+
}
125+
126+
for (i=0;i < globbuf.gl_pathc; i++) {
127+
devFile = fopen(globbuf.gl_pathv[i], "r");
128+
fgets(portState, sizeof(portState), devFile);
129+
fclose(devFile);
130+
131+
if (strstr(portState, "ACTIVE") != NULL) {
132+
/* Found at least one ACTIVE port */
133+
foundOnlineHfi1Port = true;
134+
break;
135+
}
109136
}
110-
else {
137+
138+
globfree(&globbuf);
139+
140+
if (!foundOnlineHfi1Port) {
111141
return OPAL_ERR_NOT_AVAILABLE;
112142
}
143+
144+
return OMPI_SUCCESS;
113145
}
114146

115147
static int

0 commit comments

Comments
 (0)