Changeset 3855 in Sophya for trunk/SophyaLib/SysTools/parlex.cc
- Timestamp:
- Aug 12, 2010, 1:02:24 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/SysTools/parlex.cc
r3730 r3855 11 11 12 12 /*! 13 \class ParallelTaskInterface 14 \ingroup SysTools 15 \brief Interface definition for parallel task object. 16 17 The pure virtual method execute() should be redefined by the classes 18 inheriting from ParallelTaskInterface 19 */ 20 ParallelTaskInterface::ParallelTaskInterface() 21 { 22 setNbParallelThreads(0); 23 } 24 ParallelTaskInterface::~ParallelTaskInterface() 25 { 26 } 27 /*! 28 \brief Define the number of parallel threads running to perform the task 29 30 This method is called by ParallelExecutor object. If subclasses overwrite this method, 31 base class method should be called to set the value of nbparallel_ attribute. 32 */ 33 void ParallelTaskInterface::setNbParallelThreads(int nbparthr) 34 { 35 nbparallel_=nbparthr; 36 } 37 38 /*! 13 39 \class ParallelTaskFunction 14 40 \ingroup SysTools 15 41 \brief ParallelTaskInterface implementation for functions 42 43 The function which are executed by the ParallelTaskFunction execute() method should 44 conform to the prototype: int func(int tid, int nparthr) 45 46 tid (counting from zero) is the thread rank, and nparthr the number of parallel threads 47 executing in the context 16 48 */ 17 49 //! Constructor with the specification of the function to be executed … … 22 54 int ParallelTaskFunction::execute(int tid) 23 55 { 24 return parfunc_(tid );56 return parfunc_(tid, getNbParallelThreads()); 25 57 } 26 58 … … 184 216 vrc_[i] = 0; 185 217 } 218 ptask.setNbParallelThreads( nthr ); 186 219 } 187 220 … … 195 228 { 196 229 if (vptask.size()<1) throw ParmError("ParallelExecutor(vector<ptask>/Error vptask.size()<1"); 230 int nthr= (int)nThreads(); 197 231 for(size_t i=0; i<vpext_.size(); i++) { 198 232 vpext_[i] = new ParalExThread( (*vptask[i]), i); 233 vptask[i]->setNbParallelThreads(nthr); 199 234 vrc_[i] = 0; 200 235 } … … 219 254 for(size_t i=0; i<vpext_.size(); i++) 220 255 vpext_[i]->setParallelTask(ptask); 256 ptask.setNbParallelThreads( (int)nThreads() ); 221 257 return; 222 258 } … … 229 265 if (vptask.size()!=vpext_.size()) 230 266 throw SzMismatchError("ParallelExecutor::SetParallelTask(vector<ptask>) - vptask.size()!=vpext.size()"); 231 for(size_t i=0; i<vpext_.size(); i++) 267 int nthr= (int)nThreads(); 268 for(size_t i=0; i<vpext_.size(); i++) { 232 269 vpext_[i]->setParallelTask(*vptask[i]); 270 vptask[i]->setNbParallelThreads(nthr); 271 } 233 272 return; 234 273 }
Note:
See TracChangeset
for help on using the changeset viewer.