Deduplicate concurrent compilations of the same kernel

オープン
#329 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
30/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
領域
performance

調査の方向性

Start in compile_or_lookup in src/launch.jl, where the existing job_results_lock check and the compile-outside-lock path live, and read cached_results(job) to see how one TileCompilerResults maps to each job. Add per-result in-flight tracking with a Threading.Condition created on that lock, and keep the in-flight state out of TileCompilerResults, since that type is serialized into package images. Done means concurrent misses for one job run tileiras once, waiters reuse the published cubin and call GPUCompiler.run_compile_hook, and a failed compile wakes waiters so they retry rather than hang.

索引モデルが issue の本文から書いたものです。

説明

compile_or_lookup (src/launch.jl) already compiles outside job_results_lock, but concurrent misses for the same job all compile: each requester runs emit_tile and its own tileiras, and the first result to be published wins. ObjCache.get! does not deduplicate in-flight work either.

On an RTX 5080, 8 tasks first-launching the same matmul configuration spawned tileiras 8 times for that job. tileiras takes 55–550 ms for the example kernels (fmha: 0.64 s, 133 MB RSS, single-threaded), against 1–27 ms for emit_tile, so every duplicate costs a full assembler run. With more tasks than cores, that also delays the first launch for everyone.

JuliaGPU/CUDA.jl#3398 handles the same situation for CUDA.jl's ptxas, with in-flight tracking modelled on Base.require's package_locks. Here it could go in compile_or_lookup, since cached_results(job) already returns one TileCompilerResults per job:

  • keep an IdDict{TileCompilerResults,Threads.Condition} guarded by job_results_lock, with every condition created on that lock;
  • under the lock: if res.cubin is set, return it; if an entry exists, wait on it and check again; otherwise register a condition and compile outside the lock;
  • under the lock, publish res.cubin, then remove the entry and notify (in a finally, so that after a failure the waiters retry instead of hanging);
  • waiters that end up with a published CUBIN call GPUCompiler.run_compile_hook(job), like hits do.

The in-flight state shouldn't live on TileCompilerResults itself, which is serialized into package images.

主要言語
Julia
スター
90
フォーク
13
平均マージ
4日 8時間
マージ済み PR(30日)
19

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

JuliaGPU/cuTile.jl のほかの issue

JuliaGPU/cuTile.jl の issue をすべて見る

似ている issue

Julia の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。