[flang][cuda] Bring PARAMETER arrays into the GPU module (#146416)

This commit is contained in:
Valentin Clement (バレンタイン クレメン) 2025-06-30 14:24:44 -07:00 committed by GitHub
parent 56739f5866
commit f4cecfe1bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 1 deletions

View File

@ -113,8 +113,16 @@ public:
return signalPassFailure();
mlir::SymbolTable gpuSymTable(gpuMod);
for (auto globalOp : mod.getOps<fir::GlobalOp>()) {
if (cuf::isRegisteredDeviceGlobal(globalOp))
if (cuf::isRegisteredDeviceGlobal(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) {
auto globalName{globalOp.getSymbol().getValue()};

View File

@ -11,3 +11,16 @@ module attributes {fir.defaultkind = "a1c4d8i4l4r4", fir.kindmap = "", gpu.conta
// 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>
// -----
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