Version: 9.12.0
YACS::ENGINE::PartDefinition Class Referenceabstract

#include <PlayGround.hxx>

Inheritance diagram for YACS::ENGINE::PartDefinition:
Collaboration diagram for YACS::ENGINE::PartDefinition:

Public Member Functions

const PlayGroundgetPlayGround () const
 
int getSpaceSize () const
 
void stashPart (int nbCoresStashed, double weightOfRemain, YACS::BASES::AutoRefCnt< PartDefinition > &pdStashed, YACS::BASES::AutoRefCnt< PartDefinition > &pdRemain) const
 
std::vector< std::size_t > computeWorkerIdsCovered (int nbCoresPerComp) const
 
virtual std::string printSelf () const =0
 
virtual std::vector< bool > getCoresOn () const =0
 
virtual PartDefinitioncopy () const =0
 
virtual int getNumberOfCoresConsumed () const =0
 
- Public Member Functions inherited from YACS::ENGINE::RefCounter
unsigned int getRefCnt () const
 
void incrRef () const
 
bool decrRef () const
 

Static Public Member Functions

static YACS::BASES::AutoRefCnt< PartDefinitionBuildFrom (const PlayGround *pg, const std::vector< int > &coreIds)
 

Protected Member Functions

 PartDefinition (const PlayGround *pg)
 
 PartDefinition (const PartDefinition &other)
 
virtual ~PartDefinition ()
 
- Protected Member Functions inherited from YACS::ENGINE::RefCounter
 RefCounter ()
 
 RefCounter (const RefCounter &other)
 
virtual ~RefCounter ()
 

Private Attributes

YACS::BASES::AutoConstRefCnt< PlayGround_pg
 

Additional Inherited Members

- Static Public Attributes inherited from YACS::ENGINE::RefCounter
static unsigned int _totalCnt =0
 
- Protected Attributes inherited from YACS::ENGINE::RefCounter
unsigned int _cnt
 

Detailed Description

Definition at line 118 of file PlayGround.hxx.

Constructor & Destructor Documentation

◆ PartDefinition() [1/2]

PartDefinition::PartDefinition ( const PlayGround pg)
protected

Definition at line 590 of file PlayGround.cxx.

591 {
592  _pg.takeRef(pg);
593 }
YACS::BASES::AutoConstRefCnt< PlayGround > _pg
Definition: PlayGround.hxx:136

References _pg.

◆ PartDefinition() [2/2]

PartDefinition::PartDefinition ( const PartDefinition other)
protected

Definition at line 595 of file PlayGround.cxx.

595  :_pg(other._pg)
596 {
597 }

◆ ~PartDefinition()

PartDefinition::~PartDefinition ( )
protectedvirtual

Definition at line 599 of file PlayGround.cxx.

600 {
601 }

Member Function Documentation

◆ BuildFrom()

YACS::BASES::AutoRefCnt< PartDefinition > PartDefinition::BuildFrom ( const PlayGround pg,
const std::vector< int > &  coreIds 
)
static

Definition at line 612 of file PlayGround.cxx.

613 {
614  int spaceSz(pg->getNumberOfCoresAvailable()),sz(coreIds.size());
615  if(sz>spaceSz)
616  throw Exception("PartDefinition::BuildFrom : error 1 !");
617  if(sz==0)
618  throw Exception("PartDefinition::BuildFrom : error 2 !");
619  int zeStart(coreIds.front()),zeEnd(coreIds.back());
620  if(zeStart<0 || zeEnd<zeStart)
621  throw Exception("PartDefinition::BuildFrom : error ! The content of core Ids is not OK !");
622  for(std::size_t i=0;i<sz-1;i++)
623  if(coreIds[i+1]<coreIds[i])
624  throw Exception("PartDefinition::BuildFrom : error ! The content of core Ids is not OK 2 !");
625  if(zeEnd-zeStart+1!=sz)
626  {
628  return pd;
629  }
630  if(sz==spaceSz)
631  {
633  return pd;
634  }
636  return pd;
637 }
int getNumberOfCoresAvailable() const
Definition: PlayGround.cxx:130

References YACS::ENGINE::PlayGround::getNumberOfCoresAvailable(), and yacsorb.CORBAEngineTest::i.

Referenced by YACS::ENGINE::PlayGround::partition(), and stashPart().

◆ computeWorkerIdsCovered()

std::vector< std::size_t > PartDefinition::computeWorkerIdsCovered ( int  nbCoresPerComp) const

you must garantee coherence between PlayGround::deduceMachineFrom, PlayGround::getNumberOfWorkers, and PartDefinition::computeWorkerIdsCovered

Definition at line 677 of file PlayGround.cxx.

678 {
679  std::vector<bool> coresOn(getCoresOn());
680  return _pg->getWorkerIdsFullyFetchedBy(nbCoresPerComp,coresOn);
681 }
virtual std::vector< bool > getCoresOn() const =0

References _pg, and getCoresOn().

◆ copy()

◆ getCoresOn()

virtual std::vector<bool> YACS::ENGINE::PartDefinition::getCoresOn ( ) const
pure virtual

◆ getNumberOfCoresConsumed()

virtual int YACS::ENGINE::PartDefinition::getNumberOfCoresConsumed ( ) const
pure virtual

◆ getPlayGround()

const PlayGround* YACS::ENGINE::PartDefinition::getPlayGround ( ) const
inline

◆ getSpaceSize()

◆ printSelf()

virtual std::string YACS::ENGINE::PartDefinition::printSelf ( ) const
pure virtual

◆ stashPart()

void PartDefinition::stashPart ( int  nbCoresStashed,
double  weightOfRemain,
YACS::BASES::AutoRefCnt< PartDefinition > &  pdStashed,
YACS::BASES::AutoRefCnt< PartDefinition > &  pdRemain 
) const

Definition at line 639 of file PlayGround.cxx.

640 {
641  if(nbCoresStashed<=0)
642  throw Exception("stashPart : Invalid nbCoresStashed value !");
643  if(weightOfRemain<=0.)
644  throw Exception("stashPart : Invalid weight !");
645  std::vector<bool> coresOn(getCoresOn());
646  int nbCoresAvailable(std::count(coresOn.begin(),coresOn.end(),true));
647  std::vector<int> ids(PlayGround::BuildVectOfIdsFromVecBool(coresOn));
648  if(nbCoresAvailable==0)
649  throw Exception("PartDefinition::stashPart : no available cores !");
650  if(nbCoresAvailable<=nbCoresStashed)
651  {
652  int n0((int)(1./(1.+weightOfRemain)*nbCoresAvailable)); n0=std::max(n0,1);
653  int n1(nbCoresAvailable-n0);
654  if(n1<=0)
655  {
656  pdStashed=PartDefinition::BuildFrom(getPlayGround(),ids);
658  }
659  else
660  {
661  std::vector<int> ids0(ids.begin(),ids.begin()+n0),ids1(ids.begin()+n0,ids.end());
662  pdStashed=PartDefinition::BuildFrom(getPlayGround(),ids0);
663  pdRemain=PartDefinition::BuildFrom(getPlayGround(),ids1);
664  }
665  }
666  else
667  {
668  std::vector<int> ids0(ids.begin(),ids.begin()+nbCoresStashed),ids1(ids.begin()+nbCoresStashed,ids.end());
669  pdStashed=PartDefinition::BuildFrom(getPlayGround(),ids0);
670  pdRemain=PartDefinition::BuildFrom(getPlayGround(),ids1);
671  }
672 }
const PlayGround * getPlayGround() const
Definition: PlayGround.hxx:127
static YACS::BASES::AutoRefCnt< PartDefinition > BuildFrom(const PlayGround *pg, const std::vector< int > &coreIds)
Definition: PlayGround.cxx:612
static std::vector< int > BuildVectOfIdsFromVecBool(const std::vector< bool > &v)
Definition: PlayGround.cxx:234

References BuildFrom(), YACS::ENGINE::PlayGround::BuildVectOfIdsFromVecBool(), getCoresOn(), and getPlayGround().

Member Data Documentation

◆ _pg

YACS::BASES::AutoConstRefCnt<PlayGround> YACS::ENGINE::PartDefinition::_pg
private

Definition at line 136 of file PlayGround.hxx.

Referenced by computeWorkerIdsCovered(), and PartDefinition().


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