Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Gianluca_G_

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-02-2015
01:01 AM

81 Views

MKL in C#

Hello,

I'm testing MKL in a C# application.

I have to solve a linear system of complex matrix, so first of all I want to understand how the libraries works.

I'm not expert of c++, and Marshaling too so I have tried to define the dll as best as I could. I have used the library installed with Parallel Studio XE.

The example that I have done, doesn't work is there any one that can help me to understand why?

[SuppressUnmanagedCodeSecurity] internal sealed class MKLWrapper { private MKLWrapper() { } [DllImport("mkl_rt.dll", ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int LAPACKE_zgesv( int matrix_layout, int n, int nrhs, [In, Out] Complex[,] input_matrix, int lda, [In, Out] int[] ipiv, [In, Out] Complex[,] b, int ldb ); public static void Test2() { Complex[,] A = new Complex[3,3]; Complex[,] b = new Complex[3,1]; //r1 A[0, 0] = 12; A[0, 1] = 1; A[0, 2] = 1; //r2 A[1, 0] = 1; A[1, 1] = 12; A[1, 2] = 1; //r3 A[2, 0] = 1; A[2, 1] = 1; A[2, 2] = 12; b[0, 0] = 16; b[1, 0] = 16; b[2, 0] = 16; int mat_layout = A.GetLength(0); int n = A.GetLength(0); int nrhs = 1; int lda = n; int ldb = n; int info = 1; int[] ipiv = new int; info = MKLWrapper.LAPACKE_zgesv(mat_layout, n, nrhs, A, lda, ipiv, b, ldb); if (info == 0) Console.WriteLine("Calculation completed!"); else Console.WriteLine("Calculation Error!"); }

Thankyou very much

Gianluca

Link Copied

2 Replies

Gianluca_G_

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-02-2015
05:04 AM

81 Views

this is the solution:

The function accept the input matrix in a vector form.

int LAPACK_ROW_MAJOR = 101; int LAPACK_COL_MAJOR = 102; Complex[] A = new Complex[3*3]; Complex[] b = new Complex[3]; A[0] = 12; A[1] = 1; A[2] = 1; //r1 A[3] = 1; A[4] = 12; A[5] = 1; //r2 A[6] = 1; A[7] = 1; A[8] = 12; //r3 b[0] = 16; b[1] = 16; b[2] = 16; int mat_layout = LAPACK_COL_MAJOR; int n = 3; int nrhs = 1; int lda = n; int ldb = n; int info = 1; int[] ipiv = new int; info = MKLWrapper.LAPACKE_zgesv(mat_layout, n, nrhs, A, lda, ipiv, b, ldb); if (info == 0) { Console.WriteLine("Calculation completed!"); } else Console.WriteLine("Calculation Error!");

Kevin_O_Intel1

Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-02-2015
06:16 AM

81 Views

Hi,

I think you are in the wrong forum. This is the Advisor XE forum.

You need the forum on MKL:

https://software.intel.com/en-us/forums/intel-math-kernel-library

Regards,

Kevin

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

For more complete information about compiler optimizations, see our Optimization Notice.