Skip to content

Commit 997fe7c

Browse files
author
Sunil Kuravinakop
committed
1) Claiming support for "dispatch" construct.
2) Changed comments in transformDispatchDirective() in SemaOpenMP.cpp 3) Adding checks in clang/test/OpenMP/dispatch_messages.cpp for a) depend clause b) nocontext, novariants & depend clauses occuring in the same line of dispatch construct. 4) Removing debugging statements (kept under #if 0 and #endif) in OMPContext.h.
1 parent b83e0ba commit 997fe7c

File tree

4 files changed

+52
-9
lines changed

4 files changed

+52
-9
lines changed

clang/docs/OpenMPSupport.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ implementation.
314314
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
315315
| misc | dispatch construct and function variant argument adjustment | :part:`worked on` | D99537, D99679 |
316316
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
317+
| misc | dispatch construct | :part:`worked on` | |
318+
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
317319
| misc | assumes directives | :part:`worked on` | |
318320
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
319321
| misc | assume directive | :good:`done` | |

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6142,6 +6142,8 @@ StmtResult SemaOpenMP::transformDispatchDirective(
61426142

61436143
const OMPNovariantsClause *NoVariantsC =
61446144
OMPExecutableDirective::getSingleClause<OMPNovariantsClause>(Clauses);
6145+
// The following example explains the code transformation in the code
6146+
//
61456147
// #pragma omp dispatch novariants(c2) depend(out: x)
61466148
// foo();
61476149
// becomes:
@@ -6150,7 +6152,7 @@ StmtResult SemaOpenMP::transformDispatchDirective(
61506152
// foo();
61516153
// } else {
61526154
// #pragma omp dispatch
6153-
// foo(); <--- foo() is replaced with foo_variant() in CodeGen
6155+
// foo();
61546156
// }
61556157
Expr *Cond = getInitialExprFromCapturedExpr(NoVariantsC->getCondition());
61566158
StmtResult ThenStmt =
@@ -6179,12 +6181,15 @@ StmtResult SemaOpenMP::transformDispatchDirective(
61796181
const OMPNocontextClause *NoContextC =
61806182
OMPExecutableDirective::getSingleClause<OMPNocontextClause>(Clauses);
61816183
Expr *Cond = getInitialExprFromCapturedExpr(NoContextC->getCondition());
6184+
// The following example explains the code transformation in the code
6185+
//
61826186
// #pragma omp dispatch depend(out: x) nocontext(c2)
61836187
// foo();
61846188
// becomes:
61856189
// #pragma omp taskwait depend(out: x)
61866190
// if (c2) {
6187-
// foo();
6191+
// foo(); <=== transformation explained clearly in
6192+
// replaceWithNewTraitsOrDirectCall()
61886193
// } else {
61896194
// #pragma omp dispatch
61906195
// foo();
@@ -6215,7 +6220,7 @@ StmtResult SemaOpenMP::transformDispatchDirective(
62156220
// Only:
62166221
// #pragma omp dispatch depend(out: x)
62176222
// foo();
6218-
// to
6223+
// becomes:
62196224
// #pragma omp taskwait depend(out: x)
62206225
// foo();
62216226
StmtResult FinalStmts =

clang/test/OpenMP/dispatch_messages.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,48 @@ void testit_one(int dnum) {
6464
// expected-error@+1 {{use of undeclared identifier 'x'}}
6565
#pragma omp dispatch nocontext(x)
6666
disp_call();
67+
68+
bool c1 = false;
69+
bool c2 = true;
70+
int a = 3, b=4;
71+
int output;
72+
73+
// expected-error@+1 {{expected '(' after 'depend'}}
74+
#pragma omp dispatch depend
75+
disp_call();
76+
77+
// expected-error@+4 {{expected ')'}}
78+
// expected-note@+3 {{to match this '('}}
79+
// expected-error@+2 {{expected depend modifier(iterator) or 'in', 'out', 'inout', 'mutexinoutset', 'depobj' or 'inoutset' in OpenMP clause 'depend'}}
80+
// expected-warning@+1 {{missing ':' after dependency type}}
81+
#pragma omp dispatch depend(
82+
disp_call();
83+
84+
// expected-error@+4 {{expected ')'}}
85+
// expected-note@+3 {{to match this '('}}
86+
// expected-error@+2 {{expected depend modifier(iterator) or 'in', 'out', 'inout', 'mutexinoutset', 'depobj' or 'inoutset' in OpenMP clause 'depend'}}
87+
// expected-warning@+1 {{missing ':' after dependency type}}
88+
#pragma omp dispatch depend(a
89+
disp_call();
90+
91+
// expected-error@+2 {{expected depend modifier(iterator) or 'in', 'out', 'inout', 'mutexinoutset', 'depobj' or 'inoutset' in OpenMP clause 'depend'}}
92+
// expected-warning@+1 {{missing ':' after dependency type}}
93+
#pragma omp dispatch depend(a)
94+
disp_call();
95+
96+
// expected-error@+1 {{use of undeclared identifier 'z'}}
97+
#pragma omp dispatch depend(in:z)
98+
disp_call();
99+
100+
#pragma omp dispatch depend(in:b)
101+
output = disp_call();
102+
103+
#pragma omp dispatch depend(in:b) depend(in:a)
104+
output = disp_call();
105+
106+
// expected-warning@+1 {{only 'novariants' clause is supported when 'novariants' & 'nocontext' clauses occur on the same dispatch construct}}
107+
#pragma omp dispatch nocontext(c1) novariants(c2) depend(inout:a)
108+
disp_call();
67109
}
68110

69111
void testit_two() {

llvm/include/llvm/Frontend/OpenMP/OMPContext.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,6 @@ struct VariantMatchInfo {
141141
ISATraits.push_back(RawString);
142142

143143
RequiredTraits.set(unsigned(Property));
144-
#if 0
145-
unsigned int i = 0;
146-
for (unsigned Bit : RequiredTraits.set_bits()) {
147-
i++;
148-
}
149-
#endif
150144
if (Set == TraitSet::construct)
151145
ConstructTraits.push_back(Property);
152146
}

0 commit comments

Comments
 (0)