<?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 MKL, dgels and C#... in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-dgels-and-C/m-p/762990#M32</link>
    <description>&lt;P&gt;Hello, &lt;/P&gt;&lt;P&gt;Have you got the chance the following article? It provides the steps, and examples on using in C#:&lt;BR /&gt;&lt;A href="http://software.intel.com/en-us/articles/using-intel-mkl-in-your-c-program/"&gt;http://software.intel.com/en-us/articles/using-intel-mkl-in-your-c-program/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Chao&lt;/P&gt;</description>
    <pubDate>Fri, 02 Sep 2011 05:55:43 GMT</pubDate>
    <dc:creator>Chao_Y_Intel</dc:creator>
    <dc:date>2011-09-02T05:55:43Z</dc:date>
    <item>
      <title>MKL, dgels and C#...</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-dgels-and-C/m-p/762989#M31</link>
      <description>Hi.&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;I'm having a problem with dgels in my C# project. I have created a class to import dgels and dgemv:&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV id="_mcePaste"&gt;[SuppressUnmanagedCodeSecurity]&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;	internal sealed class MKLImports&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;	{&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;private&lt;/SPAN&gt;MKLImports&lt;SPAN&gt;()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;{&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;}&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;[DllImport("mkl_rt.dll", ExactSpelling = true, SetLastError = false, CallingConvention = &lt;SPAN style="white-space: pre;"&gt;		&lt;/SPAN&gt;CallingConvention.Cdecl)]&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;internal static extern void dgels(&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;		&lt;/SPAN&gt;ref char trans,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;		&lt;/SPAN&gt;ref int m,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;		&lt;/SPAN&gt;ref int n,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;		&lt;/SPAN&gt;ref int nrhs,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;		&lt;/SPAN&gt;[In, Out] double[] a,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;		&lt;/SPAN&gt;ref int lda,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;		&lt;/SPAN&gt;[In, Out] double[] b,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;		&lt;/SPAN&gt;ref int ldb,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;		&lt;/SPAN&gt;[In, Out] double[] work,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;		&lt;/SPAN&gt;ref int lwork,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;		&lt;/SPAN&gt;ref int info&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;);&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;[DllImport("mkl_rt.dll", ExactSpelling = true, SetLastError = false, CallingConvention = &lt;SPAN style="white-space: pre;"&gt;		&lt;/SPAN&gt;CallingConvention.Cdecl)]&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;internal static extern void dgemv(&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;		&lt;/SPAN&gt;ref char trans,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;		&lt;/SPAN&gt;ref int m,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;		&lt;/SPAN&gt;ref int n,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;		&lt;/SPAN&gt;ref double alpha,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;		&lt;/SPAN&gt;[In] double[] a,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;		&lt;/SPAN&gt;ref int lda,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;		&lt;/SPAN&gt;[In] double[] x,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;		&lt;/SPAN&gt;ref int incX,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;		&lt;/SPAN&gt;ref double beta,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;		&lt;/SPAN&gt;[In, Out] double[] y,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;		&lt;/SPAN&gt;ref int incY&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;);&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;	}&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;Here is a code snipped to show how I use the imported dgels:&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;DIV id="_mcePaste"&gt;&lt;DIV id="_mcePaste"&gt;Int32 matrixARowCount = 800;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;Int32 matrixAColumnCount = 3;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;Double[] matrixA = new Double[matrixARowCount * matrixAColumnCount];&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;Double[] matrixB = new Double[799];&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;Char transpose = 'N';&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;Int32 nrhs = 1;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;Int32 info = 0;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;Int32 lwork = matrixAColumnCount + matrixARowCount * 100;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;Double[] work = new Double[lwork];&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;MKLImports.dgels(&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;ref transpose,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;ref matrixARowCount,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;ref matrixAColumnCount,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;ref nrhs,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;matrixA,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;ref matrixARowCount,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;matrixB,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;ref matrixARowCount,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;work,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;ref lwork,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;ref info&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;);&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;			&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;if (info &amp;lt; 0)&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;{&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;// info is -i and the i-th parameter had an illegal value.&lt;SPAN style="white-space: pre;"&gt;			&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;}&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;else if (info &amp;gt; 0)&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;{&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;// info is i and the i-th diagonal element of the triangular&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;// factor of A is zero, so that A does not have full rank;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;// the least squares solution could not be computed.&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;}&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;else&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;{&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;SPAN style="white-space: pre;"&gt;	&lt;/SPAN&gt;// Ok.&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;}&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;If I comment out the place where dgels is called everything works just fine but when it is used my application freezes randomly. By "randomly" I mean that it freezes everytime when I run it but sometimes it runs for 10 seconds and sometime a couple of seconds. I once managed to get an error message that described stack overflow. I'm using Visual Studio 2008 and even try-catch doesn't do any good because my application just freezes and I have to kill it using Task Manager.&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;I'm new to MKL so I if you guys could see if there's something wrong with my MKLImports ([In/Out]'s, ref's, ...). If I have understood MKL's documentation right they should be like that.&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;Kind regards,&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;DIV id="_mcePaste"&gt;-J-&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 01 Sep 2011 09:51:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-dgels-and-C/m-p/762989#M31</guid>
      <dc:creator>-jjh-</dc:creator>
      <dc:date>2011-09-01T09:51:31Z</dc:date>
    </item>
    <item>
      <title>MKL, dgels and C#...</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-dgels-and-C/m-p/762990#M32</link>
      <description>&lt;P&gt;Hello, &lt;/P&gt;&lt;P&gt;Have you got the chance the following article? It provides the steps, and examples on using in C#:&lt;BR /&gt;&lt;A href="http://software.intel.com/en-us/articles/using-intel-mkl-in-your-c-program/"&gt;http://software.intel.com/en-us/articles/using-intel-mkl-in-your-c-program/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Chao&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2011 05:55:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-dgels-and-C/m-p/762990#M32</guid>
      <dc:creator>Chao_Y_Intel</dc:creator>
      <dc:date>2011-09-02T05:55:43Z</dc:date>
    </item>
    <item>
      <title>MKL, dgels and C#...</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-dgels-and-C/m-p/762991#M33</link>
      <description>Hi Chao and thanks for you reply.&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;The example only show how to import dgemm and dgeev. Not dgels or dgemv which I need. I don't think there's anything wrong with my code and how I have imported the functions. It's just weird how my application is not stable when I use those imported MKL functions. It just freezes randomly.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;I just wanted to show how I have imported the functions and if somebody could tell me if I have done something wrong. Usually when something mystical happens, when managed and unmanaged code is used together, there's something wrong with marshaling. Well, in this case there's no need to do anything that involves "fixed" or "unsafe" keywords so the problem is propably with the parameters that are given to dgels and dgemv functions.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Is there a chance that dgels and dgemv could cause an unhandled exception that would cause freezing when invalid parameters are passed?&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;-J-&lt;/DIV&gt;</description>
      <pubDate>Fri, 02 Sep 2011 09:24:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-dgels-and-C/m-p/762991#M33</guid>
      <dc:creator>-jjh-</dc:creator>
      <dc:date>2011-09-02T09:24:12Z</dc:date>
    </item>
    <item>
      <title>MKL, dgels and C#...</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-dgels-and-C/m-p/762992#M34</link>
      <description>&lt;SPAN class="sectionbodytext"&gt;Just tested my dgels import with data that is proven to be correct and I keep feeding it to dgels every time it is called in my application. It still hangs every now and then.&lt;/SPAN&gt;&lt;DIV class="sectionbodytext"&gt;&lt;/DIV&gt;&lt;DIV class="sectionbodytext"&gt;Has anyone ever had this kind of problems? This has got to be some kind of memory allocation/usage conflict. But there's no need to do any marshaling when you use MKL functions like in the example, right?&lt;/DIV&gt;&lt;DIV class="sectionbodytext"&gt;&lt;/DIV&gt;&lt;DIV class="sectionbodytext"&gt;-J-&lt;/DIV&gt;</description>
      <pubDate>Mon, 05 Sep 2011 08:07:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-dgels-and-C/m-p/762992#M34</guid>
      <dc:creator>-jjh-</dc:creator>
      <dc:date>2011-09-05T08:07:55Z</dc:date>
    </item>
    <item>
      <title>MKL, dgels and C#...</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-dgels-and-C/m-p/762993#M35</link>
      <description>Hello,&lt;BR /&gt;Could you please provide a testcase? My test passes without problems. It is based on your code and on the examples from the article &lt;A href="http://software.intel.com/en-us/articles/using-intel-mkl-in-your-c-program/"&gt;Using Intel MKL in your C# program&lt;/A&gt;.&lt;BR /&gt;&lt;DIV&gt;Note also, the matrixB size should be800: Double[] matrixB = new Double[800];&lt;BR /&gt;Example: &lt;A onclick="ndownload('http://software.intel.com/file/38399')"&gt;dgels.zip&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;c:\wrk\forum&amp;gt;nmake intel64 MKLREDIST=c:\mkl1034\redist&lt;/DIV&gt;&lt;DIV&gt;Microsoft  Program Maintenance Utility Version 9.00.21022.08&lt;BR /&gt;Copyright (C) Microsoft Corporation. All rights reserved.&lt;/DIV&gt;&lt;DIV&gt;Add path of the MKL redistributable to the path environment variable&lt;BR /&gt; set path=%MKLREDIST%\intel64\mkl;%MKLREDIST%\intel64\compiler;%path%&lt;BR /&gt;Build and run examples&lt;BR /&gt; nmake /a dgels.exe&lt;/DIV&gt;&lt;DIV&gt;Microsoft  Program Maintenance Utility Version 9.00.21022.08&lt;BR /&gt;Copyright (C) Microsoft Corporation. All rights reserved.&lt;/DIV&gt;&lt;DIV&gt;Compile dgels.cs&lt;BR /&gt; csc .\dgels.cs&lt;BR /&gt;Microsoft  Visual C# 2008 Compiler version 3.5.30729.4926&lt;BR /&gt;for Microsoft  .NET Framework version 3.5&lt;BR /&gt;Copyright (C) Microsoft Corporation. All rights reserved.&lt;/DIV&gt;&lt;DIV&gt;Run dgels example&lt;BR /&gt; dgels.exe&lt;BR /&gt;info on exit: 0&lt;BR /&gt;TEST PASSED&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Vladimir&lt;/DIV&gt;</description>
      <pubDate>Mon, 05 Sep 2011 19:12:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-dgels-and-C/m-p/762993#M35</guid>
      <dc:creator>Vladimir_Koldakov__I</dc:creator>
      <dc:date>2011-09-05T19:12:15Z</dc:date>
    </item>
    <item>
      <title>MKL, dgels and C#...</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-dgels-and-C/m-p/762994#M36</link>
      <description>Hi Vladimir and thanks a lot!&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;The "799" in my example was a typo but thanks to you I double checked my code and there was a bug where I create the arrays. Unfortunately dgels doesn't throw any exceptions so my application just crashed. Maybe it handles the exception but it does not work when playing in unmanaged/managed environment.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Naturally you cannot calculate H x b, where H is x*y and b is y*z, if H.y != b.y.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;-J-&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 06 Sep 2011 08:51:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-dgels-and-C/m-p/762994#M36</guid>
      <dc:creator>-jjh-</dc:creator>
      <dc:date>2011-09-06T08:51:59Z</dc:date>
    </item>
  </channel>
</rss>

