summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2023-03-27 22:52:48 -0400
committerGitHub <noreply@github.com>2023-03-27 19:52:48 -0700
commitd120fec7e81bbd5e8cf2c551b573feaf6678b43d (patch)
tree2171333e6dd1132e310c1dd125e2e84c4add780d
parent579870b714e76cc92300cef1fdf091993bb55954 (diff)
Upgrade `slang-llvm` (#2741)
* #include an absolute path didn't work - because paths were taken to always be relative. * Fix SlangCompileTarget to keep ordering. * Add test. Remove V2 version of interface to access IDownstreamCompiler Update to slang-llvm which has _chkstk support. * Update slang.h Co-authored-by: Ellie Hermaszewska <github@sub.monoid.al> --------- Co-authored-by: Yong He <yonghe@outlook.com> Co-authored-by: Ellie Hermaszewska <github@sub.monoid.al>
-rw-r--r--deps/target-deps.json10
-rw-r--r--slang.h36
-rw-r--r--source/compiler-core/slang-downstream-compiler.h3
-rw-r--r--source/compiler-core/slang-llvm-compiler.cpp49
-rw-r--r--tests/bugs/stk-chk.slang55
-rw-r--r--tests/bugs/stk-chk.slang.expected.txt4
6 files changed, 87 insertions, 70 deletions
diff --git a/deps/target-deps.json b/deps/target-deps.json
index e5b28eba3..ba1fc700d 100644
--- a/deps/target-deps.json
+++ b/deps/target-deps.json
@@ -4,14 +4,14 @@
"dependencies" : [
{
"name" : "slang-llvm",
- "baseUrl" : "https://github.com/shader-slang/slang-llvm/releases/download/v13.x-35/",
+ "baseUrl" : "https://github.com/shader-slang/slang-llvm/releases/download/v13.x-36/",
"optional" : true,
"packages" :
{
- "windows-x86_64" : { "type" : "url", "path" : "slang-llvm-13.x-35-win64.zip" },
- "windows-x86" : { "type": "url", "path" : "slang-llvm-13.x-35-win32.zip" },
- "linux-x86_64" : { "type": "url", "path" : "slang-llvm-v13.x-35-linux-x86_64-release.zip" },
- "macosx-x86_64" : { "type": "url", "path" : "slang-llvm-v13.x-35-macosx-x86_64-release.zip" }
+ "windows-x86_64" : { "type" : "url", "path" : "slang-llvm-13.x-36-win64.zip" },
+ "windows-x86" : { "type": "url", "path" : "slang-llvm-13.x-36-win32.zip" },
+ "linux-x86_64" : { "type": "url", "path" : "slang-llvm-v13.x-36-linux-x86_64-release.zip" },
+ "macosx-x86_64" : { "type": "url", "path" : "slang-llvm-v13.x-36-macosx-x86_64-release.zip" }
}
},
{
diff --git a/slang.h b/slang.h
index ea165fbf7..d5630660b 100644
--- a/slang.h
+++ b/slang.h
@@ -549,14 +549,22 @@ extern "C"
SLANG_STORAGE_BUFFER,
};
+ /* NOTE! To keep binary compatibility care is needed with this enum!
+
+ * To add value, only add at the bottom (before COUNT_OF)
+ * To remove a value, add _DEPRECATED as a suffix, but leave in the list
+
+ This will make the enum values stable, and compatible with libraries that might not use the latest
+ enum values.
+ */
typedef int SlangCompileTargetIntegral;
enum SlangCompileTarget : SlangCompileTargetIntegral
{
SLANG_TARGET_UNKNOWN,
SLANG_TARGET_NONE,
SLANG_GLSL,
- SLANG_GLSL_VULKAN, //< deprecated: just use `SLANG_GLSL`
- SLANG_GLSL_VULKAN_ONE_DESC, //< deprecated
+ SLANG_GLSL_VULKAN, //< deprecated: just use `SLANG_GLSL`
+ SLANG_GLSL_VULKAN_ONE_DESC, //< deprecated
SLANG_HLSL,
SLANG_SPIRV,
SLANG_SPIRV_ASM,
@@ -564,18 +572,18 @@ extern "C"
SLANG_DXBC_ASM,
SLANG_DXIL,
SLANG_DXIL_ASM,
- SLANG_C_SOURCE, ///< The C language
- SLANG_CPP_SOURCE, ///< C++ code for shader kernels.
- SLANG_CPP_PYTORCH_BINDING, ///< C++ PyTorch binding code.
- SLANG_HOST_EXECUTABLE, ///< Standalone binary executable (for hosting CPU/OS)
- SLANG_SHADER_SHARED_LIBRARY, ///< A shared library/Dll for shader kernels (for hosting CPU/OS)
- SLANG_SHADER_HOST_CALLABLE, ///< A CPU target that makes the compiled shader code available to be run immediately
- SLANG_CUDA_SOURCE, ///< Cuda source
- SLANG_PTX, ///< PTX
- SLANG_CUDA_OBJECT_CODE, ///< Object code that contains CUDA functions.
- SLANG_OBJECT_CODE, ///< Object code that can be used for later linking
- SLANG_HOST_CPP_SOURCE, ///< C++ code for host library or executable.
- SLANG_HOST_HOST_CALLABLE, ///<
+ SLANG_C_SOURCE, ///< The C language
+ SLANG_CPP_SOURCE, ///< C++ code for shader kernels.
+ SLANG_HOST_EXECUTABLE, ///< Standalone binary executable (for hosting CPU/OS)
+ SLANG_SHADER_SHARED_LIBRARY, ///< A shared library/Dll for shader kernels (for hosting CPU/OS)
+ SLANG_SHADER_HOST_CALLABLE, ///< A CPU target that makes the compiled shader code available to be run immediately
+ SLANG_CUDA_SOURCE, ///< Cuda source
+ SLANG_PTX, ///< PTX
+ SLANG_CUDA_OBJECT_CODE, ///< Object code that contains CUDA functions.
+ SLANG_OBJECT_CODE, ///< Object code that can be used for later linking
+ SLANG_HOST_CPP_SOURCE, ///< C++ code for host library or executable.
+ SLANG_HOST_HOST_CALLABLE, ///< Host callable host code (ie non kernel/shader)
+ SLANG_CPP_PYTORCH_BINDING, ///< C++ PyTorch binding code.
SLANG_TARGET_COUNT_OF,
};
diff --git a/source/compiler-core/slang-downstream-compiler.h b/source/compiler-core/slang-downstream-compiler.h
index 3cd27138f..19f241ccf 100644
--- a/source/compiler-core/slang-downstream-compiler.h
+++ b/source/compiler-core/slang-downstream-compiler.h
@@ -264,9 +264,6 @@ struct name##_AliasDepreciated##id \
static const ptrdiff_t kEnd = SLANG_OFFSET_OF(name, lastField) + sizeof(name::lastField); \
};
-// Specifies via kStart/kEnd a slice of a type that is the previous version.
-SLANG_ALIAS_DEPRECIATED_VERSION(DownstreamCompileOptions, 1, optimizationLevel, sourceManager)
-
/* Used to indicate what kind of products are expected to be produced for a compilation. */
typedef uint32_t DownstreamProductFlags;
struct DownstreamProductFlag
diff --git a/source/compiler-core/slang-llvm-compiler.cpp b/source/compiler-core/slang-llvm-compiler.cpp
index b34c05d42..88446f605 100644
--- a/source/compiler-core/slang-llvm-compiler.cpp
+++ b/source/compiler-core/slang-llvm-compiler.cpp
@@ -6,42 +6,6 @@
namespace Slang
{
-class AliasDepreciatedDownstreamCompiler : public DownstreamCompilerBase
-{
-public:
-
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL compile(const CompileOptions& options, IArtifact** outArtifact) SLANG_OVERRIDE;
- virtual SLANG_NO_THROW bool SLANG_MCALL canConvert(const ArtifactDesc& from, const ArtifactDesc& to) SLANG_OVERRIDE { return m_inner->canConvert(from, to); }
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL convert(IArtifact* from, const ArtifactDesc& to, IArtifact** outArtifact) SLANG_OVERRIDE { return m_inner->convert(from, to, outArtifact); }
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL getVersionString(slang::IBlob** outVersionString) { return m_inner->getVersionString(outVersionString); }
- virtual SLANG_NO_THROW bool SLANG_MCALL isFileBased() { return m_inner->isFileBased(); }
-
- template <typename T>
- void initCompileOptionsDepreciated()
- {
- m_compileOptionsOffset = T::kStart;
- }
-
- AliasDepreciatedDownstreamCompiler(IDownstreamCompiler* inner) :
- m_inner(inner)
- {
- m_desc = inner->getDesc();
- }
-
- ComPtr<IDownstreamCompiler> m_inner;
- ptrdiff_t m_compileOptionsOffset = 0;
-};
-
-SlangResult AliasDepreciatedDownstreamCompiler::compile(const CompileOptions& options, IArtifact** outArtifact)
-{
- if (m_compileOptionsOffset == 0)
- {
- return m_inner->compile(options, outArtifact);
- }
- const uint8_t* ptr = ((const uint8_t*)&options) + m_compileOptionsOffset;
- return m_inner->compile(*(const CompileOptions*)ptr, outArtifact);
-}
-
/* static */SlangResult LLVMDownstreamCompilerUtil::locateCompilers(const String& path, ISlangSharedLibraryLoader* loader, DownstreamCompilerSet* set)
{
ComPtr<ISlangSharedLibrary> library;
@@ -58,18 +22,7 @@ SlangResult AliasDepreciatedDownstreamCompiler::compile(const CompileOptions& op
ComPtr<IDownstreamCompiler> downstreamCompiler;
- if (auto fnV2 = (CreateDownstreamCompilerFunc)library->findFuncByName("createLLVMDownstreamCompiler_V2"))
- {
- ComPtr<IDownstreamCompiler> innerDownstreamCompiler;
-
- SLANG_RETURN_ON_FAIL(fnV2(IDownstreamCompiler::getTypeGuid(), innerDownstreamCompiler.writeRef()));
-
- // We then need to wrap
- AliasDepreciatedDownstreamCompiler* fix = new AliasDepreciatedDownstreamCompiler(innerDownstreamCompiler);
- downstreamCompiler = fix;
- fix->initCompileOptionsDepreciated<DownstreamCompileOptions_AliasDepreciated1>();
- }
- else if (auto fnV3 = (CreateDownstreamCompilerFunc)library->findFuncByName("createLLVMDownstreamCompiler_V3"))
+ if (auto fnV3 = (CreateDownstreamCompilerFunc)library->findFuncByName("createLLVMDownstreamCompiler_V3"))
{
SLANG_RETURN_ON_FAIL(fnV3(IDownstreamCompiler::getTypeGuid(), downstreamCompiler.writeRef()));
}
diff --git a/tests/bugs/stk-chk.slang b/tests/bugs/stk-chk.slang
new file mode 100644
index 000000000..8fabaeee5
--- /dev/null
+++ b/tests/bugs/stk-chk.slang
@@ -0,0 +1,55 @@
+//TEST(compute):COMPARE_COMPUTE:-cpu
+
+// Tests slang-llvm can deal with large items on stack.
+// On some targets this requires special handling (_chkstk on windows for example)
+
+struct LargeStruct
+{
+ int values[4096];
+};
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+//TEST_INPUT:ubuffer(data=[9 1000 27 34], stride=4):name inputBuffer
+StructuredBuffer<int> inputBuffer;
+
+LargeStruct _calcStruct(int a)
+{
+ LargeStruct s;
+
+ int t = a;
+
+ for (int i = 0; i < 4096; ++i)
+ {
+ s.values[i] = t;
+
+ // Munge
+ t = t ^ (i * t) + (i - a) * 17 + inputBuffer[t & 3];
+ }
+
+ return s;
+}
+
+int _calcValue(LargeStruct s)
+{
+ int v = 0;
+ for (int i = 0; i < 4096; ++i)
+ {
+ v ^= s.values[i];
+ }
+ return v + 1;
+}
+
+int _calc1(int a)
+{
+ return _calcValue(_calcStruct(_calcValue(_calcStruct(_calcValue(_calcStruct(a ^ 19))))));
+}
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int index = int(dispatchThreadID.x);
+
+ outputBuffer[index] = _calc1(index) + 1;
+} \ No newline at end of file
diff --git a/tests/bugs/stk-chk.slang.expected.txt b/tests/bugs/stk-chk.slang.expected.txt
new file mode 100644
index 000000000..530a099a9
--- /dev/null
+++ b/tests/bugs/stk-chk.slang.expected.txt
@@ -0,0 +1,4 @@
+5B2F1F3C
+FB3647FB
+AC4B2652
+A954D2BD