Intel® oneAPI Base Toolkit
Support for the core tools and libraries within the base toolkit that are used to build and deploy high-performance data-centric applications.
419 Discussions

ICX bug (bad code) with __float128 [2021.1 Beta 20200715]

vinc17
Beginner
1,527 Views

When testing GNU MPFR with ICX 2021.1 Beta 20200715, the test tset_float128 failed. Here's a simple testcase:

#include <stdio.h>

void foo (__float128 d)
{
  int i;
  __float128 p[8], q[8];

  if (d >= 1.0)
    {
      p[0] = 2.0;
      q[0] = 0.5;
      printf ("q[0] = %a\n", (double) q[0]);
      for (i = 0; i < 13 && d >= p[i]; i++)
        {
          printf ("q[%d] = %a\n", i, (double) q[i]);
          p[i+1] = p[i] * p[i];
          q[i+1] = q[i] * q[i];
        }
      for (; i >= 0; i--)
        if (d >= p[i])
          d *= q[i];
    }
  else if (d < 0.5)
    {
      p[0] = 2.0;
      q[0] = 0.5;
      for (i = 0; i < 13 && d < q[i]; i++)
        {
          p[i+1] = p[i] * p[i];
          q[i+1] = q[i] * q[i];
        }
      for (; i >= 0; i--)
        while (d < q[i])
          d *= p[i];
    }

  return;
}

int main (void)
{
  volatile __float128 d = 65536;

  foo (d);
  return 0;
}

When I compile this code with optimizations (i.e. not with -O0), I get:

q[0] = 0x1p-1
q[0] = 0x0p+0
q[1] = 0x0p+0
q[2] = 0x0p+0
q[3] = 0x0p+0
q[4] = 0x0p+0

instead of

q[0] = 0x1p-1
q[0] = 0x1p-1
q[1] = 0x1p-2
q[2] = 0x1p-4
q[3] = 0x1p-8
q[4] = 0x1p-16

 

0 Kudos
4 Replies
vinc17
Beginner
1,522 Views

Actually the bug occurs only with -O and -O2 (not with -O1 and -O3). So I assume that -O is equivalent to -O2.

0 Kudos
AbhishekD_Intel
Moderator
1,502 Views

Hi,


Thank you for reporting this issue. We are also getting the same incorrect result with -O2 flag whereas we are getting the correct results with O1 and O3 flag as mentioned by you. As it seems a bug to us, we are forwarding this bug to the concerned team. They will get back to you.



Warm Regards,

Abhishek


0 Kudos
PrasanthD_intel
Moderator
1,226 Views

Hi Vincent,


Thanks for your patience. The issue raised by you has been fixed in the latest OneAPI version 2021.2. Please download and let us know your experience with it.


0 Kudos
PrasanthD_intel
Moderator
1,208 Views

Hi Vincent,


We are closing this thread as the issue has been fixed.

Please raise a new thread in case of any further issues.


Regards

Prasanth


0 Kudos
Reply