[flang][OpenMP] Ignore DECLARE_SIMD and warn about missing implementa… (#232712)
…tion Currently DECLARE_SIMD emits a "not yet implemented" error in the MLIR to LLVM IR translation. DECLARE_SIMD is a hint to the compiler and ignoring it is technically speaking a conforming implementation (although obviously not desirable). Do not abort compilation when DECLARE_SIMD is encountered, but emit a warning that it's currently ignored. (cherry picked from commit 5ca62fdee645ec253263e41a45fe626c6b66be22) Fixes: https://github.com/llvm/llvm-project/issues/234108
This commit is contained in:
1 parent
fde947fd58
commit
2cc5b8ca55
13 files changed
+40
-3
No files matched your search
@@ -1928,6 +1928,11 @@ void OmpStructureChecker::Leave(const parser::OmpThreadprivateDirective &x) {
|
||||
void OmpStructureChecker::Enter(const parser::OmpDeclareSimdDirective &x) {
|
||||
const parser::OmpDirectiveName &dirName{x.v.DirName()};
|
||||
|
||||
unsigned version{context_.langOptions().OpenMPVersion};
|
||||
context_.Say(dirName.source,
|
||||
"%s directive is not implemented yet and will be ignored"_warn_en_US,
|
||||
GetUpperName(dirName.v, version));
|
||||
|
||||
const Scope &containingScope = context_.FindScope(dirName.source);
|
||||
const Scope &progUnitScope = GetProgramUnitContaining(containingScope);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ subroutine test_cray_pointer_usage
|
||||
integer :: i
|
||||
real(8) :: var(*), pointee(2)
|
||||
pointer(ivar, var)
|
||||
! WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
|
||||
! ERROR: Cray Pointee 'var' may not appear in LINEAR clause
|
||||
! ERROR: List item 'var' in LINEAR clause must be a scalar variable
|
||||
! ERROR: The list item 'var' specified without the REF 'linear-modifier' must be of INTEGER type
|
||||
|
||||
@@ -21,6 +21,7 @@ end subroutine requires_2
|
||||
|
||||
subroutine declare_simd_1(a, b)
|
||||
real(8), intent(inout) :: a, b
|
||||
!WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
|
||||
!ERROR: 'a' in ALIGNED clause must be of type C_PTR, POINTER or ALLOCATABLE
|
||||
!$omp declare simd(declare_simd_1) aligned(a)
|
||||
a = 3.14 + b
|
||||
@@ -38,6 +39,7 @@ end module m1
|
||||
subroutine declare_simd_2
|
||||
use m1
|
||||
procedure (sub) sub1
|
||||
!WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
|
||||
!ERROR: INBRANCH and NOTINBRANCH clauses are mutually exclusive and may not appear on the same DECLARE SIMD directive
|
||||
!$omp declare simd(sub1) inbranch notinbranch
|
||||
procedure (sub), pointer::p
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
! RUN: %python %S/../test_errors.py %s %flang -fopenmp
|
||||
! RUN: %python %S/../test_errors.py %s %flang -fopenmp -Werror -Wno-experimental-option
|
||||
! Test the source code starting with omp syntax
|
||||
|
||||
!WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
|
||||
!$omp declare simd
|
||||
integer :: x
|
||||
end
|
||||
@@ -6,12 +6,14 @@
|
||||
|
||||
interface
|
||||
subroutine add2(i)
|
||||
!WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
|
||||
!WARNING: 'DECLARE SIMD' directive in an interface body has no effect [-Wopenmp-usage]
|
||||
!$omp declare simd(add2) linear(i:1)
|
||||
integer :: i
|
||||
end subroutine
|
||||
|
||||
subroutine add3(i)
|
||||
!WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
|
||||
!WARNING: 'DECLARE SIMD' directive in an interface body has no effect [-Wopenmp-usage]
|
||||
!$omp declare simd
|
||||
integer :: i
|
||||
@@ -20,8 +22,10 @@ end interface
|
||||
|
||||
contains
|
||||
|
||||
! A DECLARE SIMD in an actual definition is fine and must not warn.
|
||||
! A DECLARE SIMD in an actual definition is fine and must not warn about
|
||||
! its effect.
|
||||
subroutine sub(i)
|
||||
!WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
|
||||
!$omp declare simd(sub) linear(i:1)
|
||||
integer :: i
|
||||
i = i + 1
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
! Test declare simd with uniform clause
|
||||
|
||||
function add2(a,b,i,fact,alc) result(c)
|
||||
!WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
|
||||
!$omp declare simd(add2) uniform(a,b,fact)
|
||||
integer :: i
|
||||
integer,pointer::alc
|
||||
@@ -27,6 +28,7 @@ function bad_uniform(a,b,i) result(c)
|
||||
double precision :: a(*), b(*), c
|
||||
integer :: i
|
||||
double precision :: local
|
||||
!WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
|
||||
!ERROR: Variable 'local' in UNIFORM clause must be a dummy argument of the enclosing procedure
|
||||
!$omp declare simd(bad_uniform) uniform(a,local)
|
||||
c = a(i) + b(i) + local
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
|
||||
module m
|
||||
|
||||
!WARNING: DECLARE_SIMD directive is not implemented yet and will be ignored
|
||||
!ERROR: The name 'x' should refer to a procedure
|
||||
!$omp declare_simd(x)
|
||||
|
||||
!WARNING: DECLARE_SIMD directive is not implemented yet and will be ignored
|
||||
!ERROR: DECLARE_SIMD directive should have at most one argument
|
||||
!$omp declare_simd(f00, f01)
|
||||
|
||||
!WARNING: DECLARE_SIMD directive is not implemented yet and will be ignored
|
||||
!ERROR: The argument to the DECLARE_SIMD directive should be a procedure name
|
||||
!$omp declare_simd(v : integer)
|
||||
|
||||
@@ -20,7 +23,8 @@ subroutine f01
|
||||
end
|
||||
|
||||
integer function f02
|
||||
!Ok, expect no diagnostics
|
||||
!Ok, expect no errors
|
||||
!WARNING: DECLARE_SIMD directive is not implemented yet and will be ignored
|
||||
!$omp declare_simd(f02)
|
||||
end
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ subroutine f02
|
||||
end
|
||||
|
||||
subroutine f03
|
||||
!WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
|
||||
!WARNING: Directive spelling 'DECLARE_SIMD' is introduced in a later OpenMP version, try -fopenmp-version=60
|
||||
!$omp declare_simd
|
||||
end
|
||||
|
||||
@@ -19,16 +19,19 @@ end subroutine linear_clause_01
|
||||
subroutine linear_clause_02(arg_01, arg_02)
|
||||
!ERROR: The list item 'arg_01' specified without the REF 'linear-modifier' must be of INTEGER type
|
||||
!ERROR: List item 'arg_01' in LINEAR clause must be a scalar variable
|
||||
!WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
|
||||
!$omp declare simd linear(val(arg_01))
|
||||
real, intent(in) :: arg_01(:)
|
||||
|
||||
!ERROR: If the `linear-modifier` is REF or UVAL, the list item 'arg_02' must be a dummy argument without the VALUE attribute
|
||||
!WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
|
||||
!$omp declare simd linear(uval(arg_02))
|
||||
integer, value, intent(in) :: arg_02
|
||||
|
||||
!ERROR: If the `linear-modifier` is REF or UVAL, the list item 'var' must be a dummy argument without the VALUE attribute
|
||||
!ERROR: The list item `var` must be a dummy argument
|
||||
!ERROR: The list item `var` in a LINEAR clause must not be Cray Pointer or a variable with POINTER attribute
|
||||
!WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
|
||||
!$omp declare simd linear(uval(var))
|
||||
integer, pointer :: var
|
||||
end subroutine linear_clause_02
|
||||
@@ -39,13 +42,16 @@ subroutine linear_clause_03(arg)
|
||||
!ERROR: The list item `arg` specified with the REF 'linear-modifier' must be polymorphic variable, assumed-shape array, or a variable with the `ALLOCATABLE` attribute
|
||||
!ERROR: List item 'arg' present at multiple LINEAR clauses
|
||||
!ERROR: 'arg' appears in more than one data-sharing clause on the same OpenMP directive
|
||||
!WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
|
||||
!$omp declare simd linear(ref(arg)) linear(arg)
|
||||
|
||||
integer :: i
|
||||
common /cc/ i
|
||||
!WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
|
||||
!ERROR: The list item `i` must be a dummy argument
|
||||
!$omp declare simd linear(i)
|
||||
|
||||
!WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
|
||||
!ERROR: 'cc' is a common block name and must not appear in a LINEAR clause
|
||||
!ERROR: The list item `i` must be a dummy argument
|
||||
!$omp declare simd linear(/cc/)
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
subroutine f00(x)
|
||||
integer :: x
|
||||
!WARNING: The 'modifier(<list>)' syntax is deprecated in OpenMP v5.2, use '<list> : modifier' instead
|
||||
!WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
|
||||
!$omp declare simd linear(uval(x))
|
||||
end
|
||||
|
||||
subroutine f01(x)
|
||||
integer :: x
|
||||
!WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
|
||||
!ERROR: An exclusive 'step-simple-modifier' modifier cannot be specified together with a modifier of a different type
|
||||
!$omp declare simd linear(uval(x) : 2)
|
||||
end
|
||||
@@ -6,6 +6,7 @@ interface
|
||||
subroutine f(x, y)
|
||||
integer, allocatable :: x
|
||||
integer :: y
|
||||
!WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
|
||||
!WARNING: 'DECLARE SIMD' directive in an interface body has no effect [-Wopenmp-usage]
|
||||
!$omp declare simd(f) linear(ref(x) : 1) linear(uval(y))
|
||||
end
|
||||
|
||||
@@ -75,6 +75,7 @@ subroutine test_declare_simd_ref_array_valid(arr)
|
||||
implicit none
|
||||
integer, intent(in) :: arr(:)
|
||||
|
||||
!WARNING: DECLARE SIMD directive is not implemented yet and will be ignored
|
||||
!$omp declare simd linear(ref(arr))
|
||||
! No error expected - REF modifier allows assumed-shape arrays
|
||||
end subroutine
|
||||
@@ -9743,6 +9743,13 @@ LogicalResult OpenMPDialectLLVMIRTranslationInterface::convertOperation(
|
||||
.Case([&](omp::GroupprivateOp) {
|
||||
return convertOmpGroupprivate(*op, builder, moduleTranslation);
|
||||
})
|
||||
.Case([&](omp::DeclareSimdOp) {
|
||||
// TODO: Implement.
|
||||
// DECLARE_SIMD can be ignored. There is warning emitted in
|
||||
// semantic checks about the current situation, but not having an
|
||||
// implementation should not prevent compilation.
|
||||
return success();
|
||||
})
|
||||
.Default([&](Operation *inst) {
|
||||
return inst->emitError()
|
||||
<< "not yet implemented: " << inst->getName();
|
||||
|
||||
Reference in new issue
Block a user