- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page