[flang][cuda] Bring PARAMETER arrays into the GPU module (#146416)
This commit is contained in:
parent
56739f5866
commit
f4cecfe1bb
@ -113,8 +113,16 @@ public:
|
|||||||
return signalPassFailure();
|
return signalPassFailure();
|
||||||
mlir::SymbolTable gpuSymTable(gpuMod);
|
mlir::SymbolTable gpuSymTable(gpuMod);
|
||||||
for (auto globalOp : mod.getOps<fir::GlobalOp>()) {
|
for (auto globalOp : mod.getOps<fir::GlobalOp>()) {
|
||||||
if (cuf::isRegisteredDeviceGlobal(globalOp))
|
if (cuf::isRegisteredDeviceGlobal(globalOp)) {
|
||||||
candidates.insert(globalOp);
|
candidates.insert(globalOp);
|
||||||
|
} else if (globalOp.getConstant() &&
|
||||||
|
mlir::isa<fir::SequenceType>(
|
||||||
|
fir::unwrapRefType(globalOp.resultType()))) {
|
||||||
|
mlir::Attribute initAttr =
|
||||||
|
globalOp.getInitVal().value_or(mlir::Attribute());
|
||||||
|
if (initAttr && mlir::dyn_cast<mlir::DenseElementsAttr>(initAttr))
|
||||||
|
candidates.insert(globalOp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (auto globalOp : candidates) {
|
for (auto globalOp : candidates) {
|
||||||
auto globalName{globalOp.getSymbol().getValue()};
|
auto globalName{globalOp.getSymbol().getValue()};
|
||||||
|
@ -11,3 +11,16 @@ module attributes {fir.defaultkind = "a1c4d8i4l4r4", fir.kindmap = "", gpu.conta
|
|||||||
|
|
||||||
// CHECK: gpu.module @cuda_device_mo
|
// CHECK: gpu.module @cuda_device_mo
|
||||||
// CHECK-NEXT: fir.global @_QMmtestsEn(dense<[3, 4, 5, 6, 7]> : tensor<5xi32>) {data_attr = #cuf.cuda<device>} : !fir.array<5xi32>
|
// CHECK-NEXT: fir.global @_QMmtestsEn(dense<[3, 4, 5, 6, 7]> : tensor<5xi32>) {data_attr = #cuf.cuda<device>} : !fir.array<5xi32>
|
||||||
|
|
||||||
|
// -----
|
||||||
|
|
||||||
|
module attributes {fir.defaultkind = "a1c4d8i4l4r4", fir.kindmap = "", gpu.container_module} {
|
||||||
|
fir.global @_QMm1ECb(dense<[90, 100, 110]> : tensor<3xi32>) constant : !fir.array<3xi32>
|
||||||
|
fir.global @_QMm2ECc(dense<[100, 200, 300]> : tensor<3xi32>) constant : !fir.array<3xi32>
|
||||||
|
}
|
||||||
|
|
||||||
|
// CHECK: fir.global @_QMm1ECb
|
||||||
|
// CHECK: fir.global @_QMm2ECc
|
||||||
|
// CHECK: gpu.module @cuda_device_mod
|
||||||
|
// CHECK-DAG: fir.global @_QMm2ECc
|
||||||
|
// CHECK-DAG: fir.global @_QMm1ECb
|
||||||
|
Loading…
x
Reference in New Issue
Block a user