[llvm-dev] clang only spawns one thread
Jakub Kuderski via llvm-dev
llvm-dev at lists.llvm.org
Wed Dec 2 14:26:39 PST 2015
Hi Zhi,
take a look at this thread:
http://stackoverflow.com/questions/33357029/using-openmp-with-clang
Regards,
Jakub
On 2 December 2015 at 22:52, zhi chen via llvm-dev <llvm-dev at lists.llvm.org>
wrote:
> Hi,
>
> I am using LLVM 3.6.1 to test the following code:
>
> #include <omp.h>
> #include <stdio.h>
> #include <stdlib.h>
>
> int main() {
>
> int tid, nthreads;
> #pragma omp parallel sections private(nthreads, tid)
> {
> #pragma omp section
> {
> tid = omp_get_thread_num();
> printf("Hello, tid = %d\n ", tid);
> }
>
> #pragma omp section
> {
> tid = omp_get_thread_num();
> printf("Hello, tid = %d\n ", tid);
> }
> }
> if (tid == 0) {
> nthreads = omp_get_num_threads();
> printf("number of threads = %d \n", nthreads);
> }
>
> return 0;
> }
>
> I used the following command:
> clang -fopenmp -I/path/to/omp.h -L/path/to/libomp.so test.c -o test
>
> I only get one thread when I run test, for example it yields:
> Hello, tid = 0
> Hello, tid = 0
> number of threads = 1
>
> However, I can get different thread id if I compile the code using gcc.
> Any idea about what's wrong here?
>
> I found a similarly problem in the following link:
>
> http://stackoverflow.com/questions/31663996/clang-llvm-openmp-program-not-spawning-threads/31673394#31673394
>
> But I don't know where should I add -fopenmp=libomp. Any help will be
> appreciated. Thanks.
>
> Zhi
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151202/49180830/attachment.html>
More information about the llvm-dev
mailing list