Files
2025-10-25 03:02:53 +03:00

6.6 KiB
Raw Permalink Blame History

[exec.par.scheduler]

33 Execution control library [exec]

33.15 Parallel scheduler [exec.par.scheduler]

1

#

parallel_scheduler models scheduler.

2

#

Let sch be an object of type parallel_scheduler, and let BACKEND-OF(sch) be *ptr, where sch is associated with ptr.

3

#

The expression get_forward_progress_guarantee(sch) has the valueforward_progress_guarantee::parallel.

4

#

Let sch2 be an object of type parallel_scheduler.

Two objects sch and sch2 compare equal if and only ifBACKEND-OF(sch) andBACKEND-OF(sch2) refer to the same object.

5

#

Let rcvr be a receiver.

A proxy for rcvr with base B is an lvalue r of type B such that:

  • (5.1)

    r.set_value() has effects equivalent toset_value(std::move(rcvr)).

  • (5.2)

    r.set_error(e), where e is an exception_ptr object, has effects equivalent to set_error(std::move(rcvr), std::move(e)).

  • (5.3)

    r.set_stopped() has effects equivalent toset_stopped(std::move(rcvr)).

6

#

A preallocated backend storage for a proxy r is an object s of type span such that the range s remains valid and may be overwritten until one of set_value, set_error, or set_stopped is called on r.

[Note 1:

The storage referenced by s can be used as temporary storage for operations launched via calls to parallel_scheduler_backend.

— end note]

7

#

A bulk chunked proxy for rcvr with callable f and arguments args is a proxy r for rcvr with base system_context_replaceability::bulk_item_receiver_proxy such thatr.execute(i, j) for indices i and j has effects equivalent to f(i, j, args...).

8

#

A bulk unchunked proxy for rcvr with callable f and arguments args is a proxy r for rcvr with base system_context_replaceability::bulk_item_receiver_proxy such thatr.execute(i, i + 1) for index i has effects equivalent to f(i, args...).

9

#

Let b be BACKEND-OF(sch), let sndr be the object returned by schedule(sch), and let rcvr be a receiver.

If rcvr is connected to sndr and the resulting operation state is started, then:

  • (9.1)

    If sndr completes successfully, then b.schedule(r, s) is called, where

r is a proxy for rcvr with base system_context_replaceability::receiver_proxy and

s is a preallocated backend storage for r.

  • (9.2)

    All other completion operations are forwarded unchanged.

10

#

parallel_scheduler provides a customized implementation of the bulk_chunked algorithm ([exec.bulk]).

If a receiver rcvr is connected to the sender returned by bulk_chunked(sndr, pol, shape, f) and the resulting operation state is started, then:

  • (10.1)

    If sndr completes with values vals, let args be a pack of lvalue subexpressions designating vals, then b.schedule_bulk_chunked(shape, r, s) is called, where

r is a bulk chunked proxy for rcvr with callable f and arguments args and

s is a preallocated backend storage for r.

  • (10.2)

    All other completion operations are forwarded unchanged.

[Note 2:

Customizing the behavior of bulk_chunked affects the default implementation of bulk.

— end note]

11

#

parallel_scheduler provides a customized implementation of the bulk_unchunked algorithm ([exec.bulk]).

If a receiver rcvr is connected to the sender returned by bulk_unchunked(sndr, pol, shape, f) and the resulting operation state is started, then:

  • (11.1)

    If sndr completes with values vals, let args be a pack of lvalue subexpressions designating vals, then b.schedule_bulk_unchunked(shape, r, s) is called, where

r is a bulk unchunked proxy for rcvr with callable f and arguments args and

s is a preallocated backend storage for r.

  • (11.2)

    All other completion operations are forwarded unchanged.

🔗

parallel_scheduler get_parallel_scheduler();

12

#

Effects: Let eb be the result of system_context_replaceability::query_parallel_scheduler_backend().

If eb == nullptr is true, calls terminate ([except.terminate]).

Otherwise, returns a parallel_scheduler object associated with eb.