Skip to content

Commit 1d6432d

Browse files
author
Gordon Brown
committed
CP013: Add new draft of D1437r0:
* Remove proposed wording. * Update front-matter with new motivation and goals. * Add suggested straw polls for SG1.
1 parent de6e026 commit 1d6432d

File tree

1 file changed

+271
-0
lines changed

1 file changed

+271
-0
lines changed

affinity/cpp-23/d1437r0_new.md

Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
1+
# D1437r0: System topology discovery for heterogeneous & distributed computing
2+
3+
**Date: 2019-06-03**
4+
5+
**Audience: SG1, SG14, LEWG**
6+
7+
**Authors: Gordon Brown, Ruyman Reyes, Michael Wong, Mark Hoemmen, Jeff Hammond, Tom Scogland**
8+
9+
**Emails: gordon@codeplay.com, ruyman@codeplay.com, michael@codeplay.com, mhoemme@sandia.gov, jeff.science@gmail.com, tscogland@llnl.gov**
10+
11+
**Reply to: gordon@codeplay.com**
12+
13+
# Acknowledgements
14+
15+
This paper is the result of discussions from man contributors within the heterogeneous C++ group, including H. Carter Edwards, Thomas Rodgers, Patrice Roy, Carl Cook, Jeff Hammond, Hartmut Kaiser, Christian Trott, Paul Blinzer, Alex Voicu, Nat Goodspeed, Tony Tye, Paul Blinzer
16+
17+
# Changelog
18+
19+
### P1437r0 (COL 2019)
20+
21+
* Split off from [[35]][p0796], focussing on a mechanism for discovering the topology and affinity properties of a given system.
22+
* Temporarily remove the proposed wording.
23+
* Update the front matter to re-focus the motivation and goals of the paper.
24+
25+
### Changelog from P0796
26+
27+
For the earlier changelogs from prior to the split from P0796 see Appendix A.
28+
29+
# Preface
30+
31+
This paper is the result of a request from SG1 at the 2018 San Diego meeting to split [[35]][p0796] into two separate papers, one for the high-level interface and one for the low-level interface. This paper focusses on the low-level interface; a mechanism for discovering the topology and affinity properties of a given system. [[36]][pXXXX] focusses on the high-level interface; a series of properties for querying affinity relationships and requesting affinity on work being executed.
32+
33+
# Background
34+
35+
Computer systems are no longer homogeneous platforms. Every system from desktop work stations to high-performance supercomputers, and from mobile devices to purpose-built embedded SoCs, every system has some form of co-processor along side the traditional multi-core CPU, and often more than one. Furthermore the architecture these co-processors range from many-core CPUs, GPUs, FPGAs and DSPs to specifically designed vision and machine learning processors. In larger supercomputer systems there are thousands of these processors, connected physically or via network adapters in some configuration of nodes made up of these processors.
36+
37+
The way these processors access memory is also far from homogeneous, there are strict hierarchical memory structures of different address spaces, shared virtual address space with different levels of consistency, cache coherency and atomic operations, NUMA memory regions, persistent memory, HBM memory, and all of there are many different ways in which these memory regions can be configured around the processors.
38+
39+
In order to program these new systems and the architectures that inhabit them, it's vital that applications are capable of understating both what architectures are available and the properties of those architectures; their observable behaviors, capabilities and limitations. However C++ currently has virtually no way to achieve this in the current standard, so developers have to rely entirely on third party and operating system libraries.
40+
41+
# Goals: what this paper is, and what it isn't
42+
43+
This paper seeks to define, within C++, a facility for discovering execution resources available to a system that are capable of executing work, and for querying their properties.
44+
45+
However, it is not the goal of this proposal to introduce support in the C++ language or the standard library for all of the various heterogeneous architectures available today. The authors of this paper recognize that this is unrealistic as it would require significant changes to the C++ machine model and would be extremely volatile to future developments in architecture and system design.
46+
47+
Instead it seeks to define a single unified and stable layer within the C++ standard library, on which applications, libraries and programming models such as standard thread pools, SYCL or Kokkos can be built, and which can be supported, by hardware vendors via standards such as HMM, and extended when necessary.
48+
49+
This layer will not be characterized in terms of specific hardware such as CPUs, GPUs and FPGAs as these are high-level concepts that are not fixed in time and have no foundation in the C++ machine model. It will instead define a number of abstract properties, which reflect an architecture's properties.
50+
51+
The initial set of properties that this paper would propose be defined in the C++ standard library would reflect a generalization of the observable behaviors, capabilities and limitations of common architectures available in heterogeneous and distributed systems today. However the intention is that the interface be extensible so that that vendors can provide their own extensions to provide visibility into the more niche characteristics of certain architectures.
52+
53+
It is intended that this layer be defined as a natural extension of the Executors proposal, a unified interface for execution. The Executors proposal already provides a route to supporting heterogeneous and distributed systems, however it is missing a way to identify what architectures a system has.
54+
55+
# Motivation
56+
57+
There are many reasons why such a feature within C++ would benefit developers and the C++ ecosystem as a whole, and those can differ from one domain to another. We've attempted to outline some of these benefits here.
58+
59+
## Improve performance
60+
61+
The clearest benefit is performance, exposing, even at an abstract level, the properties of the underlying architecture that a program is running on, allows application and libraries to be fine tuned, resulting in significant performance improvements that would only otherwise be possible via third party or operating system libraries.
62+
63+
This includes but is not limited to how to structure data to ensure access patterns along with execution on the architecture to achieve coalesced memory access and optimal cache utilization and where to initialize data to make efficient use of hardware locality and process affinity.
64+
65+
There is a general trend to move towards a unified address space in heterogeneous and distributed systems via standards like HMM. However there are still many architectures that still require distinct address spaces, and are not yet in a position to move to a single address space, and may never be. THough if you were to consider a single unified address the ultimate goal for heterogeneous and distributed systems this actually makes the case for affinity in C++ stronger, because while you have different address spaces, the distinction between different hardware memory regions and their capabilities are clear, but once you have a single unified address space, potentially with cache coherency, distinguishing different memory regions becomes much more subtle. Therefore it becomes much more important to understand the various memory regions and their affinity relationships in order to achieve good performance on various architectures.
66+
67+
## Provide a unified interface
68+
69+
C++ is a major language when it comes to heterogeneous and distributed computing, and while it is a rapidly growing domain, it is still very challenging to develop in. There are a large number of C++ based third party and OS libraries, however developing for heterogeneous and distributed systems often involves a combination of these, which introduces a number of challenges.
70+
71+
Firstly it's common that different architectures are discovered via different libraries, You may want to use CUDA for NVidia GPUs, OpenMP for Intel CPUs, SYCL for Intel GPUs, Hwloc for the higher-level nodes and so on. This means that you have to collect together resources discovered from a different libraries, which very often do not provide a consist representation or any form of interoperability, and find some way for them to represent them in a coherent view.
72+
73+
Secondly, many of these libraries report the same underlying hardware, for example OpenMP, SYCL and Hwloc will all report the same Intel CPU. This means you have to collate the resources together such that resources from different libraries representing the same hardware are joined together, to avoid resource contention.
74+
75+
## Categorize limitations
76+
77+
There are many architectures available within heterogeneous and distributed systems which cannot support the full range of C++ features. This includes, but is not limited to dynamic allocation, recursion, dynamic polymorphism, RTTI, double precision floating point and some forms of atomic operations.
78+
79+
It's crucial to allow developers to identify these limitations and which apply to the architecture they are running on, because in many cases if a C++ feature that is not supported on the architecture is used, the application would fail to execute or potentially crash.
80+
81+
## Facilitate generic code
82+
83+
Developing algorithms for heterogeneous and distributed systems requires at least an abstract understanding of the underlying architecture(s) being targeted in order to achieve optimal performance and in some cases a much more in-depth understanding. This means that each architecture may require a slightly or largely different implementation in order to achieve optimal performance.
84+
85+
Another factor here is that in many heterogeneous and distributed programming models, the architectures available on a particular system are not known until runtime, where the topology of the system is discovered.
86+
87+
Having a unified interface for performing this topology discovery and querying the properties of the architectures available on a system would dramatically improve developers ability to write generic algorithms.
88+
89+
## Increase accessibility
90+
91+
Providing support for heterogenous and distributed computing as a first class citizen of C++ will improve it's accessibility, which is important as it becomes a more and more crucial aspect to gaining further performance in a number of platforms. This would increase the amount of libraries and applications which can take advantage of heterogeneous and distributed computing, ultimately making the ecosystem stronger.
92+
93+
## Broader standardization
94+
95+
The C++ standard is in a crucial position for heterogeneous and distributed computing domains. It is the common point between a number of different programming languages, models and libraries targeting a wide range of different architectures. This means that the C++ standards has unique opportunity to provide a single standard that not only covers the requirements of a single domain, but all of them, allowing for a convergence within the ecosystem and much more interoperability across different architectures.
96+
97+
An example of this is that a unified C++ interface could provide a single topology discovering query that would provide access to GPUs from Nvidia, AMD, Intel and ARM from their respective open standards or propitiatory frameworks along side NUMA aware systems available via Hwloc.
98+
99+
Another example of this is that while Hwloc is highly used in many domains, it now does not always accurately represent existing systems, because it's structure is strictly hierarchical, while many systems no longer have a simply hierarchical topology. A unified C++ interface does not need to be bound to the limitations of a single library, it can provide a much broader representation of a system's execution resource topology.
100+
101+
# Proposed direction
102+
103+
Below we outline a proposed direction:
104+
105+
* Propose an abstract definition of an execution resource, as a hardware or software abstraction capable of creating execution agents.
106+
107+
* Propose an abstract definition of an execution resource topology, as a non-hierarchical, non-acyclic graph of execution resource with various different kinds of connections.
108+
109+
* Propose an interface for inspecting a system's execution resource topology from various different perspectives, including, but not limited to:
110+
* A depth-based view of the system as a containment hierarchy.
111+
* A memory centric view of which memory regions are available to which execution resources and the properties of that access.
112+
* A network centric view of how the execution resource and memory regions are connected.0
113+
114+
* Propose an interface for querying properties of an execution resource; reflecting the observable behaviors, capabilities and limitations of the architecture the execution resource represents.
115+
* Propose an interface for querying the relative affinity properties between different execution resources and memory regions within a system's execution resource topology.
116+
* Propose an interface for binding execution agents and initialization of data to specific execution resource.
117+
118+
As a result of the above this paper may also:
119+
120+
* Propose a lifetime model for execution agents.
121+
* Propose some additions to the C++ machine model to facilitate describing these additional properties.
122+
123+
# Suggested straw polls
124+
125+
Would SG1 like to see a continued effort to pursue the goals outlines in this paper?
126+
127+
Does SG1 believe the proposed direction laid out in this paper is suitable to achieve those goals?
128+
129+
# References
130+
131+
[p0687]: http://wg21.link/p0687
132+
[[1]][p0687] P0687: Data Movement in C\+\+
133+
134+
[design-of-openmp]: https://link.springer.com/chapter/10.1007/978-3-642-30961-8_2
135+
[[2]][design-of-openmp] The Design of OpenMP Thread Affinity
136+
137+
[3] Euro-Par 2011 Parallel Processing: 17th International, Affinity Matters
138+
139+
[hwloc]: https://www.open-mpi.org/projects/hwloc/
140+
[[4]][hwloc] Portable Hardware Locality
141+
142+
[sycl-1-2-1]: https://www.khronos.org/registry/SYCL/specs/sycl-1.2.1.pdf
143+
[[5]][sycl-1-2-1] SYCL 1.2.1
144+
145+
[opencl-2-2]: https://www.khronos.org/registry/OpenCL/specs/opencl-2.2.pdf
146+
[[6]][opencl-2-2] OpenCL 2.2
147+
148+
[HSA]: http://www.hsafoundation.com/standards/
149+
[[7]][HSA] HSA
150+
151+
[openmp-5]: http://www.openmp.org/wp-content/uploads/openmp-TR5-final.pdf
152+
[[8]][openmp-5] OpenMP 5.0
153+
154+
[cpuaff]: https://github.com/dcdillon/cpuaff
155+
[[9]][cpuaff] cpuaff
156+
157+
[pmem]: http://pmem.io/
158+
[[10]][pmem] Persistent Memory Programming
159+
160+
[memkid]: https://github.com/memkind/memkind
161+
[[11]][memkid] MEMKIND
162+
163+
[solaris-pbind]: https://docs.oracle.com/cd/E26502_01/html/E29031/pbind-1m.html
164+
[[12]][solaris-pbind] Solaris pbind()
165+
166+
[linux-sched-setaffinity]: https://linux.die.net/man/2/sched_setaffinity
167+
[[13]][linux-sched-setaffinity] Linux sched_setaffinity()
168+
169+
[windows-set-thread-affinity-mask]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms686247(v=vs.85).aspx
170+
[[14]][windows-set-thread-affinity-mask] Windows SetThreadAffinityMask()
171+
172+
[chapel]: https://chapel-lang.org/
173+
[[15]][chapel] Chapel
174+
175+
[x10]: http://x10-lang.org/
176+
[[16]][x10] X10
177+
178+
[upc++]: https://bitbucket.org/berkeleylab/upcxx/wiki/Home
179+
[[17]][upc++] UPC\+\+
180+
181+
[tbb]: https://www.threadingbuildingblocks.org/
182+
[[18]][tbb] TBB
183+
184+
[hpx]: https://github.com/STEllAR-GROUP/hpx
185+
[[19]][hpx] HPX
186+
187+
[madness]: https://github.com/m-a-d-n-e-s-s/madness
188+
[[20]][madness] MADNESS
189+
190+
[lstopo]: https://www.open-mpi.org/projects/hwloc/lstopo/
191+
[[21]][lstopo] Portable Hardware Locality Istopo
192+
193+
[p0443]:
194+
http://wg21.link/p0443
195+
[[22]][p0443] A Unified Executors Proposal for C\+\+
196+
197+
[p0737]: http://wg21.link/p0737
198+
[[23]][p0737] P0737 : Execution Context of Execution Agents
199+
200+
[exposing-locality]: https://docs.google.com/viewer?a=v&pid=sites&srcid=bGJsLmdvdnxwYWRhbC13b3Jrc2hvcHxneDozOWE0MjZjOTMxOTk3NGU3
201+
[[24]][exposing-locality] Exposing the Locality of new Memory Hierarchies to HPC Applications
202+
203+
[mpi]: http://mpi-forum.org/docs/
204+
[[25]][mpi] MPI
205+
206+
[pvm]: http://www.csm.ornl.gov/pvm/
207+
[[26]][pvm] Parallel Virtual Machine
208+
209+
[pvm-callback]: http://etutorials.org/Linux+systems/cluster+computing+with+linux/Part+II+Parallel+Programming/Chapter+11+Fault-Tolerant+and+Adaptive+Programs+with+PVM/11.2+Building+Fault-Tolerant+Parallel+Applications/
210+
[[27]][pvm-callback] Building Fault-Tolerant Parallel Applications
211+
212+
[mpi-post-failure-recovery]: http://journals.sagepub.com/doi/10.1177/1094342013488238
213+
[[28]][mpi-post-failure-recovery] Post-failure recovery of MPI communication capability
214+
215+
[mpi-fault-tolerance]: http://www.mcs.anl.gov/~lusk/papers/fault-tolerance.pdf
216+
[[29]][mpi-fault-tolerance] Fault Tolerance in MPI Programs
217+
218+
[p0323r4]: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0323r4.html
219+
[[30]][p0323r4] p0323r4 std::expected
220+
221+
[movidius]: https://developer.movidius.com/
222+
[[31]][movidius]: Intel® Movidius™ Neural Compute Stick
223+
224+
[madness-journal]: http://dx.doi.org/10.1137/15M1026171
225+
[[32]][madness-journal] MADNESS: A Multiresolution, Adaptive Numerical Environment for Scientific Simulation
226+
227+
[openmp-affinity]: http://pages.tacc.utexas.edu/~eijkhout/pcse/html/omp-affinity.html
228+
[[33]][openmp-affinity] OpenMP topic: Affinity
229+
230+
[intel-balanced-affinity]: https://software.intel.com/en-us/node/522518
231+
[[34]][intel-balanced-affinity] Balanced Affinity Type
232+
233+
[p0796]: http://wg21.link/p0796
234+
[[35]][p0796] Supporting Heterogeneous & Distributed Computing Through Affinity
235+
236+
[pXXXX]: http://wg21.link/p1436
237+
[[36]][p1436] Executor properties for affinity-based execution
238+
239+
# Appendix A: Changelog from P0796
240+
241+
## P0796r3 (SAN 2018)
242+
243+
* Remove reference counting requirement from `execution_resource`.
244+
* Change lifetime model of `execution_resource`: it now either consistently identifies some underlying resource, or is invalid; context creation rejects an invalid resource.ster
245+
* Remove `this_thread::bind` & `this_thread::unbind` interfaces.
246+
* Make `execution_resource`s iterable by replacing `execution_resource::resources` with `execution_resource::begin` and `execution_resource::end`.
247+
* Add `size` and `operator[]` for `execution_resource`.
248+
* Rename `this_system::get_resources` to `this_system::discover_topology`.
249+
* Introduce `memory_resource` to represent the memory component of a system topology.
250+
* Remove `can_place_memory` and `can_place_agents` from the `execution_resource` as these are no longer required.
251+
* Remove `memory_resource` and `allocator` from the `execution_context` as these no longer make sense.
252+
* Update the wording to describe how execution resources and memory resources are structured.
253+
* Refactor `affinity_query` to be between an `execution_resource` and a `memory_resource`.
254+
255+
## P0796r2 (RAP 2018)
256+
257+
* Introduce a free function for retrieving the execution resource underlying the current thread of execution.
258+
* Introduce `this_thread::bind` & `this_thread::unbind` for binding and unbinding a thread of execution to an execution resource.
259+
* Introduce `bulk_execution_affinity` executor properties for specifying affinity binding patterns on bulk execution functions.
260+
261+
## P0796r1 (JAX 2018)
262+
263+
* Introduce proposed wording.
264+
* Based on feedback from SG1, introduce a pair-wise interface for querying the relative affinity between execution resources.
265+
* Introduce an interface for retrieving an allocator or polymorphic memory resource.
266+
* Based on feedback from SG1, remove requirement for a hierarchical system topology structure, which doesn't require a root resource.
267+
268+
## P0796r0 (ABQ 2017)
269+
270+
* Initial proposal.
271+
* Enumerate design space, hierarchical affinity, issues to the committee.

0 commit comments

Comments
 (0)