2017-08-08 16:18:34 -07:00
|
|
|
#
|
2019-03-06 18:17:20 -08:00
|
|
|
# Copyright (c) 2015-2019, NVIDIA CORPORATION. All rights reserved.
|
2017-08-08 16:18:34 -07:00
|
|
|
#
|
2019-03-06 18:17:20 -08:00
|
|
|
# See LICENSE.txt for license information
|
2017-08-08 16:18:34 -07:00
|
|
|
#
|
|
|
|
|
|
|
|
|
|
CUDA_HOME ?= /usr/local/cuda
|
|
|
|
|
PREFIX ?= /usr/local
|
|
|
|
|
VERBOSE ?= 0
|
|
|
|
|
DEBUG ?= 0
|
|
|
|
|
|
|
|
|
|
CUDA_LIB ?= $(CUDA_HOME)/lib64
|
|
|
|
|
CUDA_INC ?= $(CUDA_HOME)/include
|
|
|
|
|
NVCC = $(CUDA_HOME)/bin/nvcc
|
|
|
|
|
|
|
|
|
|
# Better define NVCC_GENCODE in your environment to the minimal set
|
|
|
|
|
# of archs to reduce compile time.
|
|
|
|
|
NVCC_GENCODE ?= -gencode=arch=compute_30,code=sm_30 \
|
|
|
|
|
-gencode=arch=compute_35,code=sm_35 \
|
|
|
|
|
-gencode=arch=compute_50,code=sm_50 \
|
2019-03-06 18:17:20 -08:00
|
|
|
-gencode=arch=compute_60,code=sm_60 \
|
2017-08-08 16:18:34 -07:00
|
|
|
-gencode=arch=compute_61,code=sm_61 \
|
2019-03-06 18:17:20 -08:00
|
|
|
-gencode=arch=compute_70,code=compute_70 \
|
|
|
|
|
-gencode=arch=compute_70,code=sm_70
|
2017-08-08 16:18:34 -07:00
|
|
|
|
|
|
|
|
NVCUFLAGS := -ccbin $(CXX) $(NVCC_GENCODE) -std=c++11
|
|
|
|
|
|
|
|
|
|
LDFLAGS := -L${CUDA_LIB} -lcudart -lrt
|
|
|
|
|
NVLDFLAGS := -L${CUDA_LIB} -lcudart -lrt
|
|
|
|
|
|
|
|
|
|
ifeq ($(DEBUG), 0)
|
2019-03-06 18:17:20 -08:00
|
|
|
NVCUFLAGS += -O3 -g
|
|
|
|
|
CXXFLAGS += -O3 -g
|
2017-08-08 16:18:34 -07:00
|
|
|
else
|
|
|
|
|
NVCUFLAGS += -O0 -G -g
|
|
|
|
|
CXXFLAGS += -O0 -g -ggdb3
|
|
|
|
|
endif
|
|
|
|
|
|
2019-03-06 18:17:20 -08:00
|
|
|
ifneq ($(VERBOSE), 0)
|
|
|
|
|
NVCUFLAGS += -Xcompiler -Wall,-Wextra,-Wno-unused-parameter
|
|
|
|
|
else
|
2017-08-08 16:18:34 -07:00
|
|
|
.SILENT:
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
.PHONY: build clean
|
|
|
|
|
|
|
|
|
|
BUILDDIR ?= ../build
|
2017-08-09 10:41:31 -07:00
|
|
|
ifneq ($(NCCL_HOME), "")
|
|
|
|
|
NVCUFLAGS += -I$(NCCL_HOME)/include/
|
2019-03-06 18:17:20 -08:00
|
|
|
NVLDFLAGS += -L$(NCCL_HOME)/lib
|
2017-08-08 16:18:34 -07:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
ifeq ($(MPI), 1)
|
|
|
|
|
NVCUFLAGS += -DMPI_SUPPORT -I$(MPI_HOME)/include
|
|
|
|
|
NVLDFLAGS += -L$(MPI_HOME)/lib -lmpi
|
|
|
|
|
endif
|
|
|
|
|
LIBRARIES += curand nccl nvToolsExt
|
2019-03-06 18:17:20 -08:00
|
|
|
NVLDFLAGS += $(LIBRARIES:%=-l%)
|
2017-08-08 16:18:34 -07:00
|
|
|
|
|
|
|
|
DST_DIR := $(BUILDDIR)
|
|
|
|
|
SRC_FILES := $(wildcard *.cu)
|
|
|
|
|
OBJ_FILES := $(SRC_FILES:%.cu=${DST_DIR}/%.o)
|
|
|
|
|
BIN_FILES_LIST := all_reduce all_gather broadcast reduce_scatter reduce
|
|
|
|
|
BIN_FILES := $(BIN_FILES_LIST:%=${DST_DIR}/%_perf)
|
|
|
|
|
|
|
|
|
|
build: ${BIN_FILES}
|
|
|
|
|
|
|
|
|
|
clean:
|
|
|
|
|
rm -rf ${DST_DIR}
|
|
|
|
|
|
2019-03-06 18:17:20 -08:00
|
|
|
${DST_DIR}/%.o: %.cu common.h
|
2017-08-08 16:18:34 -07:00
|
|
|
@printf "Compiling %-35s > %s\n" $< $@
|
|
|
|
|
@mkdir -p ${DST_DIR}
|
|
|
|
|
$(NVCC) -o $@ $(NVCUFLAGS) -c $<
|
|
|
|
|
|
|
|
|
|
${DST_DIR}/%_perf:${DST_DIR}/%.o ${DST_DIR}/common.o
|
|
|
|
|
@printf "Linking %-35s > %s\n" $< $@
|
|
|
|
|
@mkdir -p ${DST_DIR}
|
|
|
|
|
$(NVCC) -o $@ $(NVCUFLAGS) $^ ${NVLDFLAGS}
|
|
|
|
|
|