Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated NVVM to support Cuda SDK v8. #1187

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Src/ILGPU/Context.Builder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ---------------------------------------------------------------------------------------
// ILGPU
// Copyright (c) 2021-2023 ILGPU Project
// Copyright (c) 2021-2024 ILGPU Project
// www.ilgpu.net
//
// File: Context.Builder.cs
Expand Down Expand Up @@ -345,7 +345,7 @@ public Builder LibDevice()
var nvvmBinDir = Path.Combine(nvvmRoot, nvvmBinName);
var nvvmSearchPattern =
RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? "nvvm*.dll"
? "nvvm64*.dll"
: "libnvvm*.so";
var nvvmFiles = Directory.EnumerateFiles(nvvmBinDir, nvvmSearchPattern);
LibNvvmPath = nvvmFiles.FirstOrDefault()
Expand Down
23 changes: 15 additions & 8 deletions Src/ILGPU/Runtime/Cuda/NvvmAPI.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ---------------------------------------------------------------------------------------
// ILGPU
// Copyright (c) 2021-2023 ILGPU Project
// Copyright (c) 2021-2024 ILGPU Project
// www.ilgpu.net
//
// File: NvvmAPI.cs
Expand Down Expand Up @@ -138,7 +138,7 @@ public static NvvmAPI Create(string libNvvmPath, string libDevicePath) =>
private readonly NvvmCreateProgram nvvmCreateProgram;
private readonly NvvmDestroyProgram nvvmDestroyProgram;
private readonly NvvmAddModuleToProgram nvvmAddModuleToProgram;
private readonly NvvmLazyAddModuleToProgram nvvmLazyAddModuleToProgram;
private readonly NvvmLazyAddModuleToProgram? nvvmLazyAddModuleToProgram;
private readonly NvvmCompileProgram nvvmCompileProgram;
private readonly NvvmVerifyProgram nvvmVerifyProgram;
private readonly NvvmGetCompiledResultSize nvvmGetCompiledResultSize;
Expand Down Expand Up @@ -183,11 +183,6 @@ private NvvmAPI(string libNvvmPath, string libDevicePath)
NativeLibrary.GetExport(
libNvvmModule,
"nvvmAddModuleToProgram"));
nvvmLazyAddModuleToProgram =
Marshal.GetDelegateForFunctionPointer<NvvmLazyAddModuleToProgram>(
NativeLibrary.GetExport(
libNvvmModule,
"nvvmLazyAddModuleToProgram"));
nvvmCompileProgram =
Marshal.GetDelegateForFunctionPointer<NvvmCompileProgram>(
NativeLibrary.GetExport(
Expand Down Expand Up @@ -218,6 +213,16 @@ private NvvmAPI(string libNvvmPath, string libDevicePath)
NativeLibrary.GetExport(
libNvvmModule,
"nvvmGetProgramLog"));

if (NativeLibrary.TryGetExport(
libNvvmModule,
"nvvmLazyAddModuleToProgram",
out var nvvmLazyAddModuleToProgramPtr))
{
nvvmLazyAddModuleToProgram =
Marshal.GetDelegateForFunctionPointer<NvvmLazyAddModuleToProgram>(
nvvmLazyAddModuleToProgramPtr);
}
}

/// <inheritdoc/>
Expand Down Expand Up @@ -311,7 +316,9 @@ public NvvmResult LazyAddModuleToProgram(
IntPtr buffer,
IntPtr size,
string? name) =>
nvvmLazyAddModuleToProgram(program, buffer, size, name);
nvvmLazyAddModuleToProgram != null
? nvvmLazyAddModuleToProgram(program, buffer, size, name)
: nvvmAddModuleToProgram(program, buffer, size, name);

/// <summary>
/// Compiles the program.
Expand Down
Loading