Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • E emper
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 15
    • Issues 15
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • i4i4
  • manycore
  • emper
  • Merge requests
  • !229

[AbstractWorkStealingScheduler] Get rid of "rand() % workerCount"

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Florian Schmaus requested to merge flow/emper:random-worker-id into master Aug 11, 2021
  • Overview 0
  • Commits 1
  • Pipelines 2
  • Changes 3

The "rand() % workerCount" constructed used in the work-stealing scheduler is flawed. It has a bias toward lower worker IDs due the modulo operation. This is something I always wanted to get rid of, but never found the time to do it. Until know.

Get rid of it and replace it with std::uniform_int_distribution<workerid_t> (as field the Worker instance).

The changes in AbstractWorkStealingScheduler.cpp look more than they are actually. I had to introduce a new scope since to the goto instruction would otherwise skip the initialization of currentWorker.

The main changes in AbstractWorkStealingScheduler are

  • use currentWorker->nextRandomWorkerId() (instead of the flawed construct)
  • currentWorker->getWorkerId() (instead of Runtime::getWorkerId())
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: random-worker-id