Building and linking#

Dependencies#

Build from source using oneAPI#

Install CMake, the oneAPI Base Toolkit, the Intel compute runtime, re2c, and bison using your system package manager.

Initialize the oneAPI environment.

. /opt/intel/oneapi/setvars.sh

Clone the Double-Batched FFT library to your filesystem.

git clone https://github.com/intel/double-batched-fft-library.git

We only need libclir.so that we build and install using the following steps.

cd double-batched-fft-library/clir/
cmake -Bbuild -GNinja -DCMAKE_CXX_COMPILER=icpx -DCMAKE_INSTALL_PREFIX=$(pwd)/../../install/ \
      -DCMAKE_CXX_FLAGS="-ffp-model=precise" -DBUILD_SHARED_LIBS=YES
cmake --build build
cmake --install build
cd ../..

Then, 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/ \
      -DCMAKE_PREFIX_PATH=$(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 libclir and the Tiny Tensor Compiler.

Build options#

The following CMake option options are supported.

Option

Description

BUILD_DOCUMENTATION

Build the documentation

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 library 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)