Line data Source code
1 : /////////////////////////////////////////////////////////////////////////// 2 : // Spetabaru - Berenger Bramas MPCDF - 2017 3 : // Under LGPL Licence, please you must read the LICENCE file. 4 : /////////////////////////////////////////////////////////////////////////// 5 : #ifndef SPDOTDAT_HPP 6 : #define SPDOTDAT_HPP 7 : 8 : #include <fstream> 9 : #include <set> 10 : 11 : #include "Task/SpAbstractTask.hpp" 12 : #include "Utils/SpTimePoint.hpp" 13 : #include "Utils/small_vector.hpp" 14 : 15 : 16 : namespace SpDotDag { 17 : 18 21 : inline void GenerateDot(const std::string& outputFilename, const std::list<SpAbstractTask*>& tasksFinished, bool printAccesses) { 19 : // dot -Tpdf /tmp/graph.dot -o /tmp/fichier.pdf 20 42 : std::ofstream outputWriter(outputFilename); 21 : 22 21 : if(outputWriter.is_open() == false){ 23 0 : throw std::invalid_argument("Cannot open filename : " + outputFilename); 24 : } 25 : 26 21 : outputWriter << "digraph G {\n"; 27 : 28 42 : small_vector<SpAbstractTask*> deps; 29 : 30 792 : for(const auto& atask : tasksFinished){ 31 771 : atask->getDependences(&deps); 32 : 33 1542 : std::set<SpAbstractTask*> alreadyExist; 34 : 35 2235 : for(const auto& taskDep : deps){ 36 1464 : if(alreadyExist.find(taskDep) == alreadyExist.end()){ 37 1430 : outputWriter << "\t" << atask->getId() << " -> " << taskDep->getId() << "\n"; 38 1430 : alreadyExist.insert(taskDep); 39 : } 40 : } 41 : 42 771 : outputWriter << "\t" << atask->getId() << " [label=\"" << atask->getTaskName() << (atask->isTaskEnabled()?"":" (Disabled)"); 43 : 44 771 : if(printAccesses) { 45 125 : outputWriter << std::endl << atask->getTaskBodyString() << "\"];\n"; 46 : } else { 47 646 : outputWriter << "\"];\n"; 48 : } 49 : 50 771 : deps.clear(); 51 : } 52 : 53 21 : outputWriter << "}\n"; 54 21 : } 55 : 56 : } 57 : 58 : 59 : #endif