This fixes a bug in USM mode where the `close` map type modifer was attached to some `map.info.op`'s corresponding to user-defined type members while the parent type instance itself is not marked as `close`. This fix ensures that if a parent record type map does not have the 'close' flag, it is cleared from its members as well, maintaining consistency. Gemini was used to create tests. AI generated test code was reviewed line-by-line by me. Which were derived from a reproducer I was working with to debug the issue. Assisted-by: Gemini <gemini@google.com>
25 lines
1.5 KiB
Plaintext
25 lines
1.5 KiB
Plaintext
// RUN: fir-opt --split-input-file --omp-map-info-finalization %s | FileCheck %s
|
|
|
|
// Test that the 'close' map flag is cleared from member maps if the parent map
|
|
// (derived type) does not have the 'close' flag. This typically happens in
|
|
// Unified Shared Memory (USM) mode where the parent is in USM (no close) but
|
|
// members (like descriptors) might have been initially tagged with close.
|
|
|
|
module attributes {omp.requires = #omp<clause_requires unified_shared_memory>} {
|
|
func.func @test_usm_close_flag_cleanup(%arg0: !fir.ref<!fir.type<t{a:!fir.box<!fir.heap<!fir.array<?xf32>>>}>>) {
|
|
%map = omp.map.info var_ptr(%arg0 : !fir.ref<!fir.type<t{a:!fir.box<!fir.heap<!fir.array<?xf32>>>}>>, !fir.type<t{a:!fir.box<!fir.heap<!fir.array<?xf32>>>}>) map_clauses(to) capture(ByRef) -> !fir.ref<!fir.type<t{a:!fir.box<!fir.heap<!fir.array<?xf32>>>}>> {name = "parent"}
|
|
|
|
omp.target map_entries(%map -> %arg1 : !fir.ref<!fir.type<t{a:!fir.box<!fir.heap<!fir.array<?xf32>>>}>>) {
|
|
// Simulate usage to trigger implicit map addition
|
|
%1 = hlfir.designate %arg1{"a"} : (!fir.ref<!fir.type<t{a:!fir.box<!fir.heap<!fir.array<?xf32>>>}>>) -> !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
|
|
omp.terminator
|
|
}
|
|
return
|
|
}
|
|
}
|
|
|
|
// CHECK-LABEL: func.func @test_usm_close_flag_cleanup
|
|
// CHECK: %[[MEMBER:.*]] = omp.map.info {{.*}} map_clauses(always, to) {{.*}} {name = "parent.a.implicit_map"}
|
|
// CHECK: %[[PARENT:.*]] = omp.map.info {{.*}} map_clauses(to) {{.*}} members(%[[MEMBER]], {{.*}}) {{.*}} {name = "parent", {{.*}}}
|
|
// CHECK-NOT: close
|