diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2020-03-30 19:23:09 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-30 23:23:09 +0000 |
| commit | ea7690558bca71ce3a9453adff4e0135352a352f (patch) | |
| tree | 3eb983d3f8e6b1c215f6d2818a0f3e793ecb4485 /source/core | |
| parent | ad5b60c8b5868c69a979779f201748fb7837fdc9 (diff) | |
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
Diffstat (limited to 'source/core')
| -rw-r--r-- | source/core/slang-downstream-compiler.h | 13 | ||||
| -rw-r--r-- | source/core/slang-nvrtc-compiler.cpp | 31 | ||||
| -rw-r--r-- | source/core/slang-semantic-version.cpp | 9 | ||||
| -rw-r--r-- | source/core/slang-semantic-version.h | 23 |
4 files changed, 61 insertions, 15 deletions
diff --git a/source/core/slang-downstream-compiler.h b/source/core/slang-downstream-compiler.h index f9e33ed6c..3ffa32097 100644 --- a/source/core/slang-downstream-compiler.h +++ b/source/core/slang-downstream-compiler.h @@ -7,6 +7,7 @@ #include "slang-process-util.h" #include "slang-platform.h" +#include "slang-semantic-version.h" #include "slang-io.h" @@ -207,6 +208,16 @@ public: String value; }; + struct CapabilityVersion + { + enum class Kind + { + CUDASM, ///< What the version is for + }; + Kind kind; + SemanticVersion version; + }; + struct CompileOptions { typedef uint32_t Flags; @@ -247,6 +258,8 @@ public: List<String> includePaths; List<String> libraryPaths; + + List<CapabilityVersion> requiredCapabilityVersions; }; typedef uint32_t ProductFlags; 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; diff --git a/source/core/slang-semantic-version.cpp b/source/core/slang-semantic-version.cpp index 93536e007..7f603fd9c 100644 --- a/source/core/slang-semantic-version.cpp +++ b/source/core/slang-semantic-version.cpp @@ -7,13 +7,13 @@ namespace Slang { -SlangResult SemanticVersion::parse(const UnownedStringSlice& value, SemanticVersion& outVersion) +SlangResult SemanticVersion::parse(const UnownedStringSlice& value, char separatorChar, SemanticVersion& outVersion) { outVersion.reset(); UnownedStringSlice slices[3]; Index splitCount; - SLANG_RETURN_ON_FAIL(StringUtil::split(value, '.', 3, slices, splitCount)); + SLANG_RETURN_ON_FAIL(StringUtil::split(value, separatorChar, 3, slices, splitCount)); if (splitCount <= 0) { return SLANG_FAIL; @@ -38,6 +38,11 @@ SlangResult SemanticVersion::parse(const UnownedStringSlice& value, SemanticVers return SLANG_OK; } +SlangResult SemanticVersion::parse(const UnownedStringSlice& value, SemanticVersion& outVersion) +{ + return parse(value, '.', outVersion); +} + void SemanticVersion::append(StringBuilder& buf) const { buf << Int32(m_major) << "." << Int32(m_minor); diff --git a/source/core/slang-semantic-version.h b/source/core/slang-semantic-version.h index bbfcb663e..d33116de6 100644 --- a/source/core/slang-semantic-version.h +++ b/source/core/slang-semantic-version.h @@ -15,9 +15,9 @@ struct SemanticVersion SemanticVersion():m_major(0), m_minor(0), m_patch(0) {} SemanticVersion(int inMajor, int inMinor = 0, int inPatch = 0): - m_major(uint8_t(inMajor)), - m_minor(uint8_t(inMinor)), - m_patch(uint8_t(inPatch)) + m_major(uint32_t(inMajor)), + m_minor(uint16_t(inMinor)), + m_patch(uint16_t(inPatch)) {} void reset() @@ -27,15 +27,26 @@ struct SemanticVersion m_patch = 0; } + /// All zeros means nothing is set + bool isSet() const { return m_major || m_minor || m_patch; } + IntegerType toInteger() const { return (IntegerType(m_major) << 32) | (uint32_t(m_minor) << 16) | m_patch; } void setFromInteger(IntegerType v) { - m_major = (v >> 32); - m_minor = uint16_t(v >> 16); - m_patch = uint16_t(v); + set(int(v >> 32), int((v >> 16) & 0xffff), int(v & 0xffff)); + } + void set(int major, int minor, int patch = 0) + { + SLANG_ASSERT(major >= 0 && minor >=0 && patch >= 0); + + m_major = uint32_t(major); + m_minor = uint16_t(minor); + m_patch = uint16_t(patch); } static SlangResult parse(const UnownedStringSlice& value, SemanticVersion& outVersion); + static SlangResult parse(const UnownedStringSlice& value, char separatorChar, SemanticVersion& outVersion); + void append(StringBuilder& buf) const; bool operator>(const ThisType& rhs) const { return toInteger() > rhs.toInteger(); } |
