diff options
author | Aaron Watry <[email protected]> | 2018-02-27 20:49:03 -0600 |
---|---|---|
committer | Aaron Watry <[email protected]> | 2018-03-21 06:59:46 -0500 |
commit | c95d953b18d5174153e55957fb6947b9b59588ce (patch) | |
tree | 26ee14a026edefc35363d44b85c2e2a0f2404614 /src | |
parent | 29b4090d18fa3e7435450e30383d0416e536a425 (diff) |
clover: Dynamically calculate __OPENCL_VERSION__ and CLC language version
Use get_language_version to calculate default cl standard based on
device capabilities and -cl-std specified in build options.
v5; move dev_clc_version declaration from an earlier patch
v4: Squash the __OPENCL_VERSION__ and CLC language version patches
v3: (Jan) Allow device_version up to 2.2 while device_clc_version
only goes to 2.0
Use get_cl_version to calculate version instead
v2: Split out from the previous patch (Pierre)
Signed-off-by: Aaron Watry <[email protected]>
Reviewed-by: Pierre Moreau <[email protected]>
CC: Jan Vesely <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/state_trackers/clover/llvm/invocation.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp b/src/gallium/state_trackers/clover/llvm/invocation.cpp index a485380a036..af78c2ae284 100644 --- a/src/gallium/state_trackers/clover/llvm/invocation.cpp +++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp @@ -197,6 +197,7 @@ namespace { map(std::mem_fn(&std::string::c_str), opts); const target &target = dev.ir_target(); + const std::string &device_clc_version = dev.device_clc_version(); if (!clang::CompilerInvocation::CreateFromArgs( c->getInvocation(), copts.data(), copts.data() + copts.size(), diag)) @@ -218,7 +219,7 @@ namespace { compat::set_lang_defaults(c->getInvocation(), c->getLangOpts(), compat::ik_opencl, ::llvm::Triple(target.triple), c->getPreprocessorOpts(), - clang::LangStandard::lang_opencl11); + get_language_version(opts, device_clc_version)); c->createDiagnostics(new clang::TextDiagnosticPrinter( *new raw_string_ostream(r_log), @@ -249,7 +250,9 @@ namespace { c.getPreprocessorOpts().Includes.push_back("clc/clc.h"); // Add definition for the OpenCL version - c.getPreprocessorOpts().addMacroDef("__OPENCL_VERSION__=110"); + c.getPreprocessorOpts().addMacroDef("__OPENCL_VERSION__=" + + std::to_string(get_cl_version( + dev.device_version()).version_number)); // clc.h requires that this macro be defined: c.getPreprocessorOpts().addMacroDef("cl_clang_storage_class_specifiers"); |