@ -72,7 +72,18 @@ namespace MathNet.Numerics.Providers.Common.Mkl
}
/// <returns>Revision</returns>
internal static int Load ( string hintPath = null )
public static int Load ( string hintPath = null )
{
return Load ( hintPath , MklConsistency . Auto , MklPrecision . Double , MklAccuracy . High ) ;
}
/// <returns>Revision</returns>
[CLSCompliant(false)]
public static int Load (
string hintPath = null ,
MklConsistency consistency = MklConsistency . Auto ,
MklPrecision precision = MklPrecision . Double ,
MklAccuracy accuracy = MklAccuracy . High )
{
if ( _l oaded )
{
@ -92,6 +103,19 @@ namespace MathNet.Numerics.Providers.Common.Mkl
_ 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 ) ,
@ -115,45 +139,10 @@ namespace MathNet.Numerics.Providers.Common.Mkl
throw new NotSupportedException ( "MKL 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 ) ;
}
_l oaded = true ;
return _ nativeRevision ;
}
internal static void ConfigureThreading ( )
{
if ( ! _l oaded )
{
throw new InvalidOperationException ( ) ;
}
// set threading settings, if supported
if ( SafeNativeMethods . query_capability ( ( int ) ProviderConfig . Threading ) > 0 )
{
SafeNativeMethods . set_max_threads ( Control . MaxDegreeOfParallelism ) ;
}
}
internal static void ConfigurePrecision ( MklConsistency consistency , MklPrecision precision , MklAccuracy accuracy )
{
if ( ! _l oaded )
{
throw new InvalidOperationException ( ) ;
}
// 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 ) ;
}
}
/// <summary>
/// Frees memory buffers, caches and handles allocated in or to the provider.
/// Does not unload the provider itself, it is still usable afterwards.