Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Icc not detecting duplicate variables in OMP target update clause

Grund__Aalexander
420 Views

If you mention (accidentally) a variable twice in an OMP 4.0 target update clause icc 14.0.2 will not detect this and instead ignore it.

Sample Code:

#include <stdio.h>
#include <stdlib.h>

#pragma omp declare target
int x,y;
#pragma omp end declare target

int main (int argc, char *argv[]) {
  
  x = 4;
  y = 5;
  #pragma omp target update to(x,y)
  
  #pragma omp target
  printf("4=%d 5=%d\n",x,y);
  
  x = 8;
  y = 9;
  #pragma omp target update to(y,x,y)
  
  #pragma omp target
  printf("8=%d 9=%d\n",x,y); //Output is "8=8 9=5" (!!!!)

  return EXIT_SUCCESS;
}

See the 2nd printf.

This just caused me a lot of trouble as I had a huge update statement with one duplicate variable which silently messed up the whole program.
Please make this an error!

0 Kudos
3 Replies
jimdempseyatthecove
Honored Contributor III
420 Views

Out of curiosity, if you mention the variable 3 times does it work (iow the internals of the compiler is ++'ing the update flag)?

Jim Dempsey

0 Kudos
KitturGanesh
Employee
420 Views

Hi Alex,
Just noticed this issue. Yes, the compiler should flag this as an error :-( I'll file this issue with our developers and will keep you updated, appreciate much.

_Kittur

0 Kudos
KitturGanesh
Employee
420 Views

Alex, interestingly enough when I tried private(x,x) the compiler does flag an error so for this case (issue) it should similarly flag accordingly....

_Kittur

0 Kudos
Reply