@@ -38,6 +38,18 @@ COMPONENT_DIRS = $(cl_dirs) $(mc_dirs) $(ec_dirs) $(topo_dirs)
3838
3939include components/tl/makefile.am
4040
41+ # Kernel-only subdirectories whose .cu compilation can overlap with libucc.la.
42+ # NVCC only needs headers (source tree + config.h from configure), so there is
43+ # no build-time dependency on the compiled core library. The final link of the
44+ # parent component (libucc_ec_cuda.la, etc.) still waits for libucc.la below.
45+ early_cuda_kernel_dirs =
46+ if HAVE_CUDA
47+ early_cuda_kernel_dirs += components/ec/cuda/kernel
48+ endif
49+ if TL_CUDA_NVLS_ENABLED
50+ early_cuda_kernel_dirs += components/tl/cuda/kernels
51+ endif
52+
4153# All possible component subdirectories (including conditional ones)
4254# needed for make dist to find all source files.
4355DIST_SUBDIRS = . \
@@ -60,10 +72,25 @@ DIST_SUBDIRS = . \
6072 components/topo/cuda \
6173 components/topo/ib
6274
63- all-local : $(COMPONENT_DIRS:%=all-component/% )
75+ all-local : $(early_cuda_kernel_dirs:%=compile-kernels/% ) $(COMPONENT_DIRS:%=all-component/% )
76+
77+ # Start CUDA kernel compilation immediately (no libucc.la dependency).
78+ compile-kernels/% :
79+ +$(MAKE ) -C $* all
80+
81+ # Components wait for libucc.la before linking.
6482all-component/% : libucc.la
6583 +$(MAKE ) -C $* all
6684
85+ # Components that contain CUDA kernels must also wait for the early kernel
86+ # compilation to finish, so two make processes never run in the same directory.
87+ if HAVE_CUDA
88+ all-component/components/ec/cuda : compile-kernels/components/ec/cuda/kernel
89+ endif
90+ if TL_CUDA_NVLS_ENABLED
91+ all-component/components/tl/cuda : compile-kernels/components/tl/cuda/kernels
92+ endif
93+
6794# Component installs must wait for libucc.la to be installed to the prefix
6895# first, otherwise libtool relinking fails with "cannot find -lucc".
6996install-exec-local : install-libLTLIBRARIES $(COMPONENT_DIRS:%=install-component/% )
0 commit comments