Skip to content

Commit

Permalink
Test cases pass again
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanwbrei committed Oct 12, 2024
1 parent 6d69045 commit 53eee94
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 13 deletions.
15 changes: 8 additions & 7 deletions src/libraries/JANA/JEventProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class JEventProcessor : public jana::components::JComponent,
// any contention.

if (m_status == Status::Uninitialized) {
DoInitialize();
throw JException("JEventProcessor: Attempted to call DoTap() before Initialize()");
}
else if (m_status == Status::Finalized) {
throw JException("JEventProcessor: Attempted to call DoMap() after Finalize()");
Expand Down Expand Up @@ -121,15 +121,16 @@ class JEventProcessor : public jana::components::JComponent,

auto run_number = event->GetRunNumber();

if (m_status == Status::Uninitialized) {
DoInitialize();
}
else if (m_status == Status::Finalized) {
throw JException("JEventProcessor: Attempted to call DoMap() after Finalize()");
}
{
// Protect the call to BeginRun(), etc, to prevent some threads from running Process() before BeginRun().
std::lock_guard<std::mutex> lock(m_mutex);

if (m_status == Status::Uninitialized) {
throw JException("JEventProcessor: Attempted to call DoLegacyProcess() before Initialize()");
}
else if (m_status == Status::Finalized) {
throw JException("JEventProcessor: Attempted to call DoLegacyProcess() after Finalize()");
}
if (m_last_run_number != run_number) {
if (m_last_run_number != -1) {
CallWithJExceptionWrapper("JEventProcessor::EndRun", [&](){ EndRun(); });
Expand Down
16 changes: 16 additions & 0 deletions src/libraries/JANA/Topology/JEventMapArrow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,25 @@ void JEventMapArrow::process(Event* event, bool& success, JArrowMetrics::Status&

void JEventMapArrow::initialize() {
LOG_DEBUG(m_logger) << "Initializing arrow '" << get_name() << "'" << LOG_END;
for (auto processor : m_procs) {
if (processor->GetCallbackStyle() == JEventProcessor::CallbackStyle::LegacyMode) {
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 JEventMapArrow::finalize() {
LOG_DEBUG(m_logger) << "Finalizing arrow '" << get_name() << "'" << LOG_END;
for (auto processor : m_procs) {
if (processor->GetCallbackStyle() == JEventProcessor::CallbackStyle::LegacyMode) {
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;
}

21 changes: 21 additions & 0 deletions src/libraries/JANA/Topology/JTopologyBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,27 @@ void JTopologyBuilder::attach_level(JEventLevel current_level, JUnfoldArrow* par
parent_folder->attach_child_out(pool_at_level);
}

// Finally, we recur over lower levels!
if (need_unfold) {
auto next_level = unfolders_at_level[0]->GetChildLevel();
attach_level(next_level, unfold_arrow, fold_arrow);
}
else {
// This is the lowest level
// TODO: Improve logic for determining event counts for multilevel topologies
if (tap_arrow != nullptr) {
tap_arrow->set_is_sink(true);
}
else if (map2_arrow != nullptr) {
map2_arrow->set_is_sink(true);
}
else if (map1_arrow != nullptr) {
map1_arrow->set_is_sink(true);
}
else if (src_arrow != nullptr) {
src_arrow->set_is_sink(true);
}
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ TEST_CASE("JEventProcessorSequentialRootTests") {
app.Add(new JEventSource());
app.SetParameterValue("nthreads", 4);
app.SetParameterValue("jana:nevents", 4);
app.SetParameterValue("jana:event_source_chunksize", 1);
app.SetParameterValue("jana:event_processor_chunksize", 1);
app.SetParameterValue("jana:loglevel", "warn");
//app.SetParameterValue("jana:loglevel", "debug");
//app.SetParameterValue("jana:log:show_threadstamp", true);
auto proc = new MyRootProcessor;
app.Add(proc);
app.Run(true);
Expand Down Expand Up @@ -135,9 +134,8 @@ TEST_CASE("JEventProcessorSequentialTests") {
app.Add(new JEventSource());
app.SetParameterValue("nthreads", 4);
app.SetParameterValue("jana:nevents", 4);
app.SetParameterValue("jana:event_source_chunksize", 1);
app.SetParameterValue("jana:event_processor_chunksize", 1);
app.SetParameterValue("jana:loglevel", "warn");
//app.SetParameterValue("jana:loglevel", "debug");
//app.SetParameterValue("jana:log:show_threadstamp", 1);
auto proc = new MySeqProcessor;
app.Add(proc);
app.Run(true);
Expand Down

0 comments on commit 53eee94

Please sign in to comment.