From 6e6a876a6b5ad3d2ef402757d2e20641f5a2b49b Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 12 Dec 2019 11:39:19 -0500 Subject: Slang compiles CUDA source via NVRTC (#1151) * CPPCompiler -> DownstreamCompiler * Added DownstreamCompileResult to start abstraction such that we don't need files. * * Split out slang-blob.cpp * Made CompileResult hold a DownstreamCompileResult - for access to binary or ISlangSharedLibrary * Keep temporary files in scope. * Add a hash to the hex dump stream. * Move all file tracking into DownstreamCompiler. * WIP support for nvrtc. * WIP: Adding support for nvrtc compiler. Adding enum types, wiring up the nvrtc into slang. * Fix remaining CPPCompiler references. * Fix order issue on target string matching. * Use ISlangSharedLibrary for nvrtc. * Use DownstreamCompiler for nvrtc. * WIP first pass at compilation win nvrtc. * Added testing if file is on file system into CommandLineDownstreamCompiler. Added sourceContentsPath. * Make test cuda-compile.cu work by just compiling not comparing output. * Fix warning on clang. --- source/core/slang-shared-library.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'source/core/slang-shared-library.cpp') diff --git a/source/core/slang-shared-library.cpp b/source/core/slang-shared-library.cpp index fd61ba0a0..2b18ad6aa 100644 --- a/source/core/slang-shared-library.cpp +++ b/source/core/slang-shared-library.cpp @@ -22,6 +22,7 @@ static const Guid IID_ISlangSharedLibraryLoader = SLANG_UUID_ISlangSharedLibrary "d3dcompiler_47", // SharedLibraryType::Fxc "slang-glslang", // SharedLibraryType::Glslang "dxil", // SharedLibraryType::Dxil + "nvrtc64_102_0", // SharedLibraryType::NVRTC }; /* static */DefaultSharedLibraryLoader DefaultSharedLibraryLoader::s_singleton; @@ -44,13 +45,23 @@ ISlangUnknown* DefaultSharedLibraryLoader::getInterface(const Guid& guid) return (guid == IID_ISlangUnknown || guid == IID_ISlangSharedLibraryLoader) ? static_cast(this) : nullptr; } -SlangResult DefaultSharedLibraryLoader::loadSharedLibrary(const char* path, ISlangSharedLibrary** sharedLibraryOut) +SlangResult DefaultSharedLibraryLoader::loadSharedLibrary(const char* path, ISlangSharedLibrary** outSharedLibrary) { - *sharedLibraryOut = nullptr; + *outSharedLibrary = nullptr; // Try loading SharedLibrary::Handle handle; SLANG_RETURN_ON_FAIL(SharedLibrary::load(path, handle)); - *sharedLibraryOut = ComPtr(new DefaultSharedLibrary(handle)).detach(); + *outSharedLibrary = ComPtr(new DefaultSharedLibrary(handle)).detach(); + return SLANG_OK; +} + +SlangResult DefaultSharedLibraryLoader::loadPlatformSharedLibrary(const char* path, ISlangSharedLibrary** outSharedLibrary) +{ + *outSharedLibrary = nullptr; + // Try loading + SharedLibrary::Handle handle; + SLANG_RETURN_ON_FAIL(SharedLibrary::loadWithPlatformPath(path, handle)); + *outSharedLibrary = ComPtr(new DefaultSharedLibrary(handle)).detach(); return SLANG_OK; } -- cgit v1.2.3