From ea7690558bca71ce3a9453adff4e0135352a352f Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 30 Mar 2020 19:23:09 -0400 Subject: CUDA version handling (#1301) * render feature for CUDA compute model. * Use SemanticVersion type. * Enable CUDA wave tests that require CUDA SM 7.0. Provide mechanism for DownstreamCompiler to specify version numbers. * Enabled wave-equality.slang * Make CUDA SM version major version not just a single digit. * Fix assert. * DownstreamCompiler::Version -> CapabilityVersion --- source/core/slang-nvrtc-compiler.cpp | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'source/core/slang-nvrtc-compiler.cpp') diff --git a/source/core/slang-nvrtc-compiler.cpp b/source/core/slang-nvrtc-compiler.cpp index 5d5a1ce0f..0e167bf80 100644 --- a/source/core/slang-nvrtc-compiler.cpp +++ b/source/core/slang-nvrtc-compiler.cpp @@ -10,6 +10,7 @@ #include "slang-io.h" #include "slang-shared-library.h" +#include "slang-semantic-version.h" namespace nvrtc { @@ -307,14 +308,30 @@ SlangResult NVRTCDownstreamCompiler::compile(const CompileOptions& options, RefP // This is arguably too much - but nvrtc does not appear to have a mechanism to switch off individual warnings. // I tried the -Xcudafe mechanism but that does not appear to work for nvrtc cmdLine.addArg("-w"); + } - // -#if 0 - cmdLine.addArg("-arch=compute_70"); -#else - // Needed for Warp intrinsics - cmdLine.addArg("-arch=compute_30"); -#endif + { + // Lowest supported is 3.0 + SemanticVersion version(3); + for (const auto& capabilityVersion : options.requiredCapabilityVersions) + { + if (capabilityVersion.kind == DownstreamCompiler::CapabilityVersion::Kind::CUDASM) + { + if (capabilityVersion.version > version) + { + version = capabilityVersion.version; + } + } + } + + StringBuilder builder; + builder << "-arch=compute_"; + builder << version.m_major; + + SLANG_ASSERT(version.m_minor >= 0 && version.m_minor <= 9); + builder << char('0' + version.m_minor); + + cmdLine.addArg(builder); } nvrtcProgram program = nullptr; -- cgit v1.2.3