<?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 And lastly ,I want to ask . in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/mm256-add-ps-crashes-program/m-p/1014539#M35499</link>
    <description>&lt;P&gt;And lastly ,I want to ask .&lt;/P&gt;

&lt;P&gt;After finding the miminum ( if you look at post 1):&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;__m256 theMin = _mm256_min_ps( SIMDTempDistance[ i ]  , D );
&lt;/PRE&gt;

&lt;P&gt;I am storing:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;D = theMin;
theThreshold = theV[ i ];  ( theThreshold is  __m256i theThreshold; )&lt;/PRE&gt;

&lt;P&gt;and then store theThreshold to output array:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;_mm256_store_si256( &amp;amp;theVor[ x + y * width ] , theThreshold );&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Is this right?Do I have to do something else?&lt;/P&gt;

&lt;P&gt;I remind you that , in post 1 , I am doing:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;__m256i * theVor = (__m256i*) Vor;&lt;/PRE&gt;

&lt;P&gt;where Vor is my output float array .&lt;/P&gt;

&lt;P&gt;Can I do something like:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt; theVor[ x + y * width ] = theThreshold;&lt;/PRE&gt;

&lt;P&gt;instead?&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Wed, 08 Apr 2015 12:50:01 GMT</pubDate>
    <dc:creator>George</dc:creator>
    <dc:date>2015-04-08T12:50:01Z</dc:date>
    <item>
      <title>_mm256_add_ps crashes program</title>
      <link>https://community.intel.com/t5/Software-Archive/mm256-add-ps-crashes-program/m-p/1014535#M35495</link>
      <description>&lt;P&gt;Hello ,&lt;/P&gt;

&lt;P&gt;I am using in my code something like:&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;int x , y;

float * TempD = (float*) _mm_malloc( N * sizeof(*TempD) ,64 );
    
__m256  * SIMDTempD = (__m256*) TempD;
__m256  * theX = (__m256*) X;
__m256  * theY = (__m256*) Y;
__m256i * theV = (__m256i*) V;
__m256i * theVoronoi = (__m256i*) Vor;

__m256 Xd ,Yd ,XdSquared ,YdSquared;
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;and then in a loop:&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;__m256i tempx = _mm256_set1_epi32( x );
__m256    xIdx  = _mm256_castsi256_ps( tempx );
                    
__m256i tempy = _mm256_set1_epi32( y );
 __m256    yIdx  = _mm256_castsi256_ps( tempy );
                    
Xd = _mm256_sub_ps( theX[ i ] , xIdx );
Yd = _mm256_sub_ps( theY[ i ] , yIdx );
                    
distXSquared = _mm256_mul_ps( Xd , Xd );
distYSquared = _mm256_mul_ps( Yd , Yd );
                    
SIMDTempD[ i ] = _mm256_add_ps( XdSquared , YdSquared );

                   
 __m256 theMin = _mm256_min_ps( SIMDTempDistance[ i ]  , D );&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;When I run the code it gives :&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;*** glibc detected *** .. double free or corruption &lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;If I comment out the line :&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;SIMDTempD[ i ] = _mm256_add_ps( XdSquared , YdSquared );&lt;/PRE&gt;

&lt;P&gt;then the code runs without a problem!&lt;/P&gt;

&lt;P&gt;Am I missing something here?&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2015 11:05:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/mm256-add-ps-crashes-program/m-p/1014535#M35495</guid>
      <dc:creator>George</dc:creator>
      <dc:date>2015-04-08T11:05:35Z</dc:date>
    </item>
    <item>
      <title>I even tried ,instead of</title>
      <link>https://community.intel.com/t5/Software-Archive/mm256-add-ps-crashes-program/m-p/1014536#M35496</link>
      <description>&lt;P&gt;I even tried ,instead of using &lt;CODE class="plain"&gt;SIMDTempD &lt;/CODE&gt;:&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;float * TempD = (float*) _mm_malloc( N * sizeof(*TempD) ,64 );

for (i int i = 0; i &amp;lt; N; i++ )

      TempD[ i ] = 0;

__m256 now = _mm256_load_ps( &amp;amp;TempD[ i ] );
now =  _mm256_add_ps( XdSquared , YdSquared );&lt;/PRE&gt;

&lt;P&gt;(instead of&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;SIMDTempD[ i ] = _mm256_add_ps( XdSquared , YdSquared );&lt;/PRE&gt;

&lt;P&gt;&lt;CODE class="plain"&gt;)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;but I am receiving a segmentation fault..&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2015 11:52:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/mm256-add-ps-crashes-program/m-p/1014536#M35496</guid>
      <dc:creator>George</dc:creator>
      <dc:date>2015-04-08T11:52:19Z</dc:date>
    </item>
    <item>
      <title>George,</title>
      <link>https://community.intel.com/t5/Software-Archive/mm256-add-ps-crashes-program/m-p/1014537#M35497</link>
      <description>&lt;P&gt;George,&lt;/P&gt;

&lt;P&gt;You allocate TempD to N number of floats.&lt;/P&gt;

&lt;P&gt;Your vector size is 8 floats.&lt;/P&gt;

&lt;P&gt;In your #1 code it is not shown the loop control for i, but you do show it in #2 as indexing by float, not by vector strides&amp;nbsp;(in this case not by i+=8)&lt;/P&gt;

&lt;P&gt;Your #2 may have failed when&amp;nbsp;i exceeded N-8-1 and ran off the end of the array. The fault would occur if you were lucky enough (or unlucky enough) to have the buffer overrun run over a mapped page boundary.&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2015 12:09:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/mm256-add-ps-crashes-program/m-p/1014537#M35497</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2015-04-08T12:09:43Z</dc:date>
    </item>
    <item>
      <title>Hello Jim and thanks for</title>
      <link>https://community.intel.com/t5/Software-Archive/mm256-add-ps-crashes-program/m-p/1014538#M35498</link>
      <description>&lt;P&gt;Hello Jim and thanks for helping.&lt;/P&gt;

&lt;P&gt;I am new to vector/intrinsics programming ,so I can't fully understand all concepts.&lt;/P&gt;

&lt;P&gt;The allocation I am using for theX,theY... is like:&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;const int N = 80;
const int Nx = 32 , Ny = 32 ,width = 256 , height = 256;
const int TotalN = width * height;

float * X = (float*) _mm_malloc( Nx * Ny * sizeof (*X) ,64 );
float * Y = (float*) _mm_malloc( Nx * Ny * sizeof (*Y) ,64 );
int * V = (int*) _mm_malloc( NbOfPoints * sizeof (*V) ,64 );

int * Vor = (int*) _mm_malloc ( TotalN * N * sizeof(*Vor) ,64 );

and the loops I am using which have the intrinsics are:

for ( y = 0; y &amp;lt; height; y++ )
{
      for ( x = 0; x &amp;lt; width; x++ )
      {
                __m256 D = _mm256_set1_ps( FLT_MAX );
                
                for ( int i = 0; i &amp;lt; N; i++ )
                {
                    __m256i tempx = _mm256_set1_epi32( x );

             ..........&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I would appreciate if you can explain me how I can program what I want using the intrinsics.&lt;/P&gt;

&lt;P&gt;Thank you!&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2015 12:17:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/mm256-add-ps-crashes-program/m-p/1014538#M35498</guid>
      <dc:creator>George</dc:creator>
      <dc:date>2015-04-08T12:17:58Z</dc:date>
    </item>
    <item>
      <title>And lastly ,I want to ask .</title>
      <link>https://community.intel.com/t5/Software-Archive/mm256-add-ps-crashes-program/m-p/1014539#M35499</link>
      <description>&lt;P&gt;And lastly ,I want to ask .&lt;/P&gt;

&lt;P&gt;After finding the miminum ( if you look at post 1):&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;__m256 theMin = _mm256_min_ps( SIMDTempDistance[ i ]  , D );
&lt;/PRE&gt;

&lt;P&gt;I am storing:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;D = theMin;
theThreshold = theV[ i ];  ( theThreshold is  __m256i theThreshold; )&lt;/PRE&gt;

&lt;P&gt;and then store theThreshold to output array:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;_mm256_store_si256( &amp;amp;theVor[ x + y * width ] , theThreshold );&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Is this right?Do I have to do something else?&lt;/P&gt;

&lt;P&gt;I remind you that , in post 1 , I am doing:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;__m256i * theVor = (__m256i*) Vor;&lt;/PRE&gt;

&lt;P&gt;where Vor is my output float array .&lt;/P&gt;

&lt;P&gt;Can I do something like:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt; theVor[ x + y * width ] = theThreshold;&lt;/PRE&gt;

&lt;P&gt;instead?&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2015 12:50:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/mm256-add-ps-crashes-program/m-p/1014539#M35499</guid>
      <dc:creator>George</dc:creator>
      <dc:date>2015-04-08T12:50:01Z</dc:date>
    </item>
    <item>
      <title>Quote:George wrote:</title>
      <link>https://community.intel.com/t5/Software-Archive/mm256-add-ps-crashes-program/m-p/1014540#M35500</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;George wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;The allocation I am using for theX,theY... is like:&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;const int N = 80;
const int Nx = 32 , Ny = 32 ,width = 256 , height = 256;
const int TotalN = width * height;

float * X = (float*) _mm_malloc( Nx * Ny * sizeof (*X) ,64 );
float * Y = (float*) _mm_malloc( Nx * Ny * sizeof (*Y) ,64 );
int * V = (int*) _mm_malloc( NbOfPoints * sizeof (*V) ,64 );

int * Vor = (int*) _mm_malloc ( TotalN * N * sizeof(*Vor) ,64 );

and the loops I am using which have the intrinsics are:

for ( y = 0; y &amp;lt; height; y++ )
{
      for ( x = 0; x &amp;lt; width; x++ )
      {
                __m256 D = _mm256_set1_ps( FLT_MAX );
                
                for ( int i = 0; i &amp;lt; N; i++ )
                {
                    __m256i tempx = _mm256_set1_epi32( x );

             ..........&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I would appreciate if you can explain me how I can program what I want using the intrinsics.&lt;/P&gt;

&lt;P&gt;Thank you!&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;If x and y are used to compute an index into X and/or Y then how does Nx*Ny relate to width and/or height?&lt;/P&gt;

&lt;P&gt;(excepting for _mm256_set1_... and loads/stores&amp;nbsp;and a few others) the _mm256_.... vector instructions&amp;nbsp;require _mm256 (vector wide) data.&lt;/P&gt;

&lt;P&gt;I suggest you take a non-intrinsic but vectored version of some arbitrary small function and compile it with assembler output with source included.&amp;nbsp;Then look at the output for ideas of what to do. Next, copy the small function body into a differently named function and start adding intrinsics (a few statements at a time), compare the outputs of running both functions. Keep working at converting more statements to intrinsics checking results at each step.&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2015 15:16:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/mm256-add-ps-crashes-program/m-p/1014540#M35500</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2015-04-08T15:16:20Z</dc:date>
    </item>
  </channel>
</rss>

