Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Flang][OpenMP][MLIR] Extend derived (record) type map support in Fla…
…ng and OpenMP dialect This patch seeks to refactor slightly and extend the current record type map support that was put in place for Fortran's descriptor types to handle explicit member mapping for record types at a single level of depth. For example, the below case where two members of a Fortran derived type are mapped explicitly: '''' type :: scalar_and_array real(4) :: real integer(4) :: array(10) integer(4) :: int end type scalar_and_array type(scalar_and_array) :: scalar_arr !$omp target map(tofrom: scalar_arr%int, scalar_arr%real) '''' Current cases of derived type mapping left for future work are: > explicit member mapping of nested members (e.g. two layers of record types where we explicitly map a member from the internal record type) > Fortran's automagical mapping of all elements and nested elements of a derived type > explicit member mapping of a derived type and then constituient members (redundant in Fortran due to former case but still legal as far as I am aware) > explicit member mapping of a record type (may be handled reasonably, just not fully tested in this iteration) > explicit member mapping for Fortran allocatable types (a variation of nested record types) This patch seeks to support this by extending the OpenMPToLLVMIRTranslation phase to more generally support record types, building on the prior groundwork in the Fortran allocatables/pointers patch. It now supports different kinds of record type mapping, in this case full record type mapping and then explicit member mapping in which there is a special case for certain types when mapped individually to not require any parent map link in the kernel argument structure. To facilitate this required: > The movement of the setting of the map flag type "ptr_and_obj" to respective frontends, now supporting it as a possible flag that can be read and printed in mlir form. Some minor changes to declare target map type setting was neccesary for this. > The addition of a member index array operand, which tracks the position of the member in the parent, required for caclulating the appropriate size to offload to the target, alongside the parents offload pointer (always the first member currently being mapped). > A partial mapping attribute operand, to indicate if the entire record type is being mapped or just member components, aiding the ability to lower record types in the different manners that are possible. > Refactoring bounds calculation for record types and general arrays to one location (as well as load/store generation prior to assigning to the kernel argument structure), as a side affect enter/exit/update/data mapping should now be more correct and fully support bounds mapping, previously this would have only worked for target. It also extends the Flang-new OpenMP lowering to support generation of this newly required information, creating the neccessary parent <-to-> member map_info links, calculating the member indices and setting if it's a partial map. The OMPDescriptorMapInfoGen pass has been generalized into a map finalization phase, now named OMPMapInfoFinalization. This pass was extended to support the insertion of member maps into the BlockArg and MapOperands of relevant map carrying operations. Similar to the method in which descriptor types are expanded and constituient members inserted. Otherwise, this patch contains a large amount of tests, both runtime and compilation related, which will hopefully help showcase the cases this patch aims to cover and the IR changes neccesary.
- Loading branch information