You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: affinity/cpp-20/d0796r3.md
+23-22Lines changed: 23 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -305,13 +305,13 @@ Below *(Figure 2)* is an example of what a typical **system topology** could loo
305
305
306
306
An `execution_resource` is a lightweight structure which identifies a particular **execution resource** within a snapshot of the **system topology**. It can be queried for a name via `name`.
307
307
308
-
An `execution_resource` object can be queried for a pointer to it's parent `execution_resource` via `member_of`, and can also iterate over it's children `execution_resource`s via `begin` and `end` or access a particular child via `operator[]`.
308
+
An `execution_resource` object can be queried for a pointer to its parent `execution_resource` via `member_of`, and can also iterate over its children `execution_resource`s via `begin` and `end` or access a particular child via `operator[]`.
309
309
310
310
An `execution_resource` object can also be queried for the amount concurrency it can provide, the total number of **threads of execution** supported by the associated **execution resource**.
311
311
312
312
An `execution_resource` object can be queried for a pointer to the root `memory_resource` representing the **memory resource** which the associated **execution resource** can access via `memory_resource`.
313
313
314
-
> [*Note:* There may be a number of **memory resources** which an **execution resource** can access, but the `memory_resource` pointer returned from `memory_resource` should represent the most course grained of these. We may want to expand on this interface in the future. *--end note*]
314
+
> [*Note:* There may be a number of **memory resources** which an **execution resource** can access, but the `memory_resource` pointer returned from `memory_resource` should represent the most coarse grained of these. We may want to expand on this interface in the future. *--end note*]
315
315
316
316
Below *(Listing 3)* is an example of iterating over every **execution resource** within the **system topology**.
An `memory_resource` is a lightweight structure which inherits from `pmr::memory_resource` and identifies a particular **memory resource** within a snapshot of the **system topology**. It can be queried for a name via `name`.
337
337
338
-
A `memory_resource` object can be queried for a pointer to it's parent `memory_resource` via `member_of`, and can also iterate over it's children `memory_resource`s via `begin` and `end` or access a particular child via `operator[]`.
338
+
A `memory_resource` object can be queried for a pointer to its parent `memory_resource` via `member_of`, and can also iterate over its children `memory_resource`s via `begin` and `end` or access a particular child via `operator[]`.
339
339
340
340
An allocator capable of allocating memory in the memory region of the **memory resource** represented by a `memory_resource` object by constructing a `pmr::polymorphic_allocator` from the `memory_resource` object.
341
341
342
342
### Querying relative affinity
343
343
344
344
The `affinity_query` class template provides an abstraction of the relative affinity between an `execution_resource` and a `memory_resource` for a particular `affinity_operation` and `affinity_metric`. The `affinity_query` takes the `affinity_operation` and `affinity_metric` as template parameters, and is constructed from an `execution_resource` and a `memory_resource`.
345
345
346
-
An `affinity_query` is not generally not meaningful on its own. Instead, users are meant to compare two `affinity_query`s via comparison operators, in order to get a relative magnitude of affinity. If necessary, the underlying value of an `affinity_query` can be queried through `native_affinity`, though the return value of this is implementation defined.
346
+
An `affinity_query` is not generally meaningful on its own. Instead, users are meant to compare two `affinity_query`s via comparison operators, in order to get a relative magnitude of affinity. If necessary, the underlying value of an `affinity_query` can be queried through `native_affinity`, though the return value of this is implementation defined.
347
347
348
348
Below *(listing 4)* is an example of how to query the relative affinity between an `execution_resource` and a `memory_resource`.
349
349
@@ -384,24 +384,25 @@ When creating an `execution_context` from a given `execution_resource`, the exec
384
384
```cpp
385
385
auto systemResource = std::this_system::discover_topology();
386
386
387
-
/* find_socket_resource is a user-defined function that finds a resource that is a CPU socket in the given resource list */
387
+
// find_socket_resource is a user-defined function that finds a resource that is
388
+
// a CPU socket in the given resource list
388
389
auto socket = find_socket_resource(systemResource);
389
390
390
-
/* Create an execution_context and executor associated with the CPU socket */
391
-
execution_context context{socket}
391
+
// Create an execution_context and executor associated with the CPU socket
392
+
execution_context context{socket};
392
393
auto executor = context.executor();
393
394
394
-
/* Create an allocator from the memory resource associate with the GPU socket */
395
+
// Create an allocator from the memory resource associated with the GPU socket
*Listing 6: Example of executing and allocating with affinity*
401
402
402
-
The construction of an `execution_context` on an `execution_resource` implies affinity (where possible) to the given resource. This guarantees that all executors created from that `execution_context` can access the resources and the internal data structures requires to guarantee the placement of the processor.
403
+
The construction of an `execution_context` on an `execution_resource` implies affinity (where possible) to the given resource. This guarantees that all executors created from that `execution_context` can access the resources and the internal data structures required to guarantee the binding of execution agents.
403
404
404
-
Only developers that care about resource placement need to care about obtaining executorsfrom the correct `execution_context` object. Existing code for vectors and STL (including the Parallel STL interface) remains unaffected.
405
+
Only developers that care about resource placement need to care about obtaining executors from the correct `execution_context` object. Existing code for vectors and STL (including the Parallel STL interface) remains unaffected.
405
406
406
407
If a particular policy or algorithm requires to access placement information, the resources associated with the passed executor can be retrieved via the link to the `execution_context`.
407
408
@@ -506,7 +507,7 @@ The `execution_resource` which underlies the current thread of execution can be
@@ -587,11 +588,11 @@ The `execution_resource` class provides an abstraction over an **execution resou
587
588
588
589
iterator
589
590
590
-
*Requires:*`iterator`to model `RandomAccessIterator` with the value type `execution_resource::value_type`.
591
+
*Requires:*`iterator`satisfies the `Cpp17RandomAccessIterator` requirements and `is_same_v<iterator_traits<iterator>::value_type, execution_resource::value_type>` is well-formed and resolves to `true`.
591
592
592
593
const_iterator
593
594
594
-
*Requires:*`const_iterator`to model `RandomAccessIterator` with the value type `execution_resource::value_type`.
595
+
*Requires:*`const_iterator`satisfies the `Cpp17RandomAccessIterator` requirements and `is_same_v<iterator_traits<const_iterator>::value_type, execution_resource::value_type>` is well-formed and resolves to `true`.
595
596
596
597
### `execution_resource` constructors
597
598
@@ -642,7 +643,7 @@ The `execution_resource` class provides an abstraction over an **execution resou
642
643
643
644
## Class `memory_resource`
644
645
645
-
The `memory_resource` class provides an abstraction which represents a **memory resource**, that can allocate memory. A `memory_resource` can represent further `memory_resource`s. We say that these `ememory_resource`s are *members of* this `memory_resource`.
646
+
The `memory_resource` class provides an abstraction which represents a **memory resource**, that can allocate memory. A `memory_resource` can represent further `memory_resource`s. We say that these `memory_resource`s are *members of* this `memory_resource`.
646
647
647
648
The `memory_resource` class must inherit from the `pmr::memory_resource` class.
648
649
@@ -652,11 +653,11 @@ The `memory_resource` class must inherit from the `pmr::memory_resource` class.
652
653
653
654
iterator
654
655
655
-
*Requires:*`iterator`to model `RandomAccessIterator` with the value type `memory_resource::value_type`.
656
+
*Requires:*`iterator`satisfies the `Cpp17RandomAccessIterator` requirements and `is_same_v<iterator_traits<iterator>::value_type, execution_resource::value_type>` is well-formed and resolves to `true`.
656
657
657
658
const_iterator
658
659
659
-
*Requires:*`const_iterator`to model `RandomAccessIterator` with the value type `memory_resource::value_type`.
660
+
*Requires:*`const_iterator`satisfies the `Cpp17RandomAccessIterator` requirements and `is_same_v<iterator_traits<const_iterator>::value_type, execution_resource::value_type>` is well-formed and resolves to `true`.
660
661
661
662
### `memory_resource` constructors
662
663
@@ -725,7 +726,7 @@ The `execution_context` class provides an abstraction for managing a number of l
0 commit comments