Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Commit c15ab12

Browse files
committed
Merge pull request #1159 from matcabral/psm_link_dev_detect_2.x
PSM and PSM2 MTLs to detect drivers and link
2 parents a558e90 + 82e675d commit c15ab12

File tree

4 files changed

+88
-9
lines changed

4 files changed

+88
-9
lines changed

config/ompi_check_psm.m4

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ dnl Copyright (c) 2006 QLogic Corp. All rights reserved.
1414
dnl Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
1515
dnl Copyright (c) 2015 Research Organization for Information Science
1616
dnl and Technology (RIST). All rights reserved.
17+
dnl Copyright (c) 2016 Intel Corporation. All rights reserved.
18+
dnl
1719
dnl $COPYRIGHT$
1820
dnl
1921
dnl Additional copyrights may follow
@@ -65,6 +67,13 @@ AC_DEFUN([OMPI_CHECK_PSM],[
6567
[AC_MSG_WARN([PSM driver does not currently support progress threads. Disabling BTL.])
6668
ompi_check_psm_happy="no"])
6769

70+
AS_IF([test "$ompi_check_psm_happy" = "yes"],
71+
[AC_CHECK_HEADERS(
72+
glob.h,
73+
[],
74+
[AC_MSG_WARN([glob.h not found. Can not build component.])
75+
ompi_check_psm_happy="no"])])
76+
6877
AS_IF([test "$ompi_check_psm_happy" = "yes"],
6978
[$2],
7079
[AS_IF([test ! -z "$with_psm" && test "$with_psm" != "no"],

config/ompi_check_psm2.m4

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ AC_DEFUN([OMPI_CHECK_PSM2],[
6666
[AC_MSG_WARN([PSM2 driver does not currently support progress threads. Disabling MTL.])
6767
ompi_check_psm2_happy="no"])
6868

69+
AS_IF([test "$ompi_check_psm2_happy" = "yes"],
70+
[AC_CHECK_HEADERS(
71+
glob.h,
72+
[],
73+
[AC_MSG_WARN([glob.h not found. Can not build component.])
74+
ompi_check_psm2_happy="no"])])
75+
76+
6977
AS_IF([test "$ompi_check_psm2_happy" = "yes"],
7078
[$2],
7179
[AS_IF([test ! -z "$with_psm2" && test "$with_psm2" != "no"],

ompi/mca/mtl/psm/mtl_psm_component.c

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Copyright (c) 2006-2010 QLogic Corporation. All rights reserved.
1414
* Copyright (c) 2012-2015 Los Alamos National Security, LLC.
1515
* All rights reserved.
16-
* Copyright (c) 2014 Intel Corporation. All rights reserved.
16+
* Copyright (c) 2016 Intel Corporation. All rights reserved.
1717
* $COPYRIGHT$
1818
*
1919
* Additional copyrights may follow
@@ -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: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Copyright (c) 2006-2010 QLogic Corporation. All rights reserved.
1414
* Copyright (c) 2012-2015 Los Alamos National Security, LLC.
1515
* All rights reserved.
16-
* Copyright (c) 2013-2015 Intel, Inc. All rights reserved
16+
* Copyright (c) 2013-2016 Intel, Inc. All rights reserved
1717
* $COPYRIGHT$
1818
*
1919
* Additional copyrights may follow
@@ -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)