<?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 defect is fixed in the in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/gsl-library-optimization-error/m-p/1038523#M45059</link>
    <description>&lt;P&gt;This defect is fixed in the Intel® Parallel Studio XE 2015 Update 1 release (Version 15.0.1.133 Build 20141023 - Linux) now available from our &lt;A href="https://registrationcenter.intel.com/" target="_blank"&gt;Intel® Registration Center&lt;/A&gt;.&lt;/P&gt;</description>
    <pubDate>Mon, 17 Nov 2014 12:40:12 GMT</pubDate>
    <dc:creator>Kevin_D_Intel</dc:creator>
    <dc:date>2014-11-17T12:40:12Z</dc:date>
    <item>
      <title>gsl library optimization error</title>
      <link>https://community.intel.com/t5/Software-Archive/gsl-library-optimization-error/m-p/1038518#M45054</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;

&lt;P&gt;as a follow up to my previous post on the gsl library coredumping on the Xeon Phi there is good news and bad news.&lt;/P&gt;

&lt;P&gt;The good news is: with icc v15 the coredumps are gone&lt;/P&gt;

&lt;P&gt;The bad news is: there are other vectorization errors that seem to occur only when -mmic is used.&lt;/P&gt;

&lt;P&gt;Consider the following program (distilled from the gsl-1.16 source code):&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#include &amp;lt;stdio.h&amp;gt;

struct gsl_block_char_struct
{
  size_t size;
  char *data;
};

typedef struct gsl_block_char_struct gsl_block_char;


typedef struct
{
  size_t size1;
  size_t size2;
  size_t tda;
  char * data;
  gsl_block_char * block;
  int owner;
} gsl_matrix_char;

gsl_block_char *
gsl_block_char_alloc (const size_t n)
{
  gsl_block_char * b;

  b = (gsl_block_char *) malloc (sizeof (gsl_block_char));
  b-&amp;gt;data = (char *) calloc (1, 1 * n * sizeof (char));
  b-&amp;gt;size = n;

  return b;
}

gsl_matrix_char *
gsl_matrix_char_alloc (const size_t n1, const size_t n2)
{
  gsl_block_char * block;
  gsl_matrix_char * m;

  m = (gsl_matrix_char *) malloc (sizeof (gsl_matrix_char));

  block = gsl_block_char_alloc (n1 * n2) ;

  m-&amp;gt;data = block-&amp;gt;data;
  m-&amp;gt;size1 = n1;
  m-&amp;gt;size2 = n2;
  m-&amp;gt;tda = n2;
  m-&amp;gt;block = block;
  m-&amp;gt;owner = 1;

  return m;
}

gsl_matrix_char_get(const gsl_matrix_char * m, const size_t i, const size_t j)
{
  return m-&amp;gt;data[i * m-&amp;gt;tda + j] ;
}


void
gsl_matrix_char_set(gsl_matrix_char * m, const size_t i, const size_t j, const char x)
{
  m-&amp;gt;data[i * m-&amp;gt;tda + j] = x ;
}

void
gsl_matrix_char_minmax (const gsl_matrix_char * m,
                               char * min_out,
                               char * max_out)
{
  const size_t M = m-&amp;gt;size1;
  const size_t N = m-&amp;gt;size2;
  const size_t tda = m-&amp;gt;tda;

  char max = m-&amp;gt;data[0 * tda + 0];
  char min = m-&amp;gt;data[0 * tda + 0];

  size_t i, j;

//  #pragma novector
  for (i = 0; i &amp;lt; M; i++)
    {
//      #pragma novector
      for (j = 0; j &amp;lt; N; j++)
        {
          char x = m-&amp;gt;data[i * tda + j];
          if (x &amp;lt; min)
           {
              min = x;
            }
          if (x &amp;gt; max)
            {
              max = x;
            }
        }
    }

  *min_out = min;
  *max_out = max;
}


void
test_char_func (const size_t M, const size_t N)
{
  size_t i, j;
  size_t k = 0;
  char min, max;

  gsl_matrix_char * m = gsl_matrix_char_alloc (M, N);

  for (i = 0; i &amp;lt; M; i++)
  {
    for (j = 0; j &amp;lt; N; j++)
    {
      k++;
      gsl_matrix_char_set (m, i, j, (char) k);
    }
  }

  char exp_max = gsl_matrix_char_get (m, 0, 0);
  char exp_min = gsl_matrix_char_get (m, 0, 0); 
  for (i = 0; i &amp;lt; M; i++)
  {
    for (j = 0; j &amp;lt; N; j++)
    {   
      char k = gsl_matrix_char_get (m, i, j); 
      if (k &amp;gt; exp_max) {
        exp_max =  gsl_matrix_char_get (m, i, j); 
      }   
      if (k &amp;lt; exp_min) {
        exp_min =  gsl_matrix_char_get (m, i, j); 
      }   
    }   
  }

  gsl_matrix_char_minmax (m, &amp;amp;min, &amp;amp;max);

  printf("exp_max = %02X max = %02X\n", exp_max, max);
  printf("exp_min = %02X min = %02X\n", exp_min, min);

  if (max != exp_max) fprintf(stderr, "gsl_matrix_char_minmax returns incorrect maximum value\n");
  if (min != exp_min) fprintf(stderr, "gsl_matrix_char_minmax returns incorrect minimum value\n");
}


int
main (void)
{
  size_t M = 53; 
  size_t N = 107;

  test_char_func (M, N); 
}
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;This code compiles without a warning using&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;icc -O2 -mmic -Wall -Wuninitialized -g -o mytest mytest.c&lt;/PRE&gt;

&lt;P&gt;yet when it runs it produces a warning&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;$ ssh mic0 $PWD/mytest
exp_max = 7F max = 27
exp_min = FFFFFF80 min = 00
gsl_matrix_char_minmax returns incorrect maximum value
gsl_matrix_char_minmax returns incorrect minimum value

&lt;/PRE&gt;

&lt;P&gt;Remove the '-mmic' and rerun on the host CPU and the code runs just fine.&lt;/P&gt;

&lt;P&gt;If I uncomment the #pragma vector lines the code also runs fine on the Xeon Phi.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Sep 2014 23:21:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/gsl-library-optimization-error/m-p/1038518#M45054</guid>
      <dc:creator>JJK</dc:creator>
      <dc:date>2014-09-02T23:21:10Z</dc:date>
    </item>
    <item>
      <title>Hi Jan,</title>
      <link>https://community.intel.com/t5/Software-Archive/gsl-library-optimization-error/m-p/1038519#M45055</link>
      <description>&lt;P&gt;Hi Jan,&lt;/P&gt;

&lt;P&gt;Thank you for the convenient test case!&amp;nbsp;&amp;nbsp; I reproduced the behavior described using both the 14.0 and 15.0 compilers. The expected results occur at -O1 or at -O2 but with -O2 only when the novector directive is active for the inner loop. The other compiler options are not at play. &amp;nbsp;&lt;/P&gt;

&lt;P&gt;I reported this to Development (see Internal tracking id below) for some further analysis and will keep you updated on their findings.&lt;/P&gt;

&lt;P&gt;(Internal tracking id: DPD200360578)&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;(Resolution Update on 11/17/2014):&lt;/STRONG&gt; This defect is fixed in the Intel® Parallel Studio XE 2015 Update 1 release (2015.0.133 - Linux)&lt;/P&gt;</description>
      <pubDate>Wed, 03 Sep 2014 15:05:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/gsl-library-optimization-error/m-p/1038519#M45055</guid>
      <dc:creator>Kevin_D_Intel</dc:creator>
      <dc:date>2014-09-03T15:05:00Z</dc:date>
    </item>
    <item>
      <title>Development confirmed this is</title>
      <link>https://community.intel.com/t5/Software-Archive/gsl-library-optimization-error/m-p/1038520#M45056</link>
      <description>&lt;P&gt;Development confirmed this is a defect related to an incorrect conversion generated using an unsigned data type instead of a signed data type. To work around (as you found), the &lt;STRONG&gt;novector &lt;/STRONG&gt;can be used although they thought using an &lt;STRONG&gt;unsigned char&lt;/STRONG&gt; or &lt;STRONG&gt;int &lt;/STRONG&gt;instead of &lt;STRONG&gt;signed char&lt;/STRONG&gt; might also. I tried those and &lt;STRONG&gt;int &lt;/STRONG&gt;seemed to work but the &lt;STRONG&gt;novector &lt;/STRONG&gt;is probably best/easiest.&lt;/P&gt;

&lt;P&gt;I will keep you updated on the availability of a fix in a future IPS XE 2015 (15.0 compiler) release.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Sep 2014 08:32:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/gsl-library-optimization-error/m-p/1038520#M45056</guid>
      <dc:creator>Kevin_D_Intel</dc:creator>
      <dc:date>2014-09-05T08:32:34Z</dc:date>
    </item>
    <item>
      <title>Hi Kevin,</title>
      <link>https://community.intel.com/t5/Software-Archive/gsl-library-optimization-error/m-p/1038521#M45057</link>
      <description>&lt;P&gt;Hi Kevin,&lt;/P&gt;

&lt;P&gt;I can live with that without any issues - I think I'll create a patch for the gsl lib to compile and test it for the Xeon Phi ; that patch would include the #pragma line in it plus some minor changes to the gsl libtool code so that the tests are actually run on the Xeon Phi.&lt;/P&gt;

&lt;P&gt;AFAIAC this ticket can be closed.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Sep 2014 16:07:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/gsl-library-optimization-error/m-p/1038521#M45057</guid>
      <dc:creator>JJK</dc:creator>
      <dc:date>2014-09-05T16:07:27Z</dc:date>
    </item>
    <item>
      <title>Ok, sounds good Jan.
	 </title>
      <link>https://community.intel.com/t5/Software-Archive/gsl-library-optimization-error/m-p/1038522#M45058</link>
      <description>&lt;P&gt;Ok, sounds good Jan.&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Sep 2014 17:33:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/gsl-library-optimization-error/m-p/1038522#M45058</guid>
      <dc:creator>Kevin_D_Intel</dc:creator>
      <dc:date>2014-09-05T17:33:15Z</dc:date>
    </item>
    <item>
      <title>This defect is fixed in the</title>
      <link>https://community.intel.com/t5/Software-Archive/gsl-library-optimization-error/m-p/1038523#M45059</link>
      <description>&lt;P&gt;This defect is fixed in the Intel® Parallel Studio XE 2015 Update 1 release (Version 15.0.1.133 Build 20141023 - Linux) now available from our &lt;A href="https://registrationcenter.intel.com/" target="_blank"&gt;Intel® Registration Center&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Nov 2014 12:40:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/gsl-library-optimization-error/m-p/1038523#M45059</guid>
      <dc:creator>Kevin_D_Intel</dc:creator>
      <dc:date>2014-11-17T12:40:12Z</dc:date>
    </item>
  </channel>
</rss>

