gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
Gambit::module_functor< TYPE > Class Template Reference

Actual module functor type for all but TYPE=void. More...

#include <functors.hpp>

Inheritance diagram for Gambit::module_functor< TYPE >:
Collaboration diagram for Gambit::module_functor< TYPE >:

Public Member Functions

 module_functor (void(*)(TYPE &), str, str, str, str, Models::ModelFunctorClaw &)
 Constructor. More...
 
virtual ~module_functor ()
 Destructor. More...
 
virtual void setPrintRequirement (bool flag)
 Setter for indicating if the wrapped function's result should to be printed. More...
 
virtual bool requiresPrinting () const
 Getter indicating if the wrapped function's result should to be printed. More...
 
void calculate ()
 Calculate method. More...
 
const TYPE & operator() (int index)
 Operation (return value) More...
 
safe_ptr< TYPE > valuePtr ()
 Alternative to operation (returns a safe pointer to value) More...
 
virtual void print (Printers::BasePrinter *printer, const int pointID, int index)
 Printer function. More...
 
virtual void print (Printers::BasePrinter *printer, const int pointID)
 Printer function (no-thread-index short-circuit) More...
 
- Public Member Functions inherited from Gambit::module_functor_common
 module_functor_common (str, str, str, str, Models::ModelFunctorClaw &)
 Constructor. More...
 
virtual ~module_functor_common ()
 Destructor. More...
 
double getRuntimeAverage ()
 Getter for averaged runtime. More...
 
void reset ()
 Reset functor. More...
 
void notifyOfInvalidation (const str &)
 Tell the functor that it invalidated the current point in model space, pass a message explaining why, and throw an exception. More...
 
double getInvalidationRate ()
 Getter for invalidation rate. More...
 
void setFadeRate (double)
 Setter for the fade rate. More...
 
void setTimingPrintRequirement (bool)
 Setter for indicating if the timing data for this function's execution should be printed. More...
 
bool requiresTimingPrinting () const
 Getter indicating if the timing data for this function's execution should be printed. More...
 
bool getActiveModelFlag (str)
 Indicate whether or not a known model is activated or not. More...
 
safe_ptr< strgetChosenReqFromGroup (str)
 Return a safe pointer to a string indicating which backend requirement has been activated for a given backend group. More...
 
virtual void iterate (long long iteration)
 Execute a single iteration in the loop managed by this functor. More...
 
virtual void init_myCurrentIteration_if_NULL ()
 Initialise the array holding the current iteration(s) of this functor. More...
 
virtual void setIteration (long long iteration)
 Setter for setting the iteration number in the loop in which this functor runs. More...
 
virtual omp_safe_ptr< long long > iterationPtr ()
 Return a safe pointer to the iteration number in the loop in which this functor runs. More...
 
virtual void setCanBeLoopManager (bool canManage)
 Setter for specifying whether this is permitted to be a manager functor, which runs other functors nested in a loop. More...
 
virtual bool canBeLoopManager ()
 Getter for revealing whether this is permitted to be a manager functor. More...
 
virtual void setLoopManagerCapType (str cap, str t)
 Setter for specifying the capability required of a manager functor, if it is to run this functor nested in a loop. More...
 
virtual str loopManagerCapability ()
 Getter for revealing the required capability of the wrapped function's loop manager. More...
 
virtual str loopManagerType ()
 Getter for revealing the required type of the wrapped function's loop manager. More...
 
virtual str loopManagerName ()
 Getter for revealing the name of the wrapped function's assigned loop manager. More...
 
virtual str loopManagerOrigin ()
 Getter for revealing the module of the wrapped function's assigned loop manager. More...
 
virtual void breakLoopFromManagedFunctor ()
 Tell the manager of the loop in which this functor runs that it is time to break the loop. More...
 
virtual safe_ptr< bool > loopIsDone ()
 Return a safe pointer to the flag indicating that a loop managed by this functor should break now. More...
 
virtual void resetLoop ()
 Provide a way to reset the flag indicating that a loop managed by this functor should break. More...
 
virtual void breakLoop ()
 Tell the functor that the loop it manages should break now. More...
 
virtual std::set< sspairdependencies ()
 Getter for listing currently activated dependencies. More...
 
virtual std::set< strbackendgroups ()
 Getter for listing backend requirement groups. More...
 
virtual std::set< sspairbackendreqs ()
 Getter for listing all backend requirements. More...
 
virtual std::set< sspairbackendreqs (str)
 Getter for listing backend requirements from a specific group. More...
 
virtual std::set< sspairbackendspermitted (sspair quant)
 Getter for listing permitted backends. More...
 
virtual std::set< strbackendreq_tags (sspair)
 Getter for listing tags associated with backend requirements. More...
 
virtual std::set< sspairforcematchingbackend (str)
 Getter for listing backend requirements that must be resolved from the same backend. More...
 
virtual std::set< sspairbackend_conditional_dependencies (str req, str type, str be, str ver)
 Getter for listing backend-specific conditional dependencies (4-string version) More...
 
virtual std::set< sspairbackend_conditional_dependencies (str req, str type, str be)
 Getter for backend-specific conditional dependencies (3-string version) More...
 
virtual std::set< sspairbackend_conditional_dependencies (functor *be_functor)
 Getter for backend-specific conditional dependencies (backend functor pointer version) More...
 
virtual std::set< sspairmodel_conditional_dependencies (str model)
 Getter for listing model-specific conditional dependencies. More...
 
virtual std::set< sspairmodel_conditional_backend_reqs (str model)
 Getter for listing model-specific conditional backend requirements. More...
 
void setDependency (str, str, void(*)(functor *, module_functor_common *), str purpose="")
 Add and activate unconditional dependencies. More...
 
void setConditionalDependency (str, str)
 Add conditional dependency-type pairs in advance of later conditions. More...
 
void setBackendConditionalDependency (str, str, str, str, void(*)(functor *, module_functor_common *))
 Add a backend conditional dependency for multiple backend versions. More...
 
void setBackendConditionalDependencySingular (str, str, str, str, void(*)(functor *, module_functor_common *))
 Add a backend conditional dependency for a single backend version. More...
 
void setModelConditionalDependency (str, str, void(*)(functor *, module_functor_common *))
 Add a model conditional dependency for multiple models. More...
 
void setModelConditionalDependencySingular (str, str, void(*)(functor *, module_functor_common *))
 Add a model conditional dependency for a single model. More...
 
void makeBackendRuleForModel (str, str)
 Add a rule for activating backend requirements according to the model being scanned. More...
 
void setBackendReq (str, str, str, str, void(*)(functor *))
 Add an unconditional backend requirement The info gets updated later if this turns out to be contitional on a model. More...
 
void setModelConditionalBackendReq (str model, str req, str type)
 Add a model conditional backend requirement for multiple models. More...
 
void setModelConditionalBackendReqSingular (str model, str req, str type)
 Add a model conditional backend requirement for a single model. More...
 
void makeBackendOptionRule (str, str)
 Add a rule for dictating which backends can be used to fulfill which backend requirements. More...
 
void setPermittedBackend (str req, str be, str ver)
 Add a single permitted backend version. More...
 
void makeBackendMatchingRule (str tag)
 Add one or more rules for forcing backends reqs with the same tags to always be resolved from the same backend. More...
 
void setRequiredClassloader (str, str, str)
 Add a rule indicating that classes from a given backend must be available. More...
 
void notifyOfBackends (std::map< str, std::set< str > >)
 Indicate to the functor which backends are actually loaded and working. More...
 
virtual void setNestedList (std::vector< functor *> &newNestedList)
 Set the ordered list of pointers to other functors that should run nested in a loop managed by this one. More...
 
virtual void resolveDependency (functor *dep_functor)
 Resolve a dependency using a pointer to another functor object. More...
 
virtual void resolveLoopManager (functor *)
 Set this functor's loop manager (if it has one) More...
 
virtual void resolveBackendReq (functor *be_functor)
 Resolve a backend requirement using a pointer to another functor object. More...
 
virtual void notifyOfModel (str model)
 Notify the functor that a certain model is being scanned, so that it can activate its dependencies and backend reqs accordingly. More...
 
virtual void notifyOfDependee (functor *)
 Notify the functor that another functor depends on it. More...
 
virtual invalid_point_exceptionretrieve_invalid_point_exception ()
 Retrieve the previously saved exception generated when this functor invalidated the current point in model space. More...
 
- Public Member Functions inherited from Gambit::functor
 functor (str, str, str, str, Models::ModelFunctorClaw &)
 Constructor. More...
 
virtual ~functor ()
 
virtual void reset_and_calculate ()
 Reset-then-recalculate method. More...
 
void setStatus (int)
 Setter for status: -6 = required external tool absent (pybind11) -5 = required external tool absent (Mathematica) -4 = required backend absent (backend ini functions) -3 = required classes absent -2 = function absent -1 = origin absent 0 = model incompatibility (default) 1 = available 2 = active. More...
 
virtual void setInUse (bool)
 Set the inUse flag (must be overridden in derived class to have any effect). More...
 
void setPurpose (str)
 Setter for purpose (relevant only for next-to-output functors) More...
 
void setVertexID (int)
 Setter for vertex ID (used in printer system) More...
 
void setTimingVertexID (int)
 Set ID for timing 'vertex' (used in printer system) More...
 
str name () const
 Getter for the wrapped function's name. More...
 
str capability () const
 Getter for the wrapped function's reported capability. More...
 
str type () const
 Getter for the wrapped function's reported return type. More...
 
str origin () const
 Getter for the wrapped function's origin (module or backend name) More...
 
str version () const
 Getter for the version of the wrapped function's origin (module or backend) More...
 
virtual str safe_version () const
 Getter for the 'safe' incarnation of the version of the wrapped function's origin (module or backend) More...
 
int status () const
 Getter for the wrapped function current status: -4 = required backend absent (backend ini functions) -3 = required classes absent -2 = function absent -1 = origin absent 0 = model incompatibility (default) 1 = available 2 = active. More...
 
sspair quantity () const
 Getter for the overall quantity provided by the wrapped function (capability-type pair) More...
 
str purpose () const
 Getter for purpose (relevant for output nodes, aka helper structures for the dep. resolution) More...
 
int vertexID () const
 Getter for vertex ID. More...
 
int timingVertexID () const
 Getter for timing vertex ID. More...
 
str label () const
 Getter for string label. More...
 
str timingLabel () const
 Getter for the printer timing label. More...
 
void notifyOfIniOptions (const Options &)
 Notify the functor about an instance of the options class that contains information from its corresponding ini-file entry in the auxiliaries or observables section. More...
 
template<typename TYPE >
void setOption (const str &key, const TYPE val)
 Set an option for the functor directly (for use in standalone executables). More...
 
safe_ptr< OptionsgetOptions ()
 Return a safe pointer to the options that this functor is supposed to run with (e.g. from the ini file). More...
 
void notifyOfSubCaps (const Options &)
 Notify the functor about an instance of the options class that contains sub-capability information. More...
 
template<typename TYPE >
void setSubCap (const str &key, const TYPE val)
 Set a sub-capability (subcap)for the functor directly (for use in standalone executables). More...
 
safe_ptr< OptionsgetSubCaps ()
 Return a safe pointer to the subcaps that this functor realises it is supposed to facilitate downstream calculation of. More...
 
safe_ptr< std::set< sspair > > getDependees ()
 Return a safe pointer to the vector of all capability,type pairs of functors arranged downstream of this one in the dependency tree. More...
 
bool allModelsAllowed ()
 Test whether the functor is allowed to be used with all models. More...
 
bool modelAllowed (str model)
 Test whether the functor is always allowed (either explicitly or implicitly) to be used with a given model. More...
 
bool modelExplicitlyAllowed (str model)
 Test whether the functor is explictly always allowed to be used with a given model. More...
 
void setAllowedModel (str model)
 Add a model to the internal list of models for which this functor is allowed to be used. More...
 
bool modelComboAllowed (std::set< str > combo)
 Test whether the functor is allowed (either explicitly or implicitly) to be used with a given combination of models. More...
 
bool modelComboExplicitlyAllowed (std::set< str > combo)
 Test whether the functor has been explictly allowed to be used with a given combination of models. More...
 
void setModelGroup (str group, str contents)
 Add a model group definition to the internal list of model groups. More...
 
void setAllowedModelGroupCombo (str groups)
 Add a combination of model groups to the internal list of combinations for which this functor is allowed to be used. More...
 

Protected Member Functions

virtual void init_memory ()
 Initialise the memory of this functor. More...
 
- Protected Member Functions inherited from Gambit::module_functor_common
void reset (int)
 Reset functor for one thread only. More...
 
virtual void acknowledgeInvalidation (invalid_point_exception &, functor *f=NULL)
 Acknowledge that this functor invalidated the current point in model space. More...
 
virtual void startTiming (int)
 Do pre-calculate timing things. More...
 
virtual void finishTiming (int)
 Do post-calculate timing things. More...
 
void fill_activeModelFlags ()
 Construct the list of known models only if it doesn't yet exist. More...
 
sspair retrieve_conditional_dep_type_pair (str)
 Retrieve full conditional dependency-type pair from conditional dependency only. More...
 
void check_missing_LogTag ()
 Check if an appropriate LogTag for this functor is missing from the logging system. More...
 
void entering_multithreaded_region ()
 
void leaving_multithreaded_region ()
 
- Protected Member Functions inherited from Gambit::functor
bool allowed_parent_or_friend_exists (str model)
 Test if there is a model in the functor's allowedModels list as which this model can be interpreted. More...
 
bool in_allowed_combo (str model)
 Check that a model is actually part of a combination that is allowed to be used with this functor. More...
 
bool contains_anything_interpretable_as_member_of (std::set< str > combo, str group)
 Test whether any of the entries in a given model group is a valid interpretation of any members in a given combination. More...
 
bool has_common_elements (std::set< str > combo, str group)
 Work out whether a given combination of models and a model group have any elements in common. More...
 
str find_friend_or_parent_model_in_map (str model, std::map< str, std::set< sspair > > karta)
 Try to find a parent or friend model in some user-supplied map from models to sspair vectors. More...
 

Protected Attributes

void(* myFunction )(TYPE &)
 Internal storage of function pointer. More...
 
TYPE * myValue
 Internal pointer to storage location of function value. More...
 
bool myPrintFlag
 Flag to select whether or not the results of this functor should be sent to the printer object. More...
 
- Protected Attributes inherited from Gambit::module_functor_common
bool myTimingPrintFlag
 Flag to select whether or not the timing data for this function's execution should be printed;. More...
 
std::chrono::time_point< std::chrono::system_clock > * start
 Beginning and end timing points. More...
 
std::chrono::time_point< std::chrono::system_clock > * end
 
bool point_exception_raised
 A flag indicating whether or not this functor has invalidated the current point. More...
 
invalid_point_exception raised_point_exception
 An exception raised because this functor has invalidated the current point. More...
 
double runtime_average
 Averaged runtime in ns. More...
 
double fadeRate
 Fade rate for average runtime. More...
 
double pInvalidation
 Probability that functors invalidates point in model parameter space. More...
 
bool * needs_recalculating
 Needs recalculating or not? More...
 
bool * already_printed
 Has result already been sent to the printer? More...
 
bool * already_printed_timing
 Has timing data already been sent to the printer? More...
 
bool iCanManageLoops
 Flag indicating whether this function can manage a loop over other functions. More...
 
bool myLoopIsDone
 Flag indicating whether this function is ready to finish its loop (only relevant if iCanManageLoops = true) More...
 
bool iRunNested
 Flag indicating whether this function can run nested in a loop over functions. More...
 
str myLoopManagerCapability
 Capability of a function that mangages a loop that this function can run inside of. More...
 
str myLoopManagerType
 Capability of a function that mangages a loop that this function can run inside of. More...
 
functormyLoopManager
 Pointer to the functor that mangages the loop that this function runs inside of. More...
 
std::vector< functor * > myNestedFunctorList
 Vector of functors that have been set up to run nested within this one. More...
 
long long * myCurrentIteration
 Pointer to counters for iterations of nested functor loop. More...
 
const int globlMaxThreads
 Maximum number of OpenMP threads this MPI process is permitted to launch in total. More...
 
std::set< strmyGroups
 Internal list of backend groups that this functor's requirements fall into. More...
 
std::map< str, strchosenReqsFromGroups
 Map from groups to backend reqs, indicating which backend req has been activated for which backend group. More...
 
std::set< sspairmyBackendReqs
 Set of all backend requirement-type string pairs. More...
 
std::set< sspairmyResolvableBackendReqs
 Set of all backend requirement-type string pairs currently available for resolution. More...
 
std::map< str, std::set< sspair > > myGroupedBackendReqs
 Set of backend requirement-type string pairs for specific backend groups. More...
 
std::set< sspairmyDependencies
 Vector of dependency-type string pairs. More...
 
std::map< str, strmyConditionalDependencies
 Map of conditional dependencies to their types. More...
 
std::map< std::vector< str >, std::set< sspair > > myBackendConditionalDependencies
 Map from (vector with 4 strings: backend req, type, backend, version) to (set of {conditional dependency-type} pairs) More...
 
std::map< str, std::set< sspair > > myModelConditionalDependencies
 Map from models to (set of {conditional dependency-type} pairs) More...
 
std::map< str, std::set< sspair > > myModelConditionalBackendReqs
 Map from models to (set of {conditional backend requirement-type} pairs) More...
 
std::map< str, bool > activeModelFlags
 Map from known models to flags indicating if they are activated or not (known = allowed, in allowed groups or conditions for conditional dependencies) More...
 
std::map< sspair, void(*)(functor *, module_functor_common *)> dependency_map
 Map from (dependency-type pairs) to (pointers to templated void functions that set dependency functor pointers) More...
 
std::map< sspair, functor * > dependency_functor_map
 Map from (dependency-type pairs) to pointers to functors used to resolve them that set dependency functor pointers) More...
 
std::map< str, strbackendreq_types
 Map from backend requirements to their required types. More...
 
std::map< sspair, strbackendreq_groups
 Map from backend requirements to their designated groups. More...
 
std::map< sspair, std::set< str > > backendreq_tagmap
 Map from backend requirements to their rule tags. More...
 
std::map< sspair, void(*)(functor *)> backendreq_map
 Map from (backend requirement-type pairs) to (pointers to templated void functions that set backend requirement functor pointers) More...
 
std::map< sspair, std::set< sspair > > permitted_map
 Map from (backend requirement-type pairs) to (set of permitted {backend-version} pairs) More...
 
std::map< str, std::set< sspair > > myForcedMatches
 Map from tags to sets of matching (backend requirement-type pairs) that are forced to use the same backend. More...
 
std::map< str, std::set< str > > required_classloading_backends
 Map from required classloading backends to their versions. More...
 
std::vector< strmissing_backends
 Vector of required backends currently missing. More...
 
timespec tp
 Internal timespec object. More...
 
int myLogTag
 Integer LogTag, for tagging log messages. More...
 
bool signal_mode_locked = true
 While locked, prevent this function switching off threadsafe* emergency signal handling. More...
 
- Protected Attributes inherited from Gambit::functor
str myName
 Internal storage of the function name. More...
 
str myCapability
 Internal storage of exactly what the function calculates. More...
 
str myType
 Internal storage of the type of what the function calculates. More...
 
str myOrigin
 Internal storage of the name of the module or backend to which the function belongs. More...
 
str myVersion
 Internal storage of the version of the module or backend to which the function belongs. More...
 
str myPurpose
 Purpose of the function (relevant for output and next-to-output functors) More...
 
const Models::ModelFunctorClawmyClaw
 Bound model functor claw, for checking relationships between models. More...
 
const str myLabel
 String label, used to label functor results for printer system. More...
 
const str myTimingLabel
 String label, used to label functor timing data for printer system. More...
 
int myStatus
 Status: -4 = required backend absent (backend ini functions) -3 = required classes absent -2 = function absent -1 = origin absent 0 = model incompatibility (default) 1 = available 2 = active. More...
 
int myVertexID
 Internal storage of the vertex ID number used by the printer system to identify functors. More...
 
int myTimingVertexID
 ID assigned by printers to the timing data output stream. More...
 
bool verbose
 Debug flag. More...
 
Options myOptions
 Internal storage of function options, as a YAML node. More...
 
Options mySubCaps
 Internal storage of function sub-capabilities, as a YAML node. More...
 
std::set< sspairmyDependees
 List of all capability,type pairs of functors downstream of this one in the dependency tree. More...
 
std::set< strallowedModels
 List of allowed models. More...
 
std::set< std::set< str > > allowedGroupCombos
 List of allowed model group combinations. More...
 
std::map< str, std::set< str > > modelGroups
 Map from model group names to group contents. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from Gambit::functor
static void failBigTime (str method)
 Attempt to retrieve a dependency or model parameter that has not been resolved. More...
 

Detailed Description

template<typename TYPE>
class Gambit::module_functor< TYPE >

Actual module functor type for all but TYPE=void.

Definition at line 745 of file functors.hpp.

Constructor & Destructor Documentation

◆ module_functor()

template<typename TYPE>
Gambit::module_functor< TYPE >::module_functor ( void(*)(TYPE &)  inputFunction,
str  func_name,
str  func_capability,
str  result_type,
str  origin_name,
Models::ModelFunctorClaw claw 
)

Constructor.

Class methods for actual module functors for TYPE != void.

Definition at line 59 of file functor_definitions.hpp.

65  : module_functor_common(func_name, func_capability, result_type, origin_name, claw),
66  myFunction (inputFunction),
67  myValue (NULL),
68  myPrintFlag (false)
69  {}
module_functor_common(str, str, str, str, Models::ModelFunctorClaw &)
Constructor.
Definition: functors.cpp:637
bool myPrintFlag
Flag to select whether or not the results of this functor should be sent to the printer object...
Definition: functors.hpp:789
void(* myFunction)(TYPE &)
Internal storage of function pointer.
Definition: functors.hpp:783
TYPE * myValue
Internal pointer to storage location of function value.
Definition: functors.hpp:786

◆ ~module_functor()

template<typename TYPE >
Gambit::module_functor< TYPE >::~module_functor ( )
virtual

Destructor.

Definition at line 73 of file functor_definitions.hpp.

74  {
75  if (myValue != NULL) delete [] myValue;
76  }
TYPE * myValue
Internal pointer to storage location of function value.
Definition: functors.hpp:786

Member Function Documentation

◆ calculate()

template<typename TYPE >
void Gambit::module_functor< TYPE >::calculate ( )
virtual

Calculate method.

Calculate method (no loop-manager stuff here because only void specialisation can manage loops)

Reimplemented from Gambit::functor.

Definition at line 89 of file functor_definitions.hpp.

90  {
91  if (myStatus == -3) // Do an explicit status check to hold standalone writers' hands
92  {
93  std::ostringstream ss;
94  ss << "Sorry, the function " << origin() << "::" << name()
95  << " cannot be used" << endl << "because it requires classes from a backend that you do not have installed."
96  << endl << "Missing backends: ";
97  for (auto it = missing_backends.begin(); it != missing_backends.end(); ++it) ss << endl << " " << *it;
98  backend_error().raise(LOCAL_INFO, ss.str());
99  }
100  boost::io::ios_flags_saver ifs(cout); // Don't allow module functions to change the output precision of cout
101  int thread_num = omp_get_thread_num();
102  init_memory(); // Init memory if this is the first run through.
103  if (needs_recalculating[thread_num]) // Do the actual calculation if required.
104  {
106  this->startTiming(thread_num); //Begin timing function evaluation
107  try
108  {
109  this->myFunction(myValue[thread_num]); //Run and place result in the appropriate slot in myValue
110  }
111  catch (invalid_point_exception& e)
112  {
114  if (omp_get_level()==0) // If not in an OpenMP parallel block, throw onwards
115  {
116  this->finishTiming(thread_num); //Stop timing function evaluation
117  throw(e);
118  }
119  }
120  this->finishTiming(thread_num); //Stop timing function evaluation
122  }
123  }
virtual void startTiming(int)
Do pre-calculate timing things.
Definition: functors.cpp:1671
bool point_exception_raised
A flag indicating whether or not this functor has invalidated the current point.
Definition: functors.hpp:600
virtual void acknowledgeInvalidation(invalid_point_exception &, functor *f=NULL)
Acknowledge that this functor invalidated the current point in model space.
Definition: functors.cpp:741
#define LOCAL_INFO
Definition: local_info.hpp:34
void entering_module(int)
Set the internal variables tracking which module and/or backend is currently running.
Definition: logmaster.cpp:620
virtual void init_memory()
Initialise the memory of this functor.
str origin() const
Getter for the wrapped function&#39;s origin (module or backend name)
Definition: functors.cpp:121
bool * needs_recalculating
Needs recalculating or not?
Definition: functors.hpp:615
virtual void finishTiming(int)
Do post-calculate timing things.
Definition: functors.cpp:1677
str name() const
Getter for the wrapped function&#39;s name.
Definition: functors.cpp:115
error & backend_error()
Backend errors.
EXPORT_SYMBOLS Logging::LogMaster & logger()
Function to retrieve a reference to the Gambit global log object.
Definition: logger.cpp:95
std::vector< str > missing_backends
Vector of required backends currently missing.
Definition: functors.hpp:712
void(* myFunction)(TYPE &)
Internal storage of function pointer.
Definition: functors.hpp:783
int myStatus
Status: -4 = required backend absent (backend ini functions) -3 = required classes absent -2 = functi...
Definition: functors.hpp:346
int myLogTag
Integer LogTag, for tagging log messages.
Definition: functors.hpp:718
TYPE * myValue
Internal pointer to storage location of function value.
Definition: functors.hpp:786

◆ init_memory()

template<typename TYPE >
void Gambit::module_functor< TYPE >::init_memory ( )
protectedvirtual

Initialise the memory of this functor.

Reimplemented from Gambit::module_functor_common.

Definition at line 127 of file functor_definitions.hpp.

Referenced by Gambit::module_functor< void >::calculate().

128  {
130  if(myValue==NULL)
131  {
132  #pragma omp critical(module_functor_init_memory)
133  {
134  // Reserve enough space to hold as many results as there are slots (threads) allowed
135  if(myValue==NULL) myValue = new TYPE[(iRunNested ? globlMaxThreads : 1)];
136  }
137  }
138  }
virtual void init_memory()
Initialise the memory of this functor.
Definition: functors.cpp:1617
bool iRunNested
Flag indicating whether this function can run nested in a loop over functions.
Definition: functors.hpp:630
const int globlMaxThreads
Maximum number of OpenMP threads this MPI process is permitted to launch in total.
Definition: functors.hpp:646
TYPE * myValue
Internal pointer to storage location of function value.
Definition: functors.hpp:786
Here is the caller graph for this function:

◆ operator()()

template<typename TYPE >
const TYPE & Gambit::module_functor< TYPE >::operator() ( int  index)

Operation (return value)

Definition at line 142 of file functor_definitions.hpp.

143  {
144  init_memory(); // Init memory if this is the first run through.
145  return (iRunNested ? myValue[index] : myValue[0]);
146  }
virtual void init_memory()
Initialise the memory of this functor.
bool iRunNested
Flag indicating whether this function can run nested in a loop over functions.
Definition: functors.hpp:630
TYPE * myValue
Internal pointer to storage location of function value.
Definition: functors.hpp:786

◆ print() [1/2]

template<typename TYPE >
void Gambit::module_functor< TYPE >::print ( Printers::BasePrinter *  printer,
const int  pointID,
int  index 
)
virtual

Printer function.

Reimplemented from Gambit::functor.

Definition at line 159 of file functor_definitions.hpp.

160  {
161  // Only try to print if print flag set to true, and if this functor(+thread) hasn't already been printed
162  // TODO: though actually the printer system will probably cark it if printing from multiple threads is
163  // attempted, because it uses the VertexID to differentiate print streams, and this is shared among threads.
164  // Can fix by requiring a VertexID+thread_num pair, but I am leaving this for later.
165  init_memory(); // Init memory if this is the first run through.
166  if(myPrintFlag and not already_printed[thread_num] and type()!="void") // myPrintFlag should anyway not be true for void result types
167  {
168  if (not iRunNested) thread_num = 0; // Force printing of thread_num=0 if this functor cannot run nested.
169  int rank = printer->getRank(); // This is "first pass" printing, so use the actual rank of this process.
170  // In the auxilliary printing system we may tell the printer to overwrite
171  // the output of other ranks.
172  logger() << LogTags::debug << "Printing "<<myLabel<<" (vID="<<myVertexID<<", rank="<<rank<<", pID="<<pointID<<")" << EOM;
173  printer->print(myValue[thread_num],myLabel,myVertexID,rank,pointID);
174  already_printed[thread_num] = true;
175  }
176 
177  // Print timing info if requested (independent of whether printing actual result)
178  if(myTimingPrintFlag and not already_printed_timing[thread_num])
179  {
180  if (not iRunNested) thread_num = 0; // Force printing of thread_num=0 if this functor cannot run nested.
181  int rank = printer->getRank();
182  std::chrono::duration<double> runtime = end[thread_num] - start[thread_num];
183  logger() << LogTags::debug << "Printing "<<myTimingLabel<<" (vID="<<myTimingVertexID<<", rank="<<rank<<", pID="<<pointID<<")" << EOM;
184  printer->print(runtime.count(),myTimingLabel,myTimingVertexID,rank,pointID);
185  already_printed_timing[thread_num] = true;
186  }
187  }
void print(T const &in, const std::string &label, const int vertexID, const uint rank, const ulong pointID)
const str myTimingLabel
String label, used to label functor timing data for printer system.
Definition: functors.hpp:337
virtual void init_memory()
Initialise the memory of this functor.
bool myTimingPrintFlag
Flag to select whether or not the timing data for this function&#39;s execution should be printed;...
Definition: functors.hpp:585
bool myPrintFlag
Flag to select whether or not the results of this functor should be sent to the printer object...
Definition: functors.hpp:789
const str myLabel
String label, used to label functor results for printer system.
Definition: functors.hpp:335
int getRank()
Retrieve/Set MPI rank (setting is useful for e.g. the postprocessor to re-print points from other ran...
bool * already_printed
Has result already been sent to the printer?
Definition: functors.hpp:618
const Logging::endofmessage EOM
Explicit const instance of the end of message struct in Gambit namespace.
Definition: logger.hpp:100
EXPORT_SYMBOLS Logging::LogMaster & logger()
Function to retrieve a reference to the Gambit global log object.
Definition: logger.cpp:95
Printers::BaseBasePrinter printer
Type of the printer objects.
str type() const
Getter for the wrapped function&#39;s reported return type.
Definition: functors.cpp:119
bool * already_printed_timing
Has timing data already been sent to the printer?
Definition: functors.hpp:621
std::chrono::time_point< std::chrono::system_clock > * end
Definition: functors.hpp:597
std::chrono::time_point< std::chrono::system_clock > * start
Beginning and end timing points.
Definition: functors.hpp:597
bool iRunNested
Flag indicating whether this function can run nested in a loop over functions.
Definition: functors.hpp:630
int myVertexID
Internal storage of the vertex ID number used by the printer system to identify functors.
Definition: functors.hpp:348
int myTimingVertexID
ID assigned by printers to the timing data output stream.
Definition: functors.hpp:350
TYPE * myValue
Internal pointer to storage location of function value.
Definition: functors.hpp:786

◆ print() [2/2]

template<typename TYPE >
void Gambit::module_functor< TYPE >::print ( Printers::BasePrinter *  printer,
const int  pointID 
)
virtual

Printer function (no-thread-index short-circuit)

Reimplemented from Gambit::functor.

Definition at line 191 of file functor_definitions.hpp.

191 { print(printer,pointID,0); }
virtual void print(Printers::BasePrinter *printer, const int pointID, int index)
Printer function.
Printers::BaseBasePrinter printer
Type of the printer objects.

◆ requiresPrinting()

template<typename TYPE >
bool Gambit::module_functor< TYPE >::requiresPrinting ( ) const
virtual

Getter indicating if the wrapped function's result should to be printed.

Getter indicating if the wrapped function's result should be printed.

Reimplemented from Gambit::functor.

Definition at line 84 of file functor_definitions.hpp.

84 { return myPrintFlag; }
bool myPrintFlag
Flag to select whether or not the results of this functor should be sent to the printer object...
Definition: functors.hpp:789

◆ setPrintRequirement()

template<typename TYPE >
void Gambit::module_functor< TYPE >::setPrintRequirement ( bool  flag)
virtual

Setter for indicating if the wrapped function's result should to be printed.

Setter for indicating if the wrapped function's result should be printed.

Reimplemented from Gambit::functor.

Definition at line 80 of file functor_definitions.hpp.

80 { myPrintFlag = flag;}
bool myPrintFlag
Flag to select whether or not the results of this functor should be sent to the printer object...
Definition: functors.hpp:789

◆ valuePtr()

template<typename TYPE >
safe_ptr< TYPE > Gambit::module_functor< TYPE >::valuePtr ( )

Alternative to operation (returns a safe pointer to value)

Definition at line 150 of file functor_definitions.hpp.

151  {
152  init_memory(); // Init memory if this is the first run through.
153  return safe_ptr<TYPE>(myValue);
154  }
virtual void init_memory()
Initialise the memory of this functor.
TYPE * myValue
Internal pointer to storage location of function value.
Definition: functors.hpp:786

Member Data Documentation

◆ myFunction

template<typename TYPE>
void(* Gambit::module_functor< TYPE >::myFunction) (TYPE &)
protected

Internal storage of function pointer.

Definition at line 783 of file functors.hpp.

Referenced by Gambit::module_functor< void >::calculate().

◆ myPrintFlag

template<typename TYPE>
bool Gambit::module_functor< TYPE >::myPrintFlag
protected

Flag to select whether or not the results of this functor should be sent to the printer object.

Definition at line 789 of file functors.hpp.

◆ myValue

template<typename TYPE>
TYPE* Gambit::module_functor< TYPE >::myValue
protected

Internal pointer to storage location of function value.

Definition at line 786 of file functors.hpp.


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