diff --git a/MathNet.Numerics.NativeProviders.sln b/MathNet.Numerics.NativeProviders.sln
index 98886230..92e05cf4 100644
--- a/MathNet.Numerics.NativeProviders.sln
+++ b/MathNet.Numerics.NativeProviders.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
-VisualStudioVersion = 12.0.21005.1
+VisualStudioVersion = 12.0.30110.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{5A0892FF-82CE-40FC-BCE1-73810C615F52}"
ProjectSection(SolutionItems) = preProject
diff --git a/src/NativeProviders/Common/resource.rc b/src/NativeProviders/Common/resource.rc
index 6a29d47f..b0382206 100644
--- a/src/NativeProviders/Common/resource.rc
+++ b/src/NativeProviders/Common/resource.rc
@@ -51,8 +51,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,3,0,0
- PRODUCTVERSION 1,3,0,0
+ FILEVERSION 1,4,0,0
+ PRODUCTVERSION 1,4,0,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -70,12 +70,12 @@ BEGIN
VALUE "Comments", "http://numerics.mathdotnet.com/"
VALUE "CompanyName", "Math.NET"
VALUE "FileDescription", "MathNET Numerics Native Provider"
- VALUE "FileVersion", "1.3.0.0"
+ VALUE "FileVersion", "1.4.0.0"
VALUE "InternalName", "Math.NET"
- VALUE "LegalCopyright", "Copyright (C) Math.NET 2009-2013"
+ VALUE "LegalCopyright", "Copyright (C) Math.NET 2009-2014"
VALUE "OriginalFilename", "MathNet.Numerics"
VALUE "ProductName", "Math.NET Numerics"
- VALUE "ProductVersion", "1.3.0.0"
+ VALUE "ProductVersion", "1.4.0.0"
END
END
BLOCK "VarFileInfo"
diff --git a/src/NativeProviders/MKL/capabilities.cpp b/src/NativeProviders/MKL/capabilities.cpp
new file mode 100644
index 00000000..21502a82
--- /dev/null
+++ b/src/NativeProviders/MKL/capabilities.cpp
@@ -0,0 +1,61 @@
+#include "wrapper_common.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+ /*
+ Capability is supported if >0
+
+ Actual number can be increased over time to indicate
+ extensions/revisions (that do not break compatibility)
+ */
+ DLLEXPORT int query_capability(const int capability)
+ {
+ switch (capability)
+ {
+
+ // SANITY CHECKS
+ case 0: return 0;
+ case 1: return -1;
+
+ // PLATFORM
+ case 8:
+#ifdef _M_IX86
+ return 1;
+#else
+ return 0;
+#endif
+ case 9:
+#ifdef _M_X64
+ return 1;
+#else
+ return 0;
+#endif
+ case 10:
+#ifdef _M_IA64
+ return 1;
+#else
+ return 0;
+#endif
+
+ // COMMON/SHARED
+ case 64: return 4; // revision
+
+ // LINEAR ALGEBRA
+ case 128: return 1; // basic dense linear algebra
+
+ // OPTIMIZATION
+ case 256: return 0; // basic optimization
+
+ // FFT
+ case 384: return 0; // basic FFT
+
+ default: return 0; // unknown or not supported
+
+ }
+ }
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
diff --git a/src/NativeProviders/Windows/MKL/MKLWrapper.vcxproj b/src/NativeProviders/Windows/MKL/MKLWrapper.vcxproj
index f121b5b5..c74c7519 100644
--- a/src/NativeProviders/Windows/MKL/MKLWrapper.vcxproj
+++ b/src/NativeProviders/Windows/MKL/MKLWrapper.vcxproj
@@ -290,6 +290,7 @@
+
diff --git a/src/NativeProviders/Windows/MKL/MKLWrapper.vcxproj.filters b/src/NativeProviders/Windows/MKL/MKLWrapper.vcxproj.filters
index 0a96af4e..d8da27eb 100644
--- a/src/NativeProviders/Windows/MKL/MKLWrapper.vcxproj.filters
+++ b/src/NativeProviders/Windows/MKL/MKLWrapper.vcxproj.filters
@@ -27,6 +27,9 @@
Source Files
+
+ Source Files
+
diff --git a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs
index 6d04ab14..dcff254d 100644
--- a/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs
+++ b/src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs
@@ -28,6 +28,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
#if NATIVEMKL
namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
@@ -37,6 +39,11 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
///
public partial class MklLinearAlgebraProvider : ManagedLinearAlgebraProvider
{
+ int _nativeRevision = 0;
+ bool _nativeIX86 = false;
+ bool _nativeX64 = false;
+ bool _nativeIA64 = false;
+
/// If true improves MKL Consistency to get bit consistent results on repeated identical calculations
public MklLinearAlgebraProvider(bool bitConsistent = false)
{
@@ -52,13 +59,43 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
public override void InitializeVerify()
{
// TODO: Choose x86 or x64 based on Environment.Is64BitProcess
- // TODO: call into MKL to verify
+
+ int a = 0, b = 0, linearAlgebra = 0;
+ 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 (BadImageFormatException e)
+ {
+ throw new NotSupportedException("MKL Native Provider 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 does not support capability querying and is therefore not compatible. Try to upgrade to a newer version (1).", e);
+ }
+
+ if (a != 0 || b != -1 || linearAlgebra <=0 || _nativeRevision < 4)
+ {
+ throw new NotSupportedException("MKL Native Provider too old or not compatible (2).");
+ }
}
public override string ToString()
{
- // TODO: query version and platform and add to string
- return "Intel MKL";
+ return string.Format("Intel MKL ({1}; revision {0})", _nativeRevision, _nativeIX86 ? "x86" : _nativeX64 ? "x64" : _nativeIA64 ? "IA64" : "unknown");
}
}
}
diff --git a/src/Numerics/Providers/LinearAlgebra/Mkl/SafeNativeMethods.cs b/src/Numerics/Providers/LinearAlgebra/Mkl/SafeNativeMethods.cs
index 768f3527..b6dfc59d 100644
--- a/src/Numerics/Providers/LinearAlgebra/Mkl/SafeNativeMethods.cs
+++ b/src/Numerics/Providers/LinearAlgebra/Mkl/SafeNativeMethods.cs
@@ -46,6 +46,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
///
const string DllName = "MathNet.Numerics.MKL.dll";
+ [DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int query_capability(int capability);
+
#region BLAS
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]