Commit 960831ed authored by CARDOSI Paul's avatar CARDOSI Paul
Browse files

Merge branch 'fast-path' into 'master'

Allow the user to create non speculative task graphs

See merge request bramas/spetabaru!31
parents b36de8d3 baa42549
......@@ -12,6 +12,7 @@
#include "Tasks/SpAbstractTask.hpp"
#include "Utils/SpTimePoint.hpp"
#include "Utils/small_vector.hpp"
#include "Random/SpMTGenerator.hpp"
namespace SpSvgTrace {
......
......@@ -2,6 +2,7 @@
#define SPSPECULATIVEMODEL_HPP
enum class SpSpeculativeModel {
SP_NO_SPEC,
SP_MODEL_1,
SP_MODEL_2,
SP_MODEL_3
......
......@@ -2,19 +2,21 @@
#define SPABSTRACTTASKGRAPH_HPP
#include "Schedulers/SpTasksManager.hpp"
#include "Output/SpDotDag.hpp"
#include "Output/SpSvgTrace.hpp"
class SpComputeEngine;
class SpAbstractTask;
class SpAbstractTaskGraph {
protected:
//! Creation time point
SpTimePoint startingTime;
//! Internal scheduler of tasks
SpTasksManager scheduler;
public:
void computeOn(SpComputeEngine& inCe) {
scheduler.setComputeEngine(std::addressof(inCe));
}
protected:
void preTaskExecution(SpAbstractTask* t) {
scheduler.preTaskExecution(t);
......@@ -23,6 +25,13 @@ public:
void postTaskExecution(SpAbstractTask* t) {
scheduler.postTaskExecution(t);
}
friend void SpWorker::doLoop(SpAbstractTaskGraph*);
public:
void computeOn(SpComputeEngine& inCe) {
scheduler.setComputeEngine(std::addressof(inCe));
}
void waitAllTasks(){
scheduler.waitAllTasks();
......@@ -37,6 +46,18 @@ public:
bool isFinished() const {
return scheduler.isFinished();
}
void generateDot(const std::string& outputFilename, bool printAccesses=false) const {
SpDotDag::GenerateDot(outputFilename, scheduler.getFinishedTaskList(), printAccesses);
}
void generateTrace([[maybe_unused]] const std::string& outputFilename, [[maybe_unused]] const bool showDependences = true) const {
const SpComputeEngine * ce = scheduler.getComputeEngine();
if(ce) {
SpSvgTrace::GenerateTrace(outputFilename, scheduler.getFinishedTaskList(), startingTime, showDependences);
}
}
};
......
This diff is collapsed.
......@@ -9,7 +9,7 @@
#include "Tasks/SpTask.hpp"
#include "Runtimes/SpRuntime.hpp"
// @NBTESTS = 5
// @NBTESTS = 7
int main(){
const int NumThreads = SpUtils::DefaultNumThreads();
......@@ -54,4 +54,22 @@ int main(){
runtime.waitAllTasks();
runtime.stopAllThreads();
SpTaskGraph<SpSpeculativeModel::SP_NO_SPEC> tg;
#ifdef TEST6
tg.task(SpProbability(0.5), SpRead(initVal), SpCpu([](const double&p) {}));
#endif
#idef TEST7
tg.task(SpPriority(10), SpRead(initVal), SpMaybeWrite(writeVal),
SpCpu([](const auto& rParam, auto& wParam) -> bool {
if(rParam == 0.5) {
wParam = 2.0;
return true;
}
return false;
});
#endif
}
///////////////////////////////////////////////////////////////////////////
// Spetabaru - Berenger Bramas MPCDF - 2017
// Under LGPL Licence, please you must read the LICENCE file.
///////////////////////////////////////////////////////////////////////////
#include "UTester.hpp"
#include "Utils/SpModes.hpp"
#include "Utils/SpUtils.hpp"
#include "Tasks/SpTask.hpp"
#include "TaskGraph/SpTaskGraph.hpp"
#include "Compute/SpComputeEngine.hpp"
#include "Compute/SpWorker.hpp"
class SimpleTestNoSpec : public UTester< SimpleTestNoSpec > {
using Parent = UTester< SimpleTestNoSpec >;
void TestBasic(){
SpComputeEngine ce(SpWorker::createDefaultWorkerTeam());
SpTaskGraph<SpSpeculativeModel::SP_NO_SPEC> tg;
tg.computeOn(ce);
const int initVal = 1;
int writeVal = 0;
tg.task(SpRead(initVal),
[this, &initVal](const int& initValParam){
UASSERTETRUE(&initValParam == &initVal);
});
tg.task(SpRead(initVal), SpWrite(writeVal),
[](const int& initValParam, int& writeValParam){
writeValParam += initValParam;
});
tg.task(SpRead(writeVal),
[this](const int& writeValParam){
UASSERTETRUE(writeValParam == initVal);
});
tg.waitAllTasks();
}
void SetTests() {
Parent::AddTest(&SimpleTestNoSpec::TestBasic, "Basic test for non speculative task graphs");
}
};
// You must do this
TestClass(SimpleTestNoSpec)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment