-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[OpenACC][CIR] Implement 'gang' lowering for 'loop' #138968
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 1 commit
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -107,6 +107,18 @@ class OpenACCClauseCIREmitter final | |||||
| .CaseLower("radeon", mlir::acc::DeviceType::Radeon); | ||||||
| } | ||||||
|
|
||||||
| mlir::acc::GangArgType decodeGangType(OpenACCGangKind GK) { | ||||||
| switch (GK) { | ||||||
| case OpenACCGangKind::Num: | ||||||
| return mlir::acc::GangArgType::Num; | ||||||
| case OpenACCGangKind::Dim: | ||||||
| return mlir::acc::GangArgType::Dim; | ||||||
| case OpenACCGangKind::Static: | ||||||
| return mlir::acc::GangArgType::Static; | ||||||
| } | ||||||
| llvm_unreachable("unknown gang kind"); | ||||||
| } | ||||||
|
|
||||||
| public: | ||||||
| OpenACCClauseCIREmitter(OpTy &operation, CIRGen::CIRGenFunction &cgf, | ||||||
| CIRGen::CIRGenBuilderTy &builder, | ||||||
|
|
@@ -424,6 +436,42 @@ class OpenACCClauseCIREmitter final | |||||
| return clauseNotImplemented(clause); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| void VisitGangClause(const OpenACCGangClause &clause) { | ||||||
| if constexpr (isOneOfTypes<OpTy, mlir::acc::LoopOp>) { | ||||||
| if (clause.getNumExprs() == 0) { | ||||||
| operation.addEmptyGang(builder.getContext(), lastDeviceTypeValues); | ||||||
| } else { | ||||||
| llvm::SmallVector<mlir::Value> values; | ||||||
| llvm::SmallVector<mlir::acc::GangArgType> argTypes; | ||||||
| for (unsigned I = 0; I < clause.getNumExprs(); ++I) { | ||||||
|
||||||
| for (unsigned I = 0; I < clause.getNumExprs(); ++I) { | |
| for (unsigned i = 0; i < clause.getNumExprs(); ++i) { |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2748,6 +2748,49 @@ void acc::LoopOp::addEmptyWorker( | |||||
| effectiveDeviceTypes)); | ||||||
| } | ||||||
|
|
||||||
| void acc::LoopOp::addEmptyGang( | ||||||
| MLIRContext *context, llvm::ArrayRef<DeviceType> effectiveDeviceTypes) { | ||||||
| setGangAttr(addDeviceTypeAffectedOperandHelper(context, getGangAttr(), | ||||||
| effectiveDeviceTypes)); | ||||||
| } | ||||||
|
|
||||||
| void acc::LoopOp::addGangOperands( | ||||||
| MLIRContext *context, llvm::ArrayRef<DeviceType> effectiveDeviceTypes, | ||||||
| llvm::ArrayRef<GangArgType> argTypes, mlir::ValueRange values) { | ||||||
| llvm::SmallVector<int32_t> segments; | ||||||
| if (getGangOperandsSegments()) | ||||||
|
||||||
| llvm::copy(*getGangOperandsSegments(), std::back_inserter(segments)); | ||||||
|
|
||||||
| unsigned beforeCount = segments.size(); | ||||||
|
|
||||||
| setGangOperandsDeviceTypeAttr(addDeviceTypeAffectedOperandHelper( | ||||||
| context, getGangOperandsDeviceTypeAttr(), effectiveDeviceTypes, values, | ||||||
| getGangOperandsMutable(), segments)); | ||||||
|
|
||||||
| setGangOperandsSegments(segments); | ||||||
|
|
||||||
| // This is a bit of extra work to make sure we update the 'types' correctly by | ||||||
| // adding to the types collection the correct number of times. We could | ||||||
| // potentially add something similar to the | ||||||
| // addDeviceTypeAffectedOperandHelper, but it seems that would be pretty | ||||||
| // excessive for a one-off case. | ||||||
| unsigned numAdded = segments.size() - beforeCount; | ||||||
|
|
||||||
| if (numAdded > 0) { | ||||||
| llvm::SmallVector<mlir::Attribute> gangTypes; | ||||||
| if (getGangOperandsArgTypeAttr()) | ||||||
| llvm::copy(getGangOperandsArgTypeAttr(), std::back_inserter(gangTypes)); | ||||||
|
|
||||||
| for (unsigned I = 0; I < numAdded; ++I) | ||||||
|
||||||
| for (unsigned I = 0; I < numAdded; ++I) | |
| for (unsigned i = 0; i < numAdded; ++i) |
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.