setupmethod. 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 (
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
(4) Set the target pointer of each UniProcessor class .
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 = 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
TRUEto indicate no error occurs.
virtual int preSchedule();
(6) Perform scheduling by calling
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
procIdparameter 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
TRUEif manual assignment is requested, or return
virtual int scheduleManually();Is a public virtual method. This method first checks whether all stars are assigned to processors (
procIdparameter 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
procIdparameter. Based on that assignment, perform the list scheduling . The
procIdof a Fork star is determined by its ancestor. If the ancestor is a wormhole, the
procIdof 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
FALSEto indicate that the actual scheduling is not done in this class.
int OSOPreq();Is a protected method to return
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
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.
const char* logFile;These are for logging information.
logFileindicates 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 *exGraphIs 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
setUpProcsmethod of the derived class.
IntArray avail;This array is to monitor the pattern of processor availability during scheduling.
int inUniv;This flag is set
TRUEwhen it is the scheduler of a universe, not a wormhole. In the latter case, it is set
FALSE. By default, it is set
int withParallelStar();This method returns
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
adjustScheduleparameter 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.
ParScheduler(MultiTarget* t, const char* log = 0);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
availarray. In the derived class, this method will create a ParProcessors class (set
ParProcessors* myProcs();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
UniProcessor* getProc(int n);
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.