prasad reddy
2 min readMay 23, 2023

--

How to set MPI(Message Passing Interface) extension in Visual Studio Code in MAC

Step1: Add C/C++ extension

Open Visual Studio Code editor. Go to the extensions view by clicking on the extension’s (squares) icon. Search for C/C++ extension by Microsoft and install it.

Step2: Installing open-mpi

Open your mac terminal and use command “brew install open-mpi” to install open-mpi.

Note the bin and lib paths of open-mpi that is installed.

Openmpi will be installed in /usr/local/Cellar/ or /opt/homebrew/Cellar

So, the bin and lib paths will be

bin path => /usr/local/Cellar/open-mpi/version/bin/mpicc

lib path => /usr/local/Cellar/open-mpi/version/lib

(or)

bin path => /opt/homebrew/Cellar/open-mpi/version/bin/mpicc

lib path => /opt/homebrew/Cellar/open-mpi/version/lib

As you can see in the following mac terminal the path of open-mpi.

Step3: Configure MPI path in Visual Studio Code

Open your project folder or Create a new project folder.

Create a .vscode folder if it is not already present. Inside .vscode folder create a json file “c_cpp_properties.json”.

Add the following script in c_cpp_properties.json file

{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"macFrameworkPath": [
"/opt/homebrew/Cellar/open-mpi/version/lib"
],
"compilerPath": "/opt/homebrew/Cellar/open-mpi/version/bin/mpicc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}

In the above code snippet replace the macFrameWorkPath with your open-mpi lib path and compiler Path with your open-mpi /bin/mpicc path. Refer to Step2 for this path.

Restart your visual studio.

Once, all these steps are done MPI extension support will be enabled.

--

--