srdatalog.ir.codegen.cuda.build.compiler_ninja¶
Ninja + PCH compile orchestrator.
Emits a build.ninja in the cache dir that:
Precompiles
srdatalog.hinto a.pchonce per build (srdatalog.h pulls in boost/hana/mp11/RMM/spdlog — ~4s per TU to parse cold, so one PCH saves ~(N-1) * 4s on N-shard projects like doop).Compiles every project
.cppwith-include-pch srdatalog.pch.Links the resulting objects + extra_sources into a shared library.
Invokes ninja via the ninja PyPI wheel so we don’t need a system
binary — pip install srdatalog pulls the ninja wheel as a transitive
dep (~500 KB).
Contract matches compile_jit_project in compiler.py:
Input:
project_resultdict fromcache.write_jit_project, plus aCompilerConfig.Output:
BuildResultwith compile + link results.
The ThreadPoolExecutor orchestrator in compiler.py remains as a
fallback (env SRDATALOG_JIT_NO_NINJA=1 or use_ninja=False) for
contributors without ninja installed or for debugging a single-TU
compile path.
Module Contents¶
Functions¶
Drop-in replacement for |
|
Write |
API¶
- srdatalog.ir.codegen.cuda.build.compiler_ninja.compile_jit_project_ninja(project_result: srdatalog.ir.codegen.cuda.build.cache.JitProjectLayout, config: srdatalog.ir.codegen.cuda.build.compiler.CompilerConfig | None = None, *, use_pch: bool = False) srdatalog.ir.codegen.cuda.build.compiler.BuildResult[source]¶
Drop-in replacement for
compile_jit_projectthat goes through ninja + PCH. Returns the same BuildResult shape so callers don’t need to change.Compile-failure reporting: on non-zero ninja exit, we return a single synthetic CompileResult holding ninja’s captured output — we don’t parse per-TU diagnostics out of ninja’s stream (ninja already shows them verbatim to stderr). Callers can still read
.stderr+ exit code.
- srdatalog.ir.codegen.cuda.build.compiler_ninja.emit_build_ninja(project_result: srdatalog.ir.codegen.cuda.build.cache.JitProjectLayout, config: srdatalog.ir.codegen.cuda.build.compiler.CompilerConfig, *, use_pch: bool = False, use_ccache: bool | None = None) str[source]¶
Write
<cache_dir>/build.ninjafromproject_result+config.Returns the absolute path to the emitted ninja file.
Args: use_pch: opt-in split host/device PCH. Disabled by default because clang’s CUDA + PCH pipeline is fragile on our runtime headers (ptxas chokes when
-Xclang -emit-pchruns with--cuda-*-onlyon headers that transitively pull CUDA intrinsics viagpu/search.h). Keep the code path so future runtime-header cleanups can flip it on withuse_pch=True. use_ccache: prependccacheto the compile command when it’s on PATH. Defaults to True iffccacheis found. Warm rebuilds afterrm -rf build/go from ~97s → ~5s on doop with ccache. Override viaSRDATALOG_JIT_NO_CCACHE=1.