diff options
| author | OpportunityLiu <[email protected]> | 2019-06-10 12:02:45 +0800 |
|---|---|---|
| committer | OpportunityLiu <[email protected]> | 2019-06-10 12:02:45 +0800 |
| commit | 9c2c26c81c8c43bc1a834522bc085392c766e7e0 (patch) | |
| tree | 621e80bbb74a437d8b819837d4373988da61bf78 | |
| parent | 4fe121746da73e547d902cec6942b06681b385de (diff) | |
fix finddevice
| -rw-r--r-- | xmake/modules/lib/detect/find_cudadevices.lua | 9 | ||||
| -rw-r--r-- | xmake/scripts/find_cudadevices.cpp (renamed from xmake/scripts/find_cudadevices.cu) | 20 |
2 files changed, 18 insertions, 11 deletions
diff --git a/xmake/modules/lib/detect/find_cudadevices.lua b/xmake/modules/lib/detect/find_cudadevices.lua index 64a69f705..aa44fe0fb 100644 --- a/xmake/modules/lib/detect/find_cudadevices.lua +++ b/xmake/modules/lib/detect/find_cudadevices.lua @@ -21,6 +21,7 @@ -- imports import("core.base.option") import("core.platform.platform") +import("core.project.config") import("lib.detect.cache") -- a magic string to filter output @@ -120,13 +121,15 @@ function _find_devices(verbose) cprint("${dim}checking for cuda devices") end - local sourcefile = path.join(os.programdir(), 'scripts', 'find_cudadevices.cu') + local sourcefile = path.join(os.programdir(), 'scripts', 'find_cudadevices.cpp') local outfile = os.tmpfile() local compile_errors = nil local results, errors = try { - function () - return os.iorunv(nvcc, { sourcefile, '-run', '-o', outfile , '-DPRINT_SUFFIX="' .. _PRINT_SUFFIX .. '"' }) + function () + local archs = { i386 = "-m32", x86 = "-m32", x86_64 = "-m64", x64 = "-m64" } + local arch = archs[config.get("arch")] or "" + return os.iorunv(nvcc, { sourcefile, arch, '-run', '-o', outfile , '-DPRINT_SUFFIX="' .. _PRINT_SUFFIX .. '"' }) end, catch { diff --git a/xmake/scripts/find_cudadevices.cu b/xmake/scripts/find_cudadevices.cpp index 56d64ff2b..fd002cc84 100644 --- a/xmake/scripts/find_cudadevices.cu +++ b/xmake/scripts/find_cudadevices.cpp @@ -19,10 +19,19 @@ inline void check(cudaError_t result) } } -inline void print_value(size_t value) +inline void print_value(unsigned long long value) { - // in case we don't have '%zu' - printf("%llu", (unsigned long long)value); + printf("%llu", value); +} + +inline void print_value(unsigned long value) +{ + printf("%lu", value); +} + +inline void print_value(unsigned int value) +{ + printf("%u", value); } inline void print_value(bool value) @@ -48,11 +57,6 @@ inline void print_value(const T (&value)[len]) printf(")"); } -inline void print_value(unsigned int value) -{ - printf("%u", value); -} - inline void print_value(const void *value) { printf("\"%s\"", (const char *)value); |
