Skip to content

Commit

Permalink
[BACKEND] Update LLVM version to llvm/llvm-project@4e0a0ea (#4212)
Browse files Browse the repository at this point in the history
After
llvm/llvm-project@2c1ae80
`EffectInstance` needs an `OpOperand*`, `OpResult` or `BlockArgument` in
its constructor rather than a `Value`, so updated calls to those
constructors to match what upstream is doing.

This also adds the workflow fixes from @ptillet to make the llvm builds
work.
  • Loading branch information
gflegar authored Jul 18, 2024
1 parent 90fa818 commit e8873ae
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 92 deletions.
29 changes: 2 additions & 27 deletions .github/workflows/llvm-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ jobs:
config:
- {runner: 'Ubuntu 20.04', runs_on: 'ubuntu-20.04', target-os: 'ubuntu', arch: 'x64'}
- {runner: 'Ubuntu 20.04 ARM64', runs_on: 'ubuntu-20.04', target-os: 'ubuntu', arch: 'arm64'}
- {runner: 'CentOS 7', runs_on: ['self-hosted', 'CPU'], target-os: 'centos', arch: 'x64'}
- {runner: 'AlmaLinux 8', runs_on: ['self-hosted', 'CPU'], target-os: 'almalinux', arch: 'x64'}
- {runner: 'MacOS X64', runs_on: 'macos-12', target-os: 'macos', arch: 'x64'}
- {runner: 'MacOS ARM64', runs_on: 'macos-12', target-os: 'macos', arch: 'arm64'}
Expand Down Expand Up @@ -232,30 +231,6 @@ jobs:
tar czf "${{ env.llvm_install_dir }}.tar.gz" "${{ env.llvm_install_dir }}"
- name: Configure, Build, Test, and Install LLVM (CentOS)
if: matrix.config.target-os == 'centos'
run: |
# if this step crashes, it can leave behind a stale docker container
docker container prune -f
docker rmi -f $(docker images -q)
docker build --tag llvm-build --build-arg llvm_dir=llvm-project \
-f llvm-build/.github/workflows/llvm-build/centos.Dockerfile .
# Create temporary container to copy cache and installed artifacts.
CONTAINER_ID=$(docker create llvm-build)
docker cp "${CONTAINER_ID}:/install" "${{ env.llvm_install_dir }}"
tar czf "${{ env.llvm_install_dir }}.tar.gz" "${{ env.llvm_install_dir }}"
# We remove the existing directory, otherwise docker will
# create a subdirectory inside the existing directory.
rm -rf "${{ env.SCCACHE_DIR }}"
docker cp "${CONTAINER_ID}:/sccache" "${{ env.SCCACHE_DIR }}"
sudo chown -R "$(id -u -n):$(id -g -n)" "${{ env.SCCACHE_DIR }}"
docker rm "${CONTAINER_ID}"
- name: Configure, Build, Test, and Install LLVM (AlmaLinux)
if: matrix.config.target-os == 'almalinux'
run: |
Expand Down Expand Up @@ -297,9 +272,9 @@ jobs:
- name: Upload LLVM Artifacts to Azure
if: ${{ (github.repository == 'triton-lang/triton') }}
run: |
az storage blob upload --account-name tritonlang --auth-mode login --container-name llvm-builds --file "${{ env.llvm_install_dir }}.tar.gz" --name "${{ env.llvm_install_dir }}.tar.gz" --overwrite
az storage blob upload --account-name oaitriton --auth-mode login --container-name public --file "${{ env.llvm_install_dir }}.tar.gz" --name "llvm-builds/${{ env.llvm_install_dir }}.tar.gz" --overwrite
URL=$(az storage blob url --account-name tritonlang --auth-mode login --container-name llvm-builds --name "${{ env.llvm_install_dir }}.tar.gz")
URL=$(az storage blob url --account-name oaitriton --auth-mode login --container-name public --name "llvm-builds/${{ env.llvm_install_dir }}.tar.gz")
echo "Blob URL: ${URL}"
- name: Azure Logout
Expand Down
43 changes: 0 additions & 43 deletions .github/workflows/llvm-build/centos.Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion cmake/llvm-hash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
657ec7320d8a28171755ba0dd5afc570a5a16791
4e0a0eae58f7a6998866719f7eb970096a2a52e9
2 changes: 1 addition & 1 deletion lib/Dialect/Triton/IR/Ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace triton {
void LoadOp::getEffects(
SmallVectorImpl<SideEffects::EffectInstance<MemoryEffects::Effect>>
&effects) {
effects.emplace_back(MemoryEffects::Read::get(), getPtr(),
effects.emplace_back(MemoryEffects::Read::get(), &getPtrMutable(),
triton::GlobalMemory::get());
if (getIsVolatile())
effects.emplace_back(MemoryEffects::Write::get(),
Expand Down
11 changes: 6 additions & 5 deletions lib/Dialect/TritonGPU/IR/Dialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2879,7 +2879,8 @@ void LocalAllocOp::getEffects(
effects.emplace_back(MemoryEffects::Allocate::get(),
mlir::triton::gpu::SharedMemory::get());
if (getSrc())
effects.emplace_back(MemoryEffects::Write::get(), getResult(),
effects.emplace_back(MemoryEffects::Write::get(),
getOperation()->getOpResult(0),
mlir::triton::gpu::SharedMemory::get());
}

Expand Down Expand Up @@ -2917,7 +2918,7 @@ LogicalResult LocalAllocOp::verify() {
void LocalLoadOp::getEffects(
SmallVectorImpl<SideEffects::EffectInstance<MemoryEffects::Effect>>
&effects) {
effects.emplace_back(MemoryEffects::Read::get(), getSrc(),
effects.emplace_back(MemoryEffects::Read::get(), &getSrcMutable(),
mlir::triton::gpu::SharedMemory::get());
}

Expand All @@ -2931,7 +2932,7 @@ LogicalResult LocalStoreOp::verify() {
void LocalStoreOp::getEffects(
SmallVectorImpl<SideEffects::EffectInstance<MemoryEffects::Effect>>
&effects) {
effects.emplace_back(MemoryEffects::Write::get(), getDst(),
effects.emplace_back(MemoryEffects::Write::get(), &getDstMutable(),
mlir::triton::gpu::SharedMemory::get());
}

Expand All @@ -2945,9 +2946,9 @@ LogicalResult AsyncCopyGlobalToLocalOp::verify() {
void AsyncCopyGlobalToLocalOp::getEffects(
SmallVectorImpl<SideEffects::EffectInstance<MemoryEffects::Effect>>
&effects) {
effects.emplace_back(MemoryEffects::Read::get(), getSrc(),
effects.emplace_back(MemoryEffects::Read::get(), &getSrcMutable(),
mlir::triton::GlobalMemory::get());
effects.emplace_back(MemoryEffects::Write::get(), getResult(),
effects.emplace_back(MemoryEffects::Write::get(), &getResultMutable(),
mlir::triton::gpu::SharedMemory::get());
}

Expand Down
30 changes: 15 additions & 15 deletions lib/Dialect/TritonNvidiaGPU/IR/Ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ mlir::LogicalResult WarpGroupDotOp::inferReturnTypes(
void WarpGroupDotOp::getEffects(
SmallVectorImpl<SideEffects::EffectInstance<MemoryEffects::Effect>>
&effects) {
auto a = getA();
auto b = getB();
if (isa<MemDescType>(a.getType()))
effects.emplace_back(MemoryEffects::Read::get(), a,
auto &a = getAMutable();
auto &b = getBMutable();
if (isa<MemDescType>(a.get().getType()))
effects.emplace_back(MemoryEffects::Read::get(), &a,
mlir::triton::gpu::SharedMemory::get());
if (isa<MemDescType>(b.getType()))
effects.emplace_back(MemoryEffects::Read::get(), b,
if (isa<MemDescType>(b.get().getType()))
effects.emplace_back(MemoryEffects::Read::get(), &b,
mlir::triton::gpu::SharedMemory::get());
}

Expand Down Expand Up @@ -99,7 +99,7 @@ LogicalResult InitBarrierOp::verify() {
void InitBarrierOp::getEffects(
SmallVectorImpl<SideEffects::EffectInstance<MemoryEffects::Effect>>
&effects) {
effects.emplace_back(MemoryEffects::Write::get(), getAlloc(),
effects.emplace_back(MemoryEffects::Write::get(), &getAllocMutable(),
mlir::triton::gpu::SharedMemory::get());
}

Expand All @@ -113,7 +113,7 @@ LogicalResult InvalBarrierOp::verify() {
void InvalBarrierOp::getEffects(
SmallVectorImpl<SideEffects::EffectInstance<MemoryEffects::Effect>>
&effects) {
effects.emplace_back(MemoryEffects::Write::get(), getAlloc(),
effects.emplace_back(MemoryEffects::Write::get(), &getAllocMutable(),
mlir::triton::gpu::SharedMemory::get());
}

Expand All @@ -127,7 +127,7 @@ LogicalResult BarrierExpectOp::verify() {
void BarrierExpectOp::getEffects(
SmallVectorImpl<SideEffects::EffectInstance<MemoryEffects::Effect>>
&effects) {
effects.emplace_back(MemoryEffects::Write::get(), getAlloc(),
effects.emplace_back(MemoryEffects::Write::get(), &getAllocMutable(),
mlir::triton::gpu::SharedMemory::get());
}

Expand All @@ -141,7 +141,7 @@ LogicalResult WaitBarrierOp::verify() {
void WaitBarrierOp::getEffects(
SmallVectorImpl<SideEffects::EffectInstance<MemoryEffects::Effect>>
&effects) {
effects.emplace_back(MemoryEffects::Read::get(), getAlloc(),
effects.emplace_back(MemoryEffects::Read::get(), &getAllocMutable(),
mlir::triton::gpu::SharedMemory::get());
// Need a side effect to prevent compiler from reordering and removing
// the wait operation.
Expand All @@ -163,21 +163,21 @@ LogicalResult AsyncTMACopyGlobalToLocalOp::verify() {
void AsyncTMACopyGlobalToLocalOp::getEffects(
SmallVectorImpl<SideEffects::EffectInstance<MemoryEffects::Effect>>
&effects) {
effects.emplace_back(MemoryEffects::Read::get(), getDescPtr(),
effects.emplace_back(MemoryEffects::Read::get(), &getDescPtrMutable(),
mlir::triton::GlobalMemory::get());
effects.emplace_back(MemoryEffects::Write::get(), getBarrier(),
effects.emplace_back(MemoryEffects::Write::get(), &getBarrierMutable(),
mlir::triton::gpu::SharedMemory::get());
effects.emplace_back(MemoryEffects::Write::get(), getResult(),
effects.emplace_back(MemoryEffects::Write::get(), &getResultMutable(),
mlir::triton::gpu::SharedMemory::get());
}

// -- AsyncTMACopyLocalToGlobalOp --
void AsyncTMACopyLocalToGlobalOp::getEffects(
SmallVectorImpl<SideEffects::EffectInstance<MemoryEffects::Effect>>
&effects) {
effects.emplace_back(MemoryEffects::Write::get(), getDescPtr(),
effects.emplace_back(MemoryEffects::Write::get(), &getDescPtrMutable(),
mlir::triton::GlobalMemory::get());
effects.emplace_back(MemoryEffects::Read::get(), getSrc(),
effects.emplace_back(MemoryEffects::Read::get(), &getSrcMutable(),
mlir::triton::gpu::SharedMemory::get());
}

Expand Down
1 change: 1 addition & 0 deletions test/lib/Instrumentation/GPUHello.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Pass.h"
#include "llvm/Passes/PassBuilder.h"
Expand Down

0 comments on commit e8873ae

Please sign in to comment.