Skip to content

How to Build PhasicFlow

PhasicFlow edited this page Dec 5, 2022 · 15 revisions

You can build PhasicFlow for different hardware, CPU or GPU, depending on the computer. You can have a single build or oven multiple builds on a machine. Here you learn how to build PhasicFlow in various modes of execution.

Required packages

PhasicFlow uses Kokkos as the backend for parallelization. So, you need to have a copy of the source code in the machine alongside PhasicFlow. The make system is adjusted in a way so you do not need to separately compile Kokkos and the required source code files from Kokkos are compiled alongside the PhasicFlow.

git

if git is not installed on your computer, enter the following command

sudo apt update
sudo apt install git

g++ (C++ compiler)

The code is tested with g++ (gnu C++ compiler). The standard version of g++ on Ubuntu 18.04 LTS or upper is sufficient for compiling. If it is not installed on your operating system, enter the following command:

sudo apt update
sudo apt install g++```


### CMake
You also need to have CMake-3.22 or higher installed on your computer.

### tbb (2020.1-2 or higher)
For **Ubuntu 20.04 LTS or higher versions**, you can install tbb using official repository apt. For now, some parallel algorithms on host side rely on tbb parallel library (C++ parallel backend). Use e following commands to install it:

sudo apt update sudo apt install libtbb-dev

If you are compiling on **Ubuntu-18.04 LTS**, you need to enter the following commands to get the right version (2020.1-2 or higher) of tbb:

wget "http://archive.ubuntu.com/ubuntu/pool/universe/t/tbb/libtbb2_2020.1-2_amd64.deb" sudo dpkg --install libtbb2_2020.1-2_amd64.deb wget "http://archive.ubuntu.com/ubuntu/pool/universe/t/tbb/libtbb-dev_2020.1-2_amd64.deb" sudo dpkg --install libtbb-dev_2020.1-2_amd64.deb


# How to build? 
PhasicFlow uses CMake as the build system. you need to have CMake-3.22 or higher installed on your machine. you can either use the command line for setting-up the build system, or use `cmake-gui` to setup your build system through the GUI. 

### Step 1: Package check
Make sure you have installed all the required packages on your computer (tbb and CMake and compilers).
 
**note:** You must have git installed on your computer. If it is not installed, enter the following command:

sudo apt install git


### Step 2: Cloning Kokkos
It is assumed that Kokkos source is located in the home folder of your OS. Clone the current version of Kokkos into your home folder:

cd ~ mkdir Kokkos cd Kokkos git clone https://github.com/kokkos/kokkos.git

or simply download and extract the source code of Kokkos in `~/Kokkos` folder. In the end, the top level CMakeLists.txt file should be located in `~/Kokkos/kokkos` folder. 

### Step 3: Cloning PhasicFlow
Create the PhasicFlow folder in your home folder and then clone the source code into that folder:

cd ~ mkdir PhasicFlow cd PhasicFlow git clone https://github.com/PhasicFlow/phasicFlow.git

### Step 4: Environmental variables
In the terminal enter the following command:

`gedit ~/.bashrc`

and add the following line to the end of the file, save and close it.

**source $HOME/PhasicFlow/phasicFlow/cmake/bashrc**

close the terminal. 

### Step 5: Building PhasicFlow
Follow one of the followings to build PhasicFlow for one mode of execution.
#### Serial build for CPU
Open a new terminal and enter the following commands:

cd ~/PhasicFlow/phasicFlow mkdir build cd build cmake ../ -DpFlow_Build_Serial=On make install

For faster builds, use `make install -j`. This will use all the CPU cores on your computer for building. 
#### OpenMP build for CPU

cd ~/PhasicFlow/phasicFlow mkdir build cd build cmake ../ -DpFlow_Build_OpenMP=On make install

#### GPU build for parallel execution on CUDA-enabled GPUs

cd ~/PhasicFlow/phasicFlow mkdir build cd build cmake ../ -DpFlow_Build_Cuda=On make install


After building, `bin`, `include`, and `lib` folders will be created in `~/PhasicFlow/phasicFlow/` folder. Now you are ready to use PhasicFlow.

### Step 6: Testing
In the current terminal or a new terminal enter the following command:
`checkPhasicFlow`
This command shows the host and device environments and software version. If PhasicFlow was build correctly, you would get the following output:

Initializing host/device execution spaces . . . Host execution space is Serial Device execution space is Cuda

You are using phasicFlow v-0.1 (copyright(C): www.cemf.ir)

Finalizing host/device execution space ....

Clone this wiki locally