<?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 This is question is repost in Intel® Integrated Performance Primitives</title>
    <link>https://community.intel.com/t5/Intel-Integrated-Performance/Corrupted-heap-on-64-bit-platforms-using-Ipp32f-and-ippsMalloc/m-p/990228#M22214</link>
    <description>This is question is repost here: &lt;A href="https://software.intel.com/en-us/forums/intel-integrated-performance-primitives/topic/604623" target="_blank"&gt;https://software.intel.com/en-us/forums/intel-integrated-performance-primitives/topic/604623&lt;/A&gt;

Thanks,
Chao</description>
    <pubDate>Tue, 22 Dec 2015 05:42:23 GMT</pubDate>
    <dc:creator>Chao_Y_Intel</dc:creator>
    <dc:date>2015-12-22T05:42:23Z</dc:date>
    <item>
      <title>Corrupted heap on 64 bit platforms using Ipp32f** and ippsMalloc_32f to allocate memory</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Corrupted-heap-on-64-bit-platforms-using-Ipp32f-and-ippsMalloc/m-p/990223#M22209</link>
      <description>&lt;P&gt;I have a very simple problem. A program like folows works on 32 bit platforms Windows and linux. On 64 bi platforms the program results in a corrupted heap. Example for the program:&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;************************************************&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;Ipp32f** x = (Ipp32f**)ippsMalloc_32f(19);&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;for( int i = 0; i &amp;lt; 19; i++ ) {&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; x&lt;I&gt; = (Ipp32f*)ippsMalloc_32f(100);&lt;/I&gt;&lt;/EM&gt;&lt;I&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; for( int k = 0; k &amp;lt; 100; k++ ) {&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x&lt;I&gt;&lt;K&gt; = 0.0;&lt;/K&gt;&lt;/I&gt;&lt;/EM&gt;&lt;I&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; }&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;for( int j = 0; j &amp;lt; 19; j++ ) {&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; if( x&lt;J&gt; != NULL ) {&lt;/J&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ippsFree(x&lt;J&gt;);&lt;/J&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x&lt;J&gt; = NULL;&lt;/J&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; }&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;ippsFree(x);&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;x = NULL;&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;************************************************&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;In the reference manual I found something like&lt;BR /&gt;...&lt;BR /&gt;Ipp32f* ippsMalloc_32f(int len);&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;Example&lt;BR /&gt;The following example shows how to use the function ippsMalloc_8u:&lt;BR /&gt;&lt;EM&gt;void func_malloc(void) {&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Ipp8u* pBuf = ippsMalloc_8u(8*sizeof(Ipp8u));&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;if(NULL == pBuf)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp; // not enough memory&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;ippsFree(pBuf);&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;I can not really believe that also the sizeof(IppXYZ) has to be multiplied when calling the ippsMalloc_XYZ(...) function.&lt;BR /&gt;&lt;BR /&gt;I guess the corrupted heap in my small programm is the result of the large adressroom&lt;BR /&gt;- on 64 bit platforms: sizeof(Ipp32f*) = 8 , sizeof(Ipp32f) = 4&lt;BR /&gt;- on 32 bit platforms: sizeof(Ipp32f*) = 4 , sizeof(Ipp32f) = 4&lt;BR /&gt;&lt;BR /&gt;If I use&lt;BR /&gt;Ipp32f** x = (Ipp32f**)ippsMalloc_32f(19 * sizeof(Ipp32f*)/sizeof(Ipp32f));&lt;BR /&gt;instead of&lt;BR /&gt;Ipp32f** x = (Ipp32f**)ippsMalloc_32f(19);&lt;BR /&gt;the program works perfect on all platforms (32 and 64 bit).&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Has anybody an idea what's going wrong?&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2012 15:03:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Corrupted-heap-on-64-bit-platforms-using-Ipp32f-and-ippsMalloc/m-p/990223#M22209</guid>
      <dc:creator>Peter_N_1</dc:creator>
      <dc:date>2012-09-06T15:03:02Z</dc:date>
    </item>
    <item>
      <title>Hello,</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Corrupted-heap-on-64-bit-platforms-using-Ipp32f-and-ippsMalloc/m-p/990224#M22210</link>
      <description>Hello, 

In the 64 bit platform, the size of point is 64 bits( 8 bytes). so it should be:  
Ipp32f** x = (Ipp32f**)ippsMalloc_64f(19);

Thanks,
Chao</description>
      <pubDate>Fri, 07 Sep 2012 03:06:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Corrupted-heap-on-64-bit-platforms-using-Ipp32f-and-ippsMalloc/m-p/990224#M22210</guid>
      <dc:creator>Chao_Y_Intel</dc:creator>
      <dc:date>2012-09-07T03:06:17Z</dc:date>
    </item>
    <item>
      <title>Hi Peter,</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Corrupted-heap-on-64-bit-platforms-using-Ipp32f-and-ippsMalloc/m-p/990225#M22211</link>
      <description>Hi Peter,
 
The first line of your sample is not clear.

   Ipp32f** x = (Ipp32f**)ippsMalloc_32f(19);

If your are going to allocate room for 19 pointers to Ipp32f (19 * Ipp32f*), you should ask for at least 19*sizeof(Ipp32f*) bytes. On 32-bit system it will be 76 bytes, on 64-bit - 152 bytes. 
In any case the required space depends on size of pointer in you particular system. 
What if you got 128-bit system? ))

Assumption that sizeof(Ipp32f*) is equal to sizeof(Ipp32f) is wrong. ippsMalloc_32f allocates memory for 32-bit variables only. I wouldn't use IPP allocation functions for that. Or, you can use ippsMalloc_8u(19 * sizeof(Ipp32f*)). Here, Malloc_8u is similar to conventional "malloc" function.
 
Regards,
Sergey</description>
      <pubDate>Fri, 07 Sep 2012 14:24:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Corrupted-heap-on-64-bit-platforms-using-Ipp32f-and-ippsMalloc/m-p/990225#M22211</guid>
      <dc:creator>Sergey_K_Intel</dc:creator>
      <dc:date>2012-09-07T14:24:21Z</dc:date>
    </item>
    <item>
      <title>Thanks for the comments.</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Corrupted-heap-on-64-bit-platforms-using-Ipp32f-and-ippsMalloc/m-p/990226#M22212</link>
      <description>Thanks for the comments.

I discussed the problem again with a friend of mine. The correct way to access *PointerArrays* should be:

Ipp32f** x = (Ipp32f**)malloc(19 * sizeof(Ipp32f*));
for( int i = 0; i &amp;lt; 19; i++ ) {
  x&lt;I&gt; = (Ipp32f*)ippsMalloc_32f(100);
  for( int k = 0; k &amp;lt; 100; k++ ) {
    x&lt;I&gt;&lt;K&gt; = 0.0;
  }
}
...
for( int j = 0; j &amp;lt; 19; j++ ) {
  if( x&lt;J&gt; != NULL ) {
    ippsFree(x&lt;J&gt;);
    x&lt;J&gt; = NULL;
  }
}
free(x);
x = NULL;&lt;/J&gt;&lt;/J&gt;&lt;/J&gt;&lt;/K&gt;&lt;/I&gt;&lt;/I&gt;</description>
      <pubDate>Wed, 12 Sep 2012 07:37:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Corrupted-heap-on-64-bit-platforms-using-Ipp32f-and-ippsMalloc/m-p/990226#M22212</guid>
      <dc:creator>Peter_N_1</dc:creator>
      <dc:date>2012-09-12T07:37:42Z</dc:date>
    </item>
    <item>
      <title>what is the parameter 'len'</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Corrupted-heap-on-64-bit-platforms-using-Ipp32f-and-ippsMalloc/m-p/990227#M22213</link>
      <description>&lt;P&gt;what is the parameter 'len' referring to in ippsMalloc_XYZ(int len) function?&lt;/P&gt;

&lt;P&gt;does it refer to "number of bytes", or "number" of elements"?&lt;/P&gt;

&lt;P&gt;using examples on the reference:&amp;nbsp; &lt;A href="https://software.intel.com/en-us/ipp-9.0-ipps-manual-pdf" target="_blank"&gt;https://software.intel.com/en-us/ipp-9.0-ipps-manual-pdf&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;page 35:&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Ipp8u* pBuf = ippsMalloc_8u(8*&lt;STRONG&gt;sizeof(Ipp8u)&lt;/STRONG&gt;);&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;seems referring to "number of bytes"&lt;/P&gt;

&lt;P&gt;but the example on page 168: &amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;EM&gt;Ipp32f *x = ippsMalloc_32f(&lt;STRONG&gt;1000&lt;/STRONG&gt;), mean;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int i;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i = 0; i&amp;lt;&lt;STRONG&gt;1000&lt;/STRONG&gt;; ++i) x&lt;I&gt; = (float)rand() / RAND_MAX;&lt;/I&gt;&lt;/EM&gt;&lt;I&gt;&lt;/I&gt;&lt;/P&gt;

&lt;P&gt;seemly referring to&amp;nbsp; "number of elements": here 'array' x has 1000 'elements', and will take 1000*sizeof(Ipp32f), or 4000 bytes!&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2015 17:54:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Corrupted-heap-on-64-bit-platforms-using-Ipp32f-and-ippsMalloc/m-p/990227#M22213</guid>
      <dc:creator>jinming_g_</dc:creator>
      <dc:date>2015-12-14T17:54:29Z</dc:date>
    </item>
    <item>
      <title>This is question is repost</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Corrupted-heap-on-64-bit-platforms-using-Ipp32f-and-ippsMalloc/m-p/990228#M22214</link>
      <description>This is question is repost here: &lt;A href="https://software.intel.com/en-us/forums/intel-integrated-performance-primitives/topic/604623" target="_blank"&gt;https://software.intel.com/en-us/forums/intel-integrated-performance-primitives/topic/604623&lt;/A&gt;

Thanks,
Chao</description>
      <pubDate>Tue, 22 Dec 2015 05:42:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Corrupted-heap-on-64-bit-platforms-using-Ipp32f-and-ippsMalloc/m-p/990228#M22214</guid>
      <dc:creator>Chao_Y_Intel</dc:creator>
      <dc:date>2015-12-22T05:42:23Z</dc:date>
    </item>
  </channel>
</rss>

