Software Archive
Read-only legacy content
17061 Discussions

offload error (signal 11)

Jianbin_F_
Beginner
1,008 Views

I run the attached code with the newly downloaded Intel Parallel Studio 2017 on Intel Xeon Phi 31SP (icc -openmp hello.c -o hello). It reports the following message: 

offload error: process on the device 0 was terminated by signal 11 (SIGSEGV).

Could anybody shede some light on it? 

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

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

int main(int argc, char* argv[])
{
  int *a, *b;
  a = (int *) malloc(sizeof(int));
  b = (int *) malloc(sizeof(int));
  *a = 1;
#pragma omp target data map(to:a) map(from:b)
  {
#pragma omp target
    {
      *b = *a;
    }   
  }
  printf("%d\n", *b);
  return 0;
}

 

0 Kudos
6 Replies
Loc_N_Intel
Employee
1,008 Views

I modified the program so that it can offload an array to the Intel Xeon Phi coprocessor. Note that Intel Parallel Studio 2017 is used in this example:

int main()
{
    int *a, *b;
#ifdef ARRAY
    int num=64;
#else
    int num=1;
#endif
    a = (int *) malloc(num*sizeof(int));
    b = (int *) malloc(num*sizeof(int));

    int n;
    for (n=0; n<num; n++)
    {
       a = n;
       b = -1;
    }
    for (n=0; n<num; n++)
       printf("BEFORE: b[%d]=%d\n", n, b);

    #pragma omp target map(to: a[0:num]) map(from: b[0:num])
    {
#ifdef ARRAY
       #pragma omp parallel for
       for (n=0; n<num; n++)
          b = a;
#else
       b[0] = a[0];
#endif
    }

    for (n=0; n<num; n++)
       printf("AFTER: b[%d]=%d\n", n, b);

    free(a);
    free(b);
     
    return 0;
}

Set the environment variables:

$ source /opt/intel/parallel_studio_xe_2017.0.035/psxevars.sh intel64

Build the binary with one element offload:

$ icc hello.c -qopenmp -o single

Build the binary with an array offload:

$ icc hello.c -qopenmp -o array –DARRAY

Verify that MPSS is in service before running the program:

$ micinfo

Run the program:

$ ./single

$ ./array

0 Kudos
Jianbin_F_
Beginner
1,008 Views

Loc N. (Intel) wrote:

I modified the program so that it can offload an array to the Intel Xeon Phi coprocessor. Note that Intel Parallel Studio 2017 is used in this example:

int main()
{
    int *a, *b;
#ifdef ARRAY
    int num=64;
#else
    int num=1;
#endif
    a = (int *) malloc(num*sizeof(int));
    b = (int *) malloc(num*sizeof(int));

    int n;
    for (n=0; n<num; n++)
    {
       a = n;
       b = -1;
    }
    for (n=0; n<num; n++)
       printf("BEFORE: b[%d]=%d\n", n, b);

    #pragma omp target map(to: a[0:num]) map(from: b[0:num])
    {
#ifdef ARRAY
       #pragma omp parallel for
       for (n=0; n<num; n++)
          b = a;
#else
       b[0] = a[0];
#endif
    }

    for (n=0; n<num; n++)
       printf("AFTER: b[%d]=%d\n", n, b);

    free(a);
    free(b);
     
    return 0;
}

Set the environment variables:

$ source /opt/intel/parallel_studio_xe_2017.0.035/psxevars.sh intel64

Build the binary with one element offload:

$ icc hello.c -qopenmp -o single

Build the binary with an array offload:

$ icc hello.c -qopenmp -o array –DARRAY

Verify that MPSS is in service before running the program:

$ micinfo

Run the program:

$ ./single

$ ./array

Thank you so much for the reply. Then I change the line while all the other lines remain.

#pragma omp target map(to: a[0:num]) map(from: b[0:num])

to

#pragma omp target data map(to: a[0:num]) map(from: b[0:num])

I can compile the code without any issue, but the verification step does not work. I noticed that Array a is not moved to the target device. I wonder whether the OpenMP4.0 is fully supported by the Intel Compiler at the very moment.

0 Kudos
Ravi_N_Intel
Employee
1,008 Views

Intel compiler does support OpenMP4.0.  When you use target without any map and use a pointer inside the target region,  the pointer is treated as scalar and the value it contain ie the host memory is sent to the target.

Change your program as follows

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

int main(int argc, char* argv[])
{
  int *a, *b;
  a = (int *) malloc(sizeof(int));
  b = (int *) malloc(sizeof(int));
  *a = 1;
#pragma omp target data map(to:a[0:1]) map(from:b[0:1])
  {
#pragma omp target map(to:a[0:1]) map(from:b[0:1])
    {
      *b = *a;
    }
  }
  printf(" Value on host %d\n", *b);
  return 0;
}

0 Kudos
Jianbin_F_
Beginner
1,008 Views

Ravi Narayanaswamy (Intel) wrote:

Intel compiler does support OpenMP4.0.  When you use target without any map and use a pointer inside the target region,  the pointer is treated as scalar and the value it contain ie the host memory is sent to the target.

Change your program as follows

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

int main(int argc, char* argv[])
{
  int *a, *b;
  a = (int *) malloc(sizeof(int));
  b = (int *) malloc(sizeof(int));
  *a = 1;
#pragma omp target data map(to:a[0:1]) map(from:b[0:1])
  {
#pragma omp target map(to:a[0:1]) map(from:b[0:1])
    {
      *b = *a;
    }
  }
  printf(" Value on host %d\n", *b);
  return 0;
}

I guess you misunderstand my question. It is not about scalar, but the array/vector version. In OpenMP 4.0 sementics, the data will be moved to the target device when using the following statement separately, right? But it is not working with icc from Parallel Studio 2017.

#pragma omp target data map(to: a[0:num]) map(from: b[0:num])

 

0 Kudos
Ravi_N_Intel
Employee
1,008 Views

How did you conclude that #pragma omp target data map(to:a[0:num]) is not moving data to target device.

If you used #pragma omp target to access "a" to prove memory is not move,  then what I said holds that in #pragma omp target "a" is treated as a scalar and only the value in it which is pointing to host memory is sent to device in the #pragma omp target.  So you cannot de-reference it on the device and expect it to point to device memory which was create in the outer #pragma omp target data

0 Kudos
Ravi_N_Intel
Employee
1,008 Views

You may be right I misunderstood your question.  Is your question the value printed on the host is not 1 when you change #pragma omp target  map.....    to #pragma omp target data map .....   

If that is your question then the answer is value printed can be anything depending on what the device value of b is initialized with (usually zero).   Converting omp target to omp target data means the code inside this region is not offloaded but executed on the host.  At the end of the omp target data region the value of b is brought back from the device, remember nothing was executed on the device, so the value brought back from device could be anything,  the value which is brought back overwrites the value  of b which was assigned to 1.

0 Kudos
Reply