-
Notifications
You must be signed in to change notification settings - Fork 645
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tuner]:Add a utility function to query supported MMA intrinsics
Signed-off-by: Bangtian Liu <[email protected]>
- Loading branch information
1 parent
fa6aa1c
commit 8d86018
Showing
9 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
48 changes: 48 additions & 0 deletions
48
compiler/src/iree/compiler/Codegen/LLVMGPU/TestLLVMGPUQueryMMAPass.cpp
This file contains 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,48 @@ | ||
// Copyright 2024 The IREE Authors | ||
// | ||
// Licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#include "iree/compiler/Codegen/LLVMGPU/Passes.h" | ||
#include "iree/compiler/Codegen/Utils/GPUUtils.h" | ||
#include "mlir/Dialect/Func/IR/FuncOps.h" | ||
|
||
#include "llvm/Support/Debug.h" | ||
|
||
#define DEBUG_TYPE "iree-test-llvmgpu-query-mma" | ||
|
||
namespace mlir::iree_compiler { | ||
|
||
#define GEN_PASS_DEF_TESTLLVMGPUQUERYMMAPASS | ||
#include "iree/compiler/Codegen/LLVMGPU/Passes.h.inc" | ||
|
||
static void printMMAVector(SmallVector<IREE::GPU::MMAAttr> &mmaAttrs, | ||
const std::string &extraMessage = {}) { | ||
llvm::outs() << "Printing MMA Collection" << extraMessage | ||
<< ", size: " << mmaAttrs.size() << "\n"; | ||
for (const auto &mma : mmaAttrs) { | ||
llvm::outs() << mma << " "; | ||
} | ||
llvm::outs() << "\n"; | ||
} | ||
|
||
namespace { | ||
|
||
struct TestLLVMGPUQueryMMAPass final | ||
: impl::TestLLVMGPUQueryMMAPassBase<TestLLVMGPUQueryMMAPass> { | ||
void runOnOperation() override { | ||
ModuleOp moduleOp = getOperation(); | ||
SmallVector<IREE::GPU::MMAAttr> mmaCollecton; | ||
// Print mma vector before collection. | ||
printMMAVector(mmaCollecton, | ||
" Before querying supported mma instrinsic instructions"); | ||
// Collect mma intrinsic instructions. | ||
QueryMMAIntrinsics(moduleOp, mmaCollecton); | ||
// Print mma vector after collection. | ||
printMMAVector(mmaCollecton, | ||
" After querying supported mma instrinsic instructions"); | ||
} | ||
}; | ||
} // namespace | ||
} // namespace mlir::iree_compiler |
This file contains 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
This file contains 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
60 changes: 60 additions & 0 deletions
60
compiler/src/iree/compiler/Codegen/LLVMGPU/test/test_query_mma.mlir
This file contains 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,60 @@ | ||
// RUN: iree-opt --split-input-file --iree-test-llvmgpu-query-mma %s | FileCheck %s | ||
|
||
#executable_target_rocm_hsaco_fb = #hal.executable.target<"rocm", "rocm-hsaco-fb", | ||
{abi = "hip", iree.gpu.target = #iree_gpu.target<arch = "gfx942", features = "", | ||
wgp = <compute = fp64|fp32|fp16|int64|int32|int16|int8, storage = b64|b32|b16|b8, | ||
subgroup = shuffle|arithmetic, dot = dp4xi8toi32, | ||
mma = [<MFMA_F32_16x16x4_F32>, <MFMA_F32_16x16x16_F16>, <MFMA_F32_32x32x8_F16>, | ||
<MFMA_F32_16x16x16_BF16>, <MFMA_F32_32x32x8_BF16>, <MFMA_F32_16x16x32_F8E4M3FNUZ>, | ||
<MFMA_F32_16x16x32_F8E5M2FNUZ>, <MFMA_I32_16x16x32_I8>, <MFMA_I32_32x32x16_I8>], | ||
subgroup_size_choices = [64], max_workgroup_sizes = [1024, 1024, 1024], | ||
max_thread_count_per_workgroup = 1024, max_workgroup_memory_bytes = 65536, | ||
max_workgroup_counts = [2147483647, 2147483647, 2147483647], max_load_instruction_bits = 128, | ||
simds_per_wgp = 4, vgpr_space_bits = 16384>>, ukernels = "none", waves_per_eu = 2 : i64}> | ||
#pipeline_layout = #hal.pipeline.layout<bindings = [#hal.pipeline.binding<storage_buffer>]> | ||
module { | ||
hal.executable private @main { | ||
hal.executable.variant public @main target(#executable_target_rocm_hsaco_fb) { | ||
hal.executable.export public @entry_point layout(#pipeline_layout) | ||
builtin.module { | ||
func.func @fn() { | ||
return | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
// CHECK: Printing MMA Collection Before querying supported mma instrinsic instructions, size: 0 | ||
// CHECK: Printing MMA Collection After querying supported mma instrinsic instructions, size: 9 | ||
// CHECK: MFMA_F32_16x16x4_F32 | ||
// CHECK-SAME: MFMA_F32_16x16x16_F16 | ||
// CHECK-SAME: MFMA_F32_32x32x8_F16 | ||
// CHECK-SAME: MFMA_F32_16x16x16_BF16 | ||
// CHECK-SAME: MFMA_F32_32x32x8_BF16 | ||
// CHECK-SAME: MFMA_F32_16x16x32_F8E4M3FNUZ | ||
// CHECK-SAME: MFMA_F32_16x16x32_F8E5M2FNUZ | ||
// CHECK-SAME: MFMA_I32_16x16x32_I8 | ||
// CHECK-SAME: MFMA_I32_32x32x16_I8 | ||
// CHECK-LABEL: func.func @fn | ||
|
||
// ----- | ||
|
||
#executable_target_rocm_hsaco_fb = #hal.executable.target<"rocm", "rocm-hsaco-fb"> | ||
#pipeline_layout = #hal.pipeline.layout<bindings = [#hal.pipeline.binding<storage_buffer>]> | ||
module { | ||
hal.executable private @main { | ||
hal.executable.variant public @main target(#executable_target_rocm_hsaco_fb) { | ||
hal.executable.export public @entry_point layout(#pipeline_layout) | ||
builtin.module { | ||
func.func @fn_empty() { | ||
return | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
// CHECK: Printing MMA Collection Before querying supported mma instrinsic instructions, size: 0 | ||
// CHECK: Printing MMA Collection After querying supported mma instrinsic instructions, size: 0 | ||
// CHECK-LABEL: func.func @fn_empty |
This file contains 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
This file contains 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