Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cuda update #918

Merged
merged 5 commits into from
Aug 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -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驱动程序:
Expand Down
4 changes: 2 additions & 2 deletions tests/projects/cuda/console/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")


2 changes: 1 addition & 1 deletion tests/projects/cuda/console_2/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions xmake/modules/core/tools/nvcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
OpportunityLiu marked this conversation as resolved.
Show resolved Hide resolved
end

-- add -ccbin
Expand Down
28 changes: 22 additions & 6 deletions xmake/modules/detect/tools/nvcc/has_flags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
OpportunityLiu marked this conversation as resolved.
Show resolved Hide resolved
-- 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)?
Expand All @@ -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)
Expand All @@ -140,3 +152,7 @@ function main(flags, opt)
return _check_try_running(flags, opt, islinker)
end

function main(...)
return _has_flags(...)
end

1 change: 1 addition & 0 deletions xmake/modules/lib/detect/find_cudadevices.lua
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ function _order_by_flops(devices)
, [70] = 64
, [72] = 64
, [75] = 64
, [80] = 64
}

for _, dev in ipairs(devices) do
Expand Down
5 changes: 3 additions & 2 deletions xmake/rules/cuda/gencodes/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions xmake/templates/cuda/console/project/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down