Skip to content

Commit 12e99bc

Browse files
committed
Makefile to support CUDA 10.x and CUDA 11 both
1 parent 0bee8c0 commit 12e99bc

File tree

54 files changed

+329
-60
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+329
-60
lines changed

Chapter01/01_cuda_introduction/01_hello_world/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ TARGET=hello_world
66
INCLUDES= -I${CUDA_PATH}/samples/common/inc
77
NVCC_FLAGS=-m64 -lineinfo
88

9+
IS_CUDA_11:=$(shell echo `nvcc --version | grep compilation | grep -Eo -m 1 '[0-9]+.[0-9]' | head -1` \>= 11.0 | bc)
10+
911
# Gencode argumentes
10-
SMS = 30 35 37 50 52 60 61 70
12+
SMS = 35 37 50 52 60 61 70 75
13+
ifeq "$(IS_CUDA_11)" "1"
14+
SMS = 52 60 61 70 75 80
15+
endif
1116
$(foreach sm, ${SMS}, $(eval GENCODE_FLAGS += -gencode arch=compute_$(sm),code=sm_$(sm)))
1217

1318
hello_world: hello_world.cu

Chapter01/01_cuda_introduction/02_vector_addition/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ TARGET=vector_addition vector_addition_blocks vector_addition_threads vector_add
66
INCLUDES= -I${CUDA_PATH}/samples/common/inc
77
NVCC_FLAGS=-m64 -lineinfo
88

9+
IS_CUDA_11:=$(shell echo `nvcc --version | grep compilation | grep -Eo -m 1 '[0-9]+.[0-9]' | head -1` \>= 11.0 | bc)
10+
911
# Gencode argumentes
10-
SMS = 30 35 37 50 52 60 61 70
12+
SMS = 35 37 50 52 60 61 70 75
13+
ifeq "$(IS_CUDA_11)" "1"
14+
SMS = 52 60 61 70 75 80
15+
endif
1116
$(foreach sm, ${SMS}, $(eval GENCODE_FLAGS += -gencode arch=compute_$(sm),code=sm_$(sm)))
1217

1318
all : ${TARGET}

Chapter02/02_memory_overview/01_sgemm/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ TARGET=sgemm
66
INCLUDES= -I${CUDA_PATH}/samples/common/inc
77
NVCC_FLAGS=-m64 -lineinfo
88

9+
IS_CUDA_11:=$(shell echo `nvcc --version | grep compilation | grep -Eo -m 1 '[0-9]+.[0-9]' | head -1` \>= 11.0 | bc)
10+
911
# Gencode argumentes
10-
SMS = 30 35 37 50 52 60 61 70
12+
SMS = 35 37 50 52 60 61 70 75
13+
ifeq "$(IS_CUDA_11)" "1"
14+
SMS = 52 60 61 70 75 80
15+
endif
1116
$(foreach sm, ${SMS}, $(eval GENCODE_FLAGS += -gencode arch=compute_$(sm),code=sm_$(sm)))
1217

1318
all : ${TARGET}

Chapter02/02_memory_overview/02_vector_addition/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ TARGET=vec_addition
66
INCLUDES= -I${CUDA_PATH}/samples/common/inc
77
NVCC_FLAGS=-m64 -lineinfo
88

9+
IS_CUDA_11:=$(shell echo `nvcc --version | grep compilation | grep -Eo -m 1 '[0-9]+.[0-9]' | head -1` \>= 11.0 | bc)
10+
911
# Gencode argumentes
10-
SMS = 30 35 37 50 52 60 61 70
12+
SMS = 35 37 50 52 60 61 70 75
13+
ifeq "$(IS_CUDA_11)" "1"
14+
SMS = 52 60 61 70 75 80
15+
endif
1116
$(foreach sm, ${SMS}, $(eval GENCODE_FLAGS += -gencode arch=compute_$(sm),code=sm_$(sm)))
1217

1318
all : ${TARGET}

Chapter02/02_memory_overview/03_aos_soa/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ TARGET=aos_soa aos_soa_solved
66
INCLUDES= -I${CUDA_PATH}/samples/common/inc
77
NVCC_FLAGS=-m64 -lineinfo
88

9+
IS_CUDA_11:=$(shell echo `nvcc --version | grep compilation | grep -Eo -m 1 '[0-9]+.[0-9]' | head -1` \>= 11.0 | bc)
10+
911
# Gencode argumentes
10-
SMS = 30 35 37 50 52 60 61 70
12+
SMS = 35 37 50 52 60 61 70 75
13+
ifeq "$(IS_CUDA_11)" "1"
14+
SMS = 52 60 61 70 75 80
15+
endif
1116
$(foreach sm, ${SMS}, $(eval GENCODE_FLAGS += -gencode arch=compute_$(sm),code=sm_$(sm)))
1217

1318
all : ${TARGET}

Chapter02/02_memory_overview/04_matrix_transpose/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ TARGET=matrix_transpose conflict_solved
66
INCLUDES= -I${CUDA_PATH}/samples/common/inc
77
NVCC_FLAGS=-m64 -lineinfo
88

9+
IS_CUDA_11:=$(shell echo `nvcc --version | grep compilation | grep -Eo -m 1 '[0-9]+.[0-9]' | head -1` \>= 11.0 | bc)
10+
911
# Gencode argumentes
10-
SMS = 30 35 37 50 52 60 61 70
12+
SMS = 35 37 50 52 60 61 70 75
13+
ifeq "$(IS_CUDA_11)" "1"
14+
SMS = 52 60 61 70 75 80
15+
endif
1116
$(foreach sm, ${SMS}, $(eval GENCODE_FLAGS += -gencode arch=compute_$(sm),code=sm_$(sm)))
1217

1318
all : ${TARGET}

Chapter02/02_memory_overview/05_image_scaling/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ TARGET=image_scaling
66
INCLUDES= -I${CUDA_PATH}/samples/common/inc
77
NVCC_FLAGS=-m64 -lineinfo
88

9+
IS_CUDA_11:=$(shell echo `nvcc --version | grep compilation | grep -Eo -m 1 '[0-9]+.[0-9]' | head -1` \>= 11.0 | bc)
10+
911
# Gencode argumentes
10-
SMS = 30 35 37 50 52 60 61 70
12+
SMS = 35 37 50 52 60 61 70 75
13+
ifeq "$(IS_CUDA_11)" "1"
14+
SMS = 52 60 61 70 75 80
15+
endif
1116
$(foreach sm, ${SMS}, $(eval GENCODE_FLAGS += -gencode arch=compute_$(sm),code=sm_$(sm)))
1217

1318
all : ${TARGET}

Chapter02/02_memory_overview/06_unified_memory/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ TARGET=unified_simple unified_initialized unified_prefetch unified_64align
66
INCLUDES= -I${CUDA_PATH}/samples/common/inc
77
NVCC_FLAGS=-m64 -lineinfo
88

9+
IS_CUDA_11:=$(shell echo `nvcc --version | grep compilation | grep -Eo -m 1 '[0-9]+.[0-9]' | head -1` \>= 11.0 | bc)
10+
911
# Gencode argumentes
10-
SMS = 30 35 37 50 52 60 61 70
12+
SMS = 35 37 50 52 60 61 70 75
13+
ifeq "$(IS_CUDA_11)" "1"
14+
SMS = 52 60 61 70 75 80
15+
endif
1116
$(foreach sm, ${SMS}, $(eval GENCODE_FLAGS += -gencode arch=compute_$(sm),code=sm_$(sm)))
1217

1318
all : ${TARGET}

Chapter03/03_cuda_thread_programming/01_warp_and_thread_block/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ NVCC=${CUDA_PATH}/bin/nvcc -ccbin ${HOST_COMPILER}
55
INCLUDES= -I${CUDA_PATH}/samples/common/inc
66
NVCC_FLAGS=-m64 -lineinfo
77

8+
IS_CUDA_11:=$(shell echo `nvcc --version | grep compilation | grep -Eo -m 1 '[0-9]+.[0-9]' | head -1` \>= 11.0 | bc)
9+
810
# Gencode argumentes
9-
SMS = 30 35 37 50 52 60 61 70
11+
SMS = 35 37 50 52 60 61 70 75
12+
ifeq "$(IS_CUDA_11)" "1"
13+
SMS = 52 60 61 70 75 80
14+
endif
1015
$(foreach sm, ${SMS}, $(eval GENCODE_FLAGS += -gencode arch=compute_$(sm),code=sm_$(sm)))
1116

1217
cuda_thread_block: cuda_thread_block.cu

Chapter03/03_cuda_thread_programming/02_cuda_occupancy/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ TARGET=sgemm
66
INCLUDES = -I${CUDA_PATH}/samples/common/inc
77
NVCC_FLAGS=-m64 -lineinfo --resource-usage
88

9+
IS_CUDA_11:=$(shell echo `nvcc --version | grep compilation | grep -Eo -m 1 '[0-9]+.[0-9]' | head -1` \>= 11.0 | bc)
10+
911
# Gencode argumentes
10-
SMS = 30 35 37 50 52 60 61 70
12+
SMS = 35 37 50 52 60 61 70 75
13+
ifeq "$(IS_CUDA_11)" "1"
14+
SMS = 52 60 61 70 75 80
15+
endif
1116
$(foreach sm, ${SMS}, $(eval GENCODE_FLAGS += -gencode arch=compute_$(sm),code=sm_$(sm)))
1217

1318
all: ${TARGET}

0 commit comments

Comments
 (0)