Skip to content

Commit

Permalink
WIP Save edits before monorepo reorg
Browse files Browse the repository at this point in the history
  • Loading branch information
buybackoff committed Aug 23, 2024
1 parent 2c72680 commit ec59836
Show file tree
Hide file tree
Showing 9 changed files with 268 additions and 218 deletions.
3 changes: 3 additions & 0 deletions docs/Magma_CMake.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cmake .. -G "Ninja" -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER=clang-cl -DCMAKE_Fortran_COMPILER=flang -DCMAKE_LINKER=lld-link -DCMAKE_BUILD_TYPE=Release -DLAPACK_LIBRARIES="C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2020.1.216\windows\mkl\lib\intel64_win\mkl_intel_lp64_dll.lib;C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2020.1.216\windows\mkl\lib\intel64_win\mkl_intel_thread_dll.lib;C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2020.1.216\windows\compiler\lib\intel64_win\libiomp5md.lib" -DMKLROOT="C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2020.1.216\windows\mkl" -DGPU_TARGET="Kepler Maxwell Pascal"

"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat"
156 changes: 113 additions & 43 deletions src/Spreads.BLAS/BLAS.CBLAS.cs

Large diffs are not rendered by default.

80 changes: 11 additions & 69 deletions src/Spreads.BLAS/DataTypes/Complex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,12 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace Spreads.DataTypes
{
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 8)]
public readonly struct ComplexDouble : IEquatable<ComplexDouble>
{
[FieldOffset(0)]
public readonly double Real;

[FieldOffset(8)]
public readonly double Imaginary;

public ComplexDouble(double real, double imaginary)
{
Real = real;
Imaginary = imaginary;
}

public void Deconstruct(out double real, out double imaginary)
{
real = Real;
imaginary = Imaginary;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(ComplexDouble other)
{
return Real.Equals(other.Real) && Imaginary.Equals(other.Imaginary);
}

public override bool Equals(object obj)
{
return obj is ComplexDouble other && Equals(other);
}

public override int GetHashCode()
{
unchecked
{
return (Real.GetHashCode() * 397) ^ Imaginary.GetHashCode();
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(ComplexDouble x, ComplexDouble y)
{
return x.Equals(y);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(ComplexDouble x, ComplexDouble y)
{
return !x.Equals(y);
}
}

[StructLayout(LayoutKind.Explicit, Size = 8, Pack = 4)]
public readonly struct ComplexFloat : IEquatable<ComplexFloat>
{
Expand All @@ -83,15 +31,9 @@ public void Deconstruct(out float real, out float imaginary)
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(ComplexFloat other)
{
return Real.Equals(other.Real) && Imaginary.Equals(other.Imaginary);
}
public bool Equals(ComplexFloat other) => Real.Equals(other.Real) && Imaginary.Equals(other.Imaginary);

public override bool Equals(object obj)
{
return obj is ComplexFloat other && Equals(other);
}
public override bool Equals(object obj) => obj is ComplexFloat other && Equals(other);

public override int GetHashCode()
{
Expand All @@ -102,15 +44,15 @@ public override int GetHashCode()
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(ComplexFloat x, ComplexFloat y)
{
return x.Equals(y);
}
public static bool operator ==(ComplexFloat x, ComplexFloat y) => x.Equals(y);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(ComplexFloat x, ComplexFloat y)
{
return !x.Equals(y);
}
public static bool operator !=(ComplexFloat x, ComplexFloat y) => !x.Equals(y);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Complex(ComplexFloat value) => new Complex(value.Real, value.Imaginary);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static explicit operator ComplexFloat(Complex value) => new ComplexFloat((float)value.Real, (float)value.Imaginary);
}
}
34 changes: 17 additions & 17 deletions src/Spreads.BLAS/Native/MKL.CBLAS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -573,52 +573,52 @@ public static class CBLAS
public static extern void Zher2k(MatrixLayout matrixLayout, UpLoCblas uplo, TransCblas trans, int N, int K, IntPtr alpha, IntPtr A, int lda, IntPtr B, int ldb, double beta, IntPtr C, int ldc);

[SuppressUnmanagedCodeSecurity, DllImport("mkl_rt", EntryPoint = "MKL_Simatcopy", CallingConvention = CallingConvention.Cdecl)]
internal static extern void Simatcopy(MatrixLayoutChar matrixLayout, TransChar trans, ulong rows, ulong cols, float alpha, float* AB, ulong lda, ulong ldb);
public static extern void Simatcopy(MatrixLayoutChar matrixLayout, TransChar trans, ulong rows, ulong cols, float alpha, float* AB, ulong lda, ulong ldb);

[SuppressUnmanagedCodeSecurity, DllImport("mkl_rt", EntryPoint = "MKL_Dimatcopy", CallingConvention = CallingConvention.Cdecl)]
internal static extern void Dimatcopy(MatrixLayoutChar matrixLayout, TransChar trans, ulong rows, ulong cols, double alpha, double* AB, ulong lda, ulong ldb);
public static extern void Dimatcopy(MatrixLayoutChar matrixLayout, TransChar trans, ulong rows, ulong cols, double alpha, double* AB, ulong lda, ulong ldb);

[SuppressUnmanagedCodeSecurity, DllImport("mkl_rt", EntryPoint = "MKL_Cimatcopy", CallingConvention = CallingConvention.Cdecl)]
internal static extern void Cimatcopy(MatrixLayoutChar matrixLayout, TransChar trans, ulong rows, ulong cols, Spreads.DataTypes.ComplexFloat alpha, IntPtr AB, ulong lda, ulong ldb);
public static extern void Cimatcopy(MatrixLayoutChar matrixLayout, TransChar trans, ulong rows, ulong cols, DataTypes.ComplexFloat alpha, IntPtr AB, ulong lda, ulong ldb);

[SuppressUnmanagedCodeSecurity, DllImport("mkl_rt", EntryPoint = "MKL_Zimatcopy", CallingConvention = CallingConvention.Cdecl)]
internal static extern void Zimatcopy(MatrixLayoutChar matrixLayout, TransChar trans, ulong rows, ulong cols, IntPtr alpha, IntPtr AB, ulong lda, ulong ldb);
public static extern void Zimatcopy(MatrixLayoutChar matrixLayout, TransChar trans, ulong rows, ulong cols, IntPtr alpha, IntPtr AB, ulong lda, ulong ldb);

[SuppressUnmanagedCodeSecurity, DllImport("mkl_rt", EntryPoint = "MKL_Somatcopy", CallingConvention = CallingConvention.Cdecl)]
internal static extern void Somatcopy(MatrixLayoutChar matrixLayout, TransChar trans, ulong rows, ulong cols, float alpha, float* A, ulong lda, float* B, ulong ldb);
public static extern void Somatcopy(MatrixLayoutChar matrixLayout, TransChar trans, ulong rows, ulong cols, float alpha, float* A, ulong lda, float* B, ulong ldb);

[SuppressUnmanagedCodeSecurity, DllImport("mkl_rt", EntryPoint = "MKL_Domatcopy", CallingConvention = CallingConvention.Cdecl)]
internal static extern void Domatcopy(MatrixLayoutChar matrixLayout, TransChar trans, ulong rows, ulong cols, double alpha, double* A, ulong lda, double* B, ulong ldb);

public static extern void Domatcopy(MatrixLayoutChar matrixLayout, TransChar trans, ulong rows, ulong cols, double alpha, double* A, ulong lda, double* B, ulong ldb);
[SuppressUnmanagedCodeSecurity, DllImport("mkl_rt", EntryPoint = "MKL_Comatcopy", CallingConvention = CallingConvention.Cdecl)]
internal static extern void Comatcopy(MatrixLayoutChar matrixLayout, TransChar trans, ulong rows, ulong cols, Spreads.DataTypes.ComplexFloat alpha, IntPtr A, ulong lda, IntPtr B, ulong ldb);
public static extern void Comatcopy(MatrixLayoutChar matrixLayout, TransChar trans, ulong rows, ulong cols, DataTypes.ComplexFloat alpha, IntPtr A, ulong lda, IntPtr B, ulong ldb);

[SuppressUnmanagedCodeSecurity, DllImport("mkl_rt", EntryPoint = "MKL_Zomatcopy", CallingConvention = CallingConvention.Cdecl)]
internal static extern void Zomatcopy(MatrixLayoutChar matrixLayout, TransChar trans, ulong rows, ulong cols, IntPtr alpha, IntPtr A, ulong lda, IntPtr B, ulong ldb);
public static extern void Zomatcopy(MatrixLayoutChar matrixLayout, TransChar trans, ulong rows, ulong cols, IntPtr alpha, IntPtr A, ulong lda, IntPtr B, ulong ldb);

[SuppressUnmanagedCodeSecurity, DllImport("mkl_rt", EntryPoint = "MKL_Somatcopy2", CallingConvention = CallingConvention.Cdecl)]
internal static extern void Somatcopy2(MatrixLayoutChar matrixLayout, TransChar trans, ulong rows, ulong cols, float alpha, float* A, ulong lda, ulong stridea, float* B, ulong ldb, ulong strideb);
public static extern void Somatcopy2(MatrixLayoutChar matrixLayout, TransChar trans, ulong rows, ulong cols, float alpha, float* A, ulong lda, ulong stridea, float* B, ulong ldb, ulong strideb);

[SuppressUnmanagedCodeSecurity, DllImport("mkl_rt", EntryPoint = "MKL_Domatcopy2", CallingConvention = CallingConvention.Cdecl)]
internal static extern void Domatcopy2(MatrixLayoutChar matrixLayout, TransChar trans, ulong rows, ulong cols, double alpha, double* A, ulong lda, ulong stridea, double* B, ulong ldb, ulong strideb);
public static extern void Domatcopy2(MatrixLayoutChar matrixLayout, TransChar trans, ulong rows, ulong cols, double alpha, double* A, ulong lda, ulong stridea, double* B, ulong ldb, ulong strideb);

[SuppressUnmanagedCodeSecurity, DllImport("mkl_rt", EntryPoint = "MKL_Comatcopy2", CallingConvention = CallingConvention.Cdecl)]
internal static extern void Comatcopy2(MatrixLayoutChar matrixLayout, TransChar trans, ulong rows, ulong cols, DataTypes.ComplexFloat alpha, IntPtr A, ulong lda, ulong stridea, IntPtr B, ulong ldb, ulong strideb);
public static extern void Comatcopy2(MatrixLayoutChar matrixLayout, TransChar trans, ulong rows, ulong cols, DataTypes.ComplexFloat alpha, IntPtr A, ulong lda, ulong stridea, IntPtr B, ulong ldb, ulong strideb);

[SuppressUnmanagedCodeSecurity, DllImport("mkl_rt", EntryPoint = "MKL_Zomatcopy2", CallingConvention = CallingConvention.Cdecl)]
internal static extern void Zomatcopy2(MatrixLayoutChar matrixLayout, TransChar trans, ulong rows, ulong cols, IntPtr alpha, IntPtr A, ulong lda, ulong stridea, IntPtr B, ulong ldb, ulong strideb);
public static extern void Zomatcopy2(MatrixLayoutChar matrixLayout, TransChar trans, ulong rows, ulong cols, IntPtr alpha, IntPtr A, ulong lda, ulong stridea, IntPtr B, ulong ldb, ulong strideb);

[SuppressUnmanagedCodeSecurity, DllImport("mkl_rt", EntryPoint = "MKL_Somatadd", CallingConvention = CallingConvention.Cdecl)]
internal static extern void Somatadd(MatrixLayoutChar matrixLayout, TransChar transa, TransChar transb, ulong rows, ulong cols, float alpha, float* A, ulong lda, float beta, float* B, ulong ldb, float* C, ulong ldc);
public static extern void Somatadd(MatrixLayoutChar matrixLayout, TransChar transa, TransChar transb, ulong rows, ulong cols, float alpha, float* A, ulong lda, float beta, float* B, ulong ldb, float* C, ulong ldc);

[SuppressUnmanagedCodeSecurity, DllImport("mkl_rt", EntryPoint = "MKL_Domatadd", CallingConvention = CallingConvention.Cdecl)]
internal static extern void Domatadd(MatrixLayoutChar matrixLayout, TransChar transa, TransChar transb, ulong rows, ulong cols, double alpha, double* A, ulong lda, double beta, double* B, ulong ldb, double* C, ulong ldc);
public static extern void Domatadd(MatrixLayoutChar matrixLayout, TransChar transa, TransChar transb, ulong rows, ulong cols, double alpha, double* A, ulong lda, double beta, double* B, ulong ldb, double* C, ulong ldc);

[SuppressUnmanagedCodeSecurity, DllImport("mkl_rt", EntryPoint = "MKL_Comatadd", CallingConvention = CallingConvention.Cdecl)]
internal static extern void Comatadd(MatrixLayoutChar matrixLayout, TransChar transa, TransChar transb, ulong rows, ulong cols, DataTypes.ComplexFloat alpha, IntPtr A, ulong lda, Spreads.DataTypes.ComplexFloat beta, IntPtr B, ulong ldb, IntPtr C, ulong ldc);
public static extern void Comatadd(MatrixLayoutChar matrixLayout, TransChar transa, TransChar transb, ulong rows, ulong cols, DataTypes.ComplexFloat alpha, IntPtr A, ulong lda, Spreads.DataTypes.ComplexFloat beta, IntPtr B, ulong ldb, IntPtr C, ulong ldc);

[SuppressUnmanagedCodeSecurity, DllImport("mkl_rt", EntryPoint = "MKL_Zomatadd", CallingConvention = CallingConvention.Cdecl)]
internal static extern void Zomatadd(MatrixLayoutChar matrixLayout, TransChar transa, TransChar transb, ulong rows, ulong cols, IntPtr alpha, IntPtr A, ulong lda, IntPtr beta, IntPtr B, ulong ldb, IntPtr C, ulong ldc);
public static extern void Zomatadd(MatrixLayoutChar matrixLayout, TransChar transa, TransChar transb, ulong rows, ulong cols, IntPtr alpha, IntPtr A, ulong lda, IntPtr beta, IntPtr B, ulong ldb, IntPtr C, ulong ldc);
}
}
}
Loading

0 comments on commit ec59836

Please sign in to comment.