Selecting Algorithms
Selecting a Policy
The selection of communication algorithms determines the overall performance of communication operators to a great extent. To cope with different network topologies, communication data sizes, and hardware resources, a communication operator usually has multiple algorithm implementations. In actual distributed cluster scenarios, you need to select communication algorithms with affinity with the topology based on the specific scenario to maximize the communication efficiency.
As shown in the preceding figure, the communication operator supports multiple algorithm implementations. You can select the optimal algorithm based on the topology information.
- Ring algorithm implementation: The algorithm is orchestrated on the AICPU and applies to the scenario where the physical topology on the server is a ring.
- Mesh algorithm implementation: The algorithm is orchestrated on the AICPU and applies to the scenario where the physical topology on the server is a mesh.
- If the communication operator has only one algorithm implementation, skip the algorithm selection step in this section.
- The algorithms described in this section are implemented by yourself. The algorithms configured by the HCCL_ALGO environment variable are built-in HCCL algorithms. For details about the built-in HCCL algorithms, see in Huawei Collective Communication Library (HCCL)Introduction to Collective Communication Algorithms.
Sample Code
Take the algorithm selection policy in Selecting a Policy as an example. The corresponding algorithm selection code snippet is as follows:
1 2 3 4 5 6 7 |
if (algType == ALG_LEVEL0_NP_DOUBLE_RING || algType == ALG_LEVEL0_NP_SINGLE_RING) { algName = "Ring"; // Select the ring algorithm based on the topology information. } else if (algType == ALG_LEVEL0_NP_MESH) { algName = "Mesh"; // Select the mesh algorithm based on the topology information. } else { return HCCL_E_NOT_SUPPORT; } |