<?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 Segmentation Fault in LAPACKE_sgees in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segmentation-Fault-in-LAPACKE-sgees/m-p/1415393#M33661</link>
    <description>&lt;H3&gt;Problem&lt;/H3&gt;
&lt;P&gt;Segmentation Fault in LAPACKE_sgees&lt;/P&gt;
&lt;H3&gt;Question&lt;/H3&gt;
&lt;P&gt;I should be giving enough buffer to&amp;nbsp;&amp;nbsp;LAPACKE_sgees (in Math Kernel Library) but when the following code run, a segmentation fault occurs in line 47. However, the comment in line 27 becomes active, this function succeeds and gives the correct result. This action is done in VC++ 2022.&lt;/P&gt;
&lt;P&gt;And under the icx compiler, both of them failed.&lt;/P&gt;
&lt;P&gt;How can I solve this problem and run this function safely?&lt;/P&gt;
&lt;H3&gt;Environment&lt;/H3&gt;
&lt;UL&gt;
&lt;LI&gt;Windows 10 21H2&lt;/LI&gt;
&lt;LI&gt;Visual Studio 2022 Community&lt;/LI&gt;
&lt;LI&gt;Visual C++ 2022 or Intel C++ Compiler (2022.1.0.256)&lt;/LI&gt;
&lt;LI&gt;Intel libraries for oneAPI&amp;nbsp; (2022.1.0.256)&lt;/LI&gt;
&lt;/UL&gt;
&lt;H3&gt;Code&lt;/H3&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;#include &amp;lt;cstdint&amp;gt;
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;mkl.h&amp;gt;

namespace imkl
{
	constexpr int order = 3;
	constexpr int size = order * order;

	int ShapeArrayPrint(float* _A, int _side)
	{
		for (int i = 0; i &amp;lt; _side; i++)
		{
			for (int j = 0; j &amp;lt; _side; j++)
			{
				printf("%10lf ", _A[i * _side + j]);
			}
			printf("\n");
		}
		return 0;
	}
}

int main()
{

	//int _a = 0;

	float* mat_a = new float[imkl::size]
	{
		1, 2, 0,
		0, 3, 0,
		2, -4, 2
	};

	int* tmp_sdim = new int[imkl::size] {0};
	float* lpwr = new float[imkl::size] {0};
	float* lpwi = new float [imkl::size] {0};
	float* lpMat = new float[imkl::size] {0};

	imkl::ShapeArrayPrint(mat_a, imkl::order);

	printf("\n");

	int ret = LAPACKE_sgees
	(
		LAPACK_ROW_MAJOR, 'N', 'N', nullptr,
		imkl::order, mat_a, imkl::order, tmp_sdim,
		lpwr, lpwi, lpMat, imkl::order
	);

	imkl::ShapeArrayPrint(mat_a, imkl::order);

	printf("\n");

	delete[] tmp_sdim;
	delete[] lpwr;
	delete[] lpwi;
	delete[] lpMat;
	delete[] mat_a;

	return 0;
}
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 18 Sep 2022 17:10:17 GMT</pubDate>
    <dc:creator>Croyfet</dc:creator>
    <dc:date>2022-09-18T17:10:17Z</dc:date>
    <item>
      <title>Segmentation Fault in LAPACKE_sgees</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segmentation-Fault-in-LAPACKE-sgees/m-p/1415393#M33661</link>
      <description>&lt;H3&gt;Problem&lt;/H3&gt;
&lt;P&gt;Segmentation Fault in LAPACKE_sgees&lt;/P&gt;
&lt;H3&gt;Question&lt;/H3&gt;
&lt;P&gt;I should be giving enough buffer to&amp;nbsp;&amp;nbsp;LAPACKE_sgees (in Math Kernel Library) but when the following code run, a segmentation fault occurs in line 47. However, the comment in line 27 becomes active, this function succeeds and gives the correct result. This action is done in VC++ 2022.&lt;/P&gt;
&lt;P&gt;And under the icx compiler, both of them failed.&lt;/P&gt;
&lt;P&gt;How can I solve this problem and run this function safely?&lt;/P&gt;
&lt;H3&gt;Environment&lt;/H3&gt;
&lt;UL&gt;
&lt;LI&gt;Windows 10 21H2&lt;/LI&gt;
&lt;LI&gt;Visual Studio 2022 Community&lt;/LI&gt;
&lt;LI&gt;Visual C++ 2022 or Intel C++ Compiler (2022.1.0.256)&lt;/LI&gt;
&lt;LI&gt;Intel libraries for oneAPI&amp;nbsp; (2022.1.0.256)&lt;/LI&gt;
&lt;/UL&gt;
&lt;H3&gt;Code&lt;/H3&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;#include &amp;lt;cstdint&amp;gt;
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;mkl.h&amp;gt;

namespace imkl
{
	constexpr int order = 3;
	constexpr int size = order * order;

	int ShapeArrayPrint(float* _A, int _side)
	{
		for (int i = 0; i &amp;lt; _side; i++)
		{
			for (int j = 0; j &amp;lt; _side; j++)
			{
				printf("%10lf ", _A[i * _side + j]);
			}
			printf("\n");
		}
		return 0;
	}
}

int main()
{

	//int _a = 0;

	float* mat_a = new float[imkl::size]
	{
		1, 2, 0,
		0, 3, 0,
		2, -4, 2
	};

	int* tmp_sdim = new int[imkl::size] {0};
	float* lpwr = new float[imkl::size] {0};
	float* lpwi = new float [imkl::size] {0};
	float* lpMat = new float[imkl::size] {0};

	imkl::ShapeArrayPrint(mat_a, imkl::order);

	printf("\n");

	int ret = LAPACKE_sgees
	(
		LAPACK_ROW_MAJOR, 'N', 'N', nullptr,
		imkl::order, mat_a, imkl::order, tmp_sdim,
		lpwr, lpwi, lpMat, imkl::order
	);

	imkl::ShapeArrayPrint(mat_a, imkl::order);

	printf("\n");

	delete[] tmp_sdim;
	delete[] lpwr;
	delete[] lpwi;
	delete[] lpMat;
	delete[] mat_a;

	return 0;
}
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Sep 2022 17:10:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segmentation-Fault-in-LAPACKE-sgees/m-p/1415393#M33661</guid>
      <dc:creator>Croyfet</dc:creator>
      <dc:date>2022-09-18T17:10:17Z</dc:date>
    </item>
    <item>
      <title>Re:Segmentation Fault in LAPACKE_sgees</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segmentation-Fault-in-LAPACKE-sgees/m-p/1415575#M33667</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks for reaching out to us.&lt;/P&gt;&lt;P&gt;Could you please attach your VS project file here so that we can try reproducing the issue?&lt;/P&gt;&lt;P&gt;I've tried running the provided code on my end in both VS2022 and Intel oneAPI command prompt with icx compiler (Intel C++ Compiler (2022.1.0.256))   but could not see the segementation fault error which you are mentioning and the output displayed is as shown below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1.000000&amp;nbsp;&amp;nbsp;2.000000&amp;nbsp;&amp;nbsp;0.000000&lt;/P&gt;&lt;P&gt;&amp;nbsp;0.000000&amp;nbsp;&amp;nbsp;3.000000&amp;nbsp;&amp;nbsp;0.000000&lt;/P&gt;&lt;P&gt;&amp;nbsp;2.000000&amp;nbsp;-4.000000&amp;nbsp;&amp;nbsp;2.000000&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;2.000000&amp;nbsp;&amp;nbsp;2.000000&amp;nbsp;-4.000000&lt;/P&gt;&lt;P&gt;&amp;nbsp;0.000000&amp;nbsp;&amp;nbsp;1.000000&amp;nbsp;&amp;nbsp;2.000000&lt;/P&gt;&lt;P&gt;&amp;nbsp;0.000000&amp;nbsp;&amp;nbsp;0.000000&amp;nbsp;&amp;nbsp;3.000000&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Additionally, we suggest you try running the code from Intel oneAPI command prompt and see if the issue still persists.&lt;/P&gt;&lt;P&gt;Command:&lt;/P&gt;&lt;P&gt;&amp;gt; icx /Qmkl *.cpp&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vidya.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 19 Sep 2022 08:31:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segmentation-Fault-in-LAPACKE-sgees/m-p/1415575#M33667</guid>
      <dc:creator>VidyalathaB_Intel</dc:creator>
      <dc:date>2022-09-19T08:31:44Z</dc:date>
    </item>
    <item>
      <title>Re: Segmentation Fault in LAPACKE_sgees</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segmentation-Fault-in-LAPACKE-sgees/m-p/1416172#M33684</link>
      <description>&lt;P&gt;Thank you for trying.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The cause may be linking to "*ilp.lib" lib files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I added all lib files of mkl to the option of "Additional Dependencies". The lib files seem to have two types of library&amp;nbsp;"LP interfaces" and "ILP interfaces". The former uses 32bits to index the array and the latter uses 64bits. You must set some options when you compile using&amp;nbsp;"ILP interfaces".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I solved this by removing&amp;nbsp;"*ilp.lib" libs from the option.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2022 07:13:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segmentation-Fault-in-LAPACKE-sgees/m-p/1416172#M33684</guid>
      <dc:creator>Croyfet</dc:creator>
      <dc:date>2022-09-21T07:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: Segmentation Fault in LAPACKE_sgees</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segmentation-Fault-in-LAPACKE-sgees/m-p/1416185#M33685</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;gt;The lib files seem to have two types of library "LP interfaces" and "ILP interfaces"&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Yes, there are two types of interfaces LP64 and ILP64.&lt;/P&gt;
&lt;P&gt;Here is the link with more details regarding the same.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.intel.com/content/www/us/en/develop/documentation/onemkl-windows-developer-guide/top/linking-your-application-with-onemkl/linking-in-detail/linking-with-interface-libraries/using-the-ilp64-interface-vs-lp64-interface.html" target="_blank" rel="noopener"&gt;https://www.intel.com/content/www/us/en/develop/documentation/onemkl-windows-developer-guide/top/linking-your-application-with-onemkl/linking-in-detail/linking-with-interface-libraries/using-the-ilp64-interface-vs-lp64-interface.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;gt;I solved this by removing "*ilp.lib" libs from the option.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Glad to know that your issue is resolved.&lt;/P&gt;
&lt;P&gt;Please post a new question if you need any additional assistance from Intel as this thread will no longer be monitored.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Vidya.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2022 08:23:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segmentation-Fault-in-LAPACKE-sgees/m-p/1416185#M33685</guid>
      <dc:creator>VidyalathaB_Intel</dc:creator>
      <dc:date>2022-09-21T08:23:30Z</dc:date>
    </item>
  </channel>
</rss>

