Line data Source code
1 : #ifndef SPABSTRACTTASKGRAPH_HPP 2 : #define SPABSTRACTTASKGRAPH_HPP 3 : 4 : #include "Scheduler/SpTaskManager.hpp" 5 : #include "Output/SpDotDag.hpp" 6 : #include "Output/SpSvgTrace.hpp" 7 : 8 : class SpComputeEngine; 9 : class SpAbstractTask; 10 : 11 : class SpAbstractTaskGraph { 12 : protected: 13 : //! Creation time point 14 : SpTimePoint startingTime; 15 : 16 : //! Internal scheduler of tasks 17 : SpTaskManager scheduler; 18 : 19 : protected: 20 : 21 1073 : void preTaskExecution(SpAbstractTask* t) { 22 1073 : scheduler.preTaskExecution(t); 23 1073 : } 24 : 25 1073 : void postTaskExecution(SpAbstractTask* t) { 26 1073 : scheduler.postTaskExecution(t); 27 1073 : } 28 : 29 : friend void SpWorker::doLoop(SpAbstractTaskGraph*); 30 : 31 : public: 32 52 : void computeOn(SpComputeEngine& inCe) { 33 52 : scheduler.setComputeEngine(std::addressof(inCe)); 34 52 : } 35 : 36 163 : void waitAllTasks(){ 37 163 : scheduler.waitAllTasks(); 38 163 : } 39 : 40 167 : void waitRemain(const long int windowSize){ 41 167 : scheduler.waitRemain(windowSize); 42 167 : } 43 : 44 : void finish(); 45 : 46 0 : bool isFinished() const { 47 0 : return scheduler.isFinished(); 48 : } 49 : 50 21 : void generateDot(const std::string& outputFilename, bool printAccesses=false) const { 51 21 : SpDotDag::GenerateDot(outputFilename, scheduler.getFinishedTaskList(), printAccesses); 52 21 : } 53 : 54 14 : void generateTrace([[maybe_unused]] const std::string& outputFilename, [[maybe_unused]] const bool showDependences = true) const { 55 14 : const SpComputeEngine * ce = scheduler.getComputeEngine(); 56 : 57 14 : if(ce) { 58 14 : SpSvgTrace::GenerateTrace(outputFilename, scheduler.getFinishedTaskList(), startingTime, showDependences); 59 : } 60 14 : } 61 : 62 : }; 63 : 64 : #endif