Commit Graph

187 Commits

Author SHA1 Message Date
Valentin Clement (バレンタイン クレメン)
b171849afe [flang][openacc] Use OpenACC terminator instead of fir.unreachable after Stop stmt (#66325)
This follow an update made on OpenMP https://reviews.llvm.org/D129969
and was not possible on OpenACC until the unstructured construct was
supported.
2023-09-13 22:28:02 -07:00
Valentin Clement (バレンタイン クレメン)
b1341e2863 [flang][openacc] Fix unstructured code in OpenACC region ops (#66284)
For unstructured construct, the blocks are created in advance inside the
function body. This causes issues when the unstructured construct is
inside an OpenACC region operations. This patch adds the same fix than
OpenMP lowering and re-create the blocks inside the op region.

Initial OpenMP fix: 29f167abcf
2023-09-13 20:49:54 -07:00
Razvan Lupusoru
e070ea47a9 [flang][openacc] Enable lowering support for OpenACC atomic operations (#65776)
Since the OpenACC atomics specification is a subset of OpenMP atomics,
the same lowering implementation can be used. This change extracts out
the necessary pieces from the OpenMP lowering and puts them in a shared
spot. The shared spot is a header file so that each implementation can
template specialize directly.

After putting the OpenMP implementation in a common spot, the following
changes were needed to make it work for OpenACC:
* Ensure parsing works correctly by avoiding hardcoded offsets.
* Templatize based on atomic type.
* The checking whether it is OpenMP or OpenACC is done by checking for
OmpAtomicClauseList (OpenACC does not implement this so we just
templatize with void). It was preferable to check this instead of atomic
type because in some cases, like atomic capture, the read/write/update
implementations are called - and we want compile time evaluation of
these conditional parts.
* The memory order and hint are used only for OpenMP.
* Generate acc dialect operations instead of omp dialect operations.
2023-09-11 13:58:10 -07:00
Valentin Clement (バレンタイン クレメン)
8bc676c2ec [flang][openacc] Lower acc cache directive (#65673)
The cache directive is attached directly to the acc.loop operation when
the directive appears in the loop. When it appears before a loop, the
OpenACCCacheConstruct is saved and attached when the acc.loop is
created.

Directive that cannot be attached to a loop are silently discarded. 

Depends on #65521
2023-09-11 13:38:21 -07:00
Valentin Clement (バレンタイン クレメン)
996171a412 [mlir][openacc] Model acc cache directive as data entry operands on acc.loop (#65521)
The `cache` directive may appear at the top of (inside of) a loop. It
specifies array elements or subarrays that should be fetched into the
highest level of the cache for the body of the loop.

The `cache` directive is modeled as a data entry operands attached to
the acc.loop operation.
2023-09-11 13:38:03 -07:00
Valentin Clement (バレンタイン クレメン)
20f4a5a313 [flang][openacc][NFC] Clean up lowering api (#65678)
Remove unused argument `pft::Evaluation` from higher level lowering API.
2023-09-07 14:54:38 -07:00
Valentin Clement
e8824e05e3 [flang][openacc] Relax required clauses on acc data as portability warning
Some compilers accept `!$acc data` without any clauses. For portability
reason, this patch relaxes the strict error to a simple portability warning.

Reviewed By: razvanlupusoru, vzakhari

Differential Revision: https://reviews.llvm.org/D159019
2023-08-29 14:57:50 -07:00
Valentin Clement
d77ae428e0 Revert "[compiler-rt] Use just built libatomic if available"
This reverts commit 02fa9fc018.

Commit message and content does not match. Revert to commit with
a proper commit message.
2023-08-29 14:54:33 -07:00
Alex Brachet
02fa9fc018 [compiler-rt] Use just built libatomic if available
Use libclang_rt.atomic.so instead of the libatomic installed
on the system if it is available.

Differential Revision: https://reviews.llvm.org/D151680
2023-08-29 14:53:01 -07:00
Valentin Clement
52683899fc [flang][openacc] Fix crash with array section in acc declare in function
getSymbolFromAccObject was hitting the fatal error when
trying to retrieve the symbol on array section

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D158881
2023-08-28 08:59:04 -07:00
Valentin Clement
2db0acb279 [flang][NFC] Use the constexpr instead of hardcoded -1 2023-08-24 09:40:38 -07:00
Valentin Clement
9d7c7f6983 [flang][openacc] Lower acc set directive
Lower the acc set directive to the acc.set op.

Depends on D158554

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D158555
2023-08-23 14:08:39 -07:00
Valentin Clement
22209a673e [flang][openacc] Keep routine information in the module file
This patch propagates the acc routine information
to the module file so they can be used by the caller.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D158541
2023-08-23 08:56:55 -07:00
Valentin Clement
4d04baeca5 [flang][openacc] Lower acc declare to the new acc.declare function
Lower the acc delcare directive in function/subroutine
to the newly introduced acc.declare operation. Only a single
acc.declare operation is procduced in a function or subroutine
so they don't end up nested.

Depends on D158314

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D158315
2023-08-21 12:39:02 -07:00
Valentin Clement
69a6bd5f05 [flang][openacc] Lower acc routine with function name
The routine directive can appear in the specification part of
a subroutine, function or module and therefore appear before the
function or subroutine is lowered. We keep track of the created
routine info attribute and attach them to the function at the end
of the lowering if the directive appeared before the function was
lowered.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D158204
2023-08-17 14:25:26 -07:00
Slava Zakharin
de2be3e469 [flang][hlfir] Use the HLFIR base of hlfir.declare if possible.
This patch makes use of the HLFIR box produced for hlfir.declare
in place of the FIR box (the memref of hlfir.declare) when possible.

This makes the representation a little bit more clear, because
all accesses are made via a single box.
This reduces the life range of the original box, because the new
temporary box produced by embox/rebox is used from now.
Apparently, this works around some issues in the current HLFIR codegen,
for example, look at the LIT tests changes around fir.array_coor
produced by hlfir.designate codegen - using the FIR box for fir.array_coor
might result in using incorrect lbounds.
Apparently, this change enables more intrinsics simplifications
because the SimplifyIntrinsicsPass looks for explicit embox/rebox
in findBoxDef() to decide whether to apply the optimization.
This change also provides better association of the base addresses
referenced by OpenACC clauses with the corresponding boxes
that might be used explicitly in OpenACC regions (e.g. for reading
the lbounds).

Reviewed By: razvanlupusoru, clementval

Differential Revision: https://reviews.llvm.org/D158119
2023-08-16 17:56:23 -07:00
Valentin Clement
b1d0f5f7cd [flang][openacc] Lower the bind clause on acc routine
Lower the bind clause to the corresponding attribute

Depends on D158120

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D158121
2023-08-16 15:20:32 -07:00
Valentin Clement
939bdaec18 [flang][openacc] Attach attribute only when there is an exit operation
Not all declare clause have an exit operation attach to them and
therefore no dealloc function generated. Attach
the pre/post deallocation attribute only for the clauses that have
an exit operation.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D158106
2023-08-16 13:10:43 -07:00
Valentin Clement
9a96b0a0dc [flang][openacc] Generate pre/post alloc/dealloc function for in subroutine declare
Lowering was missing to generate the pre/post alloc/dealloc
functions for the acc declare variables. This patch adds the generation.
These functions have the descriptor as their unique argument.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D158103
2023-08-16 13:04:33 -07:00
Valentin Clement
1640b80d6f [flang][openacc] Lower gang, vector, worker, seq and nohost for acc routine
Lower clauses to the routine info op.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D158007
2023-08-16 11:22:40 -07:00
Valentin Clement
0e7649698a [flang][openacc] Fix post deallocate suffix
The wrong suffix was applied

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D158098
2023-08-16 11:09:42 -07:00
Valentin Clement
e18672ad3a [flang][openacc] Add routine info attribute to the function
Attch the routine info attribute to the func operation.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D157998
2023-08-15 22:19:03 -07:00
Valentin Clement
9334671aa7 [flang][openacc] Lower simple acc routine directive
This patch lower simple acc routine directive
with no clauses and no name inside function/subroutine.

Patch to handle name and clauses will follow up.
Patch to add attribute to the original routine will follow as well.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D157919
2023-08-15 09:45:57 -07:00
Valentin Clement
2e1982f31d [flang][openacc] Add acc.declare_action attributes on operation
This patches adds the acc.declare_action attrbites on
post allocate operation and pre/post deallocate operations.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D157915
2023-08-15 09:44:42 -07:00
Valentin Clement
69a337e2c7 [flang][openacc][NFC] Rename createRegisterFunc and refactor
Depends on D157530

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D157555
2023-08-10 10:57:25 -07:00
Valentin Clement
c54bb3d239 [flang][openacc] Set exit op for device_resident to acc.delete
The exit operation for the declare device_resident in function/subroutine
is set to delete. Make is consistent and set it also for global declare.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D157537
2023-08-10 10:56:09 -07:00
Valentin Clement
672a2c4a5a [flang][openacc] Generate declare pre/post dealloc function
Generate the function dealing with the action on deallocation (pre/post) of
a declare variable.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D157530
2023-08-10 10:55:12 -07:00
Valentin Clement
7b24612c6f [flang][openacc] Always generate acc.declare_exit
Always generate the acc.declare_exit operation so it
matches the acc.declare_enter operation. This is to ensure the
lifetime of data in the implicit region.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D157524
2023-08-09 11:11:45 -07:00
Valentin Clement
0b837e24ec [flang][openacc] Fix declare attribute for device_resident, link and deviceptr
When creating declare entry operation, the variable needs to be flagged
with the declare attribute. This was not done for device_resident, link and
deviceptr.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D157522
2023-08-09 11:08:30 -07:00
Valentin Clement
606bb8080e [flang][openacc][NFC] Remove set but not used variable 2023-08-09 10:36:02 -07:00
Valentin Clement
ade0aa6163 [flang][openacc] Generate the declare register function
Generate the register function for global declare
variable. This function is meant to be called after the
actual data is allocated. Patch to insert the function call
and attribute will follow.

Depends on D157338

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D157339
2023-08-09 10:25:30 -07:00
Valentin Clement
475938d12c [flang][openacc] Update the global ctor for descriptor
The global ctor for acc declare when the variable is a descriptor
is treated differently. The descriptor is implicity copied in.
An additional registering function will be generated to deal with
the data pointer when the data is actually allocated. This will come in
a follow up patch.

The descriptor is not a user visible detail but an implementation detail.
The intent for declare is that the lifetime is implicitly managed - and the
data must be on device. Since descriptor holds pointer to the data,
it makes sense to also make this available on device at same time.
Copyin is used because it contains relevant details about the data such
as bounds.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D157338
2023-08-08 15:14:11 -07:00
Valentin Clement
5cb48f7543 [flang][openacc] Add lowering support for device_resident clause on OpenACC declare
Depends on D156828

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D156829
2023-08-07 10:16:32 -07:00
Valentin Clement
b82c259370 [flang][openacc] Add lowering support for the link clause on OpenACC declare
Lower link clause with data entry operation.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D156913
2023-08-03 10:22:32 -07:00
Valentin Clement
07000998e4 [flang][openacc] Add lowering support for deviceptr clause on OpenACC declare
Lower the deviceptr clause for the OpenACC declare directive.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D156828
2023-08-02 21:04:21 -07:00
Valentin Clement
34e53bf1cb [flang][openacc] Add lowering support for copyout clause on OpenACC declare
Lower the copyout clause for the OpenACC declare directive

Depends on D156738

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D156824
2023-08-02 15:54:49 -07:00
Valentin Clement
0058c92609 [flang][openacc] Add lowering support for copyin clause on OpenACC declare
Depends on D156721

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D156738
2023-08-01 14:15:38 -07:00
Valentin Clement
392203d8ac [flang][openacc] Add lowering support for present clause on OpenACC declare
Lower the present clause on the OpenACC declare construct in
function/subroutine.

Depends on D156572

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D156721
2023-08-01 14:14:48 -07:00
Valentin Clement
29851f48fa [flang][openacc] Add lowering support for create clause on OpenACC declare
Lower the create clause on the OpenACC declare construct in
function/subroutine.

Depends on D156568

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D156572
2023-08-01 14:12:40 -07:00
Valentin Clement
14741ef88f [flang][openacc] Lower the exit part for OpenACC declare in function/subroutine
This patch adds lowering for the exit part of the OpenACC declare construct
in function/subroutine.

Depends on D156560

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D156568
2023-08-01 14:10:33 -07:00
Valentin Clement
ba2082cdff [flang][openacc] Lower the entry part for OpenACC declare in function/subroutine
This patch adds lowering for the entry part of the OpenACC declare construct
in function/subroutine. The exit part will come as a follow up patch.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D156560
2023-08-01 14:04:30 -07:00
Valentin Clement
887b69c1f1 [flang][openacc] Disallow the zero modifier on the create clause with the declare directive
The OpenACC 3.3 specification does not allow the `zero` modifier
on the `create` clause used with the declare directive.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D156703
2023-07-31 14:29:56 -07:00
Valentin Clement
27f39ad499 [flang][openacc] Set structured to false for entry operation in declare ctor
Fix the value of the structured attribute for entry operation in the
global constructor noted in D156353.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D156481
2023-07-28 09:48:14 -07:00
Valentin Clement
723e424e56 [flang][openacc][NFC] Remove unused variables 2023-07-27 14:06:18 -07:00
Valentin Clement
2a81925163 [flang][openacc][NFC] Move declare lowering for module in its own function 2023-07-27 14:03:32 -07:00
Valentin Clement
a2b92017d3 [flang][openacc] Lower acc declare link for module variable
This patch adds support to lower the link clause on OpenACC
declare construct in module declaration.

Depends on D156463

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D156464
2023-07-27 13:04:00 -07:00
Valentin Clement
bbd214d997 [flang][openacc] Lower acc declare device_resident for module variable
This patch adds support to lower the device_resident clause on OpenACC
declare construct in module declaration.

Depends on D156457

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D156463
2023-07-27 13:01:22 -07:00
Valentin Clement
5f2c585b10 [flang][openacc] Lower acc declare copyin for module variable
This patch adds support to lower the copyin clause on OpenACC
declare construct in module declaration.

Depends on D156353

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D156457
2023-07-27 13:00:20 -07:00
Valentin Clement
e25d7f1688 [flang][openacc] Add global destructor for acc declare construct
Add the acc.global_dtor when lowering the OpenACC declare
construct.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D156353
2023-07-27 12:59:01 -07:00
Valentin Clement
c217ff8794 [flang][openacc] Add basic lowering for OpenACC declare construct in module
This patch adds the skeleton and the basic lowering for OpenACC declare
construct when located in the module declaration. This patch just lower the
create clause with or without modifier. Other clause and global descrutor
lowering will come in follow up patches to keep this one small enough for
review.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D156266
2023-07-26 09:56:19 -07:00