Skip to content

Implement CUDA support and GPU operations for tensor processing - #8

Merged
Alwaysproblem merged 34 commits into
mainfrom
cuda-tile
Mar 8, 2026
Merged

Implement CUDA support and GPU operations for tensor processing#8
Alwaysproblem merged 34 commits into
mainfrom
cuda-tile

Conversation

@Alwaysproblem

@AlwaysproblemAlwaysproblem commented Mar 8, 2026

Copy link
Copy Markdown
Owner

Pull request overview

This PR adds a CUDA/GPU-oriented path to the mlir/cuda-tile Toy-based compiler flow, including a new matmul op, GPU outlining, and a pass to emit/embed CUDA Tile binaries, plus assorted scripts and sample MLIR/Toy programs to exercise the pipeline.

Changes:

  • Add Toy dialect/compiler extensions: matmul op + lowering, GPU outlining (toy.launch_gpu/toy.gpu_func), and a CUDA Tile emission/embedding pass.
  • Add build/sync scripts, devcontainer configuration, and VS Code configs to stand up a CUDA/MLIR development environment.
  • Add sample .toy/.mlir programs and CUDA shim/kernel sources demonstrating GPU execution.

Reviewed changes

Copilot reviewed 73 out of 73 changed files in this pull request and generated 12 comments.

Show a summary per file
FileDescription
mlir/cuda-tile/vscode/settings.jsonVS Code CMake/C++ tooling configuration for the project.
mlir/cuda-tile/vscode/launch.jsonVS Code debug launch configuration.
mlir/cuda-tile/vscode/cmake-kits.jsonCMake Tools kit definition for the workspace.
mlir/cuda-tile/vscode/c_cpp_properties.jsonIntelliSense configuration for the workspace.
mlir/cuda-tile/vscode/.zsh_historyAdded shell history file (should not be committed).
mlir/cuda-tile/vscode/.initial_container.shHelper script to start a CUDA-enabled dev container.
mlir/cuda-tile/scripts/update.shScript to sync/update tutorial sources from LLVM examples.
mlir/cuda-tile/scripts/sync_deps.shScript to clone/sync LLVM + cuda-tile dependencies.
mlir/cuda-tile/scripts/patch/matmul.patchPatch capturing matmul-related changes against upstream tutorial chapters.
mlir/cuda-tile/scripts/patch/matmul.back.patchAlternate/back patch variant for matmul changes.
mlir/cuda-tile/scripts/make_patch.shScript to generate the chapter diff patch.
mlir/cuda-tile/scripts/build_deps.shScript to configure/build/install LLVM+MLIR with CUDA runner enabled.
mlir/cuda-tile/scripts/build_cuda_tile.shScript to build/install the external cuda-tile dependency.
mlir/cuda-tile/scripts/apply_patch.shScript to apply the provided chapter patch to a local copy.
mlir/cuda-tile/sample/validation.pyNumpy validation snippet for matmul results.
mlir/cuda-tile/sample/test.mlirSample MLIR module using CUDA shim calls.
mlir/cuda-tile/sample/matmul_numpy.pyNumpy reference implementation for Toy examples.
mlir/cuda-tile/sample/matmul.toy.mlirSample Toy-MLIR for a matmul/transpose case.
mlir/cuda-tile/sample/matmul.toySample Toy source including matmul usage.
mlir/cuda-tile/sample/lowering-llvm.shScript to lower MLIR to LLVM dialect/IR and link with CUDA shim.
mlir/cuda-tile/sample/gpu.mlirSample MLIR using toy.gpu_func + toy.launch_gpu.
mlir/cuda-tile/sample/gpu-func.mlirExpanded host-side CUDA shim sample for launching a kernel.
mlir/cuda-tile/sample/example.toyMinimal Toy example program.
mlir/cuda-tile/sample/cuda-tile.mlirSample MLIR including a cuda_tile.module entry.
mlir/cuda-tile/explore/run.shExperimental script for GPU lowering to NVVM/LLVM IR.
mlir/cuda-tile/explore/outlined.mlirSample MLIR with GPU kernel outlining results.
mlir/cuda-tile/explore/gpu.mlirExperimental MLIR showing gpu.* dialect usage.
mlir/cuda-tile/explore/extern_fun.mlirExperimental MLIR for external/shim function calls.
mlir/cuda-tile/cuda_shim/vector_add.cuCUDA kernel source used for PTX generation testing.
mlir/cuda-tile/cuda_shim/outlined_gpu_kernel.cuCUDA kernels corresponding to outlined Toy GPU subgraphs.
mlir/cuda-tile/cuda_shim/load_ptx_main.cppMinimal C++ demo to load PTX and launch via shim ABI.
mlir/cuda-tile/build_with_conda.shBuild helper for conda-based environments.
mlir/cuda-tile/build.shBuild helper for non-conda environments.
mlir/cuda-tile/Toy/parser/AST.cppToy AST dumper implementation (copied/ported from tutorial).
mlir/cuda-tile/Toy/mlir/ToyCombine.tdTableGen DRR patterns for Toy canonicalization.
mlir/cuda-tile/Toy/mlir/ToyCombine.cppC++ canonicalization patterns registration.
mlir/cuda-tile/Toy/mlir/ShapeInferencePass.cppShape inference pass implementation.
mlir/cuda-tile/Toy/mlir/MLIRGen.cppMLIR generation updates including matmul emission.
mlir/cuda-tile/Toy/mlir/LowerToLLVM.cppLowering pipeline from Toy/Affine/SCF to LLVM dialect.
mlir/cuda-tile/Toy/mlir/LowerToGpu.cppPass to outline GPU-eligible Toy op subgraphs into toy.gpu_func.
mlir/cuda-tile/Toy/mlir/EmitCudaTile.cppPass to write CUDA Tile bytecode, run tileiras, and annotate launches with CUDA binary metadata.
mlir/cuda-tile/Toy/include/toy/ShapeInferenceInterface.tdShape inference op interface definition (TableGen).
mlir/cuda-tile/Toy/include/toy/ShapeInferenceInterface.hGenerated interface header inclusion wrapper.
mlir/cuda-tile/Toy/include/toy/Passes.hPass factory declarations (incl. GPU/cuda-tile passes).
mlir/cuda-tile/Toy/include/toy/Parser.hToy parser implementation header.
mlir/cuda-tile/Toy/include/toy/Ops.tdToy ODS op definitions (adds matmul, launch_gpu, gpu_func).
mlir/cuda-tile/Toy/include/toy/MLIRGen.hMLIRGen API header.
mlir/cuda-tile/Toy/include/toy/Lexer.hToy lexer header.
mlir/cuda-tile/Toy/include/toy/Dialect.hToy dialect + op/interface includes.
mlir/cuda-tile/Toy/include/toy/CMakeLists.txtTableGen targets for Toy dialect/ops/interfaces.
mlir/cuda-tile/Toy/include/toy/AST.hToy AST node definitions.
mlir/cuda-tile/Toy/include/cuda_shim/SupportOps.hppDefines which Toy ops are considered GPU-eligible by the outlining pass.
mlir/cuda-tile/Toy/include/CMakeLists.txtAdds Toy include subdirectory.
mlir/cuda-tile/Toy/cuda_wrapper/CMakeLists.txtBuilds the CUDA shim wrapper library.
mlir/cuda-tile/Toy/CMakeLists.txtBuilds toy-cuda tool and wires MLIR/CUDA Tile deps.
mlir/cuda-tile/CMakeLists.txtTop-level CMake config for the cuda-tile MLIR/Toy project.
mlir/cuda-tile/.pre-commit-config.yamlPre-commit hooks config (clang-format/cmake-format/etc.).
mlir/cuda-tile/.gitignoreIgnores CUDA/LLVM build artifacts and generated binaries.
mlir/cuda-tile/.envsetup.shConda activation helper script.
mlir/cuda-tile/.devcontainer/noop.txtPlaceholder to satisfy devcontainer COPY steps.
mlir/cuda-tile/.devcontainer/devcontainer.jsonDevcontainer config for CUDA/MLIR development.
mlir/cuda-tile/.devcontainer/DockerfileDevcontainer image definition with LLVM/Clang/CUDA tooling.
mlir/cuda-tile/.clang-formatClang-format configuration for this subproject.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@AlwaysproblemAlwaysproblem self-assigned this Mar 8, 2026
CopilotAI review requested due to automatic review settings March 8, 2026 02:08

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a CUDA/GPU-oriented path to the mlir/cuda-tile Toy-based compiler flow, including a new matmul op, GPU outlining, and a pass to emit/embed CUDA Tile binaries, plus assorted scripts and sample MLIR/Toy programs to exercise the pipeline.

Changes:

  • Add Toy dialect/compiler extensions: matmul op + lowering, GPU outlining (toy.launch_gpu/toy.gpu_func), and a CUDA Tile emission/embedding pass.
  • Add build/sync scripts, devcontainer configuration, and VS Code configs to stand up a CUDA/MLIR development environment.
  • Add sample .toy/.mlir programs and CUDA shim/kernel sources demonstrating GPU execution.

Reviewed changes

Copilot reviewed 73 out of 73 changed files in this pull request and generated 12 comments.

Show a summary per file
FileDescription
mlir/cuda-tile/vscode/settings.jsonVS Code CMake/C++ tooling configuration for the project.
mlir/cuda-tile/vscode/launch.jsonVS Code debug launch configuration.
mlir/cuda-tile/vscode/cmake-kits.jsonCMake Tools kit definition for the workspace.
mlir/cuda-tile/vscode/c_cpp_properties.jsonIntelliSense configuration for the workspace.
mlir/cuda-tile/vscode/.zsh_historyAdded shell history file (should not be committed).
mlir/cuda-tile/vscode/.initial_container.shHelper script to start a CUDA-enabled dev container.
mlir/cuda-tile/scripts/update.shScript to sync/update tutorial sources from LLVM examples.
mlir/cuda-tile/scripts/sync_deps.shScript to clone/sync LLVM + cuda-tile dependencies.
mlir/cuda-tile/scripts/patch/matmul.patchPatch capturing matmul-related changes against upstream tutorial chapters.
mlir/cuda-tile/scripts/patch/matmul.back.patchAlternate/back patch variant for matmul changes.
mlir/cuda-tile/scripts/make_patch.shScript to generate the chapter diff patch.
mlir/cuda-tile/scripts/build_deps.shScript to configure/build/install LLVM+MLIR with CUDA runner enabled.
mlir/cuda-tile/scripts/build_cuda_tile.shScript to build/install the external cuda-tile dependency.
mlir/cuda-tile/scripts/apply_patch.shScript to apply the provided chapter patch to a local copy.
mlir/cuda-tile/sample/validation.pyNumpy validation snippet for matmul results.
mlir/cuda-tile/sample/test.mlirSample MLIR module using CUDA shim calls.
mlir/cuda-tile/sample/matmul_numpy.pyNumpy reference implementation for Toy examples.
mlir/cuda-tile/sample/matmul.toy.mlirSample Toy-MLIR for a matmul/transpose case.
mlir/cuda-tile/sample/matmul.toySample Toy source including matmul usage.
mlir/cuda-tile/sample/lowering-llvm.shScript to lower MLIR to LLVM dialect/IR and link with CUDA shim.
mlir/cuda-tile/sample/gpu.mlirSample MLIR using toy.gpu_func + toy.launch_gpu.
mlir/cuda-tile/sample/gpu-func.mlirExpanded host-side CUDA shim sample for launching a kernel.
mlir/cuda-tile/sample/example.toyMinimal Toy example program.
mlir/cuda-tile/sample/cuda-tile.mlirSample MLIR including a cuda_tile.module entry.
mlir/cuda-tile/explore/run.shExperimental script for GPU lowering to NVVM/LLVM IR.
mlir/cuda-tile/explore/outlined.mlirSample MLIR with GPU kernel outlining results.
mlir/cuda-tile/explore/gpu.mlirExperimental MLIR showing gpu.* dialect usage.
mlir/cuda-tile/explore/extern_fun.mlirExperimental MLIR for external/shim function calls.
mlir/cuda-tile/cuda_shim/vector_add.cuCUDA kernel source used for PTX generation testing.
mlir/cuda-tile/cuda_shim/outlined_gpu_kernel.cuCUDA kernels corresponding to outlined Toy GPU subgraphs.
mlir/cuda-tile/cuda_shim/load_ptx_main.cppMinimal C++ demo to load PTX and launch via shim ABI.
mlir/cuda-tile/build_with_conda.shBuild helper for conda-based environments.
mlir/cuda-tile/build.shBuild helper for non-conda environments.
mlir/cuda-tile/Toy/parser/AST.cppToy AST dumper implementation (copied/ported from tutorial).
mlir/cuda-tile/Toy/mlir/ToyCombine.tdTableGen DRR patterns for Toy canonicalization.
mlir/cuda-tile/Toy/mlir/ToyCombine.cppC++ canonicalization patterns registration.
mlir/cuda-tile/Toy/mlir/ShapeInferencePass.cppShape inference pass implementation.
mlir/cuda-tile/Toy/mlir/MLIRGen.cppMLIR generation updates including matmul emission.
mlir/cuda-tile/Toy/mlir/LowerToLLVM.cppLowering pipeline from Toy/Affine/SCF to LLVM dialect.
mlir/cuda-tile/Toy/mlir/LowerToGpu.cppPass to outline GPU-eligible Toy op subgraphs into toy.gpu_func.
mlir/cuda-tile/Toy/mlir/EmitCudaTile.cppPass to write CUDA Tile bytecode, run tileiras, and annotate launches with CUDA binary metadata.
mlir/cuda-tile/Toy/include/toy/ShapeInferenceInterface.tdShape inference op interface definition (TableGen).
mlir/cuda-tile/Toy/include/toy/ShapeInferenceInterface.hGenerated interface header inclusion wrapper.
mlir/cuda-tile/Toy/include/toy/Passes.hPass factory declarations (incl. GPU/cuda-tile passes).
mlir/cuda-tile/Toy/include/toy/Parser.hToy parser implementation header.
mlir/cuda-tile/Toy/include/toy/Ops.tdToy ODS op definitions (adds matmul, launch_gpu, gpu_func).
mlir/cuda-tile/Toy/include/toy/MLIRGen.hMLIRGen API header.
mlir/cuda-tile/Toy/include/toy/Lexer.hToy lexer header.
mlir/cuda-tile/Toy/include/toy/Dialect.hToy dialect + op/interface includes.
mlir/cuda-tile/Toy/include/toy/CMakeLists.txtTableGen targets for Toy dialect/ops/interfaces.
mlir/cuda-tile/Toy/include/toy/AST.hToy AST node definitions.
mlir/cuda-tile/Toy/include/cuda_shim/SupportOps.hppDefines which Toy ops are considered GPU-eligible by the outlining pass.
mlir/cuda-tile/Toy/include/CMakeLists.txtAdds Toy include subdirectory.
mlir/cuda-tile/Toy/cuda_wrapper/CMakeLists.txtBuilds the CUDA shim wrapper library.
mlir/cuda-tile/Toy/CMakeLists.txtBuilds toy-cuda tool and wires MLIR/CUDA Tile deps.
mlir/cuda-tile/CMakeLists.txtTop-level CMake config for the cuda-tile MLIR/Toy project.
mlir/cuda-tile/.pre-commit-config.yamlPre-commit hooks config (clang-format/cmake-format/etc.).
mlir/cuda-tile/.gitignoreIgnores CUDA/LLVM build artifacts and generated binaries.
mlir/cuda-tile/.envsetup.shConda activation helper script.
mlir/cuda-tile/.devcontainer/noop.txtPlaceholder to satisfy devcontainer COPY steps.
mlir/cuda-tile/.devcontainer/devcontainer.jsonDevcontainer config for CUDA/MLIR development.
mlir/cuda-tile/.devcontainer/DockerfileDevcontainer image definition with LLVM/Clang/CUDA tooling.
mlir/cuda-tile/.clang-formatClang-format configuration for this subproject.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadmlir/cuda-tile/vscode/.zsh_history
Comment threadmlir/cuda-tile/vscode/settings.json
Comment threadmlir/cuda-tile/vscode/settings.json
Comment threadmlir/cuda-tile/CMakeLists.txt
Comment threadmlir/cuda-tile/vscode/settings.json
Comment threadmlir/cuda-tile/vscode/settings.json
Comment threadmlir/cuda-tile/.envsetup.sh
Comment threadmlir/cuda-tile/explore/run.sh
Comment threadmlir/cuda-tile/Toy/mlir/EmitCudaTile.cpp Outdated
Comment threadmlir/cuda-tile/Toy/mlir/EmitCudaTile.cpp Outdated
Alwaysproblemand others added 3 commits March 8, 2026 17:41
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Alwaysproblem
Alwaysproblem merged commit 8a28372 into mainMar 8, 2026
0 of 3 checks passed
@Alwaysproblem
Alwaysproblem deleted the cuda-tile branch March 8, 2026 10:13
Sign up for freeto 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.

2 participants

@Alwaysproblem