PandA-2024.02
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes
pragma_manager Class Reference

This class is used to manage the pragma directives found in the source code. More...

#include <pragma_manager.hpp>

Collaboration diagram for pragma_manager:
Collaboration graph
[legend]

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...
 

Detailed Description

This class is used to manage the pragma directives found in the source code.

Definition at line 80 of file pragma_manager.hpp.

Member Enumeration Documentation

◆ OmpPragmaType

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.

Constructor & Destructor Documentation

◆ pragma_manager()

pragma_manager::pragma_manager ( const application_managerRef  application_manager,
const ParameterConstRef  param 
)

Constructor.

Parameters
application_manageris the application manager
paramis 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().

Here is the call graph for this function:

◆ ~pragma_manager()

pragma_manager::~pragma_manager ( )
virtualdefault

Destructor.

Referenced by pragma_manager().

Here is the caller graph for this function:

Member Function Documentation

◆ addBlackBoxPragma()

unsigned int pragma_manager::addBlackBoxPragma ( const std::string &  function_name,
unsigned int  function_id 
)

◆ addFunctionCallPragmas()

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.

◆ AddFunctionDefinitionPragmas()

void pragma_manager::AddFunctionDefinitionPragmas ( const std::string &  name,
const CustomUnorderedSet< std::string > &  pragmas 
)

Add a set of definition pragmas to a function.

Parameters
function_nameis the name of the function
isthe set of pragmas to be added

Definition at line 165 of file pragma_manager.cpp.

References function_definition_pragmas, and THROW_ERROR.

◆ AddOmpSimdPragma()

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.

Parameters
lineis the string containing the pragma
Returns
the index of the created pragma node

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.

Here is the call graph for this function:

◆ CheckAddOmpFor()

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.

Parameters
function_indexis the index of the function
bb_vertexis 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.

Here is the call graph for this function:

◆ CheckAddOmpSimd()

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.

Parameters
function_indexis the index of the function
bb_vertexis 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.

Here is the call graph for this function:

◆ checkCompliant()

bool pragma_manager::checkCompliant ( ) const

Check if the data-structure information are compliant with the pragma reference manual.

Returns
true if the data-structure is compliant, false otherwise

Definition at line 130 of file pragma_manager.cpp.

References debug_level, DEBUG_LEVEL_MINIMUM, and PRINT_DBG_MEX.

◆ CheckOmpFor()

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.

Parameters
app_manis the application manager
function_indexis the index of the function
bb_vertexis the basic block to which for operation belongs
Returns
true if there is an associated pragma

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.

Here is the call graph for this function:

◆ ExtractClauses()

CustomUnorderedMapUnstable< std::string, std::string > pragma_manager::ExtractClauses ( const std::string &  clauses_list) const

Extract clauses associated with a pragma.

Parameters
clauses_listis the string containing the clauses
Returns
the extracted 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_mapping()

std::string pragma_manager::get_mapping ( const std::string &  function_name) const

Get mapping of a function given by the pragma.

Parameters
function_nameis the name of the function

◆ getFunctionCallPragmas()

CustomUnorderedSet< std::string > pragma_manager::getFunctionCallPragmas ( const std::string &  Name) const

Definition at line 153 of file pragma_manager.cpp.

References FunctionCallPragmas.

◆ GetFunctionDefinitionPragmas()

const std::list< std::string > pragma_manager::GetFunctionDefinitionPragmas ( const std::string &  function_name) const

Return the pragmas associated with a function definition.

Parameters
function_nameis the name of the function to be considered

Definition at line 144 of file pragma_manager.cpp.

References function_definition_pragmas.

◆ getGenericPragma()

std::string pragma_manager::getGenericPragma ( unsigned int  number) const

Definition at line 303 of file pragma_manager.cpp.

References GenericPragmas, and THROW_ASSERT.

◆ GetOmpPragmaType()

pragma_manager::OmpPragmaType pragma_manager::GetOmpPragmaType ( const std::string &  directive)
static

Returns the identifier corresponding to an openmp directive.

Parameters
directiveis the string to be considered
Returns
the corresponding identifier

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().

Here is the caller graph for this function:

◆ isBlackBox()

bool pragma_manager::isBlackBox ( const std::string &  name) const

Definition at line 139 of file pragma_manager.cpp.

References BlackBoxFunctions.

◆ setGenericPragma()

void pragma_manager::setGenericPragma ( unsigned int  number,
const std::string &  line 
)

Definition at line 298 of file pragma_manager.cpp.

References GenericPragmas, and line().

Here is the call graph for this function:

Field Documentation

◆ application_manager

const application_managerRef pragma_manager::application_manager
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.

◆ BlackBoxFunctions

CustomOrderedSet<std::string> pragma_manager::BlackBoxFunctions
protected

Definition at line 89 of file pragma_manager.hpp.

Referenced by addBlackBoxPragma(), isBlackBox(), and pragma_manager().

◆ debug_level

int pragma_manager::debug_level
protected

The debug level.

Definition at line 102 of file pragma_manager.hpp.

Referenced by CheckAddOmpFor(), CheckAddOmpSimd(), checkCompliant(), CheckOmpFor(), and ExtractClauses().

◆ function_definition_pragmas

std::map<std::string, std::list<std::string> > pragma_manager::function_definition_pragmas
protected

Function defintion pragmas.

Definition at line 94 of file pragma_manager.hpp.

Referenced by AddFunctionDefinitionPragmas(), and GetFunctionDefinitionPragmas().

◆ FunctionCallPragmas

std::map<std::string, CustomUnorderedSet<std::string> > pragma_manager::FunctionCallPragmas
protected

Definition at line 91 of file pragma_manager.hpp.

Referenced by addFunctionCallPragmas(), and getFunctionCallPragmas().

◆ GenericPragmas

std::map<unsigned int, std::string> pragma_manager::GenericPragmas
protected

Definition at line 96 of file pragma_manager.hpp.

Referenced by getGenericPragma(), and setGenericPragma().

◆ omp_directive_keywords

const std::string pragma_manager::omp_directive_keywords
static
Initial value:
= {
"atomic", "barrier", "critical", "declare simd", "for", "parallel for", "parallel sections",
"parallel", "sections", "section", "simd", "target", "task",
}

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().

◆ param

const ParameterConstRef pragma_manager::param
protected

Set of input parameters.

Definition at line 99 of file pragma_manager.hpp.

Referenced by pragma_manager().

◆ TM

const tree_managerRef pragma_manager::TM
protected

Definition at line 87 of file pragma_manager.hpp.

Referenced by addBlackBoxPragma(), and AddOmpSimdPragma().


The documentation for this class was generated from the following files:

Generated on Mon Feb 12 2024 13:04:00 for PandA-2024.02 by doxygen 1.8.13