1 // Copyright (C) 2006-2021 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 %include <std_vector.i>
20 %template() std::pair< YACS::ENGINE::PartDefinition *, YACS::ENGINE::ComplexWeight *>;
21 %template(vecppdd) std::vector< std::pair< YACS::ENGINE::PartDefinition *, YACS::ENGINE::ComplexWeight *> >;
23 %newobject YACS::ENGINE::PlayGround::copy;
26 PyObject *convertPartDefinition(YACS::ENGINE::PartDefinition *pd)
29 return SWIG_NewPointerObj(SWIG_as_voidptr(pd),SWIGTYPE_p_YACS__ENGINE__PartDefinition, SWIG_POINTER_OWN | 0 );
30 YACS::ENGINE::ContigPartDefinition *pd1(dynamic_cast<YACS::ENGINE::ContigPartDefinition *>(pd));
32 return SWIG_NewPointerObj(SWIG_as_voidptr(pd1),SWIGTYPE_p_YACS__ENGINE__ContigPartDefinition, SWIG_POINTER_OWN | 0 );
33 YACS::ENGINE::NonContigPartDefinition *pd2(dynamic_cast<YACS::ENGINE::NonContigPartDefinition *>(pd));
35 return SWIG_NewPointerObj(SWIG_as_voidptr(pd2),SWIGTYPE_p_YACS__ENGINE__NonContigPartDefinition, SWIG_POINTER_OWN | 0 );
36 YACS::ENGINE::AllPartDefinition *pd3(dynamic_cast<YACS::ENGINE::AllPartDefinition *>(pd));
38 return SWIG_NewPointerObj(SWIG_as_voidptr(pd3),SWIGTYPE_p_YACS__ENGINE__AllPartDefinition, SWIG_POINTER_OWN | 0 );
39 return SWIG_NewPointerObj(SWIG_as_voidptr(pd),SWIGTYPE_p_YACS__ENGINE__PartDefinition, SWIG_POINTER_OWN | 0 );
44 %typemap(out) std::vector< YACS::BASES::AutoRefCnt<YACS::ENGINE::PartDefinition> >
46 std::size_t sz($1.size());
47 std::vector< YACS::BASES::AutoRefCnt<YACS::ENGINE::PartDefinition> >::iterator it($1.begin());
48 $result = PyList_New($1.size());
49 for (std::size_t i=0; i<sz; i++,it++)
50 PyList_SetItem($result,i,convertPartDefinition((*it).retn()));
59 class PlayGround : public RefCounter
63 void loadFromKernelCatalog();
64 PlayGround(const std::vector< std::pair<std::string,int> >& defOfRes);
65 std::string printSelf() const;
66 std::vector< std::pair<std::string,int> > getData() const;
67 void setData(const std::vector< std::pair<std::string,int> >& defOfRes);
68 int getNumberOfCoresAvailable() const;
69 int getMaxNumberOfContainersCanBeHostedWithoutOverlap(int nbCoresPerCont) const;
70 std::string deduceMachineFrom(int workerId, int nbProcPerNode) const;
73 std::string __str__() const
75 return self->printSelf();
78 std::vector< YACS::BASES::AutoRefCnt<YACS::ENGINE::PartDefinition> > partition(const std::vector< std::pair< YACS::ENGINE::PartDefinition *, YACS::ENGINE::ComplexWeight *> >& parts, const std::vector<int> &nbCoresPerShot) const
80 std::size_t sz(parts.size());
81 std::vector< std::pair< const YACS::ENGINE::PartDefinition *, const YACS::ENGINE::ComplexWeight *> > partsCpp(sz);
82 for(std::size_t i=0;i<sz;i++)
83 partsCpp[i]=std::pair<const YACS::ENGINE::PartDefinition *, const YACS::ENGINE::ComplexWeight *>(parts[i].first, parts[i].second);
84 return self->partition(partsCpp, nbCoresPerShot);
91 class PartDefinition : public RefCounter
94 virtual PartDefinition *copy() const;
95 virtual std::string printSelf() const;
96 virtual int getNumberOfCoresConsumed() const;
102 class ContigPartDefinition : public PartDefinition
105 ContigPartDefinition(const PlayGround *pg, int zeStart, int zeStop);
106 int getStart() const;
110 std::string __str__() const
112 return self->printSelf();
116 ~ContigPartDefinition();
119 class NonContigPartDefinition : public PartDefinition
122 NonContigPartDefinition(const PlayGround *pg, const std::vector<int>& ids);
123 std::vector<int> getIDs() const;
126 std::string __str__() const
128 return self->printSelf();
132 ~NonContigPartDefinition();
135 class AllPartDefinition : public PartDefinition
138 AllPartDefinition(const PlayGround *pg);
141 std::string __str__() const
143 return self->printSelf();
147 ~AllPartDefinition();
150 class PartDefinition;
152 class ForTestOmlyHPContCls
155 std::string getContainerType() const;
156 std::vector<int> getIDS() const;
159 PyObject *getPD() const
161 const PartDefinition *ret(self->getPD());
164 return convertPartDefinition(const_cast<PartDefinition *>(ret));