public static bool IsAvailable(string hintPath = null) { if (_loaded) { return(true); } if (AppSwitches.DisableNativeProviders || AppSwitches.DisableMklNativeProvider) { return(false); } try { if (!NativeProviderLoader.TryLoad(SafeNativeMethods.DllName, hintPath)) { return(false); } int a = SafeNativeMethods.query_capability(0); int b = SafeNativeMethods.query_capability(1); int nativeRevision = SafeNativeMethods.query_capability((int)ProviderConfig.Revision); return(a == 0 && b == -1 && nativeRevision >= MinimumCompatibleRevision); } catch { return(false); } }
public static void Load(int minRevision) { int a, b; try { NativeProviderLoader.TryLoad(SafeNativeMethods.DllName); a = SafeNativeMethods.query_capability(0); b = SafeNativeMethods.query_capability(1); _nativeRevision = SafeNativeMethods.query_capability((int)ProviderConfig.Revision); _nativeX86 = SafeNativeMethods.query_capability((int)ProviderPlatform.x86) > 0; _nativeX64 = SafeNativeMethods.query_capability((int)ProviderPlatform.x64) > 0; _nativeIA64 = SafeNativeMethods.query_capability((int)ProviderPlatform.ia64) > 0; } catch (DllNotFoundException e) { throw new NotSupportedException("Cuda Native Provider not found.", e); } catch (BadImageFormatException e) { throw new NotSupportedException("Cuda Native Provider found but failed to load. Please verify that the platform matches (x64 vs x32, Windows vs Linux).", e); } catch (EntryPointNotFoundException e) { throw new NotSupportedException("Cuda Native Provider does not support capability querying and is therefore not compatible. Consider upgrading to a newer version.", e); } if (a != 0 || b != -1 || _nativeRevision < minRevision) { throw new NotSupportedException("Cuda Native Provider too old. Consider upgrading to a newer version."); } }
/// <summary> /// Initialize and verify that the provided is indeed available. /// If calling this method fails, consider to fall back to alternatives like the managed provider. /// </summary> public override void InitializeVerify() { int a, b, linearAlgebra; try { // Load the native library NativeProviderLoader.TryLoad(SafeNativeMethods.DllName); a = SafeNativeMethods.query_capability(0); b = SafeNativeMethods.query_capability(1); _nativeIX86 = SafeNativeMethods.query_capability((int)ProviderPlatform.x86) > 0; _nativeX64 = SafeNativeMethods.query_capability((int)ProviderPlatform.x64) > 0; _nativeIA64 = SafeNativeMethods.query_capability((int)ProviderPlatform.ia64) > 0; _nativeRevision = SafeNativeMethods.query_capability((int)ProviderConfig.Revision); linearAlgebra = SafeNativeMethods.query_capability((int)ProviderCapability.LinearAlgebra); } catch (DllNotFoundException e) { throw new NotSupportedException("MKL Native Provider not found.", e); } catch (BadImageFormatException e) { throw new NotSupportedException("MKL Native Provider found but failed to load. Please verify that the platform matches (x64 vs x32, Windows vs Linux).", e); } catch (EntryPointNotFoundException e) { throw new NotSupportedException("MKL Native Provider does not support capability querying and is therefore not compatible. Consider upgrading to a newer version.", e); } if (a != 0 || b != -1 || _nativeRevision < 4) { throw new NotSupportedException("MKL Native Provider too old. Consider upgrading to a newer version."); } // we only support exactly one major version, since major version changes imply a breaking change. if (linearAlgebra != 2) { throw new NotSupportedException(string.Format("MKL Native Provider not compatible. Expecting linear algebra v2 but provider implements v{0}.", linearAlgebra)); } // set numerical consistency, precision and accuracy modes, if supported if (SafeNativeMethods.query_capability((int)ProviderConfig.Precision) > 0) { SafeNativeMethods.set_consistency_mode((int)_consistency); SafeNativeMethods.set_vml_mode((uint)_precision | (uint)_accuracy); } // set threading settings, if supported if (SafeNativeMethods.query_capability((int)ProviderConfig.Threading) > 0) { SafeNativeMethods.set_max_threads(Control.MaxDegreeOfParallelism); } }
/// <returns>Revision</returns> public static int Load(string hintPath = null) { if (_loaded) { return(_nativeRevision); } if (AppSwitches.DisableNativeProviders || AppSwitches.DisableOpenBlasNativeProvider) { throw new NotSupportedException("OpenBLAS Native Provider support is actively disabled by AppSwitches."); } int a, b; try { NativeProviderLoader.TryLoad(SafeNativeMethods.DllName, hintPath); a = SafeNativeMethods.query_capability(0); b = SafeNativeMethods.query_capability(1); _nativeRevision = SafeNativeMethods.query_capability((int)ProviderConfig.Revision); _nativeX86 = SafeNativeMethods.query_capability((int)ProviderPlatform.x86) > 0; _nativeX64 = SafeNativeMethods.query_capability((int)ProviderPlatform.x64) > 0; _nativeIA64 = SafeNativeMethods.query_capability((int)ProviderPlatform.ia64) > 0; _nativeARM = SafeNativeMethods.query_capability((int)ProviderPlatform.arm) > 0; } catch (DllNotFoundException e) { throw new NotSupportedException("OpenBLAS Native Provider not found.", e); } catch (BadImageFormatException e) { throw new NotSupportedException("OpenBLAS Native Provider found but failed to load. Please verify that the platform matches (x64 vs x32, Windows vs Linux).", e); } catch (EntryPointNotFoundException e) { throw new NotSupportedException("OpenBLAS Native Provider does not support capability querying and is therefore not compatible. Consider upgrading to a newer version.", e); } if (a != 0 || b != -1 || _nativeRevision < MinimumCompatibleRevision) { throw new NotSupportedException("OpenBLAS Native Provider too old. Consider upgrading to a newer version."); } // set threading settings, if supported if (SafeNativeMethods.query_capability((int)ProviderConfig.Threading) > 0) { SafeNativeMethods.set_max_threads(Control.MaxDegreeOfParallelism); } _loaded = true; return(_nativeRevision); }
/// <summary> /// Initialize and verify that the provided is indeed available. /// If calling this method fails, consider to fall back to alternatives like the managed provider. /// </summary> public override void InitializeVerify() { int a, b, linearAlgebra; try { // Load the native library NativeProviderLoader.TryLoad(SafeNativeMethods.DllName); a = SafeNativeMethods.query_capability(0); b = SafeNativeMethods.query_capability(1); _nativeIX86 = SafeNativeMethods.query_capability(8) > 0; _nativeX64 = SafeNativeMethods.query_capability(9) > 0; _nativeIA64 = SafeNativeMethods.query_capability(10) > 0; _nativeRevision = SafeNativeMethods.query_capability(64); linearAlgebra = SafeNativeMethods.query_capability(128); } catch (DllNotFoundException e) { throw new NotSupportedException("MKL Native Provider not found.", e); } catch (BadImageFormatException e) { throw new NotSupportedException("MKL Native Provider found but failed to load. Please verify that the platform matches (x64 vs x32, Windows vs Linux).", e); } catch (EntryPointNotFoundException e) { throw new NotSupportedException("MKL Native Provider does not support capability querying and is therefore not compatible. Consider upgrading to a newer version.", e); } if (a != 0 || b != -1 || linearAlgebra <= 0 || _nativeRevision < 4) { throw new NotSupportedException("MKL Native Provider too old or not compatible. Consider upgrading to a newer version."); } // set numerical consistency, precision and accuracy modes, if supported if (SafeNativeMethods.query_capability(65) > 0) { SafeNativeMethods.set_consistency_mode((int)_consistency); SafeNativeMethods.set_vml_mode((uint)_precision | (uint)_accuracy); } // set threading settings, if supported if (SafeNativeMethods.query_capability(66) > 0) { SafeNativeMethods.set_max_threads(Control.MaxDegreeOfParallelism); } }
public override void InitializeVerify() { int a, b, linearAlgebra; try { // Load the native library NativeProviderLoader.TryLoad(SafeNativeMethods.DllName); a = SafeNativeMethods.query_capability(0); b = SafeNativeMethods.query_capability(1); _nativeIX86 = SafeNativeMethods.query_capability((int)ProviderPlatform.x86) > 0; _nativeX64 = SafeNativeMethods.query_capability((int)ProviderPlatform.x64) > 0; _nativeIA64 = SafeNativeMethods.query_capability((int)ProviderPlatform.ia64) > 0; _nativeARM = SafeNativeMethods.query_capability((int)ProviderPlatform.arm) > 0; _nativeRevision = SafeNativeMethods.query_capability((int)ProviderConfig.Revision); linearAlgebra = SafeNativeMethods.query_capability((int)ProviderCapability.LinearAlgebra); } catch (DllNotFoundException e) { throw new NotSupportedException("OpenBLAS Native Provider not found.", e); } catch (BadImageFormatException e) { throw new NotSupportedException("OpenBLAS Native Provider found but failed to load. Please verify that the platform matches (x64 vs x32, Windows vs Linux).", e); } catch (EntryPointNotFoundException e) { throw new NotSupportedException("OpenBLAS Native Provider does not support capability querying and is therefore not compatible. Consider upgrading to a newer version.", e); } if (a != 0 || b != -1 || linearAlgebra <= 0 || _nativeRevision < 1) { throw new NotSupportedException("OpenBLAS Native Provider too old or not compatible. Consider upgrading to a newer version."); } // set threading settings, if supported if (SafeNativeMethods.query_capability((int)ProviderConfig.Threading) > 0) { SafeNativeMethods.set_max_threads(Control.MaxDegreeOfParallelism); } }
public static bool IsAvailable(int minRevision) { try { if (!NativeProviderLoader.TryLoad(SafeNativeMethods.DllName)) { return(false); } int a = SafeNativeMethods.query_capability(0); int b = SafeNativeMethods.query_capability(1); int nativeRevision = SafeNativeMethods.query_capability((int)ProviderConfig.Revision); return(a == 0 && b == -1 && nativeRevision >= minRevision); } catch { return(false); } }
/// <summary> /// Initialize and verify that the provided is indeed available. /// If calling this method fails, consider to fall back to alternatives like the managed provider. /// </summary> public override void InitializeVerify() { int a, b, linearAlgebra; try { // Load the native library NativeProviderLoader.TryLoad(SafeNativeMethods.DllName); a = SafeNativeMethods.query_capability(0); b = SafeNativeMethods.query_capability(1); _nativeIX86 = SafeNativeMethods.query_capability(8) > 0; _nativeX64 = SafeNativeMethods.query_capability(9) > 0; _nativeIA64 = SafeNativeMethods.query_capability(10) > 0; _nativeRevision = SafeNativeMethods.query_capability(64); linearAlgebra = SafeNativeMethods.query_capability(128); } catch (DllNotFoundException e) { throw new NotSupportedException("Cuda Native Provider not found.", e); } catch (BadImageFormatException e) { throw new NotSupportedException("Cuda Native Provider found but failed to load. Please verify that the platform matches (x64 vs x32, Windows vs Linux).", e); } catch (EntryPointNotFoundException e) { throw new NotSupportedException("Cuda Native Provider does not support capability querying and is therefore not compatible. Consider upgrading to a newer version.", e); } if (a != 0 || b != -1 || linearAlgebra <= 0 || _nativeRevision < 1) { throw new NotSupportedException("Cuda Native Provider too old or not compatible. Consider upgrading to a newer version."); } BLAS(SafeNativeMethods.createBLASHandle(ref _blasHandle)); Solver(SafeNativeMethods.createSolverHandle(ref _solverHandle)); }
public static int Load( string hintPath = null, MklConsistency consistency = MklConsistency.Auto, MklPrecision precision = MklPrecision.Double, MklAccuracy accuracy = MklAccuracy.High) { if (_loaded) { return(_nativeRevision); } int a, b; try { NativeProviderLoader.TryLoad(SafeNativeMethods.DllName, hintPath); a = SafeNativeMethods.query_capability(0); b = SafeNativeMethods.query_capability(1); _nativeRevision = SafeNativeMethods.query_capability((int)ProviderConfig.Revision); _nativeX86 = SafeNativeMethods.query_capability((int)ProviderPlatform.x86) > 0; _nativeX64 = SafeNativeMethods.query_capability((int)ProviderPlatform.x64) > 0; _nativeIA64 = SafeNativeMethods.query_capability((int)ProviderPlatform.ia64) > 0; // set numerical consistency, precision and accuracy modes, if supported if (SafeNativeMethods.query_capability((int)ProviderConfig.Precision) > 0) { SafeNativeMethods.set_consistency_mode((int)consistency); SafeNativeMethods.set_vml_mode((uint)precision | (uint)accuracy); } // set threading settings, if supported if (SafeNativeMethods.query_capability((int)ProviderConfig.Threading) > 0) { SafeNativeMethods.set_max_threads(Control.MaxDegreeOfParallelism); } _mklVersion = new Version( SafeNativeMethods.query_capability((int)ProviderConfig.MklMajorVersion), SafeNativeMethods.query_capability((int)ProviderConfig.MklMinorVersion), SafeNativeMethods.query_capability((int)ProviderConfig.MklUpdateVersion)); } catch (DllNotFoundException e) { throw new NotSupportedException("MKL Native Provider not found.", e); } catch (BadImageFormatException e) { throw new NotSupportedException("MKL Native Provider found but failed to load. Please verify that the platform matches (x64 vs x32, Windows vs Linux).", e); } catch (EntryPointNotFoundException e) { throw new NotSupportedException("MKL Native Provider does not support capability querying and is therefore not compatible. Consider upgrading to a newer version.", e); } if (a != 0 || b != -1 || _nativeRevision < MinimumCompatibleRevision) { throw new NotSupportedException("MKL Native Provider too old. Consider upgrading to a newer version."); } _loaded = true; return(_nativeRevision); }