Browse Source

Merge branch 'mkl-consistency'

Conflicts:
	src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs
optimization-1
Christoph Ruegg 13 years ago
parent
commit
d49b8fe330
  1. 9
      src/NativeWrappers/MKL/lapack.cpp
  2. 1
      src/Numerics/Numerics.csproj
  3. 2
      src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.cs
  4. 2
      src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.cs
  5. 2
      src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Single.cs
  6. 51
      src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.cs
  7. 2
      src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.double.cs
  8. 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);
}
}

1
src/Numerics/Numerics.csproj

@ -156,6 +156,7 @@
<Compile Include="Providers\LinearAlgebra\ManagedLinearAlgebraProvider.Double.cs" />
<Compile Include="Providers\LinearAlgebra\Mkl\MklLinearAlgebraProvider.Complex.cs" />
<Compile Include="Providers\LinearAlgebra\Mkl\MklLinearAlgebraProvider.Complex32.cs" />
<Compile Include="Providers\LinearAlgebra\Mkl\MklLinearAlgebraProvider.cs" />
<Compile Include="Providers\LinearAlgebra\Mkl\MklLinearAlgebraProvider.Double.cs" />
<Compile Include="Providers\LinearAlgebra\Mkl\MklLinearAlgebraProvider.Single.cs" />
<Compile Include="Providers\LinearAlgebra\Mkl\SafeNativeMethods.cs" />

2
src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.cs

@ -41,7 +41,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
/// <summary>
/// Intel's Math Kernel Library (MKL) linear algebra provider.
/// </summary>
public partial class MklLinearAlgebraProvider : ManagedLinearAlgebraProvider
public partial class MklLinearAlgebraProvider
{
/// <summary>
/// Computes the requested <see cref="Norm"/> of the matrix.

2
src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.cs

@ -40,7 +40,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
/// <summary>
/// Intel's Math Kernel Library (MKL) linear algebra provider.
/// </summary>
public partial class MklLinearAlgebraProvider : ManagedLinearAlgebraProvider
public partial class MklLinearAlgebraProvider
{
/// <summary>
/// Computes the requested <see cref="Norm"/> of the matrix.

2
src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Single.cs

@ -41,7 +41,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
/// <summary>
/// Intel's Math Kernel Library (MKL) linear algebra provider.
/// </summary>
public partial class MklLinearAlgebraProvider : ManagedLinearAlgebraProvider
public partial class MklLinearAlgebraProvider
{
/// <summary>
/// Computes the requested <see cref="Norm"/> of the matrix.

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

@ -0,0 +1,51 @@
// <copyright file="MklLinearAlgebraProvider.cs" company="Math.NET">
// Math.NET Numerics, part of the Math.NET Project
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
//
// Copyright (c) 2009-2013 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
#if NATIVEMKL
namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
{
/// <summary>
/// Intel's Math Kernel Library (MKL) linear algebra provider.
/// </summary>
public partial class MklLinearAlgebraProvider : ManagedLinearAlgebraProvider
{
/// <param name="bitConsistent">If true improves MKL Consistency to get bit consistent results on repeated identical calculations</param>
public MklLinearAlgebraProvider(bool bitConsistent = false)
{
if (bitConsistent)
{
SafeNativeMethods.SetImprovedConsistency();
}
}
}
}
#endif

2
src/Numerics/Providers/LinearAlgebra/Mkl/MklLinearAlgebraProvider.double.cs

@ -41,7 +41,7 @@ namespace MathNet.Numerics.Providers.LinearAlgebra.Mkl
/// <summary>
/// Intel's Math Kernel Library (MKL) linear algebra provider.
/// </summary>
public partial class MklLinearAlgebraProvider : ManagedLinearAlgebraProvider
public partial class MklLinearAlgebraProvider
{
/// <summary>
/// Computes the requested <see cref="Norm"/> of the matrix.

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