Skip to content

Commit f0fb4de

Browse files
author
Razvan Lupusoru
committed
Add helper for loop to get par mode
1 parent ec45d9c commit f0fb4de

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2391,6 +2391,11 @@ def OpenACC_LoopOp : OpenACC_Op<"loop",
23912391
// Return whether this LoopOp has a gang, worker, or vector applying to the
23922392
// 'default'/None device-type.
23932393
bool hasDefaultGangWorkerVector();
2394+
2395+
// Used to obtain the parallelism mode for the requested device type.
2396+
// This first checks if the mode is set for the device_type requested.
2397+
// And if not, it returns the non-device_type mode.
2398+
LoopParMode getDefaultOrDeviceTypeParallelism(DeviceType);
23942399
}];
23952400

23962401
let hasCustomAssemblyFormat = 1;

mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2957,6 +2957,23 @@ bool acc::LoopOp::hasDefaultGangWorkerVector() {
29572957
getGangValue(GangArgType::Dim) || getGangValue(GangArgType::Static);
29582958
}
29592959

2960+
acc::LoopParMode
2961+
acc::LoopOp::getDefaultOrDeviceTypeParallelism(DeviceType deviceType) {
2962+
if (hasSeq(deviceType))
2963+
return LoopParMode::loop_seq;
2964+
if (hasAuto(deviceType))
2965+
return LoopParMode::loop_auto;
2966+
if (hasIndependent(deviceType))
2967+
return LoopParMode::loop_independent;
2968+
if (hasSeq())
2969+
return LoopParMode::loop_seq;
2970+
if (hasAuto())
2971+
return LoopParMode::loop_auto;
2972+
assert(hasIndependent() &&
2973+
"loop must have default auto, seq, or independent");
2974+
return LoopParMode::loop_independent;
2975+
}
2976+
29602977
void acc::LoopOp::addGangOperands(
29612978
MLIRContext *context, llvm::ArrayRef<DeviceType> effectiveDeviceTypes,
29622979
llvm::ArrayRef<GangArgType> argTypes, mlir::ValueRange values) {

0 commit comments

Comments
 (0)