Skip to content

Simultaneously launched sims can draw the same random seed with system_clock #435

Description

@drbergman

When <random_seed> is system_clock (or empty, or random), the seed is taken straight from std::chrono::system_clock::now().time_since_epoch().count() and truncated into an unsigned int. The count is denominated in nanoseconds under GCC, but its resolution is whatever the OS clock provides—1 µs on macOS—so simulations launched at the same moment routinely read the identical count and end up with the identical seed. I ran into this launching 8 replicates in parallel: two pairs had byte-identical output/random_seed.txt, which means those "replicates" shared their entire pre-parallel setup stream, cell placement included. Widening the seed doesn't help, since both processes read the same value at any width; seeding from std::random_device does. With 32 processes synchronised to the same instant I measured 32 duplicate seeds in 640 launches before, and none after. A few other small problems in the same code turned up while chasing this—see drbergman#75 for the details and a fix. Happy to open a PR with similar changes here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions