Created
February 22, 2018 08:08
-
-
Save jeongho/32b9f2824ff116c9904ecc5cdc858c39 to your computer and use it in GitHub Desktop.
Compile OpenMP programs with gcc compiler on OS X Yosemite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| https://en.wikipedia.org/wiki/OpenMP | |
| https://stackoverflow.com/questions/29057437/compile-openmp-programs-with-gcc-compiler-on-os-x-yosemite | |
| https://stackoverflow.com/questions/30049486/what-does-gcc-without-multilib-mean | |
| # reinstall gcc with --without-multilib | |
| brew update | |
| time brew reinstall gcc --without-multilib | |
| real 41m52.433s | |
| user 121m53.094s | |
| sys 32m39.945s | |
| # check brew install | |
| ls /usr/local/bin/gcc* | |
| /usr/local/bin/gcc-7 /usr/local/bin/gcc-nm-7 | |
| /usr/local/bin/gcc-ar-7 /usr/local/bin/gcc-ranlib-7 | |
| # create an alias at ~/.bash_profile | |
| alias gcc='gcc-7' | |
| source ~/.bash_profile | |
| cat<<EOF > hello.c | |
| #include <stdio.h> | |
| int main(void) | |
| { | |
| #pragma omp parallel | |
| printf("Hello, world.\n"); | |
| return 0; | |
| } | |
| EOF | |
| # compile with flag -fopenmp | |
| gcc -fopenmp hello.c -o hello | |
| # execute hello | |
| ./hello | |
| Hello, world. | |
| Hello, world. | |
| Hello, world. | |
| Hello, world. | |
| Hello, world. | |
| Hello, world. | |
| Hello, world. | |
| Hello, world. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment