Esempio n. 1
0
 protected override void CoreFreeNativeLibrary(IntPtr handle)
 {
     if (handle != IntPtr.Zero)
     {
         NativeLibrary3.Free(handle);
     }
 }
Esempio n. 2
0
 /// <inheritdoc/>
 protected override void Dispose(bool disposing)
 {
     if (libNvvmModule != IntPtr.Zero)
     {
         NativeLibrary.Free(libNvvmModule);
         libNvvmModule = IntPtr.Zero;
     }
     base.Dispose(disposing);
 }
Esempio n. 3
0
            protected override IntPtr CoreLoadFunctionPointer(IntPtr handle, string functionName)
            {
                if (NativeLibrary3.TryGetExport(handle, functionName, out var ptr))
                {
                    return(ptr);
                }

                return(IntPtr.Zero);
            }
Esempio n. 4
0
            protected override IntPtr CoreLoadNativeLibrary(string name)
            {
                if (NativeLibrary3.TryLoad(name, Assembly.GetCallingAssembly(), null, out var lib))
                {
                    return(lib);
                }

                return(IntPtr.Zero);
            }
Esempio n. 5
0
 protected override IntPtr CoreLoadFunctionPointer(IntPtr handle, string functionName)
 {
     return(NativeLibrary3.GetExport(handle, functionName));
 }
Esempio n. 6
0
 protected override IntPtr CoreLoadNativeLibrary(string name)
 {
     return(NativeLibrary3.Load(name, Assembly.GetCallingAssembly(), null));
 }
Esempio n. 7
0
        private NvvmAPI(string libNvvmPath, string libDevicePath)
        {
            libNvvmModule  = NativeLibrary.Load(libNvvmPath);
            libDeviceBytes = !string.IsNullOrEmpty(libDevicePath)
                ? File.ReadAllBytes(libDevicePath)
                : Array.Empty <byte>();

            nvvmGetErrorString =
                Marshal.GetDelegateForFunctionPointer <NvvmGetErrorString>(
                    NativeLibrary.GetExport(
                        libNvvmModule,
                        "nvvmGetErrorString"));
            nvvmVersion =
                Marshal.GetDelegateForFunctionPointer <NvvmVersion>(
                    NativeLibrary.GetExport(
                        libNvvmModule,
                        "nvvmVersion"));
            nvvmIRVersion =
                Marshal.GetDelegateForFunctionPointer <NvvmIRVersion>(
                    NativeLibrary.GetExport(
                        libNvvmModule,
                        "nvvmIRVersion"));
            nvvmCreateProgram =
                Marshal.GetDelegateForFunctionPointer <NvvmCreateProgram>(
                    NativeLibrary.GetExport(
                        libNvvmModule,
                        "nvvmCreateProgram"));
            nvvmDestroyProgram =
                Marshal.GetDelegateForFunctionPointer <NvvmDestroyProgram>(
                    NativeLibrary.GetExport(
                        libNvvmModule,
                        "nvvmDestroyProgram"));
            nvvmAddModuleToProgram =
                Marshal.GetDelegateForFunctionPointer <NvvmAddModuleToProgram>(
                    NativeLibrary.GetExport(
                        libNvvmModule,
                        "nvvmAddModuleToProgram"));
            nvvmLazyAddModuleToProgram =
                Marshal.GetDelegateForFunctionPointer <NvvmLazyAddModuleToProgram>(
                    NativeLibrary.GetExport(
                        libNvvmModule,
                        "nvvmLazyAddModuleToProgram"));
            nvvmCompileProgram =
                Marshal.GetDelegateForFunctionPointer <NvvmCompileProgram>(
                    NativeLibrary.GetExport(
                        libNvvmModule,
                        "nvvmCompileProgram"));
            nvvmVerifyProgram =
                Marshal.GetDelegateForFunctionPointer <NvvmVerifyProgram>(
                    NativeLibrary.GetExport(
                        libNvvmModule,
                        "nvvmVerifyProgram"));
            nvvmGetCompiledResultSize =
                Marshal.GetDelegateForFunctionPointer <NvvmGetCompiledResultSize>(
                    NativeLibrary.GetExport(
                        libNvvmModule,
                        "nvvmGetCompiledResultSize"));
            nvvmGetCompiledResult =
                Marshal.GetDelegateForFunctionPointer <NvvmGetCompiledResult>(
                    NativeLibrary.GetExport(
                        libNvvmModule,
                        "nvvmGetCompiledResult"));
            nvvmGetProgramLogSize =
                Marshal.GetDelegateForFunctionPointer <NvvmGetProgramLogSize>(
                    NativeLibrary.GetExport(
                        libNvvmModule,
                        "nvvmGetProgramLogSize"));
            nvvmGetProgramLog =
                Marshal.GetDelegateForFunctionPointer <NvvmGetProgramLog>(
                    NativeLibrary.GetExport(
                        libNvvmModule,
                        "nvvmGetProgramLog"));
        }