Skip to content

Commit

Permalink
Updated NVVM to support Cuda SDK v8.
Browse files Browse the repository at this point in the history
  • Loading branch information
MoFtZ committed Apr 9, 2024
1 parent 177d109 commit 2ca0702
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
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

0 comments on commit 2ca0702

Please sign in to comment.