Skip to content

Commit

Permalink
build for specific gpu architectures
Browse files Browse the repository at this point in the history
  • Loading branch information
Dando18 committed Feb 15, 2019
1 parent e5fb7bb commit ae61514
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
42 changes: 42 additions & 0 deletions make.device
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# make.device
# add gpu specific compilation flags


ifneq ($(findstring Kepler, $(GPU_TARGET)),)
MIN_ARCH ?= 300
NV_SM += -gencode arch=compute_30,code=sm_30
NV_SM += -gencode arch=compute_35,code=sm_35
NV_COMP := -gencode arch=compute_35,code=compute_35
endif

ifneq ($(findstring Maxwell, $(GPU_TARGET)),)
MIN_ARCH ?= 500
NV_SM += -gencode arch=compute_50,code=sm_50
NV_SM += -gencode arch=compute_52,code=sm_52
NV_COMP := -gencode arch=compute_52,code=compute_52
endif

ifneq ($(findstring Pascal, $(GPU_TARGET)),)
MIN_ARCH ?= 600
NV_SM += -gencode arch=compute_60,code=sm_60
NV_SM += -gencode arch=compute_61,code=sm_61
NV_COMP := -gencode arch=compute_61,code=compute_61
endif

ifneq ($(findstring Volta, $(GPU_TARGET)),)
MIN_ARCH ?= 700
NV_SM += -gencode arch=compute_70,code=sm_70
NV_COMP := -gencode arch=compute_70,code=compute_70
endif

ifneq ($(findstring Tesla, $(GPU_TARGET)),)
MIN_ARCH ?= 750
NV_SM += -gencode arch=compute_75,code=sm_75
NV_COMP := -gencode arch=compute_75,code=compute_75
endif


ifeq ($(NV_COMP),)
$(error GPU_TARGET, is $(GPU_TARGET), must contain one or more of Kepler, Maxwell, Pascal, Volta, and Tesla)
endif

3 changes: 2 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ LIBS =
# use nvcc to determine if we should compile for gpu or not
USE_CUDA = 0
ifneq ($(shell which nvcc),)
include make.device
CUDA_MACRO = -D_HAS_CUDA_
INC += -I$(CUDADIR)/include
LIBDIRS += -L$(CUDADIR)/lib64
Expand All @@ -40,7 +41,7 @@ CXX_VERSION ?= -std=c++11

# the entire flags for compilation
CXXFLAGS := $(OPTIMIZATION_LEVEL) $(WARNINGS) $(CXX_VERSION) $(CUDA_MACRO) $(FPIC) -MMD
NVCCFLAGS := $(CXX_VERSION) $(OPTIMIZATION_LEVEL) -Xcompiler "$(CXXFLAGS)"
NVCCFLAGS := $(CXX_VERSION) $(OPTIMIZATION_LEVEL) -Xcompiler "$(CXXFLAGS)" $(NV_SM) $(NV_COMP)


# make these available to child makefiles
Expand Down

0 comments on commit ae61514

Please sign in to comment.