Browse Source

updated gotoblas to not call serveal routines

la-knuth
Marcus Cuda 16 years ago
parent
commit
f068a33ca5
  1. 1
      src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.tt
  2. 1
      src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.tt
  3. 1
      src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.double.tt
  4. 1
      src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.float.tt
  5. 27
      src/Numerics/Algorithms/LinearAlgebra/native.dotproduct.include
  6. 74
      src/Numerics/Algorithms/LinearAlgebra/native.generic.include
  7. 1
      src/Numerics/Numerics.csproj

1
src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex.tt

@ -8,6 +8,7 @@
<# string prefix = "z";#>
<# string svd_work = "2 * Math.Min(rowsA, columnsA) + Math.Max(rowsA, columnsA)";#>
<#@ include file="..\native.header.include" #>
<#@ include file="..\native.dotproduct.include" #>
<#@ include file="..\native.generic.include" #>
<#@ include file="..\native.vector.include" #>
<#@ include file="..\native.footer.include" #>

1
src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.Complex32.tt

@ -8,6 +8,7 @@
<# string prefix = "c";#>
<# string svd_work = "2 * Math.Min(rowsA, columnsA) + Math.Max(rowsA, columnsA)";#>
<#@ include file="..\native.header.include" #>
<#@ include file="..\native.dotproduct.include" #>
<#@ include file="..\native.generic.include" #>
<#@ include file="..\native.vector.include" #>
<#@ include file="..\native.footer.include" #>

1
src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.double.tt

@ -8,6 +8,7 @@
<# string prefix = "d";#>
<# string svd_work = "Math.Max((3 * Math.Min(rowsA, columnsA)) + Math.Max(rowsA, columnsA), 5 * Math.Min(rowsA, columnsA))";#>
<#@ include file="..\native.header.include" #>
<#@ include file="..\native.dotproduct.include" #>
<#@ include file="..\native.generic.include" #>
<#@ include file="..\native.vector.include" #>
<#@ include file="..\native.footer.include" #>

1
src/Numerics/Algorithms/LinearAlgebra/Mkl/MklLinearAlgebraProvider.float.tt

@ -8,6 +8,7 @@
<# string prefix = "s";#>
<# string svd_work = "Math.Max((3 * Math.Min(rowsA, columnsA) + Math.Max(rowsA, columnsA)), 5 * Math.Min(rowsA, columnsA))";#>
<#@ include file="..\native.header.include" #>
<#@ include file="..\native.dotproduct.include" #>
<#@ include file="..\native.generic.include" #>
<#@ include file="..\native.vector.include" #>
<#@ include file="..\native.footer.include" #>

27
src/Numerics/Algorithms/LinearAlgebra/native.dotproduct.include

@ -0,0 +1,27 @@
 /// <summary>
/// Computes the dot product of x and y.
/// </summary>
/// <param name="x">The vector x.</param>
/// <param name="y">The vector y.</param>
/// <returns>The dot product of x and y.</returns>
/// <remarks>This is equivalent to the DOT BLAS routine.</remarks>
[SecuritySafeCritical]
public override <#=dataType#> DotProduct(<#=dataType#>[] x, <#=dataType#>[] y)
{
if (y == null)
{
throw new ArgumentNullException("y");
}
if (x == null)
{
throw new ArgumentNullException("x");
}
if (x.Length != y.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
return SafeNativeMethods.<#=prefix#>_dot_product(x.Length, x, y);
}

74
src/Numerics/Algorithms/LinearAlgebra/native.generic.include

@ -65,34 +65,6 @@
SafeNativeMethods.<#=prefix#>_scale(x.Length, alpha, result);
}
/// <summary>
/// Computes the dot product of x and y.
/// </summary>
/// <param name="x">The vector x.</param>
/// <param name="y">The vector y.</param>
/// <returns>The dot product of x and y.</returns>
/// <remarks>This is equivalent to the DOT BLAS routine.</remarks>
[SecuritySafeCritical]
public override <#=dataType#> DotProduct(<#=dataType#>[] x, <#=dataType#>[] y)
{
if (y == null)
{
throw new ArgumentNullException("y");
}
if (x == null)
{
throw new ArgumentNullException("x");
}
if (x.Length != y.Length)
{
throw new ArgumentException(Resources.ArgumentArraysSameLength);
}
return SafeNativeMethods.<#=prefix#>_dot_product(x.Length, x, y);
}
/// <summary>
/// Multiples two matrices. <c>result = x * y</c>
/// </summary>
@ -215,7 +187,18 @@
}
var work = new <#=dataType#>[order];
SafeNativeMethods.<#=prefix#>_lu_inverse(order, a, work, order);
<# if (dataType == "float") { #>
if (Control.LinearAlgebraProvider is Algorithms.LinearAlgebra.GotoBlas.GotoBlasLinearAlgebraProvider)
{
new ManagedLinearAlgebraProvider().LUInverse(a, order, work);
}
else
{
SafeNativeMethods.s_lu_inverse(order, a, work, work.Length);
}
<# } else{#>
SafeNativeMethods.<#=prefix#>_lu_inverse(order, a, work, work.Length);
<# } #>
}
/// <summary>
@ -249,7 +232,18 @@
}
var work = new <#=dataType#>[order];
<# if (dataType == "float") { #>
if (Control.LinearAlgebraProvider is Algorithms.LinearAlgebra.GotoBlas.GotoBlasLinearAlgebraProvider)
{
new ManagedLinearAlgebraProvider().LUInverseFactored(a, order, ipiv, work);
}
else
{
SafeNativeMethods.s_lu_inverse_factored(order, a, ipiv, work, order);
}
<# }else{ #>
SafeNativeMethods.<#=prefix#>_lu_inverse_factored(order, a, ipiv, work, order);
<# } #>
}
/// <summary>
@ -284,7 +278,18 @@
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
<# if (dataType == "float") { #>
if (Control.LinearAlgebraProvider is Algorithms.LinearAlgebra.GotoBlas.GotoBlasLinearAlgebraProvider)
{
new ManagedLinearAlgebraProvider().LUInverse(a, order, work);
}
else
{
SafeNativeMethods.s_lu_inverse(order, a, work, work.Length);
}
<# } else{#>
SafeNativeMethods.<#=prefix#>_lu_inverse(order, a, work, work.Length);
<# } #>
}
/// <summary>
@ -330,7 +335,18 @@
throw new ArgumentException(Resources.WorkArrayTooSmall, "work");
}
<# if (dataType == "float") { #>
if (Control.LinearAlgebraProvider is Algorithms.LinearAlgebra.GotoBlas.GotoBlasLinearAlgebraProvider)
{
new ManagedLinearAlgebraProvider().LUInverseFactored(a, order, ipiv, work);
}
else
{
SafeNativeMethods.s_lu_inverse_factored(order, a, ipiv, work, order);
}
<# }else{ #>
SafeNativeMethods.<#=prefix#>_lu_inverse_factored(order, a, ipiv, work, order);
<# } #>
}
/// <summary>

1
src/Numerics/Numerics.csproj

@ -70,6 +70,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="Algorithms\LinearAlgebra\native.dotproduct.include" />
<None Include="Algorithms\LinearAlgebra\GotoBlas\GotoBlasLinearAlgebraProvider.Common.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>GotoBlasLinearAlgebraProvider.Common.cs</LastGenOutput>

Loading…
Cancel
Save