This repository contains two different applications, one is a word generator and the other is a word counter. The word generator was developed in C++ using the MPI library. The word counter was developed on Go with the MapReduce algorithm. You can access the installations and application details of the development environments below.
Generator
- Go -> ^1.18.3
Counter
- C++ -> ^11
- OpenMPI -> ^4.0.3
Make
- make -> ^4.2.1
Firstly you have to check and upgrade the packages.
sudo apt-get update && sudo apt-get upgrade
In 20.04 version C++ comes with installation by default. You can check the c++ belowed command.
g++ --version
If you are getting an error you can install the C++ with belowed command.
sudo apt-get install build-essential
Then you have to install MPI library.
sudo apt-get install mpich openmpi-bin
If the installation was finished with success then you can check the MPI version.
mpic++ --version
First change directory to /tmp
then you can install the version 1.18.* to your machine.
cd /tmp && wget https://go.dev/dl/go1.18.3.linux-amd64.tar.gz
When the installation was success, you have to remove if you have any Go folders in your machine and you can copy the new version to /usr/local
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.18.3.linux-amd64.tar.gz
If the copy process was finished then you have to add the Go path to $PATH
env. A few shells rc
file locations given below.
-
The file path for BASH: $HOME/.bashrc
-
The file path for ZSH: $HOME/.zshrc
export PATH=$PATH:/usr/local/go/bin
Now you can use Go and check the version with the belowed command.
go version
In 20.04 version Make comes by default installation. If this already installed you can check this with belowed commdan.
make --version
If you are gettin an error you can install Make with the command.
sudo apt-get install make
The Makefile presents to you a useful CLI command set.
Available variables:
- DATASET_SIZE -> min= 1, max=10M, default=50K
- MAX_STR_LEN -> min=2, max=100, default=10
- MIN_STR_LEN -> min=1, max=100, default=2
- GENERATED_FILE_PATH -> Not empty, it has to be existed path
WORLD_SIZE
That variable presents the process number. Both application uses it.
Constraints: 1 <= X <= 100, default=1
- This variable can't be lower from DATASET_SIZE.
DATASET_SIZE
This variable holds the word list's size that will genarate. Only generator application uses this.
Constraints: 1 <= X <= 1000000, default=50000
- This variable can't be bigger than WORLD_SIZE.
MAX_STR_LEN
This variable is presents maximum sequence length that will generate. Only generator applicaiton uses this.
Constraints: 2 <= X <= 100, default=10
- This variable can't be lower than MIN_STR_LEN.
MIN_STR_LEN
This variable is presents minimum sequence length that will generate. Only generator applicaiton uses this.
Constraints: 1 <= X <= 100, default=2
- This variable can't be lower than MAX_STR_LEN.
GENERATED_FILE_PATH
This variable specifies the file path in which to count words.This is an optional variable. Default value is a last generated file path that generated by Generator. Only Counter application uses this.
Constraints: X > 0, default=last generated file
For compiling and running both application with default variables
make
For compiling and running both application with special values.
make MAX_STR_LEN=15 MIN_STR_LEN=5 WORLD_SIZE=10 DATASET_SIZE=20
For running both application with special values (apps must be compiled before)
make runner MAX_STR_LEN=15 MIN_STR_LEN=5 WORLD_SIZE=10 DATASET_SIZE=20
For compiling the apps
make builder
For compiling just generator application
make build_generator
For compiling just Counter application
make build_counter
For running just Generator application with special values (app must be compiled before)
make run_generator MAX_STR_LEN=15 MIN_STR_LEN=5 WORLD_SIZE=10 DATASET_SIZE=20
For compiling and running just Generator application with special values
make BR_generator MAX_STR_LEN=15 MIN_STR_LEN=5 WORLD_SIZE=10 DATASET_SIZE=20
For running just Counter application with special values (app must be compiled before)
make run_counter WORLD_SIZE=10
For running just Counter applications with special file path (app must be compiled before)
make run_counter WORLD_SIZE=5 GENERATED_FILE_PATH=$HOME/github/MPI-words/generator/results/2022_25_05-17_42_11.txt
For compiling and running just Counter application with special values
make BR_counter WORLD_SIZE=10
Machine information on which measurements are made:
- OS: Ubuntu 20.04.4 LTS x86_64
- Kernel: 5.13.0-44-generic
- Shell: zsh 5.8
- Terminal: gnome-terminal
- CPU: 11th Gen Intel i5-11400H
- Memory: 16GB DDR4 3200 MHz
In the belowed graphic, you can examine the time change of a generator that produces 1000000 RANDOM words of length 100, depending on the number of processes varying between 1-100.
- Last of all, after working in parallel with 17 processes, it is seen that increasing the parallelism is meaningless at the level of these parameters.
In the graphic below, you can examine the time change of a counter that performs word counting from file contains 1000000 words (each word has 100 character), depending on the number of processes varying in the range of 1-100.
- According to the Generator graph, there is no regular increase.
- With these parameters, it seems that further parallelization is meaningless after running it in parallel with 7 processes this time.
NOTE: The measurements vary according to the differences of C++ and Go languages, the parameters we give to the executable files, the state of my machine at that moment where the measurements were made.
Bu depo birisi kelime üretici diğeri kelime sayıcı olmak üzere iki farklı uygulama içerir. Kelime üretici C++ üzerinde MPI kütüphanesi kullanılarak geliştirilmiştir. Kelime sayıcı ise Go üzerinde MapReduce algoritması ile geliştirilmiştir. Geliştirme ortamlarının kurulumlarına ve uygulama detaylarına aşağıdan erişebilirsiniz.
Generator
- Go -> ^1.18.3
Counter
- C++ -> ^11
- OpenMPI -> ^4.0.3
Make
- make -> ^4.2.1
Öncelikle güncellemelerinizi kontrol edin ve gerekli güncellemeleri gerçekleştirin.
sudo apt-get update && sudo apt-get upgrade
C++ 20.04 üzerinde mevcut gelmektedir. Aşağıdaki komut yardımıyla kontrol edebilirsiniz.
g++ --version
Eğer hata alıyorsanız aşağıdaki komut yardımıyla kurulum gerçekleştirebilir ve tekrar kontrol edebilirsiniz.
sudo apt-get install build-essential
Aşağıdaki komut yardımıyla MPI kütüphanesini bilgisayarınıza kurabilirsiniz.
sudo apt-get install mpich openmpi-bin
Kurulum başarıyla tamamlandıktan sonra aşağıdaki komut ile test edebilirsiniz.
mpic++ --version
Öncelikle /tmp
dizinine geçin ve daha sonrasında 1.18.* versiyonunu makinenize indirin.
cd /tmp && wget https://go.dev/dl/go1.18.3.linux-amd64.tar.gz
İndirme başarıyla gerçekleştikten sonra varsa eski go dosyalarını silin ve yenisini /usr/local
dizinine kopyalayın
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.18.3.linux-amd64.tar.gz
Kopyalama gerçekleştikten sonra dizini $PATH
içerisine dahil edin. Bunun kalıcı olması için kullandığınız shellin rc
dosyasına yapıştırın.
-
Bash için dosya dizini: $HOME/.bashrc
-
Zsh için dosya dizini: $HOME/.zshrc
export PATH=$PATH:/usr/local/go/bin
Artık aşağıdaki komut ile shell üzerinden go kullanılabilir olduğunu aşağıdaki komut ile test edebilirsiniz.
go version
Make 20.04 üzerinde varsayılan olarak kurulu gelmektedir. Eğer ki kuruluysa aşağıdaki komut ile kontrol edebilirsiniz.
make --version
Eğer ki hata alıyorsanız aşağıdaki komut yardımıyla kurulumu gerçekleştirip tekrar kontrol edebilirsiniz.
sudo apt-get install make
Makefile dosyası size kolay kullanım sağlayan bir CLI komut seti sunar.
Kullanılabilir değişkenler:
- DATASET_SIZE -> min= 1, max=10M, default=50K
- MAX_STR_LEN -> min=2, max=100, default=10
- MIN_STR_LEN -> min=1, max=100, default=2
- GENERATED_FILE_PATH -> Boş olamaz, doğru bir dosya yolu olmalı
WORLD_SIZE
Kullanılacak process sayısını belirtir. Hem Generator hem de Counter için geçerlidir.
Kısıtlar: 1 <= X <= 100, varsayılan değer=1
- DATASET_SIZE değişkeninden küçük olamaz.
DATASET_SIZE
Üretilmek istenen kelime sayısını belirtir. Yalnızca Generator tarafından kullanılan bir değişkendir.
Kısıtlar: 1 <= X <= 1000000, varsayılan değer=50000
- WORLD_SIZE değişkeninden büyük olamaz.
MAX_STR_LEN
Üretilecek kelimelerin maksimum sahip olabileceği uzunluğunu belirtir. Yalnızca Generator tarafından kullanılan bir değişkendir.
Kısıtlar: 2 <= X <= 100, varsayılan değer=10
- MIN_STR_LEN değişkeninden küçük olamaz.
MIN_STR_LEN
Üretilecek kelimelerin minimum sahip olabileceği uzunluğunu belirtir. Yalnızca Generator tarafından kullanılan bir değişkendir.
Kısıtlar: 1 <= X <= 100, varsayılan değer=2
- MAX_STR_LEN değişkeninden büyük olamaz.
GENERATED_FILE_PATH
Kelimelerin sayılması istenen dosyanın yolunu özel olarak belirtmek için kullanılabilir. Opsiyoneldir. Default değeri Generator tarafından üretilmiş olan en son dosyadır. Yalnızca Counter tarafından kullanılan bir değişkendir.
Kısıtlar: X > 0, varsayılan değer=son üretilen dosya
Her iki uygulamayı da son hale göre derlemek ve varsayılan değerler ile çalıştırmak isterseniz aşağıdaki komutu deponun root dizininde çalıştırabilirsiniz.
make
Uygulamaları derledikten sonra özel değerler ile çalıştırmak için
make MAX_STR_LEN=15 MIN_STR_LEN=5 WORLD_SIZE=10 DATASET_SIZE=20
Uygulamaları özel değerler ile çalıştırmak için(önceden derlenmiş olmalı)
make runner MAX_STR_LEN=15 MIN_STR_LEN=5 WORLD_SIZE=10 DATASET_SIZE=20
Uygulamaları sadece derlemek için
make builder
Sadece Generator uygulamasını derlemek için
make build_generator
Sadece Counter uygulamasını derlemek için
make build_counter
Sadece Generator uygulamasını çalıştırmak için(önceden derlenmiş olmalı)
make run_generator MAX_STR_LEN=15 MIN_STR_LEN=5 WORLD_SIZE=10 DATASET_SIZE=20
Sadece Generator uygulamasını derlemek ve çalıştırmak için
make BR_generator MAX_STR_LEN=15 MIN_STR_LEN=5 WORLD_SIZE=10 DATASET_SIZE=20
Sadece Counter uygulamasını çalıştırmak için(önceden derlenmiş olmalı)
make run_counter WORLD_SIZE=10
Sadece Counter uygulamasını özel bir dosya yolu vererek çalıştırmak için(önceden derlenmiş olmalı)
make run_counter WORLD_SIZE=5 GENERATED_FILE_PATH=$HOME/github/MPI-words/generator/results/2022_25_05-17_42_11.txt
Sadece Counter uygulamasını derlemek ve çalıştırmak için
make BR_counter WORLD_SIZE=10
Ölçümlerin yapıldığı cihaz bilgileri:
- OS: Ubuntu 20.04.4 LTS x86_64
- Kernel: 5.13.0-44-generic
- Shell: zsh 5.8
- Terminal: gnome-terminal
- CPU: 11th Gen Intel i5-11400H
- Memory: 16GB DDR4 3200 MHz
Aşağıdaki grafikte 100 uzunluğunda 1000000 adet RASTGELE kelime üreten bir generatorun 1-100 arasında değişen process sayısına bağlı olarak zamana göre değişimini inceleyebilirsiniz.
- Sonuç olarak 17 process ile paralel çalıştıktan sonra parallelliği arttırmanın bu parametreler düzeyinde yararlı değil aksine zararlı olduğu görülüyor.
Aşağıdaki grafikte 100 uzunluğunda 1000000 adeet kelimeye sahip bir dosyadan kelime sayma işlemini gerçekleştiren ve YAML dosyası olarak kaydeden bir counterın 1-100 aralığında değişen process sayısına bağlı olarak zamana göre değişimini inceleyebilirsiniz.
- Generator grafiğine göre düzenli bir artış söz konusu değil.
- Bu parametreler eşliğinde bu sefer 7 process ile paralel çalıştırıldıktan sonra daha da paralelleşmenin yararlı değil yine aksine zararlı olduğu görülüyor.
NOT: Ölçümler C++ ve Go dillerinin farklılıklarına, çalıştırılabilir dosyalara verdiğimiz parametrelere, ölçümlerin yapıldığı yani bilgisayarımın o anlardaki statelerine göre değişkenlik gösteriyor.