Skip to content

Commit

Permalink
Fix which patch to apply where... the filestructure was restructured …
Browse files Browse the repository at this point in the history
…in the CUDA sources starting at 11.6
  • Loading branch information
casparl committed Jul 29, 2024
1 parent 988d69a commit 238ce2c
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ toolchain = {'name': 'GCC', 'version': '10.3.0'}

source_urls = ['https://github.com/NVIDIA/cuda-samples/archive/']
sources = ['v%(version)s.tar.gz']
patches = ['cuda-samples-11.X_multiple-sms.patch']
patches = ['cuda-samples-11.3_multiple-sms.patch']
checksums = ['2bee5f7c89347259aaab75aa6df6e10375059bdbbaf04cc7936f5db7d54fa3ac']

dependencies = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ toolchain = {'name': 'GCC', 'version': '11.3.0'}

source_urls = ['https://github.com/NVIDIA/cuda-samples/archive/']
sources = ['v%(version)s.tar.gz']
patches = ['cuda-samples-11.X_multiple-sms.patch']
patches = ['cuda-samples-11.6_multiple-sms.patch']
checksums = ['75b858bcf9e534eaa0f129c418e661b83872d743de218df8a5278cc429f9ea98']

dependencies = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ toolchain = {'name': 'GCC', 'version': '11.3.0'}

source_urls = ['https://github.com/NVIDIA/cuda-samples/archive/']
sources = ['v%(version)s.tar.gz']
patches = ['cuda-samples-11.X_multiple-sms.patch']
patches = ['cuda-samples-11.6_multiple-sms.patch']
checksums = ['1bc02c0ca42a323f3c7a05b5682eae703681a91e95b135bfe81f848b2d6a2c51']

dependencies = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ toolchain = {'name': 'GCC', 'version': '12.3.0'}

source_urls = ['https://github.com/NVIDIA/cuda-samples/archive/']
sources = ['v%(version)s.tar.gz']
patches = ['cuda-samples-12.X_multiple-sms.patch']
patches = ['cuda-samples-11.6_multiple-sms.patch']
checksums = ['f758160645b366d79c2638d8dfd389f01029b8d179ab0c11726b9ef58aecebd9']

dependencies = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ toolchain = {'name': 'GCC', 'version': '11.3.0'}

source_urls = ['https://github.com/NVIDIA/cuda-samples/archive/']
sources = ['v%(version)s.tar.gz']
patches = ['cuda-samples-12.X_multiple-sms.patch']
patches = ['cuda-samples-11.6_multiple-sms.patch']
checksums = ['c9fbdee420fd4567edb1239420e2a5c93d9652b4ccf3a828fcb3e0de3152e466']

builddependencies = [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Fixes "nvcc fatal: Option '--ptx (-ptx)' is not allowed when compiling for multiple GPU architectures"
# fatal compilation issue when building for multiple SM architectures
# More info, see https://github.com/NVIDIA/cuda-samples/issues/289

# Author: Caspar van Leeuwen

diff -Nru cuda-samples-11.3.orig/Samples/memMapIPCDrv/Makefile cuda-samples-11.3/Samples/memMapIPCDrv/Makefile
--- cuda-samples-11.3.orig/Samples/memMapIPCDrv/Makefile 2024-07-29 13:17:10.330743000 +0200
+++ cuda-samples-11.3/Samples/memMapIPCDrv/Makefile 2024-07-29 13:19:13.158507504 +0200
@@ -321,6 +321,12 @@
ifneq ($(HIGHEST_SM),)
GENCODE_FLAGS += -gencode arch=compute_$(HIGHEST_SM),code=compute_$(HIGHEST_SM)
endif
+
+# Generate the explicit PTX file for the lowest SM architecture in $(SMS), so it works on all SMS listed there
+LOWEST_SM := $(firstword $(sort $(SMS)))
+ifneq ($(LOWEST_SM),)
+GENCODE_FLAGS_LOWEST_SM += -gencode arch=compute_$(LOWEST_SM),code=compute_$(LOWEST_SM)
+endif
endif

ifeq ($(TARGET_OS),darwin)
@@ -401,7 +407,7 @@
endif

$(PTX_FILE): memMapIpc_kernel.cu
- $(EXEC) $(NVCC) $(INCLUDES) $(ALL_CCFLAGS) $(GENCODE_FLAGS) -o $@ -ptx $<
+ $(EXEC) $(NVCC) $(INCLUDES) $(ALL_CCFLAGS) $(GENCODE_FLAGS_LOWEST_SM) -o $@ -ptx $<
$(EXEC) mkdir -p data
$(EXEC) cp -f $@ ./data
$(EXEC) mkdir -p ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Fixes "nvcc fatal: Option '--ptx (-ptx)' is not allowed when compiling for multiple GPU architectures"
# fatal compilation issue when building for multiple SM architectures
# More info, see https://github.com/NVIDIA/cuda-samples/issues/289

# Author: Caspar van Leeuwen

diff -Nru cuda-samples-12.2.orig/Samples/3_CUDA_Features/memMapIPCDrv/Makefile cuda-samples-12.2/Samples/3_CUDA_Features/memMapIPCDrv/Makefile
--- cuda-samples-12.2.orig/Samples/3_CUDA_Features/memMapIPCDrv/Makefile 2024-07-29 12:14:28.538848000 +0200
+++ cuda-samples-12.2/Samples/3_CUDA_Features/memMapIPCDrv/Makefile 2024-07-29 13:02:45.134261829 +0200
@@ -313,6 +313,12 @@
ifneq ($(HIGHEST_SM),)
GENCODE_FLAGS += -gencode arch=compute_$(HIGHEST_SM),code=compute_$(HIGHEST_SM)
endif
+
+# Generate the explicit PTX file for the lowest SM architecture in $(SMS), so it works on all SMS listed there
+LOWEST_SM := $(firstword $(sort $(SMS)))
+ifneq ($(LOWEST_SM),)
+GENCODE_FLAGS_LOWEST_SM += -gencode arch=compute_$(LOWEST_SM),code=compute_$(LOWEST_SM)
+endif
endif

ifeq ($(TARGET_OS),darwin)
@@ -394,7 +400,7 @@
endif

$(PTX_FILE): memMapIpc_kernel.cu
- $(EXEC) $(NVCC) $(INCLUDES) $(ALL_CCFLAGS) $(GENCODE_FLAGS) -o $@ -ptx $<
+ $(EXEC) $(NVCC) $(INCLUDES) $(ALL_CCFLAGS) $(GENCODE_FLAGS_LOWEST_SM) -o $@ -ptx $<
$(EXEC) mkdir -p data
$(EXEC) cp -f $@ ./data
$(EXEC) mkdir -p ../../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
diff -Nru cuda-samples-12.2.orig/Samples/3_CUDA_Features/ptxjit/Makefile cuda-samples-12.2/Samples/3_CUDA_Features/ptxjit/Makefile
--- cuda-samples-12.2.orig/Samples/3_CUDA_Features/ptxjit/Makefile 2024-07-29 12:14:28.546771000 +0200
+++ cuda-samples-12.2/Samples/3_CUDA_Features/ptxjit/Makefile 2024-07-29 13:02:38.741961008 +0200
@@ -307,6 +307,12 @@
ifneq ($(HIGHEST_SM),)
GENCODE_FLAGS += -gencode arch=compute_$(HIGHEST_SM),code=compute_$(HIGHEST_SM)
endif
+
+# Generate the explicit PTX file for the lowest SM architecture in $(SMS), so it works on all SMS listed there
+LOWEST_SM := $(firstword $(sort $(SMS)))
+ifneq ($(LOWEST_SM),)
+GENCODE_FLAGS_LOWEST_SM += -gencode arch=compute_$(LOWEST_SM),code=compute_$(LOWEST_SM)
+endif
endif

ifeq ($(TARGET_OS),darwin)
@@ -390,7 +396,7 @@
endif

$(PTX_FILE): ptxjit_kernel.cu
- $(EXEC) $(NVCC) $(INCLUDES) $(ALL_CCFLAGS) $(GENCODE_FLAGS) -o $@ -ptx $<
+ $(EXEC) $(NVCC) $(INCLUDES) $(ALL_CCFLAGS) $(GENCODE_FLAGS_LOWEST_SM) -o $@ -ptx $<
$(EXEC) mkdir -p data
$(EXEC) cp -f $@ ./data
$(EXEC) mkdir -p ../../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)

0 comments on commit 238ce2c

Please sign in to comment.