3. Runtime Dependencies#
The followings are dependencies used during the runtime of detkit. Note that, among these dependencies, OpenMP is required, while the rest of the dependencies are optional.
3.1. OpenMP (Required)#
detkit requires OpenMP, which is typically included with most C++ compilers.
- For Linux users:#
By installing a C++ compiler such as GCC, Clang, or Intel, you also obtain OpenMP as well. You may alternatively install
libgomp
(see below) without the need to install a full compiler.- For macOS users:#
It’s crucial to note that OpenMP is not part of the default Apple Xcode’s LLVM compiler. Even if you have Apple Xcode LLVM compiler readily installed on macOS, you will still need to install OpenMP separately via
libomp
Homebrew package (see below) or as part of the open source LLVM compiler, viallvm
Homebrew package.- For Windows users:#
OpenMP support depends on the compiler you choose; Microsoft Visual C++ supports OpenMP, but you may need to enable it explicitly.
Below are the specific installation for each operating system:
sudo apt install libgomp1 -y
sudo yum install libgomp -y
sudo dnf install libgomp -y
sudo brew install libomp
Note
In macOS, for libomp
versions 15
and above, Homebrew installs OpenMP as keg-only. To utilize the OpenMP installation, you should establish the following symbolic links:
libomp_dir=$(brew --prefix libomp)
ln -sf ${libomp_dir}/include/omp-tools.h /usr/local/include/omp-tools.h
ln -sf ${libomp_dir}/include/omp.h /usr/local/include/omp.h
ln -sf ${libomp_dir}/include/ompt.h /usr/local/include/ompt.h
ln -sf ${libomp_dir}/lib/libomp.a /usr/local/lib/libomp.a
ln -sf ${libomp_dir}/lib/libomp.dylib /usr/local/lib/libomp.dylib
3.2. Perf Tool (Optional)#
detkit can count the FLOPs of computations if the argument flops=True
is used in the functions (see API Reference). To achieve this, the Linux Performance Counter tool, known as perf
, must be installed.
sudo apt-get install linux-tools-common linux-tools-generic linux-tools-$(uname -r)
sudo yum install perf
sudo dnf install perf
Attention
The perf
tool is not available on macOS or Windows.
3.2.1. Granting Permissions#
After installing perf
, grant the necessary permissions to the user to run it:
sudo sh -c 'echo 1 >/proc/sys/kernel/perf_event_paranoid'
This setting is temporary and will be lost after a reboot. To make it permanent, use the following commands instead:
echo "kernel.perf_event_paranoid = 1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
3.2.2. Testing the Perf Tool#
You can test if the perf
tool is working by running the following command:
perf stat -e instructions:u dd if=/dev/zero of=/dev/null count=100000
Alternatively, you can test the perf
tool directly with detkit.check_perf_support()
:
>>> import detkit
>>> detkit.check_perf_support()
If the perf
tool is installed and configured properly, the output of either of the above commands should be like:
{
'kernel_version': '6.8.0-51-generic',
'perf_event_paranoid': 1,
'perf_installed': True,
'perf_working': True
}