Samchon Framework for CPP  1.0.0
samchon::templates::parallel::ParallelSystemArray< System > Class Template Reference

#include <ParallelSystemArray.hpp>

Collaboration diagram for samchon::templates::parallel::ParallelSystemArray< System >:

Public Member Functions

 ParallelSystemArray ()
 Default Constructor. More...
 
auto sendSegmentData (std::shared_ptr< protocol::Invoke > invoke, size_t size) -> size_t
 
virtual auto sendPieceData (std::shared_ptr< protocol::Invoke > invoke, size_t first, size_t last) -> size_t
 
- Public Member Functions inherited from samchon::templates::external::ExternalSystemArray< System >
 ExternalSystemArray ()
 
virtual ~ExternalSystemArray ()=default
 
auto hasRole (const std::string &key) const -> bool
 
auto getRole (const std::string &key) const -> std::shared_ptr< ExternalSystemRole >
 
virtual void sendData (std::shared_ptr< protocol::Invoke > invoke)
 
virtual void replyData (std::shared_ptr< protocol::Invoke > invoke)=0
 
virtual auto CHILD_TAG () const -> std::string override
 A tag name of children. More...
 
- Public Member Functions inherited from samchon::protocol::EntityGroup< Container, T, Key >
virtual void construct (std::shared_ptr< library::XML > xml)
 Construct data of the Entity from an XML object. More...
 
auto find (const typename child_type::key_type &key) -> typename container_type::iterator
 Get iterator to element. More...
 
auto find (const typename child_type::key_type &key) const -> typename container_type::const_iterator
 Get const iterator to element. More...
 
auto has (const typename child_type::key_type &key) const -> bool
 Indicates whether a container has an object having the specified identifier. More...
 
auto count (const typename child_type::key_type &key) const -> size_t
 Count elements with a specific key. More...
 
auto get (const typename child_type::key_type &key) -> typename container_type::value_type &
 Access the element by specified identifier(key). More...
 
auto get (const typename child_type::key_type &key) const -> const typename container_type::value_type &
 Access the const element by specified identifier(key). More...
 
virtual auto toXML () const -> std::shared_ptr< library::XML >
 Get an XML object represents the EntityGroup. More...
 
- Public Member Functions inherited from samchon::protocol::Entity< Key >
virtual auto key () const -> Key
 Get a key that can identify the Entity uniquely. More...
 
- Public Member Functions inherited from samchon::protocol::IProtocol
virtual void replyData (std::shared_ptr< Invoke >)=0
 
virtual void sendData (std::shared_ptr< Invoke >)=0
 

Additional Inherited Members

- Protected Member Functions inherited from samchon::protocol::EntityGroup< Container, T, Key >
virtual auto createChild (std::shared_ptr< library::XML >) -> child_type *=0
 Factory method of a child Entity. More...
 

Detailed Description

template<class System = ParallelSystem>
class samchon::templates::parallel::ParallelSystemArray< System >

Master of Parallel Processing System.

The ParallelSystemArray is an abstract class containing and managing remote parallel slave system drivers, ParallelSystem objects. Within framework of network, ParallelSystemArray represents your system, a Master of Parallel Processing System that requesting parallel process to slave systems and the children ParallelSystem objects represent the remote slave systems, who is being requested the parallel processes.

You can specify this ParallelSystemArray class to be a server accepting parallel clients or a client connecting to parallel servers. Even both of them is possible. Extends one of them below and overrides abstract factory method(s) creating the child ParallelSystem object.

When you need the parallel process, then call one of them: sendSegmentData or sendPieceData. When the parallel process has completed, ParallelSystemArray estimates each ParallelSystem's performance index basis on their execution time. Those performance indices will be reflected to the next parallel process, how much pieces to allocate to each ParallelSystem.

Class Diagram

Proxy Pattern

This class ParallelSystemArray is derived from the ExternalSystemArray class. Thus, you can take advantage of the Proxy Pattern in the ParallelSystemArray class. If a process to request is not the parallel process (to be distrubted to all slaves), but the exclusive process handled in a system, then it may better to utilizing the Proxy Pattern:

The ExternalSystemArray class can use Proxy Pattern. In framework within user, which external system is connected with this system, it's not important. Only interested in user's perspective is which can be done.

By using the logical proxy, user dont't need to know which role is belonged to which system. Just access to a role directly from ExternalSystemArray.getRole. Sends and receives Invoke message via the role.

Templates - Parallel System

Author
Jeongho Nam http://samchon.org

Definition at line 77 of file ParallelSystemArray.hpp.

Constructor & Destructor Documentation

template<class System = ParallelSystem>
samchon::templates::parallel::ParallelSystemArray< System >::ParallelSystemArray ( )
inline

Default Constructor.

Definition at line 91 of file ParallelSystemArray.hpp.

Member Function Documentation

template<class System = ParallelSystem>
auto samchon::templates::parallel::ParallelSystemArray< System >::sendSegmentData ( std::shared_ptr< protocol::Invoke invoke,
size_t  size 
) -> size_t
inline

Send an Invoke message with segment size.

Sends an Invoke message requesting a parallel process with its segment size. The Invoke message will be delivered to children ParallelSystem objects with the piece size, which is divided from the segment size, basis on their performance indices.

  • If segment size is 100,
  • The segment will be allocated such below:
Name Performance index Number of pieces to be allocated Formula
Snail 1 10 100 / 10 * 1
Cheetah 4 40 100 / 10 * 4
Rabbit 3 30 100 / 10 * 3
Turtle 2 20 100 / 10 * 2

When the parallel process has completed, then this ParallelSystemArraY will estimate performance indices of ParallelSystem objects basis on their execution time.

Parameters
invokeAn Invoke message requesting parallel process.
sizeNumber of pieces to segment.
See also
sendPieceData, ParallelSystem.getPerformacen

Definition at line 131 of file ParallelSystemArray.hpp.

template<class System = ParallelSystem>
virtual auto samchon::templates::parallel::ParallelSystemArray< System >::sendPieceData ( std::shared_ptr< protocol::Invoke invoke,
size_t  first,
size_t  last 
) -> size_t
inlinevirtual

Send an Invoke message with range of pieces.

Sends an Invoke message requesting a parallel process with its range of pieces [first, last). The Invoke will be delivered to children ParallelSystem objects with the newly computed range of sub-pieces, which is divided from the range of pieces (first to last), basis on their performance indices.

  • If indices of pieces are 0 to 50,
  • The sub-pieces will be allocated such below:
Name Performance index Range of sub-pieces to be allocated Formula
Snail 1 ( 0, 5] (50 - 0) / 10 * 1
Cheetah 4 ( 5, 25] (50 - 0) / 10 * 4 + 5
Rabbit 3 (25, 40] (50 - 0) / 10 * 3 + 25
Turtle 2 (40, 50] (50 - 0) / 10 * 2 + 40

When the parallel process has completed, then this ParallelSystemArraY will estimate performance indices of ParallelSystem objects basis on their execution time.

Parameters
invokeAn Invoke message requesting parallel process.
firstInitial piece's index in a section.
lastFinal piece's index in a section. The range used is [first, last), which contains all the pieces' indices between first and last, including the piece pointed by index first, but not the piece pointed by the index last.
See also
sendSegmentData, ParallelSystem.getPerformacen

Definition at line 166 of file ParallelSystemArray.hpp.

Referenced by samchon::templates::parallel::ParallelSystemArray< SlaveDriver >::sendSegmentData().

Here is the caller graph for this function:


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