File indexing completed on 2025-01-18 10:17:43
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
0020 app.Add(new MyTimesliceSource);
0021 app.Add(new MyTimesliceUnfolder);
0022 app.Add(new MyEventProcessor);
0023 app.Add(new JFactoryGeneratorT<MyProtoClusterFactory>);
0024 app.Add(new JFactoryGeneratorT<MyClusterFactory>);
0025 app.SetTicker(true);
0026
0027 app.Initialize();
0028 auto ee = app.GetService<JExecutionEngine>();
0029 auto top = app.GetService<JTopologyBuilder>();
0030 enum ArrowId {TS_SRC=0, TS_MAP=1, TS_UNF=2, TS_FLD=3, PH_MAP=4, PH_TAP=5};
0031 JArrow::FireResult result = JArrow::FireResult::NotRunYet;
0032
0033 result = ee->Fire(TS_SRC, 0);
0034 REQUIRE(result == JArrow::FireResult::KeepGoing);
0035
0036 REQUIRE(top->arrows[TS_SRC]->get_port(1).queue == top->queues[0]);
0037 REQUIRE(top->pools[0]->GetCapacity() == 4);
0038 REQUIRE(top->pools[0]->GetSize(0) == 3);
0039 REQUIRE(top->queues[0]->GetSize(0) == 1);
0040
0041 result = ee->Fire(TS_MAP, 0);
0042 REQUIRE(result == JArrow::FireResult::KeepGoing);
0043 REQUIRE(top->queues[0]->GetSize(0) == 0);
0044 REQUIRE(top->queues[1]->GetSize(0) == 1);
0045
0046
0047 result = ee->Fire(TS_UNF, 0);
0048 REQUIRE(result == JArrow::FireResult::KeepGoing);
0049
0050
0051 result = ee->Fire(TS_UNF, 0);
0052 REQUIRE(result == JArrow::FireResult::KeepGoing);
0053
0054 result = ee->Fire(PH_MAP, 0);
0055 REQUIRE(result == JArrow::FireResult::KeepGoing);
0056
0057 result = ee->Fire(PH_TAP, 0);
0058 REQUIRE(result == JArrow::FireResult::KeepGoing);
0059
0060 result = ee->Fire(TS_FLD, 0);
0061 REQUIRE(result == JArrow::FireResult::KeepGoing);
0062
0063 REQUIRE(top->pools[0]->GetSize(0) == 3);
0064 REQUIRE(top->pools[1]->GetSize(0) == 4);
0065
0066 }
0067
0068 TEST_CASE("TimeslicesTests") {
0069
0070 JApplication app;
0071 app.SetParameterValue("jana:loglevel", "trace");
0072 app.SetParameterValue("jana:nevents", "5");
0073
0074 app.Add(new MyTimesliceSource);
0075 app.Add(new MyTimesliceUnfolder);
0076 app.Add(new MyEventProcessor);
0077 app.Add(new JFactoryGeneratorT<MyProtoClusterFactory>);
0078 app.Add(new JFactoryGeneratorT<MyClusterFactory>);
0079 app.SetTicker(true);
0080 try {
0081 app.Run();
0082 }
0083 catch (JException& e) {
0084 std::cout << e << std::endl;
0085 throw e;
0086 }
0087 }
0088
0089
0090 }
0091 }
0092
0093
0094
0095
0096
0097