<div dir="ltr"><div class="gmail_default"><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:17.7272720336914px">According to <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__blog.llvm.org_2015_05_openmp-2Dsupport-5F22.html&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=CnzuN65ENJ1H9py9XLiRvC_UQz6u3oG6GUNn7_wosSM&m=DZG3L_HotFJlBV70KQYfeVG2LNWyhdSqWhUuM5iWRFY&s=uaSjudxYh78HaiKygDBlyvgKvm3ysbhhmUgBl2WZ4Z8&e=" rel="nofollow" style="margin:0px;padding:0px;border:0px;text-decoration:none;color:rgb(12,101,165)">http://blog.llvm.org/2015/05/openmp-support_22.html</a>, OpenMP support in Clang is completed. However, I'm having difficulties trying a simple program.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:17.7272720336914px">I've installed Clang/LLVM as explained in <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__clang.llvm.org_get-5Fstarted.html&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=CnzuN65ENJ1H9py9XLiRvC_UQz6u3oG6GUNn7_wosSM&m=DZG3L_HotFJlBV70KQYfeVG2LNWyhdSqWhUuM5iWRFY&s=Gc8_sE_ZeQBxBwsiQHPiNeL04ECTmMvmyvA-FM_fR0k&e=" rel="nofollow" style="margin:0px;padding:0px;border:0px;text-decoration:none;color:rgb(12,101,165)">http://clang.llvm.org/get_started.html</a> and the OpenMP runtime as explained in <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__openmp.llvm.org_&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=CnzuN65ENJ1H9py9XLiRvC_UQz6u3oG6GUNn7_wosSM&m=DZG3L_HotFJlBV70KQYfeVG2LNWyhdSqWhUuM5iWRFY&s=6UtnSRSa--2dFwPH1SBQW1clEwsC-Hnc9cWqPPW-gqw&e=" rel="nofollow" style="margin:0px;padding:0px;border:0px;text-decoration:none;color:rgb(12,101,165)">http://openmp.llvm.org/</a>.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:17.7272720336914px">The test program is:</p><pre style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit">#include "omp.h"
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char** argv)
{
    #pragma omp parallel
    {
        printf("thread %d\n", omp_get_thread_num());
    }
    return 0;
}
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:17.7272720336914px">The compilation line is:</p><pre style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit">clang -lomp -I/.../openmp/runtime/exports/common/include -L/.../openmp/runtime/exports/lin_32e/lib ./test-openmp.c -o ./test-openmp
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:17.7272720336914px">Using <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(238,238,238)">which</code>, I check I'm using the correct clang binary.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:17.7272720336914px">With <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(238,238,238)">ldd</code>, I check I'm linking to the correct OpenMP library:</p><pre style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit">$ ldd ./test-openmp
linux-vdso.so.1 =>  (0x00007ffdaf6d7000)
libomp.so => /.../openmp/runtime/exports/lin_32e/lib/libomp.so (0x00007f7d47552000)
libc.so.6 => /lib64/libc.so.6 (0x00007f7d47191000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f7d46f8d000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f7d46d71000)
/lib64/ld-linux-x86-64.so.2 (0x00007f7d477fb000)
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:17.7272720336914px">But when running, it executes only one thread:</p><pre style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit">$ OMP_NUM_THREADS=4 ./test-openmp
thread 0
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:17.7272720336914px">The reason I'm linking with <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(238,238,238)">lomp</code> is because if I link with <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(238,238,238)">fopenmp</code>, the code is wrongly linked to the gcc omp library. However in that case, the result is the same:</p><pre style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit">$ clang -fopenmp -I/.../openmp/runtime/exports/common/include -L/.../openmp/runtime/exports/lin_32e/lib ./test-openmp.c -o ./test-openmp

$ ldd ./test-openmp
linux-vdso.so.1 =>  (0x00007ffdf351f000)
libgomp.so.1 => /lib64/libgomp.so.1 (0x00007fbc1c3e1000)
librt.so.1 => /lib64/librt.so.1 (0x00007fbc1c1d9000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fbc1bfbd000)
libc.so.6 => /lib64/libc.so.6 (0x00007fbc1bbfc000)
/lib64/ld-linux-x86-64.so.2 (0x00007fbc1c5f8000)

$ OMP_NUM_THREADS=4 ./test-openmp
thread 0
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:17.7272720336914px">When using gcc, it works as expected:</p><pre style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit">$ gcc -fopenmp ./test-openmp.c -o ./test-openmp

$ ldd ./test-openmp
linux-vdso.so.1 =>  (0x00007ffc444e0000)
libgomp.so.1 => /lib64/libgomp.so.1 (0x00007f7d425ce000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f7d423b2000)
libc.so.6 => /lib64/libc.so.6 (0x00007f7d41ff1000)
/lib64/ld-linux-x86-64.so.2 (0x00007f7d427e5000)

$ OMP_NUM_THREADS=4 ./test-openmp
thread 0
thread 2
thread 3
thread 1
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:17.7272720336914px">I've used in the past the implementation described in <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__clang-2Domp.github.io_&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=CnzuN65ENJ1H9py9XLiRvC_UQz6u3oG6GUNn7_wosSM&m=DZG3L_HotFJlBV70KQYfeVG2LNWyhdSqWhUuM5iWRFY&s=5Vub22V9Y68UwPJIVevyoLD1VkC46xsavAU-gEW1ROg&e=" rel="nofollow" style="margin:0px;padding:0px;border:0px;text-decoration:none;color:rgb(12,101,165)">http://clang-omp.github.io/</a> and I know that one works (a different repo is presented there for Clang and LLVM, but the OpenMP repo is the same). However that page was (apparently) updated in 2014, and the blog in<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__blog.llvm.org_2015_05_openmp-2Dsupport-5F22.html&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=CnzuN65ENJ1H9py9XLiRvC_UQz6u3oG6GUNn7_wosSM&m=DZG3L_HotFJlBV70KQYfeVG2LNWyhdSqWhUuM5iWRFY&s=uaSjudxYh78HaiKygDBlyvgKvm3ysbhhmUgBl2WZ4Z8&e=" rel="nofollow" style="margin:0px;padding:0px;border:0px;text-decoration:none;color:rgb(12,101,165)">http://blog.llvm.org/2015/05/openmp-support_22.html</a> is from May 2015, which makes you think that you can use the latest Clang/LLVM for OpenMP.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:17.7272720336914px">So my question is, am I missing something or the blog from May 2015 is actually referring to Clang/LLVM implementation from in <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__clang-2Domp.github.io_&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=CnzuN65ENJ1H9py9XLiRvC_UQz6u3oG6GUNn7_wosSM&m=DZG3L_HotFJlBV70KQYfeVG2LNWyhdSqWhUuM5iWRFY&s=5Vub22V9Y68UwPJIVevyoLD1VkC46xsavAU-gEW1ROg&e=" rel="nofollow" style="margin:0px;padding:0px;border:0px;text-decoration:none;color:rgb(12,101,165)">http://clang-omp.github.io</a> and not to the latest one?</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:17.7272720336914px">Thanks</p></div>
</div>