Building and linking#
Dependencies#
- Optional
OpenCL ICD loader [OpenCL, SYCL]
Level Zero Loader [Level Zero, SYCL]
Intel oneAPI Base Toolkit [SYCL]
Build from source using oneAPI#
Install the dependencies via your favourite package manager.
Initialize the oneAPI environment.
. /opt/intel/oneapi/setvars.sh
Build and install Tiny Tensor Compiler with the following steps
git clone https://github.com/intel/tiny-tensor-compiler.git tinytc
cd tinytc
cmake -Bbuild -GNinja -DCMAKE_CXX_COMPILER=icpx -DCMAKE_INSTALL_PREFIX=$(pwd)/../install/ \
-DBUILD_SHARED_LIBS=YES
cmake --build build
cmake --install build
cd ..
If you need a static library, set -DBUILD_SHARED_LIBS=NO when compiling the Tiny Tensor Compiler. Adjust CMAKE_INSTALL_PREFIX to control the installation directory. (Can be left empty for a system install; needs sudo.)
Build options#
The following CMake option options are supported.
Option |
Description |
|---|---|
BUILD_DOCUMENTATION |
Build the documentation |
BUILD_DOUBLE_PRECISION_TESTS |
Build unit tests for double precision (e.g. for iGPUs without DP support) |
BUILD_TESTING |
Build unit tests |
BUILD_LEVEL_ZERO |
Build libtinytc_ze for Level Zero support (enforced if BUILD_SYCL=ON) |
BUILD_OPENCL |
Build libtinytc_cl for OpenCL support (enforced if BUILD_SYCL=ON) |
BUILD_SYCL |
Build libtinytc_sycl for SYCL support |
Linking in a CMake project#
CMake targets are exported, therefore you only need
find_package(tinytc REQUIRED)
in your CMakeLists.txt to find the Tiny Tensor Compiler.
Note
For non-standard installation directories add -DCMAKE_PREFIX_PATH=/path/to/installation when invoking cmake.
Runtime support is split in the three libraries libtinytc_ze, libtinytc_cl, and libtinytc_sycl. The BUILD_(LEVEL_ZERO, OPENCL, SYCL) options control which libraries are built, respectively. For example, when using OpenCL only, you can set BUILD_SYCL=OFF such that you do not need a C++ compiler with SYCL support.
For runtime support you have to add one of the following find_package calls to your CMakeLists.txt:
# For SYCL
find_package(tinytc_sycl REQUIRED)
# For Level Zero
find_package(tinytc_ze REQUIRED)
# For OpenCL
find_package(tinytc_cl REQUIRED)
Note
You can add “static” or “shared” after “REQUIRED” to explicitly request the static or shared library version.
For linking and setting up include directories you only need
target_link_libraries(your-target PRIVATE tinytc::tinytc tinytc::tinytc_sycl)
# or
target_link_libraries(your-target PRIVATE tinytc::tinytc tinytc::tinytc_ze)
# or
target_link_libraries(your-target PRIVATE tinytc::tinytc tinytc::tinytc_cl)