-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[MLIR][XeVM] Add xevm blockload and blockstore op definition. #158118
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
#include "mlir/Dialect/GPU/IR/CompilationInterfaces.h" | ||
#include "mlir/Dialect/Utils/StaticValueUtils.h" | ||
#include "mlir/IR/DialectImplementation.h" | ||
#include "llvm/ADT/SmallSet.h" | ||
#include "llvm/ADT/TypeSwitch.h" | ||
#include "llvm/Support/FileSystem.h" | ||
#include "llvm/Support/MathExtras.h" | ||
|
@@ -306,6 +307,36 @@ LogicalResult BlockPrefetch2dOp::verify() { | |
return success(); | ||
} | ||
|
||
template <typename OpType, typename = std::enable_if_t<llvm::is_one_of< | ||
OpType, BlockLoadOp, BlockStoreOp>::value>> | ||
LogicalResult verify1DBlockArg(OpType op) { | ||
VectorType vTy; | ||
if constexpr (std::is_same_v<OpType, BlockLoadOp>) | ||
vTy = op.getResult().getType(); | ||
else | ||
vTy = op.getVal().getType(); | ||
int elemTySize = vTy.getElementType().getIntOrFloatBitWidth() / 8; | ||
if (elemTySize == 1) { | ||
llvm::SmallSet<int, 5> validSizes{1, 2, 4, 8, 16}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: seems target specific? add a TODO or move to a dedicated location for HW specifics. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not target arch or chip specific but the restrictions are OpenCL / SPIR-V Intel extensions specific. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I put links to related specs above. |
||
if (validSizes.contains(vTy.getNumElements())) | ||
return success(); | ||
else | ||
return op.emitOpError( | ||
"vector size must be 1, 2, 4, 8 or 16 for 8-bit element type"); | ||
} else { | ||
llvm::SmallSet<int, 4> validSizes{1, 2, 4, 8}; | ||
if (validSizes.contains(vTy.getNumElements())) | ||
return success(); | ||
else | ||
return op.emitOpError( | ||
"vector size must be 1, 2, 4 or 8 for element type > 8 bits"); | ||
} | ||
} | ||
|
||
LogicalResult BlockLoadOp::verify() { return verify1DBlockArg(*this); } | ||
|
||
LogicalResult BlockStoreOp::verify() { return verify1DBlockArg(*this); } | ||
|
||
LogicalResult MMAOp::verify() { | ||
if (getC()) { | ||
if (getResult().getType() != getC().getType()) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,29 @@ func.func @blockprefetch2d(%ptr: !llvm.ptr<1>, %base_width: i32, %base_height: i | |
return | ||
} | ||
|
||
// ----- | ||
// CHECK-LABEL: func.func @blockload( | ||
// CHECK-SAME: %[[ARG0:.*]]: !llvm.ptr<1>) | ||
func.func @blockload(%ptr: !llvm.ptr<1>) -> vector<4xi16> { | ||
// CHECK: %[[VAR0:.*]] = xevm.blockload %[[ARG0]] | ||
// CHECK-SAME: cache_control = #xevm.load_cache_control<L1uc_L2uc_L3uc> | ||
// CHECK-SAME: (!llvm.ptr<1>) -> vector<4xi16> | ||
%loaded = xevm.blockload %ptr <{cache_control=#xevm.load_cache_control<L1uc_L2uc_L3uc>}> | ||
: (!llvm.ptr<1>) -> vector<4xi16> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is output not a multiple of SG size? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Output is distributed to work item lanes. |
||
return %loaded : vector<4xi16> | ||
} | ||
|
||
// ----- | ||
// CHECK-LABEL: func.func @blockstore( | ||
// CHECK-SAME: %[[ARG0:.*]]: !llvm.ptr<1>, | ||
// CHECK-SAME: %[[ARG1:.*]]: vector<4xi32>) | ||
func.func @blockstore(%ptr: !llvm.ptr<1>, %value: vector<4xi32>) { | ||
// CHECK: xevm.blockstore %[[ARG0]], %[[ARG1]] | ||
// CHECK-SAME: (!llvm.ptr<1>, vector<4xi32>) | ||
xevm.blockstore %ptr, %value : (!llvm.ptr<1>, vector<4xi32>) | ||
return | ||
} | ||
|
||
// ----- | ||
// CHECK-LABEL: func.func @mma( | ||
// CHECK-SAME: %[[ARG0:.*]]: vector<8xf32>, %[[ARG1:.*]]: vector<8xi16>, %[[ARG2:.*]]: vector<8xi32>) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding: it must be uniform across subgroup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated description.