diff options
author | Patrick Mours <pmours@nvidia.com> | 2020-02-17 15:35:31 +0300 |
---|---|---|
committer | Patrick Mours <pmours@nvidia.com> | 2020-02-17 16:27:44 +0300 |
commit | 2278aa0da9d6a046ff014fab4b0cc6156394b0d1 (patch) | |
tree | 7c9e494c59875fb5f0004bfc40c9fa29521b365b /extern | |
parent | 12b6ddaf953056e36f1e86d7d79537cb8b3dbe4e (diff) |
Cycles: Add support for adaptive kernel compilation to OptiX device
This modifies the common CUDA implementation for adaptive kernel compilation slightly to support both CUBIN and PTX output (the latter which is then used in the OptiX device). It also fixes adaptive kernel compilation on Windows.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D6851
Diffstat (limited to 'extern')
-rw-r--r-- | extern/cuew/src/cuew.c | 68 |
1 files changed, 28 insertions, 40 deletions
diff --git a/extern/cuew/src/cuew.c b/extern/cuew/src/cuew.c index a0146741494..f477ec48a18 100644 --- a/extern/cuew/src/cuew.c +++ b/extern/cuew/src/cuew.c @@ -683,23 +683,23 @@ static int cuewNvrtcInit(void) { int cuewInit(cuuint32_t flags) { - int result = CUEW_SUCCESS; - - if (flags & CUEW_INIT_CUDA) { - result = cuewCudaInit(); - if (result != CUEW_SUCCESS) { - return result; - } - } - - if (flags & CUEW_INIT_NVRTC) { - result = cuewNvrtcInit(); - if (result != CUEW_SUCCESS) { - return result; - } - } - - return result; + int result = CUEW_SUCCESS; + + if (flags & CUEW_INIT_CUDA) { + result = cuewCudaInit(); + if (result != CUEW_SUCCESS) { + return result; + } + } + + if (flags & CUEW_INIT_NVRTC) { + result = cuewNvrtcInit(); + if (result != CUEW_SUCCESS) { + return result; + } + } + + return result; } @@ -798,7 +798,10 @@ static int path_exists(const char *path) { const char *cuewCompilerPath(void) { #ifdef _WIN32 - const char *defaultpaths[] = {"C:/CUDA/bin", NULL}; + const char *defaultpaths[] = { + "C:/CUDA/bin", + "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1/bin", + NULL}; const char *executable = "nvcc.exe"; #else const char *defaultpaths[] = { @@ -832,9 +835,12 @@ const char *cuewCompilerPath(void) { } } -#ifndef _WIN32 { +#ifdef _WIN32 + FILE *handle = popen("where nvcc", "r"); +#else FILE *handle = popen("which nvcc", "r"); +#endif if (handle) { char buffer[4096] = {0}; int len = fread(buffer, 1, sizeof(buffer) - 1, handle); @@ -845,7 +851,6 @@ const char *cuewCompilerPath(void) { } } } -#endif return NULL; } @@ -859,23 +864,6 @@ int cuewNvrtcVersion(void) { return 0; } -static size_t safe_strnlen(const char *s, size_t maxlen) { - size_t length; - for (length = 0; length < maxlen; s++, length++) { - if (*s == '\0') { - break; - } - } - return length; -} - -static char *safe_strncpy(char *dest, const char *src, size_t n) { - const size_t src_len = safe_strnlen(src, n - 1); - memcpy(dest, src, src_len); - dest[src_len] = '\0'; - return dest; -} - int cuewCompilerVersion(void) { const char *path = cuewCompilerPath(); const char *marker = "Cuda compilation tools, release "; @@ -891,8 +879,9 @@ int cuewCompilerVersion(void) { } /* get --version output */ - safe_strncpy(command, path, sizeof(command)); - strncat(command, " --version", sizeof(command) - strlen(path)); + strncat(command, "\"", 1); + strncat(command, path, sizeof(command) - 1); + strncat(command, "\" --version", sizeof(command) - strlen(path) - 1); pipe = popen(command, "r"); if (!pipe) { fprintf(stderr, "CUDA: failed to run compiler to retrieve version"); @@ -922,4 +911,3 @@ int cuewCompilerVersion(void) { return 10 * major + minor; } - |