diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-12-12 11:39:19 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-12 11:39:19 -0500 |
| commit | 6e6a876a6b5ad3d2ef402757d2e20641f5a2b49b (patch) | |
| tree | 29eab69c4982537376d7eaf422d9090c849e95f7 /tools/slang-test/test-context.cpp | |
| parent | 79ec0cfdb5f3461c763e0bf712cf42eb87fccb90 (diff) | |
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.
Diffstat (limited to 'tools/slang-test/test-context.cpp')
| -rw-r--r-- | tools/slang-test/test-context.cpp | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/tools/slang-test/test-context.cpp b/tools/slang-test/test-context.cpp index c37261b61..d333dbcaa 100644 --- a/tools/slang-test/test-context.cpp +++ b/tools/slang-test/test-context.cpp @@ -3,6 +3,7 @@ #include "../../source/core/slang-io.h" #include "../../source/core/slang-string-util.h" +#include "../../source/core/slang-shared-library.h" #include <stdio.h> #include <stdlib.h> @@ -27,15 +28,6 @@ Result TestContext::init() TestContext::~TestContext() { - for (auto& pair : m_sharedLibTools) - { - const auto& tool = pair.Value; - if (tool.m_sharedLibrary) - { - SharedLibrary::unload(tool.m_sharedLibrary); - } - } - if (m_session) { spDestroySession(m_session); @@ -60,11 +52,13 @@ TestContext::InnerMainFunc TestContext::getInnerMainFunc(const String& dirPath, SharedLibrary::appendPlatformFileName(sharedLibToolBuilder.getUnownedSlice(), builder); String path = Path::combine(dirPath, builder); + DefaultSharedLibraryLoader* loader = DefaultSharedLibraryLoader::getSingleton(); + SharedLibraryTool tool = {}; - if (SLANG_SUCCEEDED(SharedLibrary::loadWithPlatformPath(path.begin(), tool.m_sharedLibrary))) + if (SLANG_SUCCEEDED(loader->loadPlatformSharedLibrary(path.begin(), tool.m_sharedLibrary.writeRef()))) { - tool.m_func = (InnerMainFunc)SharedLibrary::findFuncByName(tool.m_sharedLibrary, "innerMain"); + tool.m_func = (InnerMainFunc)tool.m_sharedLibrary->findFuncByName("innerMain"); } m_sharedLibTools.Add(name, tool); @@ -76,12 +70,7 @@ void TestContext::setInnerMainFunc(const String& name, InnerMainFunc func) SharedLibraryTool* tool = m_sharedLibTools.TryGetValue(name); if (tool) { - if (tool->m_sharedLibrary) - { - SharedLibrary::unload(tool->m_sharedLibrary); - tool->m_sharedLibrary = nullptr; - } - + tool->m_sharedLibrary.setNull(); tool->m_func = func; } else @@ -99,14 +88,19 @@ DownstreamCompilerSet* TestContext::getCompilerSet() compilerSet = new DownstreamCompilerSet; DownstreamCompilerUtil::InitializeSetDesc desc; + + ComPtr<ISlangSharedLibrary> nvrtcSharedLibrary; + DefaultSharedLibraryLoader::getSingleton()->loadSharedLibrary(DefaultSharedLibraryLoader::getSharedLibraryNameFromType(SharedLibraryType::NVRTC), nvrtcSharedLibrary.writeRef()); + desc.sharedLibraries[int(DownstreamCompiler::CompilerType::NVRTC)] = nvrtcSharedLibrary; + DownstreamCompilerUtil::initializeSet(desc, compilerSet); } return compilerSet; } -Slang::DownstreamCompiler* TestContext::getDefaultCompiler() +Slang::DownstreamCompiler* TestContext::getDefaultCompiler(DownstreamCompiler::SourceType sourceType) { DownstreamCompilerSet* set = getCompilerSet(); - return set ? set->getDefaultCompiler() : nullptr; + return set ? set->getDefaultCompiler(sourceType) : nullptr; } |
