Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Molenkamp <github@lazydodo.com>2020-03-26 20:41:44 +0300
committerRay Molenkamp <github@lazydodo.com>2020-03-26 20:41:44 +0300
commit86c61ce64f6e8c921d8770fcd42ed2c21d01ca3a (patch)
treee13f1941567bffbc159063a6891431ee9b158bac /intern/cycles/app
parent58ea0d93f193adf84162d736c3c69500584e1aef (diff)
Cycles: Restore cycles_cubin_cc to working order
Reviewed by: brecht pmoursnv Differential Revision: https://developer.blender.org/D7136
Diffstat (limited to 'intern/cycles/app')
-rw-r--r--intern/cycles/app/cycles_cubin_cc.cpp31
1 files changed, 22 insertions, 9 deletions
diff --git a/intern/cycles/app/cycles_cubin_cc.cpp b/intern/cycles/app/cycles_cubin_cc.cpp
index 9d4d52b34ac..7631cb9bed5 100644
--- a/intern/cycles/app/cycles_cubin_cc.cpp
+++ b/intern/cycles/app/cycles_cubin_cc.cpp
@@ -43,7 +43,8 @@ template<typename T> std::string to_string(const T &n)
class CompilationSettings {
public:
- CompilationSettings() : target_arch(0), bits(64), verbose(false), fast_math(false)
+ CompilationSettings()
+ : target_arch(0), bits(64), verbose(false), fast_math(false), ptx_only(false)
{
}
@@ -57,12 +58,13 @@ class CompilationSettings {
int bits;
bool verbose;
bool fast_math;
+ bool ptx_only;
};
static bool compile_cuda(CompilationSettings &settings)
{
- const char *headers[] = {"stdlib.h", "float.h", "math.h", "stdio.h"};
- const char *header_content[] = {"\n", "\n", "\n", "\n"};
+ const char *headers[] = {"stdlib.h", "float.h", "math.h", "stdio.h", "stddef.h"};
+ const char *header_content[] = {"\n", "\n", "\n", "\n", "\n"};
printf("Building %s\n", settings.input_file.c_str());
@@ -83,6 +85,8 @@ static bool compile_cuda(CompilationSettings &settings)
options.push_back("-D__KERNEL_CUDA_VERSION__=" + std::to_string(cuewNvrtcVersion()));
options.push_back("-arch=compute_" + std::to_string(settings.target_arch));
options.push_back("--device-as-default-execution-space");
+ options.push_back("-DCYCLES_CUBIN_CC");
+ options.push_back("--std=c++11");
if (settings.fast_math)
options.push_back("--use_fast_math");
@@ -134,10 +138,14 @@ static bool compile_cuda(CompilationSettings &settings)
fprintf(stderr, "Error: nvrtcGetPTX failed (%d)\n\n", (int)result);
return false;
}
-
- /* Write a file in the temp folder with the ptx code. */
- settings.ptx_file = OIIO::Filesystem::temp_directory_path() + "/" +
- OIIO::Filesystem::unique_path();
+ if (settings.ptx_only) {
+ settings.ptx_file = settings.output_file;
+ }
+ else {
+ /* Write a file in the temp folder with the ptx code. */
+ settings.ptx_file = OIIO::Filesystem::temp_directory_path() + "/" +
+ OIIO::Filesystem::unique_path();
+ }
FILE *f = fopen(settings.ptx_file.c_str(), "wb");
fwrite(&ptx_code[0], 1, ptx_size, f);
fclose(f);
@@ -249,6 +257,9 @@ static bool parse_parameters(int argc, const char **argv, CompilationSettings &s
"-D %L",
&settings.defines,
"Add additional defines",
+ "-ptx",
+ &settings.ptx_only,
+ "emit PTX code",
"-v",
&settings.verbose,
"Use verbose logging",
@@ -303,8 +314,10 @@ int main(int argc, const char **argv)
exit(EXIT_FAILURE);
}
- if (!link_ptxas(settings)) {
- exit(EXIT_FAILURE);
+ if (!settings.ptx_only) {
+ if (!link_ptxas(settings)) {
+ exit(EXIT_FAILURE);
+ }
}
return 0;