Skip to content

[DRAFT][s4xbf16] JoinOp vectorization patch (Rebased) #25

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

Open
wants to merge 2 commits into
base: llvm-head-staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 13 additions & 0 deletions lib/Conversion/TritonGPUToLLVM/ViewOpToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,19 @@ struct JoinOpConversion : public ConvertOpToLLVMPattern<JoinOp> {
assert(lhsVals.size() == rhsVals.size());
SmallVector<Value> joinedVals;
joinedVals.resize(lhsVals.size() * 2);

// Specifically for packed upcasting from 4b to 16b dtypes
// numContiguousValues cannot be too large, since the two outputs of
// inline_asm contain interleaved values OTOH, if numContiguousValues * 16b
// < 32b, then we'll need to rearrange 16b values in 32b registers. Hnece we
// set numContiguousValues to 2
auto inlineOp =
dyn_cast<ElementwiseInlineAsmOp>(op.getLhs().getDefiningOp());
if (inlineOp && inlineOp.getPackedElement() == 4 &&
dstTy.getElementTypeBitWidth() == 16) {
numContiguousValues = 2;
}

for (int i = 0; i < lhsVals.size(); i += numContiguousValues) {
for (int j = 0; j < numContiguousValues; j++) {
joinedVals[2 * i + j] = lhsVals[i + j];
Expand Down
2 changes: 1 addition & 1 deletion python/src/llvm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ createTargetMachine(llvm::Module *module, std::string proc,
opt.MCOptions.AsmVerbose = true;
opt.MCOptions.PreserveAsmComments = true;
std::unique_ptr<llvm::TargetMachine> machine{target->createTargetMachine(
module->getTargetTriple(), proc, features, opt, llvm::Reloc::PIC_,
module->getTargetTriple().str(), proc, features, opt, llvm::Reloc::PIC_,
std::nullopt,
disableLLVMOpt ? llvm::CodeGenOptLevel::None
: llvm::CodeGenOptLevel::Aggressive)};
Expand Down