Using OpenMP with clang

Some additional comments: 1) You need to use -fopenmp=libomp to enable OpenMP in clang. -fopenmp just links libgomp but ignores all the pragmas. Weird, I know — and will be changed in the trunk soon. 2) 3.7 is the first version that supports OpenMP. 3.6 doesn’t. 3) clang is only able to work with libomp. … Read more

Parallel cumulative (prefix) sums in OpenMP: communicating values between threads

You can extend your strategy to an arbitrary number of sub-regions, and reduce them recursively, using tasks: #include<vector> #include<iostream> using namespace std; const int n = 10000; const int baseLength = 100; int f(int ii) { return ii; } int recursiveSumBody(int * begin, int * end){ size_t length = end – begin; size_t mid = … Read more

OpenMP and CPU affinity

Yes, named calls will work to set thread affinity. The only problem is to fix thread number and to set right affinity in right thread (you can try using static scheduling of for loop for known number of threads). As I know, almost every openmp allows to set affinity via environment. The name of environment … Read more

Pthreads vs. OpenMP

Pthreads and OpenMP represent two totally different multiprocessing paradigms. Pthreads is a very low-level API for working with threads. Thus, you have extremely fine-grained control over thread management (create/join/etc), mutexes, and so on. It’s fairly bare-bones. On the other hand, OpenMP is much higher level, is more portable and doesn’t limit you to using C. … Read more

Is OpenMP available in High Sierra LLVM?

Standard Apple’s clang supports OpenMP. They just disabled the driver option. But you can use the frontend option instead this way: clang -Xclang -fopenmp <you_program> -I <path to omp.h> -L <path to libomp.dylib> -lomp Also, you need to set DYLD_LIBRARY_PATH environmental variable: export DYLD_LIBRARY_PATH=<path to libomp.dylib> How to get/build libomp. $ cd $ svn co … Read more