2023-06-15 03:51:07 +02:00
|
|
|
/*
|
|
|
|
|
JobPlanning(Test) - data evaluation for frame job creation
|
|
|
|
|
|
|
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2023, Hermann Vosseler <Ichthyostega@web.de>
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
|
|
|
|
published by the Free Software Foundation; either version 2 of
|
|
|
|
|
the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
|
|
* *****************************************************/
|
|
|
|
|
|
|
|
|
|
/** @file job-planning-test.cpp
|
|
|
|
|
** unit test \ref JobPlanning_test
|
|
|
|
|
**
|
|
|
|
|
** @warning as of 4/2023 a complete rework of the Dispatcher is underway ///////////////////////////////////////////TICKET #1275
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "lib/test/run.hpp"
|
|
|
|
|
#include "lib/error.hpp"
|
|
|
|
|
|
|
|
|
|
//#include "steam/engine/procnode.hpp"
|
|
|
|
|
//#include "steam/play/dummy-play-connection.hpp"
|
|
|
|
|
//#include "steam/mobject/model-port.hpp"
|
2023-06-16 01:50:11 +02:00
|
|
|
#include "steam/engine/mock-dispatcher.hpp"
|
2023-06-15 03:51:07 +02:00
|
|
|
#include "steam/play/timings.hpp"
|
|
|
|
|
#include "lib/time/timevalue.hpp"
|
|
|
|
|
//#include "lib/time/timequant.hpp"
|
2023-06-16 04:09:38 +02:00
|
|
|
#include "lib/format-cout.hpp" ///////////////TODO
|
2023-06-15 03:51:07 +02:00
|
|
|
//#include "lib/depend.hpp"
|
|
|
|
|
//#include "lib/itertools.hpp"
|
|
|
|
|
//#include "lib/util-coll.hpp"
|
|
|
|
|
//#include "lib/util.hpp"
|
|
|
|
|
|
|
|
|
|
//#include <functional>
|
|
|
|
|
//#include <vector>
|
|
|
|
|
|
|
|
|
|
using test::Test;
|
|
|
|
|
//using util::isnil;
|
|
|
|
|
//using util::last;
|
|
|
|
|
//using std::vector;
|
|
|
|
|
//using std::function;
|
|
|
|
|
//using std::rand;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace steam {
|
|
|
|
|
namespace engine{
|
|
|
|
|
namespace test {
|
|
|
|
|
|
2023-06-16 01:50:11 +02:00
|
|
|
using lib::time::FrameRate;
|
2023-06-15 03:51:07 +02:00
|
|
|
// using lib::time::Duration;
|
2023-06-17 03:10:57 +02:00
|
|
|
using lib::time::Offset;
|
2023-06-15 03:51:07 +02:00
|
|
|
// using lib::time::TimeVar;
|
2023-06-17 03:10:57 +02:00
|
|
|
using lib::time::Time;
|
2023-06-15 03:51:07 +02:00
|
|
|
// using mobject::ModelPort;
|
2023-06-17 03:10:57 +02:00
|
|
|
using play::Timings;
|
2023-06-15 03:51:07 +02:00
|
|
|
|
|
|
|
|
namespace { // used internally
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ModelPort
|
|
|
|
|
// getTestPort()
|
|
|
|
|
// {
|
|
|
|
|
// return mockDispatcher().provideMockModelPort();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // (End) internal defs
|
|
|
|
|
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #1301
|
|
|
|
|
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #1301
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************//**
|
|
|
|
|
* @test document and verify the data aggregation and the calculations
|
|
|
|
|
* necessary to prepare render jobs for scheduling.
|
|
|
|
|
* @todo WIP-WIP 6/2023
|
|
|
|
|
*/
|
|
|
|
|
class JobPlanning_test : public Test
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
virtual void
|
2023-06-17 03:10:57 +02:00
|
|
|
run (Arg)
|
2023-06-15 03:51:07 +02:00
|
|
|
{
|
|
|
|
|
simpleUsage();
|
|
|
|
|
calculateDeadline();
|
|
|
|
|
setupDependentJob();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @test demonstrate a simple usage scenario
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
simpleUsage()
|
|
|
|
|
{
|
2023-06-16 01:50:11 +02:00
|
|
|
MockDispatcher dispatcher;
|
|
|
|
|
play::Timings timings (FrameRate::PAL);
|
|
|
|
|
auto [port,sink] = dispatcher.getDummyConnection(1);
|
|
|
|
|
|
|
|
|
|
Time nominalTime{200,0};
|
|
|
|
|
size_t portIDX = dispatcher.resolveModelPort (port);
|
|
|
|
|
FrameCoord frame{nominalTime, portIDX};
|
|
|
|
|
JobTicket& ticket = dispatcher.getJobTicketFor(frame);
|
|
|
|
|
|
|
|
|
|
JobPlanning plan{frame,ticket,sink};
|
|
|
|
|
Job job = plan.buildJob();
|
|
|
|
|
|
|
|
|
|
CHECK (dispatcher.verify (job, port, sink));
|
2023-06-15 03:51:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @test verify the timing calculations to establish
|
|
|
|
|
* the scheduling deadline of a simple render job
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
calculateDeadline()
|
|
|
|
|
{
|
2023-06-16 04:09:38 +02:00
|
|
|
MockDispatcher dispatcher;
|
|
|
|
|
play::Timings timings (FrameRate::PAL, Time{0,0,5});
|
|
|
|
|
auto [port,sink] = dispatcher.getDummyConnection(1);
|
|
|
|
|
|
2023-06-17 03:10:57 +02:00
|
|
|
FrameCnt frameNr{5};
|
2023-06-16 04:09:38 +02:00
|
|
|
Time nominalTime{200,0};
|
|
|
|
|
size_t portIDX = dispatcher.resolveModelPort (port);
|
2023-06-17 03:10:57 +02:00
|
|
|
FrameCoord frame{nominalTime, frameNr, portIDX};
|
2023-06-16 04:09:38 +02:00
|
|
|
JobTicket& ticket = dispatcher.getJobTicketFor(frame);
|
|
|
|
|
|
|
|
|
|
JobPlanning plan{frame,ticket,sink};
|
2023-06-17 03:10:57 +02:00
|
|
|
|
|
|
|
|
// the following calculations are expected to happen....
|
|
|
|
|
Duration latency = ticket.getExpectedRuntime()
|
|
|
|
|
+ timings.currentEngineLatency()
|
|
|
|
|
+ timings.outputLatency;
|
|
|
|
|
|
|
|
|
|
Offset nominalOffset (timings.getFrameStartAt(0), timings.getFrameStartAt(frameNr));
|
|
|
|
|
Time expectedDeadline{timings.scheduledDelivery + nominalOffset - latency};
|
2023-06-16 04:09:38 +02:00
|
|
|
|
2023-06-17 03:10:57 +02:00
|
|
|
cout << util::_Fmt{"Frame #%d @ %s\n"
|
|
|
|
|
"real-time-origin : %s\n"
|
|
|
|
|
"total latency : %s\n"
|
|
|
|
|
"deadline : %s"}
|
|
|
|
|
% frameNr % nominalOffset
|
|
|
|
|
% timings.scheduledDelivery
|
|
|
|
|
% latency
|
|
|
|
|
% plan.determineDeadline(timings)
|
|
|
|
|
<< endl;
|
|
|
|
|
CHECK (plan.determineDeadline(timings) == expectedDeadline);
|
|
|
|
|
CHECK (timings.scheduledDelivery == Time(0,0,5) );
|
|
|
|
|
CHECK (timings.playbackUrgency == play::TIMEBOUND);
|
|
|
|
|
|
|
|
|
|
// But when switching form "timebound" to "best effort"...
|
2023-06-16 04:09:38 +02:00
|
|
|
timings.playbackUrgency = play::ASAP;
|
|
|
|
|
CHECK (Time::ANYTIME == plan.determineDeadline (timings));
|
2023-06-17 03:10:57 +02:00
|
|
|
// ... no deadline is calculated at all
|
2023-06-15 03:51:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @test verify the setup of a prerequisite job in relation
|
|
|
|
|
* to the master job depending on this prerequisite
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
setupDependentJob()
|
|
|
|
|
{
|
2023-06-16 04:09:38 +02:00
|
|
|
UNIMPLEMENTED ("chained deadlines");
|
2023-06-15 03:51:07 +02:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Register this test class... */
|
|
|
|
|
LAUNCHER (JobPlanning_test, "unit engine");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}}} // namespace steam::engine::test
|