|
| 1 | +.. _Design: |
| 2 | + |
| 3 | +Library design principles |
| 4 | +========================= |
| 5 | + |
| 6 | +MPL is designed on the basis of the following |
| 7 | + |
| 8 | +Resource management |
| 9 | +------------------- |
| 10 | + |
| 11 | +In a typical MPI program, a number of resources, e.g., communicators, |
| 12 | +custom data types etc., must be management. Allocation and deallocation |
| 13 | +of such resources must be done manually by explicitly calling the |
| 14 | +respective allocation and deallocation function. This is error-prone, |
| 15 | +may lead to resource leaks and requires a lot of boilerplate code. |
| 16 | + |
| 17 | +Therefore, MPL applies the principle of "resource acquisition is |
| 18 | +initialization" (RAII) and wraps all resources in custom class types. |
| 19 | +Resources are allocated in a constructor and automatically dealocated |
| 20 | +when a resource object goes out of scope by the destructor. In contrast |
| 21 | +to MPI handles, all resource classes have a value-semantics. This means, |
| 22 | +when a resource object is copies in to another one, then a new resource |
| 23 | +is created and the two resource objects manage different independent |
| 24 | +resources. |
| 25 | + |
| 26 | + |
| 27 | +Custom data types |
| 28 | +----------------- |
| 29 | + |
| 30 | +Custom data types are one of the most versatile features of MPI. With |
| 31 | +custom data types, it is possible to write very well structured |
| 32 | +code by hiding details of the complex communication pattern in |
| 33 | +well-designed custom data types. Therefore, MPL makes it easy to |
| 34 | +create and use custom data types. These are called layouts in MPL. |
0 commit comments