diff options
| author | ruki <[email protected]> | 2020-08-10 13:15:37 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-08-10 13:15:37 +0800 |
| commit | 894b90a805a445dd9d882ffd434a73f0fa22197c (patch) | |
| tree | 603478d7ac0971586a5c026f00d09a2c0a056f24 | |
| parent | 3cbe41e25b7a3dd0872daa9ea87ba786a9dc2df8 (diff) | |
| parent | 084e01a6ac7961fa650aba9cdc06502e4bd88b2c (diff) | |
Merge pull request #918 from OpportunityLiu/cuda-update
Cuda update
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | README_zh.md | 2 | ||||
| -rw-r--r-- | tests/projects/cuda/console/xmake.lua | 4 | ||||
| -rw-r--r-- | tests/projects/cuda/console_2/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/core/tools/nvcc.lua | 1 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/nvcc/has_flags.lua | 28 | ||||
| -rw-r--r-- | xmake/modules/lib/detect/find_cudadevices.lua | 1 | ||||
| -rw-r--r-- | xmake/rules/cuda/gencodes/xmake.lua | 5 | ||||
| -rw-r--r-- | xmake/templates/cuda/console/project/xmake.lua | 4 |
9 files changed, 34 insertions, 15 deletions
@@ -278,7 +278,7 @@ target("test") set_kind("binary") add_files("src/*.cu") add_cugencodes("native") - add_cugencodes("compute_30") + add_cugencodes("compute_35") ``` WDK/UMDF Driver Program: diff --git a/README_zh.md b/README_zh.md index cd4b639f1..7ee83a15e 100644 --- a/README_zh.md +++ b/README_zh.md @@ -280,7 +280,7 @@ target("test") set_kind("binary") add_files("src/*.cu") add_cugencodes("native") - add_cugencodes("compute_30") + add_cugencodes("compute_35") ``` WDK/UMDF驱动程序: diff --git a/tests/projects/cuda/console/xmake.lua b/tests/projects/cuda/console/xmake.lua index bf69c8c1e..d6137c9d8 100644 --- a/tests/projects/cuda/console/xmake.lua +++ b/tests/projects/cuda/console/xmake.lua @@ -14,9 +14,9 @@ target("cuda_console") add_files("src/*.cu") -- 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") + add_cugencodes("sm_35", "sm_37", "sm_50", "sm_52", "sm_60", "sm_61", "sm_70", "sm_75") -- generate PTX code from the highest SM architecture to guarantee forward-compatibility - add_cugencodes("compute_70") + add_cugencodes("compute_75") diff --git a/tests/projects/cuda/console_2/xmake.lua b/tests/projects/cuda/console_2/xmake.lua index 2c445d7e3..08cc430d8 100644 --- a/tests/projects/cuda/console_2/xmake.lua +++ b/tests/projects/cuda/console_2/xmake.lua @@ -3,7 +3,7 @@ add_rules("mode.debug", "mode.release") -- generate PTX code for the virtual architecture to guarantee compatibility -add_cugencodes("compute_30") +add_cugencodes("compute_35") -- define target target("bin") diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua index 6aab1225d..24209e228 100644 --- a/xmake/modules/core/tools/nvcc.lua +++ b/xmake/modules/core/tools/nvcc.lua @@ -33,6 +33,7 @@ function init(self) -- init cuflags if not is_plat("windows", "mingw") then self:set("shared.cuflags", "-Xcompiler -fPIC") + self:set("binary.cuflags", "-Xcompiler -fPIE") end -- add -ccbin diff --git a/xmake/modules/detect/tools/nvcc/has_flags.lua b/xmake/modules/detect/tools/nvcc/has_flags.lua index 8cbffc010..2929f67bd 100644 --- a/xmake/modules/detect/tools/nvcc/has_flags.lua +++ b/xmake/modules/detect/tools/nvcc/has_flags.lua @@ -112,12 +112,24 @@ function _check_try_running(flags, opt, islinker) io.writefile(sourcefile, "int main(int argc, char** argv)\n{return 0;}") end - -- check flags - if islinker then - return _try_running(opt.program, table.join(flags, "-o", os.nuldev(), sourcefile)) - else - return _try_running(opt.program, table.join(flags, "-c", "-o", os.nuldev(), sourcefile)) + local args = table.join("-o", os.nuldev(), sourcefile) + + if not islinker then + table.insert(args, 1, "-c") + end + + -- avoid recursion + if flags[1] ~= "-allow-unsupported-compiler" then + -- add -allow-unsupported-compiler if supported to suppress error of unsupported compiler, + -- which caused all checks failed. + local allow_unsupported_compiler = _has_flags({"-allow-unsupported-compiler"}, opt) + if allow_unsupported_compiler then + table.insert(args, 1, "-allow-unsupported-compiler") + end end + + -- check flags + return _try_running(opt.program, table.join(flags, args)) end -- has_flags(flags)? @@ -126,7 +138,7 @@ end -- -- @return true or false -- -function main(flags, opt) +function _has_flags(flags, opt) -- is linker? local islinker = _islinker(flags, opt) @@ -140,3 +152,7 @@ function main(flags, opt) return _check_try_running(flags, opt, islinker) end +function main(...) + return _has_flags(...) +end + diff --git a/xmake/modules/lib/detect/find_cudadevices.lua b/xmake/modules/lib/detect/find_cudadevices.lua index bd1bb72bc..98ae81e6d 100644 --- a/xmake/modules/lib/detect/find_cudadevices.lua +++ b/xmake/modules/lib/detect/find_cudadevices.lua @@ -238,6 +238,7 @@ function _order_by_flops(devices) , [70] = 64 , [72] = 64 , [75] = 64 + , [80] = 64 } for _, dev in ipairs(devices) do diff --git a/xmake/rules/cuda/gencodes/xmake.lua b/xmake/rules/cuda/gencodes/xmake.lua index e03626c6d..91af885ba 100644 --- a/xmake/rules/cuda/gencodes/xmake.lua +++ b/xmake/rules/cuda/gencodes/xmake.lua @@ -42,8 +42,9 @@ rule("cuda.gencodes") import("core.base.hashset") -- sm_20 and compute_20 is supported until CUDA 8 - local known_v_archs = hashset.of(20, 30, 32, 35, 37, 50, 52, 53, 60, 61, 62, 70, 72, 75) - local known_r_archs = hashset.of(20, 30, 32, 35, 37, 50, 52, 53, 60, 61, 62, 70, 72, 75) + -- 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) + local known_r_archs = hashset.of(20, 30, 32, 35, 37, 50, 52, 53, 60, 61, 62, 70, 72, 75, 80) 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 6521e605c..eec69685f 100644 --- a/xmake/templates/cuda/console/project/xmake.lua +++ b/xmake/templates/cuda/console/project/xmake.lua @@ -21,10 +21,10 @@ target("${TARGETNAME}") add_cugencodes("native") -- generate PTX code for the virtual architecture to guarantee compatibility - add_cugencodes("compute_30") + add_cugencodes("compute_35") -- -- 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_35", "sm_37", "sm_50", "sm_52", "sm_60", "sm_61", "sm_70", "sm_75") -- -- generate PTX code from the highest SM architecture to guarantee forward-compatibility -- add_cugencodes("compute_75") |
