![]() |
KIDS
ver-0.0.1
KIDS : Kernel Integrated Dynamics Simulator
|
this class provides the container and implementation of algorithms More...
#include <Kernel.h>
Public Member Functions | |
virtual const std::string | getName () |
Get the name of the kernel. | |
Kernel (const std::string &customized_name="") | |
Constructor with an optional specified name. | |
virtual | ~Kernel () |
Destructor. | |
void | setInputParam (std::shared_ptr< Param > &PM) |
Set input parameters for the kernel and its children. | |
void | setInputDataSet (std::shared_ptr< DataSet > &DS) |
Set input data set for the kernel and its children. | |
std::shared_ptr< Param > | getParam () const |
Get the parameter associated with the kernel. | |
std::shared_ptr< DataSet > | getDataSet () const |
Get the data set associated with the kernel. | |
Status & | initializeKernel (Status &stat) |
Prepare initial conditions for the kernel and its children. | |
Status & | executeKernel (Status &stat) |
Execute the kernel's algorithm and those of its children. | |
Status & | finalizeKernel (Status &stat) |
Finalize the kernel and its children, performing any necessary cleanup. | |
virtual int | getType () const |
Get the type of the kernel. | |
int | getID () const |
Get the ID of the kernel. | |
bool | operator== (const Kernel &ker) |
Overloaded equality operator to compare two Kernel objects by their IDs. | |
Kernel & | appendChild (std::shared_ptr< Kernel > ker) |
Append a kernel as the last child of the current tree node. | |
Kernel & | insertAt (std::vector< std::size_t > indexes, std::shared_ptr< Kernel > ker) |
Insert a kernel at specified indexes in the tree. | |
Kernel & | removeAt (std::vector< std::size_t > indexes) |
Remove kernels at specified indexes from the tree. | |
Kernel & | updateAt (std::vector< std::size_t > indexes, std::shared_ptr< Kernel > ker) |
Update the kernel at specified indexes in the tree. | |
std::tuple< Kernel *, std::size_t > | getLastParentKernelAndChildOrder () |
Retrieve the last parent kernel along with the order of its child kernels, if available. | |
std::shared_ptr< RuleSet > | getRuleSet () |
Get RuleSet associated with the Kernel. | |
const std::string | generateInformationString (double total_time=-1.0f, int current_layer=0, int total_depth=0, int total_align_size=0) |
Generate a formatted string containing information about the kernel. | |
Static Public Member Functions | |
static int | dump (Kernel *ker) |
static int | report (Kernel *ker) |
static int | mpi_reduce_info (Kernel *ker) |
static const std::string | serializeKernel (const Kernel &ker) |
Serialize a Kernel object into a string representation. | |
static std::shared_ptr< Kernel > | deserializeKernel (const std::string &str) |
Deserialize a string representation into a Kernel object. | |
Protected Member Functions | |
virtual void | setInputParam_impl (std::shared_ptr< Param > &PM) |
Virtual function to set input parameters for the kernel implementation. | |
virtual void | setInputDataSet_impl (std::shared_ptr< DataSet > &DS) |
Virtual function to set input data set for the kernel implementation. | |
virtual Status & | initializeKernel_impl (Status &stat) |
Virtual function to initialize the kernel implementation. | |
virtual Status & | executeKernel_impl (Status &stat) |
Virtual function to execute the kernel implementation. | |
virtual Status & | finalizeKernel_impl (Status &stat) |
Virtual function to finalize the kernel implementation. | |
Protected Attributes | |
bool | is_timing = false |
Flag indicating whether timing is enabled for this kernel. | |
bool | has_parent = false |
Flag indicating whether the kernel has a parent. | |
int | count_calc = 0 |
Counter for the number of calculations performed by this kernel. | |
int | count_exec = 0 |
Counter for the number of executions performed by this kernel. | |
int | kernel_id = 0 |
ID of the kernel. | |
int | kernel_type = 0 |
Type of the kernel. | |
double | exec_time = 0.0f |
Total execution time of the kernel. | |
int | depth = 0 |
Depth of the kernel in the tree structure. | |
int | max_align_size = 0 |
Maximum alignment size used by this kernel. | |
std::string | kernel_name |
Name of the kernel. | |
std::shared_ptr< Param > | _param |
Shared pointer to the Param object associated with this kernel. | |
std::shared_ptr< DataSet > | _dataset |
Shared pointer to the DataSet object associated with this kernel. | |
std::shared_ptr< RuleSet > | _ruleset |
Recorded Rules associated with the Kernel. | |
Kernel * | _parent_kernel |
Pointer to the parent kernel. | |
std::size_t | _order_in_parent |
Order of this kernel in its parent's children. | |
std::vector< std::shared_ptr< Kernel > > | _child_kernels |
Vector containing shared pointers to the child kernels of this kernel. | |
std::vector< std::shared_ptr< Kernel > > | _all_kernels |
Vector containing shared pointers to all descendant kernels of this kernel. | |
Private Member Functions | |
void | connectRelatedKernels (std::shared_ptr< Kernel > &ker) |
Connect related kernels to this kernel. | |
Static Private Member Functions | |
static std::map< std::string, Kernel * > & | getDictOfKernels () |
Get the dictionary of kernels (mapping from names to kernel pointers). | |
static std::vector< Kernel * > & | getKernels () |
Get the vector of all kernel pointers. | |
this class provides the container and implementation of algorithms
Kernel::Kernel | ( | const std::string & | customized_name = "" | ) |
Constructor with an optional specified name.
customized_name | The name of the kernel (optional). |
Definition at line 12 of file Kernel.cpp.
References getKernels(), getName(), getType(), kernel_id, kernel_type, and max_align_size.
|
virtual |
Destructor.
Definition at line 19 of file Kernel.cpp.
Append a kernel as the last child of the current tree node.
ker | The kernel to append as the last child. |
Definition at line 78 of file Kernel.cpp.
References _child_kernels, _order_in_parent, _ruleset, depth, getLastParentKernelAndChildOrder(), and max_align_size.
Referenced by PROJECT_NS::Kernel_Elec_NAD::Kernel_Elec_NAD(), PROJECT_NS::Kernel_Elec_Switch::Kernel_Elec_Switch(), PROJECT_NS::Kernel_GWP::Kernel_GWP(), PROJECT_NS::Model_ElectronTransfer::Model_ElectronTransfer(), and PROJECT_NS::Model_SystemBath::Model_SystemBath().
|
private |
Connect related kernels to this kernel.
This function connects related kernels to the current kernel. Related kernels are kernels that are associated with or connected to this kernel in some way.
Definition at line 228 of file Kernel.cpp.
References _all_kernels, and connectRelatedKernels().
Referenced by connectRelatedKernels().
|
static |
Deserialize a string representation into a Kernel object.
str | The string containing the serialized Kernel object. |
Definition at line 187 of file Kernel.cpp.
|
inlinestatic |
Execute the kernel's algorithm and those of its children.
stat | The status object to store execution status. |
Definition at line 48 of file Kernel.cpp.
References _child_kernels, _dataset, _ruleset, count_exec, exec_time, executeKernel_impl(), has_parent, and is_timing.
Referenced by PROJECT_NS::Kernel_Conserve::initializeKernel_impl(), PROJECT_NS::Kernel_Elec_NAD::initializeKernel_impl(), PROJECT_NS::Kernel_Elec_Switch::initializeKernel_impl(), PROJECT_NS::Kernel_GWP::initializeKernel_impl(), PROJECT_NS::Kernel_NADForce::initializeKernel_impl(), PROJECT_NS::Kernel_Representation::initializeKernel_impl(), PROJECT_NS::Model_ElectronTransfer::initializeKernel_impl(), PROJECT_NS::Model_LVCM::initializeKernel_impl(), PROJECT_NS::Model_NAD1D::initializeKernel_impl(), and PROJECT_NS::Model_SystemBath::initializeKernel_impl().
Virtual function to execute the kernel implementation.
stat | Status object to store execution status. |
Reimplemented in PROJECT_NS::Kernel_Conserve, PROJECT_NS::Kernel_Dump_DataSet, PROJECT_NS::Kernel_Elec, PROJECT_NS::Kernel_Elec_NAD, PROJECT_NS::Kernel_Elec_Switch, PROJECT_NS::Kernel_GWP, PROJECT_NS::Kernel_Iter, PROJECT_NS::Kernel_Iter_Adapt, PROJECT_NS::Kernel_Load_DataSet, PROJECT_NS::Kernel_NADForce, PROJECT_NS::Kernel_Recorder, PROJECT_NS::Kernel_Representation, PROJECT_NS::Kernel_Update_c, PROJECT_NS::Kernel_Update_p, PROJECT_NS::Kernel_Update_T, PROJECT_NS::Kernel_Update_x, PROJECT_NS::Model_ElectronTransfer, PROJECT_NS::Model_Hello, PROJECT_NS::Model_Interf_MNDO, PROJECT_NS::Model_LVCM, PROJECT_NS::Model_HO, PROJECT_NS::MODEL_MD1D, PROJECT_NS::Model_NAD1D, and PROJECT_NS::Model_SystemBath.
Definition at line 224 of file Kernel.cpp.
Referenced by executeKernel().
Finalize the kernel and its children, performing any necessary cleanup.
stat | The status object to store finalization status. |
Definition at line 66 of file Kernel.cpp.
References _child_kernels, and finalizeKernel_impl().
Virtual function to finalize the kernel implementation.
stat | Status object to store finalization status. |
Reimplemented in PROJECT_NS::Kernel_Recorder.
Definition at line 226 of file Kernel.cpp.
Referenced by finalizeKernel().
const std::string Kernel::generateInformationString | ( | double | total_time = -1.0f, |
int | current_layer = 0, | ||
int | total_depth = 0, | ||
int | total_align_size = 0 ) |
Generate a formatted string containing information about the kernel.
This function generates a formatted string containing information about the kernel, including its total time, current layer, total depth, and total alignment size.
total_time | The total time taken by the kernel (default: -1.0f). |
current_layer | The current layer of the kernel (default: 0). |
total_depth | The total depth of the kernel (default: 0). |
total_align_size | The total alignment size of the kernel (default: 0). |
Definition at line 189 of file Kernel.cpp.
References _child_kernels, depth, exec_time, getName(), kernel_id, and max_align_size.
std::shared_ptr< DataSet > Kernel::getDataSet | ( | ) | const |
Get the data set associated with the kernel.
Definition at line 37 of file Kernel.cpp.
References _dataset.
|
staticprivate |
Get the dictionary of kernels (mapping from names to kernel pointers).
This function returns a reference to the static map containing the dictionary of kernels. The dictionary maps kernel names to their corresponding kernel pointers.
int Kernel::getID | ( | ) | const |
Get the ID of the kernel.
Definition at line 74 of file Kernel.cpp.
References kernel_id.
Referenced by PROJECT_NS::Kernel_Prioritization::getName(), and operator==().
|
staticprivate |
Get the vector of all kernel pointers.
This function returns a reference to the static vector containing pointers to all kernels.
Definition at line 247 of file Kernel.cpp.
Referenced by Kernel().
std::tuple< Kernel *, std::size_t > Kernel::getLastParentKernelAndChildOrder | ( | ) |
Retrieve the last parent kernel along with the order of its child kernels, if available.
Definition at line 178 of file Kernel.cpp.
References _order_in_parent, _parent_kernel, and has_parent.
Referenced by appendChild(), insertAt(), and updateAt().
|
inlinevirtual |
Get the name of the kernel.
Returns the concatenated name of the kernel, prefixed with "Kernel__".
Reimplemented in PROJECT_NS::Kernel_Conserve, PROJECT_NS::Kernel_Dump_DataSet, PROJECT_NS::Kernel_Elec, PROJECT_NS::Kernel_Elec_NAD, PROJECT_NS::Kernel_Elec_Switch, PROJECT_NS::Kernel_GWP, PROJECT_NS::Kernel_Iter, PROJECT_NS::Kernel_Iter_Adapt, PROJECT_NS::Kernel_Load_DataSet, PROJECT_NS::Kernel_NADForce, PROJECT_NS::Kernel_Prioritization, PROJECT_NS::Kernel_Random, PROJECT_NS::Kernel_Read_Dimensions, PROJECT_NS::Kernel_Recorder, PROJECT_NS::Kernel_Representation, PROJECT_NS::Kernel_Update_c, PROJECT_NS::Kernel_Update_p, PROJECT_NS::Kernel_Update_T, PROJECT_NS::Kernel_Update_x, PROJECT_NS::Model_Bath, PROJECT_NS::Model_ElectronTransfer, PROJECT_NS::Model_Hello, PROJECT_NS::Model_Interf_MNDO, PROJECT_NS::Model_LVCM, PROJECT_NS::Model_HO, PROJECT_NS::MODEL_MD1D, PROJECT_NS::Model_NAD1D, and PROJECT_NS::Model_SystemBath.
Definition at line 69 of file Kernel.h.
References utils::concat(), and kernel_name.
Referenced by generateInformationString(), and Kernel().
std::shared_ptr< Param > Kernel::getParam | ( | ) | const |
Get the parameter associated with the kernel.
Definition at line 35 of file Kernel.cpp.
References _param.
std::shared_ptr< RuleSet > Kernel::getRuleSet | ( | ) |
|
virtual |
Get the type of the kernel.
This function returns the type of the kernel.
Reimplemented in PROJECT_NS::Kernel_Conserve, PROJECT_NS::Kernel_Dump_DataSet, PROJECT_NS::Kernel_Elec, PROJECT_NS::Kernel_Elec_NAD, PROJECT_NS::Kernel_Elec_Switch, PROJECT_NS::Kernel_GWP, PROJECT_NS::Kernel_Iter, PROJECT_NS::Kernel_Iter_Adapt, PROJECT_NS::Kernel_Load_DataSet, PROJECT_NS::Kernel_NADForce, PROJECT_NS::Kernel_Prioritization, PROJECT_NS::Kernel_Random, PROJECT_NS::Kernel_Read_Dimensions, PROJECT_NS::Kernel_Recorder, PROJECT_NS::Kernel_Representation, PROJECT_NS::Kernel_Update_c, PROJECT_NS::Kernel_Update_p, PROJECT_NS::Kernel_Update_T, PROJECT_NS::Kernel_Update_x, PROJECT_NS::Model_Bath, PROJECT_NS::Model_ElectronTransfer, PROJECT_NS::Model_Hello, PROJECT_NS::Model_Interf_MNDO, PROJECT_NS::Model_LVCM, PROJECT_NS::Model_HO, PROJECT_NS::MODEL_MD1D, PROJECT_NS::Model_NAD1D, and PROJECT_NS::Model_SystemBath.
Definition at line 72 of file Kernel.cpp.
References FUNCTION_NAME, and utils::hash().
Referenced by Kernel().
Prepare initial conditions for the kernel and its children.
stat | The status object to store initialization status. |
Definition at line 39 of file Kernel.cpp.
References _child_kernels, _dataset, count_calc, and initializeKernel_impl().
Virtual function to initialize the kernel implementation.
stat | Status object to store initialization status. |
Reimplemented in PROJECT_NS::Kernel_Conserve, PROJECT_NS::Kernel_Dump_DataSet, PROJECT_NS::Kernel_Elec, PROJECT_NS::Kernel_Elec_NAD, PROJECT_NS::Kernel_Elec_Switch, PROJECT_NS::Kernel_GWP, PROJECT_NS::Kernel_Iter, PROJECT_NS::Kernel_Iter_Adapt, PROJECT_NS::Kernel_NADForce, PROJECT_NS::Kernel_Prioritization, PROJECT_NS::Kernel_Random, PROJECT_NS::Kernel_Recorder, PROJECT_NS::Kernel_Representation, PROJECT_NS::Kernel_Update_p, PROJECT_NS::Model_ElectronTransfer, PROJECT_NS::Model_Interf_MNDO, PROJECT_NS::Model_LVCM, PROJECT_NS::Model_HO, PROJECT_NS::Model_NAD1D, and PROJECT_NS::Model_SystemBath.
Definition at line 222 of file Kernel.cpp.
Referenced by initializeKernel().
Insert a kernel at specified indexes in the tree.
indexes | Indexes indicating the position to insert the kernel. |
ker | The kernel to insert. |
Definition at line 102 of file Kernel.cpp.
References _child_kernels, _ruleset, and getLastParentKernelAndChildOrder().
|
inlinestatic |
bool Kernel::operator== | ( | const Kernel & | ker | ) |
Overloaded equality operator to compare two Kernel objects by their IDs.
ker | The Kernel object to compare with. |
Definition at line 76 of file Kernel.cpp.
References getID().
Kernel & Kernel::removeAt | ( | std::vector< std::size_t > | indexes | ) |
Remove kernels at specified indexes from the tree.
indexes | Indexes indicating the kernels to remove. |
Definition at line 128 of file Kernel.cpp.
References _child_kernels.
|
inlinestatic |
|
static |
Serialize a Kernel object into a string representation.
ker | The Kernel object to serialize. |
Definition at line 185 of file Kernel.cpp.
void Kernel::setInputDataSet | ( | std::shared_ptr< DataSet > & | DS | ) |
Set input data set for the kernel and its children.
DS | Shared pointer to the DataSet object. |
Definition at line 28 of file Kernel.cpp.
References _child_kernels, _dataset, _param, and setInputDataSet_impl().
|
protectedvirtual |
Virtual function to set input data set for the kernel implementation.
DS | Shared pointer to the DataSet object containing input data. |
Reimplemented in PROJECT_NS::Kernel_Conserve, PROJECT_NS::Kernel_Elec, PROJECT_NS::Kernel_Elec_NAD, PROJECT_NS::Kernel_Elec_Switch, PROJECT_NS::Kernel_GWP, PROJECT_NS::Kernel_Iter, PROJECT_NS::Kernel_Iter_Adapt, PROJECT_NS::Kernel_NADForce, PROJECT_NS::Kernel_Prioritization, PROJECT_NS::Kernel_Random, PROJECT_NS::Kernel_Recorder, PROJECT_NS::Kernel_Representation, PROJECT_NS::Kernel_Update_c, PROJECT_NS::Kernel_Update_p, PROJECT_NS::Kernel_Update_T, PROJECT_NS::Kernel_Update_x, PROJECT_NS::Model_Bath, PROJECT_NS::Model_ElectronTransfer, PROJECT_NS::Model_Hello, PROJECT_NS::Model_Interf_MNDO, PROJECT_NS::Model_LVCM, PROJECT_NS::Model_NAD1D, and PROJECT_NS::Model_SystemBath.
Definition at line 220 of file Kernel.cpp.
Referenced by setInputDataSet().
void Kernel::setInputParam | ( | std::shared_ptr< Param > & | PM | ) |
Set input parameters for the kernel and its children.
PM | Shared pointer to the Param object. |
Definition at line 21 of file Kernel.cpp.
References _child_kernels, _param, is_timing, LOC, and setInputParam_impl().
|
protectedvirtual |
Virtual function to set input parameters for the kernel implementation.
PM | Shared pointer to the Param object containing input parameters. |
Reimplemented in PROJECT_NS::Kernel_Conserve, PROJECT_NS::Kernel_Dump_DataSet, PROJECT_NS::Kernel_Elec, PROJECT_NS::Kernel_Elec_NAD, PROJECT_NS::Kernel_Elec_Switch, PROJECT_NS::Kernel_GWP, PROJECT_NS::Kernel_Iter, PROJECT_NS::Kernel_Iter_Adapt, PROJECT_NS::Kernel_Load_DataSet, PROJECT_NS::Kernel_NADForce, PROJECT_NS::Kernel_Prioritization, PROJECT_NS::Kernel_Read_Dimensions, PROJECT_NS::Kernel_Recorder, PROJECT_NS::Kernel_Representation, PROJECT_NS::Kernel_Update_T, PROJECT_NS::Model_Bath, PROJECT_NS::Model_ElectronTransfer, PROJECT_NS::Model_Hello, PROJECT_NS::Model_Interf_MNDO, PROJECT_NS::Model_LVCM, PROJECT_NS::Model_NAD1D, and PROJECT_NS::Model_SystemBath.
Definition at line 218 of file Kernel.cpp.
Referenced by setInputParam().
Update the kernel at specified indexes in the tree.
build tree structure of the kernel
indexes | Indexes indicating the kernel to update. |
ker | The kernel to update with. |
Definition at line 147 of file Kernel.cpp.
References _child_kernels, _ruleset, and getLastParentKernelAndChildOrder().
|
protected |
Vector containing shared pointers to all descendant kernels of this kernel.
Definition at line 303 of file Kernel.h.
Referenced by connectRelatedKernels().
|
protected |
Vector containing shared pointers to the child kernels of this kernel.
Definition at line 298 of file Kernel.h.
Referenced by appendChild(), executeKernel(), PROJECT_NS::Kernel_Iter::executeKernel_impl(), PROJECT_NS::Kernel_Iter_Adapt::executeKernel_impl(), finalizeKernel(), generateInformationString(), initializeKernel(), insertAt(), removeAt(), setInputDataSet(), PROJECT_NS::Model_ElectronTransfer::setInputDataSet_impl(), PROJECT_NS::Model_SystemBath::setInputDataSet_impl(), setInputParam(), and updateAt().
|
protected |
Shared pointer to the DataSet object associated with this kernel.
Definition at line 278 of file Kernel.h.
Referenced by executeKernel(), PROJECT_NS::Kernel_Dump_DataSet::executeKernel_impl(), PROJECT_NS::Kernel_Iter_Adapt::executeKernel_impl(), PROJECT_NS::Kernel_Load_DataSet::executeKernel_impl(), getDataSet(), initializeKernel(), PROJECT_NS::Kernel_Dump_DataSet::initializeKernel_impl(), PROJECT_NS::Kernel_Elec::initializeKernel_impl(), PROJECT_NS::Kernel_Elec_NAD::initializeKernel_impl(), PROJECT_NS::Kernel_Elec_Switch::initializeKernel_impl(), PROJECT_NS::Kernel_GWP::initializeKernel_impl(), PROJECT_NS::Kernel_Representation::initializeKernel_impl(), PROJECT_NS::Model_ElectronTransfer::initializeKernel_impl(), PROJECT_NS::Model_Interf_MNDO::initializeKernel_impl(), PROJECT_NS::Model_LVCM::initializeKernel_impl(), PROJECT_NS::Model_NAD1D::initializeKernel_impl(), PROJECT_NS::Model_SystemBath::initializeKernel_impl(), PROJECT_NS::Model_Interf_MNDO::parse_standard(), setInputDataSet(), and PROJECT_NS::Kernel_Recorder::token().
|
protected |
Order of this kernel in its parent's children.
Definition at line 293 of file Kernel.h.
Referenced by appendChild(), and getLastParentKernelAndChildOrder().
|
protected |
Shared pointer to the Param object associated with this kernel.
Definition at line 273 of file Kernel.h.
Referenced by PROJECT_NS::Kernel_Iter_Adapt::executeKernel_impl(), getParam(), PROJECT_NS::Kernel_Elec_NAD::initializeKernel_impl(), PROJECT_NS::Kernel_Elec_Switch::initializeKernel_impl(), PROJECT_NS::Kernel_Recorder::initializeKernel_impl(), PROJECT_NS::Model_Interf_MNDO::initializeKernel_impl(), setInputDataSet(), PROJECT_NS::Model_Bath::setInputDataSet_impl(), PROJECT_NS::Model_ElectronTransfer::setInputDataSet_impl(), PROJECT_NS::Model_Interf_MNDO::setInputDataSet_impl(), PROJECT_NS::Model_LVCM::setInputDataSet_impl(), PROJECT_NS::Model_NAD1D::setInputDataSet_impl(), PROJECT_NS::Model_SystemBath::setInputDataSet_impl(), setInputParam(), PROJECT_NS::Kernel_NADForce::setInputParam_impl(), PROJECT_NS::Model_Bath::setInputParam_impl(), PROJECT_NS::Model_ElectronTransfer::setInputParam_impl(), PROJECT_NS::Model_LVCM::setInputParam_impl(), PROJECT_NS::Model_NAD1D::setInputParam_impl(), and PROJECT_NS::Model_SystemBath::setInputParam_impl().
|
protected |
Pointer to the parent kernel.
Definition at line 288 of file Kernel.h.
Referenced by getLastParentKernelAndChildOrder().
|
protected |
Recorded Rules associated with the Kernel.
Definition at line 283 of file Kernel.h.
Referenced by appendChild(), executeKernel(), PROJECT_NS::Kernel_Recorder::executeKernel_impl(), PROJECT_NS::Kernel_Recorder::finalizeKernel_impl(), getRuleSet(), PROJECT_NS::Kernel_Recorder::initializeKernel_impl(), insertAt(), PROJECT_NS::Kernel_Recorder::Kernel_Recorder(), PROJECT_NS::Kernel_Recorder::token(), and updateAt().