How can I get OpenMP to run on Mac OSX 10.11, so that I can execute scripts via terminal?
I have installed OpenMP: brew install clang-omp
install clang-omp
brew install clang-omp
make sure you xcode command line tool
xcode-select --install
I actually had one error while running a sample openmp code
/usr/local/opt/libiomp/include/libiomp/omp.h:139:21: error: expected ';' after top level declarator extern void __ KAI_KMPC_CONVENTION kmp_set_stacksize_s (size_t);
Just remove one space that is present between __ and KAI from the file
Now use the command
clang-omp -fopenmp helloopenmp.c
and run the following code
#include
#include
int main() {
#pragma omp parallel
printf("Hello from thread %d, nthreads %d\n", omp_get_thread_num(), omp_get_num_threads());
}
You should get output similar to this
Hello from thread 3, nthreads 4
Hello from thread 2, nthreads 4
Hello from thread 0, nthreads 4
Hello from thread 1, nthreads 4
Worked on OS X 10.11.3 and with brew update dated 18th Feb 2016