clang-omp / clang

clang with OpenMP 3.1 and some elements of OpenMP 4.0 support
clang-omp.github.com
Other
91 stars 15 forks source link

Does not support omp_set_num_threads? #50

Closed ghost closed 9 years ago

ghost commented 9 years ago

I have the following program:

#include <omp.h>
#include <stdio.h>
int main() {
    omp_set_num_threads(4);
#pragma omp parallel
    printf("Hello from thread %d, nthreads %d\n", omp_get_thread_num(), omp_get_num_threads());
}

And I compiled it with clang -fopenmp and I got the output

Hello from thread 0, nthreads 1

Clearly the set number of threads function is not called. Does anyone have ideas about why this might happen?

clang version:

Ubuntu clang version 3.5.0-4ubuntu2 (tags/RELEASE_350/final) (based on LLVM 3.5.0)
Target: x86_64-pc-linux-gnu
Thread model: posix

EDIT: I also tried setting the environment variable OMP_NUM_THREADS to 4.

alexey-bataev commented 9 years ago

Ooops, I prepared an answer, but it seems, forget to send it. :( Here it is. Hi, It seems you're using an official version of clang/LLVM, which does not have support for OpenMP yet. To use OpenMP you have to use our version of clang/LLVM.

Best regards,

Alexey Bataev

Software Engineer Intel Compiler Team Intel Corp.

17.11.2014 23:04, Bob Fang пишет:

I have the following program:

|#include

include

int main() { omp_set_num_threads(4);

pragma omp parallel

 printf("Hello from thread %d, nthreads %d\n", omp_get_thread_num(), omp_get_num_threads());

} |

And I compiled it with |clang -fopenmp| and I got the output

Hello from thread 0, nthreads 1

Clearly the set number of threads function is not called. Does anyone have ideas about why this might happen?

clang version:

Ubuntu clang version 3.5.0-4ubuntu2 (tags/RELEASE_350/final) (based on LLVM 3.5.0) Target: x86_64-pc-linux-gnu Thread model: posix

EDIT: I also tried setting the environment variable |OMP_NUM_THREADS| to 4.

— Reply to this email directly or view it on GitHub https://github.com/clang-omp/clang/issues/50.