diff --git a/.gitignore b/.gitignore index b1556d7d..70216951 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ UpgradeLog.htm *.bak *.vsdoc *.XML +*.so diff --git a/src/NativeWrappers/Common/lapack_common.h b/src/NativeWrappers/Common/lapack_common.h index f26298a8..ab2aa46a 100644 --- a/src/NativeWrappers/Common/lapack_common.h +++ b/src/NativeWrappers/Common/lapack_common.h @@ -1,6 +1,8 @@ #ifndef LAPACK_COMMON_H #define LAPACK_COMMON_H +#include + void shift_ipiv_down(int m, int ipiv[]); inline void shift_ipiv_down(int m, int ipiv[]){ for(int i = 0; i < m; ++i ){ @@ -19,12 +21,12 @@ template inline T* Clone(const int m, const int n, const T* a) { T* clone = new T[m*n]; - std::memcpy(clone, a, m*n*sizeof(T)); + memcpy(clone, a, m*n*sizeof(T)); return clone; } template -void copyBtoX (int m, int n, int bn, T b[], T x[]){ +inline void copyBtoX (int m, int n, int bn, T b[], T x[]){ for (int i = 0; i < n; ++i) { for (int j = 0; j < bn; ++j) @@ -34,4 +36,4 @@ void copyBtoX (int m, int n, int bn, T b[], T x[]){ } } -#endif \ No newline at end of file +#endif diff --git a/src/NativeWrappers/Linux/build.sh b/src/NativeWrappers/Linux/build.sh new file mode 100755 index 00000000..c30ad1bd --- /dev/null +++ b/src/NativeWrappers/Linux/build.sh @@ -0,0 +1,6 @@ +export INTEL=/opt/intel +export MKL=$INTEL/mkl + +g++ --shared -fPIC -o ./x64/MathNet.Numerics.MKL.so -I$MKL/include -I../Common ../MKL/vector_functions.c ../MKL/blas.c ../MKL/lapack.cpp $INTEL/lib/intel64/libiomp5.a $MKL/lib/intel64/libmkl_intel_lp64.a $MKL/lib/intel64/libmkl_intel_thread.a $MKL/lib/intel64/libmkl_core.a + +g++ -m32 --shared -fPIC -o ./x86/MathNet.Numerics.MKL.so -I$MKL/include -I../Common ../MKL/vector_functions.c ../MKL/blas.c ../MKL/lapack.cpp $INTEL/lib/ia32/libiomp5.a $MKL/lib/ia32/libmkl_intel.a $MKL/lib/ia32/libmkl_intel_thread.a $MKL/lib/ia32/libmkl_core.a diff --git a/src/NativeWrappers/MKL/blas.c b/src/NativeWrappers/MKL/blas.c index c63b4beb..4eb75f1f 100644 --- a/src/NativeWrappers/MKL/blas.c +++ b/src/NativeWrappers/MKL/blas.c @@ -53,28 +53,28 @@ DLLEXPORT MKL_Complex16 z_dot_product(const MKL_INT n, const MKL_Complex16 x[], return ret; } -DLLEXPORT void s_matrix_multiply(const enum CBLAS_TRANSPOSE transA, const enum CBLAS_TRANSPOSE transB, const MKL_INT m, const MKL_INT n, const MKL_INT k, const float alpha, const float x[], const float y[], const float beta, float c[]){ +DLLEXPORT void s_matrix_multiply(CBLAS_TRANSPOSE transA, CBLAS_TRANSPOSE transB, const MKL_INT m, const MKL_INT n, const MKL_INT k, const float alpha, const float x[], const float y[], const float beta, float c[]){ MKL_INT lda = transA == CblasNoTrans ? m : k; MKL_INT ldb = transB == CblasNoTrans ? k : n; cblas_sgemm(CblasColMajor, transA, transB, m, n, k, alpha, x, lda, y, ldb, beta, c, m); } -DLLEXPORT void d_matrix_multiply(const enum CBLAS_TRANSPOSE transA, const enum CBLAS_TRANSPOSE transB, const MKL_INT m, const MKL_INT n, const MKL_INT k, const double alpha, const double x[], const double y[], const double beta, double c[]){ +DLLEXPORT void d_matrix_multiply(CBLAS_TRANSPOSE transA, CBLAS_TRANSPOSE transB, const MKL_INT m, const MKL_INT n, const MKL_INT k, const double alpha, const double x[], const double y[], const double beta, double c[]){ MKL_INT lda = transA == CblasNoTrans ? m : k; MKL_INT ldb = transB == CblasNoTrans ? k : n; cblas_dgemm(CblasColMajor, transA, transB, m, n, k, alpha, x, lda, y, ldb, beta, c, m); } -DLLEXPORT void c_matrix_multiply(const enum CBLAS_TRANSPOSE transA, const enum CBLAS_TRANSPOSE transB, const MKL_INT m, const MKL_INT n, const MKL_INT k, const MKL_Complex8 alpha, const MKL_Complex8 x[], const MKL_Complex8 y[], const MKL_Complex8 beta, MKL_Complex8 c[]){ +DLLEXPORT void c_matrix_multiply(CBLAS_TRANSPOSE transA, CBLAS_TRANSPOSE transB, const MKL_INT m, const MKL_INT n, const MKL_INT k, const MKL_Complex8 alpha, const MKL_Complex8 x[], const MKL_Complex8 y[], const MKL_Complex8 beta, MKL_Complex8 c[]){ MKL_INT lda = transA == CblasNoTrans ? m : k; MKL_INT ldb = transB == CblasNoTrans ? k : n; cblas_cgemm(CblasColMajor, transA, transB, m, n, k, &alpha, x, lda, y, ldb, &beta, c, m); } -DLLEXPORT void z_matrix_multiply(const enum CBLAS_TRANSPOSE transA, const enum CBLAS_TRANSPOSE transB, const MKL_INT m, const MKL_INT n, const MKL_INT k, const MKL_Complex16 alpha, const MKL_Complex16 x[], const MKL_Complex16 y[], const MKL_Complex16 beta, MKL_Complex16 c[]){ +DLLEXPORT void z_matrix_multiply(CBLAS_TRANSPOSE transA, CBLAS_TRANSPOSE transB, const MKL_INT m, const MKL_INT n, const MKL_INT k, const MKL_Complex16 alpha, const MKL_Complex16 x[], const MKL_Complex16 y[], const MKL_Complex16 beta, MKL_Complex16 c[]){ MKL_INT lda = transA == CblasNoTrans ? m : k; MKL_INT ldb = transB == CblasNoTrans ? k : n; diff --git a/src/NativeWrappers/Windows/MKL/MKLWrapper.vcxproj b/src/NativeWrappers/Windows/MKL/MKLWrapper.vcxproj index 12de51fe..ae0a68a4 100644 --- a/src/NativeWrappers/Windows/MKL/MKLWrapper.vcxproj +++ b/src/NativeWrappers/Windows/MKL/MKLWrapper.vcxproj @@ -9,6 +9,14 @@ Debug x64 + + Intel_SSA + Win32 + + + Intel_SSA + x64 + Release Win32 @@ -36,6 +44,12 @@ MultiByte Parallel + + DynamicLibrary + Intel C++ Compiler XE 13.0 + MultiByte + Parallel + DynamicLibrary v110 @@ -49,6 +63,12 @@ MultiByte Parallel + + DynamicLibrary + Intel C++ Compiler XE 13.0 + MultiByte + Parallel + @@ -58,12 +78,18 @@ + + + + + + <_ProjectFileVersion>11.0.50727.1 @@ -71,18 +97,32 @@ $(SolutionDir)..\..\..\lib\Windows\$(Platform)\ $(Platform)\$(Configuration)\ + MathNet.Numerics.MKL + + + $(SolutionDir)..\..\..\lib\Windows\$(Platform)\ + $(Platform)\$(Configuration)\ + MathNet.Numerics.MKL $(SolutionDir)..\..\..\lib\Windows\$(Platform)\ $(Platform)\$(Configuration)\ + MathNet.Numerics.MKL + + + $(SolutionDir)..\..\..\lib\Windows\$(Platform)\ + $(Platform)\$(Configuration)\ + MathNet.Numerics.MKL $(SolutionDir)..\..\..\lib\Windows\$(Platform)\ $(Platform)\$(Configuration)\ + MathNet.Numerics.MKL $(SolutionDir)..\..\..\lib\Windows\$(Platform)\ $(Platform)\$(Configuration)\ + MathNet.Numerics.MKL @@ -98,10 +138,38 @@ libiomp5md.lib;mkl_intel_c.lib;mkl_intel_thread.lib;mkl_core.lib;%(AdditionalDependencies) - $(OutDir)MathNET.Numerics.MKL.dll + $(OutDir)$(TargetName)$(TargetExt) $(OmpLibDir)\;$(MKLLibDir)\;%(AdditionalLibraryDirectories) true MachineX86 + $(OutDir)$(TargetName).lib + + + + + + + + + Disabled + $(ProjectDir)..\..\Common;$(ProjectDir)..\..\MKL;$(MKLIncludeDir);%(AdditionalIncludeDirectories) + _WINDOWS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + Level3 + EditAndContinue + Default + Verbose + Full + + + libiomp5md.lib;mkl_intel_c.lib;mkl_intel_thread.lib;mkl_core.lib;%(AdditionalDependencies) + $(OutDir)$(TargetName)$(TargetExt) + $(OmpLibDir)\;$(MKLLibDir)\;%(AdditionalLibraryDirectories) + true + MachineX86 + $(OutDir)$(TargetName).lib @@ -125,10 +193,41 @@ libiomp5md.lib;mkl_intel_lp64.lib;mkl_intel_thread.lib;mkl_core.lib;%(AdditionalDependencies) - $(OutDir)MathNET.Numerics.MKL.dll + $(OutDir)$(TargetName)$(TargetExt) + $(OmpLibDir)\;$(MKLLibDir)\;%(AdditionalLibraryDirectories) + true + MachineX64 + $(OutDir)$(TargetName).lib + + + + + + + + + X64 + + + Disabled + $(ProjectDir)..\..\Common;$(ProjectDir)..\..\MKL;$(MKLIncludeDir);%(AdditionalIncludeDirectories) + _WINDOWS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + Level3 + ProgramDatabase + Default + Verbose + Full + + + libiomp5md.lib;mkl_intel_lp64.lib;mkl_intel_thread.lib;mkl_core.lib;%(AdditionalDependencies) + $(OutDir)$(TargetName)$(TargetExt) $(OmpLibDir)\;$(MKLLibDir)\;%(AdditionalLibraryDirectories) true MachineX64 + $(OutDir)$(TargetName).lib @@ -149,12 +248,13 @@ libiomp5md.lib;mkl_intel_c.lib;mkl_intel_thread.lib;mkl_core.lib;%(AdditionalDependencies) - $(OutDir)MathNET.Numerics.MKL.dll + $(OutDir)$(TargetName)$(TargetExt) $(OmpLibDir)\;$(MKLLibDir)\;%(AdditionalLibraryDirectories) true true true MachineX86 + $(OutDir)$(TargetName).lib @@ -178,12 +278,13 @@ libiomp5md.lib;mkl_intel_lp64.lib;mkl_intel_thread.lib;mkl_core.lib;%(AdditionalDependencies) - $(OutDir)MathNET.Numerics.MKL.dll + $(OutDir)$(TargetName)$(TargetExt) $(OmpLibDir)\;$(MKLLibDir)\;%(AdditionalLibraryDirectories) true true true MachineX64 + $(OutDir)$(TargetName).lib diff --git a/src/NativeWrappers/Windows/NativeWrappers.sln b/src/NativeWrappers/Windows/NativeWrappers.sln index 318a89a1..26b76fcf 100644 --- a/src/NativeWrappers/Windows/NativeWrappers.sln +++ b/src/NativeWrappers/Windows/NativeWrappers.sln @@ -24,6 +24,10 @@ Global Debug|Mixed Platforms = Debug|Mixed Platforms Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 + Intel_SSA|Any CPU = Intel_SSA|Any CPU + Intel_SSA|Mixed Platforms = Intel_SSA|Mixed Platforms + Intel_SSA|Win32 = Intel_SSA|Win32 + Intel_SSA|x64 = Intel_SSA|x64 Release|Any CPU = Release|Any CPU Release|Mixed Platforms = Release|Mixed Platforms Release|Win32 = Release|Win32 @@ -35,12 +39,19 @@ Global EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {C0B0DBA9-7FB0-4C87-BDB1-3EED19DC2B8F}.Debug|Any CPU.ActiveCfg = Debug|x64 - {C0B0DBA9-7FB0-4C87-BDB1-3EED19DC2B8F}.Debug|Mixed Platforms.ActiveCfg = Release|Win32 - {C0B0DBA9-7FB0-4C87-BDB1-3EED19DC2B8F}.Debug|Mixed Platforms.Build.0 = Release|Win32 + {C0B0DBA9-7FB0-4C87-BDB1-3EED19DC2B8F}.Debug|Mixed Platforms.ActiveCfg = Release|x64 + {C0B0DBA9-7FB0-4C87-BDB1-3EED19DC2B8F}.Debug|Mixed Platforms.Build.0 = Release|x64 {C0B0DBA9-7FB0-4C87-BDB1-3EED19DC2B8F}.Debug|Win32.ActiveCfg = Debug|Win32 {C0B0DBA9-7FB0-4C87-BDB1-3EED19DC2B8F}.Debug|Win32.Build.0 = Debug|Win32 {C0B0DBA9-7FB0-4C87-BDB1-3EED19DC2B8F}.Debug|x64.ActiveCfg = Debug|x64 {C0B0DBA9-7FB0-4C87-BDB1-3EED19DC2B8F}.Debug|x64.Build.0 = Debug|x64 + {C0B0DBA9-7FB0-4C87-BDB1-3EED19DC2B8F}.Intel_SSA|Any CPU.ActiveCfg = Intel_SSA|Win32 + {C0B0DBA9-7FB0-4C87-BDB1-3EED19DC2B8F}.Intel_SSA|Mixed Platforms.ActiveCfg = Intel_SSA|Win32 + {C0B0DBA9-7FB0-4C87-BDB1-3EED19DC2B8F}.Intel_SSA|Mixed Platforms.Build.0 = Intel_SSA|Win32 + {C0B0DBA9-7FB0-4C87-BDB1-3EED19DC2B8F}.Intel_SSA|Win32.ActiveCfg = Intel_SSA|Win32 + {C0B0DBA9-7FB0-4C87-BDB1-3EED19DC2B8F}.Intel_SSA|Win32.Build.0 = Intel_SSA|Win32 + {C0B0DBA9-7FB0-4C87-BDB1-3EED19DC2B8F}.Intel_SSA|x64.ActiveCfg = Intel_SSA|x64 + {C0B0DBA9-7FB0-4C87-BDB1-3EED19DC2B8F}.Intel_SSA|x64.Build.0 = Intel_SSA|x64 {C0B0DBA9-7FB0-4C87-BDB1-3EED19DC2B8F}.Release|Any CPU.ActiveCfg = Release|x64 {C0B0DBA9-7FB0-4C87-BDB1-3EED19DC2B8F}.Release|Mixed Platforms.ActiveCfg = Release|x64 {C0B0DBA9-7FB0-4C87-BDB1-3EED19DC2B8F}.Release|Mixed Platforms.Build.0 = Release|x64 @@ -61,6 +72,12 @@ Global {D0AD591B-0CE6-4A6D-8DEA-01777EE09BC3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {D0AD591B-0CE6-4A6D-8DEA-01777EE09BC3}.Debug|Win32.ActiveCfg = Debug|Any CPU {D0AD591B-0CE6-4A6D-8DEA-01777EE09BC3}.Debug|x64.ActiveCfg = Debug|Any CPU + {D0AD591B-0CE6-4A6D-8DEA-01777EE09BC3}.Intel_SSA|Any CPU.ActiveCfg = Release|Any CPU + {D0AD591B-0CE6-4A6D-8DEA-01777EE09BC3}.Intel_SSA|Any CPU.Build.0 = Release|Any CPU + {D0AD591B-0CE6-4A6D-8DEA-01777EE09BC3}.Intel_SSA|Mixed Platforms.ActiveCfg = Release|Any CPU + {D0AD591B-0CE6-4A6D-8DEA-01777EE09BC3}.Intel_SSA|Mixed Platforms.Build.0 = Release|Any CPU + {D0AD591B-0CE6-4A6D-8DEA-01777EE09BC3}.Intel_SSA|Win32.ActiveCfg = Release|Any CPU + {D0AD591B-0CE6-4A6D-8DEA-01777EE09BC3}.Intel_SSA|x64.ActiveCfg = Release|Any CPU {D0AD591B-0CE6-4A6D-8DEA-01777EE09BC3}.Release|Any CPU.ActiveCfg = Release|Any CPU {D0AD591B-0CE6-4A6D-8DEA-01777EE09BC3}.Release|Any CPU.Build.0 = Release|Any CPU {D0AD591B-0CE6-4A6D-8DEA-01777EE09BC3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU @@ -79,6 +96,12 @@ Global {B7CAE5F4-A23F-4438-B5BE-41226618B695}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {B7CAE5F4-A23F-4438-B5BE-41226618B695}.Debug|Win32.ActiveCfg = Debug|Any CPU {B7CAE5F4-A23F-4438-B5BE-41226618B695}.Debug|x64.ActiveCfg = Debug|Any CPU + {B7CAE5F4-A23F-4438-B5BE-41226618B695}.Intel_SSA|Any CPU.ActiveCfg = Release-Signed|Any CPU + {B7CAE5F4-A23F-4438-B5BE-41226618B695}.Intel_SSA|Any CPU.Build.0 = Release-Signed|Any CPU + {B7CAE5F4-A23F-4438-B5BE-41226618B695}.Intel_SSA|Mixed Platforms.ActiveCfg = Release-Signed|Any CPU + {B7CAE5F4-A23F-4438-B5BE-41226618B695}.Intel_SSA|Mixed Platforms.Build.0 = Release-Signed|Any CPU + {B7CAE5F4-A23F-4438-B5BE-41226618B695}.Intel_SSA|Win32.ActiveCfg = Release-Signed|Any CPU + {B7CAE5F4-A23F-4438-B5BE-41226618B695}.Intel_SSA|x64.ActiveCfg = Release-Signed|Any CPU {B7CAE5F4-A23F-4438-B5BE-41226618B695}.Release|Any CPU.ActiveCfg = Release|Any CPU {B7CAE5F4-A23F-4438-B5BE-41226618B695}.Release|Any CPU.Build.0 = Release|Any CPU {B7CAE5F4-A23F-4438-B5BE-41226618B695}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU @@ -97,6 +120,12 @@ Global {EB1A5D32-F264-4BCE-BEB7-0B97085075BE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {EB1A5D32-F264-4BCE-BEB7-0B97085075BE}.Debug|Win32.ActiveCfg = Debug|Any CPU {EB1A5D32-F264-4BCE-BEB7-0B97085075BE}.Debug|x64.ActiveCfg = Debug|Any CPU + {EB1A5D32-F264-4BCE-BEB7-0B97085075BE}.Intel_SSA|Any CPU.ActiveCfg = Release-Signed|Any CPU + {EB1A5D32-F264-4BCE-BEB7-0B97085075BE}.Intel_SSA|Any CPU.Build.0 = Release-Signed|Any CPU + {EB1A5D32-F264-4BCE-BEB7-0B97085075BE}.Intel_SSA|Mixed Platforms.ActiveCfg = Release-Signed|Any CPU + {EB1A5D32-F264-4BCE-BEB7-0B97085075BE}.Intel_SSA|Mixed Platforms.Build.0 = Release-Signed|Any CPU + {EB1A5D32-F264-4BCE-BEB7-0B97085075BE}.Intel_SSA|Win32.ActiveCfg = Release-Signed|Any CPU + {EB1A5D32-F264-4BCE-BEB7-0B97085075BE}.Intel_SSA|x64.ActiveCfg = Release-Signed|Any CPU {EB1A5D32-F264-4BCE-BEB7-0B97085075BE}.Release|Any CPU.ActiveCfg = Release|Any CPU {EB1A5D32-F264-4BCE-BEB7-0B97085075BE}.Release|Any CPU.Build.0 = Release|Any CPU {EB1A5D32-F264-4BCE-BEB7-0B97085075BE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU