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

How to achieve execution agent local variable? #1259

Open
RishabhRD opened this issue Feb 24, 2024 · 2 comments
Open

How to achieve execution agent local variable? #1259

RishabhRD opened this issue Feb 24, 2024 · 2 comments

Comments

@RishabhRD
Copy link
Contributor

Sometimes we need some variables to be execution agent local. Taking a use-case of parallel random number generation. If I want random number generator to be non-blocking for multiple threads, then each thread should have a separate copy of random generator.

For example, in case of a thread pool scheduler a thread_local random generator can be used. But that's not a generic solution.

I don't know how to handle the same with P2300. Is there some way to handle this kind of use-case?

I feel the use-case can be solved if I have 2 queries:

  • Maximum number of tasks that can be executed concurrently at any moment of time. (can be unbounded too)
  • Let's say the above query returns n. Then a query like current_execution_id that returns [0, n) representing on which execution agent task is currently at.
@maikel
Copy link
Collaborator

maikel commented Feb 24, 2024

You can always invent your needed queries and add support for them in the receivers env of your schedule operation, at least if you own the execution context yourself.

But querying the receivers env is basically the way to access information that is only known at that time.

@lewissbaker
Copy link
Contributor

There was a proposal for an object-pool that was intended to address this kind of use-case.
See https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2774r1.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants