Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

OpenMP or optimization changed from 13.xxx to 14.0.2.176

$
0
0

Dear Experts in OpenMP and Intel C  14.x ,

Until version 13.x of Intel C I had the following code :

static  int   fobj_offset(int m, double *a, double *fun)

{

      int     n = npivot;

      double  *p = ppivot;

      int     i;

      double  cen[3*n];

      double  x=0.0,y=0.0,z=0.0;

      double  err=0.0;

      Tool_Point_Offset[0] = a[0];

      Tool_Point_Offset[1] = a[1];

      Tool_Point_Offset[2] = a[2];

#pragma omp parallel for reduction(+ : x,y,z) num_threads (2)

      for (i=0; i<n; i++)

      {

          ComputeToolPoint(&p[8*i+0],  &p[8*i+3],  &cen[3*i]);

          x += cen[3*i + 0];

          y += cen[3*i + 1];

          z += cen[3*i + 2];

      }

 

      x = x/n;

      y = y/n;

      z = z/n;

 

--------------------------------

Every thing was fime. Tool_Point_Offset[]  is a static (local) double array with 4 elements, only 3 are used. The values of Tool_Point_Offset are invariant for the whole for duration. The values of Tool_Point_Offset[] are used inside ComputeToolPoint(), but are not modified.

Starting with version 14.0.2.176 of the compiler I had to change into :

static  int   fobj_offset(int m, double *a, double *fun)

{

      int     n = npivot;

      double  *p = ppivot;

      int     i;

      double  cen[3*n];

      double  x=0.0,y=0.0,z=0.0;

      double  err=0.0;

#pragma omp parallel for reduction(+ : x,y,z) num_threads (2)

      for (i=0; i<n; i++)

      {

          Tool_Point_Offset[0] = a[0];

          Tool_Point_Offset[1] = a[1];

          Tool_Point_Offset[2] = a[2];

      

          ComputeToolPoint(&p[8*i+0],  &p[8*i+3],  &cen[3*i]);

          x += cen[3*i + 0];

          y += cen[3*i + 1];

          z += cen[3*i + 2];

      }

      x = x/n;

      y = y/n;

      z = z/n;

-------

I do not understand why this is needed. I started thinking that Tool_Point_Offset was modified inside ComputeToolPoint(), not only used its values, by mistake.  So I printed before and after the loop, but no, it is invariant.

The new arranged code is working fine again, but for me there is not need to move  the Tool_Point_Offset initialization into the loop.

Please any clarification for me ?  Thanks.

 


Viewing all articles
Browse latest Browse all 1616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>