Data synchronization method and device and computing equipment
By detecting the sources of multiple atomic instructions, the cache unit executes the same-source instructions locally, reducing data communication with the HA, solving the problem of high cost of data synchronization communication between the cache unit and the HA, and improving the execution performance of the application.
Patent Information
- Application Number
- CN202410367888.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-26
- Publication Date
- 2025-09-26
Smart Images

Figure CN120704907A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data storage technology, and in particular to a data synchronization method, device and computing equipment. Background Art
[0002] As application loads increase, the processing power of a single processor or core becomes limited. To improve application performance, applications can run parallel portions on multiple processors or cores simultaneously, allowing multiple processors or cores to run the application simultaneously. However, when multiple processors or cores run an application simultaneously, data synchronization between them is required, which can hinder application performance. Summary of the Invention
[0003] To address the aforementioned issues, embodiments of the present application provide a data synchronization method that can reduce atomic instructions and / or Snoop requests between a cache unit and a HA, thereby reducing the data communication cost of the cache unit. Furthermore, the present application also provides a data synchronization apparatus and computing device corresponding to the data synchronization method.
[0004] To this end, the following technical solutions are adopted in the embodiments of the present application:
[0005] In a first aspect, an embodiment of the present application provides a data synchronization method, wherein the data synchronization system includes multiple first cache units and one second cache unit, the second cache unit is deployed with a local agent, and the method is executed by the second cache unit, including: receiving a first detection Snoop request sent by a target first cache unit; the first Snoop request is used to indicate that the shared data cached by the target first cache unit is modified; the multiple first cache units include the target first cache unit; based on the first Snoop request, a second Snoop request is generated; the second Snoop request is used to indicate that the first cache unit other than the target first cache unit in the multiple first cache units passes through atomic instructions; and the second Snoop request is sent to the first cache unit other than the target first cache unit in the multiple first cache units.
[0006] In this embodiment, after receiving a Snoop request from one of the multiple first cache units, the second cache unit can send Snoop requests to the other first cache units, allowing the other first cache units to transparently transmit atomic instructions. When the other first cache units send atomic instructions to the second cache unit, they do not need to transmit Snoop requests to the second cache unit, thereby reducing the data communication cost of the first cache units.
[0007] In one embodiment, the method also includes: receiving multiple atomic instructions sent by the same first cache unit; the first cache units other than the target first cache unit in the multiple first cache units include the same first cache unit; the atomic instruction carries identification information; the identification information refers to the identification stored by the processor that sends the atomic instruction; when the identification information carried by the multiple atomic instructions is the same, sending a synchronization instruction to the same first cache unit; the synchronization instruction is used to instruct the same first cache unit to perform an atomic operation based on the atomic instruction after receiving the atomic instruction.
[0008] In this embodiment, when the second cache unit receives multiple atomic instructions from the same first cache unit, if the multiple atomic instructions originate from the same processor or processors in the same server cluster, the second cache unit can send a synchronization instruction to the first cache unit. After receiving the synchronization instruction, the first cache unit can process the atomic instructions locally without transparently transmitting the atomic instructions to the second cache unit, which can further reduce the data communication cost of the first cache unit.
[0009] In one embodiment, the method further includes: receiving a synchronization message sent by the same first cache unit; the synchronization message is used to instruct the second cache unit to modify the status information of the modified shared data of the same first cache unit recorded in the directory table.
[0010] In this embodiment, after the first cache unit locally performs an atomic operation based on multiple atomic instructions, it can send the modified state information of the synchronization data to the second cache unit. The second cache unit modifies the state information recorded in the directory table so that the shared data remains consistent in other first cache units.
[0011] In one embodiment, generating a second Snoop request based on the first Snoop request specifically includes: modifying the status information of the modified shared data of the target first cache unit recorded in the locally stored target table according to the first Snoop request; the directory table includes multiple cache lines, each cache line records the status information of a first cache unit caching a shared data; generating a second Snoop request according to the modified status information of the modified shared data of the target first cache unit.
[0012] In one embodiment, modifying the status information of the modified shared data of the target first cache unit recorded in the locally stored target table according to the first Snoop request specifically includes: modifying the "whether independent" status of the modified shared data of the target first cache unit recorded in the target table to an "independent" status according to the first Snoop request.
[0013] In one embodiment, the method further includes: after receiving multiple atomic instructions sent by the first cache units other than the target first cache unit among the multiple first cache units, performing atomic operations based on the multiple atomic instructions sent by the first cache units other than the target first cache unit among the multiple first cache units.
[0014] In this embodiment, after receiving multiple atomic instructions sent by the first cache units, the second cache unit can directly perform atomic operations based on the atomic instructions without transmitting Snoop requests to the first cache unit, thereby reducing the data communication cost of the first cache unit.
[0015] In the second aspect, an embodiment of the present application provides a data synchronization device, including: a first processing unit, for receiving a first Snoop request sent by a target first cache unit; the first Snoop request is used to indicate that the shared data cached by the target first cache unit is modified; the multiple first cache units include the target first cache unit; a second processing unit, for generating a second Snoop request based on the first Snoop request; the second Snoop request is used to indicate that the first cache unit other than the target first cache unit in the multiple first cache units passes through the atomic instruction; a third processing unit, for sending the second Snoop request to the first cache unit other than the target first cache unit in the multiple first cache units.
[0016] In one embodiment, the third processing unit is further used to receive multiple atomic instructions sent by the same first cache unit; the first cache units other than the target first cache unit in the multiple first cache units include the same first cache unit; the atomic instruction carries identification information; the identification information refers to the identification stored by the processor that sends the atomic instruction; the third processing unit is also used to send a synchronization instruction to the same first cache unit when the identification information carried by the multiple atomic instructions is the same; the synchronization instruction is used to instruct the same first cache unit to perform an atomic operation based on the atomic instruction after receiving the atomic instruction.
[0017] In one embodiment, the third processing unit is further used to receive a synchronization message sent by the same first cache unit; the synchronization message is used to instruct the second cache unit to modify the status information of the modified shared data of the same first cache unit recorded in the directory table.
[0018] In one embodiment, the second processing unit is specifically used to modify the status information of the modified shared data of the target first cache unit recorded in the locally stored target table according to the first Snoop request; the directory table includes multiple cache lines, each cache line records the status information of a first cache unit caching a shared data; the second processing unit is specifically used to generate a second Snoop request according to the modified status information of the modified shared data of the target first cache unit.
[0019] In one embodiment, the second processing unit is specifically configured to modify the "whether independent" state of the modified shared data of the target first cache unit recorded in the target table to an "independent" state according to the first Snoop request.
[0020] In one embodiment, the third processing unit is further used to perform atomic operations based on the multiple atomic instructions sent by the first cache units other than the target first cache unit among the multiple first cache units after receiving the multiple atomic instructions sent by the first cache units other than the target first cache unit among the multiple first cache units.
[0021] In a third aspect, an embodiment of the present application provides a computing device, comprising: at least one memory; and at least one processor, the processor being configured to execute instructions stored in the memory so that the computing device executes various possible implementations of the first aspect.
[0022] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium comprising computer program instructions. When the computer program instructions are executed by a network device, the computing device executes the various possible implementations of the first aspect.
[0023] In a fifth aspect, an embodiment of the present application provides a computer program product comprising instructions, characterized in that the computer program product stores instructions, which, when executed by a network device, enable the network device to implement various possible implementation embodiments of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The following is a brief introduction to the drawings required for describing the embodiments or prior art.
[0025] Figure 1 A schematic diagram of the structure of a data synchronization system provided in an embodiment of the present application;
[0026] FIG2( a ) is a schematic diagram of a process in which multiple processing units perform data synchronization through two cache blocks according to an embodiment of the present application;
[0027] FIG2( b ) is a schematic diagram of a process of synchronizing data between multiple processing units through a cache block according to an embodiment of the present application;
[0028] Figure 3 A flowchart of a data synchronization method provided in an embodiment of the present application;
[0029] Figure 4 This is a structural diagram of a data synchronization device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0030] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0031] The term "and / or" as used herein describes an association between related objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A exists alone, A and B exist simultaneously, or B exists alone. The symbol " / " as used herein indicates that the related objects are in an "or" relationship, for example, A / B means either A or B.
[0032] The terms "first" and "second" in this specification and claims are used to distinguish different objects rather than to describe a specific order of objects. For example, "first response message" and "second response message" are used to distinguish different response messages rather than to describe a specific order of response messages.
[0033] In the embodiments of this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of this application should not be interpreted as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.
[0034] In the description of the embodiments of the present application, unless otherwise specified, "multiple" means two or more, for example, multiple processing units means two or more processing units, etc.; multiple elements means two or more elements, etc.
[0035] Before introducing the technical solution protected by this application, several professional terms involved in the technical solution protected by this application are explained in advance, namely:
[0036] Data synchronization is the process of ensuring that different data remains consistent across different locations. In computing, data synchronization refers to updating and exchanging data between multiple devices, systems, or applications to ensure consistency across them.
[0037] A network on chip (NoC) is a new system-level chip interconnect structure used to connect on-chip components. By combining concepts and methods from electronic design automation (EDA) with computer networking technology, NoC can build complex communication structures on a single chip, enabling high-speed data transmission and communication between different chips.
[0038] A home agent (HA) is a key component in mobile Internet Protocol (IP) networks, managing the roles of mobile devices as they transition between different networks. HA is typically an availability strategy designed to enable seamless failover and automatic recovery in the event of a system or service failure. The primary goal of HA is to ensure business continuity and data consistency, minimizing service interruptions and data loss.
[0039] Atomic instructions are processor-level operations that ensure an operation is indivisible: either all operations are executed successfully or none are executed at all. These instructions typically include atomic addition, atomic subtraction, and atomic swap, enabling atomic data manipulation without locking. Atomic instructions are suitable for simple data synchronization scenarios, such as incrementing counters and flagging bits.
[0040] Snoop requests are a communication mechanism used in cache coherence protocols, typically transmitted over a bus or interconnect network between processors. A snoop request can be either an initiating processor actively sending a request to a target processor or a request passively received by the target processor. When a processor (called the "initiating processor") writes to data in its cache, it sends a snoop request to the target processor to ensure the consistency of the data in the cache of the other processor (called the "target processor").
[0041] Take processors as an example. There are two ways to synchronize data between multiple processors: one is through non-shared memory, and the other is through shared memory. In non-shared memory cross-process scenarios, multiple processors can synchronize data using a message passing interface (MPI) or other methods. MPI is a parallel computing communication protocol used for communication and synchronization between processes in distributed memory systems, and is suitable for high-performance computing and scientific computing.
[0042] In cross-process shared memory scenarios, since shared memory allows multiple processes to access the same physical block, multiple processors can directly read and write shared memory, thereby achieving data sharing and synchronization. Typically, when multiple processors synchronize data through shared memory, they can use atomic instructions, hardware transactional memory (HTM)-based synchronization, and lock-based synchronization to ensure that multiple threads or processes access and modify shared data correctly and in an orderly manner.
[0043] In related technologies, atomic operations are implemented using two cache blocks during data synchronization between multiple processors based on atomic instructions. When multiple processors access shared memory, the two cache blocks transparently transmit the atomic instructions to the HA in the NoC, allowing the HA to perform the atomic operations. However, if the two cache blocks receive multiple atomic instructions belonging to the same processor or processor cluster, these instructions will still be transparently transmitted to the HA in the NoC, increasing the data communication overhead between the two cache blocks and the HA.
[0044] In order to solve the defects existing in the related art, an embodiment of the present application provides a data synchronization method that can detect whether multiple atomic instructions received continuously belong to the same processor or a processor cluster. If multiple atomic instructions do not belong to the same processor or a processor cluster, the cache block can pass the multiple atomic instructions to the HA, allowing the HA to perform atomic operations based on the multiple atomic instructions. If multiple atomic instructions belong to the same processor or a processor cluster, the cache block can perform atomic operations locally, which can avoid data transmission between the cache block and the HA, thereby reducing the data communication cost of the cache block.
[0045] Figure 1 This is a schematic diagram of the architecture of a data synchronization system provided in an embodiment of the present application. Figure 1 As shown, the data synchronization system 100 may include multiple processing units 110, at least one first cache unit 120, and a second cache unit 130. The multiple processing units 110 may be processing unit 110-1, processing unit 110-2, ..., processing unit 110-N. N is a positive integer greater than or equal to 2. The at least one first cache unit 120 may be first cache unit 120-1, first cache unit 120-2, ..., first cache unit 120-M.
[0046] Processing unit 120 refers to a processor that runs systems or applications in parallel. Processing unit 120 can be a central processing unit (CPU), a graphics processing unit (GPU), a neural processing unit (NPU), or other processors. Processing unit 120 can be a CPU core, a GPU core, an NPU core, or the like. Multiple processing units 120 can be processors of a single computing device or multiple computing devices.
[0047] In an embodiment of the present application, each processing unit 110 can establish a communication connection with a first cache unit 120, and each first cache unit 120 can establish a communication connection with multiple processing units 110, so that the first cache unit 120 can serve as a shared memory of the processing unit 110. When some or all of the multiple processing units 110 run a system or application in parallel, an atomic instruction can be sent to the first cache unit 120 to which it is connected to instruct the first cache unit 120 to perform an atomic operation based on the atomic instruction, thereby achieving data synchronization. The atomic instruction carries identification information, such as the identity number (ID) of the processing unit 110, so that the first cache unit 120 can identify which processing unit 110 sent the atomic instruction.
[0048] The first cache unit 120 may be a memory for temporarily storing data, such as a register or a last level cache (LLC), and is used to store data that needs to be temporarily stored during the operation of the processing unit 110 for access or operation by the processing unit 110 or other hardware.
[0049] In an embodiment of the present application, the first cache unit 120 can establish a communication connection with multiple processing units 110 to receive atomic instructions issued by each processing unit 110. After the first cache unit 120 continuously receives multiple atomic instructions, it can parse out the identification information carried in each atomic instruction to obtain the identification information of each atomic instruction. The first cache unit 120 can detect whether the identification information of each atomic instruction is the same. In one case, when the first cache unit 120 determines that the identification information of each atomic instruction is different, each atomic instruction can be sent to the second processing unit 130, allowing the second processing unit 130 to perform atomic operations based on each atomic instruction, thereby achieving data synchronization.
[0050] In another case, when the first cache unit 120 determines that the identification information of each atomic instruction is the same, the atomic operation can be performed locally. The first cache unit 120 can perform atomic operations based on each atomic instruction to achieve data synchronization. The atomic instructions can be instructions such as compare and swap (CAS), load linked / store conditional (LL / SC), etc.
[0051] In one embodiment, when the atomic instruction received by the first cache unit 120 is a CAS instruction, it may prioritize comparing the value in memory with the expected value to see if they are equal. If they are equal, the new value is written to the memory. If they are not equal, it indicates that another thread has modified the value in memory during the comparison and writing process. In this case, the first cache unit 120 abandons the operation, avoiding race conditions and data inconsistency issues, thereby ensuring secure access and updates to shared data.
[0052] In another embodiment, when the atomic instruction received by the first cache unit 120 is an LL / SC instruction, during the LL operation, the first cache unit 120 may load a value at a memory address that requires an SC operation to modify. During the SC operation, if the first cache unit 120 detects that the loaded value has been modified, it indicates that another processor has modified the memory address between the LL and SC operations. In this case, the first cache unit 120 abandons the operation, thereby avoiding race conditions and data inconsistency issues, thereby ensuring atomic operations in a multi-processor system.
[0053] In an embodiment of the present application, after receiving one or more atomic instructions, the first cache unit 120 can perform atomic operations based on the atomic instructions to achieve data synchronization. The first cache unit 120 can check the status of a cache line after completing data synchronization and generate a Snoop request. The first cache unit 120 can send the Snoop request to the second cache unit 130 to inform the second cache unit 130 and / or other first cache units 120 that the local shared data has been modified.
[0054] In the embodiment of the present application, after receiving the Snoop request sent by the second cache unit 130, the first cache unit 120 determines that the shared data has been modified and needs to update the locally cached shared data. Since the first cache unit 120 does not have the modified shared data, the first cache unit 120 can forward the received atomic instructions to the second cache unit 130, allowing the second cache unit 130 to perform atomic operations based on each atomic instruction, thereby achieving data synchronization.
[0055] The second cache unit 130 refers to a cache deployed with HA, so that the second cache unit 130 can have the function of HA. The second cache unit 130 can be an independent cache, or a cache combined with the first cache unit 120. In the embodiment of the present application, the second cache unit 130 maintains a directory table (directory table), which can be used to track the status of shared data in each cache, thereby achieving consistency control of shared data. The target table includes multiple cache lines, and each cache line records the status information of a data cached by the first cache unit 120, such as whether it has been modified, whether it is independent, whether it is shared, whether it is invalid, and other information.
[0056] In an embodiment of the present application, after receiving the Snoop request, the second cache unit 130 determines that the shared data has been modified and the locally cached shared data needs to be updated. The second cache unit 130 can query the directory table to obtain the status information of the cache line corresponding to the shared data. The second cache unit 130 can modify the "whether independent" in the status information to the "independent" state to set the shared data to the modified shared data. After the second cache unit 130 completes the modification of the status information of the cache line corresponding to the shared data, it will send a Snoop request to the other first cache units 120 to notify the other first cache units 120 to update the status of the cache line corresponding to the shared data to ensure data consistency.
[0057] In an embodiment of the present application, upon receiving one or more atomic instructions, the second cache unit 130 may perform atomic operations based on each atomic instruction, thereby achieving data synchronization. After completing the atomic operation, the second cache unit 130 may query the directory table to obtain the state information of the cache line corresponding to the data modified based on the atomic instruction, and update the state information of the cache line to ensure the consistency of the shared data after it is accessed.
[0058] In an embodiment of the present application, after receiving multiple atomic instructions from the same first cache unit 120, the second cache unit 130 can parse the identification information carried in each atomic instruction to obtain the identification information of each atomic instruction. The second cache unit 130 can detect whether the identification information of each atomic instruction is the same. In one case, when the second cache unit 130 determines that the identification information of each atomic instruction is not the same, the second cache unit 130 can continue to receive atomic instructions and perform atomic operations based on the atomic instructions to achieve data synchronization.
[0059] In another case, when the second cache unit 130 determines that the identification information of each atomic instruction is the same, it can send a synchronization instruction to the first cache unit 120 that has received multiple atomic instructions, instructing the first cache unit 120 to perform atomic operations locally after receiving atomic instructions with the same identification information to achieve data synchronization. The first cache unit 120 does not need to send atomic instructions to the second cache unit 130, which can reduce the data communication cost of the first cache unit 120.
[0060] The following two embodiments are used to introduce the implementation process of the technical solution protected by this application.
[0061] Figure 2(a) is a schematic diagram of the process of multiple processing units performing data synchronization through two cache blocks provided in an embodiment of the present application. As shown in Figure 2(a), the two cache blocks are the first cache unit 120-1 and the first cache unit 120-2. After receiving an atomic instruction, the first cache unit 120-1 can perform atomic operations based on the atomic instruction to achieve data synchronization. The first cache unit 120-1 can check the status of a cache line after completing data synchronization, generate a Snoop request, and send the Snoop request to the second cache unit 130.
[0062] After receiving the Snoop request sent by the first cache unit 120-1, the second cache unit 130 determines that the shared data has been modified and needs to update the locally cached shared data. The second cache unit 130 can query the directory table to obtain the status information of the cache line corresponding to the shared data. The second cache unit 130 can modify the "whether independent" in the status information to "independent" to set the shared data to the modified shared data. After the second cache unit 130 completes the modification of the status information of the cache line corresponding to the shared data, it will send a Snoop request to the first cache unit 120-2.
[0063] After receiving the Snoop request from the second cache unit 130, the first cache unit 120-2 determines that the shared data has been modified and needs to update the locally cached shared data. Since the first cache unit 120-2 does not have the modified shared data, the first cache unit 120-2 can transparently transmit the received atomic instruction to the second cache unit 130.
[0064] After receiving an atomic instruction, the second cache unit 130 can perform an atomic operation based on the atomic instruction to achieve data synchronization. After completing the atomic operation, the second cache unit 130 can query the directory table to obtain the state information of the cache line corresponding to the data modified by the atomic instruction, and update the state information of the cache line to ensure the consistency of the shared data after access.
[0065] In the embodiment of the present application, when multiple processing units 110 synchronize data through two first cache units 120, the synchronization point can be migrated from the first cache unit 120 to the second cache unit 130, and the second cache unit 130 can perform atomic operations on atomic instructions issued by different first cache units 120, thereby achieving data synchronization. After the first cache unit 120 migrates the synchronization point to the second cache unit 130, it does not need to transmit Snoop requests to the second cache unit 130, which can reduce the data communication cost of the first cache unit 120.
[0066] Figure 2(b) is a schematic diagram of the process of multiple processing units performing data synchronization through a cache block provided in an embodiment of the present application. As shown in Figure 2(b), after receiving multiple atomic instructions, the first cache unit 120-2 can send the multiple atomic instructions to the second processing unit 130.
[0067] After the second cache unit 130 receives multiple atomic instructions sent by the first cache unit 120-2, it can parse out the identification information carried in each atomic instruction to obtain the identification information of each atomic instruction. The second cache unit 130 can detect whether the identification information of each atomic instruction is the same. In one case, when the second cache unit 130 determines that the identification information of each atomic instruction is different, it can perform atomic operations based on each atomic instruction to achieve data synchronization. After the second cache unit 130 completes the atomic operation, it can query the directory table to obtain the status information of the cache line corresponding to the data modified based on the atomic instruction, and update the status information of the cache line to ensure the consistency of the shared data after being accessed.
[0068] In another case, when the second cache unit 130 determines that the identification information of each atomic instruction is the same, it can perform atomic operations based on each atomic instruction to achieve data synchronization. After the second cache unit 130 completes the atomic operation, it can query the directory table to obtain the status information of the cache line corresponding to the data modified based on the atomic instruction, and update the status information of the cache line to ensure the consistency of the shared data after being accessed. Then, the second cache unit 130 can send a synchronization instruction to the first cache unit 120-2 to migrate the synchronization point from the second cache unit 130 to the first cache unit 120-2. The synchronization instruction indicates that after the first cache unit 120-2 receives multiple atomic instructions, it can perform atomic operations locally to achieve data synchronization.
[0069] After first cache unit 120-2 locally executes an atomic operation based on multiple atomic instructions, it can send a synchronization message to second cache unit 130. The synchronization message instructs second cache unit 130 to modify the state information of the modified shared data recorded in the directory table of first cache unit 120-2. Second cache unit 130 modifies the recorded state information in the directory table to maintain the consistency of the shared data in other first cache units 120.
[0070] In an embodiment of the present application, when multiple processing units 110 synchronize data through a first cache unit 120, if the multiple atomic instructions received by the first cache unit 120 belong to the same processing unit 110 or processing units 110 belonging to the same processor cluster, the synchronization point can be migrated from the second cache unit 130 to the first cache unit 120. The first cache unit 120 can locally perform atomic operations on the multiple atomic instructions, thereby achieving data synchronization. During the data synchronization process, the first cache unit 120 does not need to communicate data with the second cache unit 130, which can reduce the data communication cost of the first cache unit 120.
[0071] The following describes the technical solution process of implementing Figure 2 in a flow chart.
[0072] Figure 3 Schematic diagram of a data synchronization method provided in an embodiment of the present application. Figure 3 As shown, the method can be executed by the second cache unit 130, and the implementation process is as follows:
[0073] Step S301: Receive a first Snoop request sent by a target first cache unit.
[0074] The first Snoop request is used to indicate that the shared data cached by the target first cache unit has been modified. In an embodiment of the present application, after receiving one or more atomic instructions, the target first cache unit can perform atomic operations based on the atomic instructions to achieve data synchronization. The target first cache unit can check the status of a cache line after completing data synchronization and generate a Snoop request. The target first cache unit can send the Snoop request to the second cache unit to inform the second cache unit and / or other first cache units that the local shared data has been modified.
[0075] Step S302: Generate a second Snoop request based on the first Snoop request.
[0076] The second cache unit maintains a directory table, which can be used to track the status of shared data in each cache, thereby achieving consistency control of shared data. The target table includes multiple cache lines, and each cache line records the status information of a data cached by a first cache unit, such as whether it has been modified, whether it is independent, whether it is shared, whether it is invalid, etc. In the embodiment of the present application, after receiving the first Snoop request, the second cache unit determines that the shared data has been modified and needs to update the shared data cached locally. The second cache unit can query the directory table to obtain the status information of the cache line corresponding to the shared data. The second cache unit can modify the "whether independent" in the status information to the "independent" state to set the shared data to the modified shared data. After the second cache unit completes the modification of the status information of the cache line corresponding to the shared data, it will send a second Snoop request to other first cache units to notify other first cache units to update the status of the cache line corresponding to the shared data to ensure data consistency. And the second Snoop request is used to instruct the first cache units other than the target first cache unit in multiple first cache units to pass through atomic instructions.
[0077] Step S303: Send a second Snoop request to the first cache units other than the target first cache unit among the multiple first cache units.
[0078] After receiving the Snoop request sent by the second cache unit, the first cache units other than the target first cache unit among the multiple first cache units (hereinafter referred to as "other first cache units") determine that the shared data has been modified and the locally cached shared data needs to be updated. Since the other first cache units do not have modified shared data, the other first cache units can forward the received atomic instructions to the second cache unit, allowing the second cache unit to perform atomic operations based on each atomic instruction, thereby achieving data synchronization. When the other first cache units send atomic instructions to the second cache unit, there is no need to transmit the Snoop request to the second cache unit, which can reduce the data communication cost of the first cache unit.
[0079] In an embodiment of the present application, upon receiving one or more atomic instructions, the second cache unit may perform atomic operations based on each atomic instruction, thereby achieving data synchronization. After completing the atomic operation, the second cache unit may query the directory table to obtain the state information of the cache line corresponding to the data modified based on the atomic instruction, and update the state information of the cache line to ensure the consistency of the shared data after it is accessed.
[0080] After receiving multiple atomic instructions from the same first cache unit, the second cache unit can parse the identification information carried in each atomic instruction to obtain the identification information of each atomic instruction. The second cache unit can detect whether the identification information of each atomic instruction is the same. In one case, when the second cache unit determines that the identification information of each atomic instruction is different, the second cache unit 130 can continue to receive the atomic instruction and perform atomic operations based on the atomic instruction to achieve data synchronization.
[0081] In another scenario, when the second cache unit determines that the identification information of each atomic instruction is the same, it can send a synchronization instruction to the first cache unit that has received multiple atomic instructions, instructing the first cache unit to perform atomic operations locally after receiving atomic instructions with the same identification information to achieve data synchronization. The first cache unit does not need to send atomic instructions to the second cache unit, which can reduce the data communication cost of the first cache unit.
[0082] After receiving the synchronization instruction, the first cache unit can perform atomic operations locally to achieve data synchronization. After receiving multiple atomic instructions, the first cache unit can perform atomic operations based on the multiple atomic instructions locally, and then send a synchronization message to the second cache unit. The synchronization message is used to instruct the second cache unit to modify the status information of the modified shared data of the first cache unit recorded in the directory table. The second cache unit modifies the recorded status information in the directory table so that the shared data remains consistent in other first cache units.
[0083] Figure 4 This is a structural diagram of a data synchronization device provided in an embodiment of the present application. Figure 4 As shown, the data synchronization device 400 can be divided into a first processing unit 410, a second processing unit 420 and a third processing unit 430 according to the execution function. The specific implementation process of the data synchronization device 400 is as follows:
[0084] The first processing unit 410 is used to receive a first Snoop request sent by a target first cache unit. The first Snoop request is used to indicate that shared data cached by the target first cache unit has been modified. The multiple first cache units include the target first cache unit. The second processing unit 420 is used to generate a second Snoop request based on the first Snoop request. The second Snoop request is used to instruct the first cache units other than the target first cache unit in the multiple first cache units to pass through the atomic instruction. The third processing unit 430 is used to send a second Snoop request to the first cache units other than the target first cache unit in the multiple first cache units.
[0085] In one embodiment, the third processing unit 430 is further configured to receive multiple atomic instructions sent by the same first cache unit. The first cache units other than the target first cache unit in the multiple first cache units include the same first cache unit. The atomic instruction carries identification information. The identification information refers to an identification stored by the processor that sends the atomic instruction. The third processing unit 430 is further configured to send a synchronization instruction to the same first cache unit when the identification information carried by the multiple atomic instructions is the same. The synchronization instruction is used to instruct the same first cache unit to perform an atomic operation based on the atomic instruction after receiving the atomic instruction.
[0086] In one embodiment, the third processing unit 430 is further configured to receive a synchronization message sent by the same first cache unit, wherein the synchronization message is used to instruct the second cache unit to modify the state information of the modified shared data of the same first cache unit recorded in the directory table.
[0087] In one embodiment, the second processing unit 420 is specifically configured to modify, based on the first Snoop request, the state information of the modified shared data of the target first cache unit recorded in the locally stored target table. The directory table includes multiple cache lines, each of which records the state information of a first cache unit caching a piece of shared data. The second processing unit 420 is specifically configured to generate a second Snoop request based on the modified state information of the modified shared data of the target first cache unit.
[0088] In one embodiment, the second processing unit 420 is specifically configured to modify the “whether independent” state of the modified shared data of the target first cache unit recorded in the target table to the “independent” state according to the first Snoop request.
[0089] In one embodiment, the third processing unit 430 is also used to perform atomic operations based on the multiple atomic instructions sent by the first cache units other than the target first cache unit among the multiple first cache units after receiving the multiple atomic instructions sent by the first cache units other than the target first cache unit among the multiple first cache units.
[0090] The present application also provides a computing device, which includes a processor, which can execute the following Figure 1-Figure 3 And the above-mentioned corresponding protected technical solutions make the computing device have the technical effects of the above-mentioned protected technical solutions.
[0091] The embodiment of the present application further provides a computer-readable storage medium, including computer program instructions. When the computer program instructions are executed by a computing device, the computing device executes the above Figure 1-Figure 3 and any method described in the corresponding description.
[0092] The present application also provides a computer program product including instructions, wherein the computer program product stores instructions that, when executed by a computing device, enable the computing device to implement the above-mentioned Figure 1-Figure 3 and any method described in the corresponding description.
[0093] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of this application.
[0094] In addition, various aspects or features of the embodiments of the present application can be implemented as methods, devices or products using standard programming and / or engineering techniques. The term "product" used in this application covers computer programs that can be accessed from any computer-readable device, carrier or medium. For example, computer-readable media may include, but are not limited to: magnetic storage devices (e.g., hard disks, floppy disks or tapes, etc.), optical disks (e.g., compact discs (CDs), digital versatile discs (DVDs), etc.), smart cards and flash memory devices (e.g., erasable programmable read-only memories (EPROMs), cards, sticks or key drives, etc.). In addition, the various storage media described herein may represent one or more devices and / or other machine-readable media for storing information. The term "machine-readable medium" may include, but is not limited to, wireless channels and various other media capable of storing, containing and / or carrying instructions and / or data.
[0095] In the above embodiment, Figure 4The data synchronization device 400 in the embodiment can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media integrated therein. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a high-density digital video disc (DVD)), or a semiconductor medium (eg, a solid state disk (SSD)).
[0096] It should be understood that in various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0097] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0098] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0099] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0100] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or an access network device, etc.) to execute all or part of the steps of the method described in each embodiment of the embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0101] The above is only a specific implementation of the embodiment of the present application, but the protection scope of the embodiment of the present application is not limited to this. Any technician familiar with this technical field can easily think of changes or replacements within the technical scope disclosed in the embodiment of the present application, and they should all be covered by the protection scope of the embodiment of the present application.
Claims
1. A data synchronization method, characterized in that: The data synchronization system includes a plurality of first cache units and a second cache unit, wherein the second cache unit is deployed with a local agent, and the method is performed by the second cache unit, including: receiving a first snoop request sent by a target first cache unit; the first snoop request is used to indicate that shared data cached by the target first cache unit is modified; the plurality of first cache units include the target first cache unit; Based on the first Snoop request, a second Snoop request is generated; the second Snoop request is used to instruct a first cache unit other than the target first cache unit among the plurality of first cache units to transparently transmit the atomic instruction; The second Snoop request is sent to a first cache unit other than the target first cache unit among the plurality of first cache units.
2. The method according to claim 1, characterized in that The method further comprises: receiving multiple atomic instructions sent by the same first cache unit; wherein the first cache units other than the target first cache unit in the multiple first cache units include the same first cache unit; the atomic instructions carry identification information; the identification information refers to an identification stored by the processor sending the atomic instructions; In the case where the identification information carried by the multiple atomic instructions is the same, a synchronization instruction is sent to the same first cache unit; the synchronization instruction is used to instruct the same first cache unit to perform an atomic operation based on the atomic instruction after receiving the atomic instruction.
3. The method according to claim 2, characterized in that The method further comprises: Receive a synchronization message sent by the same first cache unit; the synchronization message is used to instruct the second cache unit to modify the status information of the modified shared data of the same first cache unit recorded in the directory table.
4. The method according to any one of claims 1 to 3, characterized in that Generating a second Snoop request based on the first Snoop request specifically includes: Modify, according to the first Snoop request, the state information of the modified shared data of the target first cache unit recorded in the locally stored target table; the directory table includes a plurality of cache lines, each cache line records the state information of a first cache unit caching a piece of shared data; A second Snoop request is generated according to the modified state information of the shared data of the target first cache unit.
5. The method according to claim 4, characterized in that The step of modifying the state information of the modified shared data of the target first cache unit recorded in the locally stored target table according to the first Snoop request specifically includes: According to the first Snoop request, the “whether independent” state of the modified shared data of the target first cache unit recorded in the target table is modified to an “independent” state.
6. The method according to any one of claims 1 to 5, characterized in that The method further comprises: After receiving multiple atomic instructions sent by first cache units other than the target first cache unit among the multiple first cache units, atomic operations are performed based on the multiple atomic instructions sent by first cache units other than the target first cache unit among the multiple first cache units.
7. A data synchronization device, characterized in that: include: A first processing unit, configured to receive a first Snoop request sent by a target first cache unit; the first Snoop request is used to indicate that shared data cached by the target first cache unit is modified; The plurality of first cache units include the target first cache unit; A second processing unit is configured to generate a second Snoop request based on the first Snoop request; the second Snoop request is configured to instruct a first cache unit other than the target first cache unit among the plurality of first cache units to transparently transmit an atomic instruction; The third processing unit is configured to send the second Snoop request to a first cache unit other than the target first cache unit among the multiple first cache units.
8. The device according to claim 7, characterized in that The third processing unit is further configured to receive multiple atomic instructions sent by the same first cache unit; the first cache units other than the target first cache unit in the multiple first cache units include the same first cache unit; the atomic instruction carries identification information; the identification information refers to an identification stored by the processor sending the atomic instruction; The third processing unit is further used to send a synchronization instruction to the same first cache unit when the identification information carried by the multiple atomic instructions is the same; the synchronization instruction is used to instruct the same first cache unit to perform an atomic operation based on the atomic instruction after receiving the atomic instruction.
9. The device according to claim 8, characterized in that The third processing unit is further configured to receive a synchronization message sent by the same first cache unit; the synchronization message is configured to instruct the second cache unit to modify the status information of the modified shared data of the same first cache unit recorded in the directory table.
10. The device according to any one of claims 7 to 9, characterized in that: The second processing unit is specifically configured to modify, according to the first Snoop request, the state information of the modified shared data of the target first cache unit recorded in the locally stored target table; the directory table includes a plurality of cache lines, each cache line recording the state information of one shared data cached by one first cache unit; The second processing unit is specifically configured to generate a second Snoop request according to the modified state information of the shared data of the target first cache unit.
11. The device according to claim 10, characterized in that The second processing unit is specifically configured to modify the “whether independent” state of the modified shared data of the target first cache unit recorded in the target table to an “independent” state according to the first Snoop request.
12. The device according to any one of claims 7 to 11, characterized in that: The third processing unit is also used to perform atomic operations based on the multiple atomic instructions sent by the first cache units other than the target first cache unit among the multiple first cache units after receiving the multiple atomic instructions sent by the first cache units other than the target first cache unit among the multiple first cache units.
13. A computing device, characterized in that include: at least one memory; At least one processor, wherein the processor is configured to execute instructions stored in the memory, so that the computing device executes the method according to any one of claims 1 to 6.
14. A computer-readable storage medium, characterized in that The method comprises computer program instructions, and when the computer program instructions are executed by a computing device, the computing device performs the method according to any one of claims 1 to 6.
15. A computer program product comprising instructions, characterized in that The computer program product stores instructions, which, when executed by a computing device, enable the computing device to implement the method according to any one of claims 1 to 6.