Skip to content

Commit

Permalink
Build plugins as DSOs instead of shared libraries
Browse files Browse the repository at this point in the history
Build the plugins (tuner and net) as DSOs instead of shared libraries
by adding the `-module -avoid-version` flags to the library LDFLAGS.

Of course, now that the net plugin is not a shared library, we can't
link against it in the tests.  Rather than build a bunch of
infrastructure to dlopen() the net plugin (which would mean all
kinds of fun path work to make "make check" work), build the net
plugin by creating a helper library that contains all the source,
and building the net plugin from that.  Now the helper library
can be used to static link the plugin into the tests (both
functional and unit).

Signed-off-by: Brian Barrett <[email protected]>
  • Loading branch information
bwbarrett committed Apr 5, 2024
1 parent fa8173b commit f83ae77
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
34 changes: 30 additions & 4 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

AM_CPPFLAGS = -I$(top_srcdir)/include -DXML_DIR=\"${pkgdatadir}/xml\"

#
# net plugin
#

sources = \
nccl_ofi_api.c \
nccl_ofi_net.c \
Expand All @@ -25,21 +29,43 @@ sources += platform-aws.c
endif

if ENABLE_NEURON
lib_LTLIBRARIES = libnccom-net.la
sources += nccl_ofi_interface_neuron.c
libnccom_net_la_SOURCES = $(sources)
else
lib_LTLIBRARIES = libnccl-net.la
sources += nccl_ofi_cuda.c \
nccl_ofi_interface_nvidia.c
libnccl_net_la_SOURCES = $(sources)
endif

# Build an internal-only library that can be used by unit tests as
# well as the actual nccl_net.so / nccom_net.so libraries. This saves
# us writing dlopen() handlers for simple unit tests.
noinst_LTLIBRARIES = internal_net_plugin.la
internal_net_plugin_la_SOURCES = $(sources)
internal_net_plugin_la_LDFLAGS = -module -avoid-version

if ENABLE_NEURON
lib_LTLIBRARIES = libnccom-net.la
libnccom_net_la_SOURCES =
libnccom_net_la_LIBADD = internal_net_plugin.la
libnccom_net_la_LDFLAGS = -module -avoid-version
else
lib_LTLIBRARIES = libnccl-net.la
libnccl_net_la_SOURCES =
libnccl_net_la_LIBADD = internal_net_plugin.la
libnccl_net_la_LDFLAGS = -module -avoid-version
endif


#
# Tuner
#
if HAVE_CUDA
if WANT_PLATFORM_AWS
# NCCL tuner plugin
lib_LTLIBRARIES += libnccl-ofi-tuner.la
tuner_sources = \
tuner/nccl_ofi_model.c \
tuner/nccl_ofi_tuner.c
libnccl_ofi_tuner_la_SOURCES = $(tuner_sources)
libnccl_ofi_tuner_la_LDFLAGS = -module -avoid-version
endif
endif
4 changes: 2 additions & 2 deletions tests/functional/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

AM_CPPFLAGS = -I$(top_srcdir)/include $(MPI_CPPFLAGS)
AM_LDFLAGS = $(MPI_LDFLAGS) $(CUDA_LDFLAGS)
LDADD = $(top_builddir)/src/libnccl-net.la $(MPI_LIBS) $(CUDA_LIBS)
LDADD = $(top_builddir)/src/internal_net_plugin.la $(MPI_LIBS) $(CUDA_LIBS)
CC = $(MPICC)

noinst_HEADERS = test-common.h
Expand All @@ -25,4 +25,4 @@ cuda_check_SOURCES = cuda_check.c
# Override the LDADD for this check to avoid the -lcudart used by the
# other tests, since the purpose of this test is to make sure we
# didn't leak direct cuda dependencies into the plugin.
cuda_check_LDADD = $(top_builddir)/src/libnccl-net.la
cuda_check_LDADD = $(top_builddir)/src/internal_net_plugin.la
2 changes: 1 addition & 1 deletion tests/unit/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#

AM_CPPFLAGS = -I$(top_srcdir)/include
LDADD = $(top_builddir)/src/lib$(OFI_NCCL_ARCHIVE).la
LDADD = $(top_builddir)/src/internal_net_plugin.la

noinst_HEADERS = test-common.h

Expand Down

0 comments on commit f83ae77

Please sign in to comment.