diff --git a/Src/ILGPU/Context.Builder.cs b/Src/ILGPU/Context.Builder.cs index 989a97be5..036a0b056 100644 --- a/Src/ILGPU/Context.Builder.cs +++ b/Src/ILGPU/Context.Builder.cs @@ -1,6 +1,6 @@ // --------------------------------------------------------------------------------------- // ILGPU -// Copyright (c) 2021-2023 ILGPU Project +// Copyright (c) 2021-2024 ILGPU Project // www.ilgpu.net // // File: Context.Builder.cs @@ -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() diff --git a/Src/ILGPU/Runtime/Cuda/NvvmAPI.cs b/Src/ILGPU/Runtime/Cuda/NvvmAPI.cs index be4e258cc..b7b9f689f 100644 --- a/Src/ILGPU/Runtime/Cuda/NvvmAPI.cs +++ b/Src/ILGPU/Runtime/Cuda/NvvmAPI.cs @@ -1,6 +1,6 @@ // --------------------------------------------------------------------------------------- // ILGPU -// Copyright (c) 2021-2023 ILGPU Project +// Copyright (c) 2021-2024 ILGPU Project // www.ilgpu.net // // File: NvvmAPI.cs @@ -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; @@ -183,11 +183,6 @@ private NvvmAPI(string libNvvmPath, string libDevicePath) NativeLibrary.GetExport( libNvvmModule, "nvvmAddModuleToProgram")); - nvvmLazyAddModuleToProgram = - Marshal.GetDelegateForFunctionPointer( - NativeLibrary.GetExport( - libNvvmModule, - "nvvmLazyAddModuleToProgram")); nvvmCompileProgram = Marshal.GetDelegateForFunctionPointer( NativeLibrary.GetExport( @@ -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( + nvvmLazyAddModuleToProgramPtr); + } } /// @@ -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); /// /// Compiles the program.