diff --git a/src/Numerics/Providers/Common/Cuda/CudaProvider.cs b/src/Numerics/Providers/Common/Cuda/CudaProvider.cs
index 9f175ed2..03fdde51 100644
--- a/src/Numerics/Providers/Common/Cuda/CudaProvider.cs
+++ b/src/Numerics/Providers/Common/Cuda/CudaProvider.cs
@@ -47,12 +47,7 @@ namespace MathNet.Numerics.Providers.Common.Cuda
public static bool IsAvailable(string hintPath = null)
{
- return IsAvailable(_minimumCompatibleRevision, hintPath);
- }
-
- internal static bool IsAvailable(int minRevision, string hintPath)
- {
- if (_loaded && _nativeRevision >= minRevision)
+ if (_loaded)
{
return true;
}
@@ -67,7 +62,7 @@ namespace MathNet.Numerics.Providers.Common.Cuda
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;
+ return a == 0 && b == -1 && nativeRevision >= _minimumCompatibleRevision;
}
catch
{
@@ -75,16 +70,12 @@ namespace MathNet.Numerics.Providers.Common.Cuda
}
}
- public static void Load(string hintPath = null)
- {
- Load(_minimumCompatibleRevision, hintPath);
- }
-
- internal static void Load(int minRevision, string hintPath)
+ /// Revision
+ public static int Load(string hintPath = null)
{
- if (_loaded && _nativeRevision >= minRevision)
+ if (_loaded)
{
- return;
+ return _nativeRevision;
}
int a, b;
@@ -113,12 +104,13 @@ namespace MathNet.Numerics.Providers.Common.Cuda
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)
+ if (a != 0 || b != -1 || _nativeRevision < _minimumCompatibleRevision)
{
throw new NotSupportedException("Cuda Native Provider too old. Consider upgrading to a newer version.");
}
_loaded = true;
+ return _nativeRevision;
}
public static string Describe()
diff --git a/src/Numerics/Providers/Common/Mkl/MklProvider.cs b/src/Numerics/Providers/Common/Mkl/MklProvider.cs
index d31f2b55..bd81421a 100644
--- a/src/Numerics/Providers/Common/Mkl/MklProvider.cs
+++ b/src/Numerics/Providers/Common/Mkl/MklProvider.cs
@@ -48,12 +48,7 @@ namespace MathNet.Numerics.Providers.Common.Mkl
public static bool IsAvailable(string hintPath = null)
{
- return IsAvailable(_minimumCompatibleRevision, hintPath);
- }
-
- internal static bool IsAvailable(int minRevision, string hintPath)
- {
- if (_loaded && _nativeRevision >= minRevision)
+ if (_loaded)
{
return true;
}
@@ -68,7 +63,7 @@ namespace MathNet.Numerics.Providers.Common.Mkl
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;
+ return a == 0 && b == -1 && nativeRevision >= _minimumCompatibleRevision;
}
catch
{
@@ -76,16 +71,12 @@ namespace MathNet.Numerics.Providers.Common.Mkl
}
}
- public static void Load(string hintPath = null)
- {
- Load(_minimumCompatibleRevision, hintPath);
- }
-
- internal static void Load(int minRevision, string hintPath)
+ /// Revision
+ internal static int Load(string hintPath = null)
{
- if (_loaded && _nativeRevision >= minRevision)
+ if (_loaded)
{
- return;
+ return _nativeRevision;
}
int a, b;
@@ -119,7 +110,7 @@ namespace MathNet.Numerics.Providers.Common.Mkl
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 < minRevision)
+ if (a != 0 || b != -1 || _nativeRevision < _minimumCompatibleRevision)
{
throw new NotSupportedException("MKL Native Provider too old. Consider upgrading to a newer version.");
}
@@ -131,6 +122,7 @@ namespace MathNet.Numerics.Providers.Common.Mkl
}
_loaded = true;
+ return _nativeRevision;
}
internal static void ConfigureThreading()
diff --git a/src/Numerics/Providers/Common/OpenBlas/OpenBlasProvider.cs b/src/Numerics/Providers/Common/OpenBlas/OpenBlasProvider.cs
index c2d0d474..26de9406 100644
--- a/src/Numerics/Providers/Common/OpenBlas/OpenBlasProvider.cs
+++ b/src/Numerics/Providers/Common/OpenBlas/OpenBlasProvider.cs
@@ -48,12 +48,7 @@ namespace MathNet.Numerics.Providers.Common.OpenBlas
public static bool IsAvailable(string hintPath = null)
{
- return IsAvailable(_minimumCompatibleRevision, hintPath);
- }
-
- internal static bool IsAvailable(int minRevision, string hintPath)
- {
- if (_loaded && _nativeRevision >= minRevision)
+ if (_loaded)
{
return true;
}
@@ -68,7 +63,7 @@ namespace MathNet.Numerics.Providers.Common.OpenBlas
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;
+ return a == 0 && b == -1 && nativeRevision >= _minimumCompatibleRevision;
}
catch
{
@@ -76,16 +71,12 @@ namespace MathNet.Numerics.Providers.Common.OpenBlas
}
}
- public static void Load(string hintPath = null)
- {
- Load(_minimumCompatibleRevision, hintPath);
- }
-
- internal static void Load(int minRevision, string hintPath)
+ /// Revision
+ public static int Load(string hintPath = null)
{
- if (_loaded && _nativeRevision >= minRevision)
+ if (_loaded)
{
- return;
+ return _nativeRevision;
}
int a, b;
@@ -115,7 +106,7 @@ namespace MathNet.Numerics.Providers.Common.OpenBlas
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 < minRevision)
+ if (a != 0 || b != -1 || _nativeRevision < _minimumCompatibleRevision)
{
throw new NotSupportedException("OpenBLAS Native Provider too old. Consider upgrading to a newer version.");
}
@@ -127,6 +118,7 @@ namespace MathNet.Numerics.Providers.Common.OpenBlas
}
_loaded = true;
+ return _nativeRevision;
}
internal static void ConfigureThreading()
diff --git a/src/Numerics/Providers/FourierTransform/Mkl/MklFourierTransformProvider.cs b/src/Numerics/Providers/FourierTransform/Mkl/MklFourierTransformProvider.cs
index f27dc07a..55cc3894 100644
--- a/src/Numerics/Providers/FourierTransform/Mkl/MklFourierTransformProvider.cs
+++ b/src/Numerics/Providers/FourierTransform/Mkl/MklFourierTransformProvider.cs
@@ -2,7 +2,7 @@
// Math.NET Numerics, part of the Math.NET Project
// https://numerics.mathdotnet.com
//
-// Copyright (c) 2009-2016 Math.NET
+// Copyright (c) 2009-2018 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -37,6 +37,8 @@ namespace MathNet.Numerics.Providers.FourierTransform.Mkl
{
internal class MklFourierTransformProvider : IFourierTransformProvider, IDisposable
{
+ const int _minimumCompatibleRevision = 11;
+
class Kernel
{
public IntPtr Handle;
@@ -61,7 +63,7 @@ namespace MathNet.Numerics.Providers.FourierTransform.Mkl
///
public bool IsAvailable()
{
- return MklProvider.IsAvailable(minRevision: 11, hintPath: _hintPath);
+ return MklProvider.IsAvailable(hintPath: _hintPath);
}
///
@@ -69,7 +71,11 @@ namespace MathNet.Numerics.Providers.FourierTransform.Mkl
///
public void InitializeVerify()
{
- MklProvider.Load(minRevision: 11, hintPath: _hintPath);
+ int revision = MklProvider.Load(hintPath: _hintPath);
+ if (revision < _minimumCompatibleRevision)
+ {
+ throw new NotSupportedException($"MKL Native Provider revision r{revision} is too old. Consider upgrading to a newer version. Revision r{_minimumCompatibleRevision} and newer are supported.");
+ }
// we only support exactly one major version, since major version changes imply a breaking change.
int fftMajor = SafeNativeMethods.query_capability((int) ProviderCapability.FourierTransformMajor);
diff --git a/src/Numerics/Providers/LinearAlgebra/Cuda/CudaLinearAlgebraProvider.cs b/src/Numerics/Providers/LinearAlgebra/Cuda/CudaLinearAlgebraProvider.cs
index 5fbd80bd..7956c56d 100644
--- a/src/Numerics/Providers/LinearAlgebra/Cuda/CudaLinearAlgebraProvider.cs
+++ b/src/Numerics/Providers/LinearAlgebra/Cuda/CudaLinearAlgebraProvider.cs
@@ -3,7 +3,7 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
//
-// Copyright (c) 2009-2016 Math.NET
+// Copyright (c) 2009-2018 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -39,6 +39,8 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Cuda
///
internal partial class CudaLinearAlgebraProvider : ManagedLinearAlgebraProvider, IDisposable
{
+ const int _minimumCompatibleRevision = 1;
+
readonly string _hintPath;
IntPtr _blasHandle;
IntPtr _solverHandle;
@@ -55,7 +57,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Cuda
///
public override bool IsAvailable()
{
- return CudaProvider.IsAvailable(minRevision: 1, hintPath: _hintPath);
+ return CudaProvider.IsAvailable(hintPath: _hintPath);
}
///
@@ -64,7 +66,11 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Cuda
///
public override void InitializeVerify()
{
- CudaProvider.Load(minRevision: 1, hintPath: _hintPath);
+ int revision = CudaProvider.Load(hintPath: _hintPath);
+ if (revision < _minimumCompatibleRevision)
+ {
+ throw new NotSupportedException($"Cuda Native Provider revision r{revision} is too old. Consider upgrading to a newer version. Revision r{_minimumCompatibleRevision} and newer are supported.");
+ }
int linearAlgebra = SafeNativeMethods.query_capability((int)ProviderCapability.LinearAlgebraMajor);
diff --git a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs
index be85463a..210a6172 100644
--- a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs
+++ b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs
@@ -3,7 +3,7 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
//
-// Copyright (c) 2009-2016 Math.NET
+// Copyright (c) 2009-2018 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -50,6 +50,8 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
///
internal partial class MklLinearAlgebraProvider : ManagedLinearAlgebraProvider
{
+ const int _minimumCompatibleRevision = 4;
+
readonly string _hintPath;
readonly MklConsistency _consistency;
readonly MklPrecision _precision;
@@ -81,7 +83,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
///
public override bool IsAvailable()
{
- return MklProvider.IsAvailable(minRevision: 4, hintPath: _hintPath);
+ return MklProvider.IsAvailable(hintPath: _hintPath);
}
///
@@ -90,7 +92,12 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
///
public override void InitializeVerify()
{
- MklProvider.Load(minRevision: 4, hintPath: _hintPath);
+ int revision = MklProvider.Load(hintPath: _hintPath);
+ if (revision < _minimumCompatibleRevision)
+ {
+ throw new NotSupportedException($"MKL Native Provider revision r{revision} is too old. Consider upgrading to a newer version. Revision r{_minimumCompatibleRevision} and newer are supported.");
+ }
+
MklProvider.ConfigurePrecision(_consistency, _precision, _accuracy);
_linearAlgebraMajor = SafeNativeMethods.query_capability((int)ProviderCapability.LinearAlgebraMajor);
diff --git a/src/Numerics/Providers/LinearAlgebra/OpenBlas/OpenBlasLinearAlgebraProvider.cs b/src/Numerics/Providers/LinearAlgebra/OpenBlas/OpenBlasLinearAlgebraProvider.cs
index fc0a4f08..301d40b2 100644
--- a/src/Numerics/Providers/LinearAlgebra/OpenBlas/OpenBlasLinearAlgebraProvider.cs
+++ b/src/Numerics/Providers/LinearAlgebra/OpenBlas/OpenBlasLinearAlgebraProvider.cs
@@ -3,7 +3,7 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
//
-// Copyright (c) 2009-2016 Math.NET
+// Copyright (c) 2009-2018 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -57,6 +57,8 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.OpenBlas
///
internal partial class OpenBlasLinearAlgebraProvider : ManagedLinearAlgebraProvider
{
+ const int _minimumCompatibleRevision = 1;
+
readonly string _hintPath;
/// Hint path where to look for the native binaries
@@ -71,7 +73,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.OpenBlas
///
public override bool IsAvailable()
{
- return OpenBlasProvider.IsAvailable(minRevision: 1, hintPath: _hintPath);
+ return OpenBlasProvider.IsAvailable(hintPath: _hintPath);
}
///
@@ -80,7 +82,11 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.OpenBlas
///
public override void InitializeVerify()
{
- OpenBlasProvider.Load(minRevision: 1, hintPath: _hintPath);
+ int revision = OpenBlasProvider.Load(hintPath: _hintPath);
+ if (revision < _minimumCompatibleRevision)
+ {
+ throw new NotSupportedException($"OpenBLAS Native Provider revision r{revision} is too old. Consider upgrading to a newer version. Revision r{_minimumCompatibleRevision} and newer are supported.");
+ }
int linearAlgebra = SafeNativeMethods.query_capability((int)ProviderCapability.LinearAlgebraMajor);