Browse Source

Set Improved MKL Consistency

optimization-1
Martin Posch 13 years ago
parent
commit
44f3541f42
  1. 9
      src/NativeWrappers/MKL/lapack.cpp
  2. 8
      src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs
  3. 3
      src/Numerics/Providers/LinearAlgebra/Mkl/SafeNativeMethods.cs

9
src/NativeWrappers/MKL/lapack.cpp

@ -8,6 +8,8 @@
#include "lapack_common.h"
#include "wrapper_common.h"
#include "mkl_lapacke.h"
#include "mkl.h"
#include "mkl_trans.h"
template<typename T>
inline MKL_INT lu_factor(MKL_INT m, T a[], MKL_INT ipiv[],
@ -748,4 +750,11 @@ extern "C" {
return eigen_complex_factor<MKL_Complex16>(n, a, vectors, values, d, LAPACKE_zgees, LAPACKE_ztrevc);
}
}
DLLEXPORT void SetImprovedConsistency(void)
{
// set improved consistency for mkl and vector functions
mkl_cbwr_set(MKL_CBWR_COMPATIBLE);
vmlSetMode(VML_HA|VML_DOUBLE_CONSISTENT);
}
}

8
src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs

@ -42,6 +42,14 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
/// </summary>
public partial class MklLinearAlgebraProvider : ManagedLinearAlgebraProvider
{
/// <summary>
/// Improves MKL Consistency to get bit consistent results on repeated identical calculations
/// </summary>
public MklLinearAlgebraProvider()
{
SafeNativeMethods.SetImprovedConsistency();
}
/// <summary>
/// Computes the requested <see cref="Norm"/> of the matrix.
/// </summary>

3
src/Numerics/Providers/LinearAlgebra/Mkl/SafeNativeMethods.cs

@ -100,6 +100,9 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
#region LAPACK
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void SetImprovedConsistency();
[DllImport(DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern float s_matrix_norm(byte norm, int rows, int columns, [In] float[] a, [In, Out] float[] work);

Loading…
Cancel
Save