Skip to content

Commit c910d82

Browse files
authored
[OpenACC][CIR] Add worker/vector clause lowering for Routine (#170358)
These two are both incredibly similar and simple, basically identical to 'seq'. This patch adds them both together.
1 parent 0bb987f commit c910d82

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed

clang/lib/CIR/CodeGen/CIRGenDeclOpenACC.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,12 @@ class OpenACCRoutineClauseEmitter final
323323
void VisitSeqClause(const OpenACCSeqClause &clause) {
324324
routineOp.addSeq(builder.getContext(), lastDeviceTypeValues);
325325
}
326+
void VisitWorkerClause(const OpenACCWorkerClause &clause) {
327+
routineOp.addWorker(builder.getContext(), lastDeviceTypeValues);
328+
}
329+
void VisitVectorClause(const OpenACCVectorClause &clause) {
330+
routineOp.addVector(builder.getContext(), lastDeviceTypeValues);
331+
}
326332
};
327333
} // namespace
328334

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// RUN: %clang_cc1 -fopenacc -Wno-openacc-self-if-potential-conflict -emit-cir -fclangir %s -o - | FileCheck %s
2+
3+
#pragma acc routine seq
4+
void Func1() {}
5+
6+
void Func2() {}
7+
#pragma acc routine(Func2) seq
8+
9+
#pragma acc routine worker
10+
void Func3() {}
11+
12+
void Func4() {}
13+
#pragma acc routine(Func4) worker
14+
15+
#pragma acc routine vector
16+
void Func5() {}
17+
18+
void Func6() {}
19+
#pragma acc routine(Func6) vector
20+
21+
// CHECK: cir.func{{.*}} @[[F1_NAME:.*Func1[^\(]*]]({{.*}}){{.*}} attributes {acc.routine_info = #acc.routine_info<[@[[F1_R_NAME:.*]]]>}
22+
// CHECK: acc.routine @[[F1_R_NAME]] func(@[[F1_NAME]]) seq
23+
24+
// CHECK: cir.func{{.*}} @[[F2_NAME:.*Func2[^\(]*]]({{.*}}){{.*}} attributes {acc.routine_info = #acc.routine_info<[@[[F2_R_NAME:.*]]]>}
25+
26+
// CHECK: cir.func{{.*}} @[[F3_NAME:.*Func3[^\(]*]]({{.*}}){{.*}} attributes {acc.routine_info = #acc.routine_info<[@[[F3_R_NAME:.*]]]>}
27+
// CHECK: acc.routine @[[F3_R_NAME]] func(@[[F3_NAME]]) worker
28+
29+
// CHECK: cir.func{{.*}} @[[F4_NAME:.*Func4[^\(]*]]({{.*}}){{.*}} attributes {acc.routine_info = #acc.routine_info<[@[[F4_R_NAME:.*]]]>}
30+
31+
// CHECK: cir.func{{.*}} @[[F5_NAME:.*Func5[^\(]*]]({{.*}}){{.*}} attributes {acc.routine_info = #acc.routine_info<[@[[F5_R_NAME:.*]]]>}
32+
// CHECK: acc.routine @[[F5_R_NAME]] func(@[[F5_NAME]]) vector
33+
34+
// CHECK: cir.func{{.*}} @[[F6_NAME:.*Func6[^\(]*]]({{.*}}){{.*}} attributes {acc.routine_info = #acc.routine_info<[@[[F6_R_NAME:.*]]]>}
35+
36+
// CHECK: acc.routine @[[F2_R_NAME]] func(@[[F2_NAME]]) seq
37+
// CHECK: acc.routine @[[F4_R_NAME]] func(@[[F4_NAME]]) worker
38+
// CHECK: acc.routine @[[F6_R_NAME]] func(@[[F6_NAME]]) vector

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3282,6 +3282,10 @@ def OpenACC_RoutineOp : OpenACC_Op<"routine", [IsolatedFromAbove]> {
32823282

32833283
// Add an entry to the 'seq' attribute for each additional device types.
32843284
void addSeq(MLIRContext *, llvm::ArrayRef<DeviceType>);
3285+
// Add an entry to the 'vector' attribute for each additional device types.
3286+
void addVector(MLIRContext *, llvm::ArrayRef<DeviceType>);
3287+
// Add an entry to the 'worker' attribute for each additional device types.
3288+
void addWorker(MLIRContext *, llvm::ArrayRef<DeviceType>);
32853289
}];
32863290

32873291
let assemblyFormat = [{

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4355,6 +4355,18 @@ void RoutineOp::addSeq(MLIRContext *context,
43554355
effectiveDeviceTypes));
43564356
}
43574357

4358+
void RoutineOp::addVector(MLIRContext *context,
4359+
llvm::ArrayRef<DeviceType> effectiveDeviceTypes) {
4360+
setVectorAttr(addDeviceTypeAffectedOperandHelper(context, getVectorAttr(),
4361+
effectiveDeviceTypes));
4362+
}
4363+
4364+
void RoutineOp::addWorker(MLIRContext *context,
4365+
llvm::ArrayRef<DeviceType> effectiveDeviceTypes) {
4366+
setWorkerAttr(addDeviceTypeAffectedOperandHelper(context, getWorkerAttr(),
4367+
effectiveDeviceTypes));
4368+
}
4369+
43584370
//===----------------------------------------------------------------------===//
43594371
// InitOp
43604372
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)