Skip to content

Separate ordinary materialization from GPU materialization, examples on how to run naive matmul using both - #142

Closed
mstn wants to merge 3 commits into
marco/gpufrom
marco/materialize/rework
Closed

Separate ordinary materialization from GPU materialization, examples on how to run naive matmul using both#142
mstn wants to merge 3 commits into
marco/gpufrom
marco/materialize/rework

Conversation

@mstn

@mstn mstn commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Description

Previously, ordinary materialize implicitly launched a GPU kernel. This mixed functional buffer construction with GPU scheduling and made it difficult to distinguish a normal materialization from an explicitly parallel one.

The PR separates these responsibilities:

  • Ordinary materialize now follows the functional interpretation:

    for i in 0 .. size:
        output[i] = producer(i)
    

    Codegen lowers it to a sequential host loop without a kernel launch or device synchronization.

  • gpu.materialize remains the explicit GPU operation. It takes launch parameters and schedules one kernel invocation per logical thread.

  • The existing naive matmul uses ordinary materialize.

  • A new GPU naive matmul uses the same matrix-view and cell-dot logic through gpu.materialize, making the scheduling choice explicit.

Only nested gpu.materialize are not allowed because we don't want to launch kernels from a kernel for now.

Tests

  • Ordinary materialize with naive matmul:

    • Checks the numerical matrix-multiplication result.
    • Verifies codegen emits a sequential host loop.
    • Verifies no GPU kernel launch or device synchronization is generated.
  • gpu.materialize with naive matmul:

    • Checks the numerical result against the expected matrix.
    • Verifies codegen emits a GPU kernel, explicit launch, and synchronization.
  • gpu.materialize with tiled matmul:

    • Tests multiple output and inner tiles.
    • Tests identity matrices supplied directly as closures on either side.
    • Checks all numerical results.
    • Verifies cooperative shared-memory loads and block synchronization are generated.

@mstn mstn self-assigned this Jul 31, 2026
@mstn mstn changed the title Materialize shouldn't launch kernel Add view-based tiled matmul and separate sequential from GPU materialization Jul 31, 2026
@mstn mstn changed the title Add view-based tiled matmul and separate sequential from GPU materialization Separate ordinary materialization from GPU materialization, examples on how to run naive matmul using both Jul 31, 2026
@mstn
mstn requested a review from statusfailed July 31, 2026 09:05
@statusfailed statusfailed mentioned this pull request Aug 3, 2026
@mstn

mstn commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

outdated after #152

@mstn mstn closed this Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant