Atomic operation execution system, method and device
By decoupling write operations and read operations in the atomic operation execution system, using the original value to read the address and return address, and actively initiating write operations, the problems of low atomic operation execution efficiency and deadlock risk are solved, and efficient parallel execution is achieved. The atomicity and correctness of the operation are ensured.
Patent Information
- Application Number
- CN202410843478.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2044-06-27
AI Technical Summary
In a multi-threaded complex computing environment, the execution efficiency of atomic operations is low and there is a risk of deadlock. The existing technology avoids deadlock by controlling the number of unfinished atomic operations, but this results in a decrease in execution efficiency.
An atomic operation execution system is designed. Through the collaborative work of the atomic operation module, the calculation module and the storage module, the operand storage unit, the control unit and the atomic operation execution unit are used, combined with the original value read address and the original value return address, to solve Couple write operations and read operations, actively initiate write operations, avoid deadlocks, and perform multiple operations in parallel without reducing the number of atomic operations.
It effectively avoids the risk of deadlock during atomic operations, improves the execution efficiency of atomic operations, ensures the atomicity and correctness of operations, and improves the parallel processing capability of the system.
Smart Images

Figure CN118377741B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to an execution system, method and device for atomic operations. Background Art
[0002] In computing systems, especially in complex multi-threaded computing environments, atomic operations play a very important role. Atomic operations refer to operations that will not be interrupted by any other operations before they are completed. When multiple threads access and modify the same address or resource at the same time, atomic operations can ensure that the operation on shared resources is uninterruptible, thereby ensuring the consistency and correctness of the results.
[0003] In complex multi-threaded and highly concurrent computing systems, specialized computing components are often required to perform atomic operations. The execution process of atomic operations is generally that the computing core sends operands to the computing component, and the computing component reads the original value from the address a of the storage device, generates a new value after performing certain operations on the operand and the original value, and then returns the new value to the address a. In addition, the original value needs to be returned to the computing core.
[0004] Due to the characteristics of atomic operations, a complete atomic operation is currently split into a write operation (one or more times) and a read operation. The write operation is used to send the operand, and the read operation is used to return the original value. This will result in multiple transmission waits in the atomic operation execution component to complete a complete atomic operation. In complex computing systems, especially for atomic operations on global addresses, the path from the computing core to the atomic operation execution component is relatively complex, and this mutual waiting for transmission has the risk of deadlock. In the prior art, the number of unfinished atomic operations on the path is usually controlled from the source of the computing core to avoid the deadlock problem. However, the above method will lead to the problem of low efficiency in the execution of atomic operations. Summary of the invention
[0005] The present invention provides an atomic operation execution system, method and device to solve the defect of low atomic operation execution efficiency when avoiding deadlock problems in the atomic operation process in the prior art, thereby achieving the purpose of not only avoiding deadlock problems in the atomic operation process but also improving the execution efficiency of atomic operations.
[0006] The present invention provides an atomic operation execution system, comprising: an atomic operation module, a calculation module and a storage module, wherein the atomic operation module comprises an operand storage unit, a control unit and an atomic operation execution unit; the operand storage unit is used to receive the operands required for each atomic operation sent by the calculation module; the control unit is used to receive relevant information for executing each atomic operation sent by the calculation module, the relevant information including the original value reading address, atomic operation type and original value return address of the corresponding atomic operation; the control unit is also used to determine at least one atomic operation in a valid state based on the identification of each atomic operation, and based on the original value reading address of each atomic operation in a valid state, Determine at least one executable atomic operation from at least one atomic operation in a valid state, and determine a target atomic operation from all executable atomic operations; the atomic operation execution unit is used to read the target original value from the original value read address of the target atomic operation, and write the target original value into the computing module based on the original value return address of the target atomic operation; the atomic operation execution unit is also used to perform an operation corresponding to the atomic operation type of the target atomic operation on the operands corresponding to the target atomic operation and the target original value, to obtain a target new value corresponding to the target atomic operation; the atomic operation execution unit is also used to write the target new value into the original value read address of the target atomic operation in the storage module.
[0007] According to an atomic operation execution system provided by the present invention, the control unit is specifically used to: compare the original value reading address of each atomic operation in a valid state with each address stored in an address recording table, wherein the address recording table stores the original value reading address corresponding to at least one atomic operation currently being executed; in the case that there is an original value reading address that fails to be compared among the original value reading addresses of all atomic operations in a valid state, the atomic operation corresponding to the original value reading address that fails to be compared is determined as an executable atomic operation.
[0008] According to an atomic operation execution system provided by the present invention, the control unit is also used to store the original value reading address of the target atomic operation in the address recording table, and after determining that the target atomic operation is completed, delete the original value reading address of the target atomic operation from the address recording table.
[0009] According to an atomic operation execution system provided by the present invention, the control unit is also used to store the relevant information of the atomic operation into a table entry of an information table for each atomic operation, and send the storage address of the relevant information in the table entry to the operand storage unit; the operand storage unit is also used to store the operand corresponding to the atomic operation into the storage address of the operand storage unit; the control unit is also used to set the identifier of the atomic operation to a valid identifier, and the valid identifier is used to characterize that the atomic operation is in a valid state.
[0010] According to an atomic operation execution system provided by the present invention, the atomic operation execution unit is specifically used to: read the read original value command corresponding to the target atomic operation from a read command queue, the read command queue is used to store the read original value commands of each executable atomic operation, each read original value command includes the original value reading address of the corresponding atomic operation read by the control unit from the information table; based on the original value reading address included in the read original value command corresponding to the target atomic operation, read the target original value from the storage module.
[0011] According to an atomic operation execution system provided by the present invention, the atomic operation execution unit is specifically used to: store the target new value in a write data queue, and store the write new value command corresponding to the target new value in a write command queue, the write new value command including the original value reading address of the target original value corresponding to the target new value; read the write new value command from the write command queue, read the target new value from the write data queue, and write the target new value into the original value reading address included in the write new value command.
[0012] According to an atomic operation execution system provided by the present invention, the atomic operation execution unit is specifically used to: determine the target atomic operation from all executable atomic operations according to the operation priority of each executable atomic operation; or, poll each executable atomic operation and determine the currently polled executable atomic operation as the target atomic operation.
[0013] The present invention also provides an atomic operation execution method, which is applied to an atomic operation module, wherein the atomic operation module includes an operand storage unit, a control unit and an atomic operation execution unit; the method includes: receiving operands corresponding to at least one atomic operation sent by a calculation module through the operand storage unit; receiving relevant information for executing each of the atomic operations sent by the calculation module through the control unit, wherein the relevant information includes an original value reading address, an atomic operation type and an original value return address of the corresponding atomic operation; determining at least one atomic operation in a valid state based on an identifier of each of the atomic operations through the control unit, and reading the address based on the original value of each of the atomic operations in a valid state, Determine at least one executable atomic operation from at least one atomic operation in a valid state, and determine a target atomic operation from all executable atomic operations; read the target original value from the original value read address of the target atomic operation through the atomic operation execution unit, and write the target original value into the computing module based on the original value return address of the target atomic operation; perform the operation corresponding to the atomic operation type of the target atomic operation on the operand corresponding to the target atomic operation and the target original value through the atomic operation execution unit to obtain a target new value corresponding to the target atomic operation; write the target new value into the original value read address of the target atomic operation in the storage module through the atomic operation execution unit.
[0014] The present invention also provides an execution device for atomic operations, comprising: a receiving module, used to receive the operands required for each atomic operation sent by the calculation module; the receiving module, also used to receive relevant information for executing each atomic operation sent by the calculation module, the relevant information including the original value reading address, atomic operation type and original value return address of the corresponding atomic operation; a determination module, used to determine at least one atomic operation in a valid state based on the identification of each atomic operation, determine at least one executable atomic operation from at least one atomic operation in a valid state based on the original value reading address of each atomic operation in a valid state, and determine a target atomic operation from all executable atomic operations; a read-write module, used to read the target original value from the original value reading address of the target atomic operation, and write the target original value into the calculation module based on the original value return address of the target atomic operation; an operation module, used to perform an operation corresponding to the atomic operation type of the target atomic operation on the operand corresponding to the target atomic operation and the target original value, to obtain a target new value corresponding to the target atomic operation; and a write module, used to write the target new value into the original value reading address of the target atomic operation in the storage module.
[0015] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the execution method of any of the above-mentioned atomic operations is implemented.
[0016] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the execution method of any of the atomic operations described above is implemented.
[0017] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any one of the above-mentioned atomic operation execution methods.
[0018] The present invention provides an atomic operation execution system, method, device and storage medium, the system includes an atomic operation module, a computing module and a storage module, wherein the atomic operation module includes an operand storage unit, a control unit and an atomic operation execution unit, the operand storage unit is used to receive the operands required for each atomic operation sent by the computing module, the control unit is used to receive the relevant information for executing each atomic operation sent by the computing module, the relevant information includes the original value reading address, atomic operation type and original value return address of the corresponding atomic operation, the control unit is also used to determine at least one atomic operation in a valid state based on the identification of each atomic operation, and based on the identification of each atomic operation The original value reading address of each atomic operation is determined from at least one atomic operation in a valid state, and the target atomic operation is determined from all executable atomic operations. The atomic operation execution unit is used to read the target original value from the original value reading address of the target atomic operation, and write the target original value into the calculation module based on the original value return address of the target atomic operation. The atomic operation execution unit is also used to perform the operation corresponding to the atomic operation type of the target atomic operation on the operand and the target original value corresponding to the target atomic operation, obtain the target new value corresponding to the target atomic operation, and write the target new value into the original value reading address of the target atomic operation in the storage module. Since the relevant information sent by the calculation model includes the original value return address, the atomic operation module does not need to wait until the calculation module initiates the read operation, but can actively initiate the write operation to write the target original value into the original value return address in the calculation module. In this way, the write operation and the read operation can be decoupled, avoiding the situation of splitting an atomic operation into multiple transmissions, and there is no need to wait for each other when executing the atomic operation, thereby avoiding the risk of deadlock when waiting for each other. In addition, in the above method, since the number of unfinished atomic operations on the path is not reduced, multiple atomic operations can be executed in parallel, thereby improving the efficiency of the atomic operations. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0020] Figure 1 A schematic diagram of the structure of an execution system for atomic operations provided in an embodiment of the present invention.
[0021] Figure 2 One of the structural schematic diagrams of the atomic operation module provided in an embodiment of the present invention.
[0022] Figure 3 The second structural diagram of the atomic operation module provided in the embodiment of the present invention.
[0023] Figure 4 A schematic flow chart of a method for executing an atomic operation provided in an embodiment of the present invention.
[0024] Figure 5 A schematic diagram of the structure of an execution device for atomic operations provided in an embodiment of the present invention.
[0025] Figure 6 An example physical structure diagram of an electronic device is provided. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0027] In the prior art, atomic operations are usually split into write operations and read operations. This splitting method will result in multiple transmission waits in the atomic operation execution component to complete a complete atomic operation. For example, after executing the write operation, the computing component will wait for the computing core to issue a read instruction. Only after completing the write operation and the read operation can a complete atomic operation be completed. In complex computing systems, especially for atomic operations of global addresses, the path between the computing core and the atomic operation execution component is relatively complex, and multiple other operations may be interspersed between the write operation and the read operation. If there is a resource conflict or dependency that causes transmission congestion, the subsequent transmission will need to wait for the previous transmission to be completed, and the previous transmission will need to wait for the information carried in the subsequent transmission to match before continuing. This mutual waiting transmission has the risk of deadlock. At present, the number of atomic operations that have not been completed on the path is controlled from the source of the computing core to avoid the deadlock problem. However, the above method may lead to the problem of low efficiency in atomic operation execution.
[0028] In the embodiment of the present invention, considering the above problems, a system for executing atomic operations is proposed. In the system, an atomic operation module specifically used for executing atomic operations is set. When the computing module sends operands to the atomic operation module, the relevant information for executing each atomic operation is sent together, wherein the relevant information includes the original value reading address, the atomic operation type and the original value return address of the corresponding atomic operation. The atomic operation module can read the target original value from the storage module based on the original value reading address, and based on the atomic operation type, the read target original value and the received operand are operated to obtain a new value. In addition, since the original value return address is also included in the relevant information, the atomic operation module does not need to wait until the computing module initiates the read operation, but can actively initiate a write operation to write the target original value into the original value return address in the computing module. In this way, the write operation and the read operation can be decoupled, avoiding the situation of splitting an atomic operation into multiple transmissions, and there is no need to wait for each other when executing the atomic operation, thereby avoiding the risk of deadlock when waiting for each other. In addition, in the above method, the number of atomic operations that have not been completed on the path is not reduced, but multiple atomic operations can be executed in parallel, thereby improving the efficiency of atomic operations.
[0029] Combine the following Figures 1 to 3 The execution system of the atomic operation provided by the embodiment of the present invention is described. The embodiment of the present invention can be applied to any scenario where atomic operation is required.
[0030] Figure 1 A schematic diagram of the execution system structure of the atomic operation provided by the embodiment of the present invention is shown in FIG. Figure 1As shown, the system includes an atomic operation module, a computing module and a storage module, wherein the computing module can be a multi-core computing unit, which can also be understood as a computing core, and the computing module is connected to the atomic operation module through an interconnection structure, and the interconnection structure can be a bus, or other connection devices that can connect the computing module and the atomic operation module so that the two modules can communicate. The operands required for the atomic operation can be sent to the atomic operation module through the interconnection structure through the write operation of the computing module. In addition, the atomic operation module is connected to the storage module, and the storage module can be a shared storage device. The atomic operation module can initiate an original value read request to the storage module, and actively write the original value back to the computing module after reading the original value from the storage module, and the atomic operation module will also perform operations between the original value and the operand sent, and write the obtained new value into the storage module.
[0031] The following describes in detail the process of the atomic operation module provided in the embodiment of the present invention when performing an atomic operation. Figure 2 One of the structural diagrams of the atomic operation module provided in the embodiment of the present invention is as follows: Figure 2 As shown, the atomic operation module includes an operand storage unit, a control unit and an atomic operation execution unit, wherein the operand storage unit is used to receive the operands required for each of at least one atomic operation sent by the computing module; the control unit is used to receive relevant information for executing each atomic operation sent by the computing module, the relevant information including the original value reading address, atomic operation type and original value return address of the corresponding atomic operation; the control unit is also used to determine at least one atomic operation in a valid state based on the identifier of each atomic operation, determine at least one executable atomic operation from at least one atomic operation in a valid state based on the original value reading address of each atomic operation in a valid state, and select at least one executable atomic operation from all A target atomic operation is determined in executable atomic operations, wherein the above-mentioned atomic operation identifier can be used to characterize whether the atomic operation is in a valid state, that is, whether the information required for the atomic operation is complete; an atomic operation execution unit is used to read the target original value from the original value reading address of the target atomic operation, and write the target original value into the calculation module based on the original value return address of the target atomic operation; the atomic operation execution unit is also used to perform an operation corresponding to the atomic operation type of the target atomic operation on the operands and the target original value corresponding to the target atomic operation, to obtain a target new value corresponding to the target atomic operation; the atomic operation execution unit is also used to write the target new value into the original value reading address of the target atomic operation in the storage module.
[0032] Specifically, Figure 2As shown, the operand storage unit can receive and store the operands required for at least one atomic operation issued by the computing module from the write data path. Among them, the operand storage unit has a certain capacity, and the operand storage unit can cache the operands of multiple atomic operations, and the write position or write address when the operand is written each time is specified by the control unit. Since the operands of multiple atomic operations can be cached in the operand storage unit, multiple atomic operations can be executed in parallel, which improves the execution efficiency of atomic operations.
[0033] The control unit can receive the relevant information required for executing each atomic operation sent by the computing module from the write command path. The relevant information may include the original value reading address, atomic operation type and original value return address corresponding to each atomic operation. In addition, the relevant information may also include a number system or data type, etc. Among them, if the atomic operation only supports operations of one data type, the relevant information may not include the data type. When the atomic operation can support operations of multiple data types, the relevant information also needs to include a number system or data type, so as to operate the original value and operand through the number system or data type, and the operation type.
[0034] For a certain atomic operation, if the control unit determines that the operands and related information corresponding to the atomic operation have been stored, the atomic operation will be marked as a valid state. Atomic operations in a valid state can be understood as atomic operations to be executed, that is, the information required for the atomic operation is complete, and these atomic operations do not need to wait for other subsequent transmission information. After comparing the original value read address, if no other operation accesses the original value read address corresponding to the atomic operation, the atomic operation execution process can be attempted to be initiated. This mechanism that relies on a single data transmission to initiate atomic operations fundamentally avoids the potential deadlock problem caused by waiting for each other due to the splicing of multiple transmissions.
[0035] Therefore, the control unit can filter at least one atomic operation in a valid state based on the identifier of each atomic operation, and based on the original value read address of each atomic operation in a valid state, determine the executable atomic operation whose original value read address is not currently occupied by other operations from at least one atomic operation in a valid state. Among them, the original value read address corresponding to the determined executable atomic operation is not currently accessed by other operations. This method can ensure the atomicity of the operation and the consistency and correctness of the operation results.
[0036] Furthermore, under the scheduling of the control unit, the atomic operation execution unit can determine the target atomic operation that needs to be executed currently from all the screened executable atomic operations, and read the target original value from the original value reading address of the target atomic operation in the storage module. In addition, since the relevant information also includes the original value return address of the target atomic operation, the atomic operation execution unit can write the read target original value into the original value return address of the target atomic operation in the calculation module. Under this mechanism, when the target original value is returned to the calculation module, it is not a read operation initiated by the calculation module, but a write operation actively initiated by the atomic operation execution unit to write the target original value to the calculation module. In this way, there is no need to wait for the calculation module to initiate a read operation, and the atomic operation execution unit can actively return the read target original value to the calculation module, so the deadlock problem caused by waiting in the prior art can be avoided.
[0037] The atomic operation execution unit can also perform related operations on the operands corresponding to the target atomic operation and the read target original values according to the atomic operation type corresponding to the target atomic operation, so as to obtain the target new value corresponding to the target atomic operation. Among them, the atomic operation type can be understood as the operation type or the data processing method, for example, adding or subtracting the target original value and the operand. In addition, the atomic operation execution unit will write the obtained target new value into the original value reading address of the target atomic operation in the storage module.
[0038] The atomic operation execution system provided by the embodiment of the present invention includes an atomic operation module, a computing module and a storage module, wherein the atomic operation module includes an operand storage unit, a control unit and an atomic operation execution unit, the operand storage unit is used to receive the operands required for each atomic operation sent by the computing module, the control unit is used to receive the relevant information for executing each atomic operation sent by the computing module, the relevant information includes the original value reading address, the atomic operation type and the original value return address of the corresponding atomic operation, the control unit is further used to determine at least one atomic operation in a valid state based on the identifier of each atomic operation, and based on each atomic operation in a valid state The original value reading address of the operation is determined, at least one executable atomic operation is determined from at least one atomic operation in a valid state, and the target atomic operation is determined from all executable atomic operations. The atomic operation execution unit is used to read the target original value from the original value reading address of the target atomic operation, and write the target original value into the calculation module based on the original value return address of the target atomic operation. The atomic operation execution unit is also used to perform the operation corresponding to the atomic operation type of the target atomic operation on the operand and the target original value corresponding to the target atomic operation, obtain the target new value corresponding to the target atomic operation, and write the target new value into the original value reading address of the target atomic operation in the storage module. Since the relevant information sent by the calculation model includes the original value return address, the atomic operation module does not need to wait until the calculation module initiates the read operation, but can actively initiate the write operation to write the target original value into the original value return address in the calculation module. In this way, the write operation and the read operation can be decoupled, avoiding the situation of splitting an atomic operation into multiple transmissions. When executing atomic operations, there is no need to wait for each other, thereby avoiding the risk of deadlock when waiting for each other, and improving the security of atomic operations. In addition, in the above method, since the number of unfinished atomic operations on the path is not reduced, multiple atomic operations can be executed in parallel, thereby improving the efficiency of the atomic operations.
[0039] Exemplarily, based on the above-mentioned embodiments, the above-mentioned control unit is specifically used to: compare the original value reading address of each atomic operation in a valid state with each address stored in an address recording table, wherein the address recording table stores the original value reading address corresponding to at least one atomic operation currently being executed; in the case where there is an original value reading address that fails to be compared among the original value reading addresses of all atomic operations in a valid state, the atomic operation corresponding to the original value reading address that fails to be compared is determined as an executable atomic operation.
[0040] Specifically, an address record table is dynamically maintained inside the control unit, and the address record table stores the original value reading address corresponding to at least one atomic operation currently being executed. The original value reading addresses corresponding to all valid atomic operations are compared with the addresses stored in the address record table. Once an address comparison is successful, it means that the original value reading address corresponding to the successfully compared atomic operation to be executed in the valid state is currently in operation, that is, the original value reading address is occupied by other atomic operations. Therefore, the atomic operation to be executed in the valid state cannot be sent to the execution path for execution until this address correlation dependency is completely released, that is, there is no address in the address record table that is the same as the original value reading address corresponding to the atomic operation to be executed in the valid state.
[0041] To summarize, after address comparison, if there is an original value reading address that fails to be compared among the original value reading addresses of all atomic operations in a valid state, it means that the original value reading address that fails to be compared does not exist in the address record table, that is, there is currently no other atomic operation occupying the original value reading address that fails to be compared. Therefore, the atomic operations corresponding to these original value reading addresses that fail to be compared can be sent to the execution path for execution, so the atomic operations corresponding to these original value reading addresses that fail to be compared can be determined as executable atomic operations.
[0042] In addition, since the operands of multiple atomic operations are stored in the operand storage unit, and the control unit can also receive relevant information of multiple atomic operations, when performing address comparison, the addresses of multiple atomic operations can be checked in parallel, thereby improving the comparison efficiency.
[0043] In this embodiment, the original value reading address of each atomic operation in a valid state can be compared with the original value reading address corresponding to at least one atomic operation currently being executed and stored in the address record table, and the atomic operation corresponding to the original value reading address that fails the comparison can be determined as an executable atomic operation. This can avoid accessing data at the same address as other atomic operations currently being executed when executing the atomic operation, thereby ensuring the atomicity of the operation and ensuring the consistency and accuracy of the operation results.
[0044] Exemplarily, based on the above embodiment, the above control unit is also used to store the original value reading address of the target atomic operation in the address recording table, and after determining that the target atomic operation is completed, delete the original value reading address of the target atomic operation from the address recording table.
[0045] Specifically, after selecting the target atomic operation from at least one executable atomic operation, the target original value will be read from the original value reading address corresponding to the target atomic operation, which means that the target atomic operation has become the atomic operation currently being executed. Therefore, the original value reading address corresponding to the target atomic operation will be stored in the address record table as a comparison benchmark for determining the target atomic operation to be executed later. In addition, after determining that the target atomic operation has been executed, it is necessary to delete the original value reading address of the target atomic operation from the address record table. It should be understood that similarly for other atomic operations in the address record table, when it is determined that the atomic operation has been executed, the original value reading address corresponding to the atomic operation will be deleted from the address record table. The address record table is continuously updated in the above manner to ensure the accuracy and execution efficiency of the determined target atomic operation.
[0046] Exemplarily, on the basis of the above-mentioned embodiments, the control unit is also used to store the relevant information of each atomic operation in a table entry of the information table, and send the storage address of the relevant information in the table entry to the operand storage unit; the operand storage unit is also used to store the operand corresponding to the atomic operation in the storage address of the operand storage unit; the control unit is also used to set the flag of the atomic operation to a valid flag, and the valid flag is used to characterize that the atomic operation is in a valid state.
[0047] Specifically, Figure 3 The second structural diagram of the atomic operation module provided by the embodiment of the present invention is as follows: Figure 3 As shown, after the control unit receives the relevant information of each atomic operation sent by the computing module from the write command path, it will write the relevant information into the information table. For the relevant information of each atomic operation, an idle table entry can be selected from the information table, and the relevant information of the atomic operation can be written into the table entry. In addition, the storage address of the relevant information written in the table entry will be passed to the operand storage unit. The operand storage unit uses the received storage address as the storage address corresponding to the operand of the atomic operation, and stores the above operand in the storage address.
[0048] Generally, in the above method, the operands and related information stored at the same storage address in the operand storage unit and the information table are the operands and related information corresponding to the same atomic operation. Therefore, a one-to-one correspondence can be established between the operands and related information of the same atomic operation, avoiding confusion in the operands and related information of the atomic operation and ensuring the accuracy of the execution of the atomic operation.
[0049] Once the relevant information corresponding to a certain atomic operation is stored in a table entry of the information table, and the corresponding operand has been updated to the operand storage unit, the control unit will set the flag of this atomic operation to a valid flag, and use this valid flag to indicate that this atomic operation is in a valid state. When an atomic operation is marked as valid, the atomic operation will try to initiate the atomic operation execution process without waiting for other subsequent transmitted information. This mechanism of initiating atomic operations by relying on a single data transmission can fundamentally avoid potential deadlock problems caused by waiting for each other due to multiple transmissions.
[0050] Exemplarily, based on the above embodiments, the atomic operation execution unit is specifically used to: read the read original value command corresponding to the target atomic operation from the read command queue, the read command queue is used to store the read original value commands of each executable atomic operation, each read original value command includes the original value reading address of the corresponding atomic operation read by the control unit from the information table; based on the original value reading address included in the read original value command corresponding to the target atomic operation, read the target original value from the storage module.
[0051] Specifically, continue to refer to Figure 3 As shown, under the scheduling of the control unit, the read original value command corresponding to the determined executable atomic operation can be stored in the read command queue. For each read original value command in the read command queue, it includes the original value read address corresponding to the executable atomic operation read by the control unit from the table entry in the information table.
[0052] The atomic operation execution unit calls each read original value command from the read command queue in order from front to back, and reads the original value required for the atomic operation from the original value read address included in the read original value command in the storage module.
[0053] In this embodiment, each read original value command that can execute atomic operations can be stored in a read command queue, so that the original value can be read from the storage module in sequence based on the read original value commands in the queue, which can ensure that the original value reading is carried out in an orderly manner and the accuracy of the original value reading is guaranteed.
[0054] In addition, the write original value command can also be stored in the write original value command queue, and each write original value command stored in the write original value command queue includes an original value return address. After the original value is read from the storage module, the original value will be stored in the read data queue. By calling the write original value command, the original value data in the read data queue can be written back to the calculation module based on the original value return address in the write original value command.
[0055] In the above mechanism, the original value return is not a read operation initiated by the computing module, but a write operation actively initiated by the atomic operation execution unit to write the original value into the computing module. Therefore, the atomic operation can be completed without waiting for the computing unit to issue a read operation instruction, thus avoiding the deadlock problem caused by waiting.
[0056] Exemplarily, based on the above embodiments, the atomic operation execution unit is specifically used to: store the target new value in a write data queue, and store the write new value command corresponding to the target new value in a write command queue, the write new value command including the original value reading address of the target original value corresponding to the target new value; a storage module is used to read the write new value command from the write command queue, read the target new value from the write data queue, and write the target new value into the original value reading address included in the write new value command.
[0057] Specifically, continue to refer to Figure 3 As shown, for the target atomic operation, the read target original value and the operand cached in the operand storage unit will be passed to the atomic operation execution unit, and the atomic operation execution unit will operate on the target original value and the operand according to the atomic operation type. After obtaining the target new value, the target new value will be stored in the write data queue, and the write new value command corresponding to the target new value will be stored in the write command queue. Among them, the write new value command contains the original value read address of the target original value used when calculating the target new value.
[0058] The atomic operation execution unit reads the write new value command from the write command queue in order from front to back, and reads the target new value from the write data queue in order from front to back, thereby writing the obtained target new value data into the original value read address contained in the write new value command in the storage module.
[0059] In this embodiment, the target new value can be stored in the write data queue, and the write new value command corresponding to the target new value can be stored in the write command queue. Then, the new value can be written by reading the write new value command in the write command queue and reading the target new value in the write data queue. This allows the new value to be written in an orderly manner, ensuring that the new value is not written in disorder, thereby improving the accuracy of atomic operations.
[0060] Exemplarily, based on the above embodiments, the atomic operation execution unit is specifically used to: determine the target atomic operation from all executable atomic operations according to the operation priority of each executable atomic operation; or, poll each executable atomic operation and determine the currently polled executable atomic operation as the target atomic operation.
[0061] Specifically, when selecting the target atomic operation to be executed currently from all executable atomic operations to enter the subsequent execution path, the target atomic operation can be selected based on the operation priority of each executable atomic operation, and the executable atomic operation with the highest priority is determined as the target atomic operation. For example, the operation priority can be determined according to the time sequence of each executable atomic operation entering the atomic operation execution unit, and the earlier the entry time, the higher the priority. For another example, the relevant information sent by the computing module can also include a priority identifier, and the operation priority is determined by the priority identifier.
[0062] In addition, the executable atomic operation currently polled may be determined as the target atomic operation by polling each executable atomic operation through a polling arbitration mechanism.
[0063] In this embodiment, the target atomic operation can be determined according to the operation priority of each atomic operation or by polling each executable atomic operation, so that the atomic operations that meet the execution conditions can be executed as quickly as possible to ensure execution efficiency.
[0064] Figure 4 A schematic diagram of a flow chart of an execution method of an atomic operation provided in an embodiment of the present invention. The execution subject of this method can be Figure 1-Figure 3 The atomic operation module in the embodiment includes an operand storage unit, a control unit and an atomic operation execution unit. Figure 4 As shown, the method includes steps 401 to 406.
[0065] Step 401: Receive operands required for each atomic operation sent by a computing module through an operand storage unit.
[0066] Step 402: Receive, via the control unit, relevant information for executing each atomic operation sent by the computing module, the relevant information including the original value reading address corresponding to the atomic operation, the atomic operation type and the original value return address.
[0067] Step 403: The control unit determines at least one atomic operation in a valid state based on the identifier of each atomic operation, reads the address based on the original value of each atomic operation in a valid state, determines at least one executable atomic operation from at least one atomic operation in a valid state, and determines the target atomic operation from all executable atomic operations.
[0068] Step 404: Determine the target atomic operation from all executable atomic operations through the atomic operation execution unit, read the target original value from the original value read address of the target atomic operation, and write the target original value into the calculation module based on the original value return address of the target atomic operation.
[0069] Step 405: The atomic operation execution unit executes the operation corresponding to the atomic operation type of the target atomic operation on the operands and the target original value corresponding to the target atomic operation to obtain a target new value corresponding to the target atomic operation.
[0070] Step 406: Write the target new value into the original value reading address of the target atomic operation in the storage module through the atomic operation execution unit.
[0071] The specific implementation process and principles in the above steps are similar to the implementation process and principles in the execution system of the atomic operation described in the above embodiment, and will not be repeated here.
[0072] The method for executing atomic operations provided by an embodiment of the present invention comprises: receiving operands required for each atomic operation sent by a computing module through an operand storage unit; receiving relevant information for executing each atomic operation sent by the computing module through a control unit, wherein the relevant information includes an original value reading address, an atomic operation type and an original value return address of the corresponding atomic operation; determining at least one atomic operation in a valid state based on the identifier of each atomic operation through the control unit; determining at least one executable atomic operation from at least one atomic operation in a valid state based on the original value reading address of each atomic operation in a valid state, and determining a target atomic operation from all executable atomic operations; reading a target original value from the original value reading address of the target atomic operation through an atomic operation execution unit, and writing the target original value into the computing module based on the original value return address of the target atomic operation; executing an operation corresponding to the atomic operation type of the target atomic operation on the operand and the target original value corresponding to the target atomic operation through the atomic operation execution unit, and obtaining a target new value corresponding to the target atomic operation; and writing the target new value into the original value reading address of the target atomic operation in the storage module through the atomic operation execution unit. Since the relevant information sent by the calculation model includes the original value return address, the atomic operation module does not need to wait until the calculation module initiates a read operation, but can actively initiate a write operation to write the target original value into the original value return address in the calculation module. In this way, the write operation and the read operation can be decoupled, avoiding the situation of splitting an atomic operation into multiple transmissions. There is no need to wait for each other when executing atomic operations, thereby avoiding the risk of deadlock when waiting for each other. In addition, in the above method, since the number of unfinished atomic operations on the path is not reduced, multiple atomic operations can be executed in parallel, thereby improving the efficiency of atomic operations.
[0073] The atomic operation execution device provided by the present invention is described below. The atomic operation execution device described below and the atomic operation execution method described above can be referenced to each other.
[0074] Figure 5 A schematic diagram of the structure of an execution device of an atomic operation provided by an embodiment of the present invention is shown in FIG. Figure 5 As shown, the device 500 includes: a receiving module 11, a determining module 12, a reading and writing module 13 and an operating module 14.
[0075] A receiving module 11 is used to receive the operands required for each atomic operation sent by the computing module; the receiving module 11 is also used to receive relevant information for executing each atomic operation sent by the computing module, the relevant information including the original value reading address, atomic operation type and original value return address of the corresponding atomic operation; a determining module 12 is used to determine at least one atomic operation in a valid state based on the identifier of each atomic operation, determine at least one executable atomic operation from at least one atomic operation in a valid state based on the original value reading address of each atomic operation in a valid state, and determine a target atomic operation from all executable atomic operations; a reading and writing module 13 is used to read the target original value from the original value reading address of the target atomic operation, and write the target original value into the computing module based on the original value return address of the target atomic operation; an operating module 14 is used to perform an operation corresponding to the atomic operation type of the target atomic operation on the operand corresponding to the target atomic operation and the target original value, and obtain a target new value corresponding to the target atomic operation; the reading and writing module 13 is used to write the target new value into the original value reading address of the target atomic operation in the storage module.
[0076] The atomic operation execution device of this embodiment can be used to execute the method of any embodiment in the atomic operation execution method side embodiment. Its specific implementation process and technical effects are similar to those in the atomic operation execution method side embodiment. For details, please refer to the detailed introduction in the atomic operation execution method side embodiment, which will not be repeated here.
[0077] Figure 6 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 6As shown, the electronic device may include: a processor (processor) 610, a communication interface (Communications Interface) 620, a memory (memory) 630 and a communication bus 640, wherein the processor 610, the communication interface 620, and the memory 630 communicate with each other through the communication bus 640. The processor 610 can call the logic instructions in the memory 630 to execute the execution method of the atomic operation, the method comprising: receiving the operands required for each atomic operation sent by the calculation module through the operand storage unit; receiving the relevant information for executing each atomic operation sent by the calculation module through the control unit, the relevant information including the original value reading address, atomic operation type and original value return address of the corresponding atomic operation; determining at least one atomic operation in a valid state based on the identifier of each atomic operation through the control unit, and based on the original value reading address of each atomic operation in a valid state, receiving the original value return address from at least one atomic operation in a valid state. At least one executable atomic operation is determined in the operation, and a target atomic operation is determined from all executable atomic operations; the target original value is read from the original value reading address of the target atomic operation by the atomic operation execution unit, and the target original value is written into the computing module based on the original value return address of the target atomic operation; the operation corresponding to the atomic operation type of the target atomic operation is performed on the operand corresponding to the target atomic operation and the target original value by the atomic operation execution unit to obtain a target new value corresponding to the target atomic operation; the target new value is written into the original value reading address of the target atomic operation in the storage module by the atomic operation execution unit.
[0078] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, 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 a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0079] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the atomic operation execution method provided by the above-mentioned methods, and the method includes: receiving the operands required for each atomic operation sent by the computing module through the operand storage unit; receiving the relevant information for executing each atomic operation sent by the computing module through the control unit, and the relevant information includes the original value reading address, atomic operation type and original value return address of the corresponding atomic operation; determining through the control unit at least one atomic operation in a valid state based on the identifier of each atomic operation, and determining the atomic operation in a valid state based on the identifier of each atomic operation. The method comprises the following steps: determining an original value read address of each atomic operation in a valid state, determining at least one executable atomic operation from at least one atomic operation in a valid state, and determining a target atomic operation from all executable atomic operations; reading a target original value from the original value read address of the target atomic operation by the atomic operation execution unit, and writing the target original value into the computing module based on the original value return address of the target atomic operation; performing an operation corresponding to the atomic operation type of the target atomic operation on the operand corresponding to the target atomic operation and the target original value by the atomic operation execution unit, and obtaining a target new value corresponding to the target atomic operation; and writing the target new value into the original value read address of the target atomic operation in the storage module by the atomic operation execution unit.
[0080] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a method for executing the atomic operations provided by the above-mentioned methods, the method comprising: receiving, through the operand storage unit, the operands required for each atomic operation sent by the computing module; receiving, through the control unit, relevant information for executing each of the atomic operations sent by the computing module, the relevant information including the original value reading address, atomic operation type and original value return address of the corresponding atomic operation; determining, through the control unit, at least one atomic operation in a valid state based on the identifier of each of the atomic operations, and based on the original value reading address of each of the atomic operations in a valid state address, determine at least one executable atomic operation from at least one atomic operation in a valid state, and determine a target atomic operation from all executable atomic operations; read the target original value from the original value reading address of the target atomic operation through the atomic operation execution unit, and write the target original value into the computing module based on the original value return address of the target atomic operation; perform the operation corresponding to the atomic operation type of the target atomic operation on the operand corresponding to the target atomic operation and the target original value through the atomic operation execution unit to obtain a target new value corresponding to the target atomic operation; write the target new value into the original value reading address of the target atomic operation in the storage module through the atomic operation execution unit.
[0081] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0082] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0083] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. An atomic operation execution system, characterized in that: include: An atomic operation module, a calculation module and a storage module, wherein the atomic operation module includes an operand storage unit, a control unit and an atomic operation execution unit; The operand storage unit is used to receive operands required for each atomic operation sent by the computing module; The control unit is used to receive the relevant information sent by the computing module for executing each of the atomic operations, wherein the relevant information includes an original value reading address, an atomic operation type and an original value return address corresponding to the atomic operation; The control unit is further used to determine at least one atomic operation in a valid state based on the identifier of each of the atomic operations, read the address based on the original value of each of the atomic operations in a valid state, determine at least one executable atomic operation from the at least one atomic operation in a valid state, and determine the target atomic operation from all executable atomic operations; The atomic operation execution unit is used to read the target original value from the original value reading address of the target atomic operation, and write the target original value into the calculation module based on the original value return address of the target atomic operation; The atomic operation execution unit is further used to perform an operation corresponding to the atomic operation type of the target atomic operation on the operand corresponding to the target atomic operation and the target original value to obtain a target new value corresponding to the target atomic operation; The atomic operation execution unit is further used to write the target new value into the original value reading address of the target atomic operation in the storage module; The control unit is further configured to store the relevant information of each atomic operation in a table entry of the information table, and send the storage address of the relevant information in the table entry to the operand storage unit; The operand storage unit is further used to store the operand corresponding to the atomic operation into the storage address of the operand storage unit.
2. The atomic operation execution system according to claim 1, characterized in that: The control unit is specifically used for: Compare the original value read addresses of each atomic operation in a valid state with each address stored in an address record table, wherein the address record table stores the original value read addresses corresponding to at least one atomic operation currently being executed; When there is an original value read address that fails to be compared among the original value read addresses of all valid atomic operations, the atomic operation corresponding to the original value read address that fails to be compared is determined as an executable atomic operation.
3. The atomic operation execution system according to claim 2, characterized in that: The control unit is further used to store the original value reading address of the target atomic operation in the address recording table, and after determining that the target atomic operation is completed, delete the original value reading address of the target atomic operation from the address recording table.
4. The atomic operation execution system according to claim 2, characterized in that: The control unit is further used to set the identifier of the atomic operation to a valid identifier, where the valid identifier is used to indicate that the atomic operation is in a valid state.
5. The atomic operation execution system according to claim 4, characterized in that: The atomic operation execution unit is specifically used for: Reading a read original value command corresponding to the target atomic operation from a read command queue, wherein the read command queue is used to store the read original value commands of each executable atomic operation, each of the read original value commands including an original value read address of the corresponding atomic operation read by the control unit from the information table; The target original value is read from the storage module based on the original value read address included in the read original value command corresponding to the target atomic operation.
6. The atomic operation execution system according to claim 4, characterized in that: The atomic operation execution unit is specifically used for: The target new value is stored in a write data queue, and a write new value command corresponding to the target new value is stored in a write command queue, wherein the write new value command includes an original value reading address of a target original value corresponding to the target new value; The write new value command is read from the write command queue, the target new value is read from the write data queue, and the target new value is written into the original value read address included in the write new value command.
7. The atomic operation execution system according to any one of claims 1 to 6, characterized in that: The atomic operation execution unit is specifically used for: Determine the target atomic operation from all executable atomic operations according to the operation priority of each executable atomic operation; or, Each of the executable atomic operations is polled, and the currently polled executable atomic operation is determined as the target atomic operation.
8. A method for executing an atomic operation, characterized in that: Applied to an atomic operation module, the atomic operation module includes an operand storage unit, a control unit and an atomic operation execution unit; the method includes: Receiving operands required for each atomic operation sent by the computing module through the operand storage unit; Receiving, by the control unit, relevant information sent by the computing module for executing each of the atomic operations, the relevant information including an original value reading address corresponding to the atomic operation, an atomic operation type, and an original value return address; Determine, by the control unit, at least one atomic operation in a valid state based on the identifier of each of the atomic operations, read the address based on the original value of each of the atomic operations in a valid state, determine at least one executable atomic operation from the at least one atomic operation in a valid state, and determine the target atomic operation from all executable atomic operations; Reading a target original value from an original value read address of the target atomic operation through the atomic operation execution unit, and writing the target original value into the calculation module based on an original value return address of the target atomic operation; The atomic operation execution unit performs an operation corresponding to the atomic operation type of the target atomic operation on the operand corresponding to the target atomic operation and the target original value, so as to obtain a target new value corresponding to the target atomic operation; Writing the target new value into the original value reading address of the target atomic operation in the storage module through the atomic operation execution unit; For the relevant information of each of the atomic operations, the control unit stores the relevant information of the atomic operation in a table entry of the information table, and sends the storage address of the relevant information in the table entry to the operand storage unit; The operand corresponding to the atomic operation is stored in the storage address of the operand storage unit through the operand storage unit.
9. An atomic operation execution device, characterized in that: include: A receiving module, used for receiving operands required for each atomic operation sent by the computing module; The receiving module is further used to receive the relevant information sent by the computing module for executing each of the atomic operations, wherein the relevant information includes the original value reading address, the atomic operation type and the original value return address corresponding to the atomic operation; A determination module, configured to determine at least one atomic operation in a valid state based on the identifier of each of the atomic operations, read an address based on the original value of each of the atomic operations in a valid state, determine at least one executable atomic operation from the at least one atomic operation in a valid state, and determine a target atomic operation from all executable atomic operations; A read / write module, configured to read a target original value from an original value read address of the target atomic operation, and write the target original value into the calculation module based on an original value return address of the target atomic operation; An operation module, used for performing an operation corresponding to the atomic operation type of the target atomic operation on the operand corresponding to the target atomic operation and the target original value, to obtain a target new value corresponding to the target atomic operation; The read-write module is used to write the target new value into the original value read address of the target atomic operation in the storage module; A sending module, used for storing the relevant information of each atomic operation in a table entry of an information table, and sending the storage address of the relevant information in the table entry to an operand storage unit; A storage module is used to store the operand corresponding to the atomic operation into the storage address of the operand storage unit.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the method for executing the atomic operation as claimed in claim 8 is implemented.
Citation Information
Patent Citations
System for executing atomic operation, atomic operation method and device
CN114035849A
