Skip to content

OmpSupport

Types and functions to support OpenMP

Types

Name

Description

ClauseVariableCopyIdentity

Exact identities produced when an outlined OpenMP clause‐variable record is transferred through one deep‐copy transaction.

ComplexClause

OpenMPConversionSession

OpenMPConversionSessionAccess

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

AssociatedLoopPathContract

Typed allowlists for the structural path from an OpenMP directive's exact body edge to its associated loop. Worksharing and SIMD constructs permit only transparent singleton basic blocks. Loop transformations additionally permit nested, supported loop‐transformation directives; semantic OpenMP regions and attributed statements are never transparent wrappers.

omp_construct_enum

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

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

Attach a transformation‐generated OpenMP clause, assigning exact source‐order provenance when the directive came from combined syntax.

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

Attach an OpenMP clause to directive

analyze_omp
void analyze_omp(SgSourceFile*);

beginOpenACCCxxExactSemanticConsumption
void beginOpenACCCxxExactSemanticConsumption(SgPragmaDeclaration* pragma);

beginOpenACCCxxExactSemanticExpression
void beginOpenACCCxxExactSemanticExpression(SgPragmaDeclaration* pragma, std::string const& expression, OpenMPExprParseMode parse_mode);

beginOpenACCFortranExactSemanticConsumption
void beginOpenACCFortranExactSemanticConsumption(SgPragmaDeclaration* pragma);

beginOpenACCFortranExactSemanticExpression
void beginOpenACCFortranExactSemanticExpression(SgPragmaDeclaration* pragma, std::string const& expression);

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

buildFortranOutlinedFunctionRef
SgFunctionRefExp* buildFortranOutlinedFunctionRef(SgFunctionDeclaration* declaration);

Build a reference to a generated Fortran outlined procedure through its exact semantic‐only publication.

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

clearImplicitTargetMapVariables
void clearImplicitTargetMapVariables();

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);

consumeOpenACCFortranExactSemanticEnd
void consumeOpenACCFortranExactSemanticEnd(SgPragmaDeclaration* pragma);

consumeOpenACCFortranExactSemanticSyntax
void consumeOpenACCFortranExactSemanticSyntax(SgPragmaDeclaration* pragma, std::string const& spelling);

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

discardOpenMPProducerSemanticRecords
void discardOpenMPProducerSemanticRecords(SgSourceFile* source_file);

endOpenACCCxxExactSemanticExpression
void endOpenACCCxxExactSemanticExpression(SgPragmaDeclaration* pragma);

endOpenACCFortranExactSemanticExpression
void endOpenACCFortranExactSemanticExpression(SgPragmaDeclaration* pragma);

finishOpenACCCxxExactSemanticConsumption
void finishOpenACCCxxExactSemanticConsumption(SgPragmaDeclaration* pragma);

finishOpenACCFortranExactSemanticConsumption
void finishOpenACCFortranExactSemanticConsumption(SgPragmaDeclaration* pragma);

generateOutlinedTask
SgFunctionDeclaration* generateOutlinedTask(SgNode* node, std::string& wrapper_name, ASTtools::VarSymSet_t& syms, ASTtools::VarSymSet_t& pdSyms3, bool use_task_param = false, bool insert_runtime_ids = true);

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

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

Generate XOMP loop schedule next function's name

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

Generate XOMP loop schedule start function's name

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

getKmpcRuntimeFunctionName
std::string getKmpcRuntimeFunctionName(std::string const& abiName);

Return the exact source‐language identifier for one LLVM OpenMP runtime entry point. C/C++ use the ABI spelling directly; Fortran uses the standards‐conforming REX adapter spelling exported by kmpc_fortran_wrappers.c. Non‐__kmpc names are contract violations.

getOmpClauseList
SgOmpClauseList* getOmpClauseList(SgStatement* node);

getOmpParent
SgStatement* getOmpParent(SgStatement* node);

getOpenMPMergedEndClauseSource
std::string const& getOpenMPMergedEndClauseSource(OpenMPClause const* clause);

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*);

Insert runtime init and terminate routines to main() entry

insertRTLHeaders
void insertRTLHeaders(SgSourceFile*);

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

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

isImplicitTargetMapVariable
bool isImplicitTargetMapVariable(SgOmpClauseBodyStatement const* target, SgSymbol const* sym);

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

isInClauseVariableList overloads

isInOmpTargetRegion
bool isInOmpTargetRegion(SgStatement* node);

Check whether a SgNode is inside omp target

isOmpContextSelectorMetadataDirective
bool isOmpContextSelectorMetadataDirective(SgNode const*);

Return true when an OpenMP statement is a syntax‐only construct selector owned by a MATCH/WHEN clause rather than an executable AST statement.

isOpenMPMergedEndClause
bool isOpenMPMergedEndClause(OpenMPClause const* clause);

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*);

markImplicitTargetMapVariable
void markImplicitTargetMapVariable(SgOmpClauseBodyStatement* target, SgInitializedName* var);

markOpenMPMergedEndClause
void markOpenMPMergedEndClause(OpenMPClause* clause, std::string const& source_text);

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

openMPExpressionVariables
std::vector<SgNode*>& openMPExpressionVariables();

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);

registerOpenACCCxxExactSemanticBindings
void registerOpenACCCxxExactSemanticBindings(SgSourceFile* source_file, SgPragmaDeclaration* pragma, OpenACCCxxExactSemanticBindings bindings);

registerOpenMPFortranExactSemanticBindings
void registerOpenMPFortranExactSemanticBindings(SgSourceFile* source_file, SgPragmaDeclaration* pragma, OmpFortranExactSemanticBindings bindings);

registerOpenMPProducerSemanticRecords
void registerOpenMPProducerSemanticRecords(SgSourceFile* source_file, SgPragmaDeclaration* pragma, OpenMPProducerSemanticRecords records);

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

requireExactAssociatedForLoop
SgForStatement* requireExactAssociatedForLoop(SgOmpBodyStatement* directive, SgStatement* expected_root, AssociatedLoopPathContract path_contract, char const* contract);

requireExactAssociatedLoop
SgStatement* requireExactAssociatedLoop(SgOmpBodyStatement* directive, SgStatement* expected_root, AssociatedLoopPathContract path_contract, char const* contract);

Return the one exact loop owned by directive through expected_root. Every structural edge must be unique and parent‐consistent, and every wrapper must be admitted by path_contract. Malformed, ambiguous, cyclic, attributed, or semantically different wrapper paths are hard errors.

requireExactClauseVariableCopyIdentity
ClauseVariableCopyIdentity requireExactClauseVariableCopyIdentity(SgCopyHelp::copiedNodeMapType const& identityMap, SgOmpExecStatement* originalDirective, SgInitializedName* originalClauseVariable, SgVariableSymbol* originalBackingSymbol);

Resolve one original directive, all of the clause variable's exact expression identities, and its pointer‐backing symbol through the deep‐copy identity map. The copied clause expressions must agree on exactly one symbol/declaration. Missing, identity, ambiguous, or wrongly typed mappings are hard errors; spelling and scope lookup are never used.

requireExactIntegralConstantExpression
void requireExactIntegralConstantExpression(SgExpression* expression, char const* contract);

Require expression to be one language‐valid target‐ABI integral constant expression. This is a proof‐only API: every runtime expression is a hard contract violation.

requireExactPositiveIntegralConstant
unsigned long long requireExactPositiveIntegralConstant(SgExpression* expression, unsigned long long maximum, char const* contract);

Evaluate a language‐valid, target‐ABI integral constant and require it to be in [1, maximum]. Unsupported, malformed, volatile, cyclic, or undefined constant expressions are hard errors; no textual parsing or fallback value is permitted.

requireOpenMPConversionSession
void requireOpenMPConversionSession();

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

snapshotOpenMPProducerSemanticRecords
OpenMPProducerSemanticRecords snapshotOpenMPProducerSemanticRecords(SgPragmaDeclaration* pragma);

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

transOmpTaskgroup
void transOmpTaskgroup(SgNode* node);

transOmpTaskloop
void transOmpTaskloop(SgNode* node);

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