-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[flang][acc] Add infrastructure and tests for ACCImplicitData #166797
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2f15a1a
[flang][acc] Add infrastructure and tests for ACCImplicitData
81dfccd
Merge remote-tracking branch 'upstream/main' into firaccimplicitdata
ad6bc46
Merge remote-tracking branch 'upstream/main' into firaccimplicitdata
8b880ec
Fix braces
31487cb
Add missed case of braces due to comment obfuscating it
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
flang/include/flang/Optimizer/OpenACC/Analysis/FIROpenACCSupportAnalysis.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| //===- FIROpenACCSupportAnalysis.h - FIR OpenACCSupport Analysis ----------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This file defines the FIR-specific implementation of OpenACCSupport analysis. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef FORTRAN_OPTIMIZER_OPENACC_ANALYSIS_FIROPENACCSUPPORTANALYSIS_H | ||
| #define FORTRAN_OPTIMIZER_OPENACC_ANALYSIS_FIROPENACCSUPPORTANALYSIS_H | ||
|
|
||
| #include "mlir/Dialect/OpenACC/OpenACC.h" | ||
| #include "mlir/IR/Value.h" | ||
| #include <string> | ||
|
|
||
| namespace fir { | ||
| namespace acc { | ||
|
|
||
| /// FIR-specific implementation for the OpenACCSupport analysis interface. | ||
| /// | ||
| /// This class provides the custom implementations of the OpenACCSupport | ||
| /// interface methods that are tailored to FIR's requirements and | ||
| /// can handle FIR dialect operations and types. | ||
| /// Its primary intent is to be registered with the OpenACCSupport analysis | ||
| /// using setImplementation() | ||
| /// | ||
| /// Usage: | ||
| /// auto &support = getAnalysis<mlir::acc::OpenACCSupport>(); | ||
| /// support.setImplementation(fir::acc::FIROpenACCSupportAnalysis()); | ||
| /// | ||
| class FIROpenACCSupportAnalysis { | ||
| public: | ||
| FIROpenACCSupportAnalysis() = default; | ||
|
|
||
| std::string getVariableName(mlir::Value v); | ||
|
|
||
| std::string getRecipeName(mlir::acc::RecipeKind kind, mlir::Type type, | ||
| mlir::Value var); | ||
|
|
||
| mlir::InFlightDiagnostic emitNYI(mlir::Location loc, | ||
| const mlir::Twine &message); | ||
| }; | ||
|
|
||
| } // namespace acc | ||
| } // namespace fir | ||
|
|
||
| #endif // FORTRAN_OPTIMIZER_OPENACC_ANALYSIS_FIROPENACCSUPPORTANALYSIS_H | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
flang/include/flang/Optimizer/OpenACC/Support/FIROpenACCUtils.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| //===- FIROpenACCUtils.h - FIR OpenACC Utilities ----------------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This file declares utility functions for FIR OpenACC support. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef FORTRAN_OPTIMIZER_OPENACC_SUPPORT_FIROPENACCUTILS_H | ||
| #define FORTRAN_OPTIMIZER_OPENACC_SUPPORT_FIROPENACCUTILS_H | ||
|
|
||
| #include "mlir/Dialect/OpenACC/OpenACC.h" | ||
| #include "mlir/IR/Value.h" | ||
| #include <string> | ||
|
|
||
| namespace fir { | ||
| namespace acc { | ||
|
|
||
| /// Attempts to extract the variable name from a value by walking through | ||
| /// FIR operations and looking for variable names. | ||
| /// \param v The value to extract the variable name from | ||
| /// \param preferDemangledName If true, prefers demangled/bindc names over | ||
| /// mangled/unique names. If false, prefers mangled names. | ||
| /// Returns empty string if no name is found. | ||
| std::string getVariableName(mlir::Value v, bool preferDemangledName = true); | ||
|
|
||
| /// Get the recipe name for a given recipe kind, FIR type, and optional | ||
| /// variable. Uses FIR's type string representation with appropriate prefix. For | ||
| /// firstprivate and reduction recipes, handles bounds suffix when all bounds | ||
| /// are constant. For reduction recipes, embeds the operator name in the recipe. | ||
| /// \param kind The recipe kind (private, firstprivate, or reduction) | ||
| /// \param type The FIR type (must be a FIR type) | ||
| /// \param var Optional variable value | ||
| /// \param bounds Optional bounds for array sections (used for suffix | ||
| /// generation) | ||
| /// \param reductionOp Optional reduction operator (required for reduction | ||
| /// recipes) | ||
| /// \return The complete recipe name with all necessary suffixes | ||
| std::string getRecipeName(mlir::acc::RecipeKind kind, mlir::Type type, | ||
| mlir::Value var = nullptr, | ||
| llvm::ArrayRef<mlir::Value> bounds = {}, | ||
| mlir::acc::ReductionOperator reductionOp = | ||
| mlir::acc::ReductionOperator::AccNone); | ||
|
|
||
| /// Check if all bounds are expressed with constant values. | ||
| /// \param bounds Array of DataBoundsOp values to check | ||
| /// \return true if all bounds have constant lowerbound/upperbound or extent | ||
| bool areAllBoundsConstant(llvm::ArrayRef<mlir::Value> bounds); | ||
|
|
||
| } // namespace acc | ||
| } // namespace fir | ||
|
|
||
| #endif // FORTRAN_OPTIMIZER_OPENACC_SUPPORT_FIROPENACCUTILS_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| add_flang_library(FIROpenACCAnalysis | ||
| FIROpenACCSupportAnalysis.cpp | ||
|
|
||
| DEPENDS | ||
| FIRAnalysis | ||
| FIRDialect | ||
| FIROpenACCSupport | ||
| HLFIRDialect | ||
|
|
||
| LINK_LIBS | ||
| FIRAnalysis | ||
| FIRDialect | ||
| FIROpenACCSupport | ||
| HLFIRDialect | ||
|
|
||
| MLIR_DEPS | ||
| MLIROpenACCDialect | ||
|
|
||
| MLIR_LIBS | ||
| MLIROpenACCDialect | ||
| ) | ||
|
|
40 changes: 40 additions & 0 deletions
40
flang/lib/Optimizer/OpenACC/Analysis/FIROpenACCSupportAnalysis.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| //===- FIROpenACCSupportAnalysis.cpp - FIR OpenACCSupport Analysis -------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This file implements the FIR-specific OpenACCSupport analysis. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "flang/Optimizer/OpenACC/Analysis/FIROpenACCSupportAnalysis.h" | ||
| #include "flang/Optimizer/Builder/Todo.h" | ||
| #include "flang/Optimizer/OpenACC/Support/FIROpenACCUtils.h" | ||
|
|
||
| using namespace mlir; | ||
|
|
||
| namespace fir { | ||
| namespace acc { | ||
|
|
||
| std::string FIROpenACCSupportAnalysis::getVariableName(Value v) { | ||
| return fir::acc::getVariableName(v, /*preferDemangledName=*/true); | ||
| } | ||
|
|
||
| std::string FIROpenACCSupportAnalysis::getRecipeName(mlir::acc::RecipeKind kind, | ||
| Type type, Value var) { | ||
| return fir::acc::getRecipeName(kind, type, var); | ||
| } | ||
|
|
||
| mlir::InFlightDiagnostic | ||
| FIROpenACCSupportAnalysis::emitNYI(Location loc, const Twine &message) { | ||
| TODO(loc, message); | ||
| // Should be unreachable, but we return an actual diagnostic | ||
| // to satisfy the interface. | ||
| return mlir::emitError(loc, "not yet implemented: " + message.str()); | ||
| } | ||
|
|
||
| } // namespace acc | ||
| } // namespace fir |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| add_subdirectory(Analysis) | ||
| add_subdirectory(Support) | ||
| add_subdirectory(Transforms) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.