Top Up Prev Next Bottom Contents Index Search

15.3 Class ParScheduler


Class ParScheduler is derived from class SDFScheduler, thus inherits the most parts of setup method. They include initialization of galaxy and computation of the repetition counters of all stars in the SDF graph. It redefines the scheduling part of the set-up stage (computeSchedule).

int computeSchedule(Galaxy& g); 
Is a protected method to schedule the graph with given number of processors. The procedure is

(1) Let the target class do preparation steps if necessary before scheduling begins.

(2) Check whether the number of processors is 1 or not. If it is 1, we use the single processor scheduling (SDFScheduler :: computeSchedule). After we set the target pointer of each star, return.

(3) Form the APEG of the argument galaxy, and set the total execution time of the graph to a protected member totalWork.

(4) Set the target pointer of each UniProcessor class .

void mapTargets(IntArray* array = 0);

If no argument is given, assign the child targets to the UniProcessors sequentially. If the IntArray argument maps the child targets to the UniProcessors. If array[1] = 2, UniProcessor 1 is assigned Target 2.

(5) Before the main scheduling begins, complete the profile information of wormholes. Since we may want to perform more tasks before scheduling, make this protected method virtual. Be default, return TRUE to indicate no error occurs.

virtual int preSchedule();

(6) Perform scheduling by calling mainSchedule.

int mainSchedule(); 
This public method first checks whether manual assignment is requested or not. If it is, do manual assignment. Otherwise, call an automatic scheduling routine which will be redefined in each derived class, actual scheduling class. After scheduling is performed, set the procId parameter of the stars in the original galaxy if all invocations are enforced to be assigned to the same processor .

int assignManually(); 
Is a protected method to return TRUE if manual assignment is requested, or return FALSE otherwise.

virtual int scheduleManually(); 
Is a public virtual method. This method first checks whether all stars are assigned to processors (procId parameter of a star should be non-negative and smaller than the number of processors). If there is any star unassigned, return FALSE. All invocations of a star is set the same procId parameter. Based on that assignment, perform the list scheduling . The procId of a Fork star is determined by its ancestor. If the ancestor is a wormhole, the procId of the Fork should be given explicitly as other stars.

virtual int scheduleIt(); 
Is a public virtual method for automatic scheduling. Refer to the derived schedulers. By default, it does nothing and return FALSE to indicate that the actual scheduling is not done in this class.

int OSOPreq(); 
Is a protected method to return TRUE or FALSE, based on whether all invocations are enforced to be scheduled on the same processor.

Now, all methods necessary for step (5) are explained. Go back to the next step.

(7) As the final step, we schedule the inside of wormholes based on the main scheduling result if automatic scheduling option is taken. In the main scheduling routine, we will determine how many processors will be assigned to a wormhole.

int finalSchedule(); 
If scheduling of wormholes succeeds, return TRUE. Otherwise, return FALSE.

15.3.1 compileRun method

void compileRun(); 
Is a redefined public method of SDFScheduler class. It first checks the number of processors. If the number is 0, it just calls SDFScheduler :: compileRun. This case occurs inside a wormhole. Otherwise,

(1) Set the target pointer of UniProcessors.

(2) Create sub-universes for each processors.

int createSubGals(Galaxy& g); 
Is a public method. It first checks whether all invocations of stars are scheduled on the same processor, and set the flag if it is the case. After restoring all hidden EGGates of the APEG, create sub-universes.

(3) Prepare each processor (or UniProcessor class) for code generation. It includes sub-universe initialization, and simulation of the schedule on the processor obtained from the parallel scheduling.

(4) Let the target do something necessary, if any, before generating code.

(5) Generate code for all processors.

15.3.2 Other ParScheduler protected members

const char* logFile; 
pt_ofstream logstrm_real;
ostream* logstrm;
These are for logging information. logFile indicates where to store the logging information.

MultiTarget* mtarget; 
Is the pointer to the target object, which is MultiTarget type.

int numProcs; 
Is the total number of processors.

ParGraph *exGraph 
Is the pointer to the APEG used as the input graph to the scheduler.

ParProcessors* parProcs; 
This member points the actual scheduler object. It will be set up in the setUpProcs method of the derived class.

IntArray avail; 
This array is to monitor the pattern of processor availability during scheduling.

int inUniv; 
This flag is set TRUE when it is the scheduler of a universe, not a wormhole. In the latter case, it is set FALSE. By default, it is set TRUE.

int withParallelStar(); 
This method returns TRUE or FALSE, based on whether the galaxy contains any wormhole or data-parallel star, or not.

int overrideSchedule(); 
If the user wants to override the scheduling result after automatic scheduling, he can set the adjustSchedule parameter of the target object. This method pokes the value of that parameter. This is one of the future feature, not implemented yet in Ptolemy due to limitation of the graphical interface, pigi.

15.3.3 Other ParScheduler public members

ParScheduler(MultiTarget* t, const char* log = 0); 
virtual ~ParScheduler();
The constructor has two arguments: the target pointer and the name of log file name. The virtual destructor does nothing.

virtual void setUpProcs(int num); 
The number of processors is given as an argument to this method. It will initialize the avail array. In the derived class, this method will create a ParProcessors class (set parProcs member).

ParProcessors* myProcs();
UniProcessor* getProc(int n);
These methods will return the pointer to the ParProcessors object associated with this scheduler and the UniProcessor object indexed by the argument. The range of the index is 0 to numProcs-1.

void ofWorm(); 
Resets inUniv flag to FALSE.

int getTotalWork(); 
Returns the total execution time of the graph.

void setProfile(Profile* profile); 
Copy the scheduling results to the argument Profile . If the scheduling is inside a wormhole, the scheduling results should be passed to the outside of the wormhole by a Profile object.



Top Up Prev Next Bottom Contents Index Search

ptolemy@eecs.berkeley.edu
Copyright © 1990-1997, University of California. All rights reserved.