[flang-commits] [flang] [OpenMP][Flang] Add "IsolatedFromAbove" trait to omp.target (PR #67164)

Kiran Chandramohan via flang-commits flang-commits at lists.llvm.org
Thu Oct 12 14:08:20 PDT 2023


kiranchandramohan wrote:

> > I have another question. Are these bounds required for the map operation, then shouldn't they be part of the `map_info` operation or the variable being mapped?
> 
> Yes, and MapInfoOps are currently being created for them.

If the bounds are really required for the map operation then shouldn't be captured as part of the `omp.map_info` operation. Can it not be captured by creating an `omp.bounds` operation that feeds into the `omp.map_info`? If not, can we add another entry to `omp.map_info` to capture this? 

Also, consider the `omp.map_info` defining a(n,1024) `VAL_6`, it points back to the `hlfir.declare` of `VAL_5` which has shape `VAL_4` that includes `VAL_1` and `VAL_2`. So, through the map_info of `a` we can actually retrieve `VAL_1` and `VAL_2`.   For the purpose of the mapping operation, isn't this sufficient? Or is it that these `fir.shape` operations are not available by the time we reach the interfacing with LLVM? 

```
   !CHECK: %[[VAL_1:.*]] = arith.select %{{.*}}, %{{.*}}, %{{.*}} : index
   !CHECK: %[[VAL_2:.*]] = arith.select %{{.*}}, %{{.*}}, %{{.*}} : index
   !CHECK: %[[VAL_3:.*]] = fir.alloca !fir.array<?x1024xi32>, %[[VAL_1]] {bindc_name = "a", uniq_name = "_QFomp_target_implicit_boundsEa"}
   !CHECK: %[[VAL_4:.*]] = fir.shape %[[VAL_1]], %[[VAL_2]] : (index, index) -> !fir.shape<2>
   !CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_3]](%[[VAL_4]]) {uniq_name = "_QFomp_target_implicit_boundsEa"} : (!fir.ref<!fir.array<?x1024xi32>>, !fir.shape<2>) -> (!fir.box<!fir.array<?x1024xi32>>, !fir.ref<!fir.array<?x1024xi32>>)
   integer :: n
   integer :: a(n, 1024)
   !CHECK: %[[VAL_6:.*]] = omp.map_info var_ptr(%[[VAL_5]]#1 : !fir.ref<!fir.array<?x1024xi32>>)   map_clauses(literal, implicit, exit_release_or_enter_alloc) capture(ByCopy) -> !fir.ref<!fir.array<?x1024xi32>> {name = "a"}
   !CHECK: %[[VAL_7:.*]] = omp.map_info var_ptr(%[[VAL_1]] : index)   map_clauses(literal, implicit, exit_release_or_enter_alloc) capture(ByCopy) -> index {name = ""}
   !CHECK: %[[VAL_8:.*]] = omp.map_info var_ptr(%[[VAL_2]] : index)   map_clauses(literal, implicit, exit_release_or_enter_alloc) capture(ByCopy) -> index {name = ""}
   !CHECK: omp.target   map_entries(%[[VAL_6]] -> %[[ARG_1:.*]], %[[VAL_7]] -> %[[ARG_2:.*]], %[[VAL_8]] -> %[[ARG_3:.*]] : !fir.ref<!fir.array<?x1024xi32>>, index, index) {
   ```

If you really have to move forward with using the `omp.map_info` for values of type `index` then consider either renaming `varPtr` to a separate name or add an additional entry to `omp.map_info`.



https://github.com/llvm/llvm-project/pull/67164


More information about the flang-commits mailing list