This includes a basic implementation for the OpenMP target data, exit data, and enter data constructs
operation.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
574 | Indent looks off. | |
591 | Since map is a required clause on the Fortran side it would be better to have it directly for the first version of the op. | |
596 | Indent. | |
608 | Not sure if there is a guidelines for that but I think op should use snake_case. At least in the OMP dialect snake_case is used until now so you should follow it. (ex: num_threads on the parallel op). | |
611 | Indent looks off in the description. | |
625 | Since map is a required clause on the Fortran side it would be better to have it directly for the first version of the op. | |
632 | I don't think it makes sense to have a region attached for standalone directives. | |
658 | Since map is a required clause on the Fortran side it would be better to have it directly for the first version of the op. | |
665 | I don't think exit data should have a region attached. |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
591 | map([[map-type-modifier[,]]map-type:]list) Based on Thread discussion, the following segmentation of the map clause operands should work. Optional<StringAttr>:$mapTypeModifier acc exit data and enter data also follow the same pattern. Any suggestions? |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
591 | Not sure it would do the trick since you can have multiple map clauses with different map type and map type modifier. If you model it like that you can have only one clause represented by operation. |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
591 | I intend to make it more in line with the OpenACC data environment; copy, copying, copyout. etc. Variadic<AnyType>:$mapOperands |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
591 | Also clause can take several map-type-modifier (map([ [map-type-modifier[,] [map-type-modifier[,] ...] map-type : ] locator-list)) so a single Optional<StringAttr> will not work. You might need a special type that encapsulate all the information. |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
591 | How about Variadic<AnyType>:$mapTypeModifier? or we need a separate operand for each map<X> Operands? I feel that we need a separate modifier operand for each map<X>Operands. |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
591 | I guess a enum would fit better here. The problem is that the map-type-modifier is associated with a specific map clause so if we have the different operands as you mentioned before, how do we know which one is associated with the map-type-modifier ? |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
591 | We need to know about each modifier for each map clause |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
591 | I don't think that's enough since you can have something like in the following example: !$omp target enter data map(always, to: a) map(to:b) In this case the two operands should end up in mapToOperands but with a different modifier. Maybe a vector holding the modifier for each operands would work (VectorOf<MapTypeModifier>). With this you would be able to store the operands in the mapToOperands with a vector of size 2 that holds the modifier values ([always, none]). The vector size is of course equal to the total number of operands in you 8 operands variadic arguments. |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
591 | MLIR does not have a VectorOf operation class. We need to define one ( I think, not an MLIR expert). The quick solution to this is to define an operand for each map-type for each type modifier. FOR "TO" Similarly, we can define for each map-type { from, tofrom , alloc ,release ,delete}. The only caveat is that we will have 24 operands for the operation. |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
591 | It has vectorof class. I took it from the mlir file directly. |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
591 | You might need to add it as an attribute instead of an operand. I didn’t check but for aure the operand segment attribute is an vector of int. |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
591 | let arguments = (ins Optional<I1>:$if_expr, Optional<AnyInteger>:$device, Variadic<AnyType>:$use_device_ptr, Variadic<AnyType>:$use_device_addr, Variadic<AnyType>:$mapOperands, Variadic<AnyType>:$mapToOperands, Variadic<AnyType>:$mapFromOperands, Variadic<AnyType>:$mapToFromOperands, Variadic<AnyType>:$mapAllocOperands, Variadic<AnyType>:$mapReleaseOperands, Variadic<AnyType>:$mapDeleteOperands, VectorOfLengthAndType<[7],[AnyType]>:$map_type_modifier_always, VectorOfLengthAndType<[7],[AnyType]>:$map_type_modifier_close, VectorOfLengthAndType<[7],[AnyType]>:$map_type_modifier_mapper); I feel this should work. The vectors will keep track of modifier for each map type. |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
591 | I think a single vector would be easier and you can encode the values of always, close and mapper (maybe in a uint). It is done like this in the runtime so you will have less processing during the translation. It will also accept new modifiers if newer version of the standard add some. The vector should not be fixed in size. Its size should be equal to the number of operands. Like if you have 2 operands in $mapOperands and in $mapToOperands` the vector size is 3. |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
591 | The vector should not be fixed in size. Its size should be equal to the number of operands. Like if you have 2 operands in $mapOperands and ( You mean 1 here right???) in $mapToOperands` the vector size is 3. We are assuming the order in which the map operands appear will define the operands in the vector map_type_modifier and the corresponding element will define the content (modifier defined by a unit). For example, consider the following: map (always, to : v1, v2) map(to: a, b) map ( from:p) we have five operands. The vector size is five. The vector representation [always, always, none, none, none] |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
591 | Yeah that's what I mean. If you find a better way represent the information it's also fine but I thought this is concise and will be perfectly fitted for the translation later. |
Added map clase support to target data, enter data and exit data
Revised according to the reviewer's comments
Added a test case
Used snake_case format
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
608 | There is still an indent problem here. | |
722 | Is AnyType really what we want here? Should be an enum or an integer encoding the value. As a side not, we could also have a single $map_operands argument and have a second vector to encode the map-type but that just a thought. |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
722 |
|
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
722 |
I think we try to be permissive where we have actual data but here is smith that we have to encode so I would make it more strict otherwise the translation will be complicated.
Sure it is just a suggestion. It is totally fine to keep it the way you have it now. OpenACC has multiple clauses to represent the different map-types so that's why it was done like that. |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
722 |
| |
722 | VectorOf<[AnyInteger]>:$map_type_modifier should be fine. Whatever the coding we adapt, it will be translated to an integer number for storing. |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
722 | Does this make sence? |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
722 | <IntOrIndex> should be Okay |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
674 | If I am correct, it is defining the region within which the scope exit. |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
674 | I'm pretty sure enter data does not need an attached region. It's a standalone directive so no other operation will be nested inside its region. target exit data does not have one so these two operations are very close and it should be reflected in their MLIR design. |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
584 | There still lines exceeding the 80 characters limit. Can you double check the whole patch so we can approve it. |
Looks okay to me, please wait for Kiran/Valentin's comments. Also, will you be adding assembly format/verifier for this later?
The summary says map clause is not supported but there are map operands in the patch. Can we get these two in sync - we should either update summary or remove map-related operands.
Also, please rebase before further reviews.
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
588 | please put variables in documentation within backticks(`). This is because when the documentation is rendered on mlir.llvm.org, $ and _ interact to give unexpected text if backticks are not used. |
Yes
The summary says the map clause is not supported but there are map operands in the patch. Can we get these two in sync - we should either update the summary or remove map-related operands.
Also, please rebase before further reviews.
Will do
Do you or did you work on the rest of the lowering to OpenMPIRBuilder/LLVM IR? Might be good to have the broader pictures sometime before designing the operation.
I put the line of action that we had in mind ( based on the OpenACC translation) in the FLANG meeting with other team members. I will work on the same line. My thinking is to work on translation and see what we need to change in the operation API at this level. But, I will clean and update the patch based on the feedback as it is hanging around too long.
Do we have any comments on this? I can submit the "assembly format" later. Need the operation definition for the next step : lowering to LLVM IR
Minor nits about documentation.
LGTM given that verifier and assembly format will be added soon for each of these as a separate patch soon. Please wait for atleast one more +1.
The OpenMP IRBuilder work does not have to wait for this patch to merge. You can start working on that while keeping this patch as a dependency.
clang/lib/Testing/CMakeLists.txt | ||
---|---|---|
6 ↗ | (On Diff #429235) | nit: Merge conflict. Please remove. |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
588 | nit: Ping on this comment. The variable names have not been put in backticks and this is going to cause issues with autogenerated documentation. | |
594 | Data mapping is very similar to data privatization. Would it be a good idea to push this to the frontends while we have not concretely decided on openmp dialect privatization/mapping? If you have an idea on how to implement mapping in OpenMP Dialect to LLVM IR maybe we can go ahead with this. CC @kiranchandramohan for suggestions regarding privatization. | |
661 | It is not clear which element in this list corresponds to which map type. It would be nice if we could either document that here, or have separate operands for each map type. (same for other two constructs too) |
clang/lib/Testing/CMakeLists.txt | ||
---|---|---|
33 ↗ | (On Diff #429235) | No, this is not okay. There is some issue with these patches and I don't know what it is, but these unrelated changes should not be seen here. Thank you for pointing this out :) |
clang/lib/Testing/CMakeLists.txt | ||
---|---|---|
6 ↗ | (On Diff #429235) | removed |
33 ↗ | (On Diff #429235) | removed them manually |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
594 | @kiranchandramohan @raghavendhra I would like to keep it like this! Any comments | |
661 | I feel keeping it in vector makes more sense. I will document it here. As per OpenMP Specifications: | |
718 | will document map type here as wekk |
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td | ||
---|---|---|
661 | Correction: map_type_modifier can be "always, close, and mapper" |
Revised the patcg according to the reviews of the reviewers.
clean the code and add some comments
@abidmalikwaterloo ninja check-mlir is failing with your most upto date patch. Can you please double check?
Thanks!
Why not adding the assemblyFormat directly for these operations like your patch D105584?
I just updated the patch. Something went wrong. I used arc diff --update <patch> for uploading. However, it seems it is not comparing the last submitted patch.
@abidmalikwaterloo Can you please check your last patch pushed for review? https://buildkite.com/llvm-project/diff-checks/builds/117796 states it can not apply your patch something to do with usage of diff --update <patch>? Can you please check?
@raghavendhra I tried to correct it but could not figure out the solution. Do you have any? I am not experienced with the phabricator framework. One solution is to submit another patch with all changes till today and abandon this one.
Sorry, I am new to phabricator as well. I use "arc diff" to upload my revisions for review after addressing review comments. If no one responds probably I am fine with new review and abandoning this one.
The problem is likely that the commit before the commit of this patch is not in tree,
The easiest way is to create a new branch from main and cherry-pick the commit you need for this patch on the top of it. Then you just use arc diff --update and it should work.
[MLIR][OpenMP] Added target data, exit data, and enter data operation definition for MLIR
Extra line doesn't seem to fit the file format.