Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

OpenMP 4.0 target data directive

Dan_M_4
Beginner
184 Views

Hello,

I am using the icc v14.0.0 compiler and I would like to use the #pragma omp target data directive as described here:

https://software.intel.com/en-us/node/514568

I have made a small example program that, to my eye, looks very similar to the example given in the above link. However, it produces a compile error.

#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;
}

The compile error is the following:

$ icc -openmp -o test test.c
test.c(13): error: pointer variable "b" in this offload region must be specified in an in/out/inout/nocopy clause
  #pragma omp target
  ^

test.c(13): error: pointer variable "a" in this offload region must be specified in an in/out/inout/nocopy clause
  #pragma omp target
  ^

compilation aborted for test.c (code 2)

If I remove the 'target data' pragma and move the two map() clauses to the 'target' pragma, it compiles and runs on the target device as expected (according to the OFFLOAD_REPORT output).

What is the correct syntax for using the 'target data' pragma in OpenMP 4.0? How should I modify the above code so that it compiles with the 'target data' pragma?

Thank you for your help!

-Dan

0 Kudos
4 Replies
TimP
Black Belt
184 Views

That compiler didn't support target update and target map in the same application.  This was fixed in at least one later compiler.  Maybe there was a similar restriction on the syntax you're trying.  It's important to use a current compiler when trying OpenMP 4.

pbkenned1
Employee
184 Views

Specifically, you need at least update #2 (14.0.2.14) to compile and run your example.

$ icc -V
Intel(R) C Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.2.144 Build 20140120
Copyright (C) 1985-2014 Intel Corporation.  All rights reserved.

$ icc U505063.c -openmp && ./a.out
1
$

Patrick

Jianbin_F_
Beginner
184 Views

I run the same code with the newly downloaded Intel Parallel Studio 2017 on Intel Xeon Phi 31SP. 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? 

Jianbin

SergeyKostrov
Valued Contributor II
184 Views
>>offload error: process on the device 0 was terminated by signal 11 (SIGSEGV). >> >>Could anybody shede some light on it? ... #define SIGSEGV 11 /* segment violation */ ... So far this is it and you need to provide more technical details.
Reply