Skip to content

Commit 36f6970

Browse files
committed
backend changes updates
1 parent bc7e452 commit 36f6970

File tree

5 files changed

+28
-38
lines changed

5 files changed

+28
-38
lines changed

mlir/include/mlir/Dialect/OpenMP/OpenMPAttrDefs.td

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,6 @@ def FlagsAttr : OpenMP_Attr<"Flags", "flags"> {
6969
let assemblyFormat = "`<` struct(params) `>`";
7070
}
7171

72-
//===----------------------------------------------------------------------===//
73-
// AtomicControlAttr
74-
//===----------------------------------------------------------------------===//
75-
76-
// Atomic control attributes hold information about architectural
77-
// characteristics which are required for lowering atomic operations.
78-
def AtomicControlAttr : OpenMP_Attr<"AtomicControl", "atomic_control"> {
79-
let parameters =
80-
(ins DefaultValuedParameter<"bool", "false">:$amdgpu_ignore_denormal_mode,
81-
DefaultValuedParameter<"bool", "false">:$amdgpu_fine_grained_memory,
82-
DefaultValuedParameter<"bool", "false">:$amdgpu_remote_memory);
83-
84-
let assemblyFormat = "`<` struct(params) `>`";
85-
}
86-
8772
//===----------------------------------------------------------------------===//
8873
// TaskDependArrayAttr
8974
//===----------------------------------------------------------------------===//

mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1546,7 +1546,7 @@ def AtomicUpdateOp : OpenMP_Op<"atomic.update", traits = [
15461546
let arguments = !con(
15471547
(ins Arg<OpenMP_PointerLikeType,
15481548
"Address of variable to be updated", [MemRead, MemWrite]>:$x,
1549-
AtomicControlAttr:$atomic_control),
1549+
OptionalAttr<AtomicControlAttr>:$atomic_control),
15501550
clausesArgs);
15511551

15521552
// Override region definition.

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3223,7 +3223,6 @@ convertOmpAtomicUpdate(omp::AtomicUpdateOp &opInst,
32233223

32243224
llvm::AtomicOrdering atomicOrdering =
32253225
convertAtomicOrdering(opInst.getMemoryOrder());
3226-
32273226
// Generate update code.
32283227
auto updateFn =
32293228
[&opInst, &moduleTranslation](
@@ -3242,21 +3241,27 @@ convertOmpAtomicUpdate(omp::AtomicUpdateOp &opInst,
32423241
return moduleTranslation.lookupValue(yieldop.getResults()[0]);
32433242
};
32443243

3245-
mlir::omp::AtomicControlAttr atomicControlAttr =
3246-
opInst.getAtomicControlAttr();
3247-
bool isAmdgpuIgnoreDenormalMode =
3248-
atomicControlAttr.getAmdgpuIgnoreDenormalMode();
3249-
bool isAmdgpuNoFineGrainedMemory =
3250-
!atomicControlAttr.getAmdgpuFineGrainedMemory();
3251-
bool isAmdgpuNoRemoteMemory = !atomicControlAttr.getAmdgpuRemoteMemory();
3244+
bool isIgnoreDenormalMode = false;
3245+
bool isNoFineGrainedMemory = false;
3246+
bool isNoRemoteMemory = false;
3247+
if(opInst->hasAttr(opInst.getAtomicControlAttrName())) {
3248+
mlir::omp::AtomicControlAttr atomicControlAttr =
3249+
opInst.getAtomicControlAttr();
3250+
isIgnoreDenormalMode =
3251+
atomicControlAttr.getIgnoreDenormalMode();
3252+
isNoFineGrainedMemory =
3253+
!atomicControlAttr.getFineGrainedMemory();
3254+
isNoRemoteMemory = !atomicControlAttr.getRemoteMemory();
3255+
3256+
}
32523257
// Handle ambiguous alloca, if any.
32533258
auto allocaIP = findAllocaInsertPoint(builder, moduleTranslation);
32543259
llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
32553260
llvm::OpenMPIRBuilder::InsertPointOrErrorTy afterIP =
32563261
ompBuilder->createAtomicUpdate(
32573262
ompLoc, allocaIP, llvmAtomicX, llvmExpr, atomicOrdering, binop,
3258-
updateFn, isXBinopExpr, isAmdgpuIgnoreDenormalMode,
3259-
isAmdgpuNoFineGrainedMemory, isAmdgpuNoRemoteMemory);
3263+
updateFn, isXBinopExpr, isIgnoreDenormalMode,
3264+
isNoFineGrainedMemory, isNoRemoteMemory);
32603265

32613266
if (failed(handleError(afterIP, *opInst)))
32623267
return failure();
@@ -3346,17 +3351,17 @@ convertOmpAtomicCapture(omp::AtomicCaptureOp atomicCaptureOp,
33463351
return moduleTranslation.lookupValue(yieldop.getResults()[0]);
33473352
};
33483353

3349-
bool isAmdgpuIgnoreDenormalMode = false;
3350-
bool isAmdgpuNoFineGrainedMemory = true;
3351-
bool isAmdgpuNoRemoteMemory = true;
3354+
bool isIgnoreDenormalMode = false;
3355+
bool isNoFineGrainedMemory = true;
3356+
bool isNoRemoteMemory = true;
33523357
if (atomicUpdateOp) {
33533358
mlir::omp::AtomicControlAttr atomicControlAttr =
33543359
atomicUpdateOp.getAtomicControlAttr();
3355-
isAmdgpuIgnoreDenormalMode =
3356-
atomicControlAttr.getAmdgpuIgnoreDenormalMode();
3357-
isAmdgpuNoFineGrainedMemory =
3358-
!atomicControlAttr.getAmdgpuFineGrainedMemory();
3359-
isAmdgpuNoRemoteMemory = !atomicControlAttr.getAmdgpuRemoteMemory();
3360+
isIgnoreDenormalMode =
3361+
atomicControlAttr.getIgnoreDenormalMode();
3362+
isNoFineGrainedMemory =
3363+
!atomicControlAttr.getFineGrainedMemory();
3364+
isNoRemoteMemory = !atomicControlAttr.getRemoteMemory();
33603365
}
33613366
// Handle ambiguous alloca, if any.
33623367
auto allocaIP = findAllocaInsertPoint(builder, moduleTranslation);
@@ -3365,8 +3370,8 @@ convertOmpAtomicCapture(omp::AtomicCaptureOp atomicCaptureOp,
33653370
ompBuilder->createAtomicCapture(
33663371
ompLoc, allocaIP, llvmAtomicX, llvmAtomicV, llvmExpr, atomicOrdering,
33673372
binop, updateFn, atomicUpdateOp, isPostfixUpdate, isXBinopExpr,
3368-
isAmdgpuIgnoreDenormalMode, isAmdgpuNoFineGrainedMemory,
3369-
isAmdgpuNoRemoteMemory);
3373+
isIgnoreDenormalMode, isNoFineGrainedMemory,
3374+
isNoRemoteMemory);
33703375

33713376
if (failed(handleError(afterIP, *atomicCaptureOp)))
33723377
return failure();

mlir/test/Dialect/OpenMP/ops.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ func.func @omp_atomic_update(%x : memref<i32>, %expr : i32, %xBool : memref<i1>,
13711371
^bb0(%xval: i32):
13721372
%newval = llvm.add %xval, %expr : i32
13731373
omp.yield(%newval : i32)
1374-
} {atomic_control = #omp.atomic_control<>}
1374+
}
13751375
// CHECK: omp.atomic.update %[[XBOOL]] : memref<i1>
13761376
// CHECK-NEXT: (%[[XVAL:.*]]: i1):
13771377
// CHECK-NEXT: %[[NEWVAL:.*]] = llvm.and %[[XVAL]], %[[EXPRBOOL]] : i1

mlir/test/Target/LLVMIR/openmp-llvm.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ llvm.func @omp_atomic_update(%x:!llvm.ptr, %expr: i32, %xbool: !llvm.ptr, %exprb
14621462
^bb0(%xval: i32):
14631463
%newval = llvm.mul %xval, %expr : i32
14641464
omp.yield(%newval : i32)
1465-
} {atomic_control = #omp.atomic_control<>}
1465+
}
14661466
// CHECK: atomicrmw add ptr %[[x]], i32 %[[expr]] monotonic
14671467
omp.atomic.update %x : !llvm.ptr {
14681468
^bb0(%xval: i32):

0 commit comments

Comments
 (0)