parallel-programming/README.md

167 lines
2.7 KiB
Markdown
Raw Permalink Normal View History

2023-12-25 08:33:58 +01:00
# parallel-programming
A collection of tasks for studying parallel programming
#### 1. Setup a proxy (on university computers only):
##### On Ubuntu:
```sh
echo 'http_proxy="http://212.192.128.4:8080/"' | sudo tee -a /etc/profile
echo 'https_proxy="http://212.192.128.4:8080/"' | sudo tee -a /etc/profile
```
Reboot a virtual machine to apply changes:
```sh
systemctl reboot
```
##### On Fedora:
```sh
echo 'proxy=212.192.128.4:8080' | sudo tee -a /etc/dnf/dnf.conf
echo 'http_proxy="http://212.192.128.4:8080/"' | sudo tee -a /etc/profile
echo 'http_proxy="http://212.192.128.4:8080/"' | sudo tee -a /etc/profile
```
Reboot a virtual machine to apply changes:
```sh
systemctl reboot
```
#### 2. Install a necessary dependencies:
##### On Ubuntu:
```sh
sudo apt install gcc g++ libomp-dev git
```
##### On Fedora:
```sh
sudo dnf install gcc gcc-c++ libgomp git
```
#### 3. Clone the repository:
```sh
git clone https://git.disroot.org/hassiy/parallel-programming.git
```
#### 4. Navigate to the project directory:
```
cd parallel-programming
```
#### 5. Unzip the 500f.zip file:
```sh
unzip 500f.zip
```
#### 6. Use "cd" and "ls" commands to navigate to the necessary variant:
In case to navigate to the 9th variant use command below:
```sh
cd ~/parallel-programming/2/fork/linux
```
#### 7. Inspect README.md file before do something
```sh
less README.md
```
#### 8. (Recommended) Make a backup of a code:
```sh
cp main.cpp main.bk.cpp
```
where "main.cpp" may be different filename (i.e. fork2.cpp)
use "ls" command to check a content of the current directory
#### 9. Edit the code:
To get a count of an available (logical) threads use command below:
```sh
nproc
```
To get username enter command below:
```sh
whoami
```
or
```sh
echo $USER
```
Edit the code using one of "nano", "vi", "vim" text editor:
i.e. using nano:
```sh
nano main.cpp
```
or another .cpp filename. Use "ls" command to verify it
Inspect the comments
###### !Don't forget to change file paths to the proper values!
Save changes and exit
#### 10. Compile a program:
```sh
g++ main.cpp
```
file "a.out" will appear in the current directory
"a.out" is a default binary name in gcc or g++ compilers
Use -o (or --output) option to change an executable (binary) filename:
```sh
g++ -o binary_name.exe main.cpp
```
If a program uses thread method use command bellow:
```sh
g++ -lpthread main.cpp
```
If a program uses openMP method use command bellow:
```sh
2023-12-25 10:32:51 +01:00
g++ -fopenmp main.cpp
2023-12-25 08:33:58 +01:00
```
#### 11. Execute the binary:
```sh
./a.out
```
or another binary name that was entered after -o option
#### 12. If result wasn't in stdout you need to read "result" file(s):
```sh
cat ~/parallel-programming/500f/result*
```