<?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 Hi Vlad, in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Memory-management-in-vsl/m-p/1096804#M23629</link>
    <description>&lt;P&gt;Hi Vlad,&lt;/P&gt;

&lt;P&gt;Yes, pretty much.&lt;/P&gt;

&lt;P&gt;A couple of observations:&lt;/P&gt;

&lt;UL&gt;
	&lt;LI&gt;have only run debug mode (do not know what happens on release) and only 32-bit.&lt;/LI&gt;
	&lt;LI&gt;To ensure you are aware of it, I posted a note &lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;later&lt;/SPAN&gt;, in which I mention that, in the end, you will notice after a few runs with the user-provided task, that the problem appears there as well, although only erratically and not always&lt;/LI&gt;
	&lt;LI&gt;I have used boost ublas for many years (&amp;gt;7) and never had a memory issue (also many-many others, as you know)&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Have you ever noticed the problem on Release built?&lt;/P&gt;

&lt;P&gt;If yes (even erratically), then the &lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;windows&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;debug heap is not the issue (I do not see how the 64 vs. 32 bit can be of any relevance, in the same way I do not think that win8 vs. win7 is of any as well).&lt;/P&gt;

&lt;P&gt;If I were to place a bet, however, I would think this to be the issue.&lt;/P&gt;

&lt;P&gt;Update: Please, in case you have not done in a while, be reminded that heap corruption does not result in program crash at the offending point but only later, making things even more obscure.&lt;/P&gt;</description>
    <pubDate>Wed, 05 Oct 2016 13:53:00 GMT</pubDate>
    <dc:creator>Petros_M_</dc:creator>
    <dc:date>2016-10-05T13:53:00Z</dc:date>
    <item>
      <title>Memory management in vsl</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Memory-management-in-vsl/m-p/1096799#M23624</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am using&amp;nbsp;vsldSSEditCorParameterization in debug mode (windows) and have some problems with the windows debug heal validation step, that windows always performs on de-allocation, resulting in &lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;program&amp;nbsp;&lt;/SPAN&gt;crashing .&lt;/P&gt;

&lt;P&gt;If I understand properly the documentation, ("spectral") one diagonalizes the input matrix. Presumably, this is done using LAPACK. If this is the case,LAPACK requires user-provided memory to perform the task, which since I do not provide, have to assume it is allocated internally.&lt;/P&gt;

&lt;P&gt;Then the task&amp;nbsp;should clean-this up in the end, (either upon completion of calculation, or at &lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;vslSSDeleteTask&amp;nbsp;&lt;/SPAN&gt;) .&lt;/P&gt;

&lt;P&gt;Now, again if I understand this correctly, this is serviced by the mkl memory allocator, which sounds like it creates its own heap (always windows).&lt;/P&gt;

&lt;P&gt;I do not aim to the internals of vsl, but I have this bug that is very elusive, depending on where you call the allocation/.de-allocation vsl routines from, and have been hitting it for almost a day now (this is how I actually managed to determine that it is the memory issue).&lt;/P&gt;

&lt;P&gt;Has anyone ever had this kind of problem?&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Am I missing something? &amp;nbsp;&lt;/P&gt;

&lt;P&gt;Should I call mkl_thread_free_buffers before&amp;nbsp;&lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;vslSSDeleteTask&amp;nbsp;&lt;/SPAN&gt;? - I thought one should use it in case an exception is thrown to collect the resources.&lt;/P&gt;

&lt;P&gt;Any kind of input would be greatly appreciated.&lt;/P&gt;

&lt;P&gt;TIA,&lt;/P&gt;

&lt;P&gt;Petros&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2016 14:25:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Memory-management-in-vsl/m-p/1096799#M23624</guid>
      <dc:creator>Petros_M_</dc:creator>
      <dc:date>2016-09-29T14:25:36Z</dc:date>
    </item>
    <item>
      <title>Hi Petros,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Memory-management-in-vsl/m-p/1096800#M23625</link>
      <description>&lt;P&gt;Hi Petros,&lt;/P&gt;

&lt;P&gt;Please, provide the test-case and as many details as possible (OS/CPU/library version/build/link line etc) so we would be able to reproduce the issue on our side.&lt;/P&gt;

&lt;P&gt;The general recommendation is to call the routine de-allocating memory resources after the last call to Intel MKL function, e.g., vslSSDeleteTask().&lt;/P&gt;

&lt;P&gt;Andrey&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2016 14:47:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Memory-management-in-vsl/m-p/1096800#M23625</guid>
      <dc:creator>Andrey_N_Intel</dc:creator>
      <dc:date>2016-09-29T14:47:48Z</dc:date>
    </item>
    <item>
      <title>Hi Andrey,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Memory-management-in-vsl/m-p/1096801#M23626</link>
      <description>&lt;P&gt;Hi Andrey,&lt;/P&gt;

&lt;P&gt;Thank you for the quick reply.&lt;/P&gt;

&lt;P&gt;A code sample of the problem follows. One has 2 ways to create the task: either a user-provided one ( useClientSideTask = true )&amp;nbsp;or let the function create and destroy its own ( useClientSideTask &amp;nbsp;= false ), b&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;y toggling the appropriate variable. Apologies, for not making this command-line driven - too lazy I guess ;-)&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;The first one works like a charm. The second one "crashes" silently (does not print anything) most f the time.&lt;/P&gt;

&lt;P&gt;contrary to what i thought, one does not even need to "cross" the boundary of a static lib (as I had it before) for this to happen.&lt;/P&gt;

&lt;P&gt;Win7, VS2010, Debug,Xeon E5-2670, mkl11.3&lt;/P&gt;

&lt;P&gt;TIA, P-&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#include &amp;lt;mkl.h&amp;gt;
#include &amp;lt;iostream&amp;gt;
#include &amp;lt;boost/numeric/ublas/symmetric.hpp&amp;gt;

struct SampleAnalyzer {

	static
		void *
		create_task( MKL_INT nFactors ) {
			void * task ;
			MKL_INT status ;
			status = vsldSSNewTask( &amp;amp;task, &amp;amp;nFactors, 0, NULL, NULL, NULL, NULL ) ;
			return task ;
	}
	static
		void 
		destroy_task( void ** ptask ) {
			void * task = *ptask ;
			MKL_INT status = vslSSDeleteTask( &amp;amp;task ) ;
			mkl_thread_free_buffers() ;
	}
/************************************
	calculateNearestCorrelation :
************************************/
	static
		void
		calculateNearestCorrelation(
			MKL_INT		nF,
			double * 		pCorrelData,
			double const * 	pSymmData,
			void *			utask		= NULL 	// externally provided alternative :
		) {
			MKL_INT status ;
			MKL_INT stgFmt =  VSL_SS_MATRIX_STORAGE_L_PACKED ;
			void * task = ( utask == NULL ? create_task( nF ) : utask ) ;
			status = 
				vsldSSEditCorParameterization( task, pSymmData, &amp;amp;stgFmt, pCorrelData, &amp;amp;stgFmt ) ;
		    status = 
				vsldSSCompute( task, VSL_SS_PARAMTR_COR, VSL_SS_METHOD_SD ) ;
			if ( utask == NULL ) 
				destroy_task( &amp;amp;task ) ;
	}
} ;

int main() {
//	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF );
	const double one = double(1) ;
	typedef boost::numeric::ublas::symmetric_matrix&amp;lt;double&amp;gt; symm_matrix ;

	MKL_INT nFactors = 3 ;

	symm_matrix  symm( 3, 3 ) ; 
	symm(0,0) = one ;
	symm(1,1) = one ;
	symm(2,2) = one ;
	symm(1,0) = .25L ;	symm( 0, 1 ) = symm( 1, 0 ) ; 
	symm(2,0) = 0.6L ;  symm( 0, 2 ) = symm( 2, 0 ) ; 
	symm(2,1) = -0.8L ; symm( 1, 2 ) = symm( 2, 1 ) ; 
		
	symm_matrix corr( nFactors )  ;
	std::fill( corr.data().begin(), corr.data().end(), double(0) ) ;

	const size_t nF = size_t( nFactors ) ;

	double * const			pCorrelData = &amp;amp;corr( 0, 0 ) ;
	double const * const	pSymmData	= &amp;amp;symm( 0, 0 ) ;

// please, toggle this :
	bool useClientSideTask =  false ; // true ; // false ;
// MAIN CALL :
	{
		void * task = NULL ;
		if ( useClientSideTask )
			task = SampleAnalyzer::create_task( nFactors ) ; 
			
		SampleAnalyzer::calculateNearestCorrelation( nFactors, pCorrelData, pSymmData, task ) ;
		if ( useClientSideTask ) 
			SampleAnalyzer::destroy_task ( &amp;amp;task ) ;	
	}
	const double a = corr( 1, 0 ) ;
	const double b = corr( 2, 0 ) ;
	const double c = corr( 2, 1 ) ;

	const double leadingMinor1 = one - a * a ;
	const double leadingMinor2 = one - ( a * a + b * b + c * c )  + double(2) * a * b * c ;
	const bool isPositive = ( leadingMinor1 &amp;gt; double(0) ) &amp;amp;&amp;amp; ( leadingMinor2 &amp;gt; double(0) ) ;
	std::string passed ( isPositive ? "passed" : "failed" ) ;
	std::cout &amp;lt;&amp;lt; passed &amp;lt;&amp;lt; std::endl ;
}
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;UPDATE :&lt;/P&gt;

&lt;P&gt;After having run it a few times, it turns out that even the external task usage can fail, exhibiting an &lt;STRONG&gt;&lt;U&gt;erratic&lt;/U&gt;&lt;/STRONG&gt; behavior !&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2016 15:32:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Memory-management-in-vsl/m-p/1096801#M23626</guid>
      <dc:creator>Petros_M_</dc:creator>
      <dc:date>2016-09-29T15:32:00Z</dc:date>
    </item>
    <item>
      <title>Thanks, Petros, we will</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Memory-management-in-vsl/m-p/1096802#M23627</link>
      <description>&lt;P&gt;Thanks, Petros, we will analyze it. Andrey&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2016 15:35:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Memory-management-in-vsl/m-p/1096802#M23627</guid>
      <dc:creator>Andrey_N_Intel</dc:creator>
      <dc:date>2016-09-29T15:35:47Z</dc:date>
    </item>
    <item>
      <title>Hi Petros,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Memory-management-in-vsl/m-p/1096803#M23628</link>
      <description>&lt;P&gt;&lt;SPAN lang="EN-US" style="color: rgb(31, 73, 125); font-family: &amp;quot;Calibri&amp;quot;,sans-serif; font-size: 11pt; mso-ansi-language: EN-US; mso-fareast-language: EN-US;"&gt;Hi Petros,&lt;/SPAN&gt;&lt;BR /&gt;
	&lt;SPAN lang="EN-US" style="color: rgb(31, 73, 125); font-family: &amp;quot;Calibri&amp;quot;,sans-serif; font-size: 11pt; mso-ansi-language: EN-US; mso-fareast-language: EN-US;"&gt;Thanks for providing the test case that we used for the analysis.&lt;/SPAN&gt;&lt;BR /&gt;
	&lt;SPAN lang="EN-US" style="color: rgb(31, 73, 125); font-family: &amp;quot;Calibri&amp;quot;,sans-serif; font-size: 11pt; mso-ansi-language: EN-US; mso-fareast-language: EN-US;"&gt;We run experiments using Intel MKL 11.3, Windows* 8, MSVS* 2013, and Boost* 1.56.&lt;/SPAN&gt;&lt;BR /&gt;
	&lt;SPAN lang="EN-US" style="color: rgb(31, 73, 125); font-family: &amp;quot;Calibri&amp;quot;,sans-serif; font-size: 11pt; mso-ansi-language: EN-US; mso-fareast-language: EN-US;"&gt;The example runs fine with 64 bit version of the library in LP64 mode.&lt;/SPAN&gt;&lt;BR /&gt;
	&lt;SPAN lang="EN-US" style="color: rgb(31, 73, 125); font-family: &amp;quot;Calibri&amp;quot;,sans-serif; font-size: 11pt; mso-ansi-language: EN-US; mso-fareast-language: EN-US;"&gt;If useClientSideTask parameter is set to true, the example also runs fine with 32-bit version of the library; otherwise it results into “heap corruption” on the stage of deconstruction of the Boost matrices on exit from the function main().&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P style="margin: 0cm 0cm 0pt;"&gt;&lt;SPAN lang="EN-US" style="color: rgb(31, 73, 125); font-family: &amp;quot;Calibri&amp;quot;,sans-serif; font-size: 11pt; mso-ansi-language: EN-US; mso-fareast-language: EN-US;"&gt;Do you see similar behavior of the test case in your environment under similar parameter settings and the library’s version?&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P style="margin: 0cm 0cm 0pt;"&gt;&lt;SPAN lang="EN-US" style="color: rgb(31, 73, 125); font-family: &amp;quot;Calibri&amp;quot;,sans-serif; font-size: 11pt; mso-ansi-language: EN-US; mso-fareast-language: EN-US;"&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;
	&lt;SPAN lang="EN-US" style="color: rgb(31, 73, 125); font-family: &amp;quot;Calibri&amp;quot;,sans-serif; font-size: 11pt; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-language: AR-SA;"&gt;Vlad&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 09:11:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Memory-management-in-vsl/m-p/1096803#M23628</guid>
      <dc:creator>Vladislav_V_Intel</dc:creator>
      <dc:date>2016-10-05T09:11:15Z</dc:date>
    </item>
    <item>
      <title>Hi Vlad,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Memory-management-in-vsl/m-p/1096804#M23629</link>
      <description>&lt;P&gt;Hi Vlad,&lt;/P&gt;

&lt;P&gt;Yes, pretty much.&lt;/P&gt;

&lt;P&gt;A couple of observations:&lt;/P&gt;

&lt;UL&gt;
	&lt;LI&gt;have only run debug mode (do not know what happens on release) and only 32-bit.&lt;/LI&gt;
	&lt;LI&gt;To ensure you are aware of it, I posted a note &lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;later&lt;/SPAN&gt;, in which I mention that, in the end, you will notice after a few runs with the user-provided task, that the problem appears there as well, although only erratically and not always&lt;/LI&gt;
	&lt;LI&gt;I have used boost ublas for many years (&amp;gt;7) and never had a memory issue (also many-many others, as you know)&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Have you ever noticed the problem on Release built?&lt;/P&gt;

&lt;P&gt;If yes (even erratically), then the &lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;windows&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;debug heap is not the issue (I do not see how the 64 vs. 32 bit can be of any relevance, in the same way I do not think that win8 vs. win7 is of any as well).&lt;/P&gt;

&lt;P&gt;If I were to place a bet, however, I would think this to be the issue.&lt;/P&gt;

&lt;P&gt;Update: Please, in case you have not done in a while, be reminded that heap corruption does not result in program crash at the offending point but only later, making things even more obscure.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 13:53:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Memory-management-in-vsl/m-p/1096804#M23629</guid>
      <dc:creator>Petros_M_</dc:creator>
      <dc:date>2016-10-05T13:53:00Z</dc:date>
    </item>
    <item>
      <title>Hi Petros,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Memory-management-in-vsl/m-p/1096805#M23630</link>
      <description>Hi Petros,
In our environment the example runs fine in 32-bit release mode.
I also was able to reproduce the failure after the several runs you mentioned earlier: the example either crashes with “access violation” inside routine vsldSSCompute() or returns VSL_SS_ERROR_ALLOCATION_FAILURE error code.
Another update is that the example runs memory corruption issue on Linux OS in 32-bit mode as well.
The issue is being root-caused. Will keep you updated.

Best regards,
Vlad</description>
      <pubDate>Fri, 07 Oct 2016 13:00:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Memory-management-in-vsl/m-p/1096805#M23630</guid>
      <dc:creator>Vladislav_V_Intel</dc:creator>
      <dc:date>2016-10-07T13:00:08Z</dc:date>
    </item>
    <item>
      <title>Hi Vlad,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Memory-management-in-vsl/m-p/1096806#M23631</link>
      <description>&lt;P&gt;Hi Vlad,&lt;/P&gt;

&lt;P&gt;Thank you for the update.&lt;/P&gt;

&lt;P&gt;So it seems, if I understand you well that there is some issue within the vsl code, since it appears both on Linux and Windows.&lt;/P&gt;

&lt;P&gt;In a strange way this is very good news, because the other alternative would be much-much harder to crack ;-)&lt;/P&gt;

&lt;P&gt;All the Best, P-&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2016 14:57:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Memory-management-in-vsl/m-p/1096806#M23631</guid>
      <dc:creator>Petros_M_</dc:creator>
      <dc:date>2016-10-07T14:57:28Z</dc:date>
    </item>
  </channel>
</rss>

