From 4846ee47d9f0bbe2cf05daa6e4fbbdd202cd86da Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Mon, 1 Dec 2025 12:47:59 +0800 Subject: feat: add support for cuda 11~13; update templates and examples --- README.md | 2 +- README_zh.md | 2 +- tests/projects/cuda/console/xmake.lua | 5 ++--- tests/projects/cuda/console_2/xmake.lua | 2 +- tests/projects/cuda/shared/xmake.lua | 2 +- tests/projects/cuda/static/xmake.lua | 2 +- xmake/modules/lib/detect/find_cudadevices.lua | 6 ++++++ xmake/rules/cuda/gencodes/xmake.lua | 6 ++++-- xmake/templates/cuda/console/project/xmake.lua | 6 +++--- xmake/templates/cuda/shared/project/xmake.lua | 6 +++--- xmake/templates/cuda/static/project/xmake.lua | 6 +++--- 11 files changed, 26 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 08c8e3415..129a5bf91 100644 --- a/README.md +++ b/README.md @@ -469,7 +469,7 @@ target("test") set_kind("binary") add_files("src/*.cu") add_cugencodes("native") - add_cugencodes("compute_35") + add_cugencodes("compute_75") ``` ### WDK/UMDF Driver Program diff --git a/README_zh.md b/README_zh.md index 859caf791..bd9399bfe 100644 --- a/README_zh.md +++ b/README_zh.md @@ -457,7 +457,7 @@ target("test") set_kind("binary") add_files("src/*.cu") add_cugencodes("native") - add_cugencodes("compute_35") + add_cugencodes("compute_75") ``` #### WDK/UMDF 驱动程序 diff --git a/tests/projects/cuda/console/xmake.lua b/tests/projects/cuda/console/xmake.lua index 15f43c7f9..981d25dc5 100644 --- a/tests/projects/cuda/console/xmake.lua +++ b/tests/projects/cuda/console/xmake.lua @@ -6,9 +6,8 @@ target("cuda_console") add_files("src/*.cu") -- generate SASS code for each SM architecture - add_cugencodes("sm_35", "sm_37", "sm_50", "sm_52", "sm_60", "sm_61", "sm_70", "sm_75") + add_cugencodes("sm_75", "sm_80", "sm_89", "sm_90", "sm_100") -- generate PTX code from the highest SM architecture to guarantee forward-compatibility - add_cugencodes("compute_75") - + add_cugencodes("compute_100") diff --git a/tests/projects/cuda/console_2/xmake.lua b/tests/projects/cuda/console_2/xmake.lua index d04aa8856..9ade4cbf4 100644 --- a/tests/projects/cuda/console_2/xmake.lua +++ b/tests/projects/cuda/console_2/xmake.lua @@ -1,7 +1,7 @@ add_rules("mode.debug", "mode.release") -- generate PTX code for the virtual architecture to guarantee compatibility -add_cugencodes("compute_35") +add_cugencodes("compute_75") target("bin") set_kind("binary") diff --git a/tests/projects/cuda/shared/xmake.lua b/tests/projects/cuda/shared/xmake.lua index 590808435..7af1678e4 100644 --- a/tests/projects/cuda/shared/xmake.lua +++ b/tests/projects/cuda/shared/xmake.lua @@ -1,7 +1,7 @@ add_rules("mode.debug", "mode.release") -- generate PTX code for the virtual architecture to guarantee compatibility -add_cugencodes("compute_30") +add_cugencodes("compute_75") target("lib") set_kind("shared") diff --git a/tests/projects/cuda/static/xmake.lua b/tests/projects/cuda/static/xmake.lua index d88cf7964..6783a7484 100644 --- a/tests/projects/cuda/static/xmake.lua +++ b/tests/projects/cuda/static/xmake.lua @@ -1,7 +1,7 @@ add_rules("mode.debug", "mode.release") -- generate PTX code for the virtual architecture to guarantee compatibility -add_cugencodes("compute_30") +add_cugencodes("compute_75") target("lib") set_kind("static") diff --git a/xmake/modules/lib/detect/find_cudadevices.lua b/xmake/modules/lib/detect/find_cudadevices.lua index 0f459c711..a6ae606a6 100644 --- a/xmake/modules/lib/detect/find_cudadevices.lua +++ b/xmake/modules/lib/detect/find_cudadevices.lua @@ -228,6 +228,7 @@ end function _order_by_flops(devices) + -- See https://github.com/NVIDIA/cuda-samples/blob/master/Common/helper_cuda_drvapi.h#L100 local ngpu_arch_cores_per_sm = { [30] = 192 @@ -248,6 +249,11 @@ function _order_by_flops(devices) , [87] = 128 , [89] = 128 , [90] = 128 + , [100] = 128 + , [103] = 128 + , [110] = 128 + , [120] = 128 + , [121] = 128 } for _, dev in ipairs(devices) do diff --git a/xmake/rules/cuda/gencodes/xmake.lua b/xmake/rules/cuda/gencodes/xmake.lua index 902e932db..0da3deb56 100644 --- a/xmake/rules/cuda/gencodes/xmake.lua +++ b/xmake/rules/cuda/gencodes/xmake.lua @@ -43,8 +43,10 @@ rule("cuda.gencodes") -- sm_20 and compute_20 is supported until CUDA 8 -- sm_30 and compute_30 is supported until CUDA 10 - local known_v_archs = hashset.of(20, 30, 32, 35, 37, 50, 52, 53, 60, 61, 62, 70, 72, 75, 80, 86, 87, 89, 90) - local known_r_archs = hashset.of(20, 30, 32, 35, 37, 50, 52, 53, 60, 61, 62, 70, 72, 75, 80, 86, 87, 89, 90) + -- sm_37 and compute_37 is supported until CUDA 11 + -- sm_72 and compute_72 is supported until CUDA 12 + local known_v_archs = hashset.of(20, 30, 32, 35, 37, 50, 52, 53, 60, 61, 62, 70, 72, 75, 80, 86, 87, 89, 90, 100, 103, 110, 120, 121) + local known_r_archs = hashset.of(20, 30, 32, 35, 37, 50, 52, 53, 60, 61, 62, 70, 72, 75, 80, 86, 87, 89, 90, 100, 103, 110, 120, 121) local function nf_cugencode(archs) if type(archs) ~= "string" then diff --git a/xmake/templates/cuda/console/project/xmake.lua b/xmake/templates/cuda/console/project/xmake.lua index 70967535d..5cfdad354 100644 --- a/xmake/templates/cuda/console/project/xmake.lua +++ b/xmake/templates/cuda/console/project/xmake.lua @@ -8,12 +8,12 @@ target("${TARGETNAME}") add_cugencodes("native") -- generate PTX code for the virtual architecture to guarantee compatibility - add_cugencodes("compute_35") + add_cugencodes("compute_75") -- -- generate SASS code for each SM architecture - -- add_cugencodes("sm_35", "sm_37", "sm_50", "sm_52", "sm_60", "sm_61", "sm_70", "sm_75") + -- add_cugencodes("sm_75", "sm_80", "sm_89", "sm_90", "sm_100") -- -- generate PTX code from the highest SM architecture to guarantee forward-compatibility - -- add_cugencodes("compute_75") + -- add_cugencodes("compute_100") ${FAQ} diff --git a/xmake/templates/cuda/shared/project/xmake.lua b/xmake/templates/cuda/shared/project/xmake.lua index c24fdb0d8..45c27363f 100644 --- a/xmake/templates/cuda/shared/project/xmake.lua +++ b/xmake/templates/cuda/shared/project/xmake.lua @@ -9,12 +9,12 @@ target("${TARGETNAME}") add_cugencodes("native") -- generate PTX code for the virtual architecture to guarantee compatibility - add_cugencodes("compute_30") + add_cugencodes("compute_75") -- -- generate SASS code for each SM architecture - -- add_cugencodes("sm_30", "sm_35", "sm_37", "sm_50", "sm_52", "sm_60", "sm_61", "sm_70", "sm_75") + -- add_cugencodes("sm_75", "sm_80", "sm_89", "sm_90", "sm_100") -- -- generate PTX code from the highest SM architecture to guarantee forward-compatibility - -- add_cugencodes("compute_75") + -- add_cugencodes("compute_100") ${FAQ} diff --git a/xmake/templates/cuda/static/project/xmake.lua b/xmake/templates/cuda/static/project/xmake.lua index ec663ae28..6d84c3b92 100644 --- a/xmake/templates/cuda/static/project/xmake.lua +++ b/xmake/templates/cuda/static/project/xmake.lua @@ -9,12 +9,12 @@ target("${TARGETNAME}") add_cugencodes("native") -- generate PTX code for the virtual architecture to guarantee compatibility - add_cugencodes("compute_30") + add_cugencodes("compute_75") -- -- generate SASS code for each SM architecture - -- add_cugencodes("sm_30", "sm_35", "sm_37", "sm_50", "sm_52", "sm_60", "sm_61", "sm_70", "sm_75") + -- add_cugencodes("sm_75", "sm_80", "sm_89", "sm_90", "sm_100") -- -- generate PTX code from the highest SM architecture to guarantee forward-compatibility - -- add_cugencodes("compute_75") + -- add_cugencodes("compute_100") ${FAQ} -- cgit v1.3.1