Skip to content

Commit f4a6615

Browse files
Arnamoy BhattacharyyajeanPerier
authored andcommitted
[flang][OpenMP] Add parsing support for nontemporal clause.
This patch adds parsing support for the nontemporal clause. Also adds a couple of test cases. Reviewed By: clementval Differential Revision: https://reviews.llvm.org/D106896
1 parent b4ce919 commit f4a6615

File tree

6 files changed

+126
-1
lines changed

6 files changed

+126
-1
lines changed

flang/include/flang/Semantics/symbol.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ class Symbol {
511511
// OpenMP data-copying attribute
512512
OmpCopyIn, OmpCopyPrivate,
513513
// OpenMP miscellaneous flags
514-
OmpCommonBlock, OmpReduction, OmpAligned, OmpAllocate,
514+
OmpCommonBlock, OmpReduction, OmpAligned, OmpNontemporal, OmpAllocate,
515515
OmpDeclarativeAllocateDirective, OmpExecutableAllocateDirective,
516516
OmpDeclareSimd, OmpDeclareTarget, OmpThreadprivate, OmpDeclareReduction,
517517
OmpFlushed, OmpCriticalLock, OmpIfSpecified, OmpNone, OmpPreDetermined);

flang/lib/Parser/openmp-parsers.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ TYPE_PARSER(
203203
parenthesized(Parser<OmpMapClause>{}))) ||
204204
"MERGEABLE" >> construct<OmpClause>(construct<OmpClause::Mergeable>()) ||
205205
"NOGROUP" >> construct<OmpClause>(construct<OmpClause::Nogroup>()) ||
206+
"NONTEMPORAL" >> construct<OmpClause>(construct<OmpClause::Nontemporal>(
207+
parenthesized(nonemptyList(name)))) ||
206208
"NOTINBRANCH" >>
207209
construct<OmpClause>(construct<OmpClause::Notinbranch>()) ||
208210
"NOWAIT" >> construct<OmpClause>(construct<OmpClause::Nowait>()) ||

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,13 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
407407
ResolveOmpNameList(alignedNameList, Symbol::Flag::OmpAligned);
408408
return false;
409409
}
410+
411+
bool Pre(const parser::OmpClause::Nontemporal &x) {
412+
const auto &nontemporalNameList{x.v};
413+
ResolveOmpNameList(nontemporalNameList, Symbol::Flag::OmpNontemporal);
414+
return false;
415+
}
416+
410417
void Post(const parser::Name &);
411418

412419
// Keep track of labels in the statements that causes jumps to target labels
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
! RUN: %flang_fc1 -fdebug-unparse-no-sema -fopenmp %s | FileCheck %s
2+
3+
program omp_simd
4+
integer i
5+
integer, allocatable :: a(:)
6+
7+
allocate(a(10))
8+
9+
!NONTEMPORAL
10+
!$omp simd nontemporal(a)
11+
do i = 1, 10
12+
a(i) = i
13+
end do
14+
!$omp end simd
15+
end program omp_simd
16+
!CHECK-LABEL: PROGRAM omp_simd
17+
18+
!NONTEMPORAL
19+
!CHECK: !$OMP SIMD NONTEMPORAL(a)
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
! RUN: %python %S/test_errors.py %s %flang -fopenmp
2+
! REQUIRES: shell
3+
! Check OpenMP clause validity for NONTEMPORAL clause
4+
5+
program omp_simd
6+
integer i
7+
integer, allocatable :: a(:)
8+
9+
allocate(a(10))
10+
11+
!$omp simd nontemporal(a)
12+
do i = 1, 10
13+
a(i) = i
14+
end do
15+
!$omp end simd
16+
17+
!$omp parallel do simd nontemporal(a)
18+
do i = 1, 10
19+
a(i) = i
20+
end do
21+
!$omp end parallel do simd
22+
23+
!$omp parallel do simd nontemporal(a)
24+
do i = 1, 10
25+
a(i) = i
26+
end do
27+
!$omp end parallel do simd
28+
29+
!ERROR: NONTEMPORAL clause is not allowed on the DO SIMD directive
30+
!$omp do simd nontemporal(a)
31+
do i = 1, 10
32+
a(i) = i
33+
end do
34+
!$omp end do simd
35+
36+
!$omp taskloop simd nontemporal(a)
37+
do i = 1, 10
38+
a(i) = i
39+
end do
40+
!$omp end taskloop simd
41+
42+
!$omp teams
43+
!$omp distribute parallel do simd nontemporal(a)
44+
do i = 1, 10
45+
a(i) = i
46+
end do
47+
!$omp end distribute parallel do simd
48+
!$omp end teams
49+
50+
!$omp teams
51+
!$omp distribute simd nontemporal(a)
52+
do i = 1, 10
53+
a(i) = i
54+
end do
55+
!$omp end distribute simd
56+
!$omp end teams
57+
58+
!$omp target parallel do simd nontemporal(a)
59+
do i = 1, 10
60+
a(i) = i
61+
end do
62+
!$omp end target parallel do simd
63+
64+
!$omp target simd nontemporal(a)
65+
do i = 1, 10
66+
a(i) = i
67+
end do
68+
!$omp end target simd
69+
70+
!$omp teams distribute simd nontemporal(a)
71+
do i = 1, 10
72+
a(i) = i
73+
end do
74+
!$omp end teams distribute simd
75+
76+
!$omp teams distribute parallel do simd nontemporal(a)
77+
do i = 1, 10
78+
a(i) = i
79+
end do
80+
!$omp end teams distribute parallel do simd
81+
82+
!$omp target teams distribute parallel do simd nontemporal(a)
83+
do i = 1, 10
84+
a(i) = i
85+
end do
86+
!$omp end target teams distribute parallel do simd
87+
88+
!$omp target teams distribute simd nontemporal(a)
89+
do i = 1, 10
90+
a(i) = i
91+
end do
92+
!$omp end target teams distribute simd
93+
94+
95+
end program omp_simd

llvm/include/llvm/Frontend/OpenMP/OMP.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ def OMPC_Allocate : Clause<"allocate"> {
259259
}
260260
def OMPC_NonTemporal : Clause<"nontemporal"> {
261261
let clangClass = "OMPNontemporalClause";
262+
let flangClass = "Name";
263+
let isValueList = true;
262264
}
263265

264266
def OMP_ORDER_concurrent : ClauseVal<"default",2,0> { let isDefault = 1; }

0 commit comments

Comments
 (0)