Friday, 24 June 2016

Parallel application using OpenMP/ MacOS

brew install clang-omp
xcode-select --install

$ clang-omp --version
clang version 3.5.0
Target: x86_64-apple-darwin15.4.0
Thread model: posix

$ xcode-select --version
xcode-select version 2343.

application

#include <omp.h>
#include <stdio.h>

#define n 20                                                                                          

omp_set_num_threads(3);                                                                              
#pragma omp parallel for private(tid) schedule(static,1)                                              

for (i=0; i<n; i++) {                                                                                
 tid = omp_get_thread_num();                                                                          
 printf("Thread %d executing iteration %d\n", tid, i);                                                
}


$ clang-omp -fopenmp parallel.c 

No comments:

Post a Comment