Line data Source code
1 : /////////////////////////////////////////////////////////////////////////// 2 : // Spetabaru - Berenger Bramas MPCDF - 2017 3 : // Under LGPL Licence, please you must read the LICENCE file. 4 : /////////////////////////////////////////////////////////////////////////// 5 : 6 : #include "UTester.hpp" 7 : #include "utestUtils.hpp" 8 : 9 : #include "Data/SpDataAccessMode.hpp" 10 : #include "Utils/SpUtils.hpp" 11 : #include "Utils/SpArrayView.hpp" 12 : #include "Utils/SpArrayAccessor.hpp" 13 : 14 : #include "Task/SpTask.hpp" 15 : #include "Legacy/SpRuntime.hpp" 16 : 17 : class TestPartialMerge : public UTester< TestPartialMerge > { 18 : using Parent = UTester< TestPartialMerge >; 19 : 20 : template <SpSpeculativeModel Spm> 21 3 : void Test(){ 22 6 : SpRuntime<Spm> runtime; 23 : 24 3 : runtime.setSpeculationTest([](const int /*inNbReadyTasks*/, const SpProbability& /*inProbability*/) -> bool{ 25 0 : return true; 26 : }); 27 : 28 3 : int a=0, b=0, c=0; 29 : 30 3 : std::promise<bool> promise1; 31 : 32 21 : runtime.task(SpPotentialWrite(a), SpPotentialWrite(b), [&promise1]([[maybe_unused]] int& param_a, [[maybe_unused]] int& param_b){ 33 3 : promise1.get_future().get(); 34 3 : return false; 35 : }); 36 : 37 6 : runtime.task(SpPotentialWrite(c), []([[maybe_unused]] int& param_c){ 38 3 : return false; 39 : }); 40 : 41 8 : runtime.task(SpPotentialWrite(a), SpPotentialWrite(c), []([[maybe_unused]] int& param_a, [[maybe_unused]] int& param_c){ 42 5 : return false; 43 : }); 44 : 45 3 : promise1.set_value(true); 46 : 47 3 : runtime.waitAllTasks(); 48 3 : runtime.stopAllThreads(); 49 : 50 3 : runtime.generateDot("/tmp/testPartialMerge" + std::to_string(static_cast<int>(Spm)) + ".dot", true); 51 3 : } 52 : 53 1 : void Test1() { Test<SpSpeculativeModel::SP_MODEL_1>(); } 54 1 : void Test2() { Test<SpSpeculativeModel::SP_MODEL_2>(); } 55 1 : void Test3() { Test<SpSpeculativeModel::SP_MODEL_3>(); } 56 : 57 1 : void SetTests() { 58 1 : Parent::AddTest(&TestPartialMerge::Test1, "Partial merge test for model 1"); 59 1 : Parent::AddTest(&TestPartialMerge::Test2, "Partial merge test for model 2"); 60 1 : Parent::AddTest(&TestPartialMerge::Test3, "Partial merge test for model 3"); 61 1 : } 62 : }; 63 : 64 : // You must do this 65 1 : TestClass(TestPartialMerge) 66 : 67 :