Difference between revisions of "How to build"

From Medusa: Coordinate Free Mehless Method implementation
Jump to: navigation, search
(Building on Mac OSX)
Line 1: Line 1:
{{Warning|This section is out of date. See [https://gitlab.com/e62Lab/medusa Gitlab repository] for more details.}}
 
 
 
 
=Installation=
 
=Installation=
 
To make this work from plain Ubuntu installation, run
 
To make this work from plain Ubuntu installation, run
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
sudo apt-get install cmake doxygen graphviz libboost-dev libhdf5-serial-dev
+
sudo apt-get install git g++ python cmake libboost-dev libhdf5-serial-dev
git clone https://gitlab.com/e62Lab/e62numcodes.git
+
git clone https://gitlab.com/e62Lab/medusa.git --branch master --single-branch
cd e62numcodes
+
cd medusa
./run_tests.sh
+
./run_tests.py
 
</syntaxhighlight>
 
</syntaxhighlight>
which installs dependencies, clones the repository, goes into the root folder of the repository and runs tests. This will check the configuration, notify you of potentially missing dependencies, build and run all tests, check code style and docs. If this works, you are ready to go! Otherwise, install any missing packages and if it still fails, raise an issue!
+
which installs dependencies, clones the repository, goes into the root folder of
 +
the repository and runs tests. This will build and run all tests. If this
 +
works, you are ready to go! Otherwise install any missing packages and if it
 +
still fails, raise an issue!
 +
 
 +
For instructions on how to use this library in you project, see
 +
Including this library in your project.
  
 
=Building=
 
=Building=
Line 16: Line 19:
 
List of dependencies:
 
List of dependencies:
  
* Build tools, like <syntaxhighlight lang="bash" inline> cmake >= 2.8.12</syntaxhighlight>, <syntaxhighlight lang="bash" inline> g++ >= 4.8</syntaxhighlight>, <syntaxhighlight lang="bash" inline>make</syntaxhighlight>
+
* Build tools, like <syntaxhighlight lang="bash" inline> cmake >= 2.8.12</syntaxhighlight>, <syntaxhighlight lang="bash" inline> g++ >= 4.8</syntaxhighlight>, <syntaxhighlight lang="bash" inline>make</syntaxhighlight>, <code>python</code>
 
* [http://www.boost.org/ Boost]
 
* [http://www.boost.org/ Boost]
* HDF5 for IO [https://www.hdfgroup.org/ HDF5 library]
+
* [https://www.hdfgroup.org/ HDF5 library] for IO
 
* <syntaxhighlight lang="bash" inline> doxygen >=  1.8.8 </syntaxhighlight> and Graphviz for generating the documentation
 
* <syntaxhighlight lang="bash" inline> doxygen >=  1.8.8 </syntaxhighlight> and Graphviz for generating the documentation
  
Line 30: Line 33:
 
Note that you only have to run <syntaxhighlight lang="bash" inline> cmake </syntaxhighlight> once, after that only <syntaxhighlight lang="bash" inline> make</syntaxhighlight> is sufficient.
 
Note that you only have to run <syntaxhighlight lang="bash" inline> cmake </syntaxhighlight> once, after that only <syntaxhighlight lang="bash" inline> make</syntaxhighlight> is sufficient.
  
Binaries are placed into <syntaxhighlight lang="bash" inline> bin </syntaxhighlight> folder. Test can be run all at once via <syntaxhighlight lang="bash" inline> make
+
Binaries are placed into <syntaxhighlight lang="bash" inline>bin/</syntaxhighlight> folder. Test can be run all at once via <syntaxhighlight lang="bash" inline> make
run_all_tests </syntaxhighlight> or individually via eg. <syntaxhighlight lang="bash" inline>make basisfunc_run_tests </syntaxhighlight>.
+
medusa_run_tests </syntaxhighlight> or individually via eg. <syntaxhighlight lang="bash" inline>make operators_run_tests</syntaxhighlight>.
 +
 
 +
==HDF5==
 +
In order to use HDF5 IO you need the [https://www.hdfgroup.org/ HDF5 library].
 +
You can install it easily using the command <syntaxhighlight lang="bash" inline> sudo apt-get install libhdf5-
 +
dev </syntaxhighlight> or <syntaxhighlight lang="bash" inline> sudo pacman -S hdf5 </syntaxhighlight>.
 +
 
 +
Ubuntu places (at least on older versions) hdf5 headers and libraries in a werid folder
 +
<code>/usr/{lib, include}/x86_64-linux-gnu/hdf5/serial/</code>.
 +
 
 +
If you get an error like <code>HDF5 sample failed to compile.  See errors above.</code> during <code>cmake</code> execution
 +
then the sample hdf test file located in <code>test/test_hdf_compile.cpp</code> failed to compile. Perhaps it is good to make this file compile first,
 +
before tackling the whole project.
 +
 
 +
If you get an error similar to <code>fatal error: hdf5.h: No such file or directory</code>,
 +
then your compiler cannot see the HDF5 header files. Some distrbutions, notably (older) Ubuntu, place them into nonstandard folders
 +
<code>/usr/include/hdf5/serial/</code> or <code>/usr/include/x86_64-linux-gnu/hdf5/serial/</code>.
 +
Check these two folders or check your distributions hdf package for the locations of these files.
 +
After you have determined the location, add that directory to the include directories,
 +
using -I flag or in <code>CMakeLists.txt</code> by using
 +
```
 +
include_directories(/usr/include/hdf5/serial/)  # or your appropriate directory
 +
```
 +
If you wish to fix this problem permanently, you can create soft links to the headers in your `/usr/include` directory,
 +
by typing
 +
```
 +
sudo ln -s /usr/include/hdf5/serial/ /usr/include
 +
```
 +
After this, there should be no compile time errors. If there are, please raise an issue.
 +
 
 +
If you get error similar to <code>-lhdf5 not found</code> and you have hdf5 installed,
 +
you might have to link the libraries into a discoverable place, like <code>/usr/lib/</code>
 +
or add the above directory to the linker path. Similarly to above, check the `/usr/lib/x86_64-linux-gnu/hdf5/serial/`
 +
directory and look for file `libhdf5.a`. When found,
 +
specify the location using -L flag or <code>CMakeLists.txt</code> by using
 +
```
 +
link_directories(/usr/lib/x86_64-linux-gnu/hdf5/serial/)  # or your appropriate directory
 +
```
 +
or fix the problem permanently by soft-linking
 +
```
 +
sudo ln -s /usr/lib/x86_64-linux-gnu/hdf5/serial/ /usr/lib
 +
```
  
 
==Linear Algebra==
 
==Linear Algebra==
Line 39: Line 83:
 
[http://eigen.tuxfamily.org/dox/AsciiQuickReference.txt here].
 
[http://eigen.tuxfamily.org/dox/AsciiQuickReference.txt here].
  
==HDF5==
 
  
In order to use HDF5 IO you need [https://www.hdfgroup.org/ hdf5 library].
+
== Using Intel Math Kernel Library (MKL) ==
You can install it easily using the command <syntaxhighlight lang="bash" inline> sudo apt-get install libhdf5-
+
{{Warning|This section is out of date. Some information might be wrong or incomplete. }}
dev </syntaxhighlight> or <syntaxhighlight lang="bash" inline> sudo pacman -S hdf5-cpp-fortran </syntaxhighlight>.
 
 
 
Ubuntu places hdf5 libs in a werid folder <code>/usr/lib/x86_64-linux-gnu/hdf5/serial/</code>.  
 
If you get error similar to <code>-lhdf5 not found</code> and you have hdf5 installed, you might have to link the libraries into
 
a discoverable place, like <code>/usr/lib/</code> or add the above directory to the linker path.
 
If using cmake, you can add the following line to your CMakeLists.txt
 
  link_directories(/usr/lib/x86_64-linux-gnu/hdf5/serial/)
 
  
== Using Intel Math Kernel Library (MKL) ==
 
 
Eigen has great support for MKL all you have to do is define a EIGEN_USE_MKL_ALL macro before any includes.
 
Eigen has great support for MKL all you have to do is define a EIGEN_USE_MKL_ALL macro before any includes.
 
You can see further instructions [https://eigen.tuxfamily.org/dox/TopicUsingIntelMKL.html on their website].
 
You can see further instructions [https://eigen.tuxfamily.org/dox/TopicUsingIntelMKL.html on their website].
Line 68: Line 103:
  
 
== Building on Mac OSX ==
 
== Building on Mac OSX ==
This method was tested on El Capitan. Linking the OpenMP library is still not functioning as intended.
+
{{Warning|This section is out of date. Some information might be wrong or incomplete. }}
 +
This method was tested on El Capitan.
  
 
First install all dependencies from homebrew
 
First install all dependencies from homebrew
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
brew install llvm cmake homebrew/science/hdf5
+
brew install llvm cmake homebrew/science/hdf5 boost
 
</syntaxhighlight>
 
</syntaxhighlight>
 
Now you can clone and build the project with CLang using the following commands
 
Now you can clone and build the project with CLang using the following commands
Line 85: Line 121:
  
 
== Using Intel C/C++ Compiler ==
 
== Using Intel C/C++ Compiler ==
 
+
{{Warning|This section is out of date. Some information might be wrong or incomplete. }}
 
In order to use Intel's compiler you have to first set the <syntaxhighlight lang="bash" inline>CXX</syntaxhighlight>
 
In order to use Intel's compiler you have to first set the <syntaxhighlight lang="bash" inline>CXX</syntaxhighlight>
 
and <syntaxhighlight lang="bash" inline>CC</syntaxhighlight> bash variables. Before calling
 
and <syntaxhighlight lang="bash" inline>CC</syntaxhighlight> bash variables. Before calling

Revision as of 22:52, 3 June 2018

Installation

To make this work from plain Ubuntu installation, run

sudo apt-get install git g++ python cmake libboost-dev libhdf5-serial-dev
git clone https://gitlab.com/e62Lab/medusa.git --branch master --single-branch
cd medusa
./run_tests.py

which installs dependencies, clones the repository, goes into the root folder of the repository and runs tests. This will build and run all tests. If this works, you are ready to go! Otherwise install any missing packages and if it still fails, raise an issue!

For instructions on how to use this library in you project, see Including this library in your project.

Building

List of dependencies:

  • Build tools, like cmake >= 2.8.12, g++ >= 4.8, make, python
  • Boost
  • HDF5 library for IO
  • doxygen >= 1.8.8 and Graphviz for generating the documentation

Out of source builds are preferred. Run

mkdir -p build
cd build
cmake ..
make

Note that you only have to run cmake once, after that only make is sufficient.

Binaries are placed into bin/ folder. Test can be run all at once via make medusa_run_tests or individually via eg. make operators_run_tests.

HDF5

In order to use HDF5 IO you need the HDF5 library. You can install it easily using the command sudo apt-get install libhdf5- dev or sudo pacman -S hdf5.

Ubuntu places (at least on older versions) hdf5 headers and libraries in a werid folder /usr/{lib, include}/x86_64-linux-gnu/hdf5/serial/.

If you get an error like HDF5 sample failed to compile. See errors above. during cmake execution then the sample hdf test file located in test/test_hdf_compile.cpp failed to compile. Perhaps it is good to make this file compile first, before tackling the whole project.

If you get an error similar to fatal error: hdf5.h: No such file or directory, then your compiler cannot see the HDF5 header files. Some distrbutions, notably (older) Ubuntu, place them into nonstandard folders /usr/include/hdf5/serial/ or /usr/include/x86_64-linux-gnu/hdf5/serial/. Check these two folders or check your distributions hdf package for the locations of these files. After you have determined the location, add that directory to the include directories, using -I flag or in CMakeLists.txt by using ``` include_directories(/usr/include/hdf5/serial/) # or your appropriate directory ``` If you wish to fix this problem permanently, you can create soft links to the headers in your `/usr/include` directory, by typing ``` sudo ln -s /usr/include/hdf5/serial/ /usr/include ``` After this, there should be no compile time errors. If there are, please raise an issue.

If you get error similar to -lhdf5 not found and you have hdf5 installed, you might have to link the libraries into a discoverable place, like /usr/lib/ or add the above directory to the linker path. Similarly to above, check the `/usr/lib/x86_64-linux-gnu/hdf5/serial/` directory and look for file `libhdf5.a`. When found, specify the location using -L flag or CMakeLists.txt by using ``` link_directories(/usr/lib/x86_64-linux-gnu/hdf5/serial/) # or your appropriate directory ``` or fix the problem permanently by soft-linking ``` sudo ln -s /usr/lib/x86_64-linux-gnu/hdf5/serial/ /usr/lib ```

Linear Algebra

We use Eigen as our matrix library. See here for use reference and documentation. For a quick transition from Matlab see here.


Using Intel Math Kernel Library (MKL)

Warning: This section is out of date. Some information might be wrong or incomplete.

Eigen has great support for MKL all you have to do is define a EIGEN_USE_MKL_ALL macro before any includes. You can see further instructions on their website.

Besides setting #define EIGEN_USE_MKL_ALL in your code, some linker and compilation fixes are needed. You have to set MKL and MKLROOT variables in cmake. You can define the variable MKLROOT as a system variable (using export) which is enough. You can also define it manually when calling cmake. If it is not set in either way it will default to "/opt/intel/compilers_and_libraries_2017.2.174/linux/mkl".

cmake .. -DMKL=ON -DMKLROOT=/opt/intel/compilers_and_libraries_2016.1.150/linux/mkl

Your target has to be linked with some MKL libraries so make sure to add the following link to your cmake file.

target_link_libraries(target ${LMKL})

Building on Mac OSX

Warning: This section is out of date. Some information might be wrong or incomplete.

This method was tested on El Capitan.

First install all dependencies from homebrew

brew install llvm cmake homebrew/science/hdf5 boost

Now you can clone and build the project with CLang using the following commands

git clone https://gitlab.com/e62Lab/medusa.git
cd medusa
mkdir build
cd build
cmake .. -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++
make domain_run_tests

Using Intel C/C++ Compiler

Warning: This section is out of date. Some information might be wrong or incomplete.

In order to use Intel's compiler you have to first set the CXX and CC bash variables. Before calling cmake for the first time you have to export the following:

export CXX="icpc"
export CC="icc"

or you can define the compiler when first calling cmake like so:

cmake .. -DCMAKE_C_COMPILER=$(which icc) -DCMAKE_CXX_COMPILER=$(which icpc)


You can also compile it directly for Intel® Xeon Phi™ Coprocessor. You do this by adding -Dmmic=ON flag to the cmake command:

cmake .. -Dmmic=ON -DCMAKE_C_COMPILER=$(which icc) -DCMAKE_CXX_COMPILER=$(which icpc)

Note: All features that depend on system third-party libraries are not available on MIC (Many Integrated Core). This includes:

  • HDF class in io.hpp