Skip to content
Jonathan Beard edited this page May 2, 2016 · 1 revision

So there's this exe() function implemented within the map.hpp file. It is actually a template function which looks something like this:

template< class scheduler           = simple_schedule, 
          class allocator           = dynalloc,
          class parallelism_monitor = basic_parallel > 
   void exe()
{
   //some implementation
}

The main reason to have these template parameters is to swap out the scheduler, allocator, and parallelization implementation quickly...if needed by the end programmer. Almost all the examples I've shown in the code (in fact all of the ones as of this writing) use the default template parameters, however I expect that won't always be the case as more of these "plug-ins" are developed. We'll break each one of these down, along with the plug-in interface for each.

Starting at the entrance to the function, it:

  • Breaks sub-maps that were added into this map, into their substituent compute kernels so that this map may schedule them.
  • The map is checked for connectivity using functions found in graphtools.hpp to performa a search through the graph for unconnected edges (remember, we've already done a type check at link time).
  • The partitioner is run (TODO, currently in the scheduler) to decide where to run and how to run each compute kernel within the system.
  • Next, the allocator is instantiated and invoked on its own thread. The time of thread termination is really up to the actual allocator. The main reason to have this is to dynamically monitor the health of the allocations throughout the system. The least the allocator must do, is traverse the graph and allocate memory for the compute kernel edges.
  • The scheduler is then run on its own thread which, kicks off the computation for each compute kernel. It can monitor the performance health of the system and attempt to optimize the mapping/scheduling. Think of the first partitioning as a best effort, this is a low communications overhead fine tuning.
  • The parallelism monitor is again, run on its own thread. This thread is intended to monitor the number of parallelizable compute kernels in the system (i.e., when more compute resources are available, the graph can be expanded to take advantage of them). In the future, multi-node systems could potentially have QoS features as well.

##Classes ###class scheduler The scheduler interface is that of a simple start function (named differently than the other "run" functions) to denote that we're actually starting the computation. The constructor parameter of the whole application map should be more than sufficient to enable scheduling of the application.

class simple_schedule : public Schedule
{
public:
   simple_schedule( raft::map &map );

   virtual ~simple_schedule();

   virtual void start(); 

###class allocator The allocator interface runs, and continues running internally. It is terminated externally once the scheduler thread exits via the exit_alloc variable.

class stdalloc : public Allocate
{
public:
   /**
    * @param map - Map&, map with full application
    * @param exit_alloc - bool whose value is set by the map object
    * owning this one.  Controls when the loop within the run thread
    * is exited.
    */
   stdalloc( raft::map &map, volatile bool &exit_alloc  );
   /**
    * destructor, doesn't really do much at he moment.
    */
   virtual ~stdalloc();
   /**
    * run - call within a thread, internally we could have a loop before exiting 
    * but this version simply allocates and exits.  
    */
   virtual void run();

###class parallelism_monitor The interface expected by the parallelism_monitor looks like this. It's quite simple (intentionally), and the constructor params give the monitor class enough information to perform its job. It is terminated externally via the exit_para variable once scheduler.join() returns.

class basic_parallel
{
public:
   basic_parallel( raft::map &map, 
                   Allocate &alloc,
                   Schedule &sched,
                   volatile bool &exit_para );

   virtual ~basic_parallel() = default;
   virtual void start();