Homebrew使います。
brew install clang-omp
.zshrc等に、
export LIBRARY_PATH=/usr/local/lib:$LIBRARY_PATH
export C_INCLUDE_PATH=/usr/include:/usr/local/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/usr/include:/usr/local/include:$CPLUS_INCLUDE_PATH
試す。
hello.c
#include <libiomp/omp.h>
#include <stdio.h>
int main() {
#pragma omp parallel
printf("Hello from thread %d, nthreads %d\n", omp_get_thread_num(), omp_get_num_threads());
return 0;
}
$ clang-omp -fopenmp hello.c -o hello && ./hello
Hello from thread 0, nthreads 4
Hello from thread 1, nthreads 4
Hello from thread 3, nthreads 4
Hello from thread 2, nthreads 4