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 : 8 : #include "Data/SpDataAccessMode.hpp" 9 : #include "Utils/SpUtils.hpp" 10 : 11 : #include "Task/SpTask.hpp" 12 : #include "Legacy/SpRuntime.hpp" 13 : 14 : class TestSelectActivationLogic : public UTester< TestSelectActivationLogic> { 15 : using Parent = UTester< TestSelectActivationLogic >; 16 : 17 : template <SpSpeculativeModel Spm> 18 3 : void Test(){ 19 3 : int a=0, b=0; 20 6 : std::promise<bool> promise1; 21 : 22 3 : SpRuntime<Spm> runtime; 23 : 24 3 : runtime.setSpeculationTest([](const int /*inNbReadyTasks*/, const SpProbability& /*inProbability*/) -> bool{ 25 0 : return true; 26 : }); 27 : 28 12 : runtime.task(SpPotentialWrite(a), [&promise1]([[maybe_unused]] int ¶m_a) -> bool{ 29 3 : promise1.get_future().get(); 30 3 : return false; 31 : }); 32 : 33 19 : runtime.task(SpRead(a), SpPotentialWrite(b), [](const int ¶m_a, int ¶m_b) -> bool{ 34 3 : bool res = false; 35 3 : if(param_a == 0) { 36 3 : param_b = 1; 37 3 : res = true; 38 : } 39 3 : return res; 40 : }); 41 : 42 3 : promise1.set_value(true); 43 : 44 3 : runtime.waitAllTasks(); 45 3 : runtime.stopAllThreads(); 46 : 47 3 : UASSERTEEQUAL(b, 1); 48 3 : } 49 : 50 1 : void Test1() { Test<SpSpeculativeModel::SP_MODEL_1>(); } 51 1 : void Test2() { Test<SpSpeculativeModel::SP_MODEL_2>(); } 52 1 : void Test3() { Test<SpSpeculativeModel::SP_MODEL_3>(); } 53 : 54 1 : void SetTests() { 55 1 : Parent::AddTest(&TestSelectActivationLogic::Test1, "Test behavior of select activation logic in model 1"); 56 1 : Parent::AddTest(&TestSelectActivationLogic::Test2, "Test behavior of select activation logic in model 2"); 57 1 : Parent::AddTest(&TestSelectActivationLogic::Test3, "Test behavior of select activation logic in model 3"); 58 1 : } 59 : }; 60 : 61 : // You must do this 62 1 : TestClass(TestSelectActivationLogic)