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

Icc not detecting variables in task regions that are only used in (OMP) pragmas

Grund__Aalexander
338 Views

Consider the following code:

#pragma omp parallel
  {
#pragma omp single
    {
#pragma omp task
      {
        printf("%d\n", half_size); /* bug */

#pragma omp target data map(to:values[0:half_size])
#pragma omp target
#pragma omp parallel for
        for (i = 0; i < half_lists; ++i)
          sort(values, i, num_values);
      }

    }
  } 

Without the printf statement and any other usage of the variable, 'half_size' within the target pragma is not recognized by the compiler as required within the 'omp task' block. In contrast, 'half_lists' and 'num_values' are properly copied as they are used in user code and not solely in a target pragma.

Thus, once the runtime hits 'omp target data map', half_size is not properly set, resulting in offload errors, e.g.
'offload error: address range partially overlaps with existing allocation'.

Tested with composer_xe_2013_sp1.2.144 (icc 14.0.2)

0 Kudos
3 Replies
MalReddy_Y_Intel
Employee
338 Views

Hi,

Could you please help us with a complete (compilable) test code to reproduce the error?

Reddy

0 Kudos
Grund__Aalexander
338 Views

One example code is this:

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

int main (int argc, char *argv[]) {
  int half_size = 1000;
  int* values = (int*) malloc(sizeof(int)*half_size);
  int i;
  
  #pragma omp parallel
  {
    #pragma omp single
    {
      #pragma omp task
      {   
        #pragma omp target data map(to:values[0:half_size])
        #pragma omp target
        #pragma omp parallel for
          for (i = 0; i < half_size; ++i)
            values = i;
      }
    }
  }
  
  return EXIT_SUCCESS;
}

If you try to run this, you get a segFault on the device. If you comment the #pragma omp task (note, that this does not change anything in this case) the example works.
I also got the error mentioned in the first post but I cannot reproduce it with a small sample. Will try and update as soon as I got something.

0 Kudos
Sukruth_H_Intel
Employee
338 Views
Hi, I was able to reproduce both the errors that you have mentioned above and also escalated the same to our eng team, I would get back to you with an update. #include #include int main (int argc, char *argv[]) { int half_size = 1008; int* values = (int*) _mm_malloc(sizeof(int)*half_size,64); int i; #pragma omp parallel { #pragma omp single { #pragma omp task { #pragma omp target data map(tofrom:values[0:half_size]) #pragma omp target #pragma omp parallel for #pragma vector aligned for (i = 0; i < 100; ++i) values = i; } } } return EXIT_SUCCESS; } Regards, Sukruth H V
0 Kudos
Reply