Generate nccl.h in build instead of src

Generating nccl.h in src makes source directories dirty after builds.
This commit is contained in:
Sylvain Jeaugey 2018-11-09 14:00:41 -08:00 committed by GitHub
parent 21d9a877be
commit 3c6e25210b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View File

@ -41,15 +41,16 @@ lib : $(INCTARGETS) $(LIBDIR)/$(LIBTARGET)
staticlib : $(LIBDIR)/$(STATICLIBTARGET) staticlib : $(LIBDIR)/$(STATICLIBTARGET)
devicelib: nccl.h devicelib: $(INCDIR)/nccl.h
$(MAKE) -C collectives/device $(MAKE) -C collectives/device
-include $(DEPFILES) -include $(DEPFILES)
$(LIBDIR)/$(LIBTARGET) $(LIBDIR)/$(STATICLIBTARGET) : $(LIBOBJ) $(LIBDIR)/$(LIBTARGET) $(LIBDIR)/$(STATICLIBTARGET) : $(LIBOBJ)
nccl.h : nccl.h.in $(INCDIR)/nccl.h : nccl.h.in
# NCCL_VERSION(X,Y,Z) ((X) * 1000 + (Y) * 100 + (Z)) # NCCL_VERSION(X,Y,Z) ((X) * 1000 + (Y) * 100 + (Z))
@$(eval NCCL_VERSION := $(shell printf "%d%d%02d" $(NCCL_MAJOR) $(NCCL_MINOR) $(NCCL_PATCH))) @$(eval NCCL_VERSION := $(shell printf "%d%d%02d" $(NCCL_MAJOR) $(NCCL_MINOR) $(NCCL_PATCH)))
mkdir -p $(INCDIR)
printf "Generating %-35s > %s\n" $< $@ printf "Generating %-35s > %s\n" $< $@
sed -e "s/\$${nccl:Major}/$(NCCL_MAJOR)/g" \ sed -e "s/\$${nccl:Major}/$(NCCL_MAJOR)/g" \
-e "s/\$${nccl:Minor}/$(NCCL_MINOR)/g" \ -e "s/\$${nccl:Minor}/$(NCCL_MINOR)/g" \
@ -82,15 +83,15 @@ $(INCDIR)/%.h : %.h
$(OBJDIR)/%.o : %.cu $(OBJDIR)/%.o : %.cu
@printf "Compiling %-35s > %s\n" $< $@ @printf "Compiling %-35s > %s\n" $< $@
mkdir -p `dirname $@` mkdir -p `dirname $@`
$(NVCC) -I. -Iinclude -c $(NVCUFLAGS) --compiler-options "$(CXXFLAGS)" $< -o $@ $(NVCC) -I. -I$(INCDIR) -Iinclude -c $(NVCUFLAGS) --compiler-options "$(CXXFLAGS)" $< -o $@
@$(NVCC) -I. -Iinclude -M $(NVCUFLAGS) --compiler-options "$(CXXFLAGS)" $< > $(@:%.o=%.d.tmp) @$(NVCC) -I. -I$(INCDIR) -Iinclude -M $(NVCUFLAGS) --compiler-options "$(CXXFLAGS)" $< > $(@:%.o=%.d.tmp)
@sed "0,/^.*:/s//$(subst /,\/,$@):/" $(@:%.o=%.d.tmp) > $(@:%.o=%.d) @sed "0,/^.*:/s//$(subst /,\/,$@):/" $(@:%.o=%.d.tmp) > $(@:%.o=%.d)
@sed -e 's/.*://' -e 's/\\$$//' < $(@:%.o=%.d.tmp) | fmt -1 | \ @sed -e 's/.*://' -e 's/\\$$//' < $(@:%.o=%.d.tmp) | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> $(@:%.o=%.d) sed -e 's/^ *//' -e 's/$$/:/' >> $(@:%.o=%.d)
@rm -f $(@:%.o=%.d.tmp) @rm -f $(@:%.o=%.d.tmp)
clean : clean :
rm -rf ${INCDIR} ${LIBDIR} ${OBJDIR} nccl.h rm -rf ${INCDIR} ${LIBDIR} ${OBJDIR}
$(MAKE) -C collectives/device clean $(MAKE) -C collectives/device clean
install : lib install : lib

View File

@ -25,7 +25,7 @@ DEPENDFILES := $(DEPFILES:%.d=%.dep)
STATICLIB := $(OBJDIR)/colldevice.a STATICLIB := $(OBJDIR)/colldevice.a
DEVOBJ := $(OBJDIR)/devlink.o DEVOBJ := $(OBJDIR)/devlink.o
NVCUFLAGS += -I. -I.. -I../.. -I../../include --compiler-options "-fPIC -fvisibility=hidden" NVCUFLAGS += -I. -I.. -I$(BUILDDIR)/include -I../../include --compiler-options "-fPIC -fvisibility=hidden"
all: $(STATICLIB) all: $(STATICLIB)