<metaname="description"content="PhasicFlow is an open-source parallel DEM (discrete element method) package for simulating granular flow. It is developed in C++ and can be exectued on both GPU (like CUDA) and CPU.">
<!-- iframe showing the search results (closed by default) -->
<divid="MSearchResultsWindow">
<iframesrc="javascript:void(0)"frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<divclass="PageDoc"><divclass="header">
<divclass="headertitle">
<divclass="title">How to build PhasicFlow </div></div>
</div><!--header-->
<divclass="contents">
<divclass="textblock"><p>You can build PhasicFlow for CPU or GPU. You can have a single build or oven multiple builds on a machine. Here you learn how to have a single build of PhasicFlow, in various modes of execution.</p>
<h1>Required packages</h1>
<p>You need a list of packaged installed on your computer before building PhasicFlow:</p><ul>
<li>git, for cloning the code and package management</li>
<li>g++, for compiling the code</li>
<li>cmake, for generating build system</li>
<li>tbb, a parallel library for STL algorithms</li>
<li>Cuda (if GPU is targeted), for compiling the code for CUDA execution.</li>
<li>Kokkos, the parallelization backend of PhasicFlow</li>
</ul>
<h3>git</h3>
<p>if git is not installed on your computer, enter the following commands </p><divclass="fragment"><divclass="line">$ sudo apt update</div>
<divclass="line">$ sudo apt install git</div>
</div><!-- fragment --><h3>g++ (C++ compiler)</h3>
<p>The code is tested with g++ (gnu C++ compiler). The default 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:</p>
<p>You also need to have CMake-3.22 or higher installed on your computer. </p><divclass="fragment"><divclass="line">$ sudo apt update</div>
<divclass="line">$ sudo apt install cmake</div>
</div><!-- fragment --><h3>tbb (2020.1-2 or higher)</h3>
<p>For <b>Ubuntu 20.04 LTS or higher versions</b>, you can install tbb using apt. For now, some parallel algorithms on host side rely on tbb parallel library (C++ parallel backend). Use e following commands to install it: </p><divclass="fragment"><divclass="line">$ sudo apt update</div>
</div><!-- fragment --><p>If you are compiling on <b>Ubuntu-18.04 LTS</b>, you need to enter the following commands to get the right version (2020.1-2 or higher) of tbb: </p><divclass="fragment"><divclass="line">$ wget "http://archive.ubuntu.com/ubuntu/pool/universe/t/tbb/libtbb2_2020.1-2_amd64.deb"</div>
<p>If you want to build PhasicFlow to be executed on an nvidia-GPU, you need to install the latest version of Cuda compiler, which is compatible with your hardware and OS, on your computer.</p>
<h1>How to build?</h1>
<p>Here you will learn how to build PhasicFlow for single execution mode. Follow the steps below to install it on your computer. Tested operating systems are:</p><ul>
<li>Ubuntu 18.04 LTS</li>
<li>Ubuntu 20.04 LTS</li>
<li>Ubuntu 22.04 LTS</li>
</ul>
<h3>Step 1: Package check</h3>
<p>Make sure that you have installed all the required packages on your computer. See above for more information.</p>
<h3>Step 2: Cloning Kokkos</h3>
<p>It is assumed that Kokkos source is located in the home folder of your computer. Clone the latest version of Kokkos into your home folder: </p><divclass="fragment"><divclass="line">$ cd ~</div>
</div><!-- fragment --><p>or simply download and extract the source code of Kokkos in <code>~/Kokkos</code> folder. In the end, the top level CMakeLists.txt file should be located in <code>~/Kokkos/kokkos</code> folder.</p>
<h3>Step 3: Cloning PhasicFlow</h3>
<p>Create the PhasicFlow folder in your home folder and then clone the source code into that folder: </p><divclass="fragment"><divclass="line">$ cd ~</div>
<p>this will introduce a new source file for setting the environmental variables of PhasicFlow. If you want to load these variables in the current open terminal, you need to source it. Or, simply <b>close the terminal</b> and <b>open a new terminal</b>.</p>
<h3>Step 5: Building PhasicFlow</h3>
<p>Follow one of the followings to build PhasicFlow for one mode of execution. </p><h4>Serial build for CPU</h4>
<p>In a <b>new terminal</b> enter the following commands: </p><divclass="fragment"><divclass="line">$ cd ~/PhasicFlow/phasicFlow</div>
</div><!-- fragment --><p>For faster builds, use <code>make install -j</code>. This will use all the CPU cores on your computer for building. </p><h4>OpenMP build for CPU</h4>
<divclass="fragment"><divclass="line">$ cd ~/PhasicFlow/phasicFlow</div>
</div><!-- fragment --><p>After building, <code>bin</code>, <code>include</code>, and <code>lib</code> folders will be created in <code>~/PhasicFlow/phasicFlow/</code> folder. Now you are ready to use PhasicFlow.</p>
<p><b>note 1</b>: When compiling the code in parallel, you need to have enough RAM on your computer. As a rule, you need 1 GB free RAM per each processor in your computer for compiling in parallel. You may want to use fewer number of cores on your computer by using the following command:</p>
<p><code>$ make install -j 3</code></p>
<p>the above command only uses 3 cores for compiling.</p>
<p><b>note 2</b>: By default PhasicFlow is compiled with <b>double</b> as floating point variable. You can compile it with <b>float</b>. Just in the command line of camke added <code>-DpFlow_Build_Double=Off</code> flag to compile it with float. For example if you are building for cuda, you can enter the following command:</p>
<p>This command shows the host and device environments and software version. If PhasicFlow was build correctly, you would get the following output: </p><divclass="fragment"><divclass="line">Initializing host/device execution spaces . . . </div>
<divclass="line"> Host execution space is Serial</div>
<divclass="line"> Device execution space is Cuda</div>
<divclass="line"></div>
<divclass="line"> ou are using phasicFlow v-0.1 (copyright(C): www.cemf.ir)</div>
<divclass="line"> In this build, double is used for floating point operations.</div>
<divclass="line"></div>
<divclass="line"></div>
<divclass="line">Finalizing host/device execution space ....</div>
</div><!-- fragment --></div></div><!-- contents -->
</div><!-- PageDoc -->
</div><!-- doc-content -->
<divid="nav-path"class="navpath"><!-- id is needed for treeview function! -->