IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

Mojo function

derive_drain_mask

derive_drain_mask(program: PipelineProgram, config: PipelineConfig) -> Int

Derive per-block lgkm drain mask from block content analysis.

Drains LDS reads (wait_lgkm(0)) before DRAM→LDS writes when a block's fragment loads and global loads target different channels. This avoids LDS port contention between concurrent reads and writes to different LDS regions.

Skips the drain when fragment loads and the global load share the same channel — sequential access to the same LDS region has less contention.

Returns a bitmask where bit i=1 means block i should drain lgkm before its global loads.

Returns:

Int