Skip to content

Commit dc0bb79

Browse files
committed
Merge pull request open-mpi#721 from jsquyres/pr/v2.0.0/move-usnic-fake-ibv-provider-to-its-own-common-component
v2.0.0: common_usnic: move fake IBV provider to libopen-pal
2 parents 8b0f053 + 90e30cd commit dc0bb79

File tree

8 files changed

+145
-11
lines changed

8 files changed

+145
-11
lines changed

opal/mca/common/verbs/Makefile.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ headers = \
1717
sources = \
1818
common_verbs_basics.c \
1919
common_verbs_devlist.c \
20-
common_verbs_fake.c \
2120
common_verbs_find_max_inline.c \
2221
common_verbs_find_ports.c \
2322
common_verbs_mca.c \

opal/mca/common/verbs/common_verbs.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,6 @@ OPAL_DECLSPEC int opal_common_verbs_qp_test(struct ibv_context *device_context,
180180
*/
181181
int opal_common_verbs_fork_test(void);
182182

183-
/*
184-
* Register fake verbs drivers
185-
*/
186-
void opal_common_verbs_register_fake_drivers(void);
187-
188183
END_C_DECLS
189184

190185
#endif

opal/mca/common/verbs/common_verbs_basics.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <unistd.h>
2222
#endif
2323

24+
#include "opal/mca/common/verbs_usnic/common_verbs_usnic.h"
25+
2426
/* This is crummy, but <infiniband/driver.h> doesn't work on all
2527
platforms with all compilers. Specifically, trying to include it
2628
on RHEL4U3 with the PGI 32 bit compiler will cause problems because
@@ -89,10 +91,12 @@ int opal_common_verbs_fork_test(void)
8991
}
9092
#endif
9193

92-
/* Now rgister any necessary fake libibverbs drivers. We
94+
/* Now register any necessary fake libibverbs drivers. We
9395
piggyback loading these fake drivers on the fork test because
94-
they must be loaded before ibv_get_device_list() is invoked. */
95-
opal_common_verbs_register_fake_drivers();
96+
they must be loaded before ibv_get_device_list() is invoked.
97+
Note that this routine is in a different common component (see
98+
comments over there for an explanation why). */
99+
opal_common_verbs_usnic_register_fake_drivers();
96100

97101
return ret;
98102
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#
2+
# Copyright (c) 2009-2012 Mellanox Technologies. All rights reserved.
3+
# Copyright (c) 2009-2012 Oak Ridge National Laboratory. All rights reserved.
4+
# Copyright (c) 2012-2015 Cisco Systems, Inc. All rights reserved.
5+
# $COPYRIGHT$
6+
#
7+
# Additional copyrights may follow
8+
#
9+
# $HEADER$
10+
#
11+
12+
headers = common_verbs_usnic.h
13+
14+
sources = common_verbs_usnic_fake.c
15+
16+
# This component is always linked statically. It has code that is
17+
# registered as a driver for libibverbs. There is no corresponding
18+
# *un*register API in libibverbs, so this code can never be dlclosed.
19+
# And therefore it must be in the libopen-pal library, not a DSO or
20+
# dependent library.
21+
22+
noinst_LTLIBRARIES = lib@OPAL_LIB_PREFIX@mca_common_verbs_usnic.la
23+
24+
lib@OPAL_LIB_PREFIX@mca_common_verbs_usnic_la_SOURCES = \
25+
$(headers) $(sources)
26+
lib@OPAL_LIB_PREFIX@mca_common_verbs_usnic_la_CPPFLAGS = \
27+
$(common_verbs_usnic_CPPFLAGS)
28+
lib@OPAL_LIB_PREFIX@mca_common_verbs_usnic_la_LDFLAGS = \
29+
$(common_verbs_usnic_LDFLAGS)
30+
lib@OPAL_LIB_PREFIX@mca_common_verbs_usnic_la_LIBADD = \
31+
$(common_verbs_usnic_LIBS)
32+
33+
# Conditionally install the header files
34+
35+
if WANT_INSTALL_HEADERS
36+
opaldir = $(opalincludedir)/opal/mca/common/verbs_usnic
37+
opal_HEADERS = $(headers)
38+
else
39+
opaldir = $(includedir)
40+
endif
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
3+
* $COPYRIGHT$
4+
*
5+
* Additional copyrights may follow
6+
*
7+
* $HEADER$
8+
*/
9+
10+
#ifndef _COMMON_VERBS_USNIC_H_
11+
#define _COMMON_VERBS_USNIC_H_
12+
13+
#include "opal_config.h"
14+
15+
#include <stdint.h>
16+
#include <infiniband/verbs.h>
17+
18+
BEGIN_C_DECLS
19+
20+
/*
21+
* Register fake verbs drivers
22+
*/
23+
void opal_common_verbs_usnic_register_fake_drivers(void);
24+
25+
END_C_DECLS
26+
27+
#endif

opal/mca/common/verbs/common_verbs_fake.c renamed to opal/mca/common/verbs_usnic/common_verbs_usnic_fake.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,18 @@
2727
* More specifically: the userspace side of usNIC is exposed through
2828
* libfabric; we don't need libibverbs warnings about not being able
2929
* to find a usnic driver.
30+
*
31+
* Note: this code is statically linked into libopen-pal. It is
32+
* registered via ibv_register_driver(), and there is no corresponding
33+
* *un*register IBV API. Hence, we cannot allow this code to be
34+
* dlclosed (e.g., if it is a DSO or a dependent common library) -- it
35+
* must be in libopen-pal itself, which will stay resident in the MPI
36+
* application.
3037
*/
3138

3239
#include "opal_config.h"
3340

41+
#include <stdio.h>
3442
#include <sys/types.h>
3543
#include <dirent.h>
3644
#include <string.h>
@@ -39,7 +47,7 @@
3947
#include <infiniband/driver.h>
4048
#endif
4149

42-
#include "common_verbs.h"
50+
#include "common_verbs_usnic.h"
4351

4452
/***********************************************************************/
4553

@@ -93,7 +101,7 @@ static struct ibv_device *fake_driver_init(const char *uverbs_sys_path,
93101
}
94102

95103

96-
void opal_common_verbs_register_fake_drivers(void)
104+
void opal_common_verbs_usnic_register_fake_drivers(void)
97105
{
98106
/* No need to do this more than once */
99107
static bool already_done = false;
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# -*- shell-script -*-
2+
#
3+
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
4+
# University Research and Technology
5+
# Corporation. All rights reserved.
6+
# Copyright (c) 2004-2005 The University of Tennessee and The University
7+
# of Tennessee Research Foundation. All rights
8+
# reserved.
9+
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
10+
# University of Stuttgart. All rights reserved.
11+
# Copyright (c) 2004-2005 The Regents of the University of California.
12+
# All rights reserved.
13+
# Copyright (c) 2007-2015 Cisco Systems, Inc. All rights reserved.
14+
# Copyright (c) 2009-2012 Mellanox Technologies. All rights reserved.
15+
# Copyright (c) 2009-2012 Oak Ridge National Laboratory. All rights reserved.
16+
# $COPYRIGHT$
17+
#
18+
# Additional copyrights may follow
19+
#
20+
# $HEADER$
21+
#
22+
23+
#
24+
# This component must be linked statically into libopen-pal because it
25+
# registers a provider for libibverbs at run time, and there's no
26+
# libibverbs API to *un*register a plugin. Hence, we can't allow this
27+
# code to be dlclosed/removed from the process. Hence: it must be
28+
# compiled statically into libopen-pal.
29+
#
30+
AC_DEFUN([MCA_opal_common_verbs_usnic_COMPILE_MODE], [
31+
AC_MSG_CHECKING([for MCA component $2:$3 compile mode])
32+
$4="static"
33+
AC_MSG_RESULT([$$4])
34+
])
35+
36+
# MCA_opal_common_verbs_usnic_CONFIG([action-if-can-compile],
37+
# [action-if-cant-compile])
38+
# ------------------------------------------------
39+
AC_DEFUN([MCA_opal_common_verbs_usnic_CONFIG],[
40+
AC_CONFIG_FILES([opal/mca/common/verbs_usnic/Makefile])
41+
common_verbs_usnic_happy="no"
42+
43+
OPAL_CHECK_OPENFABRICS([common_verbs_usnic],
44+
[common_verbs_usnic_happy="yes"])
45+
46+
AS_IF([test "$common_verbs_usnic_happy" = "yes"],
47+
[$1],
48+
[$2])
49+
50+
# substitute in the things needed to build openib
51+
AC_SUBST([common_verbs_usnic_CPPFLAGS])
52+
AC_SUBST([common_verbs_usnic_LDFLAGS])
53+
AC_SUBST([common_verbs_usnic_LIBS])
54+
])dnl
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#
2+
# owner/status file
3+
# owner: institution that is responsible for this package
4+
# status: e.g. active, maintenance, unmaintained
5+
#
6+
owner: Cisco
7+
status: maintenance

0 commit comments

Comments
 (0)