bvhar Getting Started

To install bvhar in non-conda environment, you should have Eigen and boost libraries in system.

Installing

Eigen and boost

In Linux,

sudo apt-get update
sudo apt-get install -y libboost-all-dev libeigen3-dev
echo "export EIGEN_INCLUDE_DIR=/usr/include/eigen3" >> ~/.bashrc
echo "export BOOST_INCLUDE_DIR=/usr/include/boost" >> ~/.bashrc
source ~/.bashrc

In macOS,

brew update
brew install boost eigen
EIGEN_LOC=$(brew --prefix eigen)
BOOST_LOC=$(brew --prefix boost)
echo "export EIGEN_INCLUDE_DIR=$(brew --prefix eigen)/include/eigen3" >> ~/.zshrc
echo "export BOOST_INCLUDE_DIR=$(brew --prefix boost)/include" >> ~/.zshrc
source ~/.zshrc

In both Linux and macOS, verify the installation with

ls $EIGEN_INCLUDE_DIR
ls $BOOST_INCLUDE_DIR

For Windows, you can easily install both libraries using Chocolatey:

choco install eigen -y
choco install boost-msvc-14.3 -y

Set the environment variables:

$eigenPath = (
  Get-ChildItem -Path "C:\ProgramData\chocolatey\lib\eigen" -Recurse -Filter "Eigen" |
  Select-Object -First 1
).Parent.FullName
$boostPath = $null
$boostCand = @("C:\local", "C:\ProgramData\chocolatey\lib")
foreach ($cand in $boostCand) {
  $isPath = (
      Get-ChildItem -Path $cand -Directory |
      Where-Object { $_.Name -match  "boost" } |
      Sort-Object LastWriteTime -Descending |
      Select-Object -First 1
  ).FullName
  if ($isPath) {
      $boostPath = $isPath
      break
  }
}
[System.Environment]::SetEnvironmentVariable("EIGEN_INCLUDE_DIR", $eigenPath, [System.EnvironmentVariableTarget]::Machine)
[System.Environment]::SetEnvironmentVariable("BOOST_INCLUDE_DIR", $boostPath, [System.EnvironmentVariableTarget]::Machine)

Verify the environment variables and installation:

dir $env:EIGEN_INCLUDE_DIR
dir $env:BOOST_INCLUDE_DIR

OpenMP

OpenMP multithreading is used when conducting parallel chains MCMC. If OpenMP is not enabled, the chains are run sequentially. bvhar provides OpenMP checking functions.

from bvhar.utils import checkomp
checkomp.check_omp()
OpenMP threads:  4

True if enabled, False if not:

checkomp.is_omp()
True

In macOS, you need additional step to enable OpenMP. There are many options you can consider. Here is an example with LLVM.

brew update
brew install llvm libomp
echo "export CC=$(brew --prefix llvm)/bin/clang" >> ~/.zshrc
echo "export CXX=$(brew --prefix llvm)/bin/clang++" >> ~/.zshrc
echo "export CPPFLAGS=-I$(brew --prefix llvm)/include -I$(brew --prefix libomp)/include" >> ~/.zshrc
echo "export LDFLAGS=-L$(brew --prefix llvm)/lib -L$(brew --prefix libomp)/lib" >> ~/.zshrc