From 949795859315dbe358e3340967e35b09811fcbb8 Mon Sep 17 00:00:00 2001 From: Hoildkv <42310255+xq114@users.noreply.github.com> Date: Fri, 25 Feb 2022 13:50:30 +0800 Subject: fix find_cudadevice on windows x86 --- xmake/modules/lib/detect/find_cudadevices.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xmake/modules/lib/detect/find_cudadevices.lua b/xmake/modules/lib/detect/find_cudadevices.lua index dcf4a4229..fac3c8a21 100644 --- a/xmake/modules/lib/detect/find_cudadevices.lua +++ b/xmake/modules/lib/detect/find_cudadevices.lua @@ -131,6 +131,11 @@ function _find_devices(verbose, envs) { function () local args = { sourcefile, "-run", "-o", outfile , '-DPRINT_SUFFIX="' .. _PRINT_SUFFIX .. '"' } + if is_arch("x86") then + table.insert(args, "-m32") + elseif is_arch("x64") then + table.insert(args, "-m64") + end return os.iorunv(nvcc.program, args, {envs = envs}) end, catch -- cgit v1.3.1 From 0722a44d0c64f78b019c7f439ed240e7d7bf3f96 Mon Sep 17 00:00:00 2001 From: Hoildkv <42310255+xq114@users.noreply.github.com> Date: Fri, 25 Feb 2022 20:24:35 +0800 Subject: add plat/arch info to find_cudadevices --- xmake/rules/cuda/gencodes/xmake.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/rules/cuda/gencodes/xmake.lua b/xmake/rules/cuda/gencodes/xmake.lua index f4f51c06d..f60f8cd2e 100644 --- a/xmake/rules/cuda/gencodes/xmake.lua +++ b/xmake/rules/cuda/gencodes/xmake.lua @@ -59,7 +59,7 @@ rule("cuda.gencodes") break end end - local device = find_cudadevices({skip_compute_mode_prohibited = true, order_by_flops = true, envs = cuda_envs})[1] + local device = find_cudadevices({skip_compute_mode_prohibited = true, order_by_flops = true, envs = cuda_envs, plat = target:plat(), arch = target:arch()})[1] if device then return nf_cugencode("sm_" .. device.major .. device.minor) end -- cgit v1.3.1 From 304904858f9bec29aeaed8c1b646fba15ae025fb Mon Sep 17 00:00:00 2001 From: Hoildkv <42310255+xq114@users.noreply.github.com> Date: Fri, 25 Feb 2022 20:27:54 +0800 Subject: Update find_cudadevices.lua --- xmake/modules/lib/detect/find_cudadevices.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xmake/modules/lib/detect/find_cudadevices.lua b/xmake/modules/lib/detect/find_cudadevices.lua index fac3c8a21..71ee12e3b 100644 --- a/xmake/modules/lib/detect/find_cudadevices.lua +++ b/xmake/modules/lib/detect/find_cudadevices.lua @@ -113,7 +113,7 @@ function _parse_result(lines, verbose) end -- find devices -function _find_devices(verbose, envs) +function _find_devices(verbose, opt) -- find nvcc local nvcc = assert(find_tool("nvcc"), "nvcc not found") @@ -131,12 +131,12 @@ function _find_devices(verbose, envs) { function () local args = { sourcefile, "-run", "-o", outfile , '-DPRINT_SUFFIX="' .. _PRINT_SUFFIX .. '"' } - if is_arch("x86") then + if opt.arch == "x86" then table.insert(args, "-m32") - elseif is_arch("x64") then + elseif opt.arch == "x64" or opt.arch == "x86_64" then table.insert(args, "-m64") end - return os.iorunv(nvcc.program, args, {envs = envs}) + return os.iorunv(nvcc.program, args, {envs = opt.envs}) end, catch { @@ -192,7 +192,7 @@ function _get_devices(opt) end local verbose = opt.verbose or option.get("verbose") or option.get("diagnosis") - local devices = _find_devices(verbose, opt.envs) + local devices = _find_devices(verbose, opt) if devices then cachedata = { succeed = true, data = devices } else -- cgit v1.3.1