Closed mihailpopov closed 9 years ago
Hi, again thanks for the report. The bug is fixed.
Best regards,
Software Engineer Intel Compiler Team Intel Corp.
27.11.2014 18:54, Mihail Popov пишет:
With the following code,
/test.h/
include
extern int test;
pragma omp threadprivate(test)
extern void fct();
/main.c/
include
include
include "test.h"
int test;
int main() { fct(); printf("\n");
pragma omp parallel
{ test =omp_get_thread_num(); #pragma omp barrier printf("test =%d, by thread%d\n",test,omp_get_thread_num()); }
}
/test.c/
include
include
include "test.h"
void fct() {
pragma omp parallel
{ test =omp_get_thread_num(); #pragma omp barrier printf("test =%d, by thread%d\n",test,omp_get_thread_num()); }
}
gcc and icc, make t private in both main.c and fct.c translation units. But clang-omp makes t private in fct but shared in main.
I think this is a bug because OpenMP 4.0 specification explains in chapter 2.14.2, threadprivate Directive, page 153, that if a variable is specified in a threadprivate directive in one translation unit, it must be specified in a threadprivate directive in every other translation unit in which it is declared.
It appears that defining the variable after using the threadprivate removes the private state. This can be observed in the following smaller example:
include
include
extern int test;
pragma omp threadprivate(test)
int test;
int main() {
pragma omp parallel
{ test =omp_get_thread_num(); #pragma omp barrier printf("test =%d, by thread%d\n",test,omp_get_thread_num()); }
}
in gcc 4.7.2 and icc 12.1.0 each printf shows a different thread num (private), whereas in clang-omp a single thread num is printed (shared).
Thanks,
— Reply to this email directly or view it on GitHub https://github.com/clang-omp/clang/issues/54.
With the following code,
test.h
main.c
test.c
gcc and icc, make t private in both main.c and fct.c translation units. But clang-omp makes t private in fct but shared in main.
I think this is a bug because OpenMP 4.0 specification explains in chapter 2.14.2, threadprivate Directive, page 153, that if a variable is specified in a threadprivate directive in one translation unit, it must be specified in a threadprivate directive in every other translation unit in which it is declared.
It appears that defining the variable after using the threadprivate removes the private state. This can be observed in the following smaller example:
in gcc 4.7.2 and icc 12.1.0 each printf shows a different thread num (private), whereas in clang-omp a single thread num is printed (shared).
Thanks,