<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.17"/> <meta name="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."> <title>PhasicFlow: How to build PhasicFlow</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="navtree.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="resize.js"></script> <script type="text/javascript" src="navtreedata.js"></script> <script type="text/javascript" src="navtree.js"></script> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="search/searchdata.js"></script> <script type="text/javascript" src="search/search.js"></script> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ $(document).ready(function() { init_search(); }); /* @license-end */ </script> <script type="text/x-mathjax-config"> MathJax.Hub.Config({ extensions: ["tex2jax.js"], jax: ["input/TeX","output/HTML-CSS"], }); </script> <script type="text/javascript" async="async" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> <link href="customdoxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" > <tbody> <tr> <td id="projectlogo"><a href="https://github.com/PhasicFlow"><img alt="Logo" src="phasicFlow_logo.png"></a></td> <td> <div id="MSearchBox" class="MSearchBoxInactive"> <span class="left"> <img id="MSearchSelect" src="search/mag_sel.png" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" alt=""/> <input type="text" id="MSearchField" value="Search" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)" onkeyup="searchBox.OnSearchFieldChange(event)"/> </span><span class="right"> <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> </span> </div> </td> </tr> <tr> <td id="projectbrief"> <a href="https://https://cemf.ir">www.cemf.ir</a> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.17 --> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ var searchBox = new SearchBox("searchBox", "search",false,'Search'); /* @license-end */ </script> </div><!-- top --> <div id="side-nav" class="ui-resizable side-nav-resizable"> <div id="nav-tree"> <div id="nav-tree-contents"> <div id="nav-sync" class="sync"></div> </div> </div> <div id="splitbar" style="-moz-user-select:none;" class="ui-resizable-handle"> </div> </div> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ $(document).ready(function(){initNavTree('howToBuildPhasicFlow.html',''); initResizable(); }); /* @license-end */ </script> <div id="doc-content"> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> </div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <div class="PageDoc"><div class="header"> <div class="headertitle"> <div class="title">How to build PhasicFlow </div> </div> </div><!--header--> <div class="contents"> <div class="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><div class="fragment"><div class="line">$ sudo apt update</div> <div class="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> <div class="fragment"><div class="line">$ sudo apt update</div> <div class="line">$ sudo apt install g++</div> </div><!-- fragment --><h3>CMake</h3> <p>You also need to have CMake-3.22 or higher installed on your computer. </p><div class="fragment"><div class="line">$ sudo apt update</div> <div class="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><div class="fragment"><div class="line">$ sudo apt update</div> <div class="line">$ sudo apt install libtbb-dev</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><div class="fragment"><div class="line">$ wget "http://archive.ubuntu.com/ubuntu/pool/universe/t/tbb/libtbb2_2020.1-2_amd64.deb"</div> <div class="line">$ sudo dpkg --install libtbb2_2020.1-2_amd64.deb</div> <div class="line">$ wget "http://archive.ubuntu.com/ubuntu/pool/universe/t/tbb/libtbb-dev_2020.1-2_amd64.deb"</div> <div class="line">$ sudo dpkg --install libtbb-dev_2020.1-2_amd64.deb</div> </div><!-- fragment --><h3>Cuda</h3> <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><div class="fragment"><div class="line">$ cd ~</div> <div class="line">$ mkdir Kokkos</div> <div class="line">$ cd Kokkos</div> <div class="line">$ git clone https://github.com/kokkos/kokkos.git</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><div class="fragment"><div class="line">$ cd ~</div> <div class="line">$ mkdir PhasicFlow</div> <div class="line">$ cd PhasicFlow</div> <div class="line">$ git clone https://github.com/PhasicFlow/phasicFlow.git</div> </div><!-- fragment --><h3>Step 4: Environmental variables</h3> <p>Opne the bashrc file using the following command:</p> <p><code>$ gedit ~/.bashrc</code></p> <p>and add the following line to the end of the file, <b>save</b> and <b>close</b> it.</p> <p><code>source $HOME/PhasicFlow/phasicFlow/cmake/bashrc</code></p> <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><div class="fragment"><div class="line">$ cd ~/PhasicFlow/phasicFlow</div> <div class="line">$ mkdir build</div> <div class="line">$ cd build</div> <div class="line">$ cmake ../ -DpFlow_Build_Serial=On</div> <div class="line">$ make install</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> <div class="fragment"><div class="line">$ cd ~/PhasicFlow/phasicFlow</div> <div class="line">$ mkdir build</div> <div class="line">$ cd build</div> <div class="line">$ cmake ../ -DpFlow_Build_OpenMP=On</div> <div class="line">$ make install</div> </div><!-- fragment --><h4>GPU build for parallel execution on CUDA-enabled GPUs</h4> <div class="fragment"><div class="line">$ cd ~/PhasicFlow/phasicFlow</div> <div class="line">$ mkdir build</div> <div class="line">$ cd build</div> <div class="line">$ cmake ../ -DpFlow_Build_Cuda=On</div> <div class="line">$ make install</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><code>$ cmake ../ -DpFlow_Build_Cuda=On -DpFlow_Build_Double=Off</code></p> <h3>Step 6: Testing</h3> <p>In the current terminal or a new terminal enter the following command:</p> <p><code>$ checkPhasicFlow</code></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><div class="fragment"><div class="line">Initializing host/device execution spaces . . . </div> <div class="line"> Host execution space is Serial</div> <div class="line"> Device execution space is Cuda</div> <div class="line"> </div> <div class="line"> ou are using phasicFlow v-0.1 (copyright(C): www.cemf.ir)</div> <div class="line"> In this build, double is used for floating point operations.</div> <div class="line"> </div> <div class="line"> </div> <div class="line">Finalizing host/device execution space ....</div> </div><!-- fragment --> </div></div><!-- contents --> </div><!-- PageDoc --> </div><!-- doc-content --> <div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> <ul> <li class="footer">Generated by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.17 </li> </ul> </div> </body> </html>