123 lines · plain
1! RUN: %flang_fc1 -fdebug-unparse -fopenmp %s | FileCheck --ignore-case %s2! RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp %s | FileCheck --check-prefix="PARSE-TREE" %s3 4!CHECK-LABEL: SUBROUTINE initme (x, n)5subroutine initme(x,n)6 integer x,n7 x=n8end subroutine initme9!CHECK: END SUBROUTINE initme10 11!CHECK: FUNCTION func(x, n, init)12function func(x, n, init)13 integer func14 integer x(n)15 integer res16 interface17 subroutine initme(x,n)18 integer x,n19 end subroutine initme20 end interface21!$omp declare reduction(red_add:integer(4):omp_out=omp_out+omp_in) initializer(initme(omp_priv,0))22!CHECK: !$OMP DECLARE REDUCTION(red_add:INTEGER(KIND=4_4): omp_out=omp_out+omp_in) INITIA&23!CHECKL !$OMP&LIZER(initme(omp_priv,0))24 25!PARSE-TREE: DeclarationConstruct -> SpecificationConstruct -> OpenMPDeclarativeConstruct -> OpenMPDeclareReductionConstruct -> OmpDirectiveSpecification26!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction27!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier28!PARSE-TREE: | | OmpReductionIdentifier -> ProcedureDesignator -> Name = 'red_add'29!PARSE-TREE: | | OmpTypeNameList -> OmpTypeName -> DeclarationTypeSpec -> IntrinsicTypeSpec -> IntegerTypeSpec -> KindSelector -> Scalar -> Integer -> Constant -> Expr = '4_4'30!PARSE-TREE: | | | LiteralConstant -> IntLiteralConstant = '4'31!PARSE-TREE: | | OmpCombinerExpression -> OmpStylizedInstance32!PARSE-TREE: | | | OmpStylizedDeclaration33!PARSE-TREE: | | | OmpStylizedDeclaration34!PARSE-TREE: | | | Instance -> AssignmentStmt = 'omp_out=omp_out+omp_in'35!PARSE-TREE: | | | | Variable = 'omp_out'36!PARSE-TREE: | | | | | Designator -> DataRef -> Name = 'omp_out'37!PARSE-TREE: | | | | Expr = 'omp_out+omp_in'38!PARSE-TREE: | | | | | Add39!PARSE-TREE: | | | | | | Expr = 'omp_out'40!PARSE-TREE: | | | | | | | Designator -> DataRef -> Name = 'omp_out'41!PARSE-TREE: | | | | | | Expr = 'omp_in'42!PARSE-TREE: | | | | | | | Designator -> DataRef -> Name = 'omp_in'43!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> OmpInitializerExpression -> OmpStylizedInstance44!PARSE-TREE: | | OmpStylizedDeclaration45!PARSE-TREE: | | OmpStylizedDeclaration46!PARSE-TREE: | | Instance -> CallStmt = 'CALL initme(omp_priv,0_4)'47!PARSE-TREE: | | | Call48!PARSE-TREE: | | | | ProcedureDesignator -> Name = 'initme'49!PARSE-TREE: | | | | ActualArgSpec50!PARSE-TREE: | | | | | ActualArg -> Expr = 'omp_priv'51!PARSE-TREE: | | | | | | Designator -> DataRef -> Name = 'omp_priv'52!PARSE-TREE: | | | | ActualArgSpec53!PARSE-TREE: | | | | | ActualArg -> Expr = '0_4'54!PARSE-TREE: | | | | | | LiteralConstant -> IntLiteralConstant = '0'55!PARSE-TREE: | Flags = {}56 57 res=init58!$omp simd reduction(red_add:res)59!CHECK: !$OMP SIMD REDUCTION(red_add: res)60 61!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> ActionStmt -> AssignmentStmt = 'res=init'62!PARSE-TREE: | Variable = 'res'63!PARSE-TREE: | | Designator -> DataRef -> Name = 'res'64!PARSE-TREE: | Expr = 'init'65!PARSE-TREE: | | Designator -> DataRef -> Name = 'init'66!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct67!PARSE-TREE: | OmpBeginLoopDirective68!PARSE-TREE: | | OmpDirectiveName -> llvm::omp::Directive = simd69!PARSE-TREE: | | OmpClauseList -> OmpClause -> Reduction -> OmpReductionClause70!PARSE-TREE: | | | Modifier -> OmpReductionIdentifier -> ProcedureDesignator -> Name = 'red_add'71!PARSE-TREE: | | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'res'72!PARSE-TREE: | | Flags = {}73!PARSE-TREE: | Block74!PARSE-TREE: | | ExecutionPartConstruct -> ExecutableConstruct -> DoConstruct75 76 do i=1,n77 res=res+x(i)78 enddo79 func=res80end function func81!CHECK: END FUNCTION func82 83!CHECK-LABEL: program main84program main85 integer :: my_var86!CHECK: !$OMP DECLARE REDUCTION(my_add_red:INTEGER: omp_out = omp_out + omp_in) INITIA&87!CHECK: !$OMP&LIZER(omp_priv=0)88 89 !$omp declare reduction (my_add_red : integer : omp_out = omp_out + omp_in) initializer (omp_priv=0)90 my_var = 091 !$omp parallel reduction (my_add_red : my_var) num_threads(4)92 my_var = omp_get_thread_num() + 193 !$omp end parallel94 print *, "sum of thread numbers is ", my_var95end program main96 97!PARSE-TREE: DeclarationConstruct -> SpecificationConstruct -> OpenMPDeclarativeConstruct -> OpenMPDeclareReductionConstruct -> OmpDirectiveSpecification98!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction99!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier100!PARSE-TREE: | | OmpReductionIdentifier -> ProcedureDesignator -> Name = 'my_add_red'101!PARSE-TREE: | | OmpTypeNameList -> OmpTypeName -> DeclarationTypeSpec -> IntrinsicTypeSpec -> IntegerTypeSpec ->102!PARSE-TREE: | | OmpCombinerExpression -> OmpStylizedInstance103!PARSE-TREE: | | | OmpStylizedDeclaration104!PARSE-TREE: | | | OmpStylizedDeclaration105!PARSE-TREE: | | | Instance -> AssignmentStmt = 'omp_out=omp_out+omp_in'106!PARSE-TREE: | | | | Variable = 'omp_out'107!PARSE-TREE: | | | | | Designator -> DataRef -> Name = 'omp_out'108!PARSE-TREE: | | | | Expr = 'omp_out+omp_in'109!PARSE-TREE: | | | | | Add110!PARSE-TREE: | | | | | | Expr = 'omp_out'111!PARSE-TREE: | | | | | | | Designator -> DataRef -> Name = 'omp_out'112!PARSE-TREE: | | | | | | Expr = 'omp_in'113!PARSE-TREE: | | | | | | | Designator -> DataRef -> Name = 'omp_in'114!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> OmpInitializerExpression -> OmpStylizedInstance115!PARSE-TREE: | | OmpStylizedDeclaration116!PARSE-TREE: | | OmpStylizedDeclaration117!PARSE-TREE: | | Instance -> AssignmentStmt = 'omp_priv=0_4'118!PARSE-TREE: | | | Variable = 'omp_priv'119!PARSE-TREE: | | | | Designator -> DataRef -> Name = 'omp_priv'120!PARSE-TREE: | | | Expr = '0_4'121!PARSE-TREE: | | | | LiteralConstant -> IntLiteralConstant = '0'122!PARSE-TREE: | Flags = {}123