stan-dev / stan-dev/math

Avoid if-def branching for threading code

Open
#2,525 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
839
Forks
220
Avg merge
2d 4h
Merged PRs (30d)
14

Description

Description

Currently we if-def around single-core vs multi-core implementation of functions which implement parallelism. The if-def asks for the availability of STAN_THREADS being set or not during compilation. Since the TBB simplifies on a single core to just run with 1 process (if configured to do so), we should drop the if-def while ensuring that we instruct C++ users accordingly to setup the TBB task_arena things run in to just have 1 core.

Example

Code should be easier to maintain due to fewer if-def.

Expected Output

No change in outputs.

Current Version:

v4.1.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the STAN_THREADS conditionals around the single-core and multi-core implementations, then inspect how TBB task_arena is configured for C++ users. Done means the conditional branching is removed, single-core execution remains configurable through TBB, and outputs are unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
performance
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.