1
1

It turns out that we can't always include the hwloc OpenFabrics verbs

helper file, even if we find that the system has <infiniband/verbs.h>.
The reason is because there are some inline functions in that verbs
helper file that invoke ibv_* functions.  Some linkers (e.g., Solaris
Studio Compilers) will instantiate those static inline functions --
even if we don't use them -- and therefore we need to be able to
resolve the ibv_* symbols at link time.

But since -libverbs is only specified in places where we use other
ibv_* functions (e.g., the OpenFabrics-based BTLs), that means that
linking random executables can/will fail (e.g., orterun).

So instead, introduce a new #define: OPAL_HWLOC_WANT_VERBS_HELPER.  If
this macro is set to 1 before including opal/mca/hwloc/hwloc.h, then
you'll also get the hwloc OpenFabrics verbs helper header file (*if*
hwloc found <infiniband/verbs.h> -- otherwise, it'll #error).

This commit was SVN r26417.
Этот коммит содержится в:
Jeff Squyres 2012-05-09 20:18:31 +00:00
родитель 640f0610aa
Коммит de4bbacd13
2 изменённых файлов: 24 добавлений и 4 удалений

Просмотреть файл

@ -60,6 +60,12 @@ const char *ibv_get_sysfs_path(void);
#include "opal/util/argv.h"
#include "opal/memoryhooks/memory.h"
#include "opal/mca/base/mca_base_param.h"
/* Define this before including hwloc.h so that we also get the hwloc
verbs helper header file, too. We have to do this level of
indirection because the hwloc subsystem is a component -- we don't
know its exact path. We have to rely on the framework header files
to find the right hwloc verbs helper file for us. */
#define OPAL_HWLOC_WANT_VERBS_HELPER 1
#include "opal/mca/hwloc/hwloc.h"
#include "opal/mca/hwloc/base/base.h"
#include "opal/mca/installdirs/installdirs.h"

Просмотреть файл

@ -19,10 +19,24 @@ BEGIN_C_DECLS
#include "hwloc/include/hwloc.h"
/* If we have verbs.h, then include the hwloc openfabrics helpers
header file */
#if defined(HAVE_INFINIBAND_VERBS_H)
#include "hwloc/include/hwloc/openfabrics-verbs.h"
/* If the including file requested it, also include the hwloc verbs
helper file. We can't just always include this file (even if we
know we have <infiniband/verbs.h>) because there are some inline
functions in that file that invoke ibv_* functions. Some linkers
(e.g., Solaris Studio Compilers) will instantiate those static
inline functions even if we don't use them, and therefore we need
to be able to resolve the ibv_* symbols at link time.
Since -libverbs is only specified in places where we use other
ibv_* functions (e.g., the OpenFabrics-based BTLs), that means that
linking random executables can/will fail (e.g., orterun).
*/
#if defined(OPAL_HWLOC_WANT_VERBS_HELPER) && OPAL_HWLOC_WANT_VERBS_HELPER
# if defined(HAVE_INFINIBAND_VERBS_H)
# include "hwloc/include/hwloc/openfabrics-verbs.h"
# else
# error Tried to include hwloc verbs helper file, but hwloc was compiled with no OpenFabrics support
# endif
#endif
END_C_DECLS