Skip to content

OmpSupport

Types and functions to support OpenMP

Types

Name

Description

ComplexClause

SgVarRefExpVisitor

translationDriver

A driver to traverse AST trees and invoke individual translators for OpenMP constructs, (not in use) Postorder is preferred.

VariableSymbolMap_t

Enums

Name

Description

omp_construct_enum

omp_rtl_enum

The type of target runtime libraries (not yet in use)

Functions

Name

Description

addClauseVariable
void addClauseVariable(SgInitializedName* var, SgOmpClauseBodyStatement* clause_stmt, VariantT const& vt);

Add a variable into a non‐reduction clause of an OpenMP statement, create the clause transparently if it does not exist

addOmpClause
void addOmpClause(SgStatement* node, SgOmpClause* clause);

Attach an OpenMP clause to directive

analyze_omp
void analyze_omp(SgSourceFile*);

buildAndInsertDeclarationForOmp
SgVariableDeclaration* buildAndInsertDeclarationForOmp(std::string const& name, SgType* type, SgInitializer* varInit, SgBasicBlock* orig_scope);

Special handling when trying to build and insert a variable declaration into a BB within Fortran OpenMP code

buildOmpVariableClause
SgOmpVariablesClause* buildOmpVariableClause(SgOmpClauseBodyStatement* clause_stmt, VariantT const& vt);

Build a non‐reduction variable clause for a given OpenMP directive. It directly returns the clause if the clause already exists

categorizeMapClauseVariables
void categorizeMapClauseVariables(SgInitializedNamePtrList const& all_vars, std::map<SgSymbol*, std::vector<std::pair<SgExpression*, SgExpression*>>>& array_dimensions, std::set<SgSymbol*>& array_syms, std::set<SgSymbol*>& atom_syms);

Categorize mapped variables

collectAllClauseVariables
SgInitializedNamePtrList collectAllClauseVariables(SgStatement* clause_stmt);

Collect all variables from OpenMP clauses associated with an omp statement: private, reduction, etc

collectClauseVariables
SgInitializedNamePtrList collectClauseVariables(SgStatement* clause_stmt, VariantT const& vt);

collectClauseVariables overloads

collectThreadprivateVariables
std::set<SgInitializedName*> collectThreadprivateVariables();

Collect threadprivate variables within the current project, return a set to avoid duplicated elements. No input parameters are needed since it finds match from memory pools

commandLineProcessing
void commandLineProcessing(std::vector<std::string>& argvList);

createInitialValueExp
SgExpression* createInitialValueExp(SgOmpClause::omp_reduction_identifier_enum r_operator);

Create an initial value according to reduction operator type

createOmpStatementTree
void createOmpStatementTree(SgSourceFile* file);

Analysis helpers

extractMapClauses
void extractMapClauses(std::vector<SgOmpClause*> map_clauses, std::map<SgSymbol*, std::vector<std::pair<SgExpression*, SgExpression*>>>& array_dimensions, std::map<SgSymbol*, std::vector<std::pair<SgOmpClause::omp_map_dist_data_enum, SgExpression*>>>& dist_data_policies, SgOmpMapClause map_alloc_clause, SgOmpMapClause map_to_clause, SgOmpMapClause map_from_clause, SgOmpMapClause map_tofrom_clause);

Extract map clause information

generateGOMPLoopNextFuncName
std::string generateGOMPLoopNextFuncName(bool isOrdered, SgOmpClause::omp_schedule_kind_enum s_kind);

Generate GOMP loop schedule next function's name

generateGOMPLoopStartFuncName
std::string generateGOMPLoopStartFuncName(bool isOrdered, SgOmpClause::omp_schedule_kind_enum s_kind);

Generate GOMP loop schedule start function's name

generateOutlinedTask
SgFunctionDeclaration* generateOutlinedTask(SgNode* node, std::string& wrapper_name, std::set<SgVariableSymbol const*>& syms, std::set<SgVariableSymbol const*>& pdSyms3, bool use_task_param = false);

A helper function to generate implicit or explicit task for either omp parallel or omp task

getClause
std::vector<SgOmpClause*> getClause(SgStatement* clause_stmt, VariantT const& vt);

Get OpenMP clauses from an eligible OpenMP statement

getClauseExpression
SgExpression* getClauseExpression(SgStatement* clause_stmt, VariantVector const& vvt);

Collect expression from given types of OpenMP clauses associated with an omp statement: private, reduction, etc

getDataSharingAttribute
omp_construct_enum getDataSharingAttribute(SgVarRefExp* varRef);

getDataSharingAttribute overloads

getEnclosingRegionOrFuncDefinition
SgBasicBlock* getEnclosingRegionOrFuncDefinition(SgNode*);

Find an enclosing parallel region or function definition's body

getOmpParent
SgStatement* getOmpParent(SgStatement* node);

getReductionOperationType
SgOmpClause::omp_reduction_identifier_enum getReductionOperationType(SgInitializedName* init_name, SgOmpClauseBodyStatement* clause_stmt);

Return a reduction variable's reduction operation type

hasClause
bool hasClause(SgStatement* clause_stmt, VariantT const& vt);

Check if an OpenMP statement has a clause of type vt

insertAcceleratorInit
void insertAcceleratorInit(SgSourceFile*);

insertRTLHeaders
void insertRTLHeaders(SgSourceFile*);

Insert #include "xxx.h", the interface of a runtime library to the compiler

insertRTLinitAndCleanCode
void insertRTLinitAndCleanCode(SgSourceFile*);

Insert runtime init and terminate routines to main() entry

isClause
bool isClause(omp_construct_enum omp_type);

Check if an OpenMP construct is a clause

isDependenceType
bool isDependenceType(omp_construct_enum omp_type);

Check if an OpenMP construct is a dependence type for omp task depend

isDirective
bool isDirective(omp_construct_enum omp_type);

Check if an OpenMP construct is a directive

isDirectiveWithBody
bool isDirectiveWithBody(omp_construct_enum omp_type);

Check if an OpenMP directive has a structured body

isFortranBeginDirective
bool isFortranBeginDirective(omp_construct_enum omp_type);

Check if the construct is a Fortran directive which can (optionally) have a corresponding END directive

isFortranEndDirective
bool isFortranEndDirective(omp_construct_enum omp_type);

Check if the construct is a Fortran END ... directive

isInClauseVariableList
bool isInClauseVariableList(SgOmpClause* cls, SgSymbol* var);

isInClauseVariableList overloads

isInOmpTargetRegion
bool isInOmpTargetRegion(SgStatement* node);

Check whether a SgNode is inside omp target

isReductionOperator
bool isReductionOperator(omp_construct_enum omp_type);

Check if an OpenMP construct is a reduction operator

isSharedAccess
bool isSharedAccess(SgVarRefExp* varRef);

Check if a variable access is a shared access , assuming it is already within an OpenMP region.

isThreadprivate
bool isThreadprivate(SgSymbol* var);

Check if a variable is a threadprivate variable. It will search for all threadprivate directives to find the answer.

lower_omp
void lower_omp(SgSourceFile*);

The top level interface to translate OpenMP directives

makeDataSharingExplicit
int makeDataSharingExplicit(SgFile*);

mergeSgNodeList
std::vector<SgNode*> mergeSgNodeList(std::vector<SgNode*> node_list1, std::vector<SgNode*> node_list2);

patchUpFirstprivateVariables
int patchUpFirstprivateVariables(SgFile*);

Patch up firstprivate variables for omp task. The reason is that the specification 3.0 defines rules for implicitly determined data‐sharing attributes and this function will make the firstprivate variable of omp task explicit.

patchUpPrivateVariables
int patchUpPrivateVariables(SgFile*);

patchUpPrivateVariables overloads

patchUpSharedVariables
int patchUpSharedVariables(SgFile*);

makeDataSharingExplicit() can call some of existing functions for some work in OmpSupport namespace by Hongyi 07/16/2012 TODO: add a function within the OmpSupport namespace, the function should transform the AST, so all variables' data‐sharing attributes are explicitied represented in the AST. ROSE has dedicated AST nodes for OpenMP directives and the associated clauses, such as private, shared, reduction.

processOpenMP
void processOpenMP(SgSourceFile* sageFilePtr);

removeClause
int removeClause(SgStatement* clause_stmt, VariantT const& vt);

Remove one or more clauses of type vt

replaceVariableReferences
int replaceVariableReferences(SgNode* root, VariableSymbolMap_t varRemap);

replaceVariableReferences overloads

replaceVariablesWithPointerDereference
int replaceVariablesWithPointerDereference(SgNode* root, std::set<SgVariableSymbol*>& vars);

Replace all variable references in a set by pointers to the variable

setOmpRelationship
void setOmpRelationship(SgStatement* parent, SgStatement* child);

toString
std::string toString(omp_construct_enum omp_type);

toString overloads

transOmpAtomic
void transOmpAtomic(SgNode* node);

Translate omp atomic

transOmpBarrier
void transOmpBarrier(SgNode* node);

Translate omp barrier

transOmpCollapse
void transOmpCollapse(SgStatement* node);

transOmpCritical
void transOmpCritical(SgNode* node);

Translate omp critical

transOmpFlush
void transOmpFlush(SgNode* node);

Translate omp flush

transOmpLoop
void transOmpLoop(SgNode* node);

Translate omp for or omp do loops

transOmpMaster
void transOmpMaster(SgNode* node);

Translate omp master

transOmpMetadirective
void transOmpMetadirective(SgNode* node);

Translate omp metadirective

transOmpOrdered
void transOmpOrdered(SgNode* node);

Translate the ordered directive (not the ordered clause)

transOmpParallel
void transOmpParallel(SgNode* node);

Translate omp parallel

transOmpSections
void transOmpSections(SgNode* node);

Translate omp sections

transOmpSimd
void transOmpSimd(SgNode* node);

Translate omp simd

transOmpSingle
void transOmpSingle(SgNode* node);

Translate omp single

transOmpTarget
void transOmpTarget(SgNode* node);

Translate "omp target"

transOmpTargetData
void transOmpTargetData(SgNode* node);

Translate "omp target data"

transOmpTargetLoop
void transOmpTargetLoop(SgNode* node);

Translate omp for or omp do loops affected by the "omp target" directive, using naive 1‐to‐1 mapping Liao 1/28/2013

transOmpTargetLoop_RoundRobin
void transOmpTargetLoop_RoundRobin(SgNode* node);

Translate omp for or omp do loops affected by the "omp target" directive, using a round robin‐scheduler Liao 7/10/2014

transOmpTargetParallel
void transOmpTargetParallel(SgNode* node);

Translate omp parallel under "omp target"

transOmpTask
void transOmpTask(SgNode* node);

Translate omp task

transOmpTaskwait
void transOmpTaskwait(SgNode* node);

Translate omp taskwait

transOmpThreadprivate
void transOmpThreadprivate(SgNode* node);

Translate omp threadprivate

transOmpTile
void transOmpTile(SgNode* node);

Translate omp tile

transOmpUnroll
void transOmpUnroll(SgNode* node);

Translate omp unroll

transOmpVariables
void transOmpVariables(SgStatement* ompStmt, SgBasicBlock* bb1, SgExpression* orig_loop_upper = NULL, bool withinAcceleratorModel = false);

Translate OpenMP variables associated with an OpenMP pragma, such as private, firstprivate, lastprivate, reduction, etc. bb1 is the translation generated code block in which the variable handling statements will be inserted. Original loop upper bound is needed for implementing lastprivate (check if it is the last iteration). withinAcceleratorModel means if we only translate private() variables, used to support accelerator model

useStaticSchedule
bool useStaticSchedule(SgOmpClauseBodyStatement* omp_loop);

Check if an omp for/do loop use static schedule or not, including: default schedule, or schedule(static[,chunk_size])

Description

OpenMP specific data types and functions are put into this namespace

Created with MrDocs