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 TestCallableWrappers : public UTester< TestCallableWrappers > { 18 : using Parent = UTester< TestCallableWrappers >; 19 : 20 : template <SpSpeculativeModel Spm> 21 1 : void Test(){ 22 1 : SpRuntime<Spm> runtime; 23 : 24 1 : runtime.setSpeculationTest([](const int /*inNbReadyTasks*/, const SpProbability& /*inProbability*/) -> bool{ 25 0 : return true; 26 : }); 27 : 28 1 : int a=0; 29 : 30 7 : runtime.task(SpWrite(a), [](int& param_a){ 31 1 : param_a++; 32 : }); 33 : 34 1 : runtime.task(SpWrite(a), SpCpu([](int& param_a){ 35 1 : param_a++; 36 : })); 37 : 38 1 : runtime.task(SpWrite(a), 39 1 : [](int& param_a){ 40 1 : param_a++; 41 : }, 42 1 : SpGpu([](int& param_a){ 43 : param_a++; 44 : })); 45 : 46 1 : runtime.task(SpWrite(a), 47 1 : SpCpu([](int& param_a){ 48 1 : param_a++; 49 : }), 50 1 : SpGpu([](int& param_a){ 51 : param_a++; 52 : })); 53 : 54 1 : runtime.task(SpWrite(a), 55 1 : SpGpu([](int& param_a){ 56 : param_a++; 57 : }), 58 1 : [](int& param_a){ 59 1 : param_a++; 60 : }); 61 : 62 1 : runtime.task(SpWrite(a), 63 1 : SpGpu([](int& param_a){ 64 : param_a++; 65 : }), 66 1 : SpCpu([](int& param_a){ 67 1 : param_a++; 68 : })); 69 : 70 1 : runtime.waitAllTasks(); 71 1 : runtime.stopAllThreads(); 72 : 73 1 : UASSERTETRUE(a == 6); 74 : 75 1 : } 76 : 77 1 : void Test1() { Test<SpSpeculativeModel::SP_MODEL_1>(); } 78 : 79 1 : void SetTests() { 80 1 : Parent::AddTest(&TestCallableWrappers::Test1, "Test callable wrappers."); 81 1 : } 82 : }; 83 : 84 : // You must do this 85 1 : TestClass(TestCallableWrappers) 86 : 87 :