- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello everyone,
While I was making several changes in my code, I came across a case when using pragmas, that I managed to reduce to the following very simple testcase, contained in the file phitest.c:
#include <stdio.h> int main() { int i, a = 0; #if 0 #pragma offload target(mic) inout(a) \ #else #pragma offload target(mic) inout(a) #endif #pragma omp parallel for for (i = 0; i < 100000000; i++) { #pragma omp atomic a++; } printf("a = %d\n", a); return(0); }
I compile the code using icc 14.0.2 with:
icc -O3 -fopenmp -o phitest phitest.c
Notice the backslash at the end of the first pragma. This program compiles without a problem, but it executes on the CPU. Technically speaking, this is the correct behavior. With the backslash, the "#else" goes with the previous line, so the two offload pragmas are actually inside the "#if 0". Of course, if I delete the backslash the program behaves as expected.
However, it took me several hours to find this error. The offload pragmas in my case were very long and the backslash was not visible until I scrolled to the end of the line. Maybe a lesson for me to turn on line breaking in my editor :-) Although I still haven't found a good way to parallelize my application for the Phi, this made me scratch my head for hours trying to figure out why the code is not executed on the Phi at all.
You think some warning message would be appropriate in this case or not? What is your opinion?
Ioannis E. Venetis
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The compiler did what you asked it to do.
I think though the compile should have an option -Lint to perform a "Lint" operation to catch questionable statements.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried gcc -Wall but I do not get any warning,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I agree with Om don't get any warning with GCC as well as with ICC as it executed what's asked for (valid code!)
%gcc --version
%gcc (GCC) 4.8.1
Copyright (C) 2013 Free Software Foundation, Inc.
...
%gcc -O3 -fopenmp -o phitest phitest.c
%
I agree, it would be good if compiler can catch questionable syntax and issue a warning/remark depending on the context.
_Kittur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ioannis,
I"ve filed this issue as a feature request with the developers to see if any warning/remark can be output in such a context and will keep you updated accordingly
_Kittur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear all,
Thank you for taking the time to investigate this. I appreciate it and I hope that the development team will come up with a nice solution.
Best regards,
Ioannis
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ioannis,
Well, I heard back from the developers that for the compiler to issue a remark it needs to know the exact intent on which to issue a remark. That is, about the user's code that makes it likely to be unintentional than intentional. Additionally, adding a backslash without realizing it is a common mistake for users. That said, the issue I filed was closed as not a defect and not possible to add a remark for code that's perfectly valid. Let me know if you need any further clarifications. Appreciate your patience through this.
_Kittur

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