-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[MLIR][XeVM] XeVM to LLVM: Add conversion patterns for id ops #162536
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 3 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 | ||||
---|---|---|---|---|---|---|
|
@@ -714,6 +714,137 @@ class LLVMLoadStoreToOCLPattern : public OpConversionPattern<OpType> { | |||||
} | ||||||
}; | ||||||
|
||||||
//===----------------------------------------------------------------------===// | ||||||
// GPU index id operations | ||||||
//===----------------------------------------------------------------------===// | ||||||
/* | ||||||
// Launch Config ops | ||||||
// dimidx - x, y, x - is fixed to i32 | ||||||
// return type is set by XeVM type converter | ||||||
// get_local_id | ||||||
xevm::WorkitemIdXOp; | ||||||
xevm::WorkitemIdYOp; | ||||||
xevm::WorkitemIdZOp; | ||||||
// get_local_size | ||||||
xevm::WorkgroupDimXOp; | ||||||
xevm::WorkgroupDimYOp; | ||||||
xevm::WorkgroupDimZOp; | ||||||
// get_group_id | ||||||
xevm::WorkgroupIdXOp; | ||||||
xevm::WorkgroupIdYOp; | ||||||
xevm::WorkgroupIdZOp; | ||||||
// get_num_groups | ||||||
xevm::GridDimXOp; | ||||||
xevm::GridDimYOp; | ||||||
xevm::GridDimZOp; | ||||||
// get_global_id : to be added if needed | ||||||
*/ | ||||||
|
||||||
// Helpers to get the OpenCL function name and dimension argument for each op. | ||||||
static std::pair<StringRef, int64_t> getConfig(xevm::WorkitemIdXOp) { | ||||||
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. This looks like it has to be an extension to tablegen special register ops. 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. Agree. Intel GPU, without it's own LLVM backend, this pass is used as an alternative to tablegen based translation with |
||||||
return {"get_local_id", 0}; | ||||||
} | ||||||
static std::pair<StringRef, int64_t> getConfig(xevm::WorkitemIdYOp) { | ||||||
return {"get_local_id", 1}; | ||||||
} | ||||||
static std::pair<StringRef, int64_t> getConfig(xevm::WorkitemIdZOp) { | ||||||
return {"get_local_id", 2}; | ||||||
} | ||||||
static std::pair<StringRef, int64_t> getConfig(xevm::WorkgroupDimXOp) { | ||||||
return {"get_local_size", 0}; | ||||||
} | ||||||
static std::pair<StringRef, int64_t> getConfig(xevm::WorkgroupDimYOp) { | ||||||
return {"get_local_size", 1}; | ||||||
} | ||||||
static std::pair<StringRef, int64_t> getConfig(xevm::WorkgroupDimZOp) { | ||||||
return {"get_local_size", 2}; | ||||||
} | ||||||
static std::pair<StringRef, int64_t> getConfig(xevm::WorkgroupIdXOp) { | ||||||
return {"get_group_id", 0}; | ||||||
} | ||||||
static std::pair<StringRef, int64_t> getConfig(xevm::WorkgroupIdYOp) { | ||||||
return {"get_group_id", 1}; | ||||||
} | ||||||
static std::pair<StringRef, int64_t> getConfig(xevm::WorkgroupIdZOp) { | ||||||
return {"get_group_id", 2}; | ||||||
} | ||||||
static std::pair<StringRef, int64_t> getConfig(xevm::GridDimXOp) { | ||||||
return {"get_num_groups", 0}; | ||||||
} | ||||||
static std::pair<StringRef, int64_t> getConfig(xevm::GridDimYOp) { | ||||||
return {"get_num_groups", 1}; | ||||||
} | ||||||
static std::pair<StringRef, int64_t> getConfig(xevm::GridDimZOp) { | ||||||
return {"get_num_groups", 2}; | ||||||
} | ||||||
/// Replace `xevm.*` with an `llvm.call` to the corresponding OpenCL func with | ||||||
/// a constant argument for the dimension - x, y or z. | ||||||
template <typename OpType> | ||||||
class LaunchConfigOpToOCLPattern : public OpConversionPattern<OpType> { | ||||||
using OpConversionPattern<OpType>::OpConversionPattern; | ||||||
LogicalResult | ||||||
matchAndRewrite(OpType op, typename OpType::Adaptor adaptor, | ||||||
ConversionPatternRewriter &rewriter) const override { | ||||||
Location loc = op->getLoc(); | ||||||
std::pair<StringRef, int64_t> config = getConfig(op); | ||||||
|
std::pair<StringRef, int64_t> config = getConfig(op); | |
auto [baseName, dim] = getConfig(op); |
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.
Thanks for suggestion. Totally forgot that was possible with pair.
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.
Did you mean
?