mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 12:36:10 +00:00
[flang][cuda] Add gpu.launch to device context (#123105)
`gpu.launch` should also be considered device context.
This commit is contained in:
parent
2bb5ca537b
commit
ce30ee53a8
@ -224,6 +224,8 @@ static bool inDeviceContext(mlir::Operation *op) {
|
||||
return true;
|
||||
if (auto funcOp = op->getParentOfType<mlir::gpu::GPUFuncOp>())
|
||||
return true;
|
||||
if (auto funcOp = op->getParentOfType<mlir::gpu::LaunchOp>())
|
||||
return true;
|
||||
if (auto funcOp = op->getParentOfType<mlir::func::FuncOp>()) {
|
||||
if (auto cudaProcAttr =
|
||||
funcOp.getOperation()->getAttrOfType<cuf::ProcAttributeAttr>(
|
||||
|
@ -65,3 +65,28 @@ module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<f80, dense<128> :
|
||||
// There is no symbol for it and the call would result into an unresolved reference.
|
||||
// CHECK-NOT: fir.call {{.*}}GetDeviceAddress
|
||||
|
||||
// -----
|
||||
|
||||
module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<f80, dense<128> : vector<2xi64>>, #dlti.dl_entry<i128, dense<128> : vector<2xi64>>, #dlti.dl_entry<i64, dense<64> : vector<2xi64>>, #dlti.dl_entry<!llvm.ptr<272>, dense<64> : vector<4xi64>>, #dlti.dl_entry<!llvm.ptr<271>, dense<32> : vector<4xi64>>, #dlti.dl_entry<!llvm.ptr<270>, dense<32> : vector<4xi64>>, #dlti.dl_entry<f128, dense<128> : vector<2xi64>>, #dlti.dl_entry<f64, dense<64> : vector<2xi64>>, #dlti.dl_entry<f16, dense<16> : vector<2xi64>>, #dlti.dl_entry<i32, dense<32> : vector<2xi64>>, #dlti.dl_entry<i16, dense<16> : vector<2xi64>>, #dlti.dl_entry<i8, dense<8> : vector<2xi64>>, #dlti.dl_entry<i1, dense<8> : vector<2xi64>>, #dlti.dl_entry<!llvm.ptr, dense<64> : vector<4xi64>>, #dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>>} {
|
||||
fir.global @_QMmod1Eadev {data_attr = #cuf.cuda<device>} : !fir.array<10xi32> {
|
||||
%0 = fir.zero_bits !fir.array<10xi32>
|
||||
fir.has_value %0 : !fir.array<10xi32>
|
||||
}
|
||||
func.func @_QQmain() attributes {fir.bindc_name = "test"} {
|
||||
%dim = arith.constant 1 : index
|
||||
gpu.launch blocks(%bx, %by, %bz) in (%grid_x = %dim, %grid_y = %dim, %grid_z = %dim)
|
||||
threads(%tx, %ty, %tz) in (%block_x = %dim, %block_y = %dim, %block_z = %dim) {
|
||||
%c10 = arith.constant 10 : index
|
||||
%1 = fir.shape %c10 : (index) -> !fir.shape<1>
|
||||
%3 = fir.address_of(@_QMmod1Eadev) : !fir.ref<!fir.array<10xi32>>
|
||||
%4 = fir.declare %3(%1) {data_attr = #cuf.cuda<device>, uniq_name = "_QMmod1Eadev"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> !fir.ref<!fir.array<10xi32>>
|
||||
gpu.terminator
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: func.func @_QQmain()
|
||||
// CHECK: gpu.launch
|
||||
// CHECK-NOT: fir.call {{.*}}GetDeviceAddress
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user