- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am new to this so any advice would be appreciated.
I am trying to call the cblas_dgemm command in c# using "mkl_rt.2.dll" using Visual Studio 2022.
I have downloaded and installed the oneAPI Base Toolkit and I have added "C:\Program Files (x86)\Intel\oneAPI\mkl\latest\bin" to my PATH directory.
I have defined a class for calling dgemm in a .Net Standard 2.1 dll:
public sealed unsafe class CBLAS
{
[SuppressUnmanagedCodeSecurity]
[DllImport("mkl_rt.2.dll", CallingConvention = CallingConvention.Cdecl,ExactSpelling = true)]
public static extern void cblas_dgemm(
int layout,
int transa,
int transb,
int m,
int n,
int k,
double alpha,
double* a,
int lda,
double* b,
int ldb,
double beta,
double* c,
int ldc)
;
}
Which I am then calling from a console program in .Net 8:
int m_layout = 101;
int tr_i = 111;
int tr_j = 111;
int rowsA = 2;
int colsA = 2;
int rowsB = 2;
int colsB = 2;
int m = rowsA;
int n = colsB;
int k = colsA;
double alpha = 1.0;
double beta = 0.0;
int lda = k;
int ldb = n;
int ldc = n;
double[] a = new double[4] {1,3,2,4};
double[] b = new double[4] {2,1,0,2};
double[] c = new double[4] {0.0,0.0,0.0,0.0};
fixed (double* ptr_a = &a[0])
fixed (double* ptr_b = &b[0])
fixed (double* ptr_c = &c[0])
MKL.CBLAS.cblas_dgemm(m_layout, tr_i, tr_j, m,n, k, alpha, ptr_a, lda, ptr_b, ldb, beta, ptr_c, ldc);
However I am gettting the error "External component has thrown an exception." so I am not sure what the issue seems to be. Are the inputs that I am using correct? I have tested the exmple show here https://www.intel.com/content/www/us/en/developer/articles/technical/using-intel-mkl-in-your-c-program.html for LAPACKE_zgesv(int matrix_layout, int n, int nrhs, Complex* A, int lda, int[] ipiv, Complex* B, int ldb); and that seems to work without any errors.
Thanks!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Nick,
Thank you for contacting to us.
Noted you are using VS 2022, can you also tell us oneMKL version or oneAPI version in you system? And it's also helpful if you can provide out a simple reproducer.
Regards,
Ruqiu
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page