Community
cancel
Showing results for 
Search instead for 
Did you mean: 
113 Views

OpenMP map(alloc) not working for arrays (SIGSEGV)

I'm trying to use local arrays in an OMP target region. If its size is dependent on a variable, the device will crash with a SIGSEGV "offload error: process on the device 0 was terminated by signal 11 (SIGSEGV)"

Code: 

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

int main (int argc, char *argv[]) {
  {
    int size=argc*100000;
    int ar[size];
    int ar2[100000];
    printf("Size host %lld %lld\n",sizeof(ar),sizeof(ar2));
    #pragma omp target map(alloc:ar,ar2)
      printf("Size device %lld %lld\n",sizeof(ar),sizeof(ar2));
    printf("Size worked\n");
    
    #pragma omp target map(alloc:ar2)
      ar2[size-1]=55;
    printf("Static worked\n");
    
    #pragma omp target map(alloc:ar)
      ar[size-1]=55;
    printf("Dynamic worked\n");
  }
  
  return EXIT_SUCCESS;
}

If you run this you get the output:

Size host 400000 400000
Size worked
Static worked
offload error: process on the device 0 was terminated by signal 11 (SIGSEGV)

Strangely: You can access lower entries (e.g. ar[0], ar[1]...) without problems (not sure if they are valid though) and using "10000" as the size does work (at least without a crash). Also doubling the size of ar2 works. Is this a compiler bug or do I have to use this as an array section? If so, can you point me to the OMP spec where this is explained?

0 Kudos
3 Replies
TimP
Black Belt
113 Views

Apparently, the 15.0 beta compiler made an improvement here:

[tim@tim-wsm net]$ icc -openmp ag.c
[tim@tim-wsm net]$ ./a.out
Size host 400000 400000
Size worked
Static worked
Dynamic worked
Size device 400000 400000

 

Kittur_G_Intel
Employee
113 Views

Alex, yes, the 15.0 beta works for me too on the test case so it's fixed in that version. I'll file this issue against 14.0 anyways with the developers _Kittur
Kittur_G_Intel
Employee
113 Views

Alex, I've filed the issue with the developers as it fails with 14.0 version and will update you accordingly as soon as the next version (containing the fix) is released accordingly.... _Kittur
Reply