Kwok Cheung Yeung wrote on July 9, 2025:
This patch adds support for non-constant iterator bounds to the Fortran deep-mapping iterator support.

To do this, we need to keep track of the new iterator entries generated during by the deep mapping. Code is generated by lower_omp_target to allocate memory for each of these entries one-by-one, then freed after the target code. allocate_omp_iterator_elems and free_omp_iterator_elems are modified so that they work on a per-iterator basis rather than per-clause.

LGTM. Thanks!

[Note that patch 10 is still pending review – otherwise, 4–9+11 are now 
reviewed.]

[Remark: The status in libgomp.texi should at least be dumped to 'P' after
those patches are in – pending is the interaction of iterators with strided
and, Fortran only, declare mapper.]

Subject: [PATCH 11/11] openmp, fortran: Add support for non-constant iterator
  bounds in Fortran deep-mapping iterator support

gcc/fortran/

        * trans-openmp.cc (gfc_omp_deep_mapping_map): Add new argument for
        vector of newly created iterators.  Push new iterators onto the
        vector.
        (gfc_omp_deep_mapping_comps): Add new argument for vector of new
        iterators.  Pass argument in calls to gfc_omp_deep_mapping_item and
        gfc_omp_deep_mapping_comps.
        (gfc_omp_deep_mapping_item): Add new argument for vector of new
        iterators.  Pass argument in calls to gfc_omp_deep_mapping_map and
        gfc_omp_deep_mapping_comps.
        (gfc_omp_deep_mapping_do): Add new argument for vector of new
        iterators.  Pass argument in calls to gfc_omp_deep_mapping_item.
        (gfc_omp_deep_mapping_cnt): Pass NULL to new argument for
        gfc_omp_deep_mapping_do.
        (gfc_omp_deep_mapping): Add new argument for vector of new
        iterators.  Pass argument in calls to gfc_omp_deep_mapping_do.
        * trans.h (gfc_omp_deep_mapping): Add new argument.

gcc/

        * langhooks-def.h (lhd_omp_deep_mapping): Add new argument.
        * langhooks.cc (lhd_omp_deep_mapping): Likewise.
        * langhooks.h (omp_deep_mapping): Likewise.
        * omp-low.cc (allocate_omp_iterator_elems): Work on the supplied
        iterator set instead of the iterators in a supplied set of clauses.
        (free_omp_iterator_elems): Likewise.
        (lower_omp_target): Maintain vector of new iterators generated by
        deep-mapping.  Allocate and free iterator element arrays using
        iterators found in clauses and in the new iterator vector.

libgomp/

        * testsuite/libgomp.fortran/allocatable-comp-iterators.f90: Add test
        for non-const iterator boundaries.
Tobias

Reply via email to