Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/vis15/src/lib/include/diderot/parallel.hxx
ViewVC logotype

Diff of /branches/vis15/src/lib/include/diderot/parallel.hxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4796, Mon Oct 24 11:39:31 2016 UTC revision 4797, Mon Oct 24 16:59:27 2016 UTC
# Line 30  Line 30 
30    
31  #include <pthread.h>  #include <pthread.h>
32  #include "barrier.hxx"  #include "barrier.hxx"
33    #include "worker-gate.hxx"
34    
35  namespace diderot {  namespace diderot {
36    
37      struct scheduler {      struct scheduler {
38          using task = void (*)(void *);          using task = void (*)(void *);
39    
40            struct worker_info {
41                uint32_t            _id;            //!< index into thread _info[] array
42                world_base          *_wrld;         //!< world pointer
43                scheduler           *_sched;        //!< scheduler data pointer
44                void                *_data;         //!< per-worker data pointer for current task
45            };
46    
47                                             // information about the available CPUs                                             // information about the available CPUs
48          int             _numHWNodes;            //!< \brief number of (possibly multicore) processors          int             _numHWNodes;            //!< \brief number of (possibly multicore) processors
49          int             _numHWCores;            //!< \brief total number of (possibly          int             _numHWCores;            //!< \brief total number of (possibly
# Line 43  Line 52 
52          int             _numCoresPerNode;       //!< \brief number of cores per thread          int             _numCoresPerNode;       //!< \brief number of cores per thread
53          int             _numThdsPerCore;        //!< \brief number of threads per core          int             _numThdsPerCore;        //!< \brief number of threads per core
54    
55          uint32_t        _numWorkers;            //!< number of worker threads to use          uint32_t        _numWorkers;            //!< number of worker threads in the pool; this is
56                                                    //!  decremented as workers terminate
57          pthread_t       *_workers;              //!< thread IDs of workers          pthread_t       *_workers;              //!< thread IDs of workers
58            worker_info     *_info;                 //!< per-thread info structure
59          task            _task;                  //!< holds current task for workers          task            _task;                  //!< holds current task for workers
60          uint32_t        _workSize;              //!< size of a block of work          uint32_t        _workSize;              //!< size of a block of work
61          bool            _done;                  //!< flag to signal that the program is done.          bool            _done;                  //!< flag to signal that the program is done.
62    
63          uint32_t        _nextStrand CACHE_ALIGN;//!< index of next strand to update          pthread_mutex_t _lock;                  //!< lock to protect _runWait
64          uint32_t        _nactive CACHE_ALIGN;   //!< # active strands          pthread_cond_t  _runWait;               //!< used by workers to signal termination
65          uint32_t        _nstable CACHE_ALIGN;   //!< # stable strands          worker_gate     _gate;                  //!< gate for coordinator/worker synchronization
66          uint32_t        _navail CACHE_ALIGN;    //!< # unevaluated strands          barrier         _coordBar;              //!< barrier for coordinating between workers and
67          uint32_t        _nidle CACHE_ALIGN;     //!< # idle workers                                                  //!< coordinator thread
68          uint32_t        _nsteps CACHE_ALIGN;    //!< # of steps taken          barrier         _bspBar;                //!< barrier to implement BSP semantics
   
         pthread_mutex_t _lock;                  //!< big lock to protect wrld from multiple accesses  
         pthread_cond_t  _runWait;               //!< used to signal run that the workers  
                                                 //!  have finished  
         barrier         _barrier;               //!< workers wait on this when they have no work  
69    
70          scheduler ();          scheduler ();
71          ~scheduler ();          ~scheduler ();
# Line 68  Line 74 
74        //! \return true if there is an error        //! \return true if there is an error
75          bool get_cpu_info (world_base *wrld);          bool get_cpu_info (world_base *wrld);
76    
77      };        //! \brief create the pool of workers
78          //! \param wrld thw world
79          //! \param nw the requested number of workers.
80          //! \return true if there is an error
81            bool create_workers (world_base *wrld, uint32_t nw);
82    
83          //! \brief shut down the workers
84            void shutdown ();
85    
     struct worker_info {  
         int             _id;  
         struct world    *_wrld;  
         scheduler       *_sched;  
86      };      };
87    
88  } // namespace diderot  } // namespace diderot

Legend:
Removed from v.4796  
changed lines
  Added in v.4797

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0