Polly 20.0.0git
Classes | Namespaces | Macros | Typedefs | Functions
IslAst.cpp File Reference
#include "polly/CodeGen/IslAst.h"
#include "polly/CodeGen/CodeGeneration.h"
#include "polly/DependenceInfo.h"
#include "polly/LinkAllPasses.h"
#include "polly/Options.h"
#include "polly/ScopDetection.h"
#include "polly/ScopInfo.h"
#include "polly/ScopPass.h"
#include "polly/Support/GICHelper.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/IR/Function.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "isl/aff.h"
#include "isl/ast.h"
#include "isl/ast_build.h"
#include "isl/id.h"
#include "isl/isl-noexceptions.h"
#include "isl/printer.h"
#include "isl/schedule.h"
#include "isl/set.h"
#include "isl/union_map.h"
#include "isl/val.h"
#include <cassert>
#include <cstdlib>
#include "polly/Support/PollyDebug.h"

Go to the source code of this file.

Classes

struct  polly::AstBuildUserInfo
 Temporary information used when building the ast. More...
 

Namespaces

namespace  polly
 

Macros

#define DEBUG_TYPE   "polly-ast"
 

Typedefs

using IslAstUserPayload = IslAstInfo::IslAstUserPayload
 

Functions

static cl::opt< bool > PollyParallel ("polly-parallel", cl::desc("Generate thread parallel code (isl codegen only)"), cl::cat(PollyCategory))
 
static cl::opt< bool > PrintAccesses ("polly-ast-print-accesses", cl::desc("Print memory access functions"), cl::cat(PollyCategory))
 
static cl::opt< bool > PollyParallelForce ("polly-parallel-force", cl::desc("Force generation of thread parallel code ignoring any cost model"), cl::cat(PollyCategory))
 
static cl::opt< bool > UseContext ("polly-ast-use-context", cl::desc("Use context"), cl::Hidden, cl::init(true), cl::cat(PollyCategory))
 
static cl::opt< bool > DetectParallel ("polly-ast-detect-parallel", cl::desc("Detect parallelism"), cl::Hidden, cl::cat(PollyCategory))
 
 STATISTIC (ScopsProcessed, "Number of SCoPs processed")
 
 STATISTIC (ScopsBeneficial, "Number of beneficial SCoPs")
 
 STATISTIC (BeneficialAffineLoops, "Number of beneficial affine loops")
 
 STATISTIC (BeneficialBoxedLoops, "Number of beneficial boxed loops")
 
 STATISTIC (NumForLoops, "Number of for-loops")
 
 STATISTIC (NumParallel, "Number of parallel for-loops")
 
 STATISTIC (NumInnermostParallel, "Number of innermost parallel for-loops")
 
 STATISTIC (NumOutermostParallel, "Number of outermost parallel for-loops")
 
 STATISTIC (NumReductionParallel, "Number of reduction-parallel for-loops")
 
 STATISTIC (NumExecutedInParallel, "Number of for-loops executed in parallel")
 
 STATISTIC (NumIfConditions, "Number of if-conditions")
 
static void freeIslAstUserPayload (void *Ptr)
 Free an IslAstUserPayload object pointed to by Ptr.
 
static isl_printerprintLine (__isl_take isl_printer *Printer, const std::string &str, __isl_keep isl_pw_aff *PWA=nullptr)
 Print a string str in a single line using Printer.
 
static const std::string getBrokenReductionsStr (const isl::ast_node &Node)
 Return all broken reductions as a string of clauses (OpenMP style).
 
static isl_printercbPrintFor (__isl_take isl_printer *Printer, __isl_take isl_ast_print_options *Options, __isl_keep isl_ast_node *Node, void *)
 Callback executed for each for node in the ast in order to print it.
 
static bool astScheduleDimIsParallel (const isl::ast_build &Build, const Dependences *D, IslAstUserPayload *NodeInfo)
 Check if the current scheduling dimension is parallel.
 
static __isl_give isl_idastBuildBeforeFor (__isl_keep isl_ast_build *Build, void *User)
 
static __isl_give isl_ast_nodeastBuildAfterFor (__isl_take isl_ast_node *Node, __isl_keep isl_ast_build *Build, void *User)
 
static isl_stat astBuildBeforeMark (__isl_keep isl_id *MarkId, __isl_keep isl_ast_build *Build, void *User)
 
static __isl_give isl_ast_nodeastBuildAfterMark (__isl_take isl_ast_node *Node, __isl_keep isl_ast_build *Build, void *User)
 
static __isl_give isl_ast_nodeAtEachDomain (__isl_take isl_ast_node *Node, __isl_keep isl_ast_build *Build, void *User)
 
static isl::ast_expr buildCondition (Scop &S, isl::ast_build Build, const Scop::MinMaxAccessTy *It0, const Scop::MinMaxAccessTy *It1)
 
static bool benefitsFromPolly (Scop &Scop, bool PerformParallelTest)
 Simple cost analysis for a given SCoP.
 
static void walkAstForStatistics (const isl::ast_node &Ast)
 Collect statistics for the syntax tree rooted at Ast.
 
static std::unique_ptr< IslAstInforunIslAst (Scop &Scop, function_ref< const Dependences &(Dependences::AnalysisLevel)> GetDeps)
 
static __isl_give isl_printercbPrintUser (__isl_take isl_printer *P, __isl_take isl_ast_print_options *O, __isl_keep isl_ast_node *Node, void *User)
 
 INITIALIZE_PASS_BEGIN (IslAstInfoWrapperPass, "polly-ast", "Polly - Generate an AST of the SCoP (isl)", false, false)
 
 INITIALIZE_PASS_DEPENDENCY (ScopInfoRegionPass)
 
 INITIALIZE_PASS_DEPENDENCY (DependenceInfo)
 
 INITIALIZE_PASS_END (IslAstInfoWrapperPass, "polly-ast", "Polly - Generate an AST from the SCoP (isl)", false, false) namespace
 
 INITIALIZE_PASS_BEGIN (IslAstInfoPrinterLegacyPass, "polly-print-ast", "Polly - Print the AST from a SCoP (isl)", false, false)
 
 INITIALIZE_PASS_DEPENDENCY (IslAstInfoWrapperPass)
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "polly-ast"

Definition at line 56 of file IslAst.cpp.

Typedef Documentation

◆ IslAstUserPayload

Definition at line 61 of file IslAst.cpp.

Function Documentation

◆ astBuildAfterFor()

static __isl_give isl_ast_node * astBuildAfterFor ( __isl_take isl_ast_node Node,
__isl_keep isl_ast_build Build,
void *  User 
)
static

◆ astBuildAfterMark()

static __isl_give isl_ast_node * astBuildAfterMark ( __isl_take isl_ast_node Node,
__isl_keep isl_ast_build Build,
void *  User 
)
static

◆ astBuildBeforeFor()

static __isl_give isl_id * astBuildBeforeFor ( __isl_keep isl_ast_build Build,
void *  User 
)
static

◆ astBuildBeforeMark()

static isl_stat astBuildBeforeMark ( __isl_keep isl_id MarkId,
__isl_keep isl_ast_build Build,
void *  User 
)
static

◆ astScheduleDimIsParallel()

static bool astScheduleDimIsParallel ( const isl::ast_build Build,
const Dependences D,
IslAstUserPayload NodeInfo 
)
static

Check if the current scheduling dimension is parallel.

In case the dimension is parallel we also check if any reduction dependences is broken when we exploit this parallelism. If so, IsReductionParallel will be set to true. The reduction dependences we use to check are actually the union of the transitive closure of the initial reduction dependences together with their reversal. Even though these dependences connect all iterations with each other (thus they are cyclic) we can perform the parallelism check as we are only interested in a zero (or non-zero) dependence distance on the dimension in question.

Definition at line 201 of file IslAst.cpp.

References polly::IslAstInfo::IslAstUserPayload::BrokenReductions, isl::union_map::get(), isl::ast_build::get_schedule(), polly::Dependences::getDependences(), polly::Dependences::getReductionDependences(), polly::Dependences::hasValidDependences(), polly::Dependences::isParallel(), polly::IslAstInfo::IslAstUserPayload::IsReductionParallel, isl::manage(), isl::manage_copy(), polly::IslAstInfo::IslAstUserPayload::MinimalDependenceDistance, isl::union_map::release(), polly::Dependences::TYPE_RAW, polly::Dependences::TYPE_TC_RED, polly::Dependences::TYPE_WAR, and polly::Dependences::TYPE_WAW.

Referenced by astBuildBeforeFor().

◆ AtEachDomain()

static __isl_give isl_ast_node * AtEachDomain ( __isl_take isl_ast_node Node,
__isl_keep isl_ast_build Build,
void *  User 
)
static

◆ benefitsFromPolly()

static bool benefitsFromPolly ( Scop Scop,
bool  PerformParallelTest 
)
static

Simple cost analysis for a given SCoP.

TODO: Improve this analysis and extract it to make it usable in other places too. In order to improve the cost model we could either keep track of performed optimizations (e.g., tiling) or compute properties on the original as well as optimized SCoP (e.g., #stride-one-accesses).

Definition at line 445 of file IslAst.cpp.

References polly::Scop::getAliasGroups(), polly::Scop::isOptimized(), and polly::PollyProcessUnprofitable.

Referenced by polly::IslAst::init().

◆ buildCondition()

static isl::ast_expr buildCondition ( Scop S,
isl::ast_build  Build,
const Scop::MinMaxAccessTy It0,
const Scop::MinMaxAccessTy It1 
)
static

◆ cbPrintFor()

static isl_printer * cbPrintFor ( __isl_take isl_printer Printer,
__isl_take isl_ast_print_options Options,
__isl_keep isl_ast_node Node,
void *   
)
static

◆ cbPrintUser()

static __isl_give isl_printer * cbPrintUser ( __isl_take isl_printer P,
__isl_take isl_ast_print_options O,
__isl_keep isl_ast_node Node,
void *  User 
)
static

◆ DetectParallel()

static cl::opt< bool > DetectParallel ( "polly-ast-detect-parallel"  ,
cl::desc("Detect parallelism")  ,
cl::Hidden  ,
cl::cat(PollyCategory  
)
static

Referenced by polly::IslAst::init().

◆ freeIslAstUserPayload()

static void freeIslAstUserPayload ( void *  Ptr)
static

Free an IslAstUserPayload object pointed to by Ptr.

Definition at line 121 of file IslAst.cpp.

Referenced by astBuildBeforeFor(), and AtEachDomain().

◆ getBrokenReductionsStr()

static const std::string getBrokenReductionsStr ( const isl::ast_node Node)
static

Return all broken reductions as a string of clauses (OpenMP style).

Definition at line 137 of file IslAst.cpp.

References polly::IslAstInfo::getBrokenReductions(), polly::MemoryAccess::getReductionOperatorStr(), and str.

Referenced by cbPrintFor().

◆ INITIALIZE_PASS_BEGIN() [1/2]

INITIALIZE_PASS_BEGIN ( IslAstInfoPrinterLegacyPass  ,
"polly-print-ast"  ,
"Polly - Print the AST from a SCoP (isl)"  ,
false  ,
false   
)

◆ INITIALIZE_PASS_BEGIN() [2/2]

INITIALIZE_PASS_BEGIN ( IslAstInfoWrapperPass  ,
"polly-ast"  ,
"Polly - Generate an AST of the SCoP (isl)"  ,
false  ,
false   
)

◆ INITIALIZE_PASS_DEPENDENCY() [1/3]

INITIALIZE_PASS_DEPENDENCY ( DependenceInfo  )

◆ INITIALIZE_PASS_DEPENDENCY() [2/3]

INITIALIZE_PASS_DEPENDENCY ( IslAstInfoWrapperPass  )

◆ INITIALIZE_PASS_DEPENDENCY() [3/3]

INITIALIZE_PASS_DEPENDENCY ( ScopInfoRegionPass  )

◆ INITIALIZE_PASS_END()

INITIALIZE_PASS_END ( IslAstInfoWrapperPass  ,
"polly-ast"  ,
"Polly - Generate an AST from the SCoP (isl)"  ,
false  ,
false   
)

Print result from IslAstInfoWrapperPass.

Definition at line 818 of file IslAst.cpp.

References polly::ScopPass::getAnalysisUsage(), and polly::IslAstInfoWrapperPass::printScop().

◆ PollyParallel()

static cl::opt< bool > PollyParallel ( "polly-parallel"  ,
cl::desc("Generate thread parallel code (isl codegen only)")  ,
cl::cat(PollyCategory  
)
static

◆ PollyParallelForce()

static cl::opt< bool > PollyParallelForce ( "polly-parallel-force"  ,
cl::desc("Force generation of thread parallel code ignoring any cost model")  ,
cl::cat(PollyCategory  
)
static

◆ PrintAccesses()

static cl::opt< bool > PrintAccesses ( "polly-ast-print-accesses"  ,
cl::desc("Print memory access functions")  ,
cl::cat(PollyCategory  
)
static

◆ printLine()

static isl_printer * printLine ( __isl_take isl_printer Printer,
const std::string &  str,
__isl_keep isl_pw_aff PWA = nullptr 
)
static

Print a string str in a single line using Printer.

Definition at line 126 of file IslAst.cpp.

References isl_printer_end_line(), isl_printer_print_pw_aff(), isl_printer_print_str(), isl_printer_start_line(), and str.

Referenced by cbPrintFor().

◆ runIslAst()

static std::unique_ptr< IslAstInfo > runIslAst ( Scop Scop,
function_ref< const Dependences &(Dependences::AnalysisLevel)>  GetDeps 
)
static

◆ STATISTIC() [1/11]

STATISTIC ( BeneficialAffineLoops  ,
"Number of beneficial affine loops"   
)

◆ STATISTIC() [2/11]

STATISTIC ( BeneficialBoxedLoops  ,
"Number of beneficial boxed loops"   
)

◆ STATISTIC() [3/11]

STATISTIC ( NumExecutedInParallel  ,
"Number of for-loops executed in parallel"   
)

◆ STATISTIC() [4/11]

STATISTIC ( NumForLoops  ,
"Number of for-loops"   
)

◆ STATISTIC() [5/11]

STATISTIC ( NumIfConditions  ,
"Number of if-conditions"   
)

◆ STATISTIC() [6/11]

STATISTIC ( NumInnermostParallel  ,
"Number of innermost parallel for-loops"   
)

◆ STATISTIC() [7/11]

STATISTIC ( NumOutermostParallel  ,
"Number of outermost parallel for-loops"   
)

◆ STATISTIC() [8/11]

STATISTIC ( NumParallel  ,
"Number of parallel for-loops"   
)

◆ STATISTIC() [9/11]

STATISTIC ( NumReductionParallel  ,
"Number of reduction-parallel for-loops"   
)

◆ STATISTIC() [10/11]

STATISTIC ( ScopsBeneficial  ,
"Number of beneficial SCoPs"   
)

◆ STATISTIC() [11/11]

STATISTIC ( ScopsProcessed  ,
"Number of SCoPs processed"   
)

◆ UseContext()

static cl::opt< bool > UseContext ( "polly-ast-use-context"  ,
cl::desc("Use context")  ,
cl::Hidden  ,
cl::init(true)  ,
cl::cat(PollyCategory  
)
static

Referenced by polly::IslAst::init().

◆ walkAstForStatistics()

static void walkAstForStatistics ( const isl::ast_node Ast)
static

Collect statistics for the syntax tree rooted at Ast.

Definition at line 459 of file IslAst.cpp.

References __isl_keep, assert, isl::ast_node::get(), isl::ast_node::is_null(), isl_ast_node_foreach_descendant_top_down(), and isl_bool_true.

Referenced by polly::IslAst::init().