Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
3679d7a
Inital commits
Alwaysproblem Dec 29, 2025
e3204ff
Make ch6 works
Alwaysproblem Dec 29, 2025
2b310d3
Added Matmul Toy Op
Alwaysproblem Dec 29, 2025
ca1bd69
Added the validation for cuda tile
Alwaysproblem Dec 30, 2025
afe7997
Try gpu and failed
Alwaysproblem Dec 31, 2025
88ce121
update the build dep
Alwaysproblem Dec 31, 2025
8a0ba30
Change float type to FP32
Alwaysproblem Dec 31, 2025
8be2741
Added the GPU C API
Alwaysproblem Jan 1, 2026
7e1f45c
Added the GPU related operation
Alwaysproblem Jan 1, 2026
37800da
Create the gpu outline pass
Alwaysproblem Jan 2, 2026
fd70514
Added Affine pass code
Alwaysproblem Jan 2, 2026
60b8083
Added the EntryOp for cuda tile IR
Alwaysproblem Jan 3, 2026
d12717f
Sync the command line history
Alwaysproblem Jan 3, 2026
bdb9a66
Added devcontainer
Alwaysproblem Jan 3, 2026
07c722f
Added the make tensor view
Alwaysproblem Jan 5, 2026
43b2739
Sync
Alwaysproblem Jan 11, 2026
0a3ccf4
Added the return, add, mul lowering
Alwaysproblem Jan 29, 2026
f2d06f6
Added the pass that can compile cuda tile IR
Alwaysproblem Feb 4, 2026
99596b0
Verified the cuda shim API and POC is ready for the cuda shim
Alwaysproblem Feb 12, 2026
80e2354
sync the progress not finish
Alwaysproblem Feb 27, 2026
034cc87
upload file
Alwaysproblem Feb 27, 2026
5007d48
sync
Alwaysproblem Feb 27, 2026
b9cfa7e
Sync: added the getglobal memref
Alwaysproblem Mar 1, 2026
dbf81a7
Added the input and allocation for the cuda shim
Alwaysproblem Mar 1, 2026
96a122c
Tested with cuda 12.x cubin worked
Alwaysproblem Mar 2, 2026
b2e34d0
Move the helper function into cuda shim builder
Alwaysproblem Mar 2, 2026
45a5e01
Tested on the GPU RTX4090 with cuda 12.x
Alwaysproblem Mar 5, 2026
8ad69b7
Tested on the RTX4090
Alwaysproblem Mar 7, 2026
5cdabd4
Update ReadMe
Alwaysproblem Mar 7, 2026
1d98f48
Tested on RTX5090
Alwaysproblem Mar 8, 2026
d41cea8
Test on RTX4090 after grid change
Alwaysproblem Mar 8, 2026
87330ea
Update mlir/cuda-tile/Toy/mlir/EmitCudaTile.cpp
Alwaysproblem Mar 8, 2026
c7b1673
Update mlir/cuda-tile/Toy/mlir/EmitCudaTile.cpp
Alwaysproblem Mar 8, 2026
bcb8038
Fix the comments from github copilot
Alwaysproblem Mar 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions mlir/cuda-tile/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
BasedOnStyle: LLVM
LineEnding: LF
IndentWidth: 2
TabWidth: 2
UseTab: Never
41 changes: 41 additions & 0 deletions mlir/cuda-tile/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM alwaysproblem/fastdev-u2204:nv13.1.0

ARG UID=1000
ARG GID=1000

RUN echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy main" > /etc/apt/sources.list.d/llvm.list \
&& echo "deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy main" >> /etc/apt/sources.list.d/llvm.list \
&& echo "# 20" >> /etc/apt/sources.list.d/llvm.list \
&& echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-20 main" >> /etc/apt/sources.list.d/llvm.list \
&& echo "deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-20 main" >> /etc/apt/sources.list.d/llvm.list \
&& echo "# 21" >> /etc/apt/sources.list.d/llvm.list \
&& echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-21 main" >> /etc/apt/sources.list.d/llvm.list \
&& echo "deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-21 main" >> /etc/apt/sources.list.d/llvm.list \
&& wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc \
&& apt update -y && \
apt install -y \
python3 python3-dev python3-setuptools python3-pip \
libtinfo-dev zlib1g-dev \
build-essential cmake ninja-build \
clang-20 clang-tidy-20 clangd-20 cmake-format \
clang-format-20 lldb-20 lld-20 libfmt-dev libspdlog-dev \
&& apt clean -y && rm -rf /var/lib/apt/lists/* \
&& update-alternatives --install /usr/bin/clang clang /usr/bin/clang-20 100 \
&& update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-20 100 \
&& update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-20 100 \
&& update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-20 100 \
&& update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-20 100 \
&& update-alternatives --install /usr/bin/lld lld /usr/bin/lld-20 100 \
&& update-alternatives --install /usr/bin/lldb lldb /usr/bin/lldb-20 100

RUN apt update -y && apt install -yq software-properties-common \
&& add-apt-repository -y ppa:ubuntu-toolchain-r/test \
&& apt update -yq \
&& apt install -yq gcc-13 g++-13 gdb \
&& update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 100 \
&& update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 100 \
&& apt clean -y && rm -rf /var/lib/apt/lists/*

RUN git config --global --add safe.directory '*' && \
/root/.local/bin/setup_new_user ${UID} ${GID} && \
python3 -m pip install pre-commit compdb
77 changes: 77 additions & 0 deletions mlir/cuda-tile/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/anaconda
{
"remoteUser": "root",
"name": "mlir-example",
"workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder}/../../../MLcompiler-tutorial/mlir/${localWorkspaceFolderBasename},type=bind",
"workspaceFolder": "/root/Desktop/dockerVolumn/MLcompiler-tutorial/mlir/${localWorkspaceFolderBasename}",
"build": {
"context": "${localWorkspaceFolder}/.devcontainer",
"dockerfile": "Dockerfile",
"options": [
"--network=host"
],
"args": {
"UID": "1000",
"GID": "1000"
}
},
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "python --version",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
"privileged": true,
// "capAdd": ["SYS_PTRACE"],
"mounts": [
{
"source": "${localWorkspaceFolder}/../../../",
"target": "/root/Desktop/dockerVolumn",
"type": "bind"
}
],
"runArgs": [
// "--cap-add=SYS_PTRACE",
// "--security-opt",
// "seccomp=unconfined",
"--name",
// "${localEnv:USER}-tvm",
"yyx-cuda-tile",
// "-v",
// "/data/rech/yongxiy/Desktop/dockerVolumn:/root/Desktop/dockerVolumn"
],
"customizations": {
"vscode": {
"extensions": [
"jeff-hykin.better-cpp-syntax",
"aaron-bond.better-comments",
"ms-vscode.cpptools-themes",
"revng.llvm-ir",
"jakob-erzar.llvm-tablegen",
"MomenAbdelkarim-WyattCalandro-LuisPrieto.mlir",
"ms-vscode.cpptools",
"ms-vscode.cpptools-extension-pack",
"twxs.cmake",
"josetr.cmake-language-support-vscode",
"ms-vscode.cmake-tools",
"cheshirekow.cmake-format",
"yzhang.markdown-all-in-one",
"bierner.markdown-preview-github-styles",
"bierner.markdown-mermaid",
"DavidAnson.vscode-markdownlint",
"llvm-vs-code-extensions.vscode-mlir",
"llvm-vs-code-extensions.vscode-clangd",
"llvm-vs-code-extensions.lldb-dap",
"mutantdino.resourcemonitor",
"hoovercj.vscode-power-mode",
"GitHub.copilot-chat",
"Codereviewforgithubcopilot.github-copilot-code-review"
]
}
}
}
3 changes: 3 additions & 0 deletions mlir/cuda-tile/.devcontainer/noop.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This file copied into the container along with environment.yml* from the parent
folder. This file is included to prevents the Dockerfile COPY instruction from
failing if no environment.yml is found.
1 change: 1 addition & 0 deletions mlir/cuda-tile/.envsetup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source /root/miniconda3/etc/profile.d/conda.sh && conda activate mlir
18 changes: 18 additions & 0 deletions mlir/cuda-tile/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
*.ptx
*.cubin
*.fatbin
*.bc
*.ll
*.o
*.s
*.so
*.dylib
*.a
*.dll
*.obj
*.exe
*.log
*.cache
*.tmp
*.bin
*.out
19 changes: 19 additions & 0 deletions mlir/cuda-tile/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-yaml
- id: trailing-whitespace
- id: end-of-file-fixer

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: 'v14.0.6'
hooks:
- id: clang-format
types_or: [c++, c]

- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.10
hooks:
- id: cmake-format
- id: cmake-lint
45 changes: 45 additions & 0 deletions mlir/cuda-tile/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
cmake_minimum_required(VERSION 3.10)

# note: fix ztd terminfo not found
project(cuda-tile LANGUAGES C CXX)

# ############## For conda users.################################
find_package(LLVM CONFIG REQUIRED)
find_package(MLIR CONFIG REQUIRED)
# set(MLIR_TABLEGEN_EXE /root/anaconda3/envs/mlir/bin/mlir-tblgen)
# ##############################################################################

message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
message(STATUS "Found MLIR ${MLIR_PACKAGE_VERSION}")
message(STATUS "Using MLIRConfig.cmake in: ${MLIR_DIR}")
message(STATUS "Found MLIRTableGen: ${MLIR_TABLEGEN_EXE}")
message(STATUS "LLVM_INCLUDE_DIR include dir: ${LLVM_INCLUDE_DIR}")
message(STATUS "MLIR_INCLUDE_DIR include dir: ${MLIR_INCLUDE_DIR}")

# This is for non-conda users.
find_package(LLVM CONFIG PATHS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/lib/cmake/llvm)
find_package(MLIR CONFIG PATHS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/lib/cmake/mlir)
find_package(CUDAToolkit REQUIRED)
# set(MLIR_TABLEGEN_EXE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/bin/mlir-tblgen)
message(STATUS "CUDA Toolkit found: ${CUDAToolkit_INCLUDE_DIRS}")
message(STATUS "CUDA_TILE_SOURCE_DIR include dir: ${CUDA_TILE_SOURCE_DIR}")
message(STATUS "CUDA_TILE_BINARY_DIR include dir: ${CUDA_TILE_BINARY_DIR}")

include_directories(${LLVM_INCLUDE_DIR})
include_directories(${MLIR_INCLUDE_DIR})
include_directories(${CUDAToolkit_INCLUDE_DIRS})
include_directories(${CUDA_TILE_SOURCE_DIR}/include)
include_directories(${CUDA_TILE_BINARY_DIR}/include)

include(LLVMDistributionSupport)
include(TableGen)
include(AddMLIR)
include(AddLLVM)
# include(HandleLLVMOptions)

# note: fix the llvm::cl undefined reference problem
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -fno-rtti")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")

add_subdirectory(Toy)
Loading
Loading