-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Flang] [OpenMP] [Lowering] Add lowering support for IS_DEVICE_PTR and HAS_DEVICE_ADDR clauses on OMP TARGET directive. #67752
Conversation
@llvm/pr-subscribers-flang-fir-hlfir @llvm/pr-subscribers-flang-openmp ChangesThis is extension to #67290 Full diff: https://github.com/llvm/llvm-project/pull/67752.diff 1 Files Affected:
diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp
index 5f5e968eaaa6414..46cecb5854536a3 100644
--- a/flang/lib/Lower/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP.cpp
@@ -557,6 +557,18 @@ class ClauseProcessor {
llvm::SmallVectorImpl<mlir::Location> &useDeviceLocs,
llvm::SmallVectorImpl<const Fortran::semantics::Symbol *>
&useDeviceSymbols) const;
+ bool
+ processIsDevicePtr(llvm::SmallVectorImpl<mlir::Value> &operands,
+ llvm::SmallVectorImpl<mlir::Type> &isDeviceTypes,
+ llvm::SmallVectorImpl<mlir::Location> &isDeviceLocs,
+ llvm::SmallVectorImpl<const Fortran::semantics::Symbol *>
+ &isDeviceSymbols) const;
+ bool
+ processHasDeviceAddr(llvm::SmallVectorImpl<mlir::Value> &operands,
+ llvm::SmallVectorImpl<mlir::Type> &isDeviceTypes,
+ llvm::SmallVectorImpl<mlir::Location> &isDeviceLocs,
+ llvm::SmallVectorImpl<const Fortran::semantics::Symbol *>
+ &isDeviceSymbols) const;
// Call this method for these clauses that should be supported but are not
// implemented yet. It triggers a compilation error if any of the given
@@ -1824,6 +1836,34 @@ bool ClauseProcessor::processUseDevicePtr(
});
}
+bool ClauseProcessor::processIsDevicePtr(
+ llvm::SmallVectorImpl<mlir::Value> &operands,
+ llvm::SmallVectorImpl<mlir::Type> &isDeviceTypes,
+ llvm::SmallVectorImpl<mlir::Location> &isDeviceLocs,
+ llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> &isDeviceSymbols)
+ const {
+ return findRepeatableClause<ClauseTy::IsDevicePtr>(
+ [&](const ClauseTy::IsDevicePtr *devPtrClause,
+ const Fortran::parser::CharBlock &) {
+ addUseDeviceClause(converter, devPtrClause->v, operands, isDeviceTypes,
+ isDeviceLocs, isDeviceSymbols);
+ });
+}
+
+bool ClauseProcessor::processHasDeviceAddr(
+ llvm::SmallVectorImpl<mlir::Value> &operands,
+ llvm::SmallVectorImpl<mlir::Type> &isDeviceTypes,
+ llvm::SmallVectorImpl<mlir::Location> &isDeviceLocs,
+ llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> &isDeviceSymbols)
+ const {
+ return findRepeatableClause<ClauseTy::HasDeviceAddr>(
+ [&](const ClauseTy::HasDeviceAddr *devAddrClause,
+ const Fortran::parser::CharBlock &) {
+ addUseDeviceClause(converter, devAddrClause->v, operands, isDeviceTypes,
+ isDeviceLocs, isDeviceSymbols);
+ });
+}
+
template <typename... Ts>
void ClauseProcessor::processTODO(mlir::Location currentLocation,
llvm::omp::Directive directive) const {
@@ -2411,6 +2451,10 @@ genTargetOp(Fortran::lower::AbstractConverter &converter,
mlir::Value ifClauseOperand, deviceOperand, threadLimitOperand;
mlir::UnitAttr nowaitAttr;
llvm::SmallVector<mlir::Value> mapOperands;
+ llvm::SmallVector<mlir::Value> devicePtrOperands, deviceAddrOperands;
+ llvm::SmallVector<mlir::Type> useDeviceTypes;
+ llvm::SmallVector<mlir::Location> useDeviceLocs;
+ llvm::SmallVector<const Fortran::semantics::Symbol *> useDeviceSymbols;
ClauseProcessor cp(converter, clauseList);
cp.processIf(stmtCtx,
@@ -2421,11 +2465,13 @@ genTargetOp(Fortran::lower::AbstractConverter &converter,
cp.processNowait(nowaitAttr);
cp.processMap(currentLocation, directive, semanticsContext, stmtCtx,
mapOperands);
+ cp.processIsDevicePtr(devicePtrOperands, useDeviceTypes, useDeviceLocs,
+ useDeviceSymbols);
+ cp.processHasDeviceAddr(deviceAddrOperands, useDeviceTypes, useDeviceLocs,
+ useDeviceSymbols);
cp.processTODO<Fortran::parser::OmpClause::Private,
Fortran::parser::OmpClause::Depend,
Fortran::parser::OmpClause::Firstprivate,
- Fortran::parser::OmpClause::IsDevicePtr,
- Fortran::parser::OmpClause::HasDeviceAddr,
Fortran::parser::OmpClause::Reduction,
Fortran::parser::OmpClause::InReduction,
Fortran::parser::OmpClause::Allocate,
@@ -2830,6 +2876,8 @@ genOMP(Fortran::lower::AbstractConverter &converter,
!std::get_if<Fortran::parser::OmpClause::Map>(&clause.u) &&
!std::get_if<Fortran::parser::OmpClause::UseDevicePtr>(&clause.u) &&
!std::get_if<Fortran::parser::OmpClause::UseDeviceAddr>(&clause.u) &&
+ !std::get_if<Fortran::parser::OmpClause::IsDevicePtr>(&clause.u) &&
+ !std::get_if<Fortran::parser::OmpClause::HasDeviceAddr>(&clause.u) &&
!std::get_if<Fortran::parser::OmpClause::ThreadLimit>(&clause.u) &&
!std::get_if<Fortran::parser::OmpClause::NumTeams>(&clause.u)) {
TODO(clauseLocation, "OpenMP Block construct clause");
|
4cb56df
to
53a28a7
Compare
✅ With the latest revision this PR passed the C/C++ code formatter. |
Please add tests to |
53a28a7
to
76fb22a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is easier to review this patch along with the potential MLIRTranslation and OMPIRBuilder changes. That would give us a better idea of how this patch would or should interact with other map_operands and also target region code generation.
Thanks for the patch. I'd recommend adding a second PR with the MLIR/IRBuilder changes before moving forward with this.
llvm::SmallVector<mlir::Type> useDeviceTypes; | ||
llvm::SmallVector<mlir::Location> useDeviceLocs; | ||
llvm::SmallVector<const Fortran::semantics::Symbol *> useDeviceSymbols; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These variables are currently unused from what I can see.
For the use_device_ptr/addr
clauses for the target data
directive. These were used to create block_arguments
for these variables, because we wanted to replace all of their uses inside the region with new values generated by the OMPIRBuilder
.
If we are looking for a similar behaviour here, and we want to add them as block_arguments
as well. Then probably this change would be easier once #67164 is merged as that would already have the base code for doing this.
When the debug info refers to a dwo with relative `DW_AT_comp_dir` and `DW_AT_dwo_name`, we only print the `DW_AT_comp_dir` in our error message if we can't find it. This often isn't very helpful, especially when the `DW_AT_comp_dir` is ".": ``` (lldb) fr v error: unable to locate .dwo debug file "." for skeleton DIE 0x000000000000003c ``` I'm updating the error message to include both `DW_AT_comp_dir` (if it exists) and `DW_AT_dwo_name` when the `DW_AT_dwo_name` is relative. The behavior when `DW_AT_dwo_name` is absolute should be the same.
…m#69790) Due to an issue when lowering from scf to spirv as there was no conversion pass for index to spirv, we are motivated to add a conversion pass from the Index dialect to the SPIR-V dialect. Furthermore, we add the new conversion patterns to the scf-to-spirv conversion. Fixes llvm#63713 --------- Co-authored-by: Jeremy Kun <jkun@google.com>
Do not attempt to format deleted files.
This patch adds "nice-to-have" feature in lit. it prints the total number of discovered tests at the beginning. It is covenient to see the total number of tests and avoid scrolling up to the beginning of log. Further, this patch also prints %ge of tests. This patch fixes tests pointed by previous attempt of landing this patch. Reviewed By: RoboTux, jdenny-ornl Co-authored-by: Madhur A <madhura@nvidia.com>
These files satisfy all of the following: - misc-include-cleaner indicates that these files do not need Endian.h. - They do not mention "endian" anywhere. - They do not include any *.inc or *.def, which could need llvm::support::endian.
…FC (llvm#69810) Previously they were passed by non-const reference. No in tree target modifies the values. This makes it possible to call assignValueToAddress from assignCustomValue without a const_cast. For example in this patch llvm#69138.
) 69660cc broke the [Solaris/sparcv9 buildbot](https://lab.llvm.org/staging/#/builders/12/builds/264): `compiler-rt/lib/builtins/int_to_fp.h` unconditionally uses `*int128_t` which don't exist on 32-bit SPARC. As suggested in llvm#67540, this patch fixes this by moving the `CRT_HAS_TF_MODE` guard up which does the necessary checks. Tested on `sparcv9-sun-solaris2.11`.
…rs (llvm#69534) The syntax of modifiers without comma separators in the map clause was deprecated in OpenMP 5.2. Reference: OpenMP 5.2 Spec, page 627, line 19
This is the first of a series of patch to improve Alias Analysis on Scalable quantities. Keep Scalable information from TypeSize which will be used in Alias Analysis.
This is so that we can append multiple values at once without having to create a temporary array or repeatedly call `push_back`. Use the new function `append_values` to clean up the SPIR-V serializer code. (NFC)
This adds support in dsymutil for mergeable libraries [1]. dsymutil reads a new stab emitted by ld, allowing it to operate on dynamic libraries instead of object files. It also now loads the DWARF files associated to the libraries, and build the debug map for each binary from the list of symbols exported by the library. For each Debug Map Object, there is a new associated Relocation Map which is serialized from the information retrieved in the original debug_info (or debug_addr) section of the .o file. The final DWARF file has multiple compile units, so the offsets information of the relocations are adjusted relatively to the compile unit they will end up belonging to, inside the final linked DWARF file. [1] https://developer.apple.com/documentation/xcode/configuring-your-project-to-use-mergeable-libraries Differential revision: https://reviews.llvm.org/D158124
structs kmp_depend_info.flags and kmp_tasking_flags contain bitfields, which overlay integer flag values. The current bitfield definitions target little-endian machines. On big-endian machines bitfields are laid out in the opposite order, so the current definitions do not work there. There are two ways to fix this: either provide big-endian bitfield definitions, or bit-swap integer flag values. Go with the former, since it's localized to one place and therefore is more maintainable.
struct DEP defined in multiple testcases must correspond to runtime's struct kmp_depend_info. The former defines flags as int, and the latter as kmp_uint8_t. This discrepancy goes unnoticed on little-endian systems, but breaks big-endian ones. Make flags in struct DEP unsigned char.
…69963) This reverts commit a3a7d63. When compiling with MSVC2022 in C++32 mode this is giving an error. Compiling this simple test case: t1.cpp: with -std=c++23 will give the following error: In file included from C:\Users\zahiraam\t1.cpp:1: c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:16: error: compile with '-ffixed-point' to enable fixed point types 3329 | _Vbase _Accum = 0; | ^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:23: error: expected unqualified-id 3329 | _Vbase _Accum = 0; | ^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3334:13: error: compile with '-ffixed-point' to enable fixed point types 3334 | _Accum |= _Tmp ? _Mask : _Vbase{0}; | ^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3334:20: error: expected unqualified-id 3334 | _Accum |= _Tmp ? _Mask : _Vbase{0}; | ^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3336:53: error: expected '(' for function-style cast or type construction 3336 | this->_Emplace_back_unchecked(_Accum); | ~~~~~~^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3337:17: error: compile with '-ffixed-point' to enable fixed point types 3337 | _Accum = 0; | ^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3337:24: error: expected unqualified-id 3337 | _Accum = 0; | ^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3343:49: error: expected '(' for function-style cast or type construction 3343 | this->_Emplace_back_unchecked(_Accum); | ~~~~~~^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3352:16: error: compile with '-ffixed-point' to enable fixed point types 3352 | _Vbase _Accum = 0; | ^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3352:26: error: expected unqualified-id 3352 | _Vbase _Accum = 0; | ^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3357:13: error: compile with '-ffixed-point' to enable fixed point types 3357 | _Accum |= _Tmp ? _Mask : _Vbase{0}; | ^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3357:20: error: expected unqualified-id 3357 | _Accum |= _Tmp ? _Mask : _Vbase{0}; | ^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3359:46: error: expected '(' for function-style cast or type construction 3359 | this->_Myvec.push_back(_Accum); | ~~~~~~^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3360:17: error: compile with '-ffixed-point' to enable fixed point types 3360 | _Accum = 0; | ^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3360:24: error: expected unqualified-id 3360 | _Accum = 0; | ^ c:\Program files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3366:42: error: expected '(' for function-style cast or type construction 3366 | this->_Myvec.push_back(_Accum); | ~~~~~~^ 16 errors generated. See also comment here: llvm#67750 (comment)
…lvm#69843) This patch adds verifiers to `tosa.reduce_*` ops that check, among other things, that the supplied `axis` argument is compatible with the input/output tensors' shapes. We allow for a special case of `axis == 0 && rank == 0` to be valid. This patch also adds a check to `ReduceInferReturnTypes()` to ensure that the shape inference pass doesn't crash on an invalid `axis` argument anymore. Fix llvm#68187
…plicit deduction guides for nested template classes" (llvm#69676) Reland of dd0fba1 When a nested template is instantiated, the template pattern of the inner class is not copied into the outer class ClassTemplateSpecializationDecl. The specialization contains a ClassTemplateDecl with an empty record that points to the original template pattern instead. As a result, when looking up the constructors of the inner class, no results are returned. This patch finds the original template pattern and uses that for the lookup instead. Based on CWG2471 we must also substitute the known outer template arguments when creating deduction guides for the inner class. Changes from the last iteration: 1. The outer retained levels from the outer template are always added to the `MultiLevelTemplateArgumentList` for rewriting `FunctionTemplateDecl` arguments, even if there is no FTD and the arguments are empty. 2. When building implicit deduction guides, the template pattern underlying decl is pushed as the current context. This resolves the issue where `FindInstantiatedDecl` is unable to find the inner template class. 3. Tests are updated to cover the failing case, and to assert that the type is correct after argument deduction in the implicit case.
…it parameters. (llvm#70018) To avoid crashes later in sema. Fixes llvm#69962 Fixes llvm#69838
Fix clang build (`return Error => return std::move(Error)`)
This reverts commit 122c89b. Change does not build, with errors such as: In file included from ../llvm-project/llvm/tools/dsymutil/DebugMap.h:24, from ../llvm-project/llvm/tools/dsymutil/DwarfLinkerForBinary.h:13, from ../llvm-project/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp:9: ../llvm-project/llvm/tools/dsymutil/RelocationMap.h:60:17: error: declaration of ‘llvm::dsymutil::SymbolMapping llvm::dsymutil::ValidReloc::SymbolMapping’ changes meaning of ‘SymbolMapping’ [-fpermissive] 60 | SymbolMapping SymbolMapping; | ^~~~~~~~~~~~~ ../llvm-project/llvm/tools/dsymutil/RelocationMap.h:36:8: note: ‘SymbolMapping’ declared here as ‘struct llvm::dsymutil::SymbolMapping’ 36 | struct SymbolMapping { | ^~~~~~~~~~~~~ In file included from ../llvm-project/llvm/tools/dsymutil/DwarfLinkerForBinary.h:13, from ../llvm-project/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp:9: ../llvm-project/llvm/tools/dsymutil/DebugMap.h:198:32: error: declaration of ‘std::optional<llvm::dsymutil::RelocationMap> llvm::dsymutil::DebugMapObject::RelocationMap’ changes meaning of ‘RelocationMap’ [-fpermissive] 198 | std::optional<RelocationMap> RelocationMap; | ^~~~~~~~~~~~~ In file included from ../llvm-project/llvm/tools/dsymutil/DebugMap.h:24, from ../llvm-project/llvm/tools/dsymutil/DwarfLinkerForBinary.h:13, from ../llvm-project/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp:9: ../llvm-project/llvm/tools/dsymutil/RelocationMap.h:76:7: note: ‘RelocationMap’ declared here as ‘class llvm::dsymutil::RelocationMap’ 76 | class RelocationMap { | ^~~~~~~~~~~~~
A bit debateable since we could extract it from the MachineFunction (and thus the MachineInstr), but we have the same pattern for MachineFunction associated structure already for TII and MRI.
This patch adds a mention that the following papers are in progress: * P2770R0: llvm#66033 * P2441R2 and P2711R1: llvm#65536
…9824) This patch adds support for building the libc docs in Github actions. This eanbles easily diagnosing doc build failures/warnings in PRs and at the tip of tree.
Sorry I think I messed up this PR with trying to rebase with upstream and flooding with lot of commits. I will create a new PR later once the #67164 is merged into upstream. |
This is extension to #67290