- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello darkcminor,
As MKL blas (Cblas)and lapack (lapacke)support both fortran and C interface.The LAPACKE is C interface, so the ref pass is not needed. you may change the code either to use c interface as below or use dgesvd fortran interface as Using Intel Mkl In Your C# Program
Best Regards,
Ying
using System;
using System.Collections.Generic;
using System.Text;
using System.Security;
using System.Runtime.InteropServices;
using mkl;
namespace csmkl
{
class Program
{
static void Main(string[] args)
{
Int32 n = 3, m = 3;
Int32 lda = n, ldu = m, ldvt = n;
Double[] superb = new Double[m - 1];
Double[] s = new Double
Double[] u = new Double[n * n];
Double[] vt = new Double[n * n];
Double[] A = new Double[9]
{
8.79, 9.93, 9.83,
6.11, 6.91, 5.04,
-9.15, -7.93, 4.86
};
Char a1 = 'A';
Char a2 = 'N';
int mat_order = 101;
;
Int32 info = 0;
double[] work1 = new double[1];
double[] work;
int lwork = -1;
MKLImports.LAPACKE_dgesvd(
mat_order,
a1,
a2,
m,
n,
A,
lda,
s,
u,
ldu,
vt,
ldvt,
superb);
/* MKLImports.dgesvd(
ref a1,
ref a2,
ref m,
ref n,
A,
ref lda,
s,
u,
ref ldu,
vt,
ref ldvt,
work1,
ref lwork,
ref info);
Console.WriteLine("info on exit: " + info);
Console.WriteLine("work1[0]: " + work1[0]);
lwork = (int)work1[0];
work = new double[lwork];
MKLImports.dgesvd(
ref a1,
ref a2,
ref m,
ref n,
A,
ref lda,
s,
u,
ref ldu,
vt,
ref ldvt,
work,
ref lwork,
ref info);
Console.WriteLine("info on exit: " + info);
*/
Console.WriteLine("s[0]: " + s[0]);
}
}
}
namespace mkl
{
[SuppressUnmanagedCodeSecurity]
internal sealed class MKLImports
{
private MKLImports()
{
}
[DllImport("mkl_rt.dll", ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void LAPACKE_dgesvd(
int matrix_order,
char a1,
char a2,
int m,
int n,
[In, Out] double[] input_matrix,
int lda,
[In, Out] double[] s,
[In, Out] double[] u,
int ldu,
[In, Out] double[] vt,
int ldvt,
double[] superb
);
/* internal static extern void dgesvd(
ref char a1,
ref char a2,
ref int m,
ref int n,
[In, Out] double[] input_matrix,
ref int lda,
[In, Out] double[] s,
[In, Out] double[] u,
ref int ldu,
[In, Out] double[] vt,
ref int ldvt,
[In, Out] double[] work,
ref int lwork,
ref int info
);
*/
}
}
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello darkcminor,
As MKL blas (Cblas)and lapack (lapacke)support both fortran and C interface.The LAPACKE is C interface, so the ref pass is not needed. you may change the code either to use c interface as below or use dgesvd fortran interface as Using Intel Mkl In Your C# Program
Best Regards,
Ying
using System;
using System.Collections.Generic;
using System.Text;
using System.Security;
using System.Runtime.InteropServices;
using mkl;
namespace csmkl
{
class Program
{
static void Main(string[] args)
{
Int32 n = 3, m = 3;
Int32 lda = n, ldu = m, ldvt = n;
Double[] superb = new Double[m - 1];
Double[] s = new Double
Double[] u = new Double[n * n];
Double[] vt = new Double[n * n];
Double[] A = new Double[9]
{
8.79, 9.93, 9.83,
6.11, 6.91, 5.04,
-9.15, -7.93, 4.86
};
Char a1 = 'A';
Char a2 = 'N';
int mat_order = 101;
;
Int32 info = 0;
double[] work1 = new double[1];
double[] work;
int lwork = -1;
MKLImports.LAPACKE_dgesvd(
mat_order,
a1,
a2,
m,
n,
A,
lda,
s,
u,
ldu,
vt,
ldvt,
superb);
/* MKLImports.dgesvd(
ref a1,
ref a2,
ref m,
ref n,
A,
ref lda,
s,
u,
ref ldu,
vt,
ref ldvt,
work1,
ref lwork,
ref info);
Console.WriteLine("info on exit: " + info);
Console.WriteLine("work1[0]: " + work1[0]);
lwork = (int)work1[0];
work = new double[lwork];
MKLImports.dgesvd(
ref a1,
ref a2,
ref m,
ref n,
A,
ref lda,
s,
u,
ref ldu,
vt,
ref ldvt,
work,
ref lwork,
ref info);
Console.WriteLine("info on exit: " + info);
*/
Console.WriteLine("s[0]: " + s[0]);
}
}
}
namespace mkl
{
[SuppressUnmanagedCodeSecurity]
internal sealed class MKLImports
{
private MKLImports()
{
}
[DllImport("mkl_rt.dll", ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern void LAPACKE_dgesvd(
int matrix_order,
char a1,
char a2,
int m,
int n,
[In, Out] double[] input_matrix,
int lda,
[In, Out] double[] s,
[In, Out] double[] u,
int ldu,
[In, Out] double[] vt,
int ldvt,
double[] superb
);
/* internal static extern void dgesvd(
ref char a1,
ref char a2,
ref int m,
ref int n,
[In, Out] double[] input_matrix,
ref int lda,
[In, Out] double[] s,
[In, Out] double[] u,
ref int ldu,
[In, Out] double[] vt,
ref int ldvt,
[In, Out] double[] work,
ref int lwork,
ref int info
);
*/
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is more informationabout the topic.
http://software.intel.com/en-us/articles/parallelism-in-the-intel-math-kernel-library/
and http://software.intel.com/en-us/articles/intel-math-kernel-library-intel-mkl-for-linux-linking-applications-with-intel-mkl-version-100/
Best Regards,
Ying
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page