Collection communication method and system based on DMA-BUF, equipment and medium
Through the DMA-BUF collective communication method, a mapping relationship between computing units is established, which solves the problem of cross-device shared memory communication and realizes efficient data exchange.
Patent Information
- Application Number
- CN202510817755.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-18
- Publication Date
- 2025-09-16
AI Technical Summary
Existing technologies are unable to perform collective communication across electronic devices through shared memory, resulting in low data exchange efficiency.
The DMA-BUF collective communication method is adopted to establish a mapping relationship between computing units and use the sender and receiver object descriptors to achieve cross-device data synchronization and exchange, reduce data copying and improve data exchange speed.
It enables collective communication across electronic devices, improves data exchange speed and efficiency, and reduces memory usage.
Smart Images

Figure CN120653464A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a DMA-BUF-based collective communication method, system, device, and medium. Background Art
[0002] Collective communication is a mechanism for multiple processes to collaborate to complete specific communication tasks. It is primarily used for data exchange within large-scale CPU (central processing unit) / GPU (graphics processing unit) clusters. During collective communication, Direct Shared Memory (DSM) is used for data exchange. However, this method only works within the same electronic device through shared memory and cannot exchange data across devices. Summary of the Invention
[0003] The purpose of the embodiments of the present application is to provide a DMA-BUF-based collective communication method and system, device, and medium to solve the problem in related technologies that collective communication cannot be performed across electronic devices through shared memory.
[0004] An embodiment of the present application provides a DMA-BUF-based collective communication method, which is applied to a target computing unit, wherein the target computing unit is any computing unit participating in the collective communication, and the method includes: obtaining data to be processed; storing first target data in a sending memory of the target computing unit; the first target data is data obtained after the target computing unit processes the data to be processed; sending the first target data in the sending memory of the target computing unit to a receiving memory corresponding to the sending memory according to a preset mapping relationship; the mapping relationship is used to describe the association relationship between the sending memory of the target computing unit and the receiving memory of the next computing unit; the next computing unit is a computing unit that is located one position after the target computing unit according to the data sending order of the communication link to which the data to be processed belongs.
[0005] In the above implementation process, by recording the association between the sending memory of the target computing unit and the receiving memory of the next computing unit, and sending the data in the sending memory of the target computing unit to the receiving memory of the next computing unit. If the two computing units are located in different electronic devices, the next computing unit located in the other electronic device can automatically synchronize the data of the target computing unit, so that the two computing units of different electronic devices can collaboratively process data to achieve collective communication. If the two computing units are located in the same electronic device, since the sending memory of the target computing unit can be directly accessed by the next computing unit, the sending memory of the target computing unit can be directly mapped to the receiving memory of the next computing unit, thereby reducing data copying to achieve an acceleration effect, thereby speeding up the data exchange speed of the two computing units on the same electronic device.
[0006] Furthermore, the mapping relationship is established in the following manner: upon receiving the receiving object descriptor of the next computing unit, establishing a sending object descriptor of the target computing unit that has a corresponding relationship with the receiving object descriptor of the next computing unit; the receiving object descriptor is a memory descriptor of the receiving memory; the sending object descriptor is a memory descriptor of the sending memory; and recording the association relationship between the receiving object descriptor of the next computing unit and the sending object descriptor of the target computing unit.
[0007] In the above implementation process, by establishing a sender object descriptor of the target computing unit that has a corresponding relationship with the receiver object descriptor of the next computing unit, an association can be generated between the receiver object descriptor of the next computing unit and the sender object descriptor of the target computing unit, so as to facilitate the subsequent establishment of a data synchronization relationship.
[0008] Furthermore, establishing a sender object descriptor of the target computing unit that has a corresponding relationship with the receiver object descriptor of the next computing unit includes: determining whether the next computing unit and the target computing unit are located in the same electronic device; if they are not located in the same electronic device, generating a first alternative object pointing to a preset memory space as the sender object descriptor of the target computing unit; synchronizing the data of the storage space corresponding to the sender object descriptor of the target computing unit with the data of the storage space corresponding to the receiver object descriptor of the next computing unit through a preset synchronization thread; if they are located in the same electronic device, generating a second alternative object pointing to the storage space corresponding to the receiver object descriptor of the next computing unit as the sender object descriptor of the target computing unit.
[0009] In the above implementation process, considering that if the next computing unit and the target computing unit are not located in the same electronic device, then the memory of the next computing unit and the target computing unit are not in the same electronic device, by setting a specific storage space in the next computing unit to synchronize the data of the target computing unit, cross-device data sharing can be achieved. If the next computing unit and the target computing unit are located in the same electronic device, then the next computing unit and the target computing unit can read the same shared memory, and by directly setting a second alternative object pointing to the storage space corresponding to the receiver object descriptor of the next computing unit, when the next computing unit reads the data, there is no need to copy the data, which can improve the data exchange speed between the target computing unit and the next computing unit, and can also reduce memory usage.
[0010] Furthermore, the first target data in the sending memory of the target computing unit is sent to the receiving memory corresponding to the sending memory according to a preset mapping relationship, including: the target computing unit triggers the sending thread to send the data in the sending memory of the target computing unit according to the preset mapping relationship according to the sending request to the receiving memory corresponding to the sending memory; the sending request includes the sending memory data offset position and data size of the target computing unit.
[0011] In the above implementation process, triggering the sending thread to send data through the target computing unit can facilitate timely synchronization of data to the next computing unit, so as to realize data sharing between the target computing unit and the next computing unit.
[0012] Furthermore, obtaining the data to be processed includes: receiving the data to be processed with a communication link identifier; or reading the data to be processed from a receiving memory of the target computing unit.
[0013] In the above implementation, if the target computing unit is the first computing unit in the communication link, it can directly receive externally transmitted data to begin the data processing process. If the target computing unit is not the first computing unit in the communication link, it can obtain the data synchronized by the previous computing unit by reading the data to be processed from the target computing unit's receiving memory, thereby achieving collective communication with the previous computing unit. Therefore, by providing two methods for obtaining data to be processed, different processing situations can be accommodated.
[0014] Furthermore, the method also includes: using the receiving thread of the target computing unit to monitor the data sending request of the sending thread of the previous computing unit; the previous computing unit is the computing unit that is located before the target computing unit according to the data sending order of the communication link to which the data to be processed belongs; receiving the second target data sent by the sending thread of the previous computing unit, and storing it in the receiving memory of the target computing unit according to the communication link to which the second target data belongs; the second target data is the data in the storage space corresponding to the sending memory of the previous computing unit.
[0015] In the above implementation process, by receiving the second target data of the previous computing unit, the second target data of the previous computing unit can be synchronized to the target computing unit, so as to facilitate collective communication between the previous computing unit and the target computing unit.
[0016] Furthermore, the method also includes: establishing a receiving memory and a corresponding receiving object descriptor of the target computing unit; sending the receiving object descriptor of the target computing unit to the previous computing unit; the previous computing unit is the computing unit that is located before the target computing unit according to the data sending order of the communication link to which the data to be processed belongs.
[0017] In the above implementation process, by sending the receiver object descriptor of the target computing unit to the previous computing unit, the previous computing unit can establish an accurate mapping relationship according to the receiver object descriptor of the target computing unit.
[0018] An embodiment of the present application provides a DMA-BUF-based collective communication system, including: a target computing unit, used to obtain data to be processed; storing first target data in a sending memory of the target computing unit; the first target data is data obtained after the target computing unit processes the data to be processed; sending the first target data in the sending memory of the target computing unit to a receiving memory corresponding to the sending memory according to a preset mapping relationship; the mapping relationship is used to describe the association relationship between the sending memory of the target computing unit and the receiving memory of the next computing unit; the next computing unit is a computing unit that is located one position after the target computing unit according to the data sending order of the communication link to which the data to be processed belongs; the next computing unit is used to receive the first target data in the sending memory of the target computing unit and store it in the receiving memory of the next computing unit.
[0019] Furthermore, the target computing unit is also used to establish a mapping relationship in the following manner: upon receiving the receiving object descriptor of the next computing unit, establishing a sending object descriptor of the target computing unit that has a corresponding relationship with the receiving object descriptor of the next computing unit; the receiving object descriptor is a memory descriptor of the receiving memory; the sending object descriptor is a memory descriptor of the sending memory; and recording the association relationship between the receiving object descriptor of the next computing unit and the sending object descriptor of the target computing unit.
[0020] Furthermore, the target computing unit is specifically used to establish a sender object descriptor of the target computing unit that has a corresponding relationship with the receiver object descriptor of the next computing unit in the following manner: determine whether the next computing unit and the target computing unit are located in the same electronic device; if they are not located in the same electronic device, generate a first alternative object pointing to a preset memory space as the sender object descriptor of the target computing unit; synchronize the data of the storage space corresponding to the sender object descriptor of the target computing unit with the data of the storage space corresponding to the receiver object descriptor of the next computing unit through a preset synchronization thread; if they are located in the same electronic device, generate a second alternative object pointing to the storage space corresponding to the receiver object descriptor of the next computing unit as the sender object descriptor of the target computing unit.
[0021] Furthermore, the target computing unit is used to send the first target data in the sending memory of the target computing unit to the receiving memory corresponding to the sending memory according to a preset mapping relationship in the following manner: the target computing unit triggers the sending thread to send the data in the sending memory of the target computing unit according to the preset mapping relationship according to the sending request; the sending request includes the sending memory data offset position and data size of the target computing unit.
[0022] Furthermore, the target computing unit obtains the data to be processed by: receiving the data to be processed with a communication link identifier; or reading the data to be processed from a receiving memory of the target computing unit.
[0023] Furthermore, the collective communication system also includes: a previous computing unit, which is a computing unit that is located before the target computing unit according to the data sending order of the communication link to which the data to be processed belongs; the target computing unit is also used to: use the receiving thread of the target computing unit to listen to the data sending request of the sending thread of the previous computing unit; receive the second target data sent by the sending thread of the previous computing unit, and store it in the receiving memory of the target computing unit according to the communication link to which the second target data belongs; the second target data is the data in the storage space corresponding to the sending memory of the previous computing unit.
[0024] Furthermore, the collective communication system also includes: a previous computing unit, which is a computing unit located before the target computing unit according to the data sending order of the communication link to which the data to be processed belongs; the target computing unit is also used to: establish the receiving memory of the target computing unit and the corresponding receiving object descriptor; and send the receiving object descriptor of the target computing unit to the previous computing unit.
[0025] An embodiment of the present application provides an electronic device, including a computing unit and a memory, wherein the memory stores computer-executable instructions that can be executed by the computing unit, and the computing unit executes the computer-executable instructions to implement the above-mentioned collective communication method.
[0026] An embodiment of the present application provides a computer-readable storage medium, which stores one or more programs. The one or more programs can be executed by one or more computing units to implement the above-mentioned collective communication method. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.
[0028] Figure 1 A schematic diagram of data flow for conventional data transmission across electronic devices provided in an embodiment of the present application; Figure 2 A schematic diagram of a DMA-BUF-based collective communication system provided in an embodiment of the present application; Figure 3 A schematic diagram of another DMA-BUF-based collective communication system provided in an embodiment of the present application; Figure 4A schematic diagram of data flow for data transmission between electronic devices provided in an embodiment of the present application; Figure 5 A schematic diagram of a data flow for data transmission across electronic devices provided in an embodiment of the present application; Figure 6 A schematic diagram of a method for establishing a mapping relationship provided in an embodiment of the present application; Figure 7 A schematic diagram of a DMA-BUF-based collective communication method provided in an embodiment of the present application; Figure 8 A schematic diagram of an electronic device provided in an embodiment of the present application.
[0029] Reference numerals: 1: Electronic device; 2: Computing unit; 3: Memory; 4: Communication bus. DETAILED DESCRIPTION
[0030] In order to make the purpose, technical solutions and advantages of the embodiments of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application.
[0031] For ease of understanding, some technical terms appearing in this application are explained: DMA: Direct Memory Access, direct memory access.
[0032] MPI: Message Passing Interface, message passing interface.
[0033] CC: Collective Communications, collective communications.
[0034] DMA-BUF: Direct Memory Access Buffer, direct memory access buffer.
[0035] FD: File Handler, also known as memory descriptor. File descriptors are index numbers created by the kernel to efficiently manage opened files. The user layer can use file descriptors to locate kernel-level file data. In this article, memory is used as a file for the application layer.
[0036] Bootstrap network: The Bootstrap network (a front-end framework) is a socket link network established when the GPU communication library is initialized. It is used to exchange basic information between GPUs, including the GPU's address, port information, and basic communication support description. The Bootstrap network is not used to transmit actual big computing data.
[0037] Channel: A communication link. A communication link is a data link established between GPUs. The data transferred between GPUs is typically large, so data is transferred along the channel, achieving collective communication between GPUs. Multiple communication links can be established between GPUs, depending on the hardware configuration, to maximize the use of the hardware connection between GPUs.
[0038] Collective communication is a global communication operation involving all processes in a process group. It is primarily used for data exchange within large-scale CPU / GPU clusters. Data can be exchanged between processes using a communication library compatible with the CPU / GPU. For example, a communication library such as a message passing interface (MPI) can be used to exchange data between CPU processes.
[0039] Generally speaking, communication between GPUs can utilize methods such as GPU Direct Shared Memory (DSM), GPU Direct P2P (peer-to-peer communication), and GPU Direct RDMA (remote direct memory access). Specifically, DSM allows GPUs and PCI Express (a high-speed serial computer expansion bus standard) devices to access shared memory through shared host memory. Peer-to-peer communication allows GPUs on the same PCI Express bus to directly access and transmit data. Remote direct memory access allows PCI Express devices to bypass the CPU host memory and directly access the GPU memory.
[0040] Communication between CPUs is done through a message passing interface (MPI), a communication layer based on network communication and TCP (Transmission Control Protocol) / IP (Internet Protocol). Communication between electronic devices using OpenMPI (an open source message passing interface) uses network-based socket communication to exchange data.
[0041] Combine Figure 1As shown, in the prior art, data transmission is typically performed in the following manner. Assume there are two electronic devices 1, for example, a first electronic device and a second electronic device. The first electronic device prepares a memory block, which is directly accessible to the first process of the first electronic device. After the first process writes data to the memory block, it notifies a send proxy thread to transfer the data. The send proxy thread then transmits the data contents of the memory block to the second process of the second electronic device via a socket connection. After receiving the data, the receive proxy thread of the second electronic device writes the received data to the memory space prepared by the second process of the second electronic device using pointer access. This data can only be data that needs to be processed by the process. This transmission method is the most basic method of communication between electronic devices. Because it uses a thread-based processing method, data must be accessed through pointers. Data transfer is transparent between applications, making the memory transparent to the user layer.
[0042] However, when using a direct shared memory solution, interaction can only be performed through shared memory on the same electronic device, and data interaction cannot be performed across electronic devices.
[0043] In response to the above technical problems, the embodiments of the present application propose the following technical solutions, which are compatible with the same electronic device and cross-electronic devices to perform collective communication through shared memory.
[0044] Example 1 Combine Figure 2 As shown, an embodiment of the present application provides a collective communication system based on DMA-BUF, comprising: a plurality of computing units 2. Two different computing units 2 may be located in the same electronic device 1 or in different electronic devices 1. Any computing unit 2 among the plurality of computing units 2 may be used as a target computing unit. Among the computing units 2 other than the target computing unit, according to the data sending order of the communication link to which the data to be processed obtained by the target computing unit belongs, the computing unit 2 located after the target computing unit is used as the next computing unit, and the computing unit 2 located before the target computing unit is used as the previous computing unit.
[0045] Alternatively, the computing unit 2 may be a process in the electronic device 1 participating in the collective communication.
[0046] Optionally, different Rank identifiers may be used to represent different computing units 2 . For example, Rank 1 refers to one computing unit 2 , and Rank 2 refers to another computing unit 2 .
[0047] Before collective communication is performed, it is necessary to network the computing units so that communication links can be established between them. Specifically, the communication links can be established by exchanging information over the bootstrap network.
[0048] After networking, each communication link will indicate the direction of data transmission. For example, the data transmission order of the first communication link is Rank0->Rank1->Rank2->Rank3->Rank0. The data transmission order of the second communication link is Rank0->Rank3->Rank2->Rank1->Rank0.
[0049] In some embodiments, the target computing unit is configured to: establish a receiving memory of the target computing unit and a corresponding receiving object descriptor, and further configured to send the receiving object descriptor to the previous computing unit.
[0050] The receiver object descriptor is the memory descriptor of the receiving memory. It should be understood that the receiver object descriptor of the target computing unit is the memory descriptor of the receiving memory of the target computing unit. The receiver object descriptor of the next computing unit is the memory descriptor of the receiving memory of the next computing unit.
[0051] In the above embodiment, the receiver object descriptor of the target computing unit is established as follows: after networking, the target computing unit applies for multiple storage spaces in the electronic device to which it belongs, each storage space serves as a receiving memory, and each storage space corresponds to obtaining a receiver object descriptor; wherein the number of storage spaces can be greater than or equal to the number of communication links involved in data transmission.
[0052] For example, if a computing unit is part of both the first and second communication links, then the computing unit participates in data transmission on both communication links. In this case, two storage spaces can be requested for the computing unit. One storage space can correspond to the first receiver object descriptor, such as "fd1-0," and the other storage space can correspond to the second receiver object descriptor, such as "fd1-1."
[0053] In an optional manner of the above embodiment, for each communication link, a computing unit in the communication link can be designated as the starting target computing unit. If the computing unit is the starting target computing unit, the target computing unit's receiver object descriptor is directly sent to the previous computing unit. If the computing unit is not the starting target computing unit, the target computing unit's receiver object descriptor can be sent to the previous computing unit after recording the association between the next computing unit's receiver object descriptor and the target computing unit's sender object descriptor.
[0054] For example, after networking, each computing unit will know which communication links it belongs to, which other computing unit's data it needs to receive in each communication link, and which other computing unit it needs to transmit data to. Any computing unit in a communication link can serve as the starting target computing unit, and the starting target computing unit sends a receiver object descriptor to the previous computing unit according to the transmission direction of the communication link to which it belongs. For example, the computing unit identified by Rank 0 serves as the starting target computing unit and sends a receiver object descriptor to the previous computing unit. If the starting target computing unit can serve as the next computing unit in multiple different communication links, then for each communication link, the starting target computing unit can send a receiver object descriptor to a different previous computing unit. The receiver object descriptor sent to each previous computing unit is different. In this way, by sending a different receiver object descriptor to the previous computing unit in each communication link, data in different links will not be confused during subsequent transmission, thereby improving the stability of collective communication between different computing units across devices.
[0055] It should be understood that, with respect to the previous computing unit of the target computing unit, the target computing unit is the next computing unit of the previous computing unit. For example, the data transmission order of the first communication link is Rank0->Rank1->Rank2->Rank0. When Rank2 is the target computing unit, Rank1 is the previous computing unit and Rank0 is the next computing unit. When Rank1 is the target computing unit, Rank0 is the previous computing unit and Rank2 is the next computing unit.
[0056] In another optional manner of the above embodiment, since each computing unit in this application serves as a target computing unit, each computing unit can also directly send the recipient object descriptor to the computing unit immediately preceding it. That is, each computing unit does not care whether it receives the recipient object descriptor sent by the next computing unit.
[0057] In some embodiments, the target computing unit is used to establish a mapping relationship in the following manner: upon receiving the receiving object descriptor of the next computing unit, a sending object descriptor of the target computing unit is established that corresponds to the receiving object descriptor of the next computing unit; and the association relationship between the receiving object descriptor of the next computing unit and the sending object descriptor of the target computing unit is recorded.
[0058] The sender object descriptor is the memory descriptor of the sending memory. It should be understood that the sender object descriptor of the target computing unit is the memory descriptor of the sending memory of the target computing unit. The sender object descriptor of the next computing unit is the memory descriptor of the sending memory of the next computing unit.
[0059] Exemplarily, assume that the data sending order of the first communication link is Rank0->Rank1->Rank2->Rank0. Assume that Rank0 is the selected starting target computing unit, and Rank0 sends the receiver object descriptor of Rank0 to Rank2. At this time, Rank2 receives the receiver object descriptor of the next computing unit and establishes a mapping relationship. After the mapping relationship is established, Rank2 sends the receiver object descriptor of Rank2 to Rank1. At this time, Rank1 receives the receiver object descriptor of the next computing unit and establishes a mapping relationship. After the mapping relationship is established, Rank1 sends the receiver object descriptor of Rank1 to Rank0. At this time, Rank0 receives the receiver object descriptor of the next computing unit and establishes a mapping relationship.
[0060] As another example, if the initial target computing unit is not selected, assuming that the data transmission order of the first communication link is Rank0->Rank1->Rank2->Rank0, Rank0 can directly send the receiver object descriptor of Rank0 to Rank2. At the same time, Rank2 sends the receiver object descriptor of Rank2 to Rank1. At the same time, Rank1 sends the receiver object descriptor of Rank1 to Rank0. Then, after receiving the receiver object descriptor of the corresponding next computing unit, Rank0, Rank1, and Rank2 establish the corresponding mapping relationship.
[0061] In an optional manner of the above embodiment, the target computing unit is specifically used to establish a sender object descriptor of the target computing unit that corresponds to the receiver object descriptor of the next computing unit in the following manner: determine whether the next computing unit and the target computing unit are located in the same electronic device; if they are not located in the same electronic device, generate a first candidate object pointing to a preset memory space as the sender object descriptor of the target computing unit; if they are located in the same electronic device, generate a second candidate object pointing to the storage space corresponding to the receiver object descriptor of the next computing unit as the sender object descriptor of the target computing unit.
[0062] The data in the storage space corresponding to the sender object descriptor of the target computing unit and the data in the storage space corresponding to the receiver object descriptor of the next computing unit are synchronized through a preset synchronization thread.
[0063] In the above optional method, whether the next computing unit and the target computing unit are located in the same electronic device can be determined in the following way: the IP address of the next computing unit and the IP address of the target computing unit can be obtained. If the IP address of the next computing unit and the IP address of the target computing unit are consistent, they are located in the same electronic device; otherwise, they are located in different electronic devices.
[0064] In the above optional manner, the preset memory space is a storage space of an unused memory of the electronic device to which the target computing unit belongs.
[0065] Optionally, the preset memory space can be determined by obtaining the memory size of the storage space pointed to by the receiver object descriptor of the next computing unit; and applying for storage space of the same size in the electronic device to which the target computing unit belongs as the preset memory space. This ensures that the storage space corresponding to the receiver object descriptor of the next computing unit is consistent with the storage space corresponding to the sender object descriptor of the target computing unit, thereby facilitating data synchronization.
[0066] Optionally, the computing unit may pre-apply for multiple storage spaces of the same capacity, and select any one of the storage spaces to create a corresponding recipient object descriptor. Accordingly, any one of the storage spaces may be selected as the preset memory space.
[0067] In the above optional method, two computing units located on the same electronic device can generate a second alternative object pointing to the storage space corresponding to the recipient object descriptor of the next computing unit through the import mechanism of the direct memory access buffer (a method in which a process introduces the memory descriptors of other processes into the address space of the current process through the system interface of the shared buffer, so as to directly access the storage space corresponding to the memory descriptors of other processes without copying data).
[0068] In some embodiments, a synchronization thread may be established when establishing a mapping relationship. For example, when the next computing unit sends a receiving object descriptor, a receiving thread is established in the next computing unit, and when the target computing unit receives the receiving object descriptor sent by the next computing unit, a sending thread is established.
[0069] For example, a send memory and its corresponding receive memory can be referred to as a pair of memories. A synchronization thread can be established for each memory pair, so that each synchronization thread is responsible for a single memory pair. Alternatively, a send thread and a receive thread can be established for a single computing unit, with the send thread centrally managing data sent by the computing unit and the receive thread centrally managing data received by the computing unit.
[0070] In some embodiments, the target computing unit is configured to establish a correspondence between a sending memory and a receiving memory of the target computing unit.
[0071] Optionally, after establishing the sender object descriptor of the target computing unit corresponding to the receiver object descriptor of the next computing unit, the correspondence between the receiver object descriptor of the target computing unit and the sender object descriptor of the target computing unit is recorded.
[0072] In the above embodiment, the IP address of the next computing unit that has a mapping relationship with the sender object descriptor of the target computing unit may also be recorded in the target computing unit.
[0073] For example, combined Figure 3 As shown, the correspondence between the receiver object descriptor of the target computing unit and the sender object descriptor of the target computing unit can be recorded in the form of a mapping table. Each set of associations in the mapping table includes three attributes. The first attribute: the receiver object descriptor in this computing unit; represented by fdx-y, x represents the Rank identifier of this process, and y represents the sequence number of FD. The second attribute: the sender object descriptor in this computing unit; represented by rfdx-y, x represents the Rank identifier of the receiver process corresponding to the sender object descriptor of the computing unit, and y represents the sequence number of FD. The third attribute: the IP address of the next computing unit corresponding to the sender object descriptor of this computing unit.
[0074] For example, combined Figure 3 As shown, there are three electronic devices: a first electronic device, a second electronic device, and a third electronic device. The first and third computing units belong to the first electronic device, the second computing unit belongs to the second electronic device, and the fourth computing unit belongs to the third electronic device. The IP addresses of the first and third electronic devices are IP0, the IP address of the second electronic device is IP1, and the IP address of the third electronic device is IP2. The first, second, third, and fourth computing units form a ring, and two communication links are established to utilize the bidirectional bandwidth of each computing unit. The direction indicated by the arrow in each communication link indicates the direction of data transmission. In the first communication link, the data transmission order is first computing unit -> second computing unit -> fourth computing unit -> third computing unit -> first computing unit. In the second communication link, the data transmission order is first computing unit -> third computing unit -> fourth computing unit -> second computing unit -> first computing unit.
[0075] Each computing unit acts as a target computing unit and establishes a link relationship with other computing units. For example, the first computing unit establishes a link with the second and third computing units. In the first communication link, the first computing unit acts as the sender, sending data to the second computing unit. In the second channel, the first computing unit acts as the sender, sending data to the third computing unit.
[0076] For the first communication link: First, the second computing unit sends the fd1-0 object (the receiver object descriptor of the next computing unit) to the first computing unit. Secondly, the second computing unit establishes the receiver's receiving thread for the first communication link, and listens for the data sending request of the first communication link of the first computing unit. Then, the first computing unit receives the fd1-0 object of the second computing unit as the receiver, and determines whether the first computing unit and the second computing unit are on the same electronic device. Since the second computing unit and the first computing unit are not on the same electronic device, the first computing unit will create a new rfd1-0 object (the sender object descriptor of the target computing unit), and then add a record to the first computing unit mapping table. The record describes the correspondence between the fd0-0 object of the first computing unit (the receiver object descriptor of the target computing unit) and the rfd1-0 object, such as Figure 3 The first column and the second column of the first row in the first computing unit mapping table can also record the IP address of the second computing unit, that is, the IP address of the next computing unit pointed by the arrow can be recorded, such as Figure 3 The first computing unit maps the first row to the third column of the table. Finally, the first computing unit establishes a sending thread to synchronize data in the storage space corresponding to the rfd1-0 object of the first computing unit to the storage space corresponding to the fd1-0 object of the second computing unit. The receiving thread of the second computing unit is used to receive data sent by the sending thread.
[0077] For the second communication link: First, the third computing unit sends the fd3-1 object (the receiver object descriptor of the next computing unit) to the first computing unit. Secondly, the third computing unit establishes the receiver's receiving thread for the second communication link, and listens for the data sending request of the second communication link of the first computing unit. Then, the first computing unit receives the fd3-1 object of the third computing unit as the receiver, and determines whether the first computing unit and the third computing unit are on the same electronic device. Since the third computing unit and the first computing unit are on the same electronic device, the first computing unit will directly reference the fd3-1 object to generate rfd3-1 (the sender object descriptor of the target computing unit), and then add a record to the first computing unit mapping table, which describes the correspondence between the fd0-1 object of the first computing unit (the receiver object descriptor of the target computing unit) and rfd3-1, such as Figure 3 The first and second columns of the second row in the first computing unit mapping table can also record the IP address of the third computing unit, such as Figure 3 The first computing unit maps the second row and third column of the table. Finally, the first computing unit establishes a sending thread for the second communication link. Since the first and third computing units in the second communication link belong to the same electronic device, only synchronization notifications are required between the sending thread of the first computing unit and the receiving thread of the third computing unit to ensure data read and write integrity.
[0078] In some embodiments, once the mapping relationship is established, each computing unit can begin collective communication. The target computing unit is used to obtain the data to be processed; the first target data is stored in the sending memory of the target computing unit; the first target data is the data obtained after the target computing unit processes the data to be processed; the first target data in the sending memory of the target computing unit is sent to the receiving memory corresponding to the sending memory according to the preset mapping relationship; the mapping relationship is used to describe the association between the sending memory of the target computing unit and the receiving memory of the next computing unit. The next computing unit is used to receive the first target data in the sending memory of the target computing unit and store it in the receiving memory of the next computing unit.
[0079] In the above embodiment, the target computing unit obtains the data to be processed in the following manner: receiving the data to be processed with a communication link identifier; or reading the data to be processed from the receiving memory of the target computing unit.
[0080] In the above embodiment, if the data to be processed is read from the receiving memory of the target computing unit, correspondingly, storing the first target data in the sending memory of the target computing unit may be: according to the correspondence between the receiving memory of the target computing unit and the sending memory of the target computing unit, storing the first target data in the sending memory of the target computing unit.
[0081] In the above embodiment, the target computing unit is used to send the first target data in the sending memory of the target computing unit to the receiving memory corresponding to the sending memory according to the preset mapping relationship in the following manner: the target computing unit triggers the sending thread to send the data in the sending memory of the target computing unit to the receiving memory corresponding to the sending memory according to the preset mapping relationship according to the sending request.
[0082] The sending request includes the sending memory data offset position and data size of the target computing unit.
[0083] In the above embodiment, the target computing unit is also used to use the receiving thread of the target computing unit to monitor the data sending request of the sending thread of the previous computing unit; receive the second target data sent by the sending thread, and store it in the receiving memory of the target computing unit according to the communication link to which the second target data belongs.
[0084] The second target data is the data in the storage space corresponding to the sending memory of the previous computing unit.
[0085] Combine Figure 3 and Figure 4 As shown, the first computing unit and the third computing unit are on the same electronic device. Therefore, when establishing the link relationship of the first computing unit -> the third computing unit on the second communication link, the IP address recorded in the third attribute of the second item in the mapping table of the first computing unit is the IP address of the first electronic device where the first computing unit is located. Although rfd0-0 and fd0-0 are different at this time, rfd0-0 and fd0-0 point to the same block of memory. However, since the first computing unit and the third computing unit belong to different processes, the third computing unit can reference the memory pointed to by fd0-0 through the import mechanism of the direct memory access buffer to generate a new rfd0-0. In this way, the receiver and the sender actually point to the same block of memory. As shown Figure 4 As shown, the sender object descriptor of the target computing unit and the receiver object descriptor of the next computing unit point to the same block of memory. In fact, the sending thread and the receiving thread do not need to synchronize data. After the computing unit completes the calculation, it only needs to complete the data update action from the fd of the first attribute to the rfd of the second attribute according to the mapping table of the specified communication link to realize the communication between the first computing unit and the third computing unit.
[0086] Combine Figure 3 and Figure 5 As shown, the first computing unit and the second computing unit are not on the same electronic device, and their IP addresses are different. Therefore, when the first computing unit and the second computing unit establish a first communication link, fd1-0 and rfd1-0 point to different memories. Therefore, a preset synchronization thread is required between fd1-0 and rfd1-0 to synchronize data, for example, data synchronization is performed through a sending thread and a receiving thread. The preset synchronization thread will be responsible for synchronizing the content corresponding to rfd1-0 of the first computing unit to the storage space pointed to by fd1-0 of the second computing unit. Figure 5As shown, since the memory between different electronic devices cannot be directly shared, the target computing unit's rfdx-y and the next computing unit's fdx-y are synchronized through a preset synchronization thread. That is, the sender object descriptor of the target computing unit and the receiver object descriptor of the next computing unit are synchronized through the sending thread and the receiving thread. When the target computing unit completes the calculation of the data to be processed, it stores the first target data in the memory object of the second attribute rfd according to the corresponding relationship recorded in the mapping table. This facilitates the consistency of the data described between the target computing unit's rfdx-y and the next computing unit's fdx-y.
[0087] Combine Figure 3 As shown, using the first communication link as an example, the receiving thread of the first computing unit saves the received data to fd0-0. The first computing unit obtains the data to be processed from fd0-0, processes the data to obtain the first target data, and stores the first target data in rfd1-0. The first computing unit then notifies the sending thread to send the first target data to the second computing unit. The receiving thread of the second computing unit saves the received data to fd1-0. The second computing unit obtains the data to be processed from fd1-0, processes the data to obtain the first target data, and stores the first target data in rfd2-0. The fourth and third computing units repeat the above operations to complete data processing. In this way, by synchronizing the sending and receiving threads, after the sending thread sends data, the receiving thread of the next computing unit will not overwrite the existing data in the receiving memory if the main process has not yet completed processing the data. In other words, the receiving thread needs to synchronize with the main process. If the main process has not yet completed processing the data, the memory location corresponding to the data cannot be overwritten. Semaphores are typically used for synchronization between the receiving thread and the main process.
[0088] Example 2 See Figure 6 , Figure 6 A method for establishing a mapping relationship provided in an embodiment of the present application is for a single communication link: S101, the next computing unit sends the receiver object descriptor of the next computing unit to the target computing unit.
[0089] S102: The next computing unit establishes a receiving thread for its corresponding communication link.
[0090] S103, the target computing unit receives the receiving object descriptor of the next computing unit, establishes a sending object descriptor of the target computing unit that corresponds to the receiving object descriptor of the next computing unit, and records the association relationship between the receiving object descriptor of the next computing unit and the sending object descriptor of the target computing unit.
[0091] S104: The target computing unit establishes a sending thread for its communication link.
[0092] In the above method, the receiving thread is used to monitor the data sending request of the sending thread belonging to the same communication link.
[0093] In the above method, the sending thread is used to send data to the receiving thread belonging to the same communication link according to the sending request of the target computing unit.
[0094] In some embodiments, establishing a sender object descriptor of a target computing unit that has a corresponding relationship with a receiver object descriptor of a next computing unit includes: determining whether the next computing unit and the target computing unit are located on the same electronic device; if they are not located on the same electronic device, generating a first candidate object pointing to a preset memory space as the sender object descriptor of the target computing unit; synchronizing data in the storage space corresponding to the sender object descriptor of the target computing unit with data in the storage space corresponding to the receiver object descriptor of the next computing unit through a preset synchronization thread; if they are located on the same electronic device, generating a second candidate object pointing to the storage space corresponding to the receiver object descriptor of the next computing unit as the sender object descriptor of the target computing unit.
[0095] See also Figure 7 , Figure 7 A DMA-BUF-based collective communication method provided in an embodiment of the present application includes: S201, the target computing unit obtains data to be processed from the receiving memory of the target computing unit.
[0096] S202: The target computing unit processes the data to be processed to obtain first target data, and stores the first target data into a sending memory of the target computing unit.
[0097] S203, the target computing unit triggers the sending thread to send the data in the sending memory of the target computing unit according to the sending request and the preset mapping relationship to the receiving memory of the next computing unit corresponding to the sending memory.
[0098] S204, the next computing unit receives the data and stores it in the receiving memory of the next computing unit.
[0099] In some embodiments, obtaining the data to be processed includes: receiving the data to be processed with a communication link identifier; or reading the data to be processed from a receiving memory of a target computing unit.
[0100] In some embodiments, after the collective communication process is created, the collective communication process independently determines which portion of data should be routed through which channel. For example, assuming 100 megabytes of data, 50 megabytes might be allocated to the first communication link, and the remaining 50 megabytes to the second communication link. Taking the first communication link as an example, the 50 megabytes of data are sequentially processed by each computing unit within the first communication link, following the data transmission direction of the first communication link. The data initially distributed by the electronic device to the computing unit, bearing the communication link identifier, may be the data to be processed by that computing unit.
[0101] In some embodiments, the computing unit may perform operations on data, such as addition, subtraction, multiplication, and division.
[0102] In some embodiments, the first target data in the sending memory of the target computing unit is sent to the receiving memory corresponding to the sending memory according to a preset mapping relationship, including: the target computing unit triggers a sending thread to send the data in the sending memory of the target computing unit to the receiving memory corresponding to the sending memory according to a preset mapping relationship according to a sending request; the sending request includes the data offset position and data size of the sending memory of the target computing unit.
[0103] In some embodiments, the collective communication method also includes: using the receiving thread of the target computing unit to listen to the data sending request of the sending thread of the previous computing unit; receiving the second target data sent by the sending thread, and storing it in the receiving memory of the target computing unit according to the communication link to which the second target data belongs; the second target data is the data in the storage space corresponding to the sending memory of the previous computing unit.
[0104] In some embodiments, the collective communication method further includes: establishing a receiving memory of the target computing unit and a corresponding receiving object descriptor; and sending the receiving object descriptor to the previous computing unit.
[0105] It can be understood that the various embodiments described in the first embodiment are also applicable to the second embodiment if there is no conflict. For the sake of brevity, they will not be repeated here.
[0106] Example 3 This embodiment provides an electronic device 1, see Figure 8 As shown, it includes a computing unit 2, a memory 3 and a communication bus 4. Among them: The communication bus 4 is used to realize the connection and communication between the computing unit 2 and the memory 3 .
[0107] The computing unit 2 is configured to execute one or more programs stored in the memory 3 to implement the collective communication method in the first embodiment and / or the second embodiment.
[0108] I understand. Figure 8 The structure shown is only for illustration, and the electronic device may also include Figure 8 More or fewer components than shown, or with Figure 8 Different configurations shown.
[0109] In the embodiment of the present application, the electronic device may be, for example, a server, a computer, etc.
[0110] This embodiment further provides a computer-readable storage medium, such as a floppy disk, an optical disk, a hard disk, a flash memory, a USB flash drive, an SD (Secure Digital Memory Card), or an MMC (Multimedia Card). The computer-readable storage medium stores one or more programs for implementing the aforementioned steps. These one or more programs can be executed by one or more computing units to implement the collective communication method of the aforementioned first and / or second embodiments. This description is omitted here.
[0111] The technical solutions of the embodiments of the present application can be embodied in the form of a software product, which is stored in a storage medium and includes one or more instructions for causing a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method of the embodiments of the present application. The aforementioned storage medium can be a non-transitory storage medium, including: a USB flash drive, a mobile hard disk, a read-only memory, a random access memory, a magnetic disk, an optical disk, and other media that can store program code, or a transient storage medium.
[0112] In the embodiments provided herein, it should be understood that the disclosed devices and methods may be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is merely a logical functional division, and actual implementations may employ other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be omitted or not implemented.
[0113] The above are merely examples of the present application and are not intended to limit the scope of protection of the present application. Those skilled in the art will appreciate that various modifications and variations are possible. Any modifications, equivalent substitutions, improvements, and the like made within the spirit and principles of the present application are intended to be included within the scope of protection of the present application. Furthermore, the above examples may be combined with one another to form new examples, unless they conflict.
Claims
1. A collective communication method based on DMA-BUF, characterized in that: Applied to a target computing unit, where the target computing unit is any computing unit participating in collective communication, the method includes: Get the data to be processed; storing first target data in a sending memory of the target computing unit; the first target data is data obtained after the target computing unit processes the data to be processed; According to a preset mapping relationship, the first target data in the sending memory of the target computing unit is sent to the receiving memory corresponding to the sending memory; the mapping relationship is used to describe the association between the sending memory of the target computing unit and the receiving memory of the next computing unit; the next computing unit is the computing unit that is located one position after the target computing unit according to the data sending order of the communication link to which the data to be processed belongs.
2. The method according to claim 1, characterized in that The mapping relationship is established in the following way: When receiving the receiving object descriptor of the next computing unit, establishing a sending object descriptor of the target computing unit that has a corresponding relationship with the receiving object descriptor of the next computing unit; The receiving object descriptor is the memory descriptor of the receiving memory; the sending object descriptor is the memory descriptor of the sending memory; An association relationship between the receiver object descriptor of the next computing unit and the sender object descriptor of the target computing unit is recorded.
3. The method according to claim 2, characterized in that Establishing a sender object descriptor of the target computing unit that corresponds to a receiver object descriptor of the next computing unit includes: determining whether the next computing unit and the target computing unit are located in the same electronic device; In the case where the two computing units are not located in the same electronic device, a first candidate object pointing to a preset memory space is generated as a sender object descriptor of the target computing unit; data in the storage space corresponding to the sender object descriptor of the target computing unit is synchronized with data in the storage space corresponding to the receiver object descriptor of the next computing unit through a preset synchronization thread; In the case of being located in the same electronic device, a second candidate object pointing to the storage space corresponding to the receiver object descriptor of the next computing unit is generated as the sender object descriptor of the target computing unit.
4. The method according to claim 1, wherein The method includes sending the first target data in the sending memory of the target computing unit to the receiving memory corresponding to the sending memory according to a preset mapping relationship, including: The target computing unit triggers the sending thread to send the data in the sending memory of the target computing unit to the receiving memory corresponding to the sending memory according to the preset mapping relationship according to the sending request; the sending request includes the sending memory data offset position and data size of the target computing unit.
5. The method according to claim 1, wherein Get the data to be processed, including: receiving data to be processed with a communication link identifier; or, The data to be processed is read from the receiving memory of the target computing unit.
6. The method according to any one of claims 1 to 5, characterized in that The method further comprises: Using the receiving thread of the target computing unit to monitor the data sending request of the sending thread of the previous computing unit; the previous computing unit is the computing unit that is located before the target computing unit according to the data sending order of the communication link to which the data to be processed belongs; Receive the second target data sent by the sending thread of the previous computing unit, and store it in the receiving memory of the target computing unit according to the communication link to which the second target data belongs; the second target data is the data in the storage space corresponding to the sending memory of the previous computing unit.
7. The method according to any one of claims 1 to 5, characterized in that The method further comprises: Establishing a receiving memory of the target computing unit and a corresponding receiving object descriptor; The receiver object descriptor of the target computing unit is sent to a previous computing unit; the previous computing unit is a computing unit that is located before the target computing unit according to the data sending order of the communication link to which the data to be processed belongs.
8. A DMA-BUF based collective communication system, characterized in that: include: A target computing unit, used to obtain data to be processed; storing the first target data in a transmission memory of the target computing unit; The first target data is data obtained after the target computing unit processes the data to be processed; Sending the first target data in the sending memory of the target computing unit to the receiving memory corresponding to the sending memory according to a preset mapping relationship; The mapping relationship is used to describe the association relationship between the sending memory of the target computing unit and the receiving memory of the next computing unit; The next computing unit is a computing unit that is located one position after the target computing unit according to the data transmission order of the communication link to which the data to be processed belongs; The next computing unit is used to receive the first target data in the sending memory of the target computing unit and store the first target data in the receiving memory of the next computing unit.
9. An electronic device, characterized in that: The invention comprises a computing unit and a memory, wherein the memory stores computer-executable instructions that can be executed by the computing unit, and the computing unit executes the computer-executable instructions to implement the collective communication method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more computing units to implement the collective communication method according to any one of claims 1 to 7.