Methods for implementing atomic instructions, electronic devices, computer-readable media, and computer program products.

By using decoding and flag assignment, the Store Type AMO atomic instruction, which is not defined in the RISC-V instruction set, was implemented, solving the resource consumption and compatibility issues and realizing the functionality of the Store Type AMO atomic instruction.

CN123067932APending Publication Date: 2026-11-10BEIJING LEAPRISE TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611259543.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-19
Publication Date
2026-11-10

AI Technical Summary

Technical Problem

The RISC-V instruction set does not define the Store Type AMO atomic instruction. Customizing this instruction will consume resources and cause ecosystem and tool compatibility issues.

Method used

The AMO atomic instruction is decoded by the decoding module to obtain the decoding information. The flag bit is assigned according to the destination register type. The sending module sends the decoding information and the flag bit to the load storage unit. The load storage module performs the atomic operation to realize the function of the Store Type AMO atomic instruction.

Benefits of technology

Without needing to define additional Store Type AMO atomic instructions, resource consumption is reduced, ecosystem and tool compatibility issues are avoided, and the functionality of Store Type AMO atomic instructions is realized.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123067932A_ABST
    Figure CN123067932A_ABST
Patent Text Reader

Abstract

This disclosure provides a method for implementing atomic instructions, an electronic device, a computer-readable medium, and a computer program product. The method includes: a decoding module decoding an atomic memory operation (AMO) atomic instruction to obtain AMO instruction decoding information; a sending module assigning values ​​to flag bits according to the type of the destination register in the AMO instruction decoding information, the flag bits indicating whether an operand read from a memory address indicated by a second register should be returned to the destination register, the second register being the register used to execute the AMO atomic instruction; the sending module sending the AMO instruction decoding information and the flag bits to a load memory unit; and a load memory module executing the atomic operation corresponding to the AMO atomic instruction based on the flag bits and the AMO instruction decoding information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and in particular to a method for implementing atomic instructions, electronic devices, computer-readable media, and computer program products. Background Technology

[0002] Atomic instructions are a core hardware mechanism in computer architecture for achieving multi-threaded synchronization, designed to solve race conditions in shared memory access in multi-core environments. The ARM Advanced Instruction Set Machine (RISC-V) instruction set supports LoadType atomic instructions and StoreType atomic instructions. LoadType atomic instructions require returning the raw value to the destination register, while StoreType atomic instructions do not. However, the RISC-V fifth-generation RISC-V only defines LoadType Atomic Memory Operation (AMO) atomic instructions, not StoreType AMO atomic instructions. If users define their own StoreType AMO atomic instructions, not only will there be compatibility issues with the ecosystem and tools, but they will also consume more resources. Therefore, it is necessary to develop a method that can implement StoreType AMO atomic instructions without requiring additional custom definitions. Summary of the Invention

[0003] This disclosure provides a method for implementing atomic instructions, an electronic device, a computer-readable medium, and a computer program product.

[0004] In a first aspect, embodiments of this disclosure provide a method for implementing atomic instructions, comprising:

[0005] The decoding module decodes the atomic memory operation AMO atomic instructions to obtain AMO instruction decoding information;

[0006] The sending module assigns a value to the flag bit according to the type of the destination register in the AMO instruction decoding information. The flag bit is used to indicate whether the operand read from the memory address indicated by the second register is returned to the destination register. The second register is the register used to execute the AMO atomic instruction.

[0007] The sending module sends the AMO instruction decoding information and the flag bit to the loading storage unit;

[0008] The loading and storage module executes the atomic operation corresponding to the AMO atomic instruction based on the flag bit and the AMO instruction decoding information.

[0009] Secondly, embodiments of this disclosure provide an electronic device, including a memory and a processor; the memory stores a computer program that can be executed by the processor, and when the computer program is executed by the processor, it implements the atomic instruction implementation method as described above.

[0010] Thirdly, embodiments of this disclosure provide a computer-readable medium storing a computer program that, when executed by a processor, implements the atomic instruction implementation method as described above.

[0011] Fourthly, embodiments of this disclosure also provide a computer program product, including a computer program that, when executed by a processor, implements the atomic instruction implementation method as described above.

[0012] The atomic instruction implementation method provided in this disclosure involves a decoding module that decodes the AMO atomic instruction to obtain AMO instruction decoding information; a sending module that assigns a value to a flag bit according to the type of the destination register in the AMO instruction decoding information, the flag bit indicating whether the operand read from the memory address indicated by the second register should be returned to the destination register; and a loading storage module that executes the atomic operation corresponding to the AMO atomic instruction based on the flag bit and the AMO instruction decoding information. When executing the atomic operation, it is only necessary to determine whether the operand read from the memory address indicated by the second register needs to be returned to the destination register based on the flag bit. Other operations are the same as the atomic operation steps of the Load Type AMO atomic instruction defined in the RISC-V instruction set. Therefore, there is no need to define an additional Store Type AMO atomic instruction, reducing resource consumption and avoiding ecosystem and tool compatibility issues. Attached Figure Description

[0013] Figure 1 An application scenario diagram of an embodiment of this disclosure is shown.

[0014] Figure 2 A flowchart illustrating an implementation method of an atomic instruction provided in an embodiment of this disclosure is shown.

[0015] Figure 3 A flowchart illustrating another method for implementing atomic instructions provided in an embodiment of this disclosure is shown.

[0016] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure is shown. Detailed Implementation

[0017] To enable those skilled in the art to better understand the technical solutions of this disclosure, the implementation method of atomic instructions, electronic devices, computer-readable media, and computer program products provided in the embodiments of this disclosure will be described in detail below with reference to the accompanying drawings.

[0018] The present disclosure will be described more fully below with reference to the accompanying drawings; however, the embodiments shown may be embodied in different forms, and the present disclosure should not be construed as limited to the embodiments set forth below. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will enable those skilled in the art to fully understand the scope of the disclosure.

[0019] The accompanying drawings are provided to further illustrate this disclosure and form part of the specification. They are used together with the detailed embodiments to explain this disclosure and do not constitute a limitation thereof. These and other features and advantages will become more apparent to those skilled in the art from the description of detailed embodiments with reference to the accompanying drawings.

[0020] Unless otherwise specified, each embodiment and feature of this disclosure may be used individually or in combination with other embodiments and features thereof.

[0021] Those skilled in the art will understand that various changes in form and detail may be made to the embodiments of this disclosure without departing from the scope of this disclosure as set forth by the appended claims.

[0022] The terminology used in this disclosure is for the purpose of describing particular embodiments only and is not intended to limit the disclosure. The term "and / or" as used in this disclosure includes any and all combinations of one or more of the associated enumerated entries. The singular forms "a" and "the" as used in this disclosure are also intended to include the plural forms, unless the context clearly indicates otherwise. The terms "comprising," "made of," etc., as used in this disclosure specify the presence of the stated feature, integral, step, operation, element, and / or component, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or groups thereof.

[0023] Unless otherwise specified, all terms used in this disclosure (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and this disclosure, and will not be interpreted as having an idealized or overly formal meaning, unless expressly so defined in this disclosure.

[0024] This disclosure is not limited to the embodiments shown in the accompanying drawings, but includes modifications to the configuration based on the manufacturing process. Therefore, the areas illustrated in the drawings are schematic, and the shapes of the areas shown illustrate specific shapes of the areas of an element, but are not intended to be limiting.

[0025] In multi-threaded computer operations, if the traditional "read-modify-write" step-by-step execution is followed, it is easy to be interrupted and cause data corruption. However, atomic instructions, through hardware-level support, can merge "read-modify-write" operations into an indivisible single-step transaction, avoiding interference from other cores during execution.

[0026] The current ARM instruction set supports Load Type AMO atomic instructions and Store Type AMO atomic instructions. Table 1 lists the atomic instructions and their corresponding atomic operations in the ARM instruction set.

[0027] The Load Type AMO atomic instruction reads the current value from the specified memory address, performs corresponding arithmetic and logical operations (ALU) on the current value and the value in the register, writes the calculation result back to the specified memory address, and returns the original value at the specified memory address to the destination register.

[0028] The Store Type AMO atomic instruction reads the current value from the specified memory address, performs the corresponding ALU calculation on the current value and the value in the register, and then writes the calculation result back to the specified memory address. However, it does not need to return the original value at the specified memory address to the destination register.

[0029] Table 1

[0030]

[0031] In related technologies, the ARM instruction set defines Store Type AMO atomic instructions, which can perform atomic operations without returning the original value to the destination register.

[0032] Table 2 lists the atomic instructions and their corresponding atomic memory operations (AMOs) in the RISC-V instruction set. It's clear that the RISC-V instruction set only defines Load Type AMO atomic instructions, not Store Type AMO atomic instructions. Therefore, only atomic operations that return the original value to the destination register can be executed; atomic operations that don't require returning the original value to the destination register cannot be executed. Customizing Store Type AMO atomic instructions not only consumes resources but also presents ecosystem and tool compatibility issues.

[0033] Table 2

[0034]

[0035] Figure 1 An application scenario diagram of an embodiment of this disclosure is shown. For example... Figure 1 As shown, the high-performance processor includes a decoding module 10, an ISSUE UNIT (ISU) 20, and a LOADSTORE UNIT (LSU) 30. The decoding module 10 decodes AMO atomic instructions to obtain AMO instruction decoding information. The ISSUE UNIT 20 sends the AMO instruction decoding information to the LOADSTORE UNIT 30. The LOADSTORE UNIT 30 receives the AMO instruction decoding information and executes corresponding atomic operations based on it.

[0036] In this embodiment, the high-performance processor includes, but is not limited to, a central processing unit (CPU), a graphics processing unit (GPU), and a digital signal processor (DSP).

[0037] This disclosure provides a method for implementing atomic instructions, which can be used in the development of RISC-V processors. The atomic operations corresponding to the Store Type AMO atomic instructions can also be implemented using the Load Type AMO atomic instructions, without the need to define the Store Type AMO atomic instructions separately, thus reducing resource consumption and avoiding ecosystem and tool compatibility issues.

[0038] Figure 2 A flowchart illustrating an implementation method of an atomic instruction provided in an embodiment of this disclosure is shown. (Refer to...) Figure 2 The implementation methods of atomic instructions include:

[0039] Step S201: The decoding module decodes the AMO atomic instructions to obtain AMO instruction decoding information.

[0040] AMO atomic instructions can be initiated by a high-performance processor. For example, the instruction fetch module in a high-performance processor can fetch the instruction from the program flow, and then the decoding module can decode it to obtain the AMO instruction decoding information.

[0041] In step S202, the sending module assigns a value to the flag bit according to the type of the destination register in the AMO instruction decoding information. The flag bit is used to indicate whether the operand read from the memory address indicated by the second register is returned to the destination register. The second register is the register used to execute the AMO atomic instruction.

[0042] In this embodiment, the AMO atomic instruction comprises an opcode, an operation width, a destination register, a first register, and a second register. The opcode indicates the operation type of the AMO atomic instruction; the operation width indicates the data length of the operand; the destination register is used to write the operand read from the memory address indicated by the second register; the first register stores the first operand; the second register stores the memory address; and the memory address stores the second operand. Correspondingly, the AMO instruction decoding information includes the AMO instruction type, operation width, destination register, first register, and second register. The AMO instruction type indicates the arithmetic / logical operation type of the AMO atomic instruction; the operation width indicates the data length of the atomic operation; the destination register is used to write the operand read from the memory address indicated by the second register; the first register stores the first operand; the second register stores the memory address; and the memory address stores the second operand.

[0043] The RISC-V architecture defines 32 general-purpose registers, numbered from x0 to x31. Among them, x0 is a destination register that is hardwired and always has a value of 0, x1 to x31 are readable and writable registers, and the first and second registers are the registers numbered x1 to x31.

[0044] For example, taking the AMO atomic instruction amoadd.w x0, x5, (x6) as an example, amoadd indicates that the AMO instruction type is addition logic operation, w indicates the operation bit width, x0 indicates the destination register, x5 indicates the first register, and x6 indicates the second register.

[0045] In the RISC-V architecture, register x0 is a constant 0 register and is not writable, while registers x1 to x31 are writable registers. In this embodiment, the flag bits dst and vld are assigned values ​​according to the type of the destination register. Different values ​​are assigned to non-writable and writable registers.

[0046] In step S203, the sending module sends the AMO instruction decoding information and flag bits to the loading storage unit.

[0047] This embodiment does not limit the method by which the sending module sends AMO instruction decoding information and flag bits to the loading storage unit.

[0048] Step S204: The loading storage module executes the atomic operation corresponding to the AMO atomic instruction based on the flag bit and AMO instruction decoding information.

[0049] In this embodiment, when the load storage module executes the atomic operation corresponding to the AMO atomic instruction, it determines whether it needs to return the original value of the memory address pointed to by the second register to the destination register based on the flag bit.

[0050] The atomic instruction implementation method provided in this disclosure involves a decoding module that decodes the AMO atomic instruction to obtain AMO instruction decoding information; a sending module that assigns a value to a flag bit based on the type of the destination register in the AMO instruction decoding information, the flag bit indicating whether the operand read from the memory address indicated by the second register should be returned to the destination register; and a loading storage module that executes the atomic operation corresponding to the AMO atomic instruction based on the flag bit and the AMO instruction decoding information. When executing the atomic operation, it is only necessary to determine whether the operand read from the memory address indicated by the second register needs to be returned to the destination register based on the flag bit. Other operations are the same as the atomic operation steps of the Load Type AMO atomic instruction defined in the RISC-V instruction set. Therefore, there is no need to define an additional Store Type AMO atomic instruction, which reduces resource consumption and avoids ecosystem and tool compatibility issues.

[0051] In some embodiments, AMO atomic instructions include Store Type AMO atomic instructions and Load Type AMO atomic instructions. Store Type AMO atomic instructions are AMO atomic instructions not defined in the RISC-V instruction set, and the destination register corresponding to a Store Type AMO atomic instruction is of a non-writable type. Load Type AMO atomic instructions are AMO atomic instructions defined in the RISC-V instruction set, and the destination register corresponding to a Load Type AMO atomic instruction is of a readable and writable type.

[0052] The sending module assigns values ​​to flag bits in the destination register based on the AMO instruction decoding information. Specifically, if the sending module determines the destination register type to be non-writable based on the AMO instruction decoding information, it assigns the first value to the flag bit. The sending module can identify whether an AMO atomic instruction is a Store Type AMO atomic instruction based on the destination register type. If the destination register type is non-writable, the AMO atomic instruction is a Store Type AMO atomic instruction; if the destination register type is readable and writable, the AMO atomic instruction is a Load Type AMO atomic instruction.

[0053] In some embodiments, the sending module assigns a value to the flag bit according to the destination register in the AMO instruction decoding information, including: if the sending module determines that the type of the destination register is readable and writable according to the AMO instruction decoding information, it assigns a second value to the flag bit.

[0054] In some embodiments, the flag bit includes a value or a character. When the flag bit is a value, the first value is 0 if the destination register is of a non-writable type; the second value is 1 if the destination register is of a readable and writable type. When the flag bit is a character, the first value is the first character if the destination register is of a non-writable type; the second value is the second character if the destination register is of a readable and writable type.

[0055] It should be noted that the first and second values ​​can also be other numerical values, and this disclosure does not limit them. The first and second characters include A and B, and can also be other letters, and this disclosure does not limit them. For example, when the destination register is of a non-writable type, the flag bit is assigned the value A; when the destination register is of a readable and writable type, the flag bit is assigned the value B.

[0056] In some embodiments, the load storage module executes the atomic operation corresponding to the AMO atomic instruction based on the flag bit and AMO instruction decoding information, including: the load storage module executes the atomic operation corresponding to the Store Type AMO atomic instruction according to the operation mode of executing Load Type AMO atomic instructions defined by the RISC-V instruction set based on the AMO instruction decoding information, and writes the second operand into the destination register.

[0057] In some embodiments, the AMO instruction decoding information includes a first register and a second register. The first register is used to store a first operand, and the second register is used to store the memory address of the AMO atomic instruction, which stores the second operand.

[0058] The loading storage module, based on the AMO instruction decoding information, executes the atomic operations corresponding to the Store Type AMO atomic instructions according to the operation mode of executing Load Type AMO atomic instructions defined in the RISC-V instruction set. These operations include: obtaining the first operand from the first register and reading the memory address pointed to by the second register to obtain the second operand; performing arithmetic and logical operations on the first operand and the second operand to obtain the logical operation result; writing the logical operation result into the memory address pointed to by the second register and discarding the second operand.

[0059] For example, take the amoadd.w x0, x5, (x6) atomic instruction in the Store Type AMO atomic instruction as an example.

[0060] Here, amoadd indicates that an addition logical operation is performed.

[0061] .w indicates that the operation width is Word (32 bits), which means that only 4 bytes in memory can be read and written.

[0062] x0 represents the destination register, and the second operand read from the memory address pointed to by the second register can be ignored, meaning that the second operand does not need to be written back to the destination register.

[0063] x5 represents the first register, which stores the first operand.

[0064] x6 represents the second register, which stores the memory address for instruction read / write.

[0065] The process of loading the storage module and executing the atomic instructions amoadd.w x0, x5, (x6) includes: extracting the first operand from the first register x5, and reading the second operand from the memory address pointed to by the second register x6. The operation width of the second operand is 32-bit word. Performing an addition logical operation on the first operand and the second operand to obtain the logical operation result, writing the logical operation result back to the memory address pointed to by the second register x6, and discarding the second operand read from the memory address pointed to by the second register x6. That is, it is not necessary to return the original value at the memory address pointed to by the second register x6 to the destination register x0.

[0066] In some embodiments, the AMO atomic instruction includes a Load Type AMO atomic instruction, where the destination register corresponding to the Load Type AMO atomic instruction is of a read-write type. If the sending module determines that the destination register is of a read-write type based on the AMO instruction decoding information, it assigns the second value to the flag bit.

[0067] The AMO instruction decoding information includes a first register x5 and a second register x6. The first register is used to store the first operand, and the second register is used to store the memory address of the AMO atomic instruction, which stores the second operand.

[0068] The load storage module executes the atomic operation corresponding to the AMO atomic instruction based on the flag bit and AMO instruction decoding information, including: obtaining the first operand from the first register and reading the memory address pointed to by the second register to obtain the second operand; performing arithmetic and logical operations on the first operand and the second operand to obtain the logical operation result; writing the logical operation result into the memory address pointed to by the second register, and writing the second operand into the destination register.

[0069] For example, take the amoadd.w x1, x5, (x6) atomic instruction in the Load Type AMO atomic instruction as an example.

[0070] Here, amoadd indicates that an addition logical operation is performed.

[0071] .w indicates that the operation width is Word (32 bits), which means that only 4 bytes in memory can be read and written.

[0072] x1 represents the destination register, where the "second operand" read from the memory address needs to be returned to the x1 register.

[0073] x5 represents the first register, which stores the first operand.

[0074] x6 represents the second register, which stores the memory address for instruction read / write.

[0075] The process of loading the storage module and executing the atomic instructions amoadd.w x1, x5, (x6) includes: extracting the first operand from the first register x5, and reading the second operand from the memory address pointed to by the second register x6. The operation width of the second operand is 32-bit word. Performing an addition logical operation on the first operand and the second operand to obtain the logical operation result, writing the logical operation result back to the memory address pointed to by the second register x6, and returning the second operand (original value) read from the memory address pointed to by the second register x6 to the destination register x1.

[0076] To better understand this embodiment, the following is combined with... Figure 3 The implementation method of atomic instructions will be further explained.

[0077] Figure 3 A flowchart illustrating another method for implementing atomic instructions provided in an embodiment of this disclosure is shown. (Refer to...) Figure 3 The implementation methods of atomic instructions include:

[0078] Step S301: The decoding module decodes the AMO atomic instructions to obtain AMO instruction decoding information.

[0079] In step S302, the sending module assigns a value to the flag bit according to the type of the destination register in the AMO instruction decoding information.

[0080] In step S302, if the destination register in the AMO instruction decoding information is register x0 and the type of the destination register is a non-writable register, then the AMO atomic instruction is a Store Type AMO atomic instruction. The flag bit dstvld is assigned to 0, and the load storage module can execute the StoreType AMO atomic instruction according to the atomic operation mode of the Load Type AMO atomic instruction.

[0081] If the destination register in the AMO instruction decoding information is a non-x0 register and the type of the destination register is a readable and writable register, and the flag bit dst vld is assigned a value of 1, then the AMO atomic instruction is a Load Type AMO atomic instruction, and the load memory module can directly execute the corresponding atomic operation according to the Load Type AMO atomic instruction.

[0082] In step S303, the sending module sends the AMO instruction decoding information and flag bits to the loading storage unit.

[0083] Step S304: If the loading storage module detects that the flag bit dst vld is 0, perform the following operation:

[0084] Extract the first operand from the first register x5 and read the second operand, a 32-bit word, from the memory address pointed to by the second register x6. Perform an addition logical operation on the first operand and the second operand to obtain the logical operation result. Write the logical operation result back to the memory address pointed to by the second register x6 and discard the second operand read from the memory address pointed to by the second register x6.

[0085] Step S305: If the loading storage module detects that the flag bit dst vld is 1, perform the following operation:

[0086] Extract the first operand from the first register x5 and read the 32-bit word second operand from the memory address pointed to by the second register x6. Perform an addition logical operation on the first operand and the second operand to obtain the logical operation result. Write the logical operation result back to the memory address pointed to by the second register x6 and return the second operand read from the memory address pointed to by the second register x6 to the destination register x1.

[0087] This disclosure also provides an electronic device, Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure is shown, such as... Figure 4 As shown, the electronic device includes: at least one processor 401; at least one memory 402; and one or more I / O interfaces 403 connected between the processor 401 and the memory 402; wherein the memory 402 stores one or more computer programs that can be executed by at least one processor 401, and the one or more computer programs are executed by at least one processor 401 to enable at least one processor 401 to execute any of the above-described methods of implementing atomic instructions.

[0088] In this embodiment of the disclosure, the processor 401 is a device with data processing capabilities, including but not limited to a central processing unit (CPU); the memory is a device with data storage capabilities, including but not limited to random access memory (RAM), more specifically such as SDRAM, DDR, etc., read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory (FLASH); the I / O interface, or read-write interface, is connected between the processor and the memory, enabling information interaction between the memory and the processor, including but not limited to a data bus (Bus).

[0089] This disclosure also provides a computer-readable medium, which includes a computer program that, when executed by a processor, implements any of the aforementioned atomic instruction implementation methods.

[0090] This disclosure also provides a computer program product, which includes a computer program that, when executed by a processor, implements any of the aforementioned atomic instruction implementation methods.

[0091] It will be understood by those skilled in the art that all or some of the steps, systems, or apparatuses disclosed above, and their functional modules / units, can be implemented as software, firmware, hardware, or suitable combinations thereof. In hardware implementations, the division between functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed collaboratively by several physical components. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit (ASIC). Such software may be distributed on a computer-readable medium, which may include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.

[0092] Example embodiments have been disclosed herein, and while specific terminology has been used, it is for illustrative purposes only and should be construed as such, and is not intended to be limiting. In some instances, it will be apparent to those skilled in the art that features, characteristics, and / or elements described in connection with particular embodiments may be used alone, or in combination with features, characteristics, and / or elements described in connection with other embodiments, unless otherwise expressly indicated. Therefore, those skilled in the art will understand that various changes in form and detail may be made without departing from the scope of this disclosure as set forth by the appended claims.

Claims

1. A method for implementing atomic instructions, wherein, include: The decoding module decodes the atomic memory operation AMO atomic instructions to obtain AMO instruction decoding information; The sending module assigns a value to the flag bit according to the type of the destination register in the AMO instruction decoding information. The flag bit is used to indicate whether the second operand read from the memory address indicated by the second register is returned to the destination register. The second register is the register used to execute the AMO atomic instruction. The sending module sends the AMO instruction decoding information and the flag bit to the loading storage unit; The loading and storage module executes the atomic operation corresponding to the AMO atomic instruction based on the flag bit and the AMO instruction decoding information.

2. The method according to claim 1, wherein, The AMO atomic instruction includes a Store Type AMO atomic instruction, wherein the destination register in the Store Type AMO atomic instruction is of a non-writable type; The sending module assigns values ​​to the flag bits according to the destination register in the AMO instruction decoding information, including: If the sending module determines that the type of the destination register is non-writable based on the AMO instruction decoding information, it assigns the first value to the flag bit.

3. The method according to claim 2, wherein, The load-store module executes the atomic operation corresponding to the AMO atomic instruction based on the flag bit and the AMO instruction decoding information, including: The loading storage module executes the atomic operation corresponding to the Store Type AMO atomic instruction based on the AMO instruction decoding information, in accordance with the operation mode of executing the LoadType AMO atomic instruction defined by the RISC-V instruction set.

4. The method according to claim 3, wherein, The AMO instruction decoding information includes a first register and a second register. The first register is used to store a first operand, and the second register is used to store a memory address, in which the second operand is stored. The load-store module, based on the AMO instruction decoding information, executes the atomic operation corresponding to the Store Type AMO atomic instruction according to the operation mode of executing the Load Type AMO atomic instruction defined by the RISC-V instruction set, including: Obtain the first operand from the first register, and read the memory address pointed to by the second register to obtain the second operand; Perform arithmetic and logical operations on the first operand and the second operand to obtain the logical operation result; Write the result of the logical operation into the memory address pointed to by the second register, and discard the second operand.

5. The method according to claim 1, wherein, The AMO atomic instruction includes a Load Type AMO atomic instruction, and the destination register corresponding to the Load Type AMO atomic instruction is of a readable and writable type. The sending module assigns values ​​to the flag bits according to the destination register in the AMO instruction decoding information, including: If the sending module determines that the type of the destination register is readable and writable based on the AMO instruction decoding information, it assigns the flag bit to the second value.

6. The method according to claim 5, wherein, The AMO instruction decoding information includes a first register and a second register. The first register is used to store a first operand, and the second register is used to store a memory address, in which the second operand is stored. The load-store module executes the atomic operation corresponding to the AMO atomic instruction based on the flag bit and the AMO instruction decoding information, including: Obtain the first operand from the first register, and read the memory address pointed to by the second register to obtain the second operand; Perform arithmetic and logical operations on the first operand and the second operand to obtain the logical operation result; Write the result of the logical operation into the memory address pointed to by the second register, and write the second operand into the destination register.

7. The method according to claim 1, wherein, The AMO atomic instruction comprises an opcode, an operation width, a destination register, a first register, and a second register. The opcode indicates the operation type of the AMO atomic instruction; the operation width indicates the data length of the operand; the destination register is used to write the operand read from the memory address indicated by the second register; the first register stores the first operand; the second register stores the memory address; and the memory address stores the second operand.

8. An electronic device, wherein, It includes a memory and a processor; the memory stores a computer program that can be executed by the processor, and when the computer program is executed by the processor, it implements the method for implementing the atomic instructions according to any one of claims 1 to 7.

9. A computer-readable medium, wherein, The device contains a computer program that, when executed by a processor, implements the method for implementing the atomic instructions according to any one of claims 1 to 7.

10. A computer program product, wherein, It includes a computer program that, when executed by a processor, implements the method for implementing the atomic instructions according to any one of claims 1 to 7.