Program Listing for File omp_lowering.h#
↰ Return to documentation for file (src/midend/programTransformation/ompLowering/omp_lowering.h)
#include "astQuery.h"
// #include "sage3basic.h"
#ifndef OMP_LOWERING_H
#define OMP_LOWERING_H
#include "ompSupport.h"
extern std::vector<SgFunctionDeclaration *> *target_outlined_function_list;
extern std::vector<SgDeclarationStatement *> *target_outlined_struct_list;
namespace OmpSupport {
// static std::vector<SgFunctionDeclaration* >* outlined_function_list = new
// std::vector<SgFunctionDeclaration *>();
// OpenMP version info.
extern bool enable_accelerator;
// A flag to control if device data environment runtime functions are used to
// automatically manage data as much as possible. instead of generating explicit
// data allocation, copy, free functions.
extern bool useDDE /* = true */;
int patchUpSharedVariables(SgFile *);
// TODO: patchUpDefaultVariables(SgFile* );
int makeDataSharingExplicit(SgFile *);
// last edited by Hongyi on 07/24/2012.
// We support both Omni and GCC OpenMP runtime libraries
enum omp_rtl_enum { e_gomp, e_omni, e_last_rtl };
extern unsigned int nCounter; // translation generated variable counter, used to
// avoid name collision
extern omp_rtl_enum rtl_type;
typedef std::map<const SgVariableSymbol *, SgVariableSymbol *>
VariableSymbolMap_t;
void commandLineProcessing(std::vector<std::string> &argvList);
void lower_omp(SgSourceFile *);
void analyze_omp(SgSourceFile *);
void insertRTLHeaders(SgSourceFile *);
void insertRTLinitAndCleanCode(SgSourceFile *);
// Pei-Hung Insert accelerator init
void insertAcceleratorInit(SgSourceFile *);
class translationDriver : public AstSimpleProcessing {
protected:
void visit(SgNode *);
}; // translationDriver
void transOmpParallel(SgNode *node);
void transOmpTargetParallel(SgNode *node);
void transOmpSections(SgNode *node);
void transOmpTask(SgNode *node);
void transOmpLoop(SgNode *node);
// The loop iteration count may exceed the max number of threads within a CUDA
// thread block. A loop scheduler is needed for real application.
void transOmpTargetLoop(SgNode *node);
void transOmpTargetLoop_RoundRobin(SgNode *node);
// void transOmpDo(SgNode* node);
void transOmpTarget(SgNode *node);
void transOmpTargetData(SgNode *node);
void transOmpBarrier(SgNode *node);
void transOmpFlush(SgNode *node);
void transOmpTaskwait(SgNode *node);
void transOmpThreadprivate(SgNode *node);
void transOmpOrdered(SgNode *node);
void transOmpAtomic(SgNode *node);
void transOmpCritical(SgNode *node);
void transOmpMaster(SgNode *node);
void transOmpSingle(SgNode *node);
void transOmpMetadirective(SgNode *node);
bool isInOmpTargetRegion(SgStatement *node);
void transOmpSimd(SgNode *node);
void transOmpUnroll(SgNode *node);
void transOmpTile(SgNode *node);
void createOmpStatementTree(SgSourceFile *file);
SgStatement *getOmpParent(SgStatement *node);
void setOmpRelationship(SgStatement *parent, SgStatement *child);
Rose_STL_Container<SgNode *>
mergeSgNodeList(Rose_STL_Container<SgNode *> node_list1,
Rose_STL_Container<SgNode *> node_list2);
// It calls the ROSE AST outliner internally.
SgFunctionDeclaration *
generateOutlinedTask(SgNode *node, std::string &wrapper_name,
std::set<const SgVariableSymbol *> &syms,
std::set<const SgVariableSymbol *> &pdSyms3,
bool use_task_param = false);
ROSE_DLL_API void transOmpVariables(SgStatement *ompStmt, SgBasicBlock *bb1,
SgExpression *orig_loop_upper = NULL,
bool withinAcceleratorModel = false);
ROSE_DLL_API SgInitializedNamePtrList
collectAllClauseVariables(SgStatement *clause_stmt);
ROSE_DLL_API SgInitializedNamePtrList
collectClauseVariables(SgStatement *clause_stmt, const VariantT &vt);
ROSE_DLL_API SgInitializedNamePtrList
collectClauseVariables(SgStatement *clause_stmt, const VariantVector &vvt);
ROSE_DLL_API SgExpression *getClauseExpression(SgStatement *clause_stmt,
const VariantVector &vvt);
ROSE_DLL_API bool isInClauseVariableList(SgInitializedName *var,
SgOmpClauseBodyStatement *clause_stmt,
const VariantT &vt);
ROSE_DLL_API bool isInClauseVariableList(SgInitializedName *var,
SgOmpClauseBodyStatement *clause_stmt,
const VariantVector &vvt);
ROSE_DLL_API int replaceVariableReferences(SgNode *root,
SgVariableSymbol *oldVar,
SgVariableSymbol *newVar);
ROSE_DLL_API int replaceVariableReferences(SgNode *root,
VariableSymbolMap_t varRemap);
// I decided to reuse the existing Outliner work instead of coding a new one
// SgFunctionDeclaration* generateOutlinedFunction(SgNode* node);
int replaceVariablesWithPointerDereference(SgNode *root,
std::set<SgVariableSymbol *> &vars);
ROSE_DLL_API void addClauseVariable(SgInitializedName *var,
SgOmpClauseBodyStatement *clause_stmt,
const VariantT &vt);
ROSE_DLL_API SgOmpVariablesClause *
buildOmpVariableClause(SgOmpClauseBodyStatement *clause_stmt,
const VariantT &vt);
ROSE_DLL_API int removeClause(SgStatement *clause_stmt, const VariantT &vt);
ROSE_DLL_API bool hasClause(SgStatement *clause_stmt, const VariantT &vt);
ROSE_DLL_API Rose_STL_Container<SgOmpClause *>
getClause(SgStatement *clause_stmt, const VariantT &vt);
ROSE_DLL_API bool useStaticSchedule(SgOmpClauseBodyStatement *omp_loop);
ROSE_DLL_API SgOmpClause::omp_reduction_identifier_enum
getReductionOperationType(SgInitializedName *init_name,
SgOmpClauseBodyStatement *clause_stmt);
ROSE_DLL_API SgExpression *
createInitialValueExp(SgOmpClause::omp_reduction_identifier_enum r_operator);
ROSE_DLL_API std::string
generateGOMPLoopStartFuncName(bool isOrdered,
SgOmpClause::omp_schedule_kind_enum s_kind);
ROSE_DLL_API std::string
generateGOMPLoopNextFuncName(bool isOrdered,
SgOmpClause::omp_schedule_kind_enum s_kind);
ROSE_DLL_API std::string toString(SgOmpClause::omp_schedule_kind_enum s_kind);
ROSE_DLL_API int patchUpPrivateVariables(SgFile *);
ROSE_DLL_API int patchUpPrivateVariables(SgStatement *omp_loop);
ROSE_DLL_API int patchUpFirstprivateVariables(SgFile *);
std::set<SgInitializedName *> collectThreadprivateVariables();
SgVariableDeclaration *
buildAndInsertDeclarationForOmp(const std::string &name, SgType *type,
SgInitializer *varInit,
SgBasicBlock *orig_scope);
SgBasicBlock *getEnclosingRegionOrFuncDefinition(SgNode *);
ROSE_DLL_API bool isInClauseVariableList(SgOmpClause *cls, SgSymbol *var);
ROSE_DLL_API bool isThreadprivate(SgSymbol *var);
ROSE_DLL_API omp_construct_enum getDataSharingAttribute(SgSymbol *var,
SgNode *anchor_node);
ROSE_DLL_API omp_construct_enum getDataSharingAttribute(SgVarRefExp *varRef);
ROSE_DLL_API bool isSharedAccess(SgVarRefExp *varRef);
void extractMapClauses(
Rose_STL_Container<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);
void categorizeMapClauseVariables(
const SgInitializedNamePtrList
&all_vars, // all variables collected from map clauses
std::map<SgSymbol *, std::vector<std::pair<SgExpression *, SgExpression *>>>
&array_dimensions, // array bounds info as input
std::set<SgSymbol *> &array_syms, // variable symbols which are array types
// (explicit or as a pointer)
std::set<SgSymbol *>
&atom_syms); // variable symbols which are non-aggregate types: scalar,
// pointer, etc
void transOmpCollapse(SgStatement *node);
} // end namespace OmpSupport
#endif // OMP_LOWERING_H