tilelang.cpu.toolchain¶

OpenMP compile-flag helpers for CPU kernels (tl.cpu_parallel).

The kernel shared library must link the same libomp copy the host process already loaded, otherwise macOS dyld raises OMP: Error #15 (multiple OpenMP runtimes). Detection order (mirrors torch inductor’s cpp_builder):

  1. OMP_PREFIX environment variable (a prefix with include/ and lib/);

  2. an already-imported (or importable) torch’s bundled libomp.dylib;

  3. the conda prefix of the current interpreter;

  4. Homebrew’s libomp.

On Linux the compiler runtime -fopenmp is used directly. When no runtime can be found the OpenMP flags are dropped with a warning: unknown pragmas are ignored by the compiler, so the kernel stays correct, just serial.

Functions¶

get_compile_flags(target, pass_configs, *, ...)

CPU flags for the selected target, pass configuration, and adapter.

get_openmp_compile_flags()

Compile flags for OpenMP CPU kernels: -O2 plus OpenMP flags.

Module Contents¶

tilelang.cpu.toolchain.get_compile_flags(target, pass_configs, *, execution_backend)¶

CPU flags for the selected target, pass configuration, and adapter.

LLVM uses TVM’s thread pool, so OpenMP flags only apply to the C target. Disabled parallelization leaves the serial compile command unchanged.

Parameters:
  • target (tvm.target.Target)

  • pass_configs (dict[str, Any] | None)

  • execution_backend (str)

Return type:

list[str]

tilelang.cpu.toolchain.get_openmp_compile_flags()¶

Compile flags for OpenMP CPU kernels: -O2 plus OpenMP flags.

Return type:

list[str]