private set_max_threads ( int num_threads ) : void | ||
num_threads | int | |
return | void |
/// <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); } }
/// <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() { // TODO: Choose x86 or x64 based on Environment.Is64BitProcess int a, b, linearAlgebra; try { 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) { // we currently accept this to continue to support the old version for a while. // however, this is planned to be dropped for the final v3 release at latest. // TODO: drop return statement and instead fail with the exception below return; throw new NotSupportedException("MKL Native Provider found but does not support capability querying and is therefore not compatible. Try to upgrade to a newer version.", e); } if (a != 0 || b != -1 || linearAlgebra <= 0 || _nativeRevision < 4) { throw new NotSupportedException("MKL Native Provider found but too old or not compatible."); } // 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); } }
/// <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); } }