Skip to content

Commit

Permalink
Updated pre-generated LibDevice to use Cuda SDK v8.
Browse files Browse the repository at this point in the history
  • Loading branch information
MoFtZ committed Jan 22, 2024
1 parent ac36bf2 commit b46856d
Show file tree
Hide file tree
Showing 3 changed files with 336 additions and 329 deletions.
2 changes: 1 addition & 1 deletion Src/ILGPU/Backends/PTX/PTXLibDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static void FindLibDevicePaths(
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

0 comments on commit b46856d

Please sign in to comment.