Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
6f4a838
experiment on the ticket 555, not working
erizheng-amd Apr 1, 2026
fb0b657
Adding temp experiment flag for upcoming change
erizheng-amd Apr 1, 2026
f3ebce2
fixing test failure due to IR change
erizheng-amd Apr 2, 2026
fefe127
updating tests to check for [1 1 1]
erizheng-amd Apr 6, 2026
6298d6b
update test with explicit call on mhal
erizheng-amd Apr 6, 2026
604bd14
Fixing the compute errors caused by removin mhal functions
erizheng-amd Apr 6, 2026
be03d19
Removing redundant includes and experiment flags
erizheng-amd Apr 6, 2026
a9ea3c9
Merge branch 'develop' into eric-555
erizheng-amd Apr 6, 2026
89e49c1
Merge branch 'develop' into eric-555
erizheng-amd Apr 9, 2026
8e58246
extra fix after merge
erizheng-amd Apr 9, 2026
cd1b606
Fixing Clang-Format issue
erizheng-amd Apr 9, 2026
1a58b33
Merge branch 'develop' into eric-555
erizheng-amd Apr 13, 2026
bb21f09
fix nightly lit test errors
erizheng-amd Apr 13, 2026
65067b1
Fix on other lit tests explicitly using mhal launch and mhal await
erizheng-amd Apr 13, 2026
685fca3
Merge branch 'develop' into eric-555
erizheng-amd Apr 13, 2026
92472e8
Merge branch 'develop' into eric-555
erizheng-amd Apr 14, 2026
78a0dcd
Addressing PR comments
erizheng-amd Apr 14, 2026
2111b16
Full removal for mhal.launch and mhal.await support
erizheng-amd Apr 14, 2026
07ed9ad
small fix
erizheng-amd Apr 14, 2026
53c3119
small fix
erizheng-amd Apr 14, 2026
fa51897
Merge branch 'develop' into eric-555
erizheng-amd Apr 16, 2026
95a64ad
Merge branch 'develop' into eric-555
erizheng-amd Apr 20, 2026
0f86aa7
Merge branch 'develop' into eric-555
erizheng-amd Apr 30, 2026
7354be4
Addressing AI Agent Reviews
erizheng-amd Apr 30, 2026
8373389
Address AI Review
erizheng-amd Apr 30, 2026
6b9a162
addressing new AI review comments
erizheng-amd May 1, 2026
2ea4f82
fix in mlir-hal project
erizheng-amd May 1, 2026
4cb8053
Merge branch 'develop' into eric-555
erizheng-amd May 5, 2026
bd1e0ef
addressing AI reviews
erizheng-amd May 5, 2026
2db164d
Merge branch 'develop' into eric-555
erizheng-amd May 6, 2026
722facb
Merge branch 'develop' into eric-555
erizheng-amd May 7, 2026
d47acd7
Merge branch 'develop' into eric-555
erizheng-amd May 7, 2026
def429c
Merge branch 'develop' into eric-555
erizheng-amd May 8, 2026
04ae94b
Merge branch 'develop' into eric-555
erizheng-amd May 9, 2026
c7949c0
Merge branch 'develop' into eric-555
erizheng-amd May 12, 2026
86da73c
Merge branch 'develop' into eric-555
erizheng-amd May 13, 2026
43d2aaf
Merge branch 'develop' into eric-555
erizheng-amd May 13, 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
1 change: 0 additions & 1 deletion external/mlir-hal/include/mlir/Conversion/MHALPasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#ifndef MHAL_CONVERSION_PASSES_H
#define MHAL_CONVERSION_PASSES_H

#include "mlir/Conversion/MHALToCPU/MHALToCPU.h"
#include "mlir/Conversion/MHALToGPU/MHALToGPU.h"
#include "mlir/Pass/PassRegistry.h"

Expand Down
12 changes: 2 additions & 10 deletions external/mlir-hal/include/mlir/Conversion/MHALPasses.td
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,9 @@ include "mlir/Pass/PassBase.td"
//===----------------------------------------------------------------------===//

def ConvertMHALToGPUPass : Pass<"convert-mhal-to-gpu", "ModuleOp"> {
let summary = "Convert the mhal.launch operations to gpu.launch_func";
let summary = "Lower bufferized func.call to GPU kernels (mhal.targets) to "
"gpu.launch_func";
let dependentDialects = ["gpu::GPUDialect"];
}

//===----------------------------------------------------------------------===//
// MHALToCPU
//===----------------------------------------------------------------------===//

def ConvertMHALToCPUPass : Pass<"convert-mhal-to-cpu", "ModuleOp"> {
let summary = "Convert the mhal.launch operations to func.call";
let dependentDialects = ["func::FuncDialect"];
}

#endif // MHAL_CONVERSION_PASSES
22 changes: 0 additions & 22 deletions external/mlir-hal/include/mlir/Conversion/MHALToCPU/MHALToCPU.h

This file was deleted.

5 changes: 0 additions & 5 deletions external/mlir-hal/include/mlir/Dialect/MHAL/IR/MHAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,15 @@
#ifndef MLIR_MHAL_IR_MHAL_H_
#define MLIR_MHAL_IR_MHAL_H_

#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/DialectImplementation.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/Interfaces/CallInterfaces.h"

//===----------------------------------------------------------------------===//
// MHAL Dialect
//===----------------------------------------------------------------------===//

#include "mlir/Dialect/MHAL/IR/MHALOpsDialect.h.inc"
#include "mlir/Dialect/MHAL/IR/MHALTypes.h"
#define GET_OP_CLASSES
#include "mlir/Dialect/MHAL/IR/MHALOps.h.inc"

#define GET_ATTRDEF_CLASSES
#include "mlir/Dialect/MHAL/IR/MHALAttrDefs.h.inc"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ def MHALDialect : Dialect {
let name = "mhal";
let cppNamespace = "::mlir::mhal";

let summary = "Types and operations for mhal dialect";
let summary = "Attributes for the MHAL dialect";

let useDefaultTypePrinterParser = 1;
let useDefaultAttributePrinterParser = 1;

let extraClassDeclaration = [{
Expand Down
138 changes: 5 additions & 133 deletions external/mlir-hal/include/mlir/Dialect/MHAL/IR/MHALOps.td
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
//===- MHALOps.td - MHAL operations definition -----------*- tablegen -*-===//
//===- MHALOps.td - MHAL dialect TableGen entry point ----*- tablegen -*-===//
//
// Part of the LLVM Project, 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
//
//===----------------------------------------------------------------------===//
//
// This is the operation definition file for MHAL dialect operations.
// TableGen entry point referenced by `add_mlir_dialect(MHALOps mhal)`. The
// MHAL dialect currently exposes only attributes (e.g. mhal.targets,
// mhal.write_access) -- no ops, no types. The dialect class itself is defined
// in MHALBase.td; attribute definitions live in MHALAttrDefs.td.
//
//===----------------------------------------------------------------------===//

Expand All @@ -15,136 +18,5 @@

include "mlir/Dialect/MHAL/IR/MHALBase.td"
include "mlir/Dialect/MHAL/IR/MHALAttrDefs.td"
include "mlir/Interfaces/CallInterfaces.td"
include "mlir/Interfaces/ControlFlowInterfaces.td"
include "mlir/IR/SymbolInterfaces.td"
include "mlir/IR/OpAsmInterface.td"


//===----------------------------------------------------------------------===//
// MHAL op definitions
//===----------------------------------------------------------------------===//

// Base class for the operation in this dialect
class MHAL_Op<string mnemonic, list<Trait> traits = []> :
Op<MHALDialect, mnemonic, traits>;

def MHAL_LaunchOp :
MHAL_Op<"launch", [DeclareOpInterfaceMethods<CallOpInterface>,
DeclareOpInterfaceMethods<SymbolUserOpInterface>,
AttrSizedOperandSegments]> {
let summary = "asynchronous launch operation";
let description = [{
The `mhal.launch` operation encapsulates a call to a `kernel` func that
may run mhalhronously from the caller. An `mhal.token` is returned to
maintain ordered dependent execution. Subsequent instructions that depend
on results from the `mhal.launch` must either be dependent on the token
or be preceded by an `mhal.await` of that token.

The actual concurrency semantics depends on the dialect lowering to the
executable format. Fully sequential execution ("compute0" completes before
"compute1" starts) is a completely legal execution.

Because concurrent execution is not guaranteed, it is undefined behavior
to create an implicit dependency from "compute1" to "compute0" (e.g. via
shared global state). All dependencies must be made explicit with mhal
launch arguments (i.e. `mhal.token`).

`mhal.launch` operation takes `mhal.token` dependencies and operands
separately, and starts execution of the kernel function only when all
tokens become ready. In contrast to `mhal.execute` this operation does
not depend on operand values as `mhal.value` requires.

Example:

```mlir
%dependency = ... : !mhal.token

%token, %results =
mhal.launch @compute0 [%dependency] (%value0, %value1) :
(some.type, some.type) -> some.type

%1 = "compute1"(...) : !some.type
```

In the example above mhalhronous execution starts only after dependency
token becomes ready.
}];

let arguments = (ins FlatSymbolRefAttr:$callee,
Variadic<MHAL_TokenType>:$dependencies,
Variadic<AnyType>:$launchOperands);

let results = (outs MHAL_TokenType:$token,
Variadic<AnyType>:$results);

let builders = [
OpBuilder<(ins "func::FuncOp":$kernelFunc, "ValueRange":$dependencies,
"ValueRange":$kernelOperands)>,
OpBuilder<(ins "FlatSymbolRefAttr":$callee, "TypeRange":$results,
CArg<"ValueRange", "{}">:$launchOperands), [{
$_state.addOperands(launchOperands);
$_state.addAttribute("callee", callee);
$_state.addTypes(results);
auto operandSegmentSizes = $_builder.getDenseI32ArrayAttr(
{0, static_cast<int32_t>(launchOperands.size())});
$_state.addAttribute(getOperandSegmentSizesAttrName($_state.name),
operandSegmentSizes);

}]>,
];

let extraClassDeclaration = [{
Operation::result_range getCallResults();
Operation::result_type_range getCallResultTypes();
void updateSegmentSizes(MLIRContext *);
}];

let hasVerifier = 1;
let assemblyFormat = [{
$callee (` ` `[` $dependencies^ `]`)? `(` $launchOperands `)` attr-dict
`:` `(` type($launchOperands) `)` (`->` type($results)^)?
}];

}

def MHAL_AwaitOp : MHAL_Op<"await"> {
let summary = "waits for the argument to become ready";
let description = [{
The `mhal.await` operation waits until the argument becomes ready, and for

Example:

```mlir
%0 = ... : !mhal.token
mhal.await %0 : !mhal.token

```
}];

let arguments = (ins MHAL_TokenType:$operand);
let results = (outs Optional<AnyType>:$result);

let skipDefaultBuilders = 1;
let hasVerifier = 1;

let builders = [
OpBuilder<(ins "Value":$operand,
CArg<"ArrayRef<NamedAttribute>", "{}">:$attrs)>,
];

let extraClassDeclaration = [{
std::optional<Type> getResultType() {
if (getResultTypes().empty()) return std::nullopt;
return getResultTypes()[0];
}
}];

let assemblyFormat = [{
$operand `:` custom<AwaitResultType>(
type($operand), type($result)
) attr-dict
}];
}

#endif // MHAL_OPS
15 changes: 1 addition & 14 deletions external/mlir-hal/include/mlir/Dialect/MHAL/IR/MHALTypes.td
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,9 @@ include "mlir/IR/AttrTypeBase.td"
include "mlir/Dialect/MHAL/IR/MHALBase.td"

//===----------------------------------------------------------------------===//
// MHAL Types
// MHAL Enums
//===----------------------------------------------------------------------===//

class MHAL_Type<string name, string typeMnemonic> : TypeDef<MHALDialect,
name> {
let mnemonic = typeMnemonic;
}

def MHAL_TokenType : MHAL_Type<"Token", "token"> {
let summary = "mhal token type";
let description = [{
`mhal.token` is a type returned by mhalhronous operations, and it becomes
`available` when the mhalhronous operations that created it is completed.
}];
}

class MHAL_I32Enum<string name, string summary, list<I32EnumAttrCase> cases>
: I32EnumAttr<name, summary, cases> {
let cppNamespace = "::mlir::mhal";
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ namespace mhal {
void populateMHalNarrowTypeEmulationConversions(
arith::NarrowTypeEmulationConverter &typeConverter);

/// Adds patterns for rewriting `mhal.launch` ops to `patterns` that replace
/// 4-bit (or other narrow pattern of two) memrefs to 8-bit ones.
void populateMHalNarrowTypeEmulationBoundaryPatterns(
arith::NarrowTypeEmulationConverter &typeConverter,
RewritePatternSet &patterns);

/// Adds patterns that handle `extract_strided_metadata` ops targetting the
/// `builtin.unrealized_conversion_cast` operations that the type conversion
/// process introduces to prevent dialect conversion from failing due to stray
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ def MHALBufferizePass : Pass<"mhal-bufferize", "func::FuncOp"> {
}

def MHalEmulateNarrowTypePass : Pass<"mhal-emulate-narrow-type", "func::FuncOp"> {
let summary = "Emulate memrefs of 4-bit integers (or 2-bit, maybe)";
let summary = "Emulate memrefs of 4-bit integers (or 2-bit, maybe)";
let description = [{
Coordinates the rewrite patterns present in upstream MLIR for supporting
i4 memrefs by rewriting them to linear i8 ones. Also rewrite `mhal.launch`
just like `func.call` gets rewritten.
i4 memrefs by rewriting them to linear i8 ones, and rewrites `func.call`
boundaries accordingly.

Note that this pass is meant to target the host/test code, and so doesn't handle
vector loads/stores because they won't have been produced by the host runner.
Expand Down
4 changes: 0 additions & 4 deletions external/mlir-hal/include/mlir/InitMHALDialects.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,13 @@

// MHAL includes
#include "mlir/Dialect/MHAL/IR/MHAL.h"
#include "mlir/Dialect/MHAL/Transforms/BufferizableOpInterfaceImpl.h"

namespace mlir {

// Add all the MLIR dialects to the provided registry.
inline void registerMHALDialects(DialectRegistry &registry) {
// Register MHAL specific dialects
registry.insert<mhal::MHALDialect>();

// Register bufferization hooks for mhal interfaces
mhal::registerBufferizableOpInterfaceExternalModels(registry);
}

} // namespace mlir
Expand Down
1 change: 0 additions & 1 deletion external/mlir-hal/lib/Conversion/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
add_subdirectory(MHALToGPU)
add_subdirectory(MHALToCPU)
17 changes: 0 additions & 17 deletions external/mlir-hal/lib/Conversion/MHALToCPU/CMakeLists.txt

This file was deleted.

Loading
Loading