Instruction processing method, device, system and electronic device
By using modifier identification detection and caching operands in the SIMD architecture, the problem of multi-threaded read request competition is solved, instruction execution efficiency is improved, resource access conflicts are reduced, and execution performance is improved.
Patent Information
- Application Number
- CN202410692438.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-30
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2044-05-30
AI Technical Summary
In the SIMD architecture, multiple execution units or multiple threads of a single execution unit initiate read requests to the same resource at the same time, resulting in read request competition, blocking instruction execution, and affecting execution efficiency.
By using modifier identifiers to detect and cache operands in the operand buffer area, access conflicts to the same resource are reduced and efficient processing of target operands by the instruction execution unit is achieved.
It improves the instruction execution efficiency, reduces resource access conflicts, and improves the execution performance of multiple instructions.
Smart Images

Figure CN118259970B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to an instruction processing method, device, system and electronic device. Background Art
[0002] In the SIMD (Single Instruction Multiple Data) architecture, multiple threads form a group, and multiple groups are scheduled to increase parallelism and hide execution delays.
[0003] In the prior art, the thread group scheduler selects an instruction that can be executed, and the instruction is transmitted to the execution unit through the transmission port. The execution unit will initiate a read request for the operand required to execute the operation. Since multiple execution units or multiple threads of a single execution unit will simultaneously initiate read requests to the same resource, these read requests will cause some read requests to fail to read data due to competition, thereby blocking the execution of the instruction and affecting the execution efficiency of the instruction. Summary of the invention
[0004] In order to solve or partially solve the above problems, the present disclosure provides an instruction processing method, device, system and electronic device.
[0005] In a first aspect, the present disclosure provides an instruction processing method, comprising: in response to the presence of a modifier identifier in the operand address of a currently executed instruction, detecting an operand cache based on the modifier identifier; in response to determining that the operand cache has stored a target operand corresponding to a target operand address, obtaining the target operand from the operand cache, wherein the target operand address is an operand address with a modifier identifier; and an instruction execution unit processing the currently executed instruction based on the target operand.
[0006] Optionally, detecting the operand cache includes: performing a hit / miss test on the target operand address in the operand cache to obtain a test result; in response to the test result being a hit, determining that the operand cache has stored the target operand.
[0007] Optionally, the instruction processing method further includes: in response to the test result being a miss, the instruction execution unit reading a target operand from a target resource based on a miss flag; and caching the target operand into an operand cache area.
[0008] Optionally, the above instruction processing method also includes: parsing the currently executed instruction to determine the operand address to be read, wherein the operand address to be read includes the target operand address and other operand addresses not marked with modifiers; the instruction execution unit reads other operands corresponding to the other operand addresses from the target resource.
[0009] Optionally, the instruction execution unit processes the currently executed instruction based on the target operand, including: the instruction execution unit processes the currently executed instruction based on the target operand and other operands.
[0010] Optionally, the target resource includes a vector resource for storing vector operands and / or a scalar resource for storing scalar operands; the operand cache includes a vector cache for caching vector operands and / or a scalar cache for caching scalar operands.
[0011] Optionally, the instruction processing method further includes: in response to determining that the modifier is a release modifier and the instruction execution unit has obtained the target operand from the cache area, releasing cache resources occupied by the target operand in the cache area.
[0012] Optionally, the modifier identifier is added by the following steps: compiling the source program to obtain a compiled instruction set; determining instructions for reading the same operand address from the instruction set to obtain a target instruction set; adding a modifier identifier to the same operand address in each target instruction.
[0013] Optionally, the modifier identifier includes a cacheable modifier and a release modifier; and adding a modifier identifier to the same operand address in each target instruction includes: setting the modifier identifier of the same operand address in the last instruction read in the target instruction set to a release modifier; setting the modifier identifier of the same operand address in other instructions in the target instruction set to a cacheable modifier.
[0014] In a second aspect, an instruction processing device is provided, comprising: a detection module, configured to detect an operand cache in response to the presence of a modifier identifier in the operand address of a currently executed instruction, based on the modifier identifier; an acquisition module, configured to acquire the target operand from the operand cache in response to determining that the operand cache has stored a target operand corresponding to the target operand address, wherein the target operand address is an operand address with a modifier identifier; and an instruction execution module, configured to process the currently executed instruction based on the target operand.
[0015] In a third aspect, an instruction processor is provided, comprising: a scheduling interface for determining a currently executing instruction; a cache unit for determining whether to store a target operand corresponding to a target operand address, and sending the target operand in response to determining that the target operand has been stored, wherein the target operand address is an operand address with a modifier in the currently executing instruction; and an instruction execution unit for processing the currently executing instruction based on the target operand.
[0016] In a fourth aspect, an instruction processing system is provided, comprising: a compilation module, used to compile a source program, add a modifier identifier to the same operand address in the compiled instruction set, and send the instruction with the modifier identifier; an instruction processor, comprising: a scheduling interface, used to determine the current execution instruction from the instruction with the modifier identifier; a cache unit, used to determine whether to store a target operand corresponding to the target operand address, and send the target operand in response to determining that the target operand has been stored, wherein the target operand address is the operand address with the modifier identifier in the current execution instruction; an instruction execution unit, used to process the current execution instruction based on the target operand.
[0017] In a fifth aspect, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method described in any implementation manner in the first aspect.
[0018] In a sixth aspect, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause a computer to execute the method described in any implementation manner in the first aspect.
[0019] The instruction processing method provided by the embodiment of the present disclosure first detects the operand cache area based on the modifier identifier when determining that the operand address of the currently executed instruction has a modifier identifier; then obtains the target operand with the modifier identifier from the operand cache area when determining that the operand cache area has stored the target operand corresponding to the target operand address; finally, the instruction execution unit processes the currently executed instruction based on the target operand. The instruction processing method of the embodiment of the present disclosure is based on the repetitive characteristics of operands in multiple instructions, and caches repeated operands in the operand cache area, so that the operand can be directly obtained from the operand cache area when executing subsequent instructions, reducing the conflict caused by accessing the same resource, thereby improving the execution efficiency of instructions.
[0020] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0022] Figure 1 is a flow chart of an embodiment of an instruction processing method according to the present disclosure;
[0023] Figure 2is a flow chart of another embodiment of the instruction processing method according to the present disclosure;
[0024] Figure 3 is a flow chart of another embodiment of the instruction processing method according to the present disclosure;
[0025] Figure 4 is a schematic structural diagram of an embodiment of an instruction processing device according to the present disclosure;
[0026] Figure 5 is a schematic diagram of the structure of an embodiment of an instruction processor according to the present disclosure;
[0027] Figure 6 is a schematic diagram of the structure of an embodiment of an instruction processing system according to the present disclosure;
[0028] Figure 7 is an application scenario diagram of the instruction processing system according to the present disclosure;
[0029] Figure 8 It is a block diagram of an electronic device used to implement the instruction processing method of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0030] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0031] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present disclosure may be combined with each other.
[0032] The present disclosure will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.
[0033] Figure 1 A flow chart 100 of an embodiment of an instruction processing method according to the present disclosure is shown. The instruction processing method comprises the following steps:
[0034] Step 101 , in response to a modifier tag being present in an operand address of a currently executed instruction, an operand buffer is detected based on the modifier tag.
[0035] In this embodiment, the instruction processing method is applied to a SIMD system. When the execution subject executes the current execution instruction, it will identify whether there is a preset modifier identifier in the current execution instruction. If it detects that there is a modifier identifier in the current execution instruction, it will detect the operand cache area based on the modifier identifier.
[0036] It should be noted that an instruction is a command that instructs the computer to perform a certain operation. It consists of a string of binary digits. An instruction usually consists of two parts: operation code + address code, where the operation code: indicates the type or nature of the operation to be completed by the instruction, such as fetching, adding or outputting data. The address code: indicates the content of the operation object or the address of the storage unit where it is located.
[0037] The operand buffer is an area used to cache operands, which is generally constructed from registers or SRAM (Static Random-Access Memory).
[0038] The modifier identifier is a kind of identification information. When the compiler completes instruction compilation, it will add modifier identifiers to some operand addresses in the instruction.
[0039] That is, if a modifier identifier is detected in the currently executed instruction, the operand address carrying the modifier identifier will be recorded as the target operand address, and based on the modifier identifier, it will be detected whether there is a target operand corresponding to the target operand address in the operand cache.
[0040] As an example, the currently executed instruction is instruction 1, which is in the following form:
[0041] Instruction 1: OP R1, R0.cacheable.
[0042] Among them, OP represents the operation to be performed, R0 represents the operand address to be read to perform the operation, R1 represents the address where the result of executing the instruction is written back, and cacheable is a preset modifier identifier.
[0043] When executing the current execution instruction, the execution subject determines that the operand address R0 has a preset modifier identifier cacheable, and will detect the operand cache area based on the modifier identifier carried by R0 to determine whether the operand cache area has a target operand corresponding to R0.
[0044] Step 102 , in response to determining that the operand cache has stored the target operand corresponding to the target operand address, obtain the target operand from the operand cache.
[0045] In this embodiment, after determining that the operand cache has stored the target operand corresponding to the target operand address, the target operand will be directly obtained from the operand cache, wherein the target operand address is an operand address with a modifier. Specifically, a hit / miss test can be performed on the target operand corresponding to the target operand address in the operand cache, so as to determine whether the target operand exists in the operand cache based on the test result. That is, if the test result is a hit, it means that the target operand already exists in the operand cache, and the target operand can be directly obtained from the operand cache.
[0046] Step 103 : the instruction execution unit processes the currently executed instruction based on the target operand.
[0047] In this embodiment, the SIMD system includes an instruction execution unit, which is used to parse the current execution instruction and process the instruction based on the acquired operand. The instruction execution unit will execute the instruction operation corresponding to the current execution instruction based on the target operand, such as executing the operation OP in the above example, so as to process the current execution instruction.
[0048] The instruction processing method provided by the embodiment of the present disclosure first detects the operand cache area based on the modifier identifier when determining that the operand address of the currently executed instruction has a modifier identifier; then obtains the target operand with the modifier identifier from the operand cache area when determining that the operand cache area has stored the target operand corresponding to the target operand address; finally, the instruction execution unit processes the currently executed instruction based on the target operand. The instruction processing method of the embodiment of the present disclosure is based on the repetitive characteristics of operands in multiple instructions, and caches repeated operands in the operand cache area, so that the operand can be directly obtained from the operand cache area when executing subsequent instructions, reducing the conflict caused by accessing the same resource, thereby improving the execution efficiency of instructions.
[0049] Continue to refer Figure 2 , Figure 2 A process 200 of another embodiment of an instruction processing method according to the present disclosure is shown. The instruction processing method comprises the following steps:
[0050] Step 201 , in response to the presence of a modifier tag in the operand address of the currently executed instruction, a hit / miss test is performed on the target operand address in the operand cache based on the modifier tag to obtain a test result.
[0051] In this embodiment, after determining that the operand address of the currently executed instruction has a modifier identifier, the operand address carrying the modifier identifier is recorded as the target operand address. Then, a hit / miss test is performed on the target operand address in the operand cache to obtain a corresponding test result, which includes hit and miss (i.e., miss). If the test result is hit, step 202-step 203 is executed; otherwise, step 204-step 205 is executed. Thus, the hit / miss test is used to determine whether the target operand corresponding to the target operand address has been stored in the operand cache.
[0052] When performing a hit / miss test, if it is the first test, the test result must be a miss; if it is not the first test, the test result may be a hit or a miss. Because in the case of limited hardware resources, the previously cached data may be replaced. In this case, even if it is not the first hit-miss test, the test result is not a hit (it is still a miss).
[0053] Step 202: In response to the test result being a hit, determine that the operand cache has stored the target operand.
[0054] In this embodiment, if the test result is determined to be hit, it is determined that the operand buffer has stored the target operand.
[0055] Step 203, obtaining the target operand from the operand buffer.
[0056] Step 204 , in response to the test result being a miss, the instruction execution unit reads a target operand from a target resource based on a miss flag.
[0057] In this embodiment, if the test result is miss, it means that the operand cache does not store the target operand. At this time, the operand cache will generate a miss flag and send it to the instruction execution unit. The instruction execution unit will generate a target operand read request based on the miss flag, and then read the target operand from the target resource based on the read request.
[0058] It should be noted that the target resource is a resource storing operands, which is generally constructed from SRAM.
[0059] Step 205, cache the target operand into the operand cache area.
[0060] In this embodiment, the instruction execution unit will also send the read target operand to the operand cache, and the operand cache will cache the target operand, so that the target operand can be directly obtained from the operand cache when the instruction is executed next time.
[0061] Step 206 : The instruction execution unit processes the currently executed instruction based on the target operand.
[0062] Step 206 is basically the same as step 103 in the aforementioned embodiment. For the specific implementation method, reference may be made to the aforementioned description of step 103 and will not be repeated here.
[0063] from Figure 2 It can be seen that Figure 1 Compared with the corresponding embodiment, the instruction processing method in this embodiment determines whether the operand cache has stored the target operand through a hit / miss test. If the operand cache has stored the target operand, the target operand is directly obtained; if the operand cache does not store the target operand, the instruction execution unit reads the target operand from the target resource and caches the target operand in the operand cache. Thus, the target operand is obtained from the corresponding position based on the test result, which enriches the method of obtaining the target operand and improves the execution efficiency of the instruction when the target operand is stored in the cache.
[0064] In a possible implementation, the above-mentioned instruction processing method also includes: parsing the currently executed instruction to determine the operand address to be read, wherein the operand address to be read includes the target operand address and other operand addresses not marked with modifiers; the instruction execution unit reads other operands corresponding to the other operand addresses from the target resource.
[0065] In this implementation, the currently executed instruction is parsed to determine the operand address to be read. Here, the operand address to be read includes the target operand address with a modifier mark and other operand addresses without a modifier mark.
[0066] For example, instruction 2 is: OP R5, R2.cacheable, R3, R4.
[0067] Among them, OP represents the operation to be performed, R2, R3 and R4 represent the operand addresses to be read to perform the operation, R5 represents the write-back address of the instruction execution result, and the instruction execution result is the result obtained by performing the OP operation according to the read operand address, and cacheable is a preset modifier identifier.
[0068] By parsing instruction 2, it can be determined that the operand addresses to be read include R2, R3 and R4, wherein R2 is the target operand address with a modifier, and R3 and R4 are other operand addresses without a modifier.
[0069] Regardless of whether the operand buffer has stored the target operand, the other operand addresses without modifiers in the currently executed instruction are other operands read from the target resource by the instruction execution unit. Therefore, the currently executed instruction is parsed to determine the other operand addresses without modifiers so that the instruction execution unit can read the other operands from the target resource.
[0070] In a possible implementation, the instruction execution unit processes the currently executed instruction based on the target operand, including: the instruction execution unit processes the currently executed instruction based on the target operand and other operands.
[0071] As shown in the above-mentioned example instruction 2, after reading the other operands corresponding to R3 and R4, the instruction execution unit will execute operation OP based on the target operand corresponding to R2 and the other operands corresponding to R3 and R4 that have been obtained, and write the execution result back to R5, thereby realizing the processing of the currently executed instruction.
[0072] In a possible implementation, the target resource includes a vector resource for storing vector operands and / or a scalar resource for storing scalar operands; the operand cache includes a vector cache for caching vector operands and / or a scalar cache for caching scalar operands.
[0073] For the instruction set of the processor of SIMT (Single Instruction Multiple Threads) / SIMD architecture, the operands are generally divided into vector operands and / or scalar operands. Accordingly, the target resources may include vector resources for storing vector operands and / or scalar resources for storing scalar operands. Accordingly, the operand cache may include a vector cache for caching vector operands and / or a scalar cache for caching scalar operands.
[0074] That is, if the operand to be read is a vector operand, the operand to be read is read from the vector resource; if the operand to be read is a scalar operand, the operand to be read is read from the scalar resource. If the operand to be cached is a vector operand, it is cached in the vector cache area; if the operand to be cached is a scalar operand, it is cached in the scalar cache area. By dividing the resources and cache areas into blocks based on the type of operands, the data reading efficiency is improved, and then the execution efficiency of instructions is improved.
[0075] In a possible implementation, in response to determining that the modifier is a release modifier and the instruction execution unit has obtained the target operand from the operand cache, cache resources occupied by the target operand in the operand cache are released.
[0076] In this embodiment, the modifier identifier may include a cacheable modifier (cacheable) and a release modifier (release). If it is detected that the modifier identifier carried by the target operand address is release, and the instruction execution unit has obtained the target operand from the operand cache area, the cache resources occupied by the target operand in the operand cache area will be released. That is, the identification information valid of the target operand is updated to invalid, thereby releasing the cache resources occupied by the target operand in the cache area.
[0077] For example, instruction 1: OP R3, R0.cacheable, R1, R2;
[0078] Instruction 2: OP R6, R0.cacheable, R4, R5;
[0079] Instruction 3: OP R9, R0.release, R7, R8.
[0080] Among them, OP represents the operation to be executed, R1, R2, R4, R5, R7 and R8 represent the operand addresses to be read to perform the operation, R3, R6 and R9 represent the write-back addresses of the instruction execution results, and the instruction execution result is the result obtained by performing the OP operation according to the read operand address, cacheable is the cacheable modifier identifier, and release is the release modifier identifier.
[0081] During the instruction execution process, the execution subject determines that the modifier of R0 in instruction 3 is release and the instruction execution unit has obtained the target operand corresponding to R0 from the operand cache. It will update the identification information of the target operand corresponding to R0 to invalid to release the cache resources occupied by it in the operand cache.
[0082] Continue to refer Figure 3 , Figure 3 A process 300 of another embodiment of an instruction processing method according to the present disclosure is shown. The instruction processing method comprises the following steps:
[0083] Step 301, compile the source program to obtain a compiled instruction set.
[0084] In this embodiment, the compiler compiles the source program written by the user to obtain a compiled instruction set, and the compiled instruction set includes multiple instructions.
[0085] Step 302: Determine instructions for reading the same operand address from the instruction set to obtain a target instruction set.
[0086] In this embodiment, instructions in the instruction set are identified to determine instructions for reading the same operand address, where the same operand address is an operand address simultaneously included in at least two instructions.
[0087] For example, the instruction set is: Instruction 1: OP R3, R0, R1, R2;
[0088] Instruction 2: OP R7, R4, R5, R6;
[0089] Instruction 3: OP R10, R0, R8, R9;
[0090] Instruction 4: OP R13, R0, R11, R12.
[0091] It can be seen that instruction 1, instruction 3 and instruction 4 in the instruction set will all read R0, that is, R0 is the same operand address, so the obtained target instruction set includes instruction 1, instruction 3 and instruction 4.
[0092] Step 303: Add a modifier identifier to the same operand address in each target instruction.
[0093] In this embodiment, a modifier identifier is added to the same operand address in each target instruction in the target instruction set, and the modifier identifier is a kind of identification information. As an example, a modifier identifier is added to R0 in instruction 1, instruction 3 and instruction 4 in the target instruction set, thereby obtaining instructions to be executed with modifier identifiers, so that the operand cache and / or the instruction execution unit obtain the corresponding operand based on the modifier identifier in the instruction and execute the instruction.
[0094] In a possible implementation, the modifier identifier includes a cacheable modifier and a release modifier. The cacheable modifier indicates that the instruction is not the last instruction in the target instruction set to read the same operand address; the release modifier indicates that the instruction is the last instruction in the target instruction set to read the same operand address.
[0095] In a possible implementation, step 303 further includes: setting the modifier flag of the same operand address in the last instruction read in the target instruction set to a release modifier; setting the modifier flag of the same operand address in other instructions in the target instruction set to a cacheable modifier.
[0096] For example, in the above example, the target instruction set includes instruction 1, instruction 3, and instruction 4, and instruction 4 is the last instruction in the target instruction set to read R0, so the modifier flag of R0 in instruction 4 is set to release. At the same time, the modifier flag of R0 in instruction 1 and instruction 3 in the target instruction set is set to cacheable.
[0097] In addition, it should be noted that the compilation module needs to be combined with limited hardware resources and the modifier identifiers should be used reasonably to avoid waste of resources caused by frequent replacement.
[0098] from Figure 3 It can be seen that Figure 1 Compared with the corresponding embodiments, the instruction processing method in this embodiment determines the operand addresses that need to be read repeatedly during the compilation stage, and obtains the corresponding operands from different locations during the instruction execution stage by adding modifier identifiers thereto, thereby improving the instruction execution efficiency.
[0099] Further references Figure 4 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of an instruction processing device, and the device embodiment is Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0100] like Figure 4 As shown, the instruction processing device 400 of this embodiment includes: a detection module 401, an acquisition module 402 and an instruction execution module 403. The detection module 401 is configured to detect the operand cache area in response to the presence of a modifier mark in the operand address of the currently executed instruction, based on the modifier mark. The acquisition module 402 is configured to acquire the target operand from the operand cache area in response to determining that the operand cache area has stored the target operand corresponding to the target operand address, and the target operand address is an operand address with a modifier mark. The instruction execution module 403 is configured to process the currently executed instruction based on the target operand.
[0101] In this embodiment, in the instruction processing device 400, the specific processing of the detection module 401, the acquisition module 402 and the instruction execution module 403 and the technical effects thereof can be referred to in Figure 1 The relevant descriptions of steps 101 - 103 in the corresponding embodiment are not repeated here.
[0102] Further references Figure 5 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of an instruction processor. Figure 5As shown, the instruction processor 500 of this embodiment includes: a scheduling interface 501 , a cache unit 502 and an instruction execution unit 503 .
[0103] The scheduling interface 501 is used to determine the currently executed instruction. The cache unit 502 is used to determine whether to store the target operand corresponding to the target operand address, and in response to determining that the target operand has been stored, send the target operand, wherein the target operand address is the operand address with a modifier in the currently executed instruction. The instruction execution unit 503 is used to process the currently executed instruction based on the target operand.
[0104] The scheduling interface 501 determines the currently executing instruction from the target instruction set (i.e., the instruction set to be executed), and the cache unit 502 determines whether there is a target operand corresponding to the operand address (target operand address) marked with a modifier in the currently executing instruction. If it is determined that the target operand exists, the target operand is directly obtained and sent to the instruction execution unit 503. The instruction execution unit 503 processes the currently executing instruction based on the target operand.
[0105] Further references Figure 6 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of an instruction processing system. Figure 6 As shown, the instruction processing system 600 of this embodiment includes: a compiling module 601 and an instruction processor 602. The compiling module 601 is used to compile the source program, add modifiers to the same operand addresses in the compiled instruction set, and send the instructions with the modifiers to the instruction processor 602.
[0106] The instruction processor 602 includes: a scheduling interface 6021 , a cache unit 6022 , and an instruction execution unit 6023 .
[0107] The scheduling interface 6021 is used to determine the currently executed instruction from the instructions with the modifier identification. The cache unit 6022 is used to determine whether to store the target operand corresponding to the operand address (target operand address) with the modifier identification in the currently executed instruction, and send the target operand in response to determining that the target operand has been stored. The instruction execution unit 6023 is used to process the currently executed instruction based on the target operand.
[0108] The compiling module 601 compiles the source program written by the user to obtain a compiled instruction set, which includes multiple instructions. Then, the instruction that reads the same operand address is determined from the instruction set to obtain a target instruction set. A preset modifier mark is added to the same operand address in each target instruction, and the target instruction set with the modifier mark is sent to the instruction processor 602.
[0109] The scheduling interface 6021 in the instruction processor 602 determines the currently executing instruction from the target instruction set (i.e., the instruction set to be executed), and the cache unit 6022 determines whether there is a target operand corresponding to the operand address (target operand address) marked with a modifier in the currently executing instruction. If it is determined that the target operand exists, the target operand is directly obtained and sent to the instruction execution unit 6023. The instruction execution unit 6023 processes the currently executing instruction based on the target operand.
[0110] Continue to refer Figure 7 , which shows an application scenario of the instruction processing system according to the present disclosure, in which a scheduling interface (Scheduler) 701 obtains an executable instruction, i.e., a currently executed instruction, from a set of instructions to be executed. A dispatch port (Dispatch Port) 702 transmits the operand address with a modifier in the currently executed instruction to an operand cache (operand cache) 703, and sends the currently executed instruction to an execution unit (PIPE) 704.
[0111] For example, the instruction set to be executed includes the following four instructions:
[0112] Instruction 1: OP R3, R0.cacheable, R1, R2;
[0113] Instruction 2: OP R6, R0.cacheable, R4, R5;
[0114] Instruction 3: OP R9, R0.cacheable, R7, R8;
[0115] Instruction 4: OP R12, R0.release, R10, R11;
[0116] Among them, OP represents the operation to be executed, R0, R1, R2, R4, R5, R7, R8, R10, and R11 represent the operand addresses to be read for the operation, and R3, R6, R9, and R12 represent the write-back addresses of the instruction execution results. The instruction execution result is the result obtained after executing the OP operation according to the read operand address.
[0117] The transmission port 702 will first send R0 in instruction 1 to the operand cache 703, and at the same time send instruction 1 to the execution unit 0 (the execution unit 704 may include multiple, that is, it may include execution unit 0, execution unit 1, execution unit 2, execution unit 3, etc.), and then the operand cache 703 will perform a hit-miss test on the operand corresponding to R0. Since R0 is read for the first time, the test result is miss, and the miss flag is sent to the execution unit 0. The operand controller 705 will parse instruction 1 and the miss flag to generate an operand read request for R0, R1, and R2, and read the operand from the target resource (including a vector resource for storing vector operands or a scalar resource for storing scalar operands) 706 based on the read request, and return the read operand to the corresponding execution unit 0, so as to return the operand corresponding to R0 to the operand cache 703 so that the operand cache 703 can cache it. Accordingly, the operand buffer 703 also includes vector resources for storing vector operands and scalar resources for storing scalar operands.
[0118] When instruction 2 is issued, R0 is sent to the operand cache 703 for a hit-miss test. At this time, the test result is hit, and the hit flag and hit data (the operand corresponding to R0) are sent to execution unit 1 (it can also be any other execution unit). Execution unit 1 no longer generates an operand read request corresponding to R0 based on the hit flag, but directly uses the hit data. Similarly, when instruction 4 is executed, the R0 operand is sent to the operand cache 703 for a hit-miss test. At this time, it is a hit, and the hit flag and hit data are sent to the corresponding execution unit 704. At the same time, since R0 carries the release modifier, the resources occupied by the data in the operand cache are released.
[0119] As the number of requests for accessing resources is reduced, conflicts over resource access are reduced, and the time the execution unit waits for arbitration rights is reduced, each execution unit can obtain operand data more quickly, thereby improving instruction execution efficiency.
[0120] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.
[0121] Figure 8A schematic block diagram of an example electronic device 800 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0122] like Figure 8 As shown, the device 800 includes a computing unit 801, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 802 or a computer program loaded from a storage unit 808 to a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the device 800 can also be stored. The computing unit 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0123] A number of components in the device 800 are connected to the I / O interface 805, including: an input unit 806, such as a keyboard, a mouse, etc.; an output unit 807, such as various types of displays, speakers, etc.; a storage unit 808, such as a disk, an optical disk, etc.; and a communication unit 809, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 809 allows the device 800 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0124] The computing unit 801 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 801 performs the various methods and processes described above, such as the instruction processing method. For example, in some embodiments, the instruction processing method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 808. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 800 via the ROM 802 and / or the communication unit 809. When the computer program is loaded into the RAM 803 and executed by the computing unit 801, one or more steps of the instruction processing method described above may be performed. Alternatively, in other embodiments, the computing unit 801 may be configured to execute the instruction processing method in any other appropriate manner (e.g., by means of firmware).
[0125] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0126] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0127] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0128] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0129] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0130] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0131] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. An instruction processing method, applied to a SIMD system, characterized in that: The SIMD system includes an instruction execution unit, and the method includes: In response to the presence of a modifier identifier in an operand address of a currently executed instruction, detecting an operand cache area based on the modifier identifier; In response to determining that the operand cache has stored a target operand corresponding to a target operand address, the target operand is obtained from the operand cache, wherein the target operand address is an operand address with a modifier identifier, the modifier identifier includes a cacheable modifier and a release modifier, the release modifier is a modifier identifier carried by the same operand address in the instruction that is last read in the target instruction set, the cacheable modifier is a modifier identifier carried by the same operand address in other instructions in the target instruction set, and the target instruction set is a set of instructions that read the same operand address in an instruction set obtained by compiling a source program; The instruction execution unit processes the currently executed instruction based on the target operand.
2. The method according to claim 1, characterized in that The detection operand buffer area includes: Performing a hit / miss test on the target operand address in the operand cache area to obtain a test result; In response to the test result being a hit, it is determined that the operand cache has stored the target operand.
3. The method according to claim 2, characterized in that The method further comprises: In response to the test result being a miss, the instruction execution unit reads the target operand from the target resource based on a miss flag; The target operand is cached in the operand cache area.
4. The method according to claim 1, characterized in that The method further comprises: Parsing the currently executed instruction to determine the operand address to be read, wherein the operand address to be read includes the target operand address and other operand addresses without modifier identification; The instruction execution unit reads other operands corresponding to the other operand addresses from the target resource.
5. The method according to claim 4, characterized in that The instruction execution unit processes the currently executed instruction based on the target operand, including: The instruction execution unit processes the currently executing instruction based on the target operand and the other operands.
6. The method according to claim 3 or 4, characterized in that: The target resource includes a vector resource for storing a vector operand and / or a scalar resource for storing a scalar operand; The operand cache includes a vector cache for caching the vector operands and / or a scalar cache for caching the scalar operands.
7. The method according to claim 1, characterized in that The method further comprises: In response to determining that the modifier identifier is a release modifier and the instruction execution unit has obtained the target operand from the operand cache, cache resources occupied by the target operand in the operand cache are released.
8. The method according to claim 1, characterized in that The modifier identifier is added by following the steps below: Compile the source program to obtain a compiled instruction set; Determine instructions for reading the same operand address from the instruction set to obtain a target instruction set; The modifier identifier is added to the same operand address in each target instruction.
9. The method according to claim 8, characterized in that The adding the modifier identifier to the same operand address in each target instruction includes: Setting the modifier identifier of the same operand address in the last instruction read in the target instruction set to the release modifier; The modifier identifier of the same operand address in other instructions in the target instruction set is set to the cacheable modifier.
10. An instruction processing device, characterized in that: The device comprises: A detection module configured to detect an operand cache area in response to the presence of a modifier identifier in an operand address of a currently executed instruction and based on the modifier identifier; an acquisition module, configured to acquire the target operand from the operand cache in response to determining that the operand cache has stored a target operand corresponding to the target operand address, wherein the target operand address is an operand address with a modifier identifier, the modifier identifier includes a cacheable modifier and a release modifier, the release modifier is a modifier identifier carried by the same operand address in the last instruction read in the target instruction set, the cacheable modifier is a modifier identifier carried by the same operand address in other instructions in the target instruction set, and the target instruction set is a set of instructions that read the same operand address in an instruction set obtained by compiling a source program; The instruction execution module is configured to process the currently executed instruction based on the target operand.
11. An instruction processor, characterized in that: The instruction processor comprises: The scheduling interface is used to determine the currently executing instruction; a cache unit, used to determine whether to store a target operand corresponding to a target operand address, and in response to determining that the target operand has been stored, send the target operand, wherein the target operand address is an operand address with a modifier identifier in the currently executed instruction, the modifier identifier includes a cacheable modifier and a release modifier, the release modifier is a modifier identifier carried by the same operand address in the instruction that was last read in the target instruction set, the cacheable modifier is a modifier identifier carried by the same operand address in other instructions in the target instruction set, and the target instruction set is a set of instructions that read the same operand address in an instruction set obtained by compiling a source program; An instruction execution unit is used to process the currently executed instruction based on the target operand.
12. An instruction processing system, characterized in that: The system comprises: A compiling module, used for compiling a source program, adding a modifier identifier to the same operand address in the compiled instruction set, and sending the instruction with the modifier identifier; Instruction processor, including: A scheduling interface, used to determine the currently executed instruction from the instructions with the modifier identifier; a cache unit, used to determine whether to store a target operand corresponding to a target operand address, and in response to determining that the target operand has been stored, send the target operand, wherein the target operand address is an operand address with the modifier identifier in the currently executed instruction, the modifier identifier includes a cacheable modifier and a release modifier, the release modifier is a modifier identifier carried by the same operand address in the instruction that was last read in the target instruction set, the cacheable modifier is a modifier identifier carried by the same operand address in other instructions in the target instruction set, and the target instruction set is a set of instructions that read the same operand address in an instruction set obtained by compiling a source program; An instruction execution unit is used to process the currently executed instruction based on the target operand.
13. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 9.
14. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to make a computer execute the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Program compiling method and compiler
CN106406972A
Instruction-assisted cache management for efficient use of cache and memory
CN1991792A
