Open llvmbot opened 6 years ago
The only possible fix would be to add a compiler flags such as -fpolly-parallel
to clang that would add -mllvm -polly -mllvm -polly-parallel
as well as an OpenMP runtime.
clang, the driver component of the frontend, does not know that Polly is generating calls to an external library. Hence, some command line argument has to be passed to tell the driver to pass the OpenMP runtime library to the linker. -fopenmp
, -lgomp
or -fomp
should do.
Extended Description
When automatic parallelization using polly is applied, a linker outputs an error: undefined symbol: GOMP_*.
-------- test.c --------
include
include
define N 300
define M 4
double a[N][M]; double b[N][M]; double c[N][M];
void foo(int m) { int i,j; for (j=0; j<N; ++j) { for (i=0; i<m; ++i) { a[j][i] += b[j][i]*c[j][i]; } } }
double suma(void) { int i,j; double s; s = 0.0; for (j=0; j<N; ++j) { for (i=0; i<M; ++i) { s += a[j][i]; } } return s; }
define ANS (double)300.0000
define GOSA (double)0.0
int main(void) { int i,j; double s; for (j=0; j<N; ++j) { for (i=0; i<M; ++i) { a[j][i] = 0.0; b[j][i] = 0.5; c[j][i] = 0.5; } } foo(M); s = suma(); if (fabs(s - ANS) <= GOSA) { printf("ok\n"); } else { printf("ng: %lf != %lf\n", s, ANS); } }
$ clang --version clang version 8.0.0 (trunk 339303) Target: x86_64-unknown-linux-gnu
$ clang -O3 -mllvm -polly -mllvm -polly-parallel test.c ld: error: undefined symbol: GOMP_parallel_loop_runtime_start
ld: error: undefined symbol: GOMP_parallel_end
ld: error: undefined symbol: GOMP_loop_runtime_next
ld: error: undefined symbol: GOMP_loop_runtime_next
ld: error: undefined symbol: GOMP_loop_end_nowait
But, If I added -fopenmp option to the above options, the linker didn't output the error and compilation succeeded. So, when -polly-parallel option is specified, should I need to specify -fopenmp option? Or, should clang pass "-lomp" to the linker implicitly?