Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement event batching in the miniframework #364

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

asubah
Copy link

@asubah asubah commented Jun 17, 2022

This PR picks up from where @fwyzard left in #143.
It contains 3 main commits:

Add a doneWaiting overload without the exception argument:

This commit is not related to the implementation of event batching. It just allows us to call doneWaiting() without passing an exception pointer instead of passing an empty pointer.

Add event batching support for fwtest:

The event batching feature is enabled by passing the --batchEvents <batch-size> option.

From original PR

  • the Source is responsible for reading (up to) N events at a time;
  • the Events are stored in an EventBatch and passed to each Worker as an EventRange (for produce()) or ConstEventRange (for acquire); the (Const)EventRange class allows (const) iteration and a (const) range-loop over the events, without any possibility of adding/dropping events;
  • the Worker passes the events to the various EDProducer-like base classes in the same way;
  • the existing EDProducer and EDProducerExternalWork base classes loop over the events in the range, and call acquire and produce one event at a time; modules that derive from them can be used without any changes;
  • introduce two new EDBatchingProducer and EDBatchingProducerExternalWork base classes that pass the range of Events to the module's acquire and produce methods; the module's implementation can then loop over the events, process them in parallel, etc.

The framework tests have been reorganised and extended to test all four EDProdcer-like base classes:

  • EDProducer;
  • EDProducerExternalWork;
  • EDBatchingProducer;
  • EDBatchingProducerExternalWork.

Note:
The commit deletes the files src/fwtest/plugin-Test2/TestProducer2.cc and src/fwtest/plugin-Test2/TestProducer3.cc and replaces them with batching test.

Copy event batching support from fwtest to cuda:

This commit copies the same event baching implementation to cuda.
The cuda modules are not changed at the moment, they still process each event individually even if batching is used. The modules will be updated in the future to take advantage of batching.

Add an AsyncState to communicate between acquire() and produce()

Add a template type parameter to the edm::EDProducerExternalWork class.

The acquire() method is now const, and it communicates its asynchronous
state to the the produce() method via an object of this type, rather
than using data members.

Implementations that do not need to pass any state between acquire() and
produce() can use "void" or leave the template parameter empty.

Implement simple support for event batching

Add EDBatchingProducer and EDBatchingProducerExternalWork base classes

Implement tests for all kind of EDProducer

Reorganise the existing EDProducer tests, and add tests for
  - EDBatchingProducer
  - EDBatchingProducerExternalWork

Wrap ownership of and access to event batches

Introduce three new edm classes:

  - edm::EventBatch
    implements the ownership of a batch of events, implemented as an
    std::vector<edm::Event>; used by the Source to provide events to the
    StreamSchedule.

  - edm::EventRange
    implements non-owning, non-const access to a batch of events;
    wraps a pair of Event* to the begin and end of an event batch;
    passed (by value) to doProduce() and produce().

  - edm::ConstEventRange
    implements non-owning const access to a batch of events;
    wraps a pair of Event* to the begin and end of an event batch;
    passed (by value) to doAcquire() and acquire().

Avoid potential overrun while reading multiple events per batch with multiple threads
Adapt the EDProducerExternalWork modules to the new interface
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants