CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
267 lines
13 KiB
Fortran
267 lines
13 KiB
Fortran
! RUN: %flang_fc1 -fdebug-unparse -fopenmp %s | FileCheck --ignore-case %s
|
|
! RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp %s | FileCheck --check-prefix="PARSE-TREE" %s
|
|
|
|
!! Test multiple declarations for the same type, with different operations.
|
|
module mymod
|
|
type :: tt
|
|
real r
|
|
end type tt
|
|
contains
|
|
function mymax(a, b)
|
|
type(tt) :: a, b, mymax
|
|
if (a%r > b%r) then
|
|
mymax = a
|
|
else
|
|
mymax = b
|
|
end if
|
|
end function mymax
|
|
end module mymod
|
|
|
|
program omp_examples
|
|
!CHECK-LABEL: PROGRAM omp_examples
|
|
use mymod
|
|
implicit none
|
|
integer, parameter :: n = 100
|
|
integer :: i
|
|
type(tt) :: values(n), sum, prod, big, small
|
|
|
|
!$omp declare reduction(+:tt:omp_out%r = omp_out%r + omp_in%r) initializer(omp_priv%r = 0)
|
|
!CHECK: !$OMP DECLARE REDUCTION(+:tt: omp_out%r = omp_out%r + omp_in%r) INITIALIZER(om&
|
|
!CHECK-NEXT: !$OMP&p_priv%r = 0)
|
|
|
|
!PARSE-TREE: DeclarationConstruct -> SpecificationConstruct -> OpenMPDeclarativeConstruct -> OmpDeclareReductionDirective -> OmpDirectiveSpecification
|
|
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction
|
|
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
|
|
!PARSE-TREE: | | OmpReductionIdentifier -> DefinedOperator -> IntrinsicOperator = Add
|
|
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeName -> TypeSpec -> DerivedTypeSpec
|
|
!PARSE-TREE: | | | Name = 'tt'
|
|
!PARSE-TREE: | | OmpCombinerExpression -> OmpStylizedInstance
|
|
!PARSE-TREE: | | | OmpStylizedDeclaration
|
|
!PARSE-TREE: | | | OmpStylizedDeclaration
|
|
!PARSE-TREE: | | | Instance -> AssignmentStmt = 'omp_out%r=omp_out%r+omp_in%r'
|
|
!PARSE-TREE: | | | | Variable = 'omp_out%r'
|
|
!PARSE-TREE: | | | | | Designator -> DataRef -> StructureComponent
|
|
!PARSE-TREE: | | | | | | DataRef -> Name = 'omp_out'
|
|
!PARSE-TREE: | | | | | | Name = 'r'
|
|
!PARSE-TREE: | | | | Expr = 'omp_out%r+omp_in%r'
|
|
!PARSE-TREE: | | | | | Add
|
|
!PARSE-TREE: | | | | | | Expr = 'omp_out%r'
|
|
!PARSE-TREE: | | | | | | | Designator -> DataRef -> StructureComponent
|
|
!PARSE-TREE: | | | | | | | | DataRef -> Name = 'omp_out'
|
|
!PARSE-TREE: | | | | | | | | Name = 'r'
|
|
!PARSE-TREE: | | | | | | Expr = 'omp_in%r'
|
|
!PARSE-TREE: | | | | | | | Designator -> DataRef -> StructureComponent
|
|
!PARSE-TREE: | | | | | | | | DataRef -> Name = 'omp_in'
|
|
!PARSE-TREE: | | | | | | | | Name = 'r'
|
|
!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> OmpInitializerExpression -> OmpStylizedInstance
|
|
!PARSE-TREE: | | OmpStylizedDeclaration
|
|
!PARSE-TREE: | | OmpStylizedDeclaration
|
|
!PARSE-TREE: | | Instance -> AssignmentStmt = 'omp_priv%r=0._4'
|
|
!PARSE-TREE: | | | Variable = 'omp_priv%r'
|
|
!PARSE-TREE: | | | | Designator -> DataRef -> StructureComponent
|
|
!PARSE-TREE: | | | | | DataRef -> Name = 'omp_priv'
|
|
!PARSE-TREE: | | | | | Name = 'r'
|
|
!PARSE-TREE: | | | Expr = '0_4'
|
|
!PARSE-TREE: | | | | LiteralConstant -> IntLiteralConstant = '0'
|
|
!PARSE-TREE: | Flags = {}
|
|
|
|
!$omp declare reduction(*:tt:omp_out%r = omp_out%r * omp_in%r) initializer(omp_priv%r = 1)
|
|
!CHECK-NEXT: !$OMP DECLARE REDUCTION(*:tt: omp_out%r = omp_out%r * omp_in%r) INITIALIZER(om&
|
|
!CHECK-NEXT: !$OMP&p_priv%r = 1)
|
|
|
|
!PARSE-TREE: DeclarationConstruct -> SpecificationConstruct -> OpenMPDeclarativeConstruct -> OmpDeclareReductionDirective -> OmpDirectiveSpecification
|
|
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction
|
|
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
|
|
!PARSE-TREE: | | OmpReductionIdentifier -> DefinedOperator -> IntrinsicOperator = Multiply
|
|
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeName -> TypeSpec -> DerivedTypeSpec
|
|
!PARSE-TREE: | | | Name = 'tt'
|
|
!PARSE-TREE: | | OmpCombinerExpression -> OmpStylizedInstance
|
|
!PARSE-TREE: | | | OmpStylizedDeclaration
|
|
!PARSE-TREE: | | | OmpStylizedDeclaration
|
|
!PARSE-TREE: | | | Instance -> AssignmentStmt = 'omp_out%r=omp_out%r*omp_in%r'
|
|
!PARSE-TREE: | | | | Variable = 'omp_out%r'
|
|
!PARSE-TREE: | | | | | Designator -> DataRef -> StructureComponent
|
|
!PARSE-TREE: | | | | | | DataRef -> Name = 'omp_out'
|
|
!PARSE-TREE: | | | | | | Name = 'r'
|
|
!PARSE-TREE: | | | | Expr = 'omp_out%r*omp_in%r'
|
|
!PARSE-TREE: | | | | | Multiply
|
|
!PARSE-TREE: | | | | | | Expr = 'omp_out%r'
|
|
!PARSE-TREE: | | | | | | | Designator -> DataRef -> StructureComponent
|
|
!PARSE-TREE: | | | | | | | | DataRef -> Name = 'omp_out'
|
|
!PARSE-TREE: | | | | | | | | Name = 'r'
|
|
!PARSE-TREE: | | | | | | Expr = 'omp_in%r'
|
|
!PARSE-TREE: | | | | | | | Designator -> DataRef -> StructureComponent
|
|
!PARSE-TREE: | | | | | | | | DataRef -> Name = 'omp_in'
|
|
!PARSE-TREE: | | | | | | | | Name = 'r'
|
|
!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> OmpInitializerExpression -> OmpStylizedInstance
|
|
!PARSE-TREE: | | OmpStylizedDeclaration
|
|
!PARSE-TREE: | | OmpStylizedDeclaration
|
|
!PARSE-TREE: | | Instance -> AssignmentStmt = 'omp_priv%r=1._4'
|
|
!PARSE-TREE: | | | Variable = 'omp_priv%r'
|
|
!PARSE-TREE: | | | | Designator -> DataRef -> StructureComponent
|
|
!PARSE-TREE: | | | | | DataRef -> Name = 'omp_priv'
|
|
!PARSE-TREE: | | | | | Name = 'r'
|
|
!PARSE-TREE: | | | Expr = '1_4'
|
|
!PARSE-TREE: | | | | LiteralConstant -> IntLiteralConstant = '1'
|
|
!PARSE-TREE: | Flags = {}
|
|
|
|
!$omp declare reduction(max:tt:omp_out = mymax(omp_out, omp_in)) initializer(omp_priv%r = 0)
|
|
!CHECK-NEXT: !$OMP DECLARE REDUCTION(max:tt: omp_out = mymax(omp_out, omp_in)) INITIALIZER(&
|
|
!CHECK-NEXT: !$OMP&omp_priv%r = 0)
|
|
|
|
!PARSE-TREE: DeclarationConstruct -> SpecificationConstruct -> OpenMPDeclarativeConstruct -> OmpDeclareReductionDirective -> OmpDirectiveSpecification
|
|
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction
|
|
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
|
|
!PARSE-TREE: | | OmpReductionIdentifier -> ProcedureDesignator -> Name = 'max'
|
|
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeName -> TypeSpec -> DerivedTypeSpec
|
|
!PARSE-TREE: | | | Name = 'tt'
|
|
!PARSE-TREE: | | OmpCombinerExpression -> OmpStylizedInstance
|
|
!PARSE-TREE: | | | OmpStylizedDeclaration
|
|
!PARSE-TREE: | | | OmpStylizedDeclaration
|
|
!PARSE-TREE: | | | Instance -> AssignmentStmt = 'omp_out=mymax(omp_out,omp_in)'
|
|
!PARSE-TREE: | | | | Variable = 'omp_out'
|
|
!PARSE-TREE: | | | | | Designator -> DataRef -> Name = 'omp_out'
|
|
!PARSE-TREE: | | | | Expr = 'mymax(omp_out,omp_in)'
|
|
!PARSE-TREE: | | | | | FunctionReference -> Call
|
|
!PARSE-TREE: | | | | | | ProcedureDesignator -> Name = 'mymax'
|
|
!PARSE-TREE: | | | | | | ActualArgSpec
|
|
!PARSE-TREE: | | | | | | | ActualArg -> Expr = 'omp_out'
|
|
!PARSE-TREE: | | | | | | | | Designator -> DataRef -> Name = 'omp_out'
|
|
!PARSE-TREE: | | | | | | ActualArgSpec
|
|
!PARSE-TREE: | | | | | | | ActualArg -> Expr = 'omp_in'
|
|
!PARSE-TREE: | | | | | | | | Designator -> DataRef -> Name = 'omp_in'
|
|
!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> OmpInitializerExpression -> OmpStylizedInstance
|
|
!PARSE-TREE: | | OmpStylizedDeclaration
|
|
!PARSE-TREE: | | OmpStylizedDeclaration
|
|
!PARSE-TREE: | | Instance -> AssignmentStmt = 'omp_priv%r=0._4'
|
|
!PARSE-TREE: | | | Variable = 'omp_priv%r'
|
|
!PARSE-TREE: | | | | Designator -> DataRef -> StructureComponent
|
|
!PARSE-TREE: | | | | | DataRef -> Name = 'omp_priv'
|
|
!PARSE-TREE: | | | | | Name = 'r'
|
|
!PARSE-TREE: | | | Expr = '0_4'
|
|
!PARSE-TREE: | | | | LiteralConstant -> IntLiteralConstant = '0'
|
|
!PARSE-TREE: | Flags = {}
|
|
|
|
!$omp declare reduction(min:tt:omp_out%r = min(omp_out%r, omp_in%r)) initializer(omp_priv%r = 1)
|
|
!CHECK-NEXT: !$OMP DECLARE REDUCTION(min:tt: omp_out%r = min(omp_out%r, omp_in%r)) INITIALI&
|
|
!CHECK-NEXT: !$OMP&ZER(omp_priv%r = 1)
|
|
|
|
!PARSE-TREE: DeclarationConstruct -> SpecificationConstruct -> OpenMPDeclarativeConstruct -> OmpDeclareReductionDirective -> OmpDirectiveSpecification
|
|
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction
|
|
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
|
|
!PARSE-TREE: | | OmpReductionIdentifier -> ProcedureDesignator -> Name = 'min'
|
|
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeName -> TypeSpec -> DerivedTypeSpec
|
|
!PARSE-TREE: | | | Name = 'tt'
|
|
!PARSE-TREE: | | OmpCombinerExpression -> OmpStylizedInstance
|
|
!PARSE-TREE: | | | OmpStylizedDeclaration
|
|
!PARSE-TREE: | | | OmpStylizedDeclaration
|
|
!PARSE-TREE: | | | Instance -> AssignmentStmt = 'omp_out%r=min(omp_out%r,omp_in%r)'
|
|
!PARSE-TREE: | | | | Variable = 'omp_out%r'
|
|
!PARSE-TREE: | | | | | Designator -> DataRef -> StructureComponent
|
|
!PARSE-TREE: | | | | | | DataRef -> Name = 'omp_out'
|
|
!PARSE-TREE: | | | | | | Name = 'r'
|
|
!PARSE-TREE: | | | | Expr = 'min(omp_out%r,omp_in%r)'
|
|
!PARSE-TREE: | | | | | FunctionReference -> Call
|
|
!PARSE-TREE: | | | | | | ProcedureDesignator -> Name = 'min'
|
|
!PARSE-TREE: | | | | | | ActualArgSpec
|
|
!PARSE-TREE: | | | | | | | ActualArg -> Expr = 'omp_out%r'
|
|
!PARSE-TREE: | | | | | | | | Designator -> DataRef -> StructureComponent
|
|
!PARSE-TREE: | | | | | | | | | DataRef -> Name = 'omp_out'
|
|
!PARSE-TREE: | | | | | | | | | Name = 'r'
|
|
!PARSE-TREE: | | | | | | ActualArgSpec
|
|
!PARSE-TREE: | | | | | | | ActualArg -> Expr = 'omp_in%r'
|
|
!PARSE-TREE: | | | | | | | | Designator -> DataRef -> StructureComponent
|
|
!PARSE-TREE: | | | | | | | | | DataRef -> Name = 'omp_in'
|
|
!PARSE-TREE: | | | | | | | | | Name = 'r'
|
|
!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> OmpInitializerExpression -> OmpStylizedInstance
|
|
!PARSE-TREE: | | OmpStylizedDeclaration
|
|
!PARSE-TREE: | | OmpStylizedDeclaration
|
|
!PARSE-TREE: | | Instance -> AssignmentStmt = 'omp_priv%r=1._4'
|
|
!PARSE-TREE: | | | Variable = 'omp_priv%r'
|
|
!PARSE-TREE: | | | | Designator -> DataRef -> StructureComponent
|
|
!PARSE-TREE: | | | | | DataRef -> Name = 'omp_priv'
|
|
!PARSE-TREE: | | | | | Name = 'r'
|
|
!PARSE-TREE: | | | Expr = '1_4'
|
|
!PARSE-TREE: | | | | LiteralConstant -> IntLiteralConstant = '1'
|
|
!PARSE-TREE: | Flags = {}
|
|
|
|
call random_number(values%r)
|
|
|
|
sum%r = 0
|
|
!$omp parallel do reduction(+:sum)
|
|
!CHECK: !$OMP PARALLEL DO REDUCTION(+: sum)
|
|
|
|
!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct
|
|
!PARSE-TREE: | OmpBeginDirective
|
|
!PARSE-TREE: | | OmpDirectiveName -> llvm::omp::Directive = parallel do
|
|
!PARSE-TREE: | | OmpClauseList -> OmpClause -> Reduction -> OmpReductionClause
|
|
!PARSE-TREE: | | | Modifier -> OmpReductionIdentifier -> DefinedOperator -> IntrinsicOperator = Add
|
|
!PARSE-TREE: | | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'sum'
|
|
!PARSE-TREE: | | Flags = {}
|
|
!PARSE-TREE: | Block
|
|
!PARSE-TREE: | | ExecutionPartConstruct -> ExecutableConstruct -> DoConstruct
|
|
|
|
do i = 1, n
|
|
sum%r = sum%r + values(i)%r
|
|
end do
|
|
|
|
prod%r = 1
|
|
!$omp parallel do reduction(*:prod)
|
|
!CHECK: !$OMP PARALLEL DO REDUCTION(*: prod)
|
|
|
|
!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct
|
|
!PARSE-TREE: | OmpBeginDirective
|
|
!PARSE-TREE: | | OmpDirectiveName -> llvm::omp::Directive = parallel do
|
|
!PARSE-TREE: | | OmpClauseList -> OmpClause -> Reduction -> OmpReductionClause
|
|
!PARSE-TREE: | | | Modifier -> OmpReductionIdentifier -> DefinedOperator -> IntrinsicOperator = Multiply
|
|
!PARSE-TREE: | | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'prod'
|
|
!PARSE-TREE: | | Flags = {}
|
|
!PARSE-TREE: | Block
|
|
!PARSE-TREE: | | ExecutionPartConstruct -> ExecutableConstruct -> DoConstruct
|
|
|
|
do i = 1, n
|
|
prod%r = prod%r * (values(i)%r+0.6)
|
|
end do
|
|
|
|
big%r = 0
|
|
!$omp parallel do reduction(max:big)
|
|
!CHECK: $OMP PARALLEL DO REDUCTION(max: big)
|
|
|
|
!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct
|
|
!PARSE-TREE: | OmpBeginDirective
|
|
!PARSE-TREE: | | OmpDirectiveName -> llvm::omp::Directive = parallel do
|
|
!PARSE-TREE: | | OmpClauseList -> OmpClause -> Reduction -> OmpReductionClause
|
|
!PARSE-TREE: | | | Modifier -> OmpReductionIdentifier -> ProcedureDesignator -> Name = 'max'
|
|
!PARSE-TREE: | | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'big'
|
|
!PARSE-TREE: | | Flags = {}
|
|
!PARSE-TREE: | Block
|
|
!PARSE-TREE: | | ExecutionPartConstruct -> ExecutableConstruct -> DoConstruct
|
|
|
|
do i = 1, n
|
|
big = mymax(values(i), big)
|
|
end do
|
|
|
|
small%r = 1
|
|
!$omp parallel do reduction(min:small)
|
|
!CHECK: !$OMP PARALLEL DO REDUCTION(min: small)
|
|
|
|
!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct
|
|
!PARSE-TREE: | OmpBeginDirective
|
|
!PARSE-TREE: | | OmpDirectiveName -> llvm::omp::Directive = parallel do
|
|
!PARSE-TREE: | | OmpClauseList -> OmpClause -> Reduction -> OmpReductionClause
|
|
!PARSE-TREE: | | | Modifier -> OmpReductionIdentifier -> ProcedureDesignator -> Name = 'min'
|
|
!PARSE-TREE: | | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'small'
|
|
!PARSE-TREE: | | Flags = {}
|
|
!PARSE-TREE: | Block
|
|
!PARSE-TREE: | | ExecutionPartConstruct -> ExecutableConstruct -> DoConstruct
|
|
|
|
do i = 1, n
|
|
small%r = min(values(i)%r, small%r)
|
|
end do
|
|
|
|
print *, values%r
|
|
print *, "sum=", sum%r
|
|
print *, "prod=", prod%r
|
|
print *, "small=", small%r, " big=", big%r
|
|
end program omp_examples
|