From dc13597a8edaa3cacb56b5960e4021666ccdcc18 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Thu, 17 Oct 2024 15:05:58 -0400 Subject: [PATCH] Remove JEventProcessorArrow --- .../SubeventCUDAExample.cu | 19 +++--- .../SubeventExample/SubeventExample.cc | 6 +- src/libraries/JANA/CMakeLists.txt | 1 - .../JANA/Topology/JEventProcessorArrow.cc | 58 ------------------- .../JANA/Topology/JEventProcessorArrow.h | 22 ------- .../JANA/Topology/JTopologyBuilder.cc | 2 +- .../JANA/Utils/JCallGraphEntryMaker.h | 4 +- .../unit_tests/Topology/SubeventTests.cc | 5 +- 8 files changed, 20 insertions(+), 97 deletions(-) delete mode 100644 src/libraries/JANA/Topology/JEventProcessorArrow.cc delete mode 100644 src/libraries/JANA/Topology/JEventProcessorArrow.h diff --git a/src/examples/SubeventCUDAExample/SubeventCUDAExample.cu b/src/examples/SubeventCUDAExample/SubeventCUDAExample.cu index 16ea6eee5..cc2b2cd2b 100644 --- a/src/examples/SubeventCUDAExample/SubeventCUDAExample.cu +++ b/src/examples/SubeventCUDAExample/SubeventCUDAExample.cu @@ -4,10 +4,10 @@ #include #include -#include #include #include #include "JANA/Engine/JTopologyBuilder.h" +#include struct MyInput : public JObject { @@ -128,8 +128,7 @@ int main() { JMailbox > subevents_out; auto split_arrow = new JSplitArrow("split", &processor, &events_in, &subevents_in); - auto subprocess_arrow = new JSubeventArrow("subprocess", &processor, &subevents_in, - &subevents_out); + auto subprocess_arrow = new JSubeventArrow("subprocess", &processor, &subevents_in, &subevents_out); auto merge_arrow = new JMergeArrow("merge", &processor, &subevents_out, &events_out); JApplication app; @@ -140,12 +139,14 @@ int main() { source->SetNEvents(10); // limit ourselves to 10 events. Note that the 'jana:nevents' param won't work // here because we aren't using JComponentManager to manage the EventSource - auto topology = app.GetService()->create_empty(); - auto source_arrow = new JEventSourceArrow("simpleSource", - {source}, - &events_in, - topology->event_pool); - auto proc_arrow = new JEventProcessorArrow("simpleProcessor", &events_out, nullptr, topology->event_pool); + auto topology = app.GetService(); + auto source_arrow = new JEventSourceArrow("simpleSource", {source}); + source_arrow->set_input(topology->event_pool); + source_arrow->set_output(&events_in); + + auto proc_arrow = new JEventMapArrow("simpleProcessor"); + proc_arrow->set_input(&events_out); + proc_arrow->set_output(topology->event_pool); proc_arrow->add_processor(new SimpleProcessor); topology->arrows.push_back(source_arrow); diff --git a/src/examples/SubeventExample/SubeventExample.cc b/src/examples/SubeventExample/SubeventExample.cc index 8617fef82..cef877c02 100644 --- a/src/examples/SubeventExample/SubeventExample.cc +++ b/src/examples/SubeventExample/SubeventExample.cc @@ -8,9 +8,9 @@ #include #include -#include +#include #include -#include "JANA/Topology/JTopologyBuilder.h" +#include struct MyInput : public JObject { @@ -111,7 +111,7 @@ int main() { source_arrow->set_input(topology->event_pool); source_arrow->set_output(&events_in); - auto proc_arrow = new JEventProcessorArrow("simpleProcessor"); + auto proc_arrow = new JEventMapArrow("simpleProcessor"); proc_arrow->set_input(&events_out); proc_arrow->set_output(topology->event_pool); proc_arrow->add_processor(new SimpleProcessor); diff --git a/src/libraries/JANA/CMakeLists.txt b/src/libraries/JANA/CMakeLists.txt index bac884cab..627e54a86 100644 --- a/src/libraries/JANA/CMakeLists.txt +++ b/src/libraries/JANA/CMakeLists.txt @@ -17,7 +17,6 @@ set(JANA2_SOURCES Engine/JPerfMetrics.cc Engine/JPerfSummary.cc - Topology/JEventProcessorArrow.cc Topology/JEventSourceArrow.cc Topology/JEventMapArrow.cc Topology/JEventTapArrow.cc diff --git a/src/libraries/JANA/Topology/JEventProcessorArrow.cc b/src/libraries/JANA/Topology/JEventProcessorArrow.cc deleted file mode 100644 index 4bd4873c3..000000000 --- a/src/libraries/JANA/Topology/JEventProcessorArrow.cc +++ /dev/null @@ -1,58 +0,0 @@ - -// Copyright 2020, Jefferson Science Associates, LLC. -// Subject to the terms in the LICENSE file found in the top-level directory. - - -#include -#include -#include - - -JEventProcessorArrow::JEventProcessorArrow(std::string name) - : JPipelineArrow(std::move(name), true, false, true) {} - -void JEventProcessorArrow::add_processor(JEventProcessor* processor) { - m_processors.push_back(processor); -} - -void JEventProcessorArrow::process(std::shared_ptr* event, bool& success, JArrowMetrics::Status& status) { - - - LOG_DEBUG(m_logger) << "Executing arrow " << get_name() << " for event# " << (*event)->GetEventNumber() << LOG_END; - for (JEventProcessor* processor : m_processors) { - // TODO: Move me into JEventProcessor::DoMap - JCallGraphEntryMaker cg_entry(*(*event)->GetJCallGraphRecorder(), processor->GetTypeName()); // times execution until this goes out of scope - if (processor->GetCallbackStyle() == JEventProcessor::CallbackStyle::LegacyMode) { - processor->DoLegacyProcess(*event); - } - else { - processor->DoMap(*event); - processor->DoTap(*event); - - } - } - LOG_DEBUG(m_logger) << "Executed arrow " << get_name() << " for event# " << (*event)->GetEventNumber() << LOG_END; - success = true; - status = JArrowMetrics::Status::KeepGoing; -} - -void JEventProcessorArrow::initialize() { - LOG_DEBUG(m_logger) << "Initializing arrow '" << get_name() << "'" << LOG_END; - for (auto processor : m_processors) { - LOG_INFO(m_logger) << "Initializing JEventProcessor '" << processor->GetTypeName() << "'" << LOG_END; - processor->DoInitialize(); - LOG_INFO(m_logger) << "Initialized JEventProcessor '" << processor->GetTypeName() << "'" << LOG_END; - } - LOG_DEBUG(m_logger) << "Initialized arrow '" << get_name() << "'" << LOG_END; -} - -void JEventProcessorArrow::finalize() { - LOG_DEBUG(m_logger) << "Finalizing arrow " << get_name() << LOG_END; - for (auto processor : m_processors) { - LOG_DEBUG(m_logger) << "Finalizing JEventProcessor " << processor->GetTypeName() << LOG_END; - processor->DoFinalize(); - LOG_INFO(m_logger) << "Finalized JEventProcessor " << processor->GetTypeName() << LOG_END; - } - LOG_DEBUG(m_logger) << "Finalized arrow " << get_name() << LOG_END; -} - diff --git a/src/libraries/JANA/Topology/JEventProcessorArrow.h b/src/libraries/JANA/Topology/JEventProcessorArrow.h deleted file mode 100644 index 58a415419..000000000 --- a/src/libraries/JANA/Topology/JEventProcessorArrow.h +++ /dev/null @@ -1,22 +0,0 @@ - -// Copyright 2020, Jefferson Science Associates, LLC. -// Subject to the terms in the LICENSE file found in the top-level directory. - -#pragma once -#include -#include - - -class JEventProcessorArrow : public JPipelineArrow { - -private: - std::vector m_processors; - -public: - JEventProcessorArrow(std::string name); - void add_processor(JEventProcessor* processor); - void process(std::shared_ptr* event, bool& success, JArrowMetrics::Status& status); - void initialize() final; - void finalize() final; -}; - diff --git a/src/libraries/JANA/Topology/JTopologyBuilder.cc b/src/libraries/JANA/Topology/JTopologyBuilder.cc index 5108cdad2..0e4b53181 100644 --- a/src/libraries/JANA/Topology/JTopologyBuilder.cc +++ b/src/libraries/JANA/Topology/JTopologyBuilder.cc @@ -6,11 +6,11 @@ #include "JTopologyBuilder.h" #include "JEventSourceArrow.h" -#include "JEventProcessorArrow.h" #include "JEventMapArrow.h" #include "JEventTapArrow.h" #include "JUnfoldArrow.h" #include "JFoldArrow.h" +#include #include diff --git a/src/libraries/JANA/Utils/JCallGraphEntryMaker.h b/src/libraries/JANA/Utils/JCallGraphEntryMaker.h index 23448abb1..f0952148c 100644 --- a/src/libraries/JANA/Utils/JCallGraphEntryMaker.h +++ b/src/libraries/JANA/Utils/JCallGraphEntryMaker.h @@ -18,11 +18,13 @@ /// (and possibly other places). class JCallGraphEntryMaker{ public: + JCallGraphEntryMaker(JCallGraphRecorder &callgraphrecorder, JFactory *factory) : m_call_graph(callgraphrecorder), m_factory(factory){ m_call_graph.StartFactoryCall(m_factory->GetObjectName(), m_factory->GetTag()); } + JCallGraphEntryMaker(JCallGraphRecorder &callgraphrecorder, std::string name) : m_call_graph(callgraphrecorder) { - // (This is used mainly for JEventProcessors and called from JEventProcessorArrow::execute ) + // This is used mainly for JEventProcessors m_call_graph.StartFactoryCall(name, ""); } diff --git a/src/programs/unit_tests/Topology/SubeventTests.cc b/src/programs/unit_tests/Topology/SubeventTests.cc index 5ee7573e7..f0881fbab 100644 --- a/src/programs/unit_tests/Topology/SubeventTests.cc +++ b/src/programs/unit_tests/Topology/SubeventTests.cc @@ -7,8 +7,9 @@ #include #include +#include #include -#include +#include #include #include @@ -105,7 +106,7 @@ TEST_CASE("Basic subevent arrow functionality") { source_arrow->set_input(topology.event_pool); source_arrow->set_output(&events_in); - auto proc_arrow = new JEventProcessorArrow("simpleProcessor"); + auto proc_arrow = new JEventMapArrow("simpleProcessor"); proc_arrow->set_input(&events_out); proc_arrow->set_output(topology.event_pool); proc_arrow->add_processor(new SimpleProcessor);