Community
cancel
Showing results for 
Search instead for 
Did you mean: 
mmoorkamp
Beginner
61 Views

Different results with thread checker with icpc and g++

Hi,

I am trying to find some openmp parallelization problems in my application but get inconsistent results with even a simple test.
This is the code I am using

#include
#include
#include
#include

int main(int argc, char** argv) {
const size_t nelements = 100;
double Test[nelements];
const double start = 2.1;
const double factor = 0.8;

#pragma omp parallel for default(shared)
for (int i = 0; i < nelements; ++i) {
double result = start + factor * i;
Test = result;
}
for (int i = 0; i < nelements; ++i) {
if (std::fabs(Test - (start + factor * i)) > 1e-10)
std::cout << Test << " " << start + factor * i << std::endl;
}
}

Now when I compile this with this command line

icpc -o intel -openmp -tcheck -g -O0 min.cpp

the output of tcheck_cl ./intel is

Intel Thread Checker 3.1 command line instrumentation driver (27583)
Copyright (c) 2007 Intel Corporation. All rights reserved.
Building project
Instrumenting
12% intel ( All Functions ):..
37% libc-2.9.so ( Minimal ):....
50% libdl-2.9.so ( Minimal ):..
62% libgcc_s.so.1 ( Minimal ):..
75% libm-2.9.so ( Minimal ):..
87% libpthread-2.9.so ( Minimal ):..
100% libstdc++.so.6.0.10 ( Minimal ):..

Running: /home/mmoorkamp/playground/thread/intel


Application finished

_______________________________________________________________________________
|ID|Short Desc|Severit|Cou|Context|Description |1st Acce|2nd Acce|
| |ription |y Name |nt |[Best] | |ss[Best]|ss[Best]|
_______________________________________________________________________________
|1 |Thread ter|Informa|1 |Whole |Thread termination at |"min.cpp|"min.cpp|
| |mination |tion | |Program|"min.cpp":6 - includes |":6 |":6 |
| | | | |1 |stack allocation of 8 MB | | |
| | | | | |and use of 3.062 KB | | |
_______________________________________________________________________________


while g++ -fopenmp -o gcc -g -O0 min.cpp produces:

Intel Thread Checker 3.1 command line instrumentation driver (27583)
Copyright (c) 2007 Intel Corporation. All rights reserved.
Building project
Instrumenting
11% gcc ( All Functions ):..
33% libc-2.9.so ( Minimal ):....
44% libgcc_s.so.1 ( Minimal ):..
55% libgomp.so.1.0.0 ( All Functions ):...............................
.
66% libm-2.9.so ( Minimal ):..
77% libpthread-2.9.so ( Minimal ):..
88% librt-2.9.so ( API Imports ):..
100% libstdc++.so.6.0.10 ( Minimal ):.....
.

Running: /home/mmoorkamp/playground/thread/gcc


Application finished

_______________________________________________________________________________
|ID|Short Des|Severi|C|Contex|Description |1st Ac|2nd Ac|
| |cription |ty |o|t[Best| |cess[B|cess[B|
| | |Name |u|] | |est] |est] |
| | | |n| | | | |
| | | |t| | | | |
_______________________________________________________________________________
|1 |Write -> |Error |7|"min.c|Memory read at "min.cpp":18 |"min.c|"min.c|
| |Read | |5|pp":6 |conflicts with a prior memory |pp":15|pp":18|
| |data-race| | | |write at "min.cpp":15 (flow | | |
| | | | | |dependence) | | |
_______________________________________________________________________________
|2 |Thread te|Inform|1|WholeP|Thread termination at "min.cpp":6-|"min.c|"min.c|
| |rmination|ation | |rogram|includes stack allocation of 8 MB |pp":6 |pp":6 |
| | | | |1 |and use of 4.406 KB | | |
_______________________________________________________________________________
|3 |Thread te|Inform|1|WholeP|Thread termination at [gcc, |[gcc,0|[gcc,0|
| |rmination|ation | |rogram|0x48a9] - includes stack |x48a9]|x48a9]|
| | | | |2 |allocation of 8.004 MB and use of | | |
| | | | | |5.375 KB | | |
_______________________________________________________________________________
|4 |Thread te|Inform|1|WholeP|Thread termination at [gcc, |[gcc,0|[gcc,0|
| |rmination|ation | |rogram|0x48a9] - includes stack |x48a9]|x48a9]|
| | | | |3 |allocation of 8.004 MB and use of | | |
| | | | | |5.375 KB | | |
_______________________________________________________________________________
|5 |Thread te|Inform|1|WholeP|Thread termination at [gcc, |[gcc,0|[gcc,0|
| |rmination|ation | |rogram|0x48a9] - includes stack |x48a9]|x48a9]|
| | | | |4 |allocation of 8.004 MB and use of | | |
| | | | | |5.375 KB | | |
_______________________________________________________________________________

this is with gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) and Intel C++ Intel 64 Compiler Professional for applications running on Intel 64, Version 11.0 Build 20090609 Package ID: l_cproc_p_11.0.084 on Ubuntu 09/04

These are my questions:

1. Is this code supposed to work? I read some comments about the atomicity of writes to a certain memory location in an array depending on the
size of its elements without further clarification.

2. Why do I get different results? Is it a bug with g++ or with the thread checker?

Thanks for any advice

Max
0 Kudos
1 Reply
TimP
Black Belt
61 Views

It looks like you are using the Intel debug OpenMP library with icpc and the release libgomp with g++, superimposing dynamic instrumentation in both cases. If you are looking for curiosity, what happens if you run the g++ build with the libiomp debug library?
I'm not sure I can count source lines accurately from you posting; is the dynamic instrumentation of your g++ build getting confused about where the parallel region ends?
Reply