File indexing completed on 2025-07-09 08:51:57
0001 #include "MultiLevelTopologyTests.h"
0002 #include "JANA/Engine/JExecutionEngine.h"
0003 #include "JANA/JException.h"
0004 #include "JANA/Topology/JArrow.h"
0005 #include "JANA/Topology/JTopologyBuilder.h"
0006
0007 #include <iostream>
0008 #include <map>
0009
0010 namespace jana {
0011 namespace timeslice_tests {
0012
0013
0014 TEST_CASE("TimeslicesTests_FineGrained") {
0015
0016 JApplication app;
0017 app.SetParameterValue("jana:loglevel", "trace");
0018 app.SetParameterValue("jana:nevents", "5");
0019 app.SetParameterValue("jana:max_inflight_events", "4");
0020
0021 app.Add(new MyTimesliceSource);
0022 app.Add(new MyTimesliceUnfolder);
0023 app.Add(new MyEventProcessor);
0024 app.Add(new JFactoryGeneratorT<MyProtoClusterFactory>);
0025 app.Add(new JFactoryGeneratorT<MyClusterFactory>);
0026 app.SetTicker(true);
0027
0028 app.Initialize();
0029 auto ee = app.GetService<JExecutionEngine>();
0030 auto top = app.GetService<JTopologyBuilder>();
0031 enum ArrowId {TS_SRC=0, TS_MAP=1, TS_UNF=2, TS_FLD=3, PH_MAP=4, PH_TAP=5};
0032 JArrow::FireResult result = JArrow::FireResult::NotRunYet;
0033
0034 result = ee->Fire(TS_SRC, 0);
0035 REQUIRE(result == JArrow::FireResult::KeepGoing);
0036
0037 REQUIRE(top->arrows[TS_SRC]->get_port(1).queue == top->queues[0]);
0038 REQUIRE(top->pools[0]->GetCapacity() == 4);
0039 REQUIRE(top->pools[0]->GetSize(0) == 3);
0040 REQUIRE(top->queues[0]->GetSize(0) == 1);
0041
0042 result = ee->Fire(TS_MAP, 0);
0043 REQUIRE(result == JArrow::FireResult::KeepGoing);
0044 REQUIRE(top->queues[0]->GetSize(0) == 0);
0045 REQUIRE(top->queues[1]->GetSize(0) == 1);
0046
0047
0048 result = ee->Fire(TS_UNF, 0);
0049 REQUIRE(result == JArrow::FireResult::KeepGoing);
0050
0051
0052 result = ee->Fire(TS_UNF, 0);
0053 REQUIRE(result == JArrow::FireResult::KeepGoing);
0054
0055 result = ee->Fire(PH_MAP, 0);
0056 REQUIRE(result == JArrow::FireResult::KeepGoing);
0057
0058 result = ee->Fire(PH_TAP, 0);
0059 REQUIRE(result == JArrow::FireResult::KeepGoing);
0060
0061 result = ee->Fire(TS_FLD, 0);
0062 REQUIRE(result == JArrow::FireResult::KeepGoing);
0063
0064 REQUIRE(top->pools[0]->GetSize(0) == 3);
0065 REQUIRE(top->pools[1]->GetSize(0) == 4);
0066
0067 }
0068
0069 TEST_CASE("TimeslicesTests") {
0070
0071 JApplication app;
0072 app.SetParameterValue("jana:loglevel", "trace");
0073 app.SetParameterValue("jana:nevents", "5");
0074
0075 app.Add(new MyTimesliceSource);
0076 app.Add(new MyTimesliceUnfolder);
0077 app.Add(new MyEventProcessor);
0078 app.Add(new JFactoryGeneratorT<MyProtoClusterFactory>);
0079 app.Add(new JFactoryGeneratorT<MyClusterFactory>);
0080 app.SetTicker(true);
0081 try {
0082 app.Run();
0083 }
0084 catch (JException& e) {
0085 std::cout << e << std::endl;
0086 throw e;
0087 }
0088 }
0089
0090
0091 }
0092 }
0093
0094
0095
0096
0097
0098