from bvhar.utils import checkomp
checkomp.check_omp()
OpenMP threads: 4
To install bvhar
in non-conda environment, you should have Eigen and boost libraries in system.
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
For Windows, you can easily install both libraries using Chocolatey:
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:
OpenMP multithreading is used when conducting parallel chains MCMC. If OpenMP is not enabled, the chains are run sequentially. bvhar
provides OpenMP checking functions.
True
if enabled, False
if not:
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