LoginSignup
2
2

More than 5 years have passed since last update.

clang-ompのセットアップ

Posted at

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

参考:http://clang-omp.github.io

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2