Use typed assignment in Atomic Write lowering to better handle
type conversions of allowed types.
Note: We should make similar changes for other constructs in
later patches.
Reviewed By: NimishMishra
Differential Revision: https://reviews.llvm.org/D154163
This is an attempt at mimicing the method in which
threadprivate handles the following type of variables:
program main
integer :: i
!$omp declare target to(i)
end
Which essentially generates a GlobalOp for the variable (which
would normally only be an alloca) when it's instantiated. The
main difference is there is no operation generated within the
function, instead the declare target attribute is appended
later within handleDeclareTarget.
Reviewers: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D152037
This patch lowers allocatables and pointers named in "private" OpenMP clause.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D148570
This patch extends the logic for lowering loop construct reductions to parallel block reductions.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D154182
This patch fixes location information of a few OpenMP constructs
and clauses. More fixes will come in follow-up patches.
This patch follows the same fixes for OpenACC (D131659).
Addresses some of the issues in https://github.com/llvm/llvm-project/issues/57215
Reviewed By: clementval
Differential Revision: https://reviews.llvm.org/D153887
Add lowering support for the use_device_ptr and use_Device_addr clauses for the Target Data directive.
Depends on D152822
Differential Revision: https://reviews.llvm.org/D152824
[flang][OpenMP][OpenACC] Support stop statement in OpenMP/OpenACC region
This supports lowering of stop statement in OpenMP/OpenACC region.
* OpenMP/OpenACC: Emit `fir.unreachable` only if the block is not
terminated by any terminator. This avoids knocking off an existing
OpenMP/OpenACC terminator.
* OpenMP: Emit the OpenMP terminator instead of `fir.unreachable` since
OpenMP regions can only be terminated by OpenMP terminators. This is
currently skipped for OpenACC since unstructured code is not yet
handled specially in OpenACC lowering.
Fixes#60737Fixes#61877
Co-authored-by: Kiran Chandramohan <kiranchandramohan@gmail.com>
Co-authored-by: Val Donaldson <vdonaldson@nvidia.com>
Reviewed By: vdonaldson, peixin
Differential Revision: https://reviews.llvm.org/D129969
This patch fixes an unused variable warning that was caused by the task
depend patch.
Original Commit: 3373c8405c
Original Differential Revision: https://reviews.llvm.org/D146766
This patch adds support for the OpenMP 4.0 depend clause for the task
construct, excluding array sections, to Flang lowering from parse-tree
to MLIR.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D146766
This patch adds PFT lowering for the OpenMP declare target directive
in Flang to the omp dialects declare target attribute, which currently
applies to function or global operations.
Reviewers: kiranchandramohan, skatrak, jsjodin
Differential Revision: https://reviews.llvm.org/D150329
This is a valid usage. We do not handle it as of now. Gfortran/Ifx produces an error, possibly because `do concurrent` was not allowed in previous versions of the OpenMP standard.
Fixes#62649
Reviewed By: Leporacanthicus
Differential Revision: https://reviews.llvm.org/D150869
This patch adds lowering support for atomic capture operation. First is
created a region (without any operand) for the atomic capture operation.
Then based on one of the following configurations...
1. [update-stmt, capture-stmt]
2. [capture-stmt, update-stmt]
3. [capture-stmt, write-stmt]
... the lowering proceeds by creating these individual operations inside
the atomic capture's region.
Differential Revision: https://reviews.llvm.org/D127272
Reviewed By: kiranchandramohan
construct
This patch adds lowering support for lastprivate privatization on
unstructured construct. Generic lastprivate lowering on sections
involves creating a if operation on the lexically last section block
and updating the lastprivate variable inside it. However, this control
flow is not needed if the section construct is lowered as an
unstructured construct. Hence, this patch modifies the lowering control
flow to not emit an unnecessary scf.if if the section block is lowered
as an unstructured construct.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D143077
For finding the last iteration of a loop, or the last section an
if condition is generated. Using scf::if can cause some lowering
issues since the code contained inside it can have branches. Using
fir::if instead ensures that the fir::if is lowered into branches
along with any code contained inside that can generate branches.
Fixes#62458.
Reviewed By: NimishMishra
Differential Revision: https://reviews.llvm.org/D149547
This patch adds support for reduction of min-intrinsic for scalar
types. Min is lowered as a compare-select in the default lowering
flow for Flang. This pattern is matched and replaced with the
OpenMP dialect reduction operation.
Note: This is a temporary flow. The plan is to move to a flow
where the OpenMP reduction operation is inserted during lowering.
This patch fixes a crash that appear in an OpenMP MAX intrinsic
reduction when the reduction is not expressed using MAX intrinsic
function. Updated flang/test/Lower/OpenMP/wsloop-reduction-max.f90
test case with additional way of expressing MAX reduction.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D146967
This patch adds TODO checks for unspported types in the map clause for OpenMP Target directives.
Example of unsupported code:
implicit none
character(len=10) :: str1, str2(5,5)
type t
character(len=10) :: str1, str2(5,5)
end type t
type(t) :: v
!$omp target enter data map(to: str2(2,5))
!$omp target enter data map(to: v%str1)
!$omp target enter data map(to: v%str2)
!$omp target enter data map(to: v%str2(1,2))
end
Differential Revision: https://reviews.llvm.org/D146292
This patch adds support for reduction of max-intrinsic for scalar
types. Max is lowered as a compare-select in the default lowering
flow for Flang. This pattern is matched and replaced with the
OpenMP dialect reduction operation.
Note: This is a temporary flow. The plan is to move to a flow where
the OpenMP reduction operation is inserted during lowering.
Reviewed By: do
Differential Revision: https://reviews.llvm.org/D145083
This patch adds support for reduction of max-intrinsic for scalar
types. Max is lowered as a compare-select in the default lowering
flow for Flang. This pattern is matched and replaced with the
OpenMP dialect reduction operation.
Note: This is a temporary flow. The plan is to move to a flow where
the OpenMP reduction operation is inserted during lowering.
Reviewed By: do
Differential Revision: https://reviews.llvm.org/D145083
The patch adds the lowering from Flang parse-tree to FIR+OpenMP. The
conversion code is also added in MLIR.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D133442
Co-authored-by: Kiran Chandramohan <kiran.chandramohan@arm.com>
The code for handing privatization code has grown in complexity.
This patch begins an effort to refactor and simplify the code.
The refactoring will hopefully will make it modular and
enable privatization to be invoked in different places. This
patch moves the privatization related code into a class called
dataSharingProcessor.
Reviewed By: DavidTruby
Differential Revision: https://reviews.llvm.org/D144766
Provide the name of the construct and the clause info (reduction)
in the TODO mesage.
Reviewed By: DavidTruby
Differential Revision: https://reviews.llvm.org/D145061
This patch adds support for lastprivate on sections construct.
One omp.sections operation can have several omp.section operation. As such, the privatization happens in the lexically last omp.section operation.
Reviewed By: kiranchandramohan, peixin
Differential Revision: https://reviews.llvm.org/D133686
This patch adds support for the OpenMP 4.0 depend clause (in, out,
inout) of the task construct to the definition of the OpenMP MLIR
dialect and translation from MLIR to LLVM IR using OMPIRBuilder.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D142730
In lowering code Flang follows the MLIR coding guideline of using
camelBack for variables names. Correct a few instances that were
not following this guideline.
The current OpenMP implementation assumes the use of typed pointers (or rather typed pointer like types). Given the support for typed pointers in LLVM is now pending removal, the OpenMP Dialect should be able to support opaque pointers as well, given that any users of it must lower OpenMP through the LLVM Dialect.
This patch fixes the above and adds support for using LLVM opaque pointers with the OpenMP dialect. This is implemented by making all related code not make use of the element type of pointer arguments. The few (one) op requiring a pointer element type now use an explicit `TypeAttr` for representing the element type.
More concretely, the list of changes are:
* `omp.atomic.read` now has an extra `TypeAttr` (also in syntax) which is the element type of the values read and stored from the operands
* `omp.reduction` now has an type argument in the syntax for both the accmulator and operand since the operand type can no longer be inferred from the accumulator
* `OpenMPToLLVMIRTranslation.cpp` was rewritten to never query element types of pointers
* Adjusted the verifier to be able to handle pointers without element types
Differential Revision: https://reviews.llvm.org/D143582
This patch adds Fortran Lowering support for the OpenMP Target Data, Target Exit Data and Target Enter Data constructs.
operation.
Differential Revision: https://reviews.llvm.org/D142357
simd nontemporal construct is represented as a list of variables
which have low locality accross simd iterations
Added verifier of nontemporal clause. MLIR tests were updated to test
correctness of MLIR definition of nontemporal clause.
Differential Revision: https://reviews.llvm.org/D140553
Reviewed By: kiranchandramohan
OpenMP 5.0 adds support for the "requires" directive. This patch adds parser support for it in flang.
Differential revision: https://reviews.llvm.org/D136867
simd aligned construct is represented as pair of variable which needs
to be aligned and corresponding alignment value.
Added parser, printer and verifier of aligned clause. MLIR tests were
updated to test correctness of MLIR definition of aligned clause.
Differential Revision: https://reviews.llvm.org/D135865
Reviewed By: kiranchandramohan
The symbol may be used by use-association for multiple times such
as one in module specification part and one in module procedure.
Then in module procedure, the variable instantiation will be called
for multiple times. But we only need to threadprivatize it once and
use the threadprivatized value for the second time.
Fix#58379.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D136035
nullptr matches both against ::mlir::UnitAttr and ::mlir::TypeRange,
so the following two candidates fit:
static void mlir::omp::OrderedRegionOp::build(::mlir::OpBuilder &odsBuilder,
::mlir::OperationState &odsState,
/*optional*/::mlir::UnitAttr simd)
static void mlir::omp::OrderedRegionOp::build(::mlir::OpBuilder &odsBuilder,
::mlir::OperationState &odsState,
::mlir::TypeRange resultTypes,
/*optional*/bool simd = false)
This supports the lowering of private and firstprivate clauses in single
construct. The alloca ops are emitted in the entry block according to
https://llvm.org/docs/Frontend/PerformanceTips.html#use-of-allocas, and
the load/store ops are emitted in the single region. The data race
problem is handled in OMPIRBuilder. That is, the barrier is emitted in
OMPIRBuilder.
Co-authored-by: Nimish Mishra <neelam.nimish@gmail.com>
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D128596
This flips all of the remaining dialects to prefixed except for linalg, which
will be done in a followup.
Differential Revision: https://reviews.llvm.org/D134995