diff options
| author | ruki <[email protected]> | 2019-06-19 00:48:20 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-06-18 22:50:04 +0800 |
| commit | d6d53fa5696b012d435506d3b88edb5851c269f8 (patch) | |
| tree | f517fb5c82d58e47d4d8860907b80cdc70f2acc8 /xmake/modules/lib | |
| parent | 96bda12356f3d69edae33a31d384d28b1ef74274 (diff) | |
modify code style
Diffstat (limited to 'xmake/modules/lib')
| -rw-r--r-- | xmake/modules/lib/detect/find_cudadevices.lua | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/xmake/modules/lib/detect/find_cudadevices.lua b/xmake/modules/lib/detect/find_cudadevices.lua index 63874685d..8e2a1ae64 100644 --- a/xmake/modules/lib/detect/find_cudadevices.lua +++ b/xmake/modules/lib/detect/find_cudadevices.lua @@ -40,13 +40,14 @@ function _get_lines(str) return result end - -- parse a single value +-- -- format: -- 1. a number: `2048` -- 2. an array: `(65536, 2048, 2048)` -- 3. bool value: `true` or `false` -- 4. string: `"string"` +-- function _parse_value(value) local num = tonumber(value) if num then return num end @@ -71,8 +72,10 @@ end -- parse single line +-- -- format: -- key = value +-- function _parse_line(line, device) local key = line:match("%s+(%g+) = .+") local value = line:match("%s+%g+ = (.+)") @@ -84,9 +87,9 @@ function _parse_line(line, device) end end - -- parse filtered lines function _parse_result(lines, verbose) + if #lines == 0 then -- not a failure, returns {} rather than nil utils.warning("no cuda devices was found") @@ -110,23 +113,25 @@ function _parse_result(lines, verbose) return devices end - -- find devices function _find_devices(verbose) + + -- find nvcc local nvcc = assert(find_tool("nvcc"), "nvcc not found") + -- trace if verbose then cprint("${dim}checking for cuda devices") end + -- get cuda devices local sourcefile = path.join(os.programdir(), "scripts", "find_cudadevices.cpp") local outfile = os.tmpfile() - local args = { sourcefile, "-run", "-o", outfile , '-DPRINT_SUFFIX="' .. _PRINT_SUFFIX .. '"' } - local compile_errors = nil local results, errors = try { function () + local args = { sourcefile, "-run", "-o", outfile , '-DPRINT_SUFFIX="' .. _PRINT_SUFFIX .. '"' } return os.iorunv(nvcc.program, args) end, catch @@ -167,7 +172,6 @@ function _find_devices(verbose) return devices end - -- get devices array form cache or via _find_devices function _get_devices(opt) @@ -219,7 +223,9 @@ function _min_sm_arch(devices, min_sm_arch) end function _order_by_flops(devices) - local ngpu_arch_cores_per_sm = { + + local ngpu_arch_cores_per_sm = + { [30] = 192 , [32] = 192 , [35] = 192 |
