PandA-2024.02
|
This class is used to manage the pragma directives found in the source code. More...
#include <pragma_manager.hpp>
Public Types | |
enum | OmpPragmaType { OMP_ATOMIC = 0, OMP_BARRIER, OMP_CRITICAL, OMP_DECLARE_SIMD, OMP_FOR, OMP_PARALLEL_FOR, OMP_PARALLEL_SECTIONS, OMP_PARALLEL, OMP_SECTIONS, OMP_SECTION, OMP_SIMD, OMP_TARGET, OMP_TASK, OMP_UNKNOWN } |
The possible openmp pragmas Note that sections has to go before section but after parallel sections otherwise recognition would be wrong. More... | |
Public Member Functions | |
pragma_manager (const application_managerRef application_manager, const ParameterConstRef param) | |
Constructor. More... | |
virtual | ~pragma_manager () |
Destructor. More... | |
bool | checkCompliant () const |
Check if the data-structure information are compliant with the pragma reference manual. More... | |
bool | isBlackBox (const std::string &name) const |
const std::list< std::string > | GetFunctionDefinitionPragmas (const std::string &function_name) const |
Return the pragmas associated with a function definition. More... | |
CustomUnorderedSet< std::string > | getFunctionCallPragmas (const std::string &Name) const |
void | AddFunctionDefinitionPragmas (const std::string &name, const CustomUnorderedSet< std::string > &pragmas) |
Add a set of definition pragmas to a function. More... | |
void | addFunctionCallPragmas (const std::string &Name, const CustomUnorderedSet< std::string > &Pragmas) |
unsigned int | addBlackBoxPragma (const std::string &function_name, unsigned int function_id) |
void | setGenericPragma (unsigned int number, const std::string &line) |
std::string | getGenericPragma (unsigned int number) const |
unsigned int | AddOmpSimdPragma (const std::string &line, unsigned int function_id) const |
Create a simd openmp pragma starting from the line containing it. More... | |
bool | CheckOmpFor (const application_managerConstRef app_man, const unsigned int function_index, const vertex bb_operation_vertex) const |
Check if a omp for pragma is associated with the loop. More... | |
void | CheckAddOmpFor (const unsigned int function_index, const vertex bb_operation_vertex, const application_managerRef AppM) |
Check if a omp for pragma is associated with the loop; if yes, add the gimple_for. More... | |
void | CheckAddOmpSimd (const unsigned int function_index, const vertex bb_operation_vertex, const application_managerRef AppM) |
Check if a omp simd pragma is associated with the loop; if yes, add information to the loop. More... | |
std::string | get_mapping (const std::string &function_name) const |
Get mapping of a function given by the pragma. More... | |
CustomUnorderedMapUnstable< std::string, std::string > | ExtractClauses (const std::string &clauses_list) const |
Extract clauses associated with a pragma. More... | |
Static Public Member Functions | |
static OmpPragmaType | GetOmpPragmaType (const std::string &directive) |
Returns the identifier corresponding to an openmp directive. More... | |
Static Public Attributes | |
static const std::string | omp_directive_keywords [OMP_UNKNOWN] |
The list of omp directive keywords. More... | |
Protected Attributes | |
const application_managerRef | application_manager |
The application manager NOTE: this is equivalente to a weakrefcount since deleter should be null. More... | |
const tree_managerRef | TM |
CustomOrderedSet< std::string > | BlackBoxFunctions |
std::map< std::string, CustomUnorderedSet< std::string > > | FunctionCallPragmas |
std::map< std::string, std::list< std::string > > | function_definition_pragmas |
Function defintion pragmas. More... | |
std::map< unsigned int, std::string > | GenericPragmas |
const ParameterConstRef | param |
Set of input parameters. More... | |
int | debug_level |
The debug level. More... | |
This class is used to manage the pragma directives found in the source code.
Definition at line 80 of file pragma_manager.hpp.
The possible openmp pragmas Note that sections has to go before section but after parallel sections otherwise recognition would be wrong.
Enumerator | |
---|---|
OMP_ATOMIC | |
OMP_BARRIER | |
OMP_CRITICAL | |
OMP_DECLARE_SIMD | |
OMP_FOR | |
OMP_PARALLEL_FOR | |
OMP_PARALLEL_SECTIONS | |
OMP_PARALLEL | |
OMP_SECTIONS | |
OMP_SECTION | |
OMP_SIMD | |
OMP_TARGET | |
OMP_TASK | |
OMP_UNKNOWN |
Definition at line 109 of file pragma_manager.hpp.
pragma_manager::pragma_manager | ( | const application_managerRef | application_manager, |
const ParameterConstRef | param | ||
) |
Constructor.
application_manager | is the application manager |
param | is the set of the input parameters |
Definition at line 109 of file pragma_manager.cpp.
References BlackBoxFunctions, OUTPUT_LEVEL_VERBOSE, param, PRINT_OUT_MEX, and ~pragma_manager().
|
virtualdefault |
unsigned int pragma_manager::addBlackBoxPragma | ( | const std::string & | function_name, |
unsigned int | function_id | ||
) |
Definition at line 190 of file pragma_manager.cpp.
References BlackBoxFunctions, STR, TM, TOK, TOK_IS_BLOCK, TOK_OPEN, TOK_PRAGMA_DIRECTIVE, TOK_PRAGMA_SCOPE, TOK_SCPE, and TOK_SRCP.
void pragma_manager::addFunctionCallPragmas | ( | const std::string & | Name, |
const CustomUnorderedSet< std::string > & | Pragmas | ||
) |
Definition at line 181 of file pragma_manager.cpp.
References FunctionCallPragmas, and k.
void pragma_manager::AddFunctionDefinitionPragmas | ( | const std::string & | name, |
const CustomUnorderedSet< std::string > & | pragmas | ||
) |
Add a set of definition pragmas to a function.
function_name | is the name of the function |
is | the set of pragmas to be added |
Definition at line 165 of file pragma_manager.cpp.
References function_definition_pragmas, and THROW_ERROR.
unsigned int pragma_manager::AddOmpSimdPragma | ( | const std::string & | line, |
unsigned int | function_id | ||
) | const |
Create a simd openmp pragma starting from the line containing it.
line | is the string containing the pragma |
Definition at line 214 of file pragma_manager.cpp.
References ExtractClauses(), STR, TM, TOK, TOK_BB_INDEX, TOK_IS_BLOCK, TOK_OPEN, TOK_PRAGMA_DIRECTIVE, TOK_PRAGMA_SCOPE, TOK_SCPE, and TOK_SRCP.
void pragma_manager::CheckAddOmpFor | ( | const unsigned int | function_index, |
const vertex | bb_operation_vertex, | ||
const application_managerRef | AppM | ||
) |
Check if a omp for pragma is associated with the loop; if yes, add the gimple_for.
function_index | is the index of the function |
bb_vertex | is the basic block to which for operation belongs |
Definition at line 343 of file pragma_manager.cpp.
References FunctionBehavior::BB, FunctionBehavior::CGetBBGraph(), application_manager::CGetFunctionBehavior(), debug_level, DEBUG_LEVEL_VERY_PEDANTIC, DOALL_LOOP, GET_NODE, application_manager::GetFunctionBehavior(), INDENT_DBG_MEX, and STR.
void pragma_manager::CheckAddOmpSimd | ( | const unsigned int | function_index, |
const vertex | bb_operation_vertex, | ||
const application_managerRef | AppM | ||
) |
Check if a omp simd pragma is associated with the loop; if yes, add information to the loop.
function_index | is the index of the function |
bb_vertex | is the basic block to which for operation belongs |
Definition at line 384 of file pragma_manager.cpp.
References FunctionBehavior::BB, debug_level, DEBUG_LEVEL_VERY_PEDANTIC, DOALL_LOOP, GET_INDEX_NODE, GET_NODE, application_manager::GetFunctionBehavior(), INDENT_DBG_MEX, and STR.
bool pragma_manager::checkCompliant | ( | ) | const |
Check if the data-structure information are compliant with the pragma reference manual.
Definition at line 130 of file pragma_manager.cpp.
References debug_level, DEBUG_LEVEL_MINIMUM, and PRINT_DBG_MEX.
bool pragma_manager::CheckOmpFor | ( | const application_managerConstRef | app_man, |
const unsigned int | function_index, | ||
const vertex | bb_operation_vertex | ||
) | const |
Check if a omp for pragma is associated with the loop.
app_man | is the application manager |
function_index | is the index of the function |
bb_vertex | is the basic block to which for operation belongs |
Definition at line 309 of file pragma_manager.cpp.
References FunctionBehavior::BB, BBGraph::CGetBBNodeInfo(), debug_level, DEBUG_LEVEL_VERY_PEDANTIC, GET_NODE, and INDENT_DBG_MEX.
CustomUnorderedMapUnstable< std::string, std::string > pragma_manager::ExtractClauses | ( | const std::string & | clauses_list | ) | const |
Extract clauses associated with a pragma.
clauses_list | is the string containing the clauses |
Trim blanks inside parentheses
Definition at line 242 of file pragma_manager.cpp.
References debug_level, DEBUG_LEVEL_VERY_PEDANTIC, INDENT_DBG_MEX, index, key, SplitString(), and symmetry::value.
Referenced by AddOmpSimdPragma().
std::string pragma_manager::get_mapping | ( | const std::string & | function_name | ) | const |
Get mapping of a function given by the pragma.
function_name | is the name of the function |
CustomUnorderedSet< std::string > pragma_manager::getFunctionCallPragmas | ( | const std::string & | Name | ) | const |
Definition at line 153 of file pragma_manager.cpp.
References FunctionCallPragmas.
const std::list< std::string > pragma_manager::GetFunctionDefinitionPragmas | ( | const std::string & | function_name | ) | const |
Return the pragmas associated with a function definition.
function_name | is the name of the function to be considered |
Definition at line 144 of file pragma_manager.cpp.
References function_definition_pragmas.
std::string pragma_manager::getGenericPragma | ( | unsigned int | number | ) | const |
Definition at line 303 of file pragma_manager.cpp.
References GenericPragmas, and THROW_ASSERT.
|
static |
Returns the identifier corresponding to an openmp directive.
directive | is the string to be considered |
Definition at line 459 of file pragma_manager.cpp.
References index, omp_directive_keywords, and OMP_UNKNOWN.
Referenced by PragmaAnalysis::create_omp_pragma(), and PragmaParser::recognize_omp_pragma().
bool pragma_manager::isBlackBox | ( | const std::string & | name | ) | const |
Definition at line 139 of file pragma_manager.cpp.
References BlackBoxFunctions.
void pragma_manager::setGenericPragma | ( | unsigned int | number, |
const std::string & | line | ||
) |
Definition at line 298 of file pragma_manager.cpp.
References GenericPragmas, and line().
|
protected |
The application manager NOTE: this is equivalente to a weakrefcount since deleter should be null.
Definition at line 85 of file pragma_manager.hpp.
|
protected |
Definition at line 89 of file pragma_manager.hpp.
Referenced by addBlackBoxPragma(), isBlackBox(), and pragma_manager().
|
protected |
The debug level.
Definition at line 102 of file pragma_manager.hpp.
Referenced by CheckAddOmpFor(), CheckAddOmpSimd(), checkCompliant(), CheckOmpFor(), and ExtractClauses().
|
protected |
Function defintion pragmas.
Definition at line 94 of file pragma_manager.hpp.
Referenced by AddFunctionDefinitionPragmas(), and GetFunctionDefinitionPragmas().
|
protected |
Definition at line 91 of file pragma_manager.hpp.
Referenced by addFunctionCallPragmas(), and getFunctionCallPragmas().
|
protected |
Definition at line 96 of file pragma_manager.hpp.
Referenced by getGenericPragma(), and setGenericPragma().
|
static |
The list of omp directive keywords.
Autoheader include.
Header include Behavior include Constants include Graph include Parameter include parser/pragma include parser/compiler include STD include STL includes Tree include Utility include
Definition at line 128 of file pragma_manager.hpp.
Referenced by PragmaAnalysis::create_omp_pragma(), GetOmpPragmaType(), and PragmaParser::recognize_omp_pragma().
|
protected |
Set of input parameters.
Definition at line 99 of file pragma_manager.hpp.
Referenced by pragma_manager().
|
protected |
Definition at line 87 of file pragma_manager.hpp.
Referenced by addBlackBoxPragma(), and AddOmpSimdPragma().