<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re:Calling dgemm from C# using mkl_rt.2.dll in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Calling-dgemm-from-C-using-mkl-rt-2-dll/m-p/1593894#M36081</link>
    <description>&lt;P&gt;Hello Nick,&lt;/P&gt;&lt;P&gt;Thank you for contacting to us.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ruqiu&lt;/P&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 30 Apr 2024 14:52:46 GMT</pubDate>
    <dc:creator>Ruqiu_C_Intel</dc:creator>
    <dc:date>2024-04-30T14:52:46Z</dc:date>
    <item>
      <title>Calling dgemm from C# using mkl_rt.2.dll</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Calling-dgemm-from-C-using-mkl-rt-2-dll/m-p/1592724#M36069</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to this so any advice would be appreciated.&lt;/P&gt;&lt;P&gt;I am trying to call the&amp;nbsp;cblas_dgemm command in c# using "mkl_rt.2.dll" using Visual Studio 2022.&lt;/P&gt;&lt;P&gt;I have downloaded and installed the&amp;nbsp;&lt;SPAN&gt;oneAPI Base Toolkit and I have added "C:\Program Files (x86)\Intel\oneAPI\mkl\latest\bin" to my PATH directory.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have defined a class for calling dgemm in a .Net Standard 2.1 dll:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public sealed unsafe class CBLAS&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;[SuppressUnmanagedCodeSecurity]&lt;BR /&gt;[DllImport("mkl_rt.2.dll", CallingConvention = CallingConvention.Cdecl,ExactSpelling = true)]&lt;/P&gt;&lt;P&gt;public static extern void cblas_dgemm(&lt;BR /&gt;int layout,&lt;BR /&gt;int transa,&lt;BR /&gt;int transb,&lt;BR /&gt;int m,&lt;BR /&gt;int n,&lt;BR /&gt;int k,&lt;BR /&gt;double alpha,&lt;BR /&gt;double* a,&lt;BR /&gt;int lda,&lt;BR /&gt;double* b,&lt;BR /&gt;int ldb,&lt;BR /&gt;double beta,&lt;BR /&gt;double* c,&lt;BR /&gt;int ldc)&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which I am then calling from a console program in .Net 8:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;int m_layout = 101;&lt;BR /&gt;int tr_i = 111;&lt;BR /&gt;int tr_j = 111;&lt;/P&gt;&lt;P&gt;int rowsA = 2;&lt;BR /&gt;int colsA = 2;&lt;BR /&gt;int rowsB = 2;&lt;BR /&gt;int colsB = 2;&lt;BR /&gt;&lt;BR /&gt;int m = rowsA;&lt;BR /&gt;int n = colsB;&lt;BR /&gt;int k = colsA;&lt;BR /&gt;double alpha = 1.0;&lt;BR /&gt;double beta = 0.0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;int lda = k;&lt;BR /&gt;int ldb = n;&lt;BR /&gt;int ldc = n;&lt;/P&gt;&lt;P&gt;double[] a = new double[4] {1,3,2,4};&lt;BR /&gt;double[] b = new double[4] {2,1,0,2};&lt;BR /&gt;double[] c = new double[4] {0.0,0.0,0.0,0.0};&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;fixed (double* ptr_a = &amp;amp;a[0])&lt;BR /&gt;fixed (double* ptr_b = &amp;amp;b[0])&lt;BR /&gt;fixed (double* ptr_c = &amp;amp;c[0])&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;MKL.CBLAS.cblas_dgemm(m_layout, tr_i, tr_j, m,n, k, alpha, ptr_a, lda, ptr_b, ldb, beta, ptr_c, ldc);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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&amp;nbsp;&lt;A href="https://www.intel.com/content/www/us/en/developer/articles/technical/using-intel-mkl-in-your-c-program.html" target="_blank"&gt;https://www.intel.com/content/www/us/en/developer/articles/technical/using-intel-mkl-in-your-c-program.html&lt;/A&gt;&amp;nbsp;for&amp;nbsp;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 21:09:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Calling-dgemm-from-C-using-mkl-rt-2-dll/m-p/1592724#M36069</guid>
      <dc:creator>Nik5</dc:creator>
      <dc:date>2024-04-25T21:09:35Z</dc:date>
    </item>
    <item>
      <title>Re:Calling dgemm from C# using mkl_rt.2.dll</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Calling-dgemm-from-C-using-mkl-rt-2-dll/m-p/1593894#M36081</link>
      <description>&lt;P&gt;Hello Nick,&lt;/P&gt;&lt;P&gt;Thank you for contacting to us.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ruqiu&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 30 Apr 2024 14:52:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Calling-dgemm-from-C-using-mkl-rt-2-dll/m-p/1593894#M36081</guid>
      <dc:creator>Ruqiu_C_Intel</dc:creator>
      <dc:date>2024-04-30T14:52:46Z</dc:date>
    </item>
  </channel>
</rss>

