generated from Alwaysproblem/init-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Implement CUDA support and GPU operations for tensor processing #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
3679d7a
Inital commits
Alwaysproblem e3204ff
Make ch6 works
Alwaysproblem 2b310d3
Added Matmul Toy Op
Alwaysproblem ca1bd69
Added the validation for cuda tile
Alwaysproblem afe7997
Try gpu and failed
Alwaysproblem 88ce121
update the build dep
Alwaysproblem 8a0ba30
Change float type to FP32
Alwaysproblem 8be2741
Added the GPU C API
Alwaysproblem 7e1f45c
Added the GPU related operation
Alwaysproblem 37800da
Create the gpu outline pass
Alwaysproblem fd70514
Added Affine pass code
Alwaysproblem 60b8083
Added the EntryOp for cuda tile IR
Alwaysproblem d12717f
Sync the command line history
Alwaysproblem bdb9a66
Added devcontainer
Alwaysproblem 07c722f
Added the make tensor view
Alwaysproblem 43b2739
Sync
Alwaysproblem 0a3ccf4
Added the return, add, mul lowering
Alwaysproblem f2d06f6
Added the pass that can compile cuda tile IR
Alwaysproblem 99596b0
Verified the cuda shim API and POC is ready for the cuda shim
Alwaysproblem 80e2354
sync the progress not finish
Alwaysproblem 034cc87
upload file
Alwaysproblem 5007d48
sync
Alwaysproblem b9cfa7e
Sync: added the getglobal memref
Alwaysproblem dbf81a7
Added the input and allocation for the cuda shim
Alwaysproblem 96a122c
Tested with cuda 12.x cubin worked
Alwaysproblem b2e34d0
Move the helper function into cuda shim builder
Alwaysproblem 45a5e01
Tested on the GPU RTX4090 with cuda 12.x
Alwaysproblem 8ad69b7
Tested on the RTX4090
Alwaysproblem 5cdabd4
Update ReadMe
Alwaysproblem 1d98f48
Tested on RTX5090
Alwaysproblem d41cea8
Test on RTX4090 after grid change
Alwaysproblem 87330ea
Update mlir/cuda-tile/Toy/mlir/EmitCudaTile.cpp
Alwaysproblem c7b1673
Update mlir/cuda-tile/Toy/mlir/EmitCudaTile.cpp
Alwaysproblem bcb8038
Fix the comments from github copilot
Alwaysproblem File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| BasedOnStyle: LLVM | ||
| LineEnding: LF | ||
| IndentWidth: 2 | ||
| TabWidth: 2 | ||
| UseTab: Never |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| ] | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| source /root/miniconda3/etc/profile.d/conda.sh && conda activate mlir | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
Alwaysproblem marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # 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) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.