OpenMP on macOS 11+

A Hands-On Guide for Installing and Running Parallel Computations

Tapashree
1 min readAug 12, 2023

Prerequisites

  1. Install Command Line Tools for XCode. Go to the default terminal and enter the following command.
xcode-select --install

2. Install HomeBrew.

mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew

eval "$(homebrew/bin/brew shellenv)"
brew update --force --quiet
chmod -R go-w "$(brew --prefix)/share/zsh"

For more information, visit:

Installing OpenMP package

Open the terminal again and enter the following command:

brew install libomp

Running and Verifying them OMP environment is working properly, open your code editor and save the following C program:

// verifying that OMP environment actually works

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

int main()
{
#pragma omp parallel
{
int ID = 0;
printf("Hello(%d)", ID);
printf("World(%d)\n", ID);
}}

To compile and run the program, open the terminal in the same directory as your C file and enter the following:

gcc-13 -fopenmp <file-name>.c

And its done!

Sign up to discover human stories that deepen your understanding of the world.

Tapashree
Tapashree

No responses yet

Write a response