-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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] Add LLVM translation support for UNTIED clause in Task #121052
Changes from 2 commits
5eb942e
d77eae0
972c9f0
84306d3
ef30f3a
83f224f
9e38043
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -213,6 +213,29 @@ class AssociatedLoopChecker { | |
std::map<std::string, std::int64_t> constructNamesAndLevels_; | ||
}; | ||
|
||
// `OmpDesignatorChecker` is used to check if the designator | ||
// can appear within the OpenMP construct | ||
class OmpDesignatorChecker { | ||
public: | ||
OmpDesignatorChecker(SemanticsContext &context) : context_{context} {} | ||
|
||
template <typename T> bool Pre(const T &) { return true; } | ||
template <typename T> void Post(const T &) {} | ||
|
||
bool Pre(const parser::Name &name) { | ||
if (name.symbol->test(Symbol::Flag::OmpThreadprivate)) { | ||
// OpenMP 5.2: 5.2 threadprivate directive restriction | ||
context_.Say(name.source, | ||
"A THREADPRIVATE variable `%s` cannot appear in a UNTIED TASK region"_err_en_US, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: "an UNTIED TASK region" |
||
name.source); | ||
} | ||
return true; | ||
} | ||
|
||
private: | ||
SemanticsContext &context_; | ||
}; | ||
|
||
bool OmpStructureChecker::CheckAllowedClause(llvmOmpClause clause) { | ||
unsigned version{context_.langOptions().OpenMPVersion}; | ||
DirectiveContext &dirCtx = GetContext(); | ||
|
@@ -1164,6 +1187,16 @@ void OmpStructureChecker::Enter(const parser::OpenMPBlockConstruct &x) { | |
HasInvalidWorksharingNesting( | ||
beginDir.source, llvm::omp::nestedWorkshareErrSet); | ||
break; | ||
case llvm::omp::Directive::OMPD_task: { | ||
const auto &clauses{std::get<parser::OmpClauseList>(beginBlockDir.t)}; | ||
for (const auto &clause : clauses.v) { | ||
if (std::get_if<parser::OmpClause::Untied>(&clause.u)) { | ||
OmpDesignatorChecker ompDesignatorChecker{context_}; | ||
parser::Walk(block, ompDesignatorChecker); | ||
} | ||
} | ||
break; | ||
} | ||
default: | ||
break; | ||
} | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
! REQUIRES: openmp_runtime | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. File name: "task-united01.f90" -> "task-untied01.f90" ? |
||
! RUN: %python %S/../test_errors.py %s %flang %openmp_flags | ||
! | ||
! OpenMP 5.2: 5.2 threadprivate directive restriction | ||
|
||
subroutine task_united01() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. |
||
integer, save :: var_01, var_02(2) | ||
real :: var_03 | ||
common /c/ var_03 | ||
|
||
!$omp threadprivate(var_01, var_02) | ||
!$omp threadprivate(/c/) | ||
|
||
!$omp task untied | ||
!ERROR: A THREADPRIVATE variable `var_01` cannot appear in a UNTIED TASK region | ||
var_01 = 10 | ||
!ERROR: A THREADPRIVATE variable `var_02` cannot appear in a UNTIED TASK region | ||
!ERROR: A THREADPRIVATE variable `var_01` cannot appear in a UNTIED TASK region | ||
var_02(1) = sum([var_01, 20]) | ||
!$omp end task | ||
|
||
!$omp task untied | ||
!ERROR: A THREADPRIVATE variable `var_02` cannot appear in a UNTIED TASK region | ||
!ERROR: A THREADPRIVATE variable `var_02` cannot appear in a UNTIED TASK region | ||
var_02(2) = product(var_02) | ||
!ERROR: A THREADPRIVATE variable `var_03` cannot appear in a UNTIED TASK region | ||
var_03 = 3.14 | ||
!$omp end task | ||
end subroutine task_united01 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3020,6 +3020,18 @@ module attributes {omp.is_target_device = true} { | |
|
||
// ----- | ||
|
||
llvm.func @omp_task_untied() { | ||
// The third argument is 0: which signifies the united task | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "united" -> "untied" |
||
// CHECK: {{.*}} = call ptr @__kmpc_omp_task_alloc(ptr @1, i32 %{{.*}}, i32 0, | ||
// CHECK-SAME: i64 40, i64 0, ptr @{{.*}}) | ||
omp.task untied { | ||
omp.terminator | ||
} | ||
llvm.return | ||
} | ||
|
||
// ----- | ||
|
||
// Third argument is 5: essentially (4 || 1) | ||
// signifying this task is TIED and MERGEABLE | ||
|
||
|
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.
Please don't call this "designator checker". It only applies to the body of a
TASK
construct, and only if there is anUNTIED
clause on it. Please give this class a more specific name.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.
Yea, sure.