Page MenuHomeHEPForge

Introduced function to set seed.
ClosedPublic

Authored by abudinen on Jun 20 2024, 2:26 PM.

Details

Summary

Introduced function setSeed for random engines. Related with !26.

Set seed during event generation in testing.

Specify functions that are overriden in EvtMTRandomEngine class.

This is related with the general thread-safety modifications: T168.

Test Plan

All tests run flawlessly. Outputs will change within statistical uncertainties as we now set the seed by hand for each event.

Diff Detail

Repository
rEVTGEN evtgen
Branch
SetRandomSeed
Lint
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 316
Build 316: arc lint + arc unit

Event Timeline

abudinen changed the visibility from "All Users" to "Public (No Login Required)".Jun 20 2024, 2:26 PM
abudinen changed the edit policy from "All Users" to "Restricted Project (Project)".
abudinen added a project: Restricted Project.
test/testDecayModel.cc
460

OK, so will multithreading generate multiple events simultaneously when it encounters this loop, and we therefore need to ensure that each event (thread) has its own unique random seed to avoid generating duplicate events?

test/testDecayModel.cc
460

Yes, the idea is that each thread will generate a batch of events, Seeding with the event number will guarantee that we don't duplicate events and furthermore that the results should be identical regardless of the number of threads used. This will allow us to properly test that we aren't encountering any race conditions because if we do we should find that the results change when going from a single thread to multiple threads.

EvtGenBase/EvtRandom.hh
37

So I gather that we still need this EvtRandom.hh class to use static methods since there will only be one "instance" of this that will be used by all threads (which will each use unique random number seeds)?

abudinen added inline comments.
EvtGenBase/EvtRandom.hh
37

We will have a static thread_local instance of the random engine. That means one instance per thread. Therefore we still need these methods to be static. By setting the seed for each event we ensure that the outcome for each event is the same irrespective of the number of threads and of the thread it is simulated in.

Code looks OK. Thanks for the info about the thread safety aspects.

This revision is now accepted and ready to land.Jun 20 2024, 5:33 PM
This revision was automatically updated to reflect the committed changes.