Changes

Jump to: navigation, search

GPU621/Group 5

1,614 bytes added, 22:37, 12 April 2023
m
File Directory System:
== Investigative Report: Integrating OpenMP, TBB, and MPI into VSCode on MacOS v11.0+ ==
== Team ==
# [mailto:imuhammad-yusoof@myseneca.ca?subject=GPU621_Project Ibrahim Muhammad Yusoof]
# [mailto:hllo@myseneca.ca?subject=GPU621_Project Ho Wa Lo]
== Introduction ==
Since 2020, there has been a lot of updates to the Mac OS ecosystem, and its command line interface. Which has caused for the dependancy documentation for integrating with Mac OS outdated. So this report is our comprehensive findings for interfacing with the OpenMP, TBB, and MPI libraries on Visual Studio Code to leverage Parallel Computing Concepts that are outlined in this course. As many Software Developers working on Mac already now, Visual Studio for Mac only supports some languages, one of which '''isn’t C/C++'''. So we’ll be using the common and popular text editor, Visual Studio Code. Visual Studio Code will allow us to use the command line interface for our compiler to integrate and option the dependancies that we want to use. You should already have downloaded and installed:
* Visual Studio Code,
:* If not, you can find the Download and Install for it here: [https://code.visualstudio.com Visual Studio Code - Code Editing. Redefined]
== Integrating ==
Before we go into specifically each library, let’s talk about how VScode handles compilers. Within VSCode, when we create a .CPP file, we can either run the code in our terminal, or we can create a '''task''' that compiles our code before '''launching''' the executable with our runtime arguments. We’ll use this **task and launch** method to setup our environment for C++.
Start by creating a regular C++ workspace:
=== tasks.json ===
From here, we want to tell VScode what **tasks** to run when we press the Run and Debug button. This will be similar to how we use terminal to '''build''' our code.
This task tells VScode, when we use this task, run [this].command with [this].args. VScode will inject this into our terminal to automatically compile our code. This will help our VScode Debugger and help our launch task get ready for running our code.
g++ -fdiagnostics-color=always -g helloworld.cpp -o ./helloworld
=== launch.json ===
Our launch file will facilitate the execution of our code, in the '''task.json''' we compiled and produced an output, here we will run our code with the correct information.
}
]
}
'''prelaunchTask''': The prelaunch task is set to a string that matches the label section in our tasks. It identifies which task needs to run in order for the launch to be successful. This is where you can create multiple launch tasks that setup your files differently. We’ll be adding a '''task''' and a '''launch''' for all the library we’ll be setting up.
We recommend you create and test these configurations yourself, after you’ve gotten it working, you can use the same /.vscode directory in your other projects.
== OpenMP ==
Assuming that you’ve already installed the *Intel oneAPI Base & HPC Toolkits*, let’s start with integrating OpenMP into our workspace. We’ll need to do a couple of things:
# Add a Launch
# Add the library and bin directory location for intellisense
=== tasks.json ===
We’ll add a task to compile our source code using OpenMP, this task will only build the active file using OpenMP.
brew update
 
If you have not install homebrew in your enviroment please use the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
<ol >
]
}
=== launch.json ===
{
"version": "0.2.0",
],
"version": 4
}
== Testing ==
Using these test files will help you identify if there you've successfully set up your dependancies
=== OpenMP ===
{
// OpenMP - Runtime Routines
// omp_hi.cpp // for OpenMP library functions
}
}
}
=== TBB ===
{
// TBB - Hello World
// tbb.cpp
<< TBB_INTERFACE_VERSION << ")" << std::endl; // Print a message showing the version of TBB being used
}
}
=== MPI ===
{
// MPI Program - Hello World
// mpi_hello.c
return 0;
}
}
== Final Note ==
Congratulations! You’ve successfully started your journey working in a parallel environment on Mac. While the fundamentals are here, it’s not the entire picture, you may run into problems that were not covered here. For example to change the optimization level, you can use these flags:
# -O0 (for no optimization)# -O1 (for slight optimization)# -O2 (for lots of optimization)
Google is your friend, but when you’re lost here are some great resources:
=== General G++ ===
[https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/ https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/]
 
=== OpenMP: ===
=== MPI: ===
[https://www.open-mpi.org/doc/current/man1/mpic++.1.php https://www.open-mpi.org/doc/current/man1/mpic++.1.php]
[https://www.open-mpi.org/doc/current/man1/mpirun.1.php https://www.open-mpi.org/doc/current/man1/mpirun.1.php]
=== File Directory System: ===
{
--> .vscode
| \-> launch.json
| \-> task.json | \-> c_cpp_properties.json
--> ws1
--> ws2
=== Final tasks.json: ===
{ {
"tasks": [
{
}
]
} }
=== Final launch.json ===
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ using OpenMP: g++ build and debug active file",
"type": "cppdbg", // Create for a CPP Debugger
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}", // The program to be debugged.
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true, // Run task in External Console
"MIMode": "lldb",
"preLaunchTask": "C/C++ using OpenMP: g++ build active file" // Make sure to set this to our task label
},
{
"name": "C/C++ using TBB: g++ build and debug active file",
"type": "cppdbg", // Create for a CPP Debugger
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}", // The program to be debugged.
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true, // Run task in External Console
"MIMode": "lldb",
"preLaunchTask": "C/C++ using TBB: g++ build active file" // Make sure to set this to our task label
},
{
"configurations": [ { "name": "Custom C/C++using MPI: gmpic++ build and debug run active file", "type": "cppdbg", "request": "launch", "program": "${fileDirname}/${fileBasenameNoExtension} ", "args": [], "stopAtEntry": false, "cwd": "${fileDirname}", "environment": [], "externalConsole": false, "MIMode": "lldb", "preLaunchTask": "C/C++: g++ build active file" }, { "Task name": "Build and Debug WS2",we'll use to identify the task "type": "cppdbg", "request": "launch", "program": "/Usersusr/ibrahimlocal/Desktopbin/Winter 2023/GPU621/ws2/ws2", "args": ["100000000"], "stopAtEntry": false, "cwd": "${fileDirname}", "environment": [], mpirun"externalConsole": false, "MIMode": "lldb", "preLaunchTask": "C/C++: g++ build WS2 file" }, { "name": "Build and Debug WS5", "type": "cppdbg", "request": "launch", "program": "/Users/ibrahim/Desktop/Winter 2023/GPU621/ws5/w5", "args": ["100000000"], "stopAtEntry": false, "cwd": "${fileDirname}", "environment": [], "externalConsole": false, "MIMode": "lldb", "preLaunchTask": "C/C++: g++ build WS5 file" }, { "name": "MPI Debug", "type": "cppdbg", "request": "launch", "program": "/usr/local/bin/files uses mpirun", "args": [ "-np",// Flag identifies the that we want to configure the number of processes we want to run "4",// Number of processes "${fileDirname}/${fileBasenameNoExtension}",// Path to active file "1000000" ], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true,// Use an external console "MIMode": "lldb", "setupCommandspreLaunchTask": [], "preLaunchTask"C/C++ using MPI: "mpic++ build mpi" } ], "version": "2.0.0active file"
}
]
}
== References ==
[https://code.visualstudio.com/docs/cpp/launch-json-reference https://code.visualstudio.com/docs/cpp/launch-json-reference]
[https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html]
[https://medium.com/@li.nguyen_15905/setting-up-vscode-for-mpi-programming-b6665da6b4ad https://medium.com/@li.nguyen_15905/setting-up-vscode-for-mpi-programming-b6665da6b4ad]
[https://www.open-mpi.org/doc/current/man1/mpic++.1.php https://www.open-mpi.org/doc/current/man1/mpic++.1.php]
[https://www.open-mpi.org/doc/current/man1/mpirun.1.php https://www.open-mpi.org/doc/current/man1/mpirun.1.php]
[https://mac.r-project.org/openmp/ https://mac.r-project.org/openmp/]
 
[https://brew.sh/ https://brew.sh/]

Navigation menu