Merge pull request #410 from jsquyres/topic/libltdl-must-die
RFC: Replace libltdl with OPAL "dl" framework
Этот коммит содержится в:
Коммит
b958daa3e6
3
README
3
README
@ -8,7 +8,7 @@ Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
|
||||
University of Stuttgart. All rights reserved.
|
||||
Copyright (c) 2004-2007 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
Copyright (c) 2006-2014 Cisco Systems, Inc. All rights reserved.
|
||||
Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved.
|
||||
Copyright (c) 2006-2011 Mellanox Technologies. All rights reserved.
|
||||
Copyright (c) 2006-2012 Oracle and/or its affiliates. All rights reserved.
|
||||
Copyright (c) 2007 Myricom, Inc. All rights reserved.
|
||||
@ -1977,6 +1977,7 @@ backtrace - Debugging call stack backtrace support
|
||||
compress - Compression algorithms
|
||||
crs - Checkpoint and restart service
|
||||
db - Internal database support
|
||||
dl - Dynamic loading library interface
|
||||
event - Event library (libevent) versioning support
|
||||
hwloc - Hardware locality (hwloc) versioning support
|
||||
if - OS IP interface support
|
||||
|
23
autogen.pl
23
autogen.pl
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env perl
|
||||
#
|
||||
# Copyright (c) 2009-2014 Cisco Systems, Inc. All rights reserved.
|
||||
# Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved.
|
||||
# Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2013 Mellanox Technologies, Inc.
|
||||
# All rights reserved.
|
||||
@ -1265,7 +1265,6 @@ verbose "\n$step. Running autotools on top-level tree\n\n";
|
||||
verbose "==> Remove stale files\n";
|
||||
find_and_delete(qw/config.guess config.sub depcomp compile install-sh ltconfig
|
||||
ltmain.sh missing mkinstalldirs libtool/);
|
||||
system("rm -rf opal/libltdl");
|
||||
|
||||
# Remove the old m4 file and write the new one
|
||||
verbose "==> Writing m4 file with autogen.pl results\n";
|
||||
@ -1292,26 +1291,6 @@ safe_system($cmd);
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# For FreeBSD (carried over from autogen.sh); apparently some versions
|
||||
# of automake don't so this (prior to 1.9.7...?).
|
||||
system("chmod u+w opal/libltdl/configure");
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
++$step;
|
||||
verbose "\n$step. Patching autotools output on top-level tree :-(\n\n";
|
||||
|
||||
# Patch preopen error in libltdl
|
||||
if (-f "opal/libltdl/loaders/preopen.c") {
|
||||
verbose "=== Patching preopen error masking in libltdl\n";
|
||||
safe_system("$patch_prog -N -p0 < config/libltdl-preopen-error.diff");
|
||||
unlink("opal/libltdl/loaders/preopen.c.rej");
|
||||
}
|
||||
|
||||
patch_autotools_output(".");
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
verbose "
|
||||
================================================
|
||||
Open MPI autogen: completed successfully. w00t!
|
||||
|
@ -9,7 +9,7 @@
|
||||
# University of Stuttgart. All rights reserved.
|
||||
# Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
# All rights reserved.
|
||||
# Copyright (c) 2006-2010 Cisco Systems, Inc. All rights reserved.
|
||||
# Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved.
|
||||
# Copyright (c) 2010 Oracle and/or its affiliates. All rights
|
||||
# reserved.
|
||||
# Copyright (c) 2014 Intel, Inc. All rights reserved.
|
||||
@ -23,7 +23,6 @@
|
||||
EXTRA_DIST = \
|
||||
distscript.csh \
|
||||
opal_get_version.m4sh \
|
||||
libltdl-preopen-error.diff \
|
||||
ltmain_pgi_tp.diff \
|
||||
opal_mca_priority_sort.pl
|
||||
|
||||
|
@ -1,27 +0,0 @@
|
||||
--- opal/libltdl/loaders/preopen.c.~1~ 2010-03-03 14:13:28.000000000 -0500
|
||||
+++ opal/libltdl/loaders/preopen.c 2010-03-05 17:57:11.000000000 -0500
|
||||
@@ -185,7 +185,24 @@
|
||||
}
|
||||
}
|
||||
|
||||
+#if 0
|
||||
+ /* Open MPI: This line is commented out because Open MPI does not
|
||||
+ use the preopen functionality in libltdl at all -- so we never
|
||||
+ need to see errors from this module. Additionally, this module
|
||||
+ is usually invoked last in the sequence when trying to
|
||||
+ lt_dlopenadvise() a DSO -- so if there was a real error when
|
||||
+ opening that DSO (e.g., a symbol not found), setting the
|
||||
+ FILE_NOT_FOUND error here will mask the real error.
|
||||
+
|
||||
+ This error has been reported upstream to the Libtool maintainers;
|
||||
+ they acknowledge that it is a problem but no one has come up with
|
||||
+ a good general solution yet. This Open MPI-specific solution is
|
||||
+ workable for us, but not workable as a general solution. Hence,
|
||||
+ we patch in this "if 0" block in autogen.pl after Libtool
|
||||
+ installs libltdl in the opal/ tree.
|
||||
+ */
|
||||
LT__SETERROR (FILE_NOT_FOUND);
|
||||
+#endif
|
||||
|
||||
done:
|
||||
return module;
|
@ -10,7 +10,7 @@ dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
||||
dnl University of Stuttgart. All rights reserved.
|
||||
dnl Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
dnl All rights reserved.
|
||||
dnl Copyright (c) 2006-2010 Cisco Systems, Inc. All rights reserved.
|
||||
dnl Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved.
|
||||
dnl Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
|
||||
dnl Copyright (c) 2009 IBM Corporation. All rights reserved.
|
||||
dnl Copyright (c) 2009 Los Alamos National Security, LLC. All rights
|
||||
@ -72,10 +72,12 @@ AS_IF([test "$with_cuda" = "no" || test "x$with_cuda" = "x"],
|
||||
opal_cuda_incdir="$with_cuda/include"
|
||||
AC_MSG_RESULT([found ($opal_cuda_incdir/cuda.h)])])])])])
|
||||
|
||||
# We cannot have CUDA support without dlopen support. Check for that and
|
||||
# error out if the user has also set --disable-dlopen.
|
||||
AS_IF([test "$enable_dlopen" = "no" && test "$opal_check_cuda_happy" = "yes"],
|
||||
[AC_MSG_ERROR([--with-cuda cannot be used with --disable-dlopen. Remove one of them and reconfigure.])])
|
||||
dnl We cannot have CUDA support without dlopen support. HOWEVER, at
|
||||
dnl this point in configure, we can't know whether the DL framework
|
||||
dnl has been configured or not yet (it likely hasn't, since CUDA is a
|
||||
dnl common framework, and likely configured first). So we have to
|
||||
dnl defer this check until later (see the OPAL_CHECK_CUDA_AFTER_OPAL_DL m4
|
||||
dnl macro, below). :-(
|
||||
|
||||
# If we have CUDA support, check to see if we have CUDA 4.1 support
|
||||
AS_IF([test "$opal_check_cuda_happy"="yes"],
|
||||
@ -142,3 +144,21 @@ AC_DEFINE_UNQUOTED([OPAL_CUDA_GDR_SUPPORT],$CUDA_VERSION_60_OR_GREATER,
|
||||
[Whether we have CUDA GDR support available])
|
||||
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl CUDA support requires DL support (it dynamically opens the CUDA
|
||||
dnl library at run time). But we do not check for OPAL DL support
|
||||
dnl until lafter the initial OPAL_CHECK_CUDA is called. So put the
|
||||
dnl CUDA+DL check in a separate macro that can be called after the DL MCA
|
||||
dnl framework checks in the top-level configure.ac.
|
||||
dnl
|
||||
AC_DEFUN([OPAL_CHECK_CUDA_AFTER_OPAL_DL],[
|
||||
|
||||
# We cannot have CUDA support without OPAL DL support. Error out
|
||||
# if the user wants CUDA but we do not have OPAL DL support.
|
||||
AS_IF([test $OPAL_HAVE_DL_SUPPORT -eq 0 && \
|
||||
test "$opal_check_cuda_happy" = "yes"],
|
||||
[AC_MSG_WARN([--with-cuda was specified, but dlopen support is disabled.])
|
||||
AC_MSG_WARN([You must reconfigure Open MPI with dlopen ("dl") support.])
|
||||
AC_MSG_ERROR([Cannot continue.])])
|
||||
])
|
||||
|
@ -10,7 +10,7 @@ dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
||||
dnl University of Stuttgart. All rights reserved.
|
||||
dnl Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
dnl All rights reserved.
|
||||
dnl Copyright (c) 2006-2014 Cisco Systems, Inc. All rights reserved.
|
||||
dnl Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved.
|
||||
dnl Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
|
||||
dnl Copyright (c) 2009 IBM Corporation. All rights reserved.
|
||||
dnl Copyright (c) 2009 Los Alamos National Security, LLC. All rights
|
||||
|
@ -1,195 +0,0 @@
|
||||
dnl
|
||||
dnl Copyright (c) 2004-2009 The Trustees of Indiana University and Indiana
|
||||
dnl University Research and Technology
|
||||
dnl Corporation. All rights reserved.
|
||||
dnl Copyright (c) 2004-2005 The University of Tennessee and The University
|
||||
dnl of Tennessee Research Foundation. All rights
|
||||
dnl reserved.
|
||||
dnl Copyright (c) 2004-2007 High Performance Computing Center Stuttgart,
|
||||
dnl University of Stuttgart. All rights reserved.
|
||||
dnl Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
dnl All rights reserved.
|
||||
dnl Copyright (c) 2006-2014 Cisco Systems, Inc. All rights reserved.
|
||||
dnl Copyright (c) 2006-2008 Sun Microsystems, Inc. All rights reserved.
|
||||
dnl Copyright (c) 2006-2007 Los Alamos National Security, LLC. All rights
|
||||
dnl reserved.
|
||||
dnl Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
|
||||
dnl $COPYRIGHT$
|
||||
dnl
|
||||
dnl Additional copyrights may follow
|
||||
dnl
|
||||
dnl $HEADER$
|
||||
dnl
|
||||
|
||||
AC_DEFUN([OPAL_SETUP_LIBLTDL],[
|
||||
OPAL_VAR_SCOPE_PUSH([HAPPY])
|
||||
|
||||
opal_show_subtitle "GNU libltdl setup"
|
||||
|
||||
# AC_CONFIG_SUBDIRS appears to be broken for non-gcc compilers (i.e.,
|
||||
# passing precious variables down to the sub-configure).
|
||||
#
|
||||
# Finally, make ltdl follow the same shared/static convention that was
|
||||
# user for the main OMPI libraries. So manually examine
|
||||
# $enable_shared and $enable_static and pass down the corresponding
|
||||
# flags.
|
||||
|
||||
LIBLTDL_SUBDIR=
|
||||
OPAL_HAVE_LTDL_ADVISE=0
|
||||
OPAL_LIBLTDL_INTERNAL=0
|
||||
|
||||
AS_IF([test "$OPAL_ENABLE_DLOPEN_SUPPORT" = "0"],
|
||||
[AC_MSG_WARN([libltdl support disabled (by --disable-dlopen)])
|
||||
LIBLTDL=
|
||||
LDTLINCL=
|
||||
OPAL_WRAPPER_FLAGS_ADD(LIBS, "$LIBS")],
|
||||
[
|
||||
# Default to building the internal copy. After this,
|
||||
# paffinity_hwloc_location is guaranteed to be set to one of:
|
||||
# "internal", a directory name (i.e., whatever the user
|
||||
# supplied), or "no".
|
||||
libltdl_location=$with_libltdl
|
||||
AS_IF([test -z "$libltdl_location" -o "$libltdl_location" = "yes"],
|
||||
[libltdl_location=internal])
|
||||
|
||||
AC_MSG_CHECKING([location of libltdl])
|
||||
case $libltdl_location in
|
||||
no)
|
||||
AC_MSG_WARN([--without-libltdl specified in conjunction with])
|
||||
AC_MSG_WARN([--enable-dlopen (or --disable-dlopen was not specified)])
|
||||
AC_MSG_WARN([Cannot have dlopen without libltdl])
|
||||
AC_MSG_ERROR([Cannot continue])
|
||||
;;
|
||||
internal)
|
||||
AC_MSG_RESULT([internal copy])
|
||||
_OPAL_SETUP_LIBLTDL_INTERNAL
|
||||
;;
|
||||
external)
|
||||
AC_MSG_RESULT([external copy (unspecified)])
|
||||
# If we're using an extern libltdl, then reset the
|
||||
# LTDLINCL that was set earlier (ie., there's no need to
|
||||
# -I into our internal libltdl tree).
|
||||
LIBLTDL=
|
||||
LDTLINCL=
|
||||
libltdl_location=
|
||||
libltdl_need_external=1
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT([external copy ($libltdl_location)])
|
||||
OPAL_CHECK_WITHDIR([libltdl], [$libltdl_location],
|
||||
[include/ltdl.h])
|
||||
# If we're using an extern libltdl, then reset the
|
||||
# LTDLINCL that was set earlier (ie., there's no need to
|
||||
# -I into our internal libltdl tree).
|
||||
LIBLTDL=
|
||||
LDTLINCL=
|
||||
libltdl_need_external=1
|
||||
;;
|
||||
esac
|
||||
|
||||
AS_IF([test "$libltdl_need_external" = "1"],
|
||||
[OPAL_CHECK_PACKAGE([libltdl],
|
||||
[ltdl.h],
|
||||
[ltdl],
|
||||
[lt_dlopen],
|
||||
[],
|
||||
[$libltdl_location],
|
||||
[],
|
||||
[],
|
||||
[AC_MSG_WARN([External libltdl installation not found])
|
||||
AC_MSG_WARN([or not usable.])
|
||||
AC_MSG_ERROR([Cannot continue.])])
|
||||
CPPFLAGS="$CPPFLAGS $libltdl_CPPFLAGS"
|
||||
LDFLAGS="$LDFLAGS $libltdl_LDFLAGS"
|
||||
LIBS="$LIBS $libltdl_LIBS"
|
||||
|
||||
# Check for lt_dladvise_init; warn if we don't have
|
||||
# it
|
||||
AC_CHECK_FUNC([lt_dladvise_init],
|
||||
[OPAL_HAVE_LTDL_ADVISE=1],
|
||||
[AC_MSG_WARN([*********************************************])
|
||||
AC_MSG_WARN([Could not find lt_dladvise_init in the])
|
||||
AC_MSG_WARN([external libltdl installation.])
|
||||
AC_MSG_WARN([This could mean that your libltdl version])
|
||||
AC_MSG_WARN([is old. We recommend that you re-configure])
|
||||
AC_MSG_WARN([Open MPI with --with-libltdl=internal to])
|
||||
AC_MSG_WARN([use the internal libltdl copy in Open MPI.])
|
||||
AC_MSG_WARN([])
|
||||
AC_MSG_WARN([Sleeping 10 seconds to give you a])
|
||||
AC_MSG_WARN([chance to read this message.])
|
||||
AC_MSG_WARN([*********************************************])
|
||||
sleep 10
|
||||
])
|
||||
])
|
||||
])
|
||||
|
||||
AC_SUBST(LTDLINCL)
|
||||
AC_SUBST(LIBLTDL)
|
||||
AC_SUBST(LIBLTDL_SUBDIR)
|
||||
|
||||
AC_MSG_CHECKING([for lt_dladvise])
|
||||
AS_IF([test $OPAL_HAVE_LTDL_ADVISE -eq 1],
|
||||
[AC_MSG_RESULT([yes])],
|
||||
[AC_MSG_RESULT([no])])
|
||||
AC_DEFINE_UNQUOTED(OPAL_HAVE_LTDL_ADVISE, $OPAL_HAVE_LTDL_ADVISE,
|
||||
[Whether libltdl appears to have the lt_dladvise interface])
|
||||
|
||||
AC_DEFINE_UNQUOTED(OPAL_WANT_LIBLTDL, $OPAL_ENABLE_DLOPEN_SUPPORT,
|
||||
[Whether to include support for libltdl or not])
|
||||
AC_DEFINE_UNQUOTED(OPAL_LIBLTDL_INTERNAL, $OPAL_LIBLTDL_INTERNAL,
|
||||
[Whether we are using the internal libltdl or not])
|
||||
|
||||
AM_CONDITIONAL(OPAL_HAVE_DLOPEN,
|
||||
[test "$OPAL_ENABLE_DLOPEN_SUPPORT" = "1"])
|
||||
OPAL_VAR_SCOPE_POP([HAPPY])
|
||||
])dnl
|
||||
|
||||
|
||||
#
|
||||
# Setup to build the internal copy of libltdl
|
||||
#
|
||||
AC_DEFUN([_OPAL_SETUP_LIBLTDL_INTERNAL],[
|
||||
OPAL_VAR_SCOPE_PUSH([CFLAGS_save CPPFLAGS_save])
|
||||
|
||||
opal_subdir_args="$opal_subdir_args --enable-ltdl-convenience --disable-ltdl-install"
|
||||
if test "$enable_shared" = "yes"; then
|
||||
opal_subdir_args="$opal_subdir_args --enable-shared"
|
||||
else
|
||||
opal_subdir_args="$opal_subdir_args --disable-shared"
|
||||
fi
|
||||
if test "$enable_static" = "yes"; then
|
||||
opal_subdir_args="$opal_subdir_args --enable-static"
|
||||
else
|
||||
opal_subdir_args="$opal_subdir_args --disable-static"
|
||||
fi
|
||||
|
||||
CFLAGS_save=$CFLAGS
|
||||
CFLAGS="$OPAL_CFLAGS_BEFORE_PICKY $OPAL_VISIBILITY_CFLAGS"
|
||||
|
||||
# VPATH support will be included by default in CONFIG_SUBDIR
|
||||
OPAL_CONFIG_SUBDIR(opal/libltdl, [$opal_subdir_args],
|
||||
[HAPPY=1], [HAPPY=0])
|
||||
if test $HAPPY -eq 1; then
|
||||
LIBLTDL_SUBDIR=libltdl
|
||||
OPAL_LIBLTDL_INTERNAL=1
|
||||
|
||||
CPPFLAGS_save=$CPPFLAGS
|
||||
CPPFLAGS="-I$srcdir -I$srcdir/opal/libltdl"
|
||||
AC_EGREP_HEADER([lt_dladvise_init], [opal/libltdl/ltdl.h],
|
||||
[OPAL_HAVE_LTDL_ADVISE=1])
|
||||
CPPFLAGS=$CPPFLAGS_save
|
||||
|
||||
# --export-dynamic allows exported symbols to be resolved via
|
||||
# --dlsym and friends.
|
||||
LDFLAGS="-export-dynamic $LDFLAGS"
|
||||
else
|
||||
AC_MSG_WARN([Failed to build GNU libltdl. This usually means that something])
|
||||
AC_MSG_WARN([is incorrectly setup with your environment. There may be useful information in])
|
||||
AC_MSG_WARN([opal/libltdl/config.log. You can also disable GNU libltdl, which will disable])
|
||||
AC_MSG_WARN([dynamic shared object loading, by configuring with --disable-dlopen.])
|
||||
AC_MSG_ERROR([Cannot continue])
|
||||
fi
|
||||
CFLAGS=$CFLAGS_save
|
||||
|
||||
OPAL_VAR_SCOPE_POP
|
||||
])dnl
|
16
configure.ac
16
configure.ac
@ -1157,6 +1157,18 @@ m4_ifdef([project_ompi], [OMPI_REQUIRE_ENDPOINT_TAG_FINI])
|
||||
# checkpoint results
|
||||
AC_CACHE_SAVE
|
||||
|
||||
##################################
|
||||
# CUDA: part two
|
||||
##################################
|
||||
|
||||
# This is somewhat gross to have a configure check for a common MCA
|
||||
# component outside of the normal MCA checks, but this check must come
|
||||
# after the opal DL MCA checks have done. Someday this could perhaps
|
||||
# be done better by having some kind of "run this check at the end of
|
||||
# all other MCA checks" hook...?
|
||||
|
||||
OPAL_CHECK_CUDA_AFTER_OPAL_DL
|
||||
|
||||
##################################
|
||||
# MPI Extended Interfaces
|
||||
##################################
|
||||
@ -1218,8 +1230,6 @@ fi
|
||||
# a C++ compiler.
|
||||
AS_IF([test "$OMPI_WANT_FORTRAN_BINDINGS" != "1"],[F77=no FC=no])
|
||||
|
||||
LT_CONFIG_LTDL_DIR([opal/libltdl], [subproject])
|
||||
LTDL_CONVENIENCE
|
||||
LT_INIT([dlopen win32-dll])
|
||||
|
||||
# What's the suffix of shared libraries? Inspired by generated
|
||||
@ -1256,8 +1266,6 @@ esac
|
||||
AC_SUBST(OPAL_DYN_LIB_PREFIX)
|
||||
AC_SUBST(OPAL_DYN_LIB_SUFFIX)
|
||||
|
||||
OPAL_SETUP_LIBLTDL
|
||||
|
||||
# Need the libtool binary before the rpathify stuff
|
||||
LT_OUTPUT
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
# University of Stuttgart. All rights reserved.
|
||||
# Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
# All rights reserved.
|
||||
# Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
|
||||
# $COPYRIGHT$
|
||||
#
|
||||
# Additional copyrights may follow
|
||||
@ -90,11 +91,6 @@ sub wanted {
|
||||
elsif ($parts[0] eq "ompi" && $parts[1] eq "mpi" && $parts[2] eq "f90") {
|
||||
return;
|
||||
}
|
||||
# The only file we want in opal/libltdl is ltdl.h
|
||||
elsif ($parts[0] eq "opal" && $parts[1] eq "libltdl" &&
|
||||
$name ne "ltdl.h") {
|
||||
return;
|
||||
}
|
||||
# The only file we want in opal/event is event.h
|
||||
elsif ($parts[0] eq "opal" && $parts[1] eq "event" &&
|
||||
$name ne "event.h") {
|
||||
|
@ -9,7 +9,7 @@
|
||||
# University of Stuttgart. All rights reserved.
|
||||
# Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
# All rights reserved.
|
||||
# Copyright (c) 2007-2013 Cisco Systems, Inc. All rights reserved.
|
||||
# Copyright (c) 2007-2015 Cisco Systems, Inc. All rights reserved.
|
||||
# $COPYRIGHT$
|
||||
#
|
||||
# Additional copyrights may follow
|
||||
@ -20,10 +20,7 @@
|
||||
noinst_LTLIBRARIES = libdebuggers.la libompi_debugger_canary.la
|
||||
ompilib_LTLIBRARIES = libompi_dbg_msgq.la
|
||||
|
||||
check_PROGRAMS = predefined_gap_test predefined_pad_test
|
||||
if OPAL_HAVE_DLOPEN
|
||||
check_PROGRAMS += dlopen_test
|
||||
endif
|
||||
check_PROGRAMS = predefined_gap_test predefined_pad_test dlopen_test
|
||||
|
||||
TESTS = $(check_PROGRAMS)
|
||||
|
||||
@ -44,11 +41,10 @@ headers = \
|
||||
msgq_interface.h ompi_msgq_dll_defs.h
|
||||
|
||||
# Simple checks to ensure that the DSOs are functional
|
||||
# This test is only built if we have libltdl support.
|
||||
|
||||
dlopen_test_SOURCES = dlopen_test.c
|
||||
dlopen_test_CPPFLAGS = -I$(top_srcdir)/opal/libltdl
|
||||
dlopen_test_LDADD = $(top_builddir)/opal/libltdl/libltdlc.la
|
||||
dlopen_test_LDADD = $(top_builddir)/ompi/libmpi.la
|
||||
dlopen_test_DEPENDENCIES = $(ompi_predefined_LDADD)
|
||||
|
||||
predefined_gap_test_SOURCES = predefined_gap_test.c
|
||||
predefined_gap_test_LDFLAGS = $(WRAPPER_EXTRA_LDFLAGS)
|
||||
|
Двоичные данные
ompi/debuggers/core.lt-dlopen_test-1424445474-6373
Обычный файл
Двоичные данные
ompi/debuggers/core.lt-dlopen_test-1424445474-6373
Обычный файл
Двоичный файл не отображается.
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009-2010 Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -13,9 +13,10 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "opal/libltdl/ltdl.h"
|
||||
#include "opal/runtime/opal.h"
|
||||
#include "opal/mca/dl/base/base.h"
|
||||
|
||||
#if !OPAL_WANT_LIBLTDL
|
||||
#if !OPAL_HAVE_DL_SUPPORT
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
/* If OPAL wasn't built with libltdl support, then skip this test */
|
||||
@ -23,7 +24,36 @@ int main(int argc, char *argv[])
|
||||
return 77;
|
||||
}
|
||||
|
||||
#else /* OPAL_WANT_LIBLTDL */
|
||||
#else /* OPAL_HAVE_DL_SUPPORT */
|
||||
|
||||
static int try_open(const char *filename)
|
||||
{
|
||||
char *err_msg;
|
||||
opal_dl_handle_t *handle;
|
||||
int ret;
|
||||
|
||||
ret = opal_dl_open(filename, true, true, &handle, &err_msg);
|
||||
if (OPAL_SUCCESS == ret) {
|
||||
opal_dl_close(handle);
|
||||
printf("File opened with private namespace, all passed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("Failed to open with private namespace: %s\n", err_msg);
|
||||
printf("Retrying with global namespace\n");
|
||||
|
||||
ret = opal_dl_open(filename, true, false, &handle, &err_msg);
|
||||
if (OPAL_SUCCESS == ret) {
|
||||
opal_dl_close(handle);
|
||||
printf("File opened with global namespace\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
fprintf(stderr, "File failed to open with global namespace: %s\n",
|
||||
err_msg);
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int do_test(void)
|
||||
{
|
||||
@ -32,11 +62,6 @@ static int do_test(void)
|
||||
char full_filename[] = "./libompi_dbg_msgq.la";
|
||||
char line[1024];
|
||||
int happy;
|
||||
lt_dlhandle dlhandle;
|
||||
|
||||
#if OPAL_HAVE_LTDL_ADVISE
|
||||
lt_dladvise dladvise;
|
||||
#endif
|
||||
|
||||
/* Double check that the .la file is there that we expect; if it's
|
||||
not, skip this test. */
|
||||
@ -74,60 +99,41 @@ static int do_test(void)
|
||||
exit(77);
|
||||
}
|
||||
|
||||
/* Startup LT */
|
||||
if (lt_dlinit() != 0) {
|
||||
fprintf(stderr, "Failed to lt_dlinit\n");
|
||||
return 1;
|
||||
}
|
||||
char cwd[4096];
|
||||
getcwd(cwd, sizeof(cwd) - 1);
|
||||
cwd[sizeof(cwd) - 1] = '\0';
|
||||
printf("Running in CWD: %s\n", cwd);
|
||||
|
||||
printf("Trying to lt_dlopen file with dladvise_local: %s\n", filename);
|
||||
printf("Trying to open file with private namespace: %s\n", filename);
|
||||
|
||||
#if OPAL_HAVE_LTDL_ADVISE
|
||||
if (lt_dladvise_init(&dladvise) ||
|
||||
lt_dladvise_ext(&dladvise) ||
|
||||
lt_dladvise_local(&dladvise)) {
|
||||
fprintf(stderr, "lt_dladvise failed to initialize properly\n");
|
||||
return 1;
|
||||
}
|
||||
dlhandle = lt_dlopenadvise(filename, dladvise);
|
||||
lt_dladvise_destroy(&dladvise);
|
||||
#else
|
||||
dlhandle = lt_dlopenext(filename);
|
||||
#endif
|
||||
if (NULL != dlhandle) {
|
||||
lt_dlclose(dlhandle);
|
||||
printf("File opened with dladvise_local, all passed\n");
|
||||
/* If that works, great */
|
||||
if (0 == try_open(filename)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("Failed to open with dladvise_local: %s\n", lt_dlerror());
|
||||
printf("Retrying with dladvise_global\n");
|
||||
|
||||
#if OPAL_HAVE_LTDL_ADVISE
|
||||
if (lt_dladvise_init(&dladvise) ||
|
||||
lt_dladvise_ext(&dladvise) ||
|
||||
lt_dladvise_global(&dladvise)) {
|
||||
fprintf(stderr, "lt_dladvise failed to initialize properly\n");
|
||||
/* If we're using libltdl, it will find the .la file and may
|
||||
discover that it needs to open the actual file in the .libs
|
||||
directory. If we're not using libltdl, then we won't know
|
||||
about the magic .la file / .libs directory. Hueristic: if we
|
||||
get here, manually prefix the filename with .libs/ and try
|
||||
again. */
|
||||
char *rel_filename;
|
||||
asprintf(&rel_filename, ".libs/%s", filename);
|
||||
if (NULL == rel_filename) {
|
||||
return 1;
|
||||
}
|
||||
dlhandle = lt_dlopenadvise(filename, dladvise);
|
||||
lt_dladvise_destroy(&dladvise);
|
||||
#else
|
||||
dlhandle = lt_dlopenext(filename);
|
||||
#endif
|
||||
if (NULL != dlhandle) {
|
||||
lt_dlclose(dlhandle);
|
||||
printf("File opened with dladvise_global\n");
|
||||
return 0;
|
||||
}
|
||||
fprintf(stderr, "File failed to open with dladvise_global: %s\n",
|
||||
lt_dlerror());
|
||||
int rc = try_open(rel_filename);
|
||||
free(rel_filename);
|
||||
|
||||
return 2;
|
||||
return rc;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
return do_test();
|
||||
opal_init(&argc, &argv);
|
||||
int ret = do_test();
|
||||
opal_finalize();
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* OPAL_WANT_LIBLTDL */
|
||||
#endif /* OPAL_HAVE_DL_SUPPORT */
|
||||
|
@ -118,8 +118,7 @@ void ompi_info_do_config(bool want_all)
|
||||
char *fortran_usempif08_profiling;
|
||||
char *cxxexceptions;
|
||||
char *threads;
|
||||
char *want_libltdl;
|
||||
char *have_ltdl_advise;
|
||||
char *have_dl;
|
||||
#if OMPI_RTE_ORTE
|
||||
char *mpirun_prefix_by_default;
|
||||
#endif
|
||||
@ -259,8 +258,7 @@ void ompi_info_do_config(bool want_all)
|
||||
fortran_mpifh_profiling = (OMPI_ENABLE_MPI_PROFILING && OMPI_BUILD_FORTRAN_MPIFH_BINDINGS) ? "yes" : "no";
|
||||
fortran_usempi_profiling = (OMPI_ENABLE_MPI_PROFILING && OMPI_BUILD_FORTRAN_USEMPI_BINDINGS) ? "yes" : "no";
|
||||
fortran_usempif08_profiling = (OMPI_ENABLE_MPI_PROFILING && OMPI_BUILD_FORTRAN_USEMPIF08_BINDINGS) ? "yes" : "no";
|
||||
want_libltdl = OPAL_WANT_LIBLTDL ? "yes" : "no";
|
||||
have_ltdl_advise = OPAL_HAVE_LTDL_ADVISE ? "yes" : "no";
|
||||
have_dl = OPAL_HAVE_DL_SUPPORT ? "yes" : "no";
|
||||
#if OMPI_RTE_ORTE
|
||||
mpirun_prefix_by_default = ORTE_WANT_ORTERUN_PREFIX_BY_DEFAULT ? "yes" : "no";
|
||||
#endif
|
||||
@ -620,8 +618,7 @@ void ompi_info_do_config(bool want_all)
|
||||
opal_info_out("MPI parameter check", "option:mpi-param-check", paramcheck);
|
||||
opal_info_out("Memory profiling support", "option:mem-profile", memprofile);
|
||||
opal_info_out("Memory debugging support", "option:mem-debug", memdebug);
|
||||
opal_info_out("libltdl support", "option:dlopen", want_libltdl);
|
||||
opal_info_out("lt_dladvise support", "option:lt_dladvise", have_ltdl_advise);
|
||||
opal_info_out("dl support", "option:dlopen", have_dl);
|
||||
opal_info_out("Heterogeneous support", "options:heterogeneous", heterogeneous);
|
||||
#if OMPI_RTE_ORTE
|
||||
opal_info_out("mpirun default --prefix", "mpirun:prefix_by_default",
|
||||
|
@ -9,7 +9,7 @@
|
||||
# University of Stuttgart. All rights reserved.
|
||||
# Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
# All rights reserved.
|
||||
# Copyright (c) 2009-2014 Cisco Systems, Inc. All rights reserved.
|
||||
# Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved.
|
||||
# $COPYRIGHT$
|
||||
#
|
||||
# Additional copyrights may follow
|
||||
@ -19,7 +19,6 @@
|
||||
|
||||
SUBDIRS = \
|
||||
include \
|
||||
$(LIBLTDL_SUBDIR) \
|
||||
asm \
|
||||
datatype \
|
||||
etc \
|
||||
@ -35,7 +34,6 @@ SUBDIRS = \
|
||||
# therefore make distclean will fail).
|
||||
DIST_SUBDIRS = \
|
||||
include \
|
||||
$(LIBLTDL_SUBDIR) \
|
||||
asm \
|
||||
datatype \
|
||||
etc \
|
||||
@ -49,7 +47,6 @@ DIST_SUBDIRS = \
|
||||
lib_LTLIBRARIES = lib@OPAL_LIB_PREFIX@open-pal.la
|
||||
lib@OPAL_LIB_PREFIX@open_pal_la_SOURCES =
|
||||
lib@OPAL_LIB_PREFIX@open_pal_la_LIBADD = \
|
||||
$(LIBLTDL) \
|
||||
asm/libasm.la \
|
||||
datatype/libdatatype.la \
|
||||
mca/base/libmca_base.la \
|
||||
@ -69,11 +66,6 @@ lib@OPAL_LIB_PREFIX@open_pal_la_SOURCES += $(headers)
|
||||
if WANT_INSTALL_HEADERS
|
||||
opaldir = $(opalincludedir)/$(subdir)
|
||||
nobase_opal_HEADERS = $(headers)
|
||||
|
||||
# This is somewhat of a hack -- libltdl is installed by libtoolize,
|
||||
# and us installing the header here is slightly less kludgey than
|
||||
# hacking their Makefile.am.
|
||||
nobase_opal_HEADERS += libltdl/ltdl.h
|
||||
endif
|
||||
|
||||
include class/Makefile.am
|
||||
|
@ -10,7 +10,7 @@
|
||||
* University of Stuttgart. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2008-2010 Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2015 Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Copyright (c) 2015 Research Organization for Information Science
|
||||
* and Technology (RIST). All rights reserved.
|
||||
@ -43,14 +43,6 @@
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
#if OPAL_LIBLTDL_INTERNAL
|
||||
#include "opal/libltdl/ltdl.h"
|
||||
#else
|
||||
#include "ltdl.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "opal/mca/installdirs/installdirs.h"
|
||||
#include "opal/util/opal_environ.h"
|
||||
#include "opal/util/output.h"
|
||||
@ -61,9 +53,10 @@
|
||||
#include "opal/mca/base/base.h"
|
||||
#include "opal/mca/base/mca_base_component_repository.h"
|
||||
#include "opal/constants.h"
|
||||
#include "opal/mca/dl/base/base.h"
|
||||
|
||||
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
#if OPAL_HAVE_DL_SUPPORT
|
||||
/*
|
||||
* Private types; only necessary when we're dlopening components.
|
||||
*/
|
||||
@ -98,20 +91,17 @@ typedef struct dependency_item_t dependency_item_t;
|
||||
|
||||
static OBJ_CLASS_INSTANCE(dependency_item_t, opal_list_item_t, NULL, NULL);
|
||||
|
||||
#if OPAL_HAVE_LTDL_ADVISE
|
||||
extern lt_dladvise opal_mca_dladvise;
|
||||
#endif
|
||||
#endif /* OPAL_WANT_LIBLTDL */
|
||||
#endif /* OPAL_HAVE_DL_SUPPORT */
|
||||
|
||||
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
#if OPAL_HAVE_DL_SUPPORT
|
||||
/*
|
||||
* Private functions
|
||||
*/
|
||||
static void find_dyn_components(const char *path, const char *type,
|
||||
const char **names, bool include_mode,
|
||||
opal_list_t *found_components);
|
||||
static int save_filename(const char *filename, lt_ptr data);
|
||||
static int save_filename(const char *filename, void *data);
|
||||
static int open_component(component_file_item_t *target_file,
|
||||
opal_list_t *found_components);
|
||||
static int check_opal_info(component_file_item_t *target_file,
|
||||
@ -131,7 +121,7 @@ static const char component_template[] = "mca_%s_";
|
||||
static opal_list_t found_files;
|
||||
static char **found_filenames = NULL;
|
||||
static char *last_path_to_use = NULL;
|
||||
#endif /* OPAL_WANT_LIBLTDL */
|
||||
#endif /* OPAL_HAVE_DL_SUPPORT */
|
||||
|
||||
static int component_find_check (const char *framework_name, char **requested_component_names, opal_list_t *components);
|
||||
|
||||
@ -196,7 +186,7 @@ int mca_base_component_find(const char *directory, const char *type,
|
||||
}
|
||||
}
|
||||
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
#if OPAL_HAVE_DL_SUPPORT
|
||||
/* Find any available dynamic components in the specified directory */
|
||||
if (open_dso_components && !mca_base_component_disable_dlopen) {
|
||||
find_dyn_components(directory, type,
|
||||
@ -228,7 +218,7 @@ component_find_out:
|
||||
|
||||
int mca_base_component_find_finalize(void)
|
||||
{
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
#if OPAL_HAVE_DL_SUPPORT
|
||||
if (NULL != found_filenames) {
|
||||
opal_argv_free(found_filenames);
|
||||
found_filenames = NULL;
|
||||
@ -306,18 +296,15 @@ int mca_base_components_filter (const char *framework_name, opal_list_t *compone
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
#if OPAL_HAVE_DL_SUPPORT
|
||||
|
||||
/*
|
||||
* Open up all directories in a given path and search for components of
|
||||
* the specified type (and possibly of a given name).
|
||||
*
|
||||
* Note that we use our own path iteration functionality (vs. ltdl's
|
||||
* lt_dladdsearchdir() functionality) because we need to look at
|
||||
* companion .ompi_info files in the same directory as the library to
|
||||
* generate dependencies, etc. If we use the plain lt_dlopen()
|
||||
* functionality, we would not get the directory name of the file
|
||||
* finally opened in recursive dependency traversals.
|
||||
* Note that we use our own path iteration functionality because we
|
||||
* need to look at companion .ompi_info files in the same directory as
|
||||
* the library to generate dependencies, etc.
|
||||
*/
|
||||
static void find_dyn_components(const char *path, const char *type_name,
|
||||
const char **names, bool include_mode,
|
||||
@ -377,18 +364,18 @@ static void find_dyn_components(const char *path, const char *type_name,
|
||||
if ((0 == strcmp(dir, "USER_DEFAULT") ||
|
||||
0 == strcmp(dir, "USR_DEFAULT"))
|
||||
&& NULL != mca_base_user_default_path) {
|
||||
if (0 != lt_dlforeachfile(mca_base_user_default_path,
|
||||
save_filename, NULL)) {
|
||||
if (0 != opal_dl_foreachfile(mca_base_user_default_path,
|
||||
save_filename, NULL)) {
|
||||
break;
|
||||
}
|
||||
} else if (0 == strcmp(dir, "SYS_DEFAULT") ||
|
||||
0 == strcmp(dir, "SYSTEM_DEFAULT")) {
|
||||
if (0 != lt_dlforeachfile(mca_base_system_default_path,
|
||||
save_filename, NULL)) {
|
||||
if (0 != opal_dl_foreachfile(mca_base_system_default_path,
|
||||
save_filename, NULL)) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (0 != lt_dlforeachfile(dir, save_filename, NULL)) {
|
||||
if (0 != opal_dl_foreachfile(dir, save_filename, NULL)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -475,7 +462,7 @@ static void find_dyn_components(const char *path, const char *type_name,
|
||||
* Blindly save all filenames into an argv-style list. This function
|
||||
* is the callback from lt_dlforeachfile().
|
||||
*/
|
||||
static int save_filename(const char *filename, lt_ptr data)
|
||||
static int save_filename(const char *filename, void *data)
|
||||
{
|
||||
opal_argv_append_nosize(&found_filenames, filename);
|
||||
return 0;
|
||||
@ -508,9 +495,9 @@ static int file_exists(const char *filename, const char *ext)
|
||||
static int open_component(component_file_item_t *target_file,
|
||||
opal_list_t *found_components)
|
||||
{
|
||||
lt_dlhandle component_handle;
|
||||
opal_dl_handle_t *component_handle;
|
||||
mca_base_component_t *component_struct;
|
||||
char *struct_name, *err;
|
||||
char *struct_name;
|
||||
opal_list_t dependencies;
|
||||
opal_list_item_t *cur;
|
||||
mca_base_component_list_item_t *mitem;
|
||||
@ -562,18 +549,14 @@ static int open_component(component_file_item_t *target_file,
|
||||
|
||||
/* Now try to load the component */
|
||||
|
||||
#if OPAL_HAVE_LTDL_ADVISE
|
||||
component_handle = lt_dlopenadvise(target_file->filename, opal_mca_dladvise);
|
||||
#else
|
||||
component_handle = lt_dlopenext(target_file->filename);
|
||||
#endif
|
||||
if (NULL == component_handle) {
|
||||
/* Apparently lt_dlerror() sometimes returns NULL! */
|
||||
const char *str = lt_dlerror();
|
||||
if (NULL != str) {
|
||||
err = strdup(str);
|
||||
char *err_msg;
|
||||
if (OPAL_SUCCESS !=
|
||||
opal_dl_open(target_file->filename, true, false, &component_handle,
|
||||
&err_msg)) {
|
||||
if (NULL != err_msg) {
|
||||
err_msg = strdup(err_msg);
|
||||
} else {
|
||||
err = strdup("lt_dlerror() returned NULL!");
|
||||
err_msg = strdup("opal_dl_open() error message was NULL!");
|
||||
}
|
||||
/* Because libltdl erroneously says "file not found" for any
|
||||
type of error -- which is especially misleading when the file
|
||||
@ -581,17 +564,17 @@ static int open_component(component_file_item_t *target_file,
|
||||
(e.g., missing symbol) -- do some simple huersitics and if
|
||||
the file [probably] does exist, print a slightly better error
|
||||
message. */
|
||||
if (0 == strcmp("file not found", err) &&
|
||||
if (0 == strcmp("file not found", err_msg) &&
|
||||
(file_exists(target_file->filename, "lo") ||
|
||||
file_exists(target_file->filename, "so") ||
|
||||
file_exists(target_file->filename, "dylib") ||
|
||||
file_exists(target_file->filename, "dll"))) {
|
||||
free(err);
|
||||
err = strdup("perhaps a missing symbol, or compiled for a different version of Open MPI?");
|
||||
free(err_msg);
|
||||
err_msg = strdup("perhaps a missing symbol, or compiled for a different version of Open MPI?");
|
||||
}
|
||||
opal_output_verbose(vl, 0, "mca: base: component_find: unable to open %s: %s (ignored)",
|
||||
target_file->filename, err);
|
||||
free(err);
|
||||
target_file->filename, err_msg);
|
||||
free(err_msg);
|
||||
target_file->status = FAILED_TO_LOAD;
|
||||
free_dependency_list(&dependencies);
|
||||
return OPAL_ERR_BAD_PARAM;
|
||||
@ -603,7 +586,7 @@ static int open_component(component_file_item_t *target_file,
|
||||
len = strlen(target_file->type) + strlen(target_file->name) + 32;
|
||||
struct_name = (char*)malloc(len);
|
||||
if (NULL == struct_name) {
|
||||
lt_dlclose(component_handle);
|
||||
opal_dl_close(component_handle);
|
||||
target_file->status = FAILED_TO_LOAD;
|
||||
free_dependency_list(&dependencies);
|
||||
return OPAL_ERR_OUT_OF_RESOURCE;
|
||||
@ -614,25 +597,24 @@ static int open_component(component_file_item_t *target_file,
|
||||
mitem = OBJ_NEW(mca_base_component_list_item_t);
|
||||
if (NULL == mitem) {
|
||||
free(struct_name);
|
||||
lt_dlclose(component_handle);
|
||||
opal_dl_close(component_handle);
|
||||
target_file->status = FAILED_TO_LOAD;
|
||||
free_dependency_list(&dependencies);
|
||||
return OPAL_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
|
||||
component_struct = (mca_base_component_t*)lt_dlsym(component_handle, struct_name);
|
||||
if (NULL == component_struct) {
|
||||
/* Apparently lt_dlerror() sometimes returns NULL! */
|
||||
const char *str = lt_dlerror();
|
||||
if (NULL == str) {
|
||||
str = "lt_dlerror() returned NULL!";
|
||||
if (OPAL_SUCCESS != opal_dl_lookup(component_handle, struct_name,
|
||||
(void**) &component_struct, &err_msg) ||
|
||||
NULL == component_struct) {
|
||||
if (NULL == err_msg) {
|
||||
err_msg = "opal_dl_loookup() error message was NULL!";
|
||||
}
|
||||
opal_output_verbose(vl, 0, "mca: base: component_find: \"%s\" does not appear to be a valid "
|
||||
"%s MCA dynamic component (ignored): %s",
|
||||
target_file->basename, target_file->type, str);
|
||||
"%s MCA dynamic component (ignored): %s",
|
||||
target_file->basename, target_file->type, err_msg);
|
||||
free(mitem);
|
||||
free(struct_name);
|
||||
lt_dlclose(component_handle);
|
||||
opal_dl_close(component_handle);
|
||||
target_file->status = FAILED_TO_LOAD;
|
||||
free_dependency_list(&dependencies);
|
||||
return OPAL_ERR_BAD_PARAM;
|
||||
@ -652,7 +634,7 @@ static int open_component(component_file_item_t *target_file,
|
||||
MCA_BASE_VERSION_RELEASE);
|
||||
free(mitem);
|
||||
free(struct_name);
|
||||
lt_dlclose(component_handle);
|
||||
opal_dl_close(component_handle);
|
||||
target_file->status = FAILED_TO_LOAD;
|
||||
free_dependency_list(&dependencies);
|
||||
return OPAL_ERR_BAD_PARAM;
|
||||
@ -668,7 +650,7 @@ static int open_component(component_file_item_t *target_file,
|
||||
component_struct->mca_component_name);
|
||||
free(mitem);
|
||||
free(struct_name);
|
||||
lt_dlclose(component_handle);
|
||||
opal_dl_close(component_handle);
|
||||
target_file->status = FAILED_TO_LOAD;
|
||||
free_dependency_list(&dependencies);
|
||||
return OPAL_ERR_BAD_PARAM;
|
||||
@ -945,7 +927,7 @@ static void free_dependency_list(opal_list_t *dependencies)
|
||||
OBJ_DESTRUCT(dependencies);
|
||||
}
|
||||
|
||||
#endif /* OPAL_WANT_LIBLTDL */
|
||||
#endif /* OPAL_HAVE_DL_SUPPORT */
|
||||
|
||||
static bool use_component(const bool include_mode,
|
||||
const char **requested_component_names,
|
||||
|
@ -9,7 +9,7 @@
|
||||
* University of Stuttgart. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2008-2010 Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2015 Cisco Systems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -26,21 +26,14 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
#if OPAL_LIBLTDL_INTERNAL
|
||||
#include "opal/libltdl/ltdl.h"
|
||||
#else
|
||||
#include "ltdl.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "opal/class/opal_list.h"
|
||||
#include "opal/mca/mca.h"
|
||||
#include "opal/mca/base/base.h"
|
||||
#include "opal/mca/base/mca_base_component_repository.h"
|
||||
#include "opal/mca/dl/base/base.h"
|
||||
#include "opal/constants.h"
|
||||
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
#if OPAL_HAVE_DL_SUPPORT
|
||||
|
||||
/*
|
||||
* Private types
|
||||
@ -49,7 +42,7 @@ struct repository_item_t {
|
||||
opal_list_item_t super;
|
||||
|
||||
char ri_type[MCA_BASE_MAX_TYPE_NAME_LEN + 1];
|
||||
lt_dlhandle ri_dlhandle;
|
||||
opal_dl_handle_t *ri_dlhandle;
|
||||
const mca_base_component_t *ri_component_struct;
|
||||
opal_list_t ri_dependencies;
|
||||
};
|
||||
@ -70,7 +63,7 @@ static void di_destructor(opal_object_t *obj);
|
||||
static OBJ_CLASS_INSTANCE(dependency_item_t, opal_list_item_t,
|
||||
di_constructor, di_destructor);
|
||||
|
||||
#endif /* OPAL_WANT_LIBLTDL */
|
||||
#endif /* OPAL_HAVE_DL_SUPPORT */
|
||||
|
||||
|
||||
/*
|
||||
@ -79,7 +72,7 @@ static OBJ_CLASS_INSTANCE(dependency_item_t, opal_list_item_t,
|
||||
static bool initialized = false;
|
||||
|
||||
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
#if OPAL_HAVE_DL_SUPPORT
|
||||
|
||||
static opal_list_t repository;
|
||||
|
||||
@ -90,11 +83,7 @@ static opal_list_t repository;
|
||||
static repository_item_t *find_component(const char *type, const char *name);
|
||||
static int link_items(repository_item_t *src, repository_item_t *depend);
|
||||
|
||||
#if OPAL_HAVE_LTDL_ADVISE
|
||||
lt_dladvise opal_mca_dladvise;
|
||||
#endif
|
||||
|
||||
#endif /* OPAL_WANT_LIBLTDL */
|
||||
#endif /* OPAL_HAVE_DL_SUPPORT */
|
||||
|
||||
|
||||
/*
|
||||
@ -105,29 +94,30 @@ int mca_base_component_repository_init(void)
|
||||
/* Setup internal structures */
|
||||
|
||||
if (!initialized) {
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
/* Initialize libltdl */
|
||||
#if OPAL_HAVE_DL_SUPPORT
|
||||
|
||||
if (lt_dlinit() != 0) {
|
||||
return OPAL_ERR_OUT_OF_RESOURCE;
|
||||
/* Initialize the dl framework */
|
||||
int ret = mca_base_framework_open(&opal_dl_base_framework, 0);
|
||||
if (OPAL_SUCCESS != ret) {
|
||||
opal_output(0, "%s %d:%s failed -- process will likely abort (open the dl framework returned %d instead of OPAL_SUCCESS)\n",
|
||||
__FILE__, __LINE__, __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
opal_dl_base_select();
|
||||
|
||||
#if OPAL_HAVE_LTDL_ADVISE
|
||||
if (lt_dladvise_init(&opal_mca_dladvise)) {
|
||||
return OPAL_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
|
||||
if (lt_dladvise_ext(&opal_mca_dladvise)) {
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
|
||||
if (lt_dladvise_global(&opal_mca_dladvise)) {
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
#endif
|
||||
/* Bump the refcount to indicate that this framework is "special"
|
||||
-- it can't be finalized until all other frameworks have been
|
||||
finalized. E.g., in opal/runtime/opal_info_support.c, there's
|
||||
a loop calling mca_base_framework_close() on all OPAL
|
||||
frameworks. But that function simply decrements each
|
||||
framework's refcount, and if it's zero, closes it. This
|
||||
additional increment ensures that the "dl" framework is not
|
||||
closed as part of that loop. */
|
||||
++opal_dl_base_framework.framework_refcnt;
|
||||
|
||||
OBJ_CONSTRUCT(&repository, opal_list_t);
|
||||
#endif
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
@ -143,10 +133,10 @@ int mca_base_component_repository_init(void)
|
||||
* saved.
|
||||
*/
|
||||
int mca_base_component_repository_retain(char *type,
|
||||
lt_dlhandle component_handle,
|
||||
opal_dl_handle_t *component_handle,
|
||||
const mca_base_component_t *component_struct)
|
||||
{
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
#if OPAL_HAVE_DL_SUPPORT
|
||||
repository_item_t *ri;
|
||||
|
||||
/* Allocate a new repository item */
|
||||
@ -182,7 +172,7 @@ int mca_base_component_repository_retain(char *type,
|
||||
int mca_base_component_repository_retain_component(const char *type,
|
||||
const char *name)
|
||||
{
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
#if OPAL_HAVE_DL_SUPPORT
|
||||
repository_item_t *ri = find_component(type, name);
|
||||
if (NULL != ri) {
|
||||
OBJ_RETAIN(ri);
|
||||
@ -203,7 +193,7 @@ int mca_base_component_repository_link(const char *src_type,
|
||||
const char *depend_type,
|
||||
const char *depend_name)
|
||||
{
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
#if OPAL_HAVE_DL_SUPPORT
|
||||
repository_item_t *src, *depend;
|
||||
|
||||
/* Look up the two components */
|
||||
@ -232,7 +222,7 @@ int mca_base_component_repository_link(const char *src_type,
|
||||
*/
|
||||
void mca_base_component_repository_release(const mca_base_component_t *component)
|
||||
{
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
#if OPAL_HAVE_DL_SUPPORT
|
||||
if (initialized) {
|
||||
repository_item_t *ri = find_component(component->mca_type_name,
|
||||
component->mca_component_name);
|
||||
@ -249,12 +239,12 @@ void mca_base_component_repository_release(const mca_base_component_t *component
|
||||
*/
|
||||
void mca_base_component_repository_finalize(void)
|
||||
{
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
#if OPAL_HAVE_DL_SUPPORT
|
||||
repository_item_t *ri, *next;
|
||||
#endif
|
||||
|
||||
if (initialized) {
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
#if OPAL_HAVE_DL_SUPPORT
|
||||
|
||||
/* Have to be slightly careful about this because of dependencies,
|
||||
particularly on OS's where it matters (i.e., closing a
|
||||
@ -275,22 +265,17 @@ void mca_base_component_repository_finalize(void)
|
||||
}
|
||||
} while (opal_list_get_size(&repository) > 0);
|
||||
|
||||
#if OPAL_HAVE_LTDL_ADVISE
|
||||
if (lt_dladvise_destroy(&opal_mca_dladvise)) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Close down libltdl */
|
||||
|
||||
lt_dlexit();
|
||||
/* Close the dl framework (see comment about refcnt in
|
||||
mca_base_component_repository_init()) */
|
||||
--opal_dl_base_framework.framework_refcnt;
|
||||
(void) mca_base_framework_close(&opal_dl_base_framework);
|
||||
#endif
|
||||
|
||||
initialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
#if OPAL_HAVE_DL_SUPPORT
|
||||
|
||||
static repository_item_t *find_component(const char *type, const char *name)
|
||||
{
|
||||
@ -379,7 +364,7 @@ static void ri_destructor(opal_object_t *obj)
|
||||
}
|
||||
|
||||
/* Close the component (and potentially unload it from memory */
|
||||
lt_dlclose(ri->ri_dlhandle);
|
||||
opal_dl_close(ri->ri_dlhandle);
|
||||
|
||||
/* It should be obvious, but I'll state it anyway because it bit me
|
||||
during debugging: after the dlclose(), the mca_base_component_t
|
||||
@ -419,4 +404,4 @@ static void di_destructor(opal_object_t *obj)
|
||||
OBJ_RELEASE(di->di_repository_entry);
|
||||
}
|
||||
|
||||
#endif /* OPAL_WANT_LIBLTDL */
|
||||
#endif /* OPAL_HAVE_DL_SUPPORT */
|
||||
|
@ -9,6 +9,7 @@
|
||||
* University of Stuttgart. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -21,6 +22,9 @@
|
||||
|
||||
#include "opal_config.h"
|
||||
|
||||
#include "opal/mca/dl/dl.h"
|
||||
#include "opal/mca/dl/base/base.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
OPAL_DECLSPEC int mca_base_component_repository_init(void);
|
||||
@ -33,37 +37,9 @@ BEGIN_C_DECLS
|
||||
* the functions exported from one header file rather than to separate
|
||||
* retain_component() and retain() into two separate header files
|
||||
* (i.e., have a separate header file just for retain()).
|
||||
*
|
||||
* Note that internal to opal/mca/base, <ltdl.h> will *always* be
|
||||
* included before this file, and <ltdl.h> is not included anywhere
|
||||
* else in the OMPI tree. So checking for the LTDL_H preprocessor
|
||||
* macro is a good indicator as to whether this file is being included
|
||||
* from an opal/mca/base source file or not. If we are, then we need
|
||||
* already have a real definition of lt_dlhandle. If we are being
|
||||
* included from elsewhere, then <ltdl.h> will not previously have
|
||||
* been included, LTDL_H will not be defined, and we need a fake
|
||||
* definition of lt_dlhandle (or we'll get compile errors). So just
|
||||
* typedef it to (void*).
|
||||
*
|
||||
* One more case that this handles is the --disable-dlopen case. In
|
||||
* that case, even in opal/mca/base, we *won't* be including <ltdl.h>.
|
||||
* Hence, LTDL_H won't be defined, so we'll end up typedefing
|
||||
* lt_dlhandle to (void *). "But why does that matter?" you ask, "If
|
||||
* we configure with --disable-dlopen, then lt_dlhandle shouldn't be
|
||||
* used anywhere." Incorrect, Grasshopper. A small number of places
|
||||
* (like the retain() function) are still prototyped, but have 99% of
|
||||
* their innards #if'ed out -- i.e., they just return
|
||||
* OPAL_ERR_NOT_SUPPORTED. Why was it coded up this way? I'm not
|
||||
* entirely sure -- there may be a reason (and that reason may just be
|
||||
* conservative coding), but I'm not really too inspired to look into
|
||||
* it any further at this point. :-)
|
||||
*/
|
||||
#if !defined(LTDL_H)
|
||||
typedef void *lt_dlhandle;
|
||||
#endif
|
||||
|
||||
OPAL_DECLSPEC int mca_base_component_repository_retain(char *type,
|
||||
lt_dlhandle component_handle,
|
||||
opal_dl_handle_t *component_handle,
|
||||
const mca_base_component_t *component_struct);
|
||||
|
||||
OPAL_DECLSPEC int mca_base_component_repository_retain_component(const char *type,
|
||||
|
@ -10,6 +10,7 @@
|
||||
* Copyright (c) 2004-2006 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2011-2015 NVIDIA Corporation. All rights reserved.
|
||||
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -33,13 +34,13 @@
|
||||
#include "opal/datatype/opal_convertor.h"
|
||||
#include "opal/datatype/opal_datatype_cuda.h"
|
||||
#include "opal/util/output.h"
|
||||
#include "opal/util/lt_interface.h"
|
||||
#include "opal/util/show_help.h"
|
||||
#include "opal/util/proc.h"
|
||||
|
||||
#include "opal/mca/mpool/base/base.h"
|
||||
#include "opal/runtime/opal_params.h"
|
||||
#include "opal/mca/timer/base/base.h"
|
||||
#include "opal/mca/dl/base/base.h"
|
||||
|
||||
#include "common_cuda.h"
|
||||
|
||||
@ -55,12 +56,15 @@
|
||||
|
||||
#define OPAL_CUDA_DLSYM(libhandle, funcName) \
|
||||
do { \
|
||||
*(void **)(&cuFunc.funcName) = opal_lt_dlsym(libhandle, STRINGIFY(funcName)); \
|
||||
if (NULL == cuFunc.funcName) { \
|
||||
char *err_msg; \
|
||||
void *ptr; \
|
||||
if (OPAL_SUCCESS != \
|
||||
opal_dl_lookup(libhandle, STRINGIFY(funcName), &ptr, &err_msg)) { \
|
||||
opal_show_help("help-mpi-common-cuda.txt", "dlsym failed", true, \
|
||||
STRINGIFY(funcName), opal_lt_dlerror()); \
|
||||
STRINGIFY(funcName), err_msg); \
|
||||
return 1; \
|
||||
} else { \
|
||||
*(void **)(&cuFunc.funcName) = ptr; \
|
||||
opal_output_verbose(15, mca_common_cuda_output, \
|
||||
"CUDA: successful dlsym of %s", \
|
||||
STRINGIFY(funcName)); \
|
||||
@ -185,7 +189,7 @@ static int cuda_event_dtoh_most = 0;
|
||||
static int cuda_event_htod_most = 0;
|
||||
|
||||
/* Handle to libcuda.so */
|
||||
opal_lt_dlhandle libcuda_handle = NULL;
|
||||
opal_dl_handle_t *libcuda_handle = NULL;
|
||||
|
||||
/* Unused variable that we register at init time and unregister at fini time.
|
||||
* This is used to detect if user has done a device reset prior to MPI_Finalize.
|
||||
@ -233,9 +237,7 @@ static void cuda_dump_memhandle(int, void *, char *) __opal_attribute_unused__ ;
|
||||
*/
|
||||
int mca_common_cuda_stage_one_init(void)
|
||||
{
|
||||
opal_lt_dladvise advise;
|
||||
int retval, i, j;
|
||||
int advise_support = 1;
|
||||
char *cudalibs[] = {"libcuda.so.1", "libcuda.dylib", NULL};
|
||||
char *searchpaths[] = {"", "/usr/lib64", NULL};
|
||||
char **errmsgs = NULL;
|
||||
@ -339,120 +341,76 @@ int mca_common_cuda_stage_one_init(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != (retval = opal_lt_dlinit())) {
|
||||
if (OPAL_ERR_NOT_SUPPORTED == retval) {
|
||||
opal_show_help("help-mpi-common-cuda.txt", "dlopen disabled", true);
|
||||
} else {
|
||||
opal_show_help("help-mpi-common-cuda.txt", "unknown ltdl error", true,
|
||||
"opal_lt_dlinit", retval, opal_lt_dlerror());
|
||||
}
|
||||
if (!OPAL_HAVE_DL_SUPPORT) {
|
||||
opal_show_help("help-mpi-common-cuda.txt", "dlopen disabled", true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Initialize the lt_dladvise structure. If this does not work, we can
|
||||
* proceed without the support. Things should still work. */
|
||||
if (0 != (retval = opal_lt_dladvise_init(&advise))) {
|
||||
if (OPAL_ERR_NOT_SUPPORTED == retval) {
|
||||
advise_support = 0;
|
||||
} else {
|
||||
opal_show_help("help-mpi-common-cuda.txt", "unknown ltdl error", true,
|
||||
"opal_lt_dladvise_init", retval, opal_lt_dlerror());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Now walk through all the potential names libcuda and find one
|
||||
* that works. If it does, all is good. If not, print out all
|
||||
* the messages about why things failed. This code was careful
|
||||
* to try and save away all error messages if the loading ultimately
|
||||
* failed to help with debugging.
|
||||
* failed to help with debugging.
|
||||
*
|
||||
* NOTE: On the first loop we just utilize the default loading
|
||||
* paths from the system. For the second loop, set /usr/lib64 to
|
||||
* the search path and try again. This is done to handle the case
|
||||
* where we have both 32 and 64 bit libcuda.so libraries installed.
|
||||
* Even when running in 64-bit mode, the /usr/lib directory
|
||||
* is searched first and we may find a 32-bit libcuda.so.1 library.
|
||||
* Loading of this library will fail as libtool does not handle having
|
||||
* the wrong ABI in the search path (unlike ld or ld.so). Note that
|
||||
* we only set this search path after the original search. This is
|
||||
* so that LD_LIBRARY_PATH and run path settings are respected.
|
||||
* Setting this search path overrides them (rather then being appended). */
|
||||
if (advise_support) {
|
||||
if (0 != (retval = opal_lt_dladvise_global(&advise))) {
|
||||
opal_show_help("help-mpi-common-cuda.txt", "unknown ltdl error", true,
|
||||
"opal_lt_dladvise_global", retval, opal_lt_dlerror());
|
||||
opal_lt_dladvise_destroy(&advise);
|
||||
return 1;
|
||||
}
|
||||
j = 0;
|
||||
while (searchpaths[j] != NULL) {
|
||||
/* Set explicit search path if entry is not empty string */
|
||||
if (strcmp("", searchpaths[j])) {
|
||||
opal_lt_dlsetsearchpath(searchpaths[j]);
|
||||
}
|
||||
i = 0;
|
||||
while (cudalibs[i] != NULL) {
|
||||
const char *str;
|
||||
libcuda_handle = opal_lt_dlopenadvise(cudalibs[i], advise);
|
||||
if (NULL == libcuda_handle) {
|
||||
str = opal_lt_dlerror();
|
||||
if (NULL != str) {
|
||||
opal_argv_append(&errsize, &errmsgs, str);
|
||||
} else {
|
||||
opal_argv_append(&errsize, &errmsgs, "lt_dlerror() returned NULL.");
|
||||
}
|
||||
opal_output_verbose(10, mca_common_cuda_output,
|
||||
"CUDA: Library open error: %s",
|
||||
errmsgs[errsize-1]);
|
||||
} else {
|
||||
opal_output_verbose(10, mca_common_cuda_output,
|
||||
"CUDA: Library successfully opened %s",
|
||||
cudalibs[i]);
|
||||
stage_one_init_passed = true;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (true == stage_one_init_passed) break; /* Break out of outer loop */
|
||||
j++;
|
||||
}
|
||||
opal_lt_dladvise_destroy(&advise);
|
||||
} else {
|
||||
j = 0;
|
||||
/* No lt_dladvise support. This should rarely happen. */
|
||||
while (searchpaths[j] != NULL) {
|
||||
/* Set explicit search path if entry is not empty string */
|
||||
if (strcmp("", searchpaths[j])) {
|
||||
opal_lt_dlsetsearchpath(searchpaths[j]);
|
||||
}
|
||||
i = 0;
|
||||
while (cudalibs[i] != NULL) {
|
||||
const char *str;
|
||||
libcuda_handle = opal_lt_dlopen(cudalibs[i]);
|
||||
if (NULL == libcuda_handle) {
|
||||
str = opal_lt_dlerror();
|
||||
if (NULL != str) {
|
||||
opal_argv_append(&errsize, &errmsgs, str);
|
||||
} else {
|
||||
opal_argv_append(&errsize, &errmsgs, "lt_dlerror() returned NULL.");
|
||||
}
|
||||
* where we have both 32 and 64 bit libcuda.so libraries
|
||||
* installed. Even when running in 64-bit mode, the /usr/lib
|
||||
* directory is searched first and we may find a 32-bit
|
||||
* libcuda.so.1 library. Loading of this library will fail as the
|
||||
* OPAL DL framework does not handle having the wrong ABI in the
|
||||
* search path (unlike ld or ld.so). Note that we only set this
|
||||
* search path after the original search. This is so that
|
||||
* LD_LIBRARY_PATH and run path settings are respected. Setting
|
||||
* this search path overrides them (rather then being
|
||||
* appended). */
|
||||
j = 0;
|
||||
while (searchpaths[j] != NULL) {
|
||||
while (cudalibs[i] != NULL) {
|
||||
char *filename;
|
||||
char *str;
|
||||
|
||||
opal_output_verbose(10, mca_common_cuda_output,
|
||||
"CUDA: Library open error: %s",
|
||||
errmsgs[errsize-1]);
|
||||
|
||||
} else {
|
||||
opal_output_verbose(10, mca_common_cuda_output,
|
||||
"CUDA: Library successfully opened %s",
|
||||
cudalibs[i]);
|
||||
stage_one_init_passed = true;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
/* If there's a non-empty search path, prepend it
|
||||
to the library filename */
|
||||
if (strlen(searchpaths[j]) > 0) {
|
||||
asprintf(&filename, "%s/%s", searchpaths[j], cudalibs[i]);
|
||||
} else {
|
||||
filename = strdup(cudalibs[i]);
|
||||
}
|
||||
if (true == stage_one_init_passed) break; /* Break out of outer loop */
|
||||
j++;
|
||||
if (NULL == filename) {
|
||||
opal_show_help("help-mpi-common-cuda.txt", "No memory",
|
||||
true, OPAL_PROC_MY_HOSTNAME);
|
||||
return 1;
|
||||
}
|
||||
|
||||
retval = opal_dl_open(filename, false, false,
|
||||
&libcuda_handle, &str);
|
||||
if (OPAL_SUCCESS != retval || NULL == libcuda_handle) {
|
||||
if (NULL != str) {
|
||||
opal_argv_append(&errsize, &errmsgs, str);
|
||||
} else {
|
||||
opal_argv_append(&errsize, &errmsgs,
|
||||
"opal_dl_open() returned NULL.");
|
||||
}
|
||||
opal_output_verbose(10, mca_common_cuda_output,
|
||||
"CUDA: Library open error: %s",
|
||||
errmsgs[errsize-1]);
|
||||
} else {
|
||||
opal_output_verbose(10, mca_common_cuda_output,
|
||||
"CUDA: Library successfully opened %s",
|
||||
cudalibs[i]);
|
||||
stage_one_init_passed = true;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
|
||||
free(filename);
|
||||
}
|
||||
if (true == stage_one_init_passed) {
|
||||
break; /* Break out of outer loop */
|
||||
}
|
||||
j++;
|
||||
}
|
||||
|
||||
if (true != stage_one_init_passed) {
|
||||
@ -916,8 +874,7 @@ void mca_common_cuda_fini(void)
|
||||
OBJ_DESTRUCT(&common_cuda_dtoh_lock);
|
||||
OBJ_DESTRUCT(&common_cuda_ipc_lock);
|
||||
if (NULL != libcuda_handle) {
|
||||
opal_lt_dlclose(libcuda_handle);
|
||||
opal_lt_dlexit();
|
||||
opal_dl_close(libcuda_handle);
|
||||
}
|
||||
|
||||
opal_output_verbose(20, mca_common_cuda_output,
|
||||
|
@ -1,10 +1,11 @@
|
||||
# -*- text -*-
|
||||
#
|
||||
# Copyright (c) 2011-2015 NVIDIA. All rights reserved.
|
||||
# Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
|
||||
# $COPYRIGHT$
|
||||
#
|
||||
#
|
||||
# Additional copyrights may follow
|
||||
#
|
||||
#
|
||||
# $HEADER$
|
||||
#
|
||||
[cuCtxGetCurrent failed not initialized]
|
||||
@ -152,14 +153,6 @@ Open MPI was compiled without dynamic library support (e.g., with the
|
||||
|
||||
If you need CUDA support, reconfigure Open MPI with dynamic library support enabled.
|
||||
#
|
||||
[unknown ltdl error]
|
||||
While attempting to load the supporting libcuda.so library, an error
|
||||
occurred. This really should rarely happen. Please notify the Open
|
||||
MPI developers.
|
||||
Function: %s
|
||||
Return Value: %d
|
||||
Error string: %s
|
||||
#
|
||||
[dlopen failed]
|
||||
The library attempted to open the following supporting CUDA libraries,
|
||||
but each of them failed. CUDA-aware support is disabled.
|
||||
|
36
opal/mca/dl/Makefile.am
Обычный файл
36
opal/mca/dl/Makefile.am
Обычный файл
@ -0,0 +1,36 @@
|
||||
#
|
||||
# Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana
|
||||
# University Research and Technology
|
||||
# Corporation. All rights reserved.
|
||||
# Copyright (c) 2010-2015 Cisco Systems, Inc. All rights reserved.
|
||||
# $COPYRIGHT$
|
||||
#
|
||||
# Additional copyrights may follow
|
||||
#
|
||||
# $HEADER$
|
||||
#
|
||||
|
||||
# main library setup
|
||||
noinst_LTLIBRARIES = libmca_dl.la
|
||||
libmca_dl_la_SOURCES =
|
||||
|
||||
# local files
|
||||
headers = dl.h
|
||||
libmca_dl_la_SOURCES += $(headers)
|
||||
|
||||
# Ensure that the man pages are rebuilt if the opal_config.h file
|
||||
# changes; a "good enough" way to know if configure was run again (and
|
||||
# therefore the release date or version may have changed)
|
||||
$(nodist_man_MANS): $(top_builddir)/opal/include/opal_config.h
|
||||
|
||||
# Conditionally install the header files
|
||||
if WANT_INSTALL_HEADERS
|
||||
opaldir = $(opalincludedir)/$(subdir)
|
||||
nobase_opal_HEADERS = $(headers)
|
||||
endif
|
||||
|
||||
include base/Makefile.am
|
||||
|
||||
distclean-local:
|
||||
rm -f base/static-components.h
|
||||
rm -f $(nodist_man_MANS)
|
17
opal/mca/dl/base/Makefile.am
Обычный файл
17
opal/mca/dl/base/Makefile.am
Обычный файл
@ -0,0 +1,17 @@
|
||||
#
|
||||
# Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
|
||||
# $COPYRIGHT$
|
||||
#
|
||||
# Additional copyrights may follow
|
||||
#
|
||||
# $HEADER$
|
||||
#
|
||||
|
||||
headers += \
|
||||
base/base.h
|
||||
|
||||
libmca_dl_la_SOURCES += \
|
||||
base/dl_base_open.c \
|
||||
base/dl_base_close.c \
|
||||
base/dl_base_select.c \
|
||||
base/dl_base_fns.c
|
106
opal/mca/dl/base/base.h
Обычный файл
106
opal/mca/dl/base/base.h
Обычный файл
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana
|
||||
* University Research and Technology
|
||||
* Corporation. All rights reserved.
|
||||
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#ifndef OPAL_DL_BASE_H
|
||||
#define OPAL_DL_BASE_H
|
||||
|
||||
#include "opal_config.h"
|
||||
#include "opal/mca/dl/dl.h"
|
||||
#include "opal/util/opal_environ.h"
|
||||
#include "opal/runtime/opal_cr.h"
|
||||
|
||||
#include "opal/mca/base/base.h"
|
||||
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
/**
|
||||
* Globals
|
||||
*/
|
||||
OPAL_DECLSPEC extern mca_base_framework_t opal_dl_base_framework;
|
||||
OPAL_DECLSPEC extern opal_dl_base_component_t
|
||||
*opal_dl_base_selected_component;
|
||||
OPAL_DECLSPEC extern opal_dl_base_module_t *opal_dl;
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the DL MCA framework
|
||||
*
|
||||
* @retval OPAL_SUCCESS Upon success
|
||||
* @retval OPAL_ERROR Upon failures
|
||||
*
|
||||
* This function is invoked during opal_init();
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_dl_base_open(mca_base_open_flag_t flags);
|
||||
|
||||
/**
|
||||
* Select an available component.
|
||||
*
|
||||
* @retval OPAL_SUCCESS Upon Success
|
||||
* @retval OPAL_NOT_FOUND If no component can be selected
|
||||
* @retval OPAL_ERROR Upon other failure
|
||||
*
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_dl_base_select(void);
|
||||
|
||||
/**
|
||||
* Finalize the DL MCA framework
|
||||
*
|
||||
* @retval OPAL_SUCCESS Upon success
|
||||
* @retval OPAL_ERROR Upon failures
|
||||
*
|
||||
* This function is invoked during opal_finalize();
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_dl_base_close(void);
|
||||
|
||||
/**
|
||||
* Open a DSO
|
||||
*
|
||||
* (see opal_dl_base_module_open_ft_t in opal/mca/dl/dl.h for
|
||||
* documentation of this function)
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_dl_open(const char *fname,
|
||||
bool use_ext, bool private_namespace,
|
||||
opal_dl_handle_t **handle, char **err_msg);
|
||||
|
||||
/**
|
||||
* Lookup a symbol in a DSO
|
||||
*
|
||||
* (see opal_dl_base_module_lookup_ft_t in opal/mca/dl/dl.h for
|
||||
* documentation of this function)
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_dl_lookup(opal_dl_handle_t *handle,
|
||||
const char *symbol,
|
||||
void **ptr, char **err_msg);
|
||||
|
||||
/**
|
||||
* Close a DSO
|
||||
*
|
||||
* (see opal_dl_base_module_close_ft_t in opal/mca/dl/dl.h for
|
||||
* documentation of this function)
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_dl_close(opal_dl_handle_t *handle);
|
||||
|
||||
/**
|
||||
* Iterate over files in a path
|
||||
*
|
||||
* (see opal_dl_base_module_foreachfile_ft_t in opal/mca/dl/dl.h for
|
||||
* documentation of this function)
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_dl_foreachfile(const char *search_path,
|
||||
int (*cb_func)(const char *filename,
|
||||
void *context),
|
||||
void *context);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /* OPAL_DL_BASE_H */
|
25
opal/mca/dl/base/dl_base_close.c
Обычный файл
25
opal/mca/dl/base/dl_base_close.c
Обычный файл
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2010 The Trustees of Indiana University.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#include "opal_config.h"
|
||||
|
||||
#include "opal/mca/mca.h"
|
||||
#include "opal/mca/base/base.h"
|
||||
|
||||
#include "opal/mca/dl/dl.h"
|
||||
#include "opal/mca/dl/base/base.h"
|
||||
|
||||
|
||||
int opal_dl_base_close(void)
|
||||
{
|
||||
/* Close all available modules that are open */
|
||||
return mca_base_framework_components_close(&opal_dl_base_framework, NULL);
|
||||
}
|
68
opal/mca/dl/base/dl_base_fns.c
Обычный файл
68
opal/mca/dl/base/dl_base_fns.c
Обычный файл
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2010 The Trustees of Indiana University.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file is a simple set of wrappers around the selected OPAL DL
|
||||
* component (it's a compile-time framework with, at most, a single
|
||||
* component; see dl.h for details).
|
||||
*/
|
||||
|
||||
#include "opal_config.h"
|
||||
|
||||
#include "opal/include/opal/constants.h"
|
||||
|
||||
#include "opal/mca/dl/base/base.h"
|
||||
|
||||
|
||||
int opal_dl_open(const char *fname,
|
||||
bool use_ext, bool private_namespace,
|
||||
opal_dl_handle_t **handle, char **err_msg)
|
||||
{
|
||||
*handle = NULL;
|
||||
|
||||
if (NULL != opal_dl && NULL != opal_dl->open) {
|
||||
return opal_dl->open(fname, use_ext, private_namespace,
|
||||
handle, err_msg);
|
||||
}
|
||||
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
int opal_dl_lookup(opal_dl_handle_t *handle,
|
||||
const char *symbol,
|
||||
void **ptr, char **err_msg)
|
||||
{
|
||||
if (NULL != opal_dl && NULL != opal_dl->lookup) {
|
||||
return opal_dl->lookup(handle, symbol, ptr, err_msg);
|
||||
}
|
||||
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
int opal_dl_close(opal_dl_handle_t *handle)
|
||||
{
|
||||
if (NULL != opal_dl && NULL != opal_dl->close) {
|
||||
return opal_dl->close(handle);
|
||||
}
|
||||
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
int opal_dl_foreachfile(const char *search_path,
|
||||
int (*cb_func)(const char *filename, void *context),
|
||||
void *context)
|
||||
{
|
||||
if (NULL != opal_dl && NULL != opal_dl->foreachfile) {
|
||||
return opal_dl->foreachfile(search_path, cb_func, context);
|
||||
}
|
||||
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
}
|
54
opal/mca/dl/base/dl_base_open.c
Обычный файл
54
opal/mca/dl/base/dl_base_open.c
Обычный файл
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2010 The Trustees of Indiana University.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2011-2013 Los Alamos National Security, LLC.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#include "opal_config.h"
|
||||
|
||||
#include "opal/mca/dl/base/base.h"
|
||||
|
||||
#include "opal/mca/dl/base/static-components.h"
|
||||
|
||||
|
||||
/*
|
||||
* Globals
|
||||
*/
|
||||
opal_dl_base_module_t *opal_dl = NULL;
|
||||
opal_dl_base_component_t *opal_dl_base_selected_component = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* Function for finding and opening either all MCA components,
|
||||
* or the one that was specifically requested via a MCA parameter.
|
||||
*
|
||||
* Note that we really don't need this function -- we could specify a
|
||||
* NULL pointer in the framework declare and the base would do this
|
||||
* exact same thing. However, we need to have at least some
|
||||
* executable code in this file, or some linkers (cough cough OS X
|
||||
* cough cough) may not actually link in this .o file.
|
||||
*/
|
||||
int opal_dl_base_open(mca_base_open_flag_t flags)
|
||||
{
|
||||
/* Open up all available components */
|
||||
return mca_base_framework_components_open(&opal_dl_base_framework, flags);
|
||||
}
|
||||
|
||||
/* VERY IMPORTANT: This framework is static, and is opened before any
|
||||
other dyanmic frameworks are opened (which makes sense, of course).
|
||||
But we must mark this framework is NO_DSO so that the MCA framework
|
||||
base doesn't try to open any dynamic components in this
|
||||
framework. */
|
||||
MCA_BASE_FRAMEWORK_DECLARE(opal, dl, "Dynamic loader framework",
|
||||
NULL /* register */,
|
||||
opal_dl_base_open /* open */,
|
||||
NULL /* close */,
|
||||
mca_dl_base_static_components,
|
||||
MCA_BASE_FRAMEWORK_FLAG_NO_DSO);
|
52
opal/mca/dl/base/dl_base_select.c
Обычный файл
52
opal/mca/dl/base/dl_base_select.c
Обычный файл
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2010 The Trustees of Indiana University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#include "opal_config.h"
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include "unistd.h"
|
||||
#endif
|
||||
|
||||
#include "opal/include/opal/constants.h"
|
||||
#include "opal/util/output.h"
|
||||
#include "opal/mca/mca.h"
|
||||
#include "opal/mca/base/base.h"
|
||||
#include "opal/mca/dl/dl.h"
|
||||
#include "opal/mca/dl/base/base.h"
|
||||
|
||||
|
||||
int opal_dl_base_select(void)
|
||||
{
|
||||
int exit_status = OPAL_SUCCESS;
|
||||
opal_dl_base_component_t *best_component = NULL;
|
||||
opal_dl_base_module_t *best_module = NULL;
|
||||
|
||||
/*
|
||||
* Select the best component
|
||||
*/
|
||||
if (OPAL_SUCCESS != mca_base_select("dl",
|
||||
opal_dl_base_framework.framework_output,
|
||||
&opal_dl_base_framework.framework_components,
|
||||
(mca_base_module_t **) &best_module,
|
||||
(mca_base_component_t **) &best_component) ) {
|
||||
/* This will only happen if no component was selected */
|
||||
exit_status = OPAL_ERROR;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Save the winner */
|
||||
opal_dl_base_selected_component = best_component;
|
||||
opal_dl = best_module;
|
||||
|
||||
cleanup:
|
||||
return exit_status;
|
||||
}
|
77
opal/mca/dl/configure.m4
Обычный файл
77
opal/mca/dl/configure.m4
Обычный файл
@ -0,0 +1,77 @@
|
||||
dnl -*- shell-script -*-
|
||||
dnl
|
||||
dnl Copyright (c) 2010-2015 Cisco Systems, Inc. All rights reserved.
|
||||
dnl $COPYRIGHT$
|
||||
dnl
|
||||
dnl Additional copyrights may follow
|
||||
dnl
|
||||
dnl $HEADER$
|
||||
dnl
|
||||
|
||||
dnl There will only be one component used in this framework, and it will
|
||||
dnl be selected at configure time by priority. Components must set
|
||||
dnl their priorities in their configure.m4 file.
|
||||
|
||||
dnl We only want one winning component (vs. STOP_AT_FIRST_PRIORITY,
|
||||
dnl which will allow all components of the same priority who succeed to
|
||||
dnl win)
|
||||
m4_define(MCA_opal_dl_CONFIGURE_MODE, STOP_AT_FIRST)
|
||||
|
||||
AC_DEFUN([MCA_opal_dl_CONFIG],[
|
||||
OPAL_HAVE_DL_SUPPORT=0
|
||||
|
||||
# If --disable-dlopen was used, then have all the components fail
|
||||
# (we still need to configure them all so that things like "make
|
||||
# dist" work", but we just want the MCA system to (artificially)
|
||||
# conclude that it can't build any of the components.
|
||||
AS_IF([test "$enable_dlopen" = "no"],
|
||||
[want_dl=0], [want_dl=1])
|
||||
|
||||
MCA_CONFIGURE_FRAMEWORK([opal], [dl], [$want_dl])
|
||||
|
||||
# If we found no suitable static dl component and dlopen support
|
||||
# was not specifically disabled, this is an error.
|
||||
AS_IF([test "$MCA_opal_dl_STATIC_COMPONENTS" = "" && \
|
||||
test "$enable_dlopen" != "no"],
|
||||
[AC_MSG_WARN([Did not find a suitable static opal dl component])
|
||||
AC_MSG_WARN([You might need to install libltld (and its headers) or])
|
||||
AC_MSG_WARN([specify --disable-dlopen to configure.])
|
||||
AC_MSG_ERROR([Cannot continue])])
|
||||
|
||||
# If we have a winning component (which, per above, will only
|
||||
# happen if --disable-dlopen was *not* specified), do some more
|
||||
# logic.
|
||||
AS_IF([test "$MCA_opal_dl_STATIC_COMPONENTS" != ""],
|
||||
[ # We had a winner -- w00t!
|
||||
|
||||
OPAL_HAVE_DL_SUPPORT=1
|
||||
# If we added any -L flags to ADD_LDFLAGS, then we (might)
|
||||
# need to add those directories to LD_LIBRARY_PATH.
|
||||
# Otherwise, if we try to AC RUN_IFELSE anything here in
|
||||
# configure, it might die because it can't find the libraries
|
||||
# we just linked against.
|
||||
OPAL_VAR_SCOPE_PUSH([opal_dl_base_found_l opal_dl_base_token opal_dl_base_tmp opal_dl_base_dir])
|
||||
opal_dl_base_found_l=0
|
||||
eval "opal_dl_base_tmp=\$opal_dl_${opal_dl_winner}_ADD_LIBS"
|
||||
for opal_dl_base_token in $opal_dl_base_tmp; do
|
||||
case $opal_dl_base_token in
|
||||
-l*) opal_dl_base_found_l=1 ;;
|
||||
esac
|
||||
done
|
||||
AS_IF([test $opal_dl_base_found_l -eq 1],
|
||||
[eval "opal_dl_base_tmp=\$opal_dl_${opal_dl_winner}_ADD_LDFLAGS"
|
||||
for opal_dl_base_token in $opal_dl_base_tmp; do
|
||||
case $opal_dl_base_token in
|
||||
-L*)
|
||||
opal_dl_base_dir=`echo $opal_dl_base_token | cut -c3-`
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$opal_dl_base_dir
|
||||
AC_MSG_WARN([Adding to LD_LIBRARY_PATH: $opal_dl_base_dir])
|
||||
;;
|
||||
esac
|
||||
done])
|
||||
OPAL_VAR_SCOPE_POP
|
||||
])
|
||||
|
||||
AC_DEFINE_UNQUOTED([OPAL_HAVE_DL_SUPPORT], [$OPAL_HAVE_DL_SUPPORT],
|
||||
[Whether the OPAL DL framework is functional or not])
|
||||
])
|
184
opal/mca/dl/dl.h
Обычный файл
184
opal/mca/dl/dl.h
Обычный файл
@ -0,0 +1,184 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Dynamic library framework
|
||||
*
|
||||
* General Description:
|
||||
*
|
||||
* This framework provides portable access to dlopen- and dlsym-like
|
||||
* functionality, very similar to Libtool's libltdl. Indeed, one of
|
||||
* the components in this framework will use libltdl, if it is
|
||||
* present/available. However, on some common types systems where
|
||||
* libltdl headers and libraries are *not* available, we can support
|
||||
* plugins via this simple framework.
|
||||
*
|
||||
* This is a compile-time framework: a single component will be
|
||||
* selected by the priority that its configure.m4 provides. All other
|
||||
* components will be ignored (i.e., not built/not part of the
|
||||
* installation). Meaning: the static_components of the dl framework
|
||||
* will always contain 0 or 1 components.
|
||||
*
|
||||
* SIDENOTE: Open MPI used to embed libltdl. However, as of early
|
||||
* 2015, this became problematic, for a variety of complex and
|
||||
* uninteresting reasons (see the following if you care about the
|
||||
* details: https://github.com/open-mpi/ompi/issues/311,
|
||||
* http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19370,
|
||||
* https://github.com/open-mpi/ompi/pull/366,
|
||||
* https://github.com/open-mpi/ompi/pull/390). That being said, we,
|
||||
* as a developer community, still wanted to be able to natively use
|
||||
* DSOs by default. A small/simple framework for DL functionality,
|
||||
* along with a simple component that supports dlopen/dlsym on POSIX
|
||||
* platforms and another component that natively uses libltdl seemed
|
||||
* like a good solution.
|
||||
*/
|
||||
|
||||
#ifndef MCA_DLOPEN_H
|
||||
#define MCA_DLOPEN_H
|
||||
|
||||
#include "opal_config.h"
|
||||
|
||||
#include "opal/mca/mca.h"
|
||||
#include "opal/mca/base/base.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
/**
|
||||
* Handle for an opened file
|
||||
*/
|
||||
struct opal_dl_handle_t;
|
||||
typedef struct opal_dl_handle_t opal_dl_handle_t;
|
||||
|
||||
/**
|
||||
* Dynamically open the file specified.
|
||||
*
|
||||
* Arguments:
|
||||
* fname = Base filename to open. If NULL, open this process.
|
||||
* use_ext = If true, try various filename suffixes that are
|
||||
* relevant on this platform (e.g., .so, .dll, .dylib). If
|
||||
* false, just use exactly whatever was passed as fname.
|
||||
* private = If true, open the file in a private namespace.
|
||||
* Otherwise, open the file in a global namespace.
|
||||
* handle = Upon successful open, a handle to the opened file will
|
||||
* be returned.
|
||||
* err_msg= if non-NULL and !=OPAL_SUCCESS is returned, will point to a
|
||||
* string error message
|
||||
*
|
||||
* Returns:
|
||||
* OPAL_SUCCESS on success, or OPAL_ERROR
|
||||
*
|
||||
* Space for the handle must be allocated by the module (it can be
|
||||
* freed during the call to opal_dl_base_module_dlclose_fn_t).
|
||||
*
|
||||
* The err_msg points to an internal string and should not be altered
|
||||
* or freed by the caller. The contents of the err_msg string may
|
||||
* change after successive calls to opal_dl API calls.
|
||||
*/
|
||||
typedef int (*opal_dl_base_module_open_fn_t)
|
||||
(const char *fname, bool use_ext, bool private_namespace,
|
||||
opal_dl_handle_t **handle, char **err_msg);
|
||||
|
||||
/**
|
||||
* Lookup a symbol in an opened file.
|
||||
*
|
||||
* Arguments:
|
||||
* handle = handle of a previously dynamically opened file
|
||||
* symbol = name of the symbol to lookup
|
||||
* ptr = if found, a pointer to the symbol. Otherwise, NULL.
|
||||
* err_msg= if non-NULL and !=OPAL_SUCCESS is returned, will point to a
|
||||
* string error message
|
||||
* Returns:
|
||||
* OPAL_SUCCESS on success, or OPAL_ERROR
|
||||
*
|
||||
*
|
||||
* The err_msg points to an internal string and should not be altered
|
||||
* or freed by the caller. The contents of the err_msg string may
|
||||
* change after successive calls to opal_dl API calls.
|
||||
*/
|
||||
typedef int (*opal_dl_base_module_lookup_fn_t)
|
||||
(opal_dl_handle_t *handle, const char *symbol, void **ptr, char **err_msg);
|
||||
|
||||
/**
|
||||
* Dynamically close a previously dynamically-opened file.
|
||||
*
|
||||
* Arguments:
|
||||
* handle = handle of a previously dynamically opened file.
|
||||
* Returns:
|
||||
* OPAL_SUCCESS on success, or OPAL_ERROR
|
||||
*
|
||||
* This function should close the file and free and resources
|
||||
* associated with it (e.g., whatever is cached on the handle).
|
||||
*/
|
||||
typedef int (*opal_dl_base_module_close_fn_t)
|
||||
(opal_dl_handle_t *handle);
|
||||
|
||||
/**
|
||||
* Search through a path of directories, invoking a callback on each
|
||||
* unique regular (non-Libtool) file basename found (e.g., will only
|
||||
* be invoked once for the files "foo.la" and "foo.so", with the
|
||||
* parameter "foo").
|
||||
*
|
||||
* Arguments:
|
||||
* path = OPAL_ENV_SEP-delimited list of directories
|
||||
* cb_func= function to invoke on each filename found
|
||||
* data = context for callback function
|
||||
* Returns:
|
||||
* OPAL_SUCESS on success, OPAL_ERR* otherwise
|
||||
*/
|
||||
typedef int (*opal_dl_base_module_foreachfile_fn_t)
|
||||
(const char *search_path,
|
||||
int (*cb_func)(const char *filename, void *context),
|
||||
void *context);
|
||||
|
||||
/**
|
||||
* Structure for DL components.
|
||||
*/
|
||||
struct opal_dl_base_component_1_0_0_t {
|
||||
/** MCA base component */
|
||||
mca_base_component_t base_version;
|
||||
/** MCA base data */
|
||||
mca_base_component_data_t base_data;
|
||||
|
||||
/** Default priority */
|
||||
int priority;
|
||||
};
|
||||
typedef struct opal_dl_base_component_1_0_0_t opal_dl_base_component_1_0_0_t;
|
||||
typedef struct opal_dl_base_component_1_0_0_t opal_dl_base_component_t;
|
||||
|
||||
/**
|
||||
* Structure for DL modules
|
||||
*/
|
||||
struct opal_dl_base_module_1_0_0_t {
|
||||
mca_base_module_2_0_0_t super;
|
||||
|
||||
/** Open / close */
|
||||
opal_dl_base_module_open_fn_t open;
|
||||
opal_dl_base_module_close_fn_t close;
|
||||
|
||||
/** Lookup a symbol */
|
||||
opal_dl_base_module_lookup_fn_t lookup;
|
||||
|
||||
/** Iterate looking for files */
|
||||
opal_dl_base_module_foreachfile_fn_t foreachfile;
|
||||
};
|
||||
typedef struct opal_dl_base_module_1_0_0_t opal_dl_base_module_1_0_0_t;
|
||||
typedef struct opal_dl_base_module_1_0_0_t opal_dl_base_module_t;
|
||||
|
||||
/**
|
||||
* Macro for use in components that are of type DL
|
||||
*/
|
||||
#define OPAL_DL_BASE_VERSION_1_0_0 \
|
||||
MCA_BASE_VERSION_2_0_0, \
|
||||
"dl", 1, 0, 0
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /* OPAL_DL_H */
|
23
opal/mca/dl/dlopen/Makefile.am
Обычный файл
23
opal/mca/dl/dlopen/Makefile.am
Обычный файл
@ -0,0 +1,23 @@
|
||||
#
|
||||
# Copyright (c) 2004-2010 The Trustees of Indiana University.
|
||||
# All rights reserved.
|
||||
# Copyright (c) 2014-2015 Cisco Systems, Inc. All rights reserved.
|
||||
# $COPYRIGHT$
|
||||
#
|
||||
# Additional copyrights may follow
|
||||
#
|
||||
# $HEADER$
|
||||
#
|
||||
|
||||
sources = \
|
||||
dl_dlopen.h \
|
||||
dl_dlopen_component.c \
|
||||
dl_dlopen_module.c
|
||||
|
||||
# This component will only ever be built statically -- never as a DSO.
|
||||
|
||||
noinst_LTLIBRARIES = libmca_dl_dlopen.la
|
||||
|
||||
libmca_dl_dlopen_la_SOURCES = $(sources)
|
||||
libmca_dl_dlopen_la_LDFLAGS = -module -avoid-version
|
||||
libmca_dl_dlopen_la_LIBS = $(opal_dl_dlopen_LIBS)
|
55
opal/mca/dl/dlopen/configure.m4
Обычный файл
55
opal/mca/dl/dlopen/configure.m4
Обычный файл
@ -0,0 +1,55 @@
|
||||
# -*- shell-script -*-
|
||||
#
|
||||
# Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved.
|
||||
#
|
||||
# $COPYRIGHT$
|
||||
#
|
||||
# Additional copyrights may follow
|
||||
#
|
||||
# $HEADER$
|
||||
#
|
||||
|
||||
AC_DEFUN([MCA_opal_dl_dlopen_PRIORITY], [80])
|
||||
|
||||
#
|
||||
# Force this component to compile in static-only mode
|
||||
#
|
||||
AC_DEFUN([MCA_opal_dl_dlopen_COMPILE_MODE], [
|
||||
AC_MSG_CHECKING([for MCA component $2:$3 compile mode])
|
||||
$4="static"
|
||||
AC_MSG_RESULT([$$4])
|
||||
])
|
||||
|
||||
# MCA_dl_dlopen_CONFIG([action-if-can-compile],
|
||||
# [action-if-cant-compile])
|
||||
# ------------------------------------------------
|
||||
AC_DEFUN([MCA_opal_dl_dlopen_CONFIG],[
|
||||
AC_CONFIG_FILES([opal/mca/dl/dlopen/Makefile])
|
||||
|
||||
dnl This is effectively a back-door for Open MPI developers to
|
||||
dnl force the use of the libltdl dl component.
|
||||
AC_ARG_ENABLE([dl-dlopen],
|
||||
[AS_HELP_STRING([--disable-dl-dlopen],
|
||||
[Disable the "dlopen" DL component (and probably force the use of the "libltdl" DL component). This option should really only be used by Open MPI developers. You are probably actually looking for the "--disable-dlopen" option, which disables all dlopen-like functionality from Open MPI.])
|
||||
])
|
||||
|
||||
opal_dl_dlopen_happy=no
|
||||
AS_IF([test "$enable_dl_dlopen" != "no"],
|
||||
[OPAL_CHECK_PACKAGE([opal_dl_dlopen],
|
||||
[dlfcn.h],
|
||||
[dl],
|
||||
[dlopen],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[opal_dl_dlopen_happy=yes],
|
||||
[opal_dl_dlopen_happy=no])
|
||||
])
|
||||
|
||||
AS_IF([test "$opal_dl_dlopen_happy" = "yes"],
|
||||
[opal_dl_dlopen_ADD_LIBS=$opal_dl_dlopen_LIBS
|
||||
$1],
|
||||
[$2])
|
||||
|
||||
AC_SUBST(opal_dl_dlopen_LIBS)
|
||||
])
|
40
opal/mca/dl/dlopen/dl_dlopen.h
Обычный файл
40
opal/mca/dl/dlopen/dl_dlopen.h
Обычный файл
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#ifndef OPAL_DL_DLOPEN
|
||||
#define OPAL_DL_DLOPEN
|
||||
|
||||
#include "opal_config.h"
|
||||
|
||||
#include "opal/mca/dl/dl.h"
|
||||
|
||||
OPAL_DECLSPEC extern opal_dl_base_module_t opal_dl_dlopen_module;
|
||||
|
||||
/*
|
||||
* Dynamic library handles generated by this component.
|
||||
*
|
||||
* If we're debugging, keep a copy of the name of the file we've opened.
|
||||
*/
|
||||
struct opal_dl_handle_t {
|
||||
void *dlopen_handle;
|
||||
#if OPAL_ENABLE_DEBUG
|
||||
void *filename;
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
opal_dl_base_component_t base;
|
||||
|
||||
char *filename_suffixes_mca_storage;
|
||||
char **filename_suffixes;
|
||||
} opal_dl_dlopen_component_t;
|
||||
|
||||
OPAL_DECLSPEC extern opal_dl_dlopen_component_t mca_dl_dlopen_component;
|
||||
|
||||
#endif /* OPAL_DL_DLOPEN */
|
128
opal/mca/dl/dlopen/dl_dlopen_component.c
Обычный файл
128
opal/mca/dl/dlopen/dl_dlopen_component.c
Обычный файл
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#include "opal_config.h"
|
||||
|
||||
#include "opal/constants.h"
|
||||
#include "opal/mca/dl/dl.h"
|
||||
#include "opal/util/argv.h"
|
||||
|
||||
#include "dl_dlopen.h"
|
||||
|
||||
|
||||
/*
|
||||
* Public string showing the sysinfo ompi_linux component version number
|
||||
*/
|
||||
const char *opal_dl_dlopen_component_version_string =
|
||||
"OPAL dl dlopen MCA component version " OPAL_VERSION;
|
||||
|
||||
|
||||
/*
|
||||
* Local functions
|
||||
*/
|
||||
static int dlopen_component_register(void);
|
||||
static int dlopen_component_open(void);
|
||||
static int dlopen_component_close(void);
|
||||
static int dlopen_component_query(mca_base_module_t **module, int *priority);
|
||||
|
||||
/*
|
||||
* Instantiate the public struct with all of our public information
|
||||
* and pointers to our public functions in it
|
||||
*/
|
||||
|
||||
opal_dl_dlopen_component_t mca_dl_dlopen_component = {
|
||||
|
||||
/* Fill in the mca_dl_base_component_t */
|
||||
.base = {
|
||||
|
||||
/* First, the mca_component_t struct containing meta information
|
||||
about the component itself */
|
||||
.base_version = {
|
||||
OPAL_DL_BASE_VERSION_1_0_0,
|
||||
|
||||
/* Component name and version */
|
||||
"dlopen",
|
||||
OPAL_MAJOR_VERSION,
|
||||
OPAL_MINOR_VERSION,
|
||||
OPAL_RELEASE_VERSION,
|
||||
|
||||
/* Component functions */
|
||||
.mca_register_component_params = dlopen_component_register,
|
||||
.mca_open_component = dlopen_component_open,
|
||||
.mca_close_component = dlopen_component_close,
|
||||
.mca_query_component = dlopen_component_query,
|
||||
},
|
||||
|
||||
.base_data = {
|
||||
/* The component is checkpoint ready */
|
||||
MCA_BASE_METADATA_PARAM_CHECKPOINT
|
||||
},
|
||||
|
||||
/* The dl framework members */
|
||||
.priority = 80
|
||||
},
|
||||
|
||||
/* Now fill in the dlopen component-specific members */
|
||||
.filename_suffixes_mca_storage = ".so,.dylib,.dll,.sl",
|
||||
.filename_suffixes = NULL
|
||||
};
|
||||
|
||||
|
||||
static int dlopen_component_register(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret =
|
||||
mca_base_component_var_register(&mca_dl_dlopen_component.base.base_version,
|
||||
"filename_suffixes",
|
||||
"Comma-delimited list of filename suffixes that the dlopen component will try",
|
||||
MCA_BASE_VAR_TYPE_STRING,
|
||||
NULL,
|
||||
0,
|
||||
MCA_BASE_VAR_FLAG_SETTABLE,
|
||||
OPAL_INFO_LVL_5,
|
||||
MCA_BASE_VAR_SCOPE_LOCAL,
|
||||
&mca_dl_dlopen_component.filename_suffixes_mca_storage);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
mca_dl_dlopen_component.filename_suffixes =
|
||||
opal_argv_split(mca_dl_dlopen_component.filename_suffixes_mca_storage,
|
||||
',');
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
static int dlopen_component_open(void)
|
||||
{
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int dlopen_component_close(void)
|
||||
{
|
||||
if (NULL != mca_dl_dlopen_component.filename_suffixes) {
|
||||
opal_argv_free(mca_dl_dlopen_component.filename_suffixes);
|
||||
mca_dl_dlopen_component.filename_suffixes = NULL;
|
||||
}
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int dlopen_component_query(mca_base_module_t **module, int *priority)
|
||||
{
|
||||
/* The priority value is somewhat meaningless here; by
|
||||
opal/mca/dl/configure.m4, there's at most one component
|
||||
available. */
|
||||
*priority = mca_dl_dlopen_component.base.priority;
|
||||
*module = &opal_dl_dlopen_module.super;
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
263
opal/mca/dl/dlopen/dl_dlopen_module.c
Обычный файл
263
opal/mca/dl/dlopen/dl_dlopen_module.c
Обычный файл
@ -0,0 +1,263 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#include "opal_config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <dlfcn.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "opal/constants.h"
|
||||
#include "opal/mca/dl/dl.h"
|
||||
#include "opal/util/argv.h"
|
||||
|
||||
#include "dl_dlopen.h"
|
||||
|
||||
|
||||
/*
|
||||
* Trivial helper function to avoid replicating code
|
||||
*/
|
||||
static void do_dlopen(const char *fname, int flags,
|
||||
void **handle, char **err_msg)
|
||||
{
|
||||
assert(fname);
|
||||
assert(handle);
|
||||
|
||||
*handle = dlopen(fname, flags);
|
||||
|
||||
if (NULL != err_msg) {
|
||||
if (NULL != *handle) {
|
||||
*err_msg = NULL;
|
||||
} else {
|
||||
*err_msg = dlerror();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int dlopen_open(const char *fname, bool use_ext, bool private_namespace,
|
||||
opal_dl_handle_t **handle, char **err_msg)
|
||||
{
|
||||
assert(fname);
|
||||
assert(handle);
|
||||
|
||||
*handle = NULL;
|
||||
|
||||
/* Setup the dlopen flags */
|
||||
int flags = RTLD_LAZY;
|
||||
if (private_namespace) {
|
||||
flags |= RTLD_LOCAL;
|
||||
} else {
|
||||
flags |= RTLD_GLOBAL;
|
||||
}
|
||||
|
||||
/* If the caller wants to use filename extensions, loop through
|
||||
them */
|
||||
void *local_handle = NULL;
|
||||
if (use_ext) {
|
||||
int i;
|
||||
char *ext;
|
||||
|
||||
for (i = 0, ext = mca_dl_dlopen_component.filename_suffixes[i];
|
||||
NULL != ext;
|
||||
ext = mca_dl_dlopen_component.filename_suffixes[++i]) {
|
||||
char *name;
|
||||
|
||||
asprintf(&name, "%s%s", fname, ext);
|
||||
if (NULL == name) {
|
||||
return OPAL_ERR_IN_ERRNO;
|
||||
}
|
||||
|
||||
/* Does the file exist? */
|
||||
struct stat buf;
|
||||
if (stat(name, &buf) < 0) {
|
||||
free(name);
|
||||
if (NULL != err_msg) {
|
||||
*err_msg = "File not found";
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Yes, the file exists -- try to dlopen it. If we can't
|
||||
dlopen it, bail. */
|
||||
do_dlopen(name, flags, &local_handle, err_msg);
|
||||
free(name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Otherwise, the caller does not want to use filename extensions,
|
||||
so just use the single filename that the caller provided */
|
||||
else {
|
||||
do_dlopen(fname, flags, &local_handle, err_msg);
|
||||
}
|
||||
|
||||
if (NULL != local_handle) {
|
||||
*handle = calloc(1, sizeof(opal_dl_handle_t));
|
||||
(*handle)->dlopen_handle = local_handle;
|
||||
|
||||
#if OPAL_ENABLE_DEBUG
|
||||
(*handle)->filename = strdup(fname);
|
||||
#endif
|
||||
}
|
||||
return (NULL != local_handle) ? OPAL_SUCCESS : OPAL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
static int dlopen_lookup(opal_dl_handle_t *handle, const char *symbol,
|
||||
void **ptr, char **err_msg)
|
||||
{
|
||||
assert(handle);
|
||||
assert(handle->dlopen_handle);
|
||||
assert(symbol);
|
||||
assert(ptr);
|
||||
|
||||
*ptr = dlsym(handle->dlopen_handle, symbol);
|
||||
if (NULL != *ptr) {
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
if (NULL != err_msg) {
|
||||
*err_msg = dlerror();
|
||||
}
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
static int dlopen_close(opal_dl_handle_t *handle)
|
||||
{
|
||||
assert(handle);
|
||||
|
||||
int ret;
|
||||
ret = dlclose(handle->dlopen_handle);
|
||||
|
||||
#if OPAL_ENABLE_DEBUG
|
||||
free(handle->filename);
|
||||
#endif
|
||||
free(handle);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Scan all the files in a directory (or path) and invoke a callback
|
||||
* on each one.
|
||||
*/
|
||||
static int dlopen_foreachfile(const char *search_path,
|
||||
int (*func)(const char *filename, void *data),
|
||||
void *data)
|
||||
{
|
||||
int ret;
|
||||
DIR *dp = NULL;
|
||||
char **dirs = NULL;
|
||||
char **good_files = NULL;
|
||||
|
||||
dirs = opal_argv_split(search_path, OPAL_ENV_SEP);
|
||||
for (int i = 0; NULL != dirs[i]; ++i) {
|
||||
|
||||
dp = opendir(dirs[i]);
|
||||
if (NULL == dp) {
|
||||
return OPAL_ERR_IN_ERRNO;
|
||||
}
|
||||
|
||||
struct dirent *de;
|
||||
while (NULL != (de = readdir(dp))) {
|
||||
|
||||
/* Make the absolute path name */
|
||||
char *abs_name = NULL;
|
||||
asprintf(&abs_name, "%s/%s", dirs[i], de->d_name);
|
||||
if (NULL == abs_name) {
|
||||
ret = OPAL_ERR_IN_ERRNO;
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Stat the file */
|
||||
struct stat buf;
|
||||
if (stat(abs_name, &buf) < 0) {
|
||||
free(abs_name);
|
||||
ret = OPAL_ERR_IN_ERRNO;
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Skip if not a file */
|
||||
if (!S_ISREG(buf.st_mode)) {
|
||||
free(abs_name);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Find the suffix */
|
||||
char *ptr = strrchr(abs_name, '.');
|
||||
if (NULL != ptr) {
|
||||
|
||||
/* Skip libtool files */
|
||||
if (strcmp(ptr, ".la") == 0 ||
|
||||
strcmp(ptr, ".lo") == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
*ptr = '\0';
|
||||
}
|
||||
|
||||
/* Have we already found this file? Or already found a
|
||||
file with the same basename (but different suffix)? */
|
||||
if (NULL != good_files) {
|
||||
for (int j = 0; NULL != good_files[j]; ++j) {
|
||||
if (strcmp(good_files[j], abs_name) == 0) {
|
||||
free(abs_name);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
opal_argv_append_nosize(&good_files, abs_name);
|
||||
free(abs_name);
|
||||
}
|
||||
}
|
||||
closedir(dp);
|
||||
dp = NULL;
|
||||
|
||||
/* Invoke the callback on all the found files */
|
||||
if (NULL != good_files) {
|
||||
for (int i = 0; NULL != good_files[i]; ++i) {
|
||||
ret = func(good_files[i], data);
|
||||
if (OPAL_SUCCESS != ret) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ret = OPAL_SUCCESS;
|
||||
|
||||
error:
|
||||
if (NULL != dp) {
|
||||
closedir(dp);
|
||||
}
|
||||
if (NULL != dirs) {
|
||||
opal_argv_free(dirs);
|
||||
}
|
||||
if (NULL != good_files) {
|
||||
opal_argv_free(good_files);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Module definition
|
||||
*/
|
||||
opal_dl_base_module_t opal_dl_dlopen_module = {
|
||||
.open = dlopen_open,
|
||||
.lookup = dlopen_lookup,
|
||||
.close = dlopen_close,
|
||||
.foreachfile = dlopen_foreachfile
|
||||
};
|
26
opal/mca/dl/libltdl/Makefile.am
Обычный файл
26
opal/mca/dl/libltdl/Makefile.am
Обычный файл
@ -0,0 +1,26 @@
|
||||
#
|
||||
# Copyright (c) 2004-2010 The Trustees of Indiana University.
|
||||
# All rights reserved.
|
||||
# Copyright (c) 2014-2015 Cisco Systems, Inc. All rights reserved.
|
||||
# $COPYRIGHT$
|
||||
#
|
||||
# Additional copyrights may follow
|
||||
#
|
||||
# $HEADER$
|
||||
#
|
||||
|
||||
sources = \
|
||||
dl_libltdl.h \
|
||||
dl_libltdl_component.c \
|
||||
dl_libltdl_module.c
|
||||
|
||||
# This component will only ever be built statically -- never as a DSO.
|
||||
|
||||
noinst_LTLIBRARIES = libmca_dl_libltdl.la
|
||||
|
||||
libmca_dl_libltdl_la_SOURCES = $(sources)
|
||||
libmca_dl_libltdl_la_CPPFLAGS = $(opal_dl_libltdl_CPPFLAGS)
|
||||
libmca_dl_libltdl_la_LDFLAGS = \
|
||||
$(opal_dl_libltdl_LDFLAGS) \
|
||||
-module -avoid-version
|
||||
libmca_dl_libltdl_la_LIBS = $(opal_dl_libltdl_LIBS)
|
123
opal/mca/dl/libltdl/configure.m4
Обычный файл
123
opal/mca/dl/libltdl/configure.m4
Обычный файл
@ -0,0 +1,123 @@
|
||||
# -*- shell-script -*-
|
||||
#
|
||||
# Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved.
|
||||
#
|
||||
# $COPYRIGHT$
|
||||
#
|
||||
# Additional copyrights may follow
|
||||
#
|
||||
# $HEADER$
|
||||
#
|
||||
|
||||
AC_DEFUN([MCA_opal_dl_libltdl_PRIORITY], [50])
|
||||
|
||||
#
|
||||
# Force this component to compile in static-only mode
|
||||
#
|
||||
AC_DEFUN([MCA_opal_dl_libltdl_COMPILE_MODE], [
|
||||
AC_MSG_CHECKING([for MCA component $2:$3 compile mode])
|
||||
$4="static"
|
||||
AC_MSG_RESULT([$$4])
|
||||
])
|
||||
|
||||
# MCA_event_external_POST_CONFIG()
|
||||
# ---------------------------------
|
||||
AC_DEFUN([MCA_opal_dl_libltdl_POST_CONFIG],[
|
||||
# If we won, then do all the rest of the setup
|
||||
AS_IF([test "$1" = "1"],
|
||||
[
|
||||
# Add some stuff to CPPFLAGS so that the rest of the source
|
||||
# tree can be built
|
||||
LDFLAGS="$LDFLAGS $opal_dl_libltdl_ADD_LDFLAGS"
|
||||
LIBS="$LIBS $opal_dl_libltdl_ADD_LIBS"
|
||||
])
|
||||
])dnl
|
||||
|
||||
# MCA_dl_libltdl_CONFIG([action-if-can-compile],
|
||||
# [action-if-cant-compile])
|
||||
# ------------------------------------------------
|
||||
AC_DEFUN([MCA_opal_dl_libltdl_CONFIG],[
|
||||
OPAL_VAR_SCOPE_PUSH([CPPFLAGS_save LDFLAGS_save LIBS_save])
|
||||
AC_CONFIG_FILES([opal/mca/dl/libltdl/Makefile])
|
||||
|
||||
# Add --with options
|
||||
AC_ARG_WITH([libltdl],
|
||||
[AC_HELP_STRING([--with-libltdl(=DIR)],
|
||||
[Build libltdl support, optionally adding DIR/include, DIR/lib, and DIR/lib64 to the search path for headers and libraries])])
|
||||
AC_ARG_WITH([libltdl-libdir],
|
||||
[AC_HELP_STRING([--with-libltdl-libdir=DIR],
|
||||
[Search for libltdl libraries in DIR])])
|
||||
|
||||
# Sanity check the --with values
|
||||
OPAL_CHECK_WITHDIR([libltdl], [$with_libltdl],
|
||||
[include/ltdl.h])
|
||||
OPAL_CHECK_WITHDIR([libltdl-libdir], [$with_libltdl_libdir],
|
||||
[libltdl.*])
|
||||
|
||||
# Defaults
|
||||
opal_check_libltdl_dir_msg="compiler default"
|
||||
opal_check_libltdl_libdir_msg="linker default"
|
||||
|
||||
# Save directory names if supplied
|
||||
AS_IF([test ! -z "$with_libltdl" && test "$with_libltdl" != "yes"],
|
||||
[opal_check_libltdl_dir=$with_libltdl
|
||||
opal_check_libltdl_dir_msg="$opal_check_libltdl_dir (from --with-libltdl)"])
|
||||
AS_IF([test ! -z "$with_libltdl_libdir" && test "$with_libltdl_libdir" != "yes"],
|
||||
[opal_check_libltdl_libdir=$with_libltdl_libdir
|
||||
opal_check_libltdl_libdir_msg="$opal_check_libltdl_libdir (from --with-libltdl-libdir)"])
|
||||
|
||||
opal_dl_libltdl_happy=no
|
||||
AS_IF([test "$with_libltdl" != "no"],
|
||||
[AC_MSG_CHECKING([for libltdl dir])
|
||||
AC_MSG_RESULT([$opal_check_libltdl_dir_msg])
|
||||
AC_MSG_CHECKING([for libltdl library dir])
|
||||
AC_MSG_RESULT([$opal_check_libltdl_libdir_msg])
|
||||
|
||||
OPAL_CHECK_PACKAGE([opal_dl_libltdl],
|
||||
[ltdl.h],
|
||||
[ltdl],
|
||||
[lt_dlopen],
|
||||
[],
|
||||
[$opal_check_libltdl_dir],
|
||||
[$opal_check_libltdl_libdir],
|
||||
[opal_dl_libltdl_happy=yes],
|
||||
[opal_dl_libltdl_happy=no])
|
||||
])
|
||||
|
||||
# If we have libltdl, do we have lt_dladvise?
|
||||
opal_dl_libltdl_have_lt_dladvise=0
|
||||
AS_IF([test "$opal_dl_libltdl_happy" = "yes"],
|
||||
[CPPFLAGS_save=$CPPFLAGS
|
||||
LDFLAGS_save=$LDFLAGS
|
||||
LIBS_save=$LIBS
|
||||
|
||||
CPPFLAGS="$opal_dl_libltdl_CPPFLAGS $CPPFLAGS"
|
||||
LDFLAGS="$opal_dl_libltdl_LDFLAGS $LDFLAGS"
|
||||
LIBS="$opal_dl_libltdl_LIBS $LIBS"
|
||||
AC_CHECK_FUNC([lt_dladvise_init],
|
||||
[opal_dl_libltdl_have_lt_dladvise=1])
|
||||
CPPFLAGS=$CPPFLAGS_save
|
||||
LDFLAGS=$LDFLAGS_save
|
||||
LIBS=$LIBS_save
|
||||
])
|
||||
AC_DEFINE_UNQUOTED(OPAL_DL_LIBLTDL_HAVE_LT_DLADVISE,
|
||||
[$opal_dl_libltdl_have_lt_dladvise],
|
||||
[Whether we have lt_dladvise or not])
|
||||
|
||||
AS_IF([test "$opal_dl_libltdl_happy" = "yes"],
|
||||
[opal_dl_libltdl_ADD_CPPFLAGS=$opal_dl_libltdl_CPPFLAGS
|
||||
opal_dl_libltdl_ADD_LDFLAGS=$opal_dl_libltdl_LDFLAGS
|
||||
opal_dl_libltdl_ADD_LIBS=$opal_dl_libltdl_LIBS
|
||||
$1],
|
||||
[AS_IF([test ! -z "$with_libltdl" && \
|
||||
test "$with_libltdl" != "no"],
|
||||
[AC_MSG_WARN([Libltdl support requested (via --with-libltdl) but not found.])
|
||||
AC_MSG_ERROR([Cannot continue.])])
|
||||
$2])
|
||||
|
||||
AC_SUBST(opal_dl_libltdl_CPPFLAGS)
|
||||
AC_SUBST(opal_dl_libltdl_LDFLAGS)
|
||||
AC_SUBST(opal_dl_libltdl_LIBS)
|
||||
|
||||
OPAL_VAR_SCOPE_POP
|
||||
])
|
50
opal/mca/dl/libltdl/dl_libltdl.h
Обычный файл
50
opal/mca/dl/libltdl/dl_libltdl.h
Обычный файл
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#ifndef OPAL_DL_LIBLTDL
|
||||
#define OPAL_DL_LIBLTDL
|
||||
|
||||
#include "opal_config.h"
|
||||
|
||||
#include "opal/mca/dl/dl.h"
|
||||
|
||||
#include <ltdl.h>
|
||||
|
||||
|
||||
OPAL_DECLSPEC extern opal_dl_base_module_t opal_dl_libltdl_module;
|
||||
|
||||
/*
|
||||
* Dynamic library handles generated by this component.
|
||||
*
|
||||
* If we're debugging, keep a copy of the name of the file we've opened.
|
||||
*/
|
||||
struct opal_dl_handle_t {
|
||||
lt_dlhandle ltdl_handle;
|
||||
#if OPAL_ENABLE_DEBUG
|
||||
char *filename;
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
opal_dl_base_component_t base;
|
||||
|
||||
#if OPAL_DL_LIBLTDL_HAVE_LT_DLADVISE
|
||||
/* If the version of libltdl that we are compiling against has
|
||||
lt_dladvise, use it to support opening DSOs in a variety of
|
||||
modes. */
|
||||
lt_dladvise advise_private_noext;
|
||||
lt_dladvise advise_private_ext;
|
||||
lt_dladvise advise_public_noext;
|
||||
lt_dladvise advise_public_ext;
|
||||
#endif
|
||||
} opal_dl_libltdl_component_t;
|
||||
|
||||
OPAL_DECLSPEC extern opal_dl_libltdl_component_t mca_dl_libltdl_component;
|
||||
|
||||
#endif /* OPAL_DL_LIBLTDL */
|
155
opal/mca/dl/libltdl/dl_libltdl_component.c
Обычный файл
155
opal/mca/dl/libltdl/dl_libltdl_component.c
Обычный файл
@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#include "opal_config.h"
|
||||
|
||||
#include "opal/constants.h"
|
||||
#include "opal/mca/dl/dl.h"
|
||||
#include "opal/mca/base/mca_base_var.h"
|
||||
#include "opal/util/argv.h"
|
||||
|
||||
#include "dl_libltdl.h"
|
||||
|
||||
|
||||
/*
|
||||
* Public string showing the sysinfo ompi_linux component version number
|
||||
*/
|
||||
const char *opal_dl_libltdl_component_version_string =
|
||||
"OPAL dl libltdl MCA component version " OPAL_VERSION;
|
||||
|
||||
|
||||
/*
|
||||
* Local functions
|
||||
*/
|
||||
static int libltdl_component_register(void);
|
||||
static int libltdl_component_open(void);
|
||||
static int libltdl_component_close(void);
|
||||
static int libltdl_component_query(mca_base_module_t **module, int *priority);
|
||||
|
||||
/*
|
||||
* Instantiate the public struct with all of our public information
|
||||
* and pointers to our public functions in it
|
||||
*/
|
||||
|
||||
opal_dl_libltdl_component_t mca_dl_libltdl_component = {
|
||||
|
||||
/* Fill in the mca_dl_base_component_t */
|
||||
.base = {
|
||||
|
||||
/* First, the mca_component_t struct containing meta information
|
||||
about the component itself */
|
||||
.base_version = {
|
||||
OPAL_DL_BASE_VERSION_1_0_0,
|
||||
|
||||
/* Component name and version */
|
||||
"libltdl",
|
||||
OPAL_MAJOR_VERSION,
|
||||
OPAL_MINOR_VERSION,
|
||||
OPAL_RELEASE_VERSION,
|
||||
|
||||
/* Component functions */
|
||||
.mca_register_component_params = libltdl_component_register,
|
||||
.mca_open_component = libltdl_component_open,
|
||||
.mca_close_component = libltdl_component_close,
|
||||
.mca_query_component = libltdl_component_query,
|
||||
},
|
||||
|
||||
.base_data = {
|
||||
/* The component is checkpoint ready */
|
||||
MCA_BASE_METADATA_PARAM_CHECKPOINT
|
||||
},
|
||||
|
||||
/* The dl framework members */
|
||||
.priority = 50
|
||||
}
|
||||
|
||||
/* Now fill in the libltdl component-specific members */
|
||||
};
|
||||
|
||||
|
||||
static int libltdl_component_register(void)
|
||||
{
|
||||
/* Register an info param indicating whether we have lt_dladvise
|
||||
support or not */
|
||||
bool supported = OPAL_INT_TO_BOOL(OPAL_DL_LIBLTDL_HAVE_LT_DLADVISE);
|
||||
mca_base_component_var_register(&mca_dl_libltdl_component.base.base_version,
|
||||
"have_lt_dladvise",
|
||||
"Whether the version of libltdl that this component is built against supports lt_dladvise functionality or not",
|
||||
MCA_BASE_VAR_TYPE_BOOL,
|
||||
NULL,
|
||||
0,
|
||||
MCA_BASE_VAR_FLAG_DEFAULT_ONLY,
|
||||
OPAL_INFO_LVL_7,
|
||||
MCA_BASE_VAR_SCOPE_CONSTANT,
|
||||
&supported);
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
static int libltdl_component_open(void)
|
||||
{
|
||||
if (lt_dlinit()) {
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
|
||||
#if OPAL_DL_LIBLTDL_HAVE_LT_DLADVISE
|
||||
opal_dl_libltdl_component_t *c = &mca_dl_libltdl_component;
|
||||
|
||||
if (lt_dladvise_init(&c->advise_private_noext)) {
|
||||
return OPAL_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
|
||||
if (lt_dladvise_init(&c->advise_private_ext) ||
|
||||
lt_dladvise_ext(&c->advise_private_ext)) {
|
||||
return OPAL_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
|
||||
if (lt_dladvise_init(&c->advise_public_noext) ||
|
||||
lt_dladvise_global(&c->advise_public_noext)) {
|
||||
return OPAL_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
|
||||
if (lt_dladvise_init(&c->advise_public_ext) ||
|
||||
lt_dladvise_global(&c->advise_public_ext) ||
|
||||
lt_dladvise_ext(&c->advise_public_ext)) {
|
||||
return OPAL_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
#endif
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int libltdl_component_close(void)
|
||||
{
|
||||
#if OPAL_DL_LIBLTDL_HAVE_LT_DLADVISE
|
||||
opal_dl_libltdl_component_t *c = &mca_dl_libltdl_component;
|
||||
|
||||
lt_dladvise_destroy(&c->advise_private_noext);
|
||||
lt_dladvise_destroy(&c->advise_private_ext);
|
||||
lt_dladvise_destroy(&c->advise_public_noext);
|
||||
lt_dladvise_destroy(&c->advise_public_ext);
|
||||
#endif
|
||||
|
||||
lt_dlexit();
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int libltdl_component_query(mca_base_module_t **module, int *priority)
|
||||
{
|
||||
/* The priority value is somewhat meaningless here; by
|
||||
opal/mca/dl/configure.m4, there's at most one component
|
||||
available. */
|
||||
*priority = mca_dl_libltdl_component.base.priority;
|
||||
*module = &opal_dl_libltdl_module.super;
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
128
opal/mca/dl/libltdl/dl_libltdl_module.c
Обычный файл
128
opal/mca/dl/libltdl/dl_libltdl_module.c
Обычный файл
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#include "opal_config.h"
|
||||
|
||||
#include "opal/constants.h"
|
||||
#include "opal/mca/dl/dl.h"
|
||||
|
||||
#include "dl_libltdl.h"
|
||||
|
||||
|
||||
static int libltdl_open(const char *fname, bool use_ext, bool private_namespace,
|
||||
opal_dl_handle_t **handle, char **err_msg)
|
||||
{
|
||||
assert(fname);
|
||||
assert(handle);
|
||||
|
||||
*handle = NULL;
|
||||
if (NULL != err_msg) {
|
||||
*err_msg = NULL;
|
||||
}
|
||||
|
||||
lt_dlhandle local_handle;
|
||||
|
||||
#if OPAL_DL_LIBLTDL_HAVE_LT_DLADVISE
|
||||
opal_dl_libltdl_component_t *c = &mca_dl_libltdl_component;
|
||||
|
||||
if (use_ext && private_namespace) {
|
||||
local_handle = lt_dlopenadvise(fname, c->advise_private_ext);
|
||||
} else if (use_ext && !private_namespace) {
|
||||
local_handle = lt_dlopenadvise(fname, c->advise_public_ext);
|
||||
} else if (!use_ext && private_namespace) {
|
||||
local_handle = lt_dlopenadvise(fname, c->advise_private_noext);
|
||||
} else if (!use_ext && !private_namespace) {
|
||||
local_handle = lt_dlopenadvise(fname, c->advise_public_noext);
|
||||
}
|
||||
#else
|
||||
if (use_ext) {
|
||||
local_handle = lt_dlopenext(fname);
|
||||
} else {
|
||||
local_handle = lt_dlopen(fname);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (NULL != local_handle) {
|
||||
*handle = calloc(1, sizeof(opal_dl_handle_t));
|
||||
(*handle)->ltdl_handle = local_handle;
|
||||
|
||||
#if OPAL_ENABLE_DEBUG
|
||||
(*handle)->filename = strdup(fname);
|
||||
#endif
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
if (NULL != err_msg) {
|
||||
*err_msg = (char*) lt_dlerror();
|
||||
}
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
static int libltdl_lookup(opal_dl_handle_t *handle, const char *symbol,
|
||||
void **ptr, char **err_msg)
|
||||
{
|
||||
assert(handle);
|
||||
assert(handle->ltdl_handle);
|
||||
assert(symbol);
|
||||
assert(ptr);
|
||||
|
||||
if (NULL != err_msg) {
|
||||
*err_msg = NULL;
|
||||
}
|
||||
|
||||
*ptr = lt_dlsym(handle->ltdl_handle, symbol);
|
||||
if (NULL != *ptr) {
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
if (NULL != err_msg) {
|
||||
*err_msg = (char*) lt_dlerror();
|
||||
}
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
static int libltdl_close(opal_dl_handle_t *handle)
|
||||
{
|
||||
assert(handle);
|
||||
|
||||
int ret;
|
||||
ret = lt_dlclose(handle->ltdl_handle);
|
||||
|
||||
#if OPAL_ENABLE_DEBUG
|
||||
free(handle->filename);
|
||||
#endif
|
||||
free(handle);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int libltdl_foreachfile(const char *search_path,
|
||||
int (*func)(const char *filename, void *data),
|
||||
void *data)
|
||||
{
|
||||
assert(search_path);
|
||||
assert(func);
|
||||
|
||||
int ret = lt_dlforeachfile(search_path, func, data);
|
||||
return (0 == ret) ? OPAL_SUCCESS : OPAL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Module definition
|
||||
*/
|
||||
opal_dl_base_module_t opal_dl_libltdl_module = {
|
||||
.open = libltdl_open,
|
||||
.lookup = libltdl_lookup,
|
||||
.close = libltdl_close,
|
||||
.foreachfile = libltdl_foreachfile
|
||||
};
|
@ -47,7 +47,6 @@ headers = \
|
||||
fd.c \
|
||||
if.h \
|
||||
keyval_parse.h \
|
||||
lt_interface.h \
|
||||
malloc.h \
|
||||
net.h \
|
||||
numtostr.h \
|
||||
@ -83,7 +82,6 @@ libopalutil_la_SOURCES = \
|
||||
if.c \
|
||||
keyval_parse.c \
|
||||
malloc.c \
|
||||
lt_interface.c \
|
||||
net.c \
|
||||
numtostr.c \
|
||||
opal_environ.c \
|
||||
|
@ -1,246 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2015 Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2013 NVIDIA Corporation. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#include "opal_config.h"
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include "opal/constants.h"
|
||||
#include "opal/util/lt_interface.h"
|
||||
#include "opal/util/output.h"
|
||||
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
#if OPAL_LIBLTDL_INTERNAL
|
||||
#include "opal/libltdl/ltdl.h"
|
||||
#else
|
||||
#include "ltdl.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
struct opal_lt_dlhandle_st { lt_dlhandle dlhandle; };
|
||||
#else /* OPAL_WANT_LIBLTDL */
|
||||
struct opal_lt_dlhandle_st { void *dlhandle; };
|
||||
#endif /* OPAL_WANT_LIBLTDL */
|
||||
|
||||
#if OPAL_WANT_LIBLTDL && OPAL_HAVE_LTDL_ADVISE
|
||||
struct opal_lt_dladvise_st { lt_dladvise dladvise; };
|
||||
#else /* OPAL_WANT_LIBLTDL && OPAL_HAVE_LTDL_ADVISE */
|
||||
struct opal_lt_dladvise_st { void *dladvise; };
|
||||
#endif /* OPAL_WANT_LIBLTDL && OPAL_HAVE_LTDL_ADVISE */
|
||||
|
||||
OPAL_DECLSPEC int opal_lt_dlinit(void)
|
||||
{
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
return lt_dlinit();
|
||||
#else /* OPAL_WANT_LIBLTDL */
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
#endif /* OPAL_WANT_LIBLTDL */
|
||||
}
|
||||
|
||||
OPAL_DECLSPEC int opal_lt_dlexit(void) {
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
return lt_dlexit();
|
||||
#else /* OPAL_WANT_LIBLTDL */
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
#endif /* OPAL_WANT_LIBLTDL */
|
||||
}
|
||||
|
||||
/* Module search path manipulation. */
|
||||
OPAL_DECLSPEC int opal_lt_dladdsearchdir(const char *search_dir) {
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
return lt_dladdsearchdir(search_dir);
|
||||
#else /* OPAL_WANT_LIBLTDL */
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
#endif /* OPAL_WANT_LIBLTDL */
|
||||
}
|
||||
|
||||
OPAL_DECLSPEC int opal_lt_dlinsertsearchdir(const char *before,
|
||||
const char *search_dir) {
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
return lt_dlinsertsearchdir(before, search_dir);
|
||||
#else /* OPAL_WANT_LIBLTDL */
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
#endif /* OPAL_WANT_LIBLTDL */
|
||||
}
|
||||
|
||||
OPAL_DECLSPEC int opal_lt_dlsetsearchpath(const char *search_path) {
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
return lt_dlsetsearchpath(search_path);
|
||||
#else /* OPAL_WANT_LIBLTDL */
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
#endif /* OPAL_WANT_LIBLTDL */
|
||||
}
|
||||
|
||||
OPAL_DECLSPEC const char *opal_lt_dlgetsearchpath(void) {
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
return lt_dlgetsearchpath();
|
||||
#else /* OPAL_WANT_LIBLTDL */
|
||||
return NULL;
|
||||
#endif /* OPAL_WANT_LIBLTDL */
|
||||
}
|
||||
OPAL_DECLSPEC int opal_lt_dlforeachfile(const char *search_path,
|
||||
int (*func) (const char *filename, void *data),
|
||||
void *data) {
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
return lt_dlforeachfile(search_path, func, data);
|
||||
#else /* OPAL_WANT_LIBLTDL */
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
#endif /* OPAL_WANT_LIBLTDL */
|
||||
}
|
||||
|
||||
/* User module loading advisors. */
|
||||
OPAL_DECLSPEC int opal_lt_dladvise_init(opal_lt_dladvise *advise) {
|
||||
#if OPAL_WANT_LIBLTDL && OPAL_HAVE_LTDL_ADVISE
|
||||
*advise = malloc(sizeof(struct opal_lt_dladvise_st));
|
||||
if (NULL == *advise) {
|
||||
return OPAL_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
return lt_dladvise_init(&(*advise)->dladvise);
|
||||
#else /* OPAL_WANT_LIBLTDL */
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
#endif /* OPAL_WANT_LIBLTDL */
|
||||
}
|
||||
|
||||
OPAL_DECLSPEC int opal_lt_dladvise_destroy(opal_lt_dladvise *advise) {
|
||||
#if OPAL_WANT_LIBLTDL && OPAL_HAVE_LTDL_ADVISE
|
||||
int retval = lt_dladvise_destroy(&(*advise)->dladvise);
|
||||
free(*advise);
|
||||
return retval;
|
||||
#else /* OPAL_WANT_LIBLTDL && OPAL_HAVE_LTDL_ADVISE */
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
#endif /* OPAL_WANT_LIBLTDL && OPAL_HAVE_LTDL_ADVISE */
|
||||
}
|
||||
|
||||
OPAL_DECLSPEC int opal_lt_dladvise_ext(opal_lt_dladvise *advise) {
|
||||
#if OPAL_WANT_LIBLTDL && OPAL_HAVE_LTDL_ADVISE
|
||||
assert(advise);
|
||||
return lt_dladvise_ext(&(*advise)->dladvise);
|
||||
#else /* OPAL_WANT_LIBLTDL && OPAL_HAVE_LTDL_ADVISE */
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
#endif /* OPAL_WANT_LIBLTDL && OPAL_HAVE_LTDL_ADVISE */
|
||||
}
|
||||
|
||||
OPAL_DECLSPEC int opal_lt_dladvise_resident(opal_lt_dladvise *advise) {
|
||||
#if OPAL_WANT_LIBLTDL && OPAL_HAVE_LTDL_ADVISE
|
||||
assert(advise);
|
||||
return lt_dladvise_resident(&(*advise)->dladvise);
|
||||
#else /* OPAL_WANT_LIBLTDL && OPAL_HAVE_LTDL_ADVISE */
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
#endif /* OPAL_WANT_LIBLTDL && OPAL_HAVE_LTDL_ADVISE */
|
||||
}
|
||||
|
||||
OPAL_DECLSPEC int opal_lt_dladvise_local(opal_lt_dladvise *advise) {
|
||||
#if OPAL_WANT_LIBLTDL && OPAL_HAVE_LTDL_ADVISE
|
||||
assert(advise);
|
||||
return lt_dladvise_local(&(*advise)->dladvise);
|
||||
#else /* OPAL_WANT_LIBLTDL && OPAL_HAVE_LTDL_ADVISE */
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
#endif /* OPAL_WANT_LIBLTDL && OPAL_HAVE_LTDL_ADVISE */
|
||||
}
|
||||
|
||||
OPAL_DECLSPEC int opal_lt_dladvise_global(opal_lt_dladvise *advise) {
|
||||
#if OPAL_WANT_LIBLTDL && OPAL_HAVE_LTDL_ADVISE
|
||||
assert(advise);
|
||||
return lt_dladvise_global(&(*advise)->dladvise);
|
||||
#else /* OPAL_WANT_LIBLTDL && OPAL_HAVE_LTDL_ADVISE */
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
#endif /* OPAL_WANT_LIBLTDL && OPAL_HAVE_LTDL_ADVISE */
|
||||
}
|
||||
|
||||
OPAL_DECLSPEC int opal_lt_dladvise_preload(opal_lt_dladvise *advise) {
|
||||
#if OPAL_WANT_LIBLTDL && OPAL_HAVE_LTDL_ADVISE
|
||||
assert(advise);
|
||||
return lt_dladvise_preload(&(*advise)->dladvise);
|
||||
#else /* OPAL_WANT_LIBLTDL && OPAL_HAVE_LTDL_ADVISE */
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
#endif /* OPAL_WANT_LIBLTDL && OPAL_HAVE_LTDL_ADVISE */
|
||||
}
|
||||
|
||||
/* Portable libltdl versions of the system dlopen() API. */
|
||||
OPAL_DECLSPEC opal_lt_dlhandle opal_lt_dlopen(const char *filename) {
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
opal_lt_dlhandle handle;
|
||||
handle = malloc(sizeof(struct opal_lt_dlhandle_st));
|
||||
if (NULL == handle) {
|
||||
return NULL;
|
||||
}
|
||||
handle->dlhandle = lt_dlopen(filename);
|
||||
if (NULL == handle->dlhandle) {
|
||||
free(handle);
|
||||
return NULL;
|
||||
}
|
||||
return handle;
|
||||
#else /* OPAL_WANT_LIBLTDL */
|
||||
return NULL;
|
||||
#endif /* OPAL_WANT_LIBLTDL */
|
||||
}
|
||||
|
||||
OPAL_DECLSPEC opal_lt_dlhandle opal_lt_dlopenext(const char *filename) {
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
opal_lt_dlhandle handle;
|
||||
handle = malloc(sizeof(struct opal_lt_dlhandle_st));
|
||||
if (NULL == handle) {
|
||||
return NULL;
|
||||
}
|
||||
handle->dlhandle = lt_dlopenext(filename);
|
||||
if (NULL == handle->dlhandle) {
|
||||
free(handle);
|
||||
return NULL;
|
||||
}
|
||||
return handle;
|
||||
#else /* OPAL_WANT_LIBLTDL */
|
||||
return NULL;
|
||||
#endif /* OPAL_WANT_LIBLTDL */
|
||||
}
|
||||
|
||||
OPAL_DECLSPEC void *opal_lt_dlsym(opal_lt_dlhandle handle, const char *name) {
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
return lt_dlsym(handle->dlhandle, name);
|
||||
#else /* OPAL_WANT_LIBLTDL */
|
||||
return NULL;
|
||||
#endif /* OPAL_WANT_LIBLTDL */
|
||||
}
|
||||
|
||||
OPAL_DECLSPEC const char *opal_lt_dlerror(void) {
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
return lt_dlerror();
|
||||
#else /* OPAL_WANT_LIBLTDL */
|
||||
return NULL;
|
||||
#endif /* OPAL_WANT_LIBLTDL */
|
||||
}
|
||||
|
||||
OPAL_DECLSPEC int opal_lt_dlclose(opal_lt_dlhandle handle) {
|
||||
#if OPAL_WANT_LIBLTDL
|
||||
int retval = lt_dlclose(handle->dlhandle);
|
||||
free(handle);
|
||||
return retval;
|
||||
#else
|
||||
return OPAL_ERR_NOT_SUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
OPAL_DECLSPEC opal_lt_dlhandle opal_lt_dlopenadvise(const char *filename,
|
||||
opal_lt_dladvise advise) {
|
||||
#if OPAL_WANT_LIBLTDL && OPAL_HAVE_LTDL_ADVISE
|
||||
opal_lt_dlhandle handle;
|
||||
handle = malloc(sizeof(struct opal_lt_dlhandle_st));
|
||||
if (NULL == handle) {
|
||||
return NULL;
|
||||
}
|
||||
handle->dlhandle = lt_dlopenadvise(filename, advise->dladvise);
|
||||
if (NULL == handle->dlhandle) {
|
||||
free(handle);
|
||||
return NULL;
|
||||
}
|
||||
return handle;
|
||||
#else /* OPAL_WANT_LIBLTDL && OPAL_HAVE_LTDL_ADVISE */
|
||||
return NULL;
|
||||
#endif /* OPAL_WANT_LIBLTDL && OPAL_HAVE_LTDL_ADVISE */
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2013 NVIDIA Corporation. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Wrappers to LTDL functions so that other parts of library can
|
||||
* access the LTDL functionality that is embedded/linked in to Open
|
||||
* MPI (vs. a LTDL library that was linked in by the application).
|
||||
* The OPAL-linked LTDL library is intentionally not DECLSPEC'ed so
|
||||
* that it is not visible to upper-layer applications; its functions
|
||||
* are provided to the rest of the OMPI code base via the following
|
||||
* OPAL wrappers.
|
||||
* For functions that return int, if there are any failures, these
|
||||
* functions can return both OPAL error codes and LTDL error codes.
|
||||
* If the return code is negative it is OPAL, and if positive it
|
||||
* follows the LTDL convention where the number represents the number
|
||||
* of errors seen. You can then call opal_lt_dlerror() to get more
|
||||
* information when you see a positive error code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create opal_lt_dlhandle and opal_lt_dladvise types so that
|
||||
* consumers of this code can use these opal types rather than the
|
||||
* LTDL versions. In this way, there is no need to include the
|
||||
* underlying ltdl.h here (it is only needed in lt_interface.c) and we
|
||||
* do not need to use the OPAL_WANT_LIBLTDL and OPAL_HAVE_LTDL_ADVISE
|
||||
* macros anywhere else. These types are effectively just pointers to
|
||||
* the underlying LTDL types.
|
||||
*/
|
||||
struct opal_lt_dlhandle_st;
|
||||
typedef struct opal_lt_dlhandle_st* opal_lt_dlhandle;
|
||||
struct opal_lt_dladvise_st;
|
||||
typedef struct opal_lt_dladvise_st* opal_lt_dladvise;
|
||||
|
||||
/**
|
||||
* Wrappers for the ltdl library.
|
||||
*/
|
||||
OPAL_DECLSPEC int opal_lt_dlinit(void);
|
||||
OPAL_DECLSPEC int opal_lt_dlexit(void);
|
||||
|
||||
/* Module search path manipulation. */
|
||||
OPAL_DECLSPEC int opal_lt_dladdsearchdir(const char *search_dir);
|
||||
OPAL_DECLSPEC int opal_lt_dlinsertsearchdir(const char *before,
|
||||
const char *search_dir);
|
||||
OPAL_DECLSPEC int opal_lt_dlsetsearchpath(const char *search_path);
|
||||
OPAL_DECLSPEC const char *opal_lt_dlgetsearchpath(void);
|
||||
OPAL_DECLSPEC int opal_lt_dlforeachfile(const char *search_path,
|
||||
int (*func) (const char *filename, void *data),
|
||||
void *data);
|
||||
/* User module loading advisors. */
|
||||
OPAL_DECLSPEC int opal_lt_dladvise_init(opal_lt_dladvise *advise);
|
||||
OPAL_DECLSPEC int opal_lt_dladvise_destroy(opal_lt_dladvise *advise);
|
||||
OPAL_DECLSPEC int opal_lt_dladvise_ext(opal_lt_dladvise *advise);
|
||||
OPAL_DECLSPEC int opal_lt_dladvise_resident(opal_lt_dladvise *advise);
|
||||
OPAL_DECLSPEC int opal_lt_dladvise_local(opal_lt_dladvise *advise);
|
||||
OPAL_DECLSPEC int opal_lt_dladvise_global(opal_lt_dladvise *advise);
|
||||
OPAL_DECLSPEC int opal_lt_dladvise_preload(opal_lt_dladvise *advise);
|
||||
|
||||
/* Portable libltdl versions of the system dlopen() API. */
|
||||
OPAL_DECLSPEC opal_lt_dlhandle opal_lt_dlopen(const char *filename);
|
||||
OPAL_DECLSPEC opal_lt_dlhandle opal_lt_dlopenext(const char *filename);
|
||||
OPAL_DECLSPEC void *opal_lt_dlsym(opal_lt_dlhandle handle, const char *name);
|
||||
OPAL_DECLSPEC const char *opal_lt_dlerror(void);
|
||||
OPAL_DECLSPEC int opal_lt_dlclose(opal_lt_dlhandle handle);
|
||||
OPAL_DECLSPEC opal_lt_dlhandle opal_lt_dlopenadvise(const char *filename,
|
||||
opal_lt_dladvise advise);
|
@ -339,8 +339,7 @@ void orte_info_do_config(bool want_all)
|
||||
char *memdebug;
|
||||
char *debug;
|
||||
char *threads;
|
||||
char *want_libltdl;
|
||||
char *have_ltdl_advise;
|
||||
char *have_dl;
|
||||
char *orterun_prefix_by_default;
|
||||
char *wtime_support;
|
||||
char *symbol_visibility;
|
||||
@ -351,8 +350,7 @@ void orte_info_do_config(bool want_all)
|
||||
memprofile = OPAL_ENABLE_MEM_PROFILE ? "yes" : "no";
|
||||
memdebug = OPAL_ENABLE_MEM_DEBUG ? "yes" : "no";
|
||||
debug = OPAL_ENABLE_DEBUG ? "yes" : "no";
|
||||
want_libltdl = OPAL_WANT_LIBLTDL ? "yes" : "no";
|
||||
have_ltdl_advise = OPAL_HAVE_LTDL_ADVISE ? "yes" : "no";
|
||||
have_dl = OPAL_HAVE_DL_SUPPORT ? "yes" : "no";
|
||||
orterun_prefix_by_default = ORTE_WANT_ORTERUN_PREFIX_BY_DEFAULT ? "yes" : "no";
|
||||
wtime_support = OPAL_TIMER_USEC_NATIVE ? "native" : "gettimeofday";
|
||||
symbol_visibility = OPAL_C_HAVE_VISIBILITY ? "yes" : "no";
|
||||
@ -423,8 +421,7 @@ void orte_info_do_config(bool want_all)
|
||||
orte_info_out("Internal debug support", "option:debug", debug);
|
||||
orte_info_out("Memory profiling support", "option:mem-profile", memprofile);
|
||||
orte_info_out("Memory debugging support", "option:mem-debug", memdebug);
|
||||
orte_info_out("libltdl support", "option:dlopen", want_libltdl);
|
||||
orte_info_out("lt_dladvise support", "option:lt_dladvise", have_ltdl_advise);
|
||||
orte_info_out("dl support", "option:dlopen", have_dl);
|
||||
orte_info_out("Heterogeneous support", "options:heterogeneous", heterogeneous);
|
||||
orte_info_out("orterun default --prefix", "orterun:prefix_by_default",
|
||||
orterun_prefix_by_default);
|
||||
|
@ -108,8 +108,7 @@ void oshmem_info_do_config(bool want_all)
|
||||
char *fortran_usempif08_profiling;
|
||||
char *cxxexceptions;
|
||||
char *threads;
|
||||
char *want_libltdl;
|
||||
char *have_ltdl_advise;
|
||||
char *have_dl;
|
||||
#if OMPI_RTE_ORTE
|
||||
char *mpirun_prefix_by_default;
|
||||
#endif
|
||||
@ -234,8 +233,7 @@ void oshmem_info_do_config(bool want_all)
|
||||
fortran_mpifh_profiling = (OMPI_ENABLE_MPI_PROFILING && OMPI_BUILD_FORTRAN_MPIFH_BINDINGS) ? "yes" : "no";
|
||||
fortran_usempi_profiling = (OMPI_ENABLE_MPI_PROFILING && OMPI_BUILD_FORTRAN_USEMPI_BINDINGS) ? "yes" : "no";
|
||||
fortran_usempif08_profiling = (OMPI_ENABLE_MPI_PROFILING && OMPI_BUILD_FORTRAN_USEMPIF08_BINDINGS) ? "yes" : "no";
|
||||
want_libltdl = OPAL_WANT_LIBLTDL ? "yes" : "no";
|
||||
have_ltdl_advise = OPAL_HAVE_LTDL_ADVISE ? "yes" : "no";
|
||||
have_dl = OPAL_HAVE_DL_SUPPORT ? "yes" : "no";
|
||||
#if OMPI_RTE_ORTE
|
||||
mpirun_prefix_by_default = ORTE_WANT_ORTERUN_PREFIX_BY_DEFAULT ? "yes" : "no";
|
||||
#endif
|
||||
@ -568,8 +566,7 @@ void oshmem_info_do_config(bool want_all)
|
||||
opal_info_out("MPI parameter check", "option:mpi-param-check", paramcheck);
|
||||
opal_info_out("Memory profiling support", "option:mem-profile", memprofile);
|
||||
opal_info_out("Memory debugging support", "option:mem-debug", memdebug);
|
||||
opal_info_out("libltdl support", "option:dlopen", want_libltdl);
|
||||
opal_info_out("lt_dladvise support", "option:lt_dladvise", have_ltdl_advise);
|
||||
opal_info_out("dl support", "option:dlopen", have_dl);
|
||||
opal_info_out("Heterogeneous support", "options:heterogeneous", heterogeneous);
|
||||
#if OMPI_RTE_ORTE
|
||||
opal_info_out("mpirun default --prefix", "mpirun:prefix_by_default",
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user