Icc not detecting duplicate variables in OMP target update clause

Icc not detecting duplicate variables in OMP target update clause

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!

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

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


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.


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....


Leave a Comment

Please sign in to add a comment. Not a member? Join today