-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Flang][OpenMP][Sema] Add semantics checks for REQUIRES directive
This patch adds semantics checks for REQUIRES directives appearing after other directives that are affected by them. In particular, it adds checks for device constructs appearing after device-related REQUIRES directives and for the `atomic_default_mem_order` clause appearing after atomic operations where the memory order is not explicitly specified. This is patch 2/5 of a series splitting D149337 to simplify review. Depends on D157710. Differential Revision: https://reviews.llvm.org/D157722
- Loading branch information
Showing
10 changed files
with
243 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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 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
File renamed without changes.
This file contains 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,17 @@ | ||
! RUN: %python %S/../test_errors.py %s %flang -fopenmp | ||
! OpenMP Version 5.0 | ||
! 2.4 Requires directive | ||
! All atomic_default_mem_order clauses in 'requires' directives must come | ||
! strictly before any atomic directives on which the memory_order clause is not | ||
! specified. | ||
|
||
subroutine f | ||
integer :: a = 0 | ||
!$omp atomic | ||
a = a + 1 | ||
end subroutine f | ||
|
||
subroutine g | ||
!ERROR: REQUIRES directive with 'ATOMIC_DEFAULT_MEM_ORDER' clause found lexically after atomic operation without a memory order clause | ||
!$omp requires atomic_default_mem_order(relaxed) | ||
end subroutine g |
This file contains 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,21 @@ | ||
! RUN: %python %S/../test_errors.py %s %flang -fopenmp | ||
! OpenMP Version 5.0 | ||
! 2.4 Requires directive | ||
! Target-related clauses in 'requires' directives must come strictly before any | ||
! device constructs, such as target regions. | ||
|
||
subroutine f | ||
!$omp target | ||
!$omp end target | ||
end subroutine f | ||
|
||
subroutine g | ||
!ERROR: REQUIRES directive with 'DYNAMIC_ALLOCATORS' clause found lexically after device construct | ||
!$omp requires dynamic_allocators | ||
!ERROR: REQUIRES directive with 'REVERSE_OFFLOAD' clause found lexically after device construct | ||
!$omp requires reverse_offload | ||
!ERROR: REQUIRES directive with 'UNIFIED_ADDRESS' clause found lexically after device construct | ||
!$omp requires unified_address | ||
!ERROR: REQUIRES directive with 'UNIFIED_SHARED_MEMORY' clause found lexically after device construct | ||
!$omp requires unified_shared_memory | ||
end subroutine g |
This file contains 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,20 @@ | ||
! RUN: %python %S/../test_errors.py %s %flang -fopenmp | ||
! OpenMP Version 5.0 | ||
! 2.4 Requires directive | ||
! Target-related clauses in 'requires' directives must come strictly before any | ||
! device constructs, such as declare target with device_type=nohost|any. | ||
|
||
subroutine f | ||
!$omp declare target device_type(nohost) | ||
end subroutine f | ||
|
||
subroutine g | ||
!ERROR: REQUIRES directive with 'DYNAMIC_ALLOCATORS' clause found lexically after device construct | ||
!$omp requires dynamic_allocators | ||
!ERROR: REQUIRES directive with 'REVERSE_OFFLOAD' clause found lexically after device construct | ||
!$omp requires reverse_offload | ||
!ERROR: REQUIRES directive with 'UNIFIED_ADDRESS' clause found lexically after device construct | ||
!$omp requires unified_address | ||
!ERROR: REQUIRES directive with 'UNIFIED_SHARED_MEMORY' clause found lexically after device construct | ||
!$omp requires unified_shared_memory | ||
end subroutine g |
This file contains 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,20 @@ | ||
! RUN: %python %S/../test_errors.py %s %flang -fopenmp | ||
! OpenMP Version 5.0 | ||
! 2.4 Requires directive | ||
! Target-related clauses in 'requires' directives must come strictly before any | ||
! device constructs, such as declare target with 'to' clause and no device_type. | ||
|
||
subroutine f | ||
!$omp declare target to(f) | ||
end subroutine f | ||
|
||
subroutine g | ||
!ERROR: REQUIRES directive with 'DYNAMIC_ALLOCATORS' clause found lexically after device construct | ||
!$omp requires dynamic_allocators | ||
!ERROR: REQUIRES directive with 'REVERSE_OFFLOAD' clause found lexically after device construct | ||
!$omp requires reverse_offload | ||
!ERROR: REQUIRES directive with 'UNIFIED_ADDRESS' clause found lexically after device construct | ||
!$omp requires unified_address | ||
!ERROR: REQUIRES directive with 'UNIFIED_SHARED_MEMORY' clause found lexically after device construct | ||
!$omp requires unified_shared_memory | ||
end subroutine g |
This file contains 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,20 @@ | ||
! RUN: %python %S/../test_errors.py %s %flang -fopenmp | ||
! OpenMP Version 5.0 | ||
! 2.4 Requires directive | ||
! Target-related clauses in 'requires' directives must come strictly before any | ||
! device constructs, such as declare target with extended list. | ||
|
||
subroutine f | ||
!$omp declare target (f) | ||
end subroutine f | ||
|
||
subroutine g | ||
!ERROR: REQUIRES directive with 'DYNAMIC_ALLOCATORS' clause found lexically after device construct | ||
!$omp requires dynamic_allocators | ||
!ERROR: REQUIRES directive with 'REVERSE_OFFLOAD' clause found lexically after device construct | ||
!$omp requires reverse_offload | ||
!ERROR: REQUIRES directive with 'UNIFIED_ADDRESS' clause found lexically after device construct | ||
!$omp requires unified_address | ||
!ERROR: REQUIRES directive with 'UNIFIED_SHARED_MEMORY' clause found lexically after device construct | ||
!$omp requires unified_shared_memory | ||
end subroutine g |
This file contains 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,21 @@ | ||
! RUN: %python %S/../test_errors.py %s %flang -fopenmp | ||
! OpenMP Version 5.0 | ||
! 2.4 Requires directive | ||
! Target-related clauses in 'requires' directives must come strictly before any | ||
! device constructs, such as target parallel regions. | ||
|
||
subroutine f | ||
!$omp target parallel | ||
!$omp end target parallel | ||
end subroutine f | ||
|
||
subroutine g | ||
!ERROR: REQUIRES directive with 'DYNAMIC_ALLOCATORS' clause found lexically after device construct | ||
!$omp requires dynamic_allocators | ||
!ERROR: REQUIRES directive with 'REVERSE_OFFLOAD' clause found lexically after device construct | ||
!$omp requires reverse_offload | ||
!ERROR: REQUIRES directive with 'UNIFIED_ADDRESS' clause found lexically after device construct | ||
!$omp requires unified_address | ||
!ERROR: REQUIRES directive with 'UNIFIED_SHARED_MEMORY' clause found lexically after device construct | ||
!$omp requires unified_shared_memory | ||
end subroutine g |
This file contains 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,23 @@ | ||
! RUN: %python %S/../test_errors.py %s %flang -fopenmp | ||
! OpenMP Version 5.0 | ||
! 2.4 Requires directive | ||
! Target-related clauses in 'requires' directives must come strictly before any | ||
! device constructs, such as target teams distribute parallel do loops. | ||
|
||
subroutine f | ||
!$omp target teams distribute parallel do | ||
do i=1, 10 | ||
end do | ||
!$omp end target teams distribute parallel do | ||
end subroutine f | ||
|
||
subroutine g | ||
!ERROR: REQUIRES directive with 'DYNAMIC_ALLOCATORS' clause found lexically after device construct | ||
!$omp requires dynamic_allocators | ||
!ERROR: REQUIRES directive with 'REVERSE_OFFLOAD' clause found lexically after device construct | ||
!$omp requires reverse_offload | ||
!ERROR: REQUIRES directive with 'UNIFIED_ADDRESS' clause found lexically after device construct | ||
!$omp requires unified_address | ||
!ERROR: REQUIRES directive with 'UNIFIED_SHARED_MEMORY' clause found lexically after device construct | ||
!$omp requires unified_shared_memory | ||
end subroutine g |