WO2023142524A1 - Instruction processing method and apparatus, chip, electronic device, and storage medium - Google Patents

Instruction processing method and apparatus, chip, electronic device, and storage medium Download PDF

Info

Publication number
WO2023142524A1
WO2023142524A1 PCT/CN2022/124520 CN2022124520W WO2023142524A1 WO 2023142524 A1 WO2023142524 A1 WO 2023142524A1 CN 2022124520 W CN2022124520 W CN 2022124520W WO 2023142524 A1 WO2023142524 A1 WO 2023142524A1
Authority
WO
WIPO (PCT)
Prior art keywords
instruction
calculation
address
address information
information
Prior art date
Application number
PCT/CN2022/124520
Other languages
French (fr)
Chinese (zh)
Inventor
王文强
霍冠廷
孙海涛
夏晓旭
徐宁仪
Original Assignee
上海商汤智能科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 上海商汤智能科技有限公司 filed Critical 上海商汤智能科技有限公司
Publication of WO2023142524A1 publication Critical patent/WO2023142524A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30098Register arrangements
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30145Instruction analysis, e.g. decoding, instruction word fields
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/32Address formation of the next instruction, e.g. by incrementing the instruction counter

Definitions

  • the present disclosure relates to the field of electronic technology, and in particular, to an instruction processing method, device, chip, electronic equipment, and computer-readable storage medium.
  • the working process of a computer involves the execution of computer instructions arranged in a certain order.
  • Computer instructions are instructions and commands to direct and coordinate the work of various components of the computer.
  • the execution of instructions mainly includes access to storage space and calculation of data, wherein the form of storage space access includes immediate direct addressing and indirect addressing using operation results.
  • the indirect addressing mode needs to calculate the value of the address in real time. Therefore, the indirect addressing mode brings extra instruction cycles, thereby affecting the execution efficiency of the instruction.
  • Embodiments of the present disclosure at least provide an instruction processing method, device, chip, electronic device, and computer-readable storage medium.
  • an embodiment of the present disclosure provides an instruction processing device, including: an instruction processing unit configured to obtain a first calculation instruction to be processed; an instruction execution unit configured to obtain an accumulated calculation instruction based on the first calculation instruction step size information, and obtain the second address information of the second access data corresponding to the second calculation instruction; wherein, the second calculation instruction is the previous instruction of the first calculation instruction; based on the second address information and the accumulative step information, determine the first address information of the first access data corresponding to the first calculation instruction, and execute the first calculation instruction based on the first address information, wherein the first An operand included in the fetched data and/or a calculation result of the operand.
  • the instruction execution unit may acquire the accumulative step size information based on the first calculation instruction, and acquire the first value of the second access data corresponding to the second calculation instruction. second address information, and then determine the first address information based on the second address information and the accumulation step information, and execute the first calculation instruction based on the first address information.
  • the address calculation can be hidden in the instruction processing process of the calculation instruction, so that the extra instruction cycle can be reduced, and the execution efficiency of the instruction can be accelerated.
  • the instruction processing unit is configured to, after acquiring the first computing instruction to be processed, determine the first Addressing mode of address information; the instruction execution unit is configured to, when the addressing mode is an address accumulation mode, obtain the accumulation step information based on the first calculation instruction, and obtain the second calculation second address information of the second access data corresponding to the instruction; and based on the second address information and the accumulation step information, determine the first address information, and execute the first address information based on the first address information A first calculation instruction.
  • the first address information of the first access data of the first calculation instruction can be determined through the address accumulation mode, and the determination process of the first address information can be hidden in the first An instruction processing process for computing instructions, thereby reducing additional instruction cycles, thereby speeding up the execution efficiency of instructions.
  • the instruction execution unit includes: an accumulation register configured to store the second address information; a first calculation unit configured to obtain the After the accumulative step information, perform accumulative calculation on the second address information and the accumulative step information to obtain the first address information.
  • the first address information includes a first access address and a first storage address
  • the instruction execution unit further includes a second computing unit configured to: obtain the first computing unit Send the first access address and the first storage address, and obtain the operand stored in the storage location corresponding to the first access address; and obtain the operand stored in the storage location corresponding to the first access address Executing the first computing instruction with the obtained operand as the first memory access data, obtaining a first computing result of the first computing instruction, and storing the first computing result in the first storage address corresponding storage location.
  • the instruction processing unit is further configured to: if the addressing mode is a direct addressing mode, obtain the field content in the address field in the first calculation instruction ; Determine the first address information of the first memory access data based on the obtained field content, and send the first address information to the instruction execution unit, so that the instruction execution unit based on the first The address information executes the first calculation instruction.
  • the instruction processing unit includes an instruction decoding unit configured to determine a first enable flag in the first calculation instruction, where the first enable flag is used for Indicating whether the address accumulation mode for the first memory access data is enabled and valid; and determining the addressing of the first address information of the first memory access data corresponding to the first calculation instruction based on the first enable flag model.
  • the first enabling flag includes a plurality of first sub-enabling flags, and each of the first sub-enabling flags corresponds to one data in the first access data;
  • the instruction decoding unit is configured to: determine a first sub-enablement flag that matches each data in the first memory access data among the plurality of first sub-enablement flags; The first sub-enabling flag that matches each data in the first memory access data, and determine the addressing mode of the first address information of each data in the first memory access data corresponding to the first calculation instruction .
  • the instruction decoding unit is configured to: after determining that the first enable flag indicates that address accumulation mode enable is valid, detect the second enable in the second calculation instruction An enable flag; wherein, the second enable flag is used to indicate whether the address accumulation mode indicated by the first enable flag in the first calculation instruction is enabled and valid; and determining the The first address information of the first access data corresponding to the first calculation instruction.
  • the instruction decoding unit is configured to: when determining that the second enabling flag is address accumulation mode enable and disable, determine the The first address information of the first access data is the second address information of the second access data corresponding to the second calculation instruction.
  • the second enabling flag includes a plurality of second sub-enabling flags, and each of the second sub-enabling flags corresponds to one data in the first access data;
  • the instruction decoding unit is configured to: determine a second sub-enablement flag that matches each data in the first memory access data among the plurality of second sub-enablement flags;
  • the second sub-enabling identifier that matches each data in the first access data, and determine the first address information of each data in the first access data.
  • the instruction content of the first calculation instruction includes at least one continuous first enable flag and/or at least one continuous second enable flag, wherein each of the first The enabling identifier includes a first identifying field and/or first field content, each of the second enabling identifiers includes a second identifying field and/or second field content, and the first identifying field is used to indicate that the first An addressing mode of a calculation instruction, the content of the first field is used to indicate the accumulation step information or the first address information, and the second identification field is used to indicate the next calculation of the first calculation instruction The addressing mode of the instruction, the content of the second field is used to indicate the accumulation step size information or the first address information corresponding to the execution of the next calculation instruction.
  • the instruction processing device further includes: a register file, configured to store at least one of the accumulation step information, the first memory access data, and the first address information.
  • the instruction execution unit includes: an instruction decoding unit configured to decode the instruction content of the first computing instruction to obtain a decoding result; an instruction issuing unit configured to An instruction for acquiring the accumulation step information is sent to the register file based on the decoding result; wherein, the instruction execution unit is configured to determine the accumulated step information based on the second address information and the accumulation step information The first address information of the first access data.
  • the register file includes a vector register file and a scalar register file, wherein the vector register file is used to store the first memory access data of the first computing instruction, and the scalar register The stack is used to store the accumulation step information and/or the first address information.
  • an embodiment of the present disclosure provides an instruction processing method, including: obtaining a first computing instruction to be processed; determining the addressing of the first address information of the first access data corresponding to the first computing instruction Mode; wherein, the first memory access data includes the operand and/or the calculation result of the operand used to execute the first calculation instruction; in the case where the addressing mode is an address accumulation mode, based on the The first calculation instruction obtains the cumulative step size information, and obtains the second address information of the second access data corresponding to the second calculation instruction; wherein, the second calculation instruction is a previous instruction of the first calculation instruction; The first address information is determined based on the second address information and the accumulation step information, and the first calculation instruction is executed based on the first address information.
  • an embodiment of the present disclosure provides an instruction processing device, including: a first acquiring unit, configured to acquire a first computing instruction to be processed; a determining unit, configured to determine a first computing instruction corresponding to the first computing instruction An addressing mode of the first address information of the access data; wherein, the first access data includes the operand and/or the calculation result of the operand used to execute the first calculation instruction; the second acquisition unit, It is used to obtain the accumulation step size information based on the first calculation instruction when the addressing mode is the address accumulation mode, and obtain the second address information of the second memory access data corresponding to the second calculation instruction; wherein , the second calculation instruction is the previous instruction of the first calculation instruction; the instruction execution unit is configured to determine the first address information based on the second address information and the accumulation step information, and based on The first address information executes the first calculation instruction.
  • an embodiment of the present disclosure further provides a chip, including the instruction processing device described in any one of the above first aspects.
  • an embodiment of the present disclosure further provides an electronic device, including a processor, a memory, and a bus, the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the The processor communicates with the memory through the bus, and when the machine-readable instructions are executed by the processor, the steps of the instruction processing method described in any one of the above-mentioned second aspects are implemented.
  • an embodiment of the present disclosure further provides an electronic device, including the chip described in the fourth aspect.
  • the embodiments of the present disclosure further provide a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is run by a processor, it executes any one of the above-mentioned second aspects. Steps of the instruction processing method described above.
  • FIG. 1 shows a flowchart of an instruction processing method provided by an embodiment of the present disclosure
  • Fig. 2 shows a flow chart of a specific method for determining the addressing mode of the first address information of the first access data corresponding to the first calculation instruction in the instruction processing method provided by the embodiment of the present disclosure
  • FIG. 3 shows a flowchart of another instruction processing method provided by an embodiment of the present disclosure
  • FIG. 4 shows a schematic structural diagram of a first instruction processing device provided by an embodiment of the present disclosure
  • FIG. 5 shows a schematic structural diagram of a second instruction processing device provided by an embodiment of the present disclosure
  • FIG. 6 shows a schematic structural diagram of a third instruction processing device provided by an embodiment of the present disclosure
  • Fig. 7 shows a schematic diagram of the instruction processing flow of the first instruction processing device provided by the embodiment of the present disclosure
  • FIG. 8 shows a schematic diagram of an instruction processing flow of a second instruction processing apparatus provided by an embodiment of the present disclosure
  • FIG. 9 shows a schematic diagram of an instruction processing device provided by an embodiment of the present disclosure.
  • Fig. 10 shows a schematic diagram of an electronic device provided by an embodiment of the present disclosure.
  • a and/or B may mean that A exists alone, A and B exist simultaneously, and B exists alone.
  • at least one herein means any one of a variety or any combination of at least two of the more, for example, including at least one of A, B, and C, which may mean including from A, Any one or more elements selected from the set formed by B and C.
  • the execution of computer instructions mainly includes access to storage space and calculation of data, wherein the form of storage space access includes direct addressing of immediate data and indirect addressing using operation results.
  • the indirect addressing mode needs to calculate the value of the address in real time. Therefore, the indirect addressing mode brings extra instruction cycles, thereby affecting the execution efficiency of the instruction.
  • the present disclosure provides an instruction processing method.
  • the addressing mode of the first address information of the first access data corresponding to the first calculation instruction may be determined.
  • the accumulation step information can be obtained based on the first calculation instruction, and the second address information of the second access data corresponding to the second calculation instruction can be obtained, and then based on the second address information and accumulation step information determine first address information, and execute the first calculation instruction based on the first address information.
  • the first address information of the first access data of the first calculation instruction is determined through the address accumulation mode, and the determination process of the first address information can be hidden in the first
  • the instruction processing process of the calculation instruction reduces the extra instruction cycle, thereby speeding up the execution efficiency of the instruction.
  • the execution subject of the instruction processing method provided by the embodiments of the present disclosure is generally an electronic device with a certain computing capability.
  • FIG. 1 is a flowchart of an instruction processing method provided by an embodiment of the present disclosure, the method includes steps S101 to S107.
  • S101 Acquire a first computing instruction to be processed.
  • the first calculation instruction to be processed may be obtained from the instruction register.
  • the first calculation instruction may be any type of calculation instruction, for example, a multiply-accumulate instruction macc, which is not specifically limited in the present disclosure.
  • S103 Determine the addressing mode of the first address information of the first memory access data corresponding to the first calculation instruction; wherein the first memory access data includes an operand and an operand used to execute the first calculation instruction /or the result of the computation of the operand.
  • the addressing mode includes an address accumulation mode and a direct addressing mode.
  • the address accumulation mode can be understood as determining the first address information (access address information and/or storage address information) of the first memory access data in the storage device according to a preset accumulation algorithm during instruction execution.
  • the direct addressing mode can be understood as obtaining the first address information (access address information and/or storage address information) of the first access data in the storage device based on the address field in the first calculation instruction during the execution of the instruction.
  • the storage device may be a memory and a register file in an internal storage device of the instruction processing device, or may be an external storage device of the instruction processing device.
  • the addressing mode of the first address information of the first access data may be determined based on the instruction content of the first calculation instruction. During specific implementation, it may be determined based on the specified data bit in the first computing instruction whether the addressing mode of the first address information of the first access data is an address accumulation mode or a direct addressing mode.
  • S105 If the addressing mode is an address accumulation mode, obtain accumulation step information based on the first calculation instruction, and obtain second address information of the second memory access data corresponding to the second calculation instruction; wherein , the second calculation instruction is a previous instruction of the first calculation instruction.
  • the second calculation instruction is a previous instruction executed immediately before the first calculation instruction.
  • the second address information is address information (access address information and/or storage address information) of the second memory access data corresponding to the second calculation instruction in the storage device of the instruction processing device.
  • the second memory access data includes an operand (operand) for executing the second calculation instruction and/or a calculation result of the operand.
  • the "operand" in this article refers to the entity that the operator acts on, which specifies the processing object of the instruction to be processed.
  • the instruction to be processed is a comparison instruction, in which the operator specifies the computer to perform a comparison operation, and the operand specifies two values to be compared.
  • S107 Determine the first address information based on the second address information and the accumulation step information, and execute the first calculation instruction based on the first address information.
  • an accumulation calculation may be performed on the second address information and the accumulation step information to obtain the first address information.
  • macc is a multiply-accumulate instruction.
  • the addressing mode of the first address information of the first access data corresponding to the first calculation instruction may be determined.
  • the accumulation step information can be obtained based on the first calculation instruction, and the second address information of the second access data corresponding to the second calculation instruction can be obtained, and then based on the second address information and accumulation step information determine first address information, and execute the first calculation instruction based on the first address information.
  • the first address information of the first access data of the first calculation instruction is determined through the address accumulation mode, and the determination process of the first address information can be hidden in the first
  • the instruction processing process of the calculation instruction reduces the extra instruction cycle, thereby speeding up the execution efficiency of the instruction.
  • the first calculation instruction to be processed is obtained from the instruction register, and then the addressing mode of the first address information of the first memory access data corresponding to the first calculation instruction is determined.
  • step S103 determining the addressing mode of the first address information of the first memory access data corresponding to the first computing instruction, specifically includes the following steps:
  • S1031 Determine a first enable flag in the first calculation instruction, where the first enable flag is used to indicate whether the address accumulation mode for the first memory access data is enabled and valid;
  • S1032 Determine an addressing mode of the first address information of the first memory access data corresponding to the first computing instruction based on the first enabling flag.
  • a specified data bit including the first enable flag may be determined in each data bit of the first calculation instruction, and the value of the specified data bit is determined as the first enable flag.
  • the first enabling flag when the first enabling flag is the first numerical value, it can be determined that the address accumulation mode of the first memory access data is enabled; when the first enabling flag is the second numerical value, it can be determined that the first 1.
  • the address accumulation mode of accessing data is enabled and disabled.
  • the first value and the second value may be set according to actual needs, which is not specifically limited in the present disclosure.
  • the first value can be set to "1", indicating that the address accumulation mode of the first memory access data is enabled; the second value can be set to "0", indicating that the address accumulation mode of the first memory access data is enabled and disabled.
  • the first enabling flag corresponds to a specified data bit as an example for illustration, however, in the case where the first enabling flag includes multiple first sub-enabling flags (wherein, each sub-enabling flag corresponds to One data of the first access data), the first enable flag may correspond to multiple specified data bits, which will be described in subsequent embodiments.
  • the value of the designated data bit in the first calculation instruction may be obtained, and then the first enabling flag is determined according to the value of the designated data bit. After the first enabling flag is acquired, it may be determined based on the first enabling flag whether the address accumulation mode for the first memory access data is enabled and valid.
  • the addressing mode for the first address information of the first memory access data is the address accumulation mode; when it is determined that the address accumulation mode is enabled and disabled, it can be determined that The addressing mode for the first address information of the first access data is a non-address accumulation mode (for example, a direct addressing mode).
  • the first address information of the first access data (that is, the above-mentioned first address information) can be determined based on the addressing mode, the following cases Make an introduction.
  • Case 1 The addressing mode is the address accumulation mode.
  • the accumulation step size information may be acquired based on the instruction content of the first calculation instruction.
  • the accumulative step size information can be obtained in the register file or in the instruction code based on the instruction content of the first calculation instruction, and the two methods will be introduced respectively below.
  • Method 1 The method based on the register file.
  • the instruction content of the first calculation instruction includes an index identifier of a register in the register file storing the accumulation step information.
  • the data in the corresponding register may be read based on the index identifier, and the read data may be determined as the accumulative step size information.
  • Method 2 A method based on instruction encoding.
  • the instruction content of the first calculation instruction includes accumulation step size information.
  • the accumulative step size information can be directly determined according to the instruction content of the first calculation instruction.
  • the second address information of the operand used in the execution of the second calculation instruction can be obtained, and based on the second address information and the The accumulation step information is used to determine first address information, and then the first calculation instruction is executed based on the first address information.
  • Case 2 The addressing mode is direct addressing mode.
  • the addressing mode is the direct addressing mode
  • obtaining the field content in the address field in the first computing instruction and determining the first access data of the first memory based on the obtained field content 1. Address information.
  • the addressing mode is the direct addressing mode
  • the first address information of the first fetched data that is, the above-mentioned first address information
  • the first address information of the first memory access data can be obtained in the register file or in the instruction code based on the field content of the address field in the first computing instruction, and the two methods will be introduced respectively below.
  • Method 1 The method based on the register file.
  • the field content of the address field in the first computing instruction includes the index identifier of the register storing the first address information in the register file.
  • the first address information in the corresponding register can be read based on the index identifier.
  • Method 2 A method based on instruction encoding.
  • the field content of the address field in the first calculation instruction includes the first address information of the first memory access data.
  • the first address information of the first fetched data can be determined directly according to the field content of the address field in the first calculation instruction.
  • the first calculation instruction may be executed based on the first address information.
  • addr1/dlt1 and addr2/dlt2 are the instruction contents used to determine the access information (for example, the access address of the operand) of the operand in the first memory access data
  • addr3/dlt3 are used to determine the first memory access data.
  • the instruction content of the storage information of the calculation result (for example, the storage address of the calculation result).
  • the addressing mode is the address accumulation mode
  • the enable flag is enabled and valid
  • a1, b1, and c1 may be accumulation step information, and may also be expressed as index identifiers of registers storing the accumulation step information in the register file.
  • the addressing mode is the direct addressing mode
  • the first enabling flag includes a plurality of first sub-enabling flags; each of the first sub-enabling flags corresponds to one data in the first access data.
  • addr1/dlt1, addr2/dlt2 and addr3/dlt3 are the above-mentioned multiple first sub-enabling identifiers, wherein the first sub-enabling identifier addr1/dlt1 is used to indicate the addressing mode of the access address of operand 1, and the first sub-enabling identifier
  • the enable flag addr2/dlt2 is used to indicate the addressing mode of the access address of operand 2
  • the first sub-enable flag addr3/dlt3 is used to indicate the addressing mode of the storage address of the calculation result of the operand of the first calculation instruction.
  • step S1032: determining the addressing mode of the first address information of the first access data corresponding to the first calculation instruction based on the first enabling flag includes the following steps:
  • first enablement flag may include a plurality of first sub-enablement flags, and each first sub-enablement flag is used to indicate the first address information of each data in the first access data. address mode.
  • each data in the first fetch data can be understood as each operand used to execute the first calculation instruction and/or the calculation result of the operand.
  • the addressing modes of the first address information of each operand and/or the calculation result of the operand may be the same or different, which is not specifically limited in the present disclosure.
  • the first address information can be understood as the read address of the operand (that is, the first access address described below); for the calculation result of the operand, the first address information can be It is understood as the storage location of the calculation result (that is, the first storage address described below).
  • the addressing modes of the first address information of each operand and the calculation result of the operand may not be completely the same. At this time, for each operation data and calculation result of the operand, the corresponding The addressing mode determines first address information.
  • the first sub-enabling identifier that matches each data in the first memory access data may be determined among the plurality of first sub-enabling identifiers, and then according to the matched first sub-enabling identifier
  • the method provided by the embodiment of the present disclosure further includes the following steps:
  • S302 Determine first address information of first memory access data corresponding to the first computing instruction based on the second enabling flag.
  • the program for each layer of loop process includes an initial instruction and a loop instruction; wherein, the initial instruction is used to give an initial address.
  • the loop instruction is an instruction that loops and executes N times
  • the address accumulation mode is enabled for the first loop instruction
  • the data address information corresponding to the first loop instruction is based on The data address information of the initial address is determined after address accumulation calculation. In this way, the data address information of the first loop instruction will be wrong, resulting in wrong operands being obtained, which seriously affects the calculation result of the instruction.
  • the above-mentioned address accumulation mode is extended, so that the extended address accumulation mode can support the loop program more concisely and efficiently.
  • the specific extension method is:
  • a second enable flag is set in the previous instruction (that is, the second computation instruction) of the first computation instruction, and the second enable flag is used to indicate the next computation instruction (that is, the first computation instruction) of the second computation instruction. instruction) whether the address accumulation mode indicated by the first enable flag is enabled or not.
  • the first enabling flag in the first calculation instruction indicates that the address accumulation mode for the first memory access data is enabled
  • the second enabling flag in the second computing instruction is address accumulation If the mode is enabled and disabled, it is determined that the address accumulation mode indicated by the first enable flag in the first calculation instruction is enabled and disabled. That is to say, even if the addressing mode is determined to be the address accumulation mode according to the first enabling flag in the first calculation instruction, if the second enabling flag is enabled and disabled, the first memory access data in the first computing instruction
  • the addressing mode may be a direct addressing mode, or the first address information is determined according to the second address information.
  • the second calculation instruction is an address initialization instruction in the cyclic program.
  • the first calculation instruction is the first loop instruction in the cyclic program
  • the first use can be set in the first calculation instruction.
  • the enable flag is valid
  • the second enable flag is set in the second calculation instruction as enable and disable.
  • the first address information of the first memory access data can be determined through the direct addressing mode, or the second address information of the second memory access data corresponding to the second calculation instruction can be determined as The above-mentioned first address information.
  • the Nth loop instruction where N is greater than 1, it can be determined whether the address accumulation mode is enabled and valid according to the second enable flag in the N-1th loop instruction.
  • the second enable flag when the second enable flag is the third value, it can be determined that the address accumulation mode indicated by the first enable flag in the next computation instruction of the second computation instruction is enabled;
  • the second enabling flag is the fourth value, it may be determined that the address accumulation mode indicated by the first enabling flag in the next computing instruction of the second computing instruction is enabled and disabled.
  • the third value and the fourth value can be set according to actual needs, which is not specifically limited in the present disclosure.
  • the third numerical value may be set to "1", indicating that enabling is valid; the fourth numerical value may be set as "0", indicating that enabling is disabled.
  • step S301 and step S302 can not only be applied to the multi-cycle calculation process, but also can be applied to other calculation processes, for example, a calculation process similar to the multi-cycle calculation process, or other It is necessary to specify the scenarios where the address accumulation mode indicated by the first enable flag in the first calculation instruction is enabled and disabled, and this disclosure does not specifically limit this, and the implementation shall prevail.
  • step S302 determining the first address information of the first access data corresponding to the first computing instruction based on the second enabling flag, specifically includes the following steps:
  • the first address information of the first memory access data may be determined according to the address accumulation mode.
  • the accumulative step size information can be obtained based on the first computing instruction, and the second address information of the second memory access data corresponding to the second computing instruction can be obtained; further, based on the second address information and the accumulating step size information, determining the first address information, and executing the first calculation instruction based on the first address information.
  • the second address information of the second memory access data corresponding to the second calculation instruction may be determined as the above-mentioned first address information.
  • each layer of the loop program in the multiple loop program includes an initial instruction and a loop instruction.
  • the initial instruction is used to give the initial address.
  • the second calculation instruction is the address initialization instruction in the cyclic program
  • the first calculation instruction is the first loop instruction in the cyclic program
  • the second enabling flag can be set in the second calculation instruction as Enable and disable.
  • the second address information of the second memory access data corresponding to the second calculation instruction may be determined as the first address information.
  • the second address information in the address initialization instruction is determined as the first address information of the first calculation instruction.
  • the programmer can set whether the second enabling flag is enabled or disabled according to actual needs. Through this processing method, errors in the data address information of the first loop instruction can be avoided, so that accurate operands can be obtained. At the same time, through this processing method, the flexibility of programs written by users can be improved, so as to meet various programming needs of programmers.
  • the address accumulation mode indicated by the first enabling flag in the first computing instruction is determined according to the second enabling flag Whether to enable an effective method can expand the applicable scenarios of the technical solution of the present disclosure.
  • the technical solution of the present disclosure can still process calculation instructions, thereby improving the processing efficiency of cycle instructions.
  • Step S302 Determine the first address information of the first memory access data corresponding to the first computing instruction based on the second enabling flag, specifically including the following steps:
  • the above-mentioned second enablement flag may include multiple second sub-enablement flags, and each second sub-enablement flag corresponds to one data in the first access data.
  • each data in the first fetch data can be understood as each operand used to execute the first calculation instruction and/or the calculation result of the operand.
  • the second sub-enabling identifier matching each data in the first access data may be determined among multiple second sub-enabling identifiers, and then according to the matched second sub-enabling identifier The identification value of the enabling identification determines the first address information of the corresponding data.
  • the first calculation instruction and the second calculation instruction are:
  • opcal is the above-mentioned first calculation instruction
  • opening is the second calculation instruction
  • (addr1/dlt1, addr2/dlt2, addr3/dlt3, nxt_dlt_on[2:0]) is part of the instruction content of the first calculation instruction.
  • addr1/dlt1 and addr2/dlt2 are the instruction content used to determine the access information of the operand in the first memory access data
  • addr3/dlt3 are used to determine the storage of the calculation result of the operand in the first memory access data The command content of the message.
  • the first enabling flag in the first computing instruction is valid for enabling the address accumulation mode.
  • the second enable flag (nxt_dlt0_on, nxt_dlt1_on, nxt_dlt2_off) in the second calculation instruction the address accumulation mode of the access address of the operand corresponding to "dlt0" and "dlt1" in the first calculation instruction is enabled.
  • the address accumulation mode of the storage address of the calculation result corresponding to "dlt2" in a calculation instruction is enabled and disabled.
  • the access addresses of the operands corresponding to "dlt0" and “dlt1" can be determined based on the address accumulation mode, and the storage address of the calculation result of the second calculation instruction can be determined as the storage address of the calculation result of the first calculation instruction address.
  • minit is an address initialization instruction
  • the address initialization instruction is the previous instruction of the first instruction in the for loop, that is, minit is the above-mentioned second calculation instruction
  • the first macc instruction in the for loop can be the above-mentioned first instruction.
  • vector x, vector y, and initial addresses of calculation results of vector x and vector y are included.
  • "nxt_dlt0_on, nxt_dlt1_on, nxt_dlt2_on" in the address initialization instruction respectively indicate that the address accumulation mode corresponding to vector x in the first macc instruction of the for loop is enabled and valid, and the address accumulation mode corresponding to vector y in the first macc instruction of the for loop Enable is valid, and the address accumulation mode corresponding to the calculation results of vector x and vector y in the first macc instruction of the for loop is enabled and valid.
  • the access addresses of vector x and vector y can be determined based on the address accumulation mode, and the storage addresses of the calculation results of vector x and vector y can be determined.
  • the above-mentioned instruction processing device includes a register file, and the register file is used to store the accumulation step size information and the first memory access data.
  • step S105: acquiring the accumulation step information based on the first calculation instruction includes: acquiring the accumulation step information in the register file based on the instruction content of the first calculation instruction.
  • step S107 determining the first address information based on the second address information and the accumulation step information includes: based on the second address information and the The accumulative step size information is used to determine the first address information of the first memory access data.
  • the instruction content of the first calculation instruction includes an index identifier of a register in the register file storing the accumulation step information.
  • the data in the corresponding register may be read based on the index identifier, and the read data may be determined as the accumulative step size information.
  • the second address information and the accumulation step information may be accumulated and calculated to obtain the first address information of the first access data.
  • the register file includes a vector register file and a scalar register file
  • the vector register file is used to store the first memory access data of the first computing instruction
  • the scalar register file is used to store the Describe the accumulative step size information.
  • the development of artificial intelligence has put forward higher requirements for computing power.
  • the computing power density of instruction processing devices continues to increase, and the performance requirements for memory access also increase accordingly.
  • the current trend is to increase high-speed internal storage spaces (for example, register files) inside the instruction processing device, and the first calculation unit of the instruction processing device can directly access these storage spaces (for example, register files), and Efficient data multiplexing is performed therein, thereby improving the calculation efficiency of the first calculation unit in the instruction processing device.
  • step S107 Execute the first calculation instruction based on the first address information, which specifically includes the following step:
  • S1072 Execute the first calculation instruction by using the operand obtained from the storage location corresponding to the first access address as the first memory access data, to obtain a first calculation result of the first calculation instruction, and storing the first calculation result in a storage location corresponding to the first storage address.
  • the operand stored in the storage location corresponding to the first access address may be acquired. For example, obtain the operand stored in the register corresponding to the first access address in the register file, and execute the first calculation instruction with the obtained operand, so as to obtain the first calculation result of the first calculation instruction, and store the first calculation result Store in the register corresponding to the first storage address in the register file.
  • the determination process of the first address information can be hidden in the instruction processing process of the first calculation instruction, thereby reducing the extra instruction cycle, and further speeding up the execution efficiency of the instruction.
  • the instruction processing device includes:
  • an instruction processing unit 41 configured to obtain a first computing instruction to be processed
  • the instruction execution unit 42 is configured to obtain the accumulation step size information based on the first calculation instruction, and obtain the second address information of the second access data corresponding to the second calculation instruction; wherein, the second calculation instruction is The previous instruction of the first calculation instruction; and based on the second address information and the accumulation step information, determine the first address information of the first memory access data corresponding to the first calculation instruction, and based on The first address information executes the first calculation instruction, wherein the first memory access data includes an operand and/or a calculation result of the operand of the first calculation instruction.
  • the instruction execution unit may acquire the accumulative step size information based on the first calculation instruction, and acquire the first value of the second access data corresponding to the second calculation instruction. second address information, and then determine the first address information based on the second address information and the accumulation step information, and execute the first calculation instruction based on the first address information.
  • the address calculation can be hidden in the instruction processing process of the calculation instruction, so that the extra instruction cycle can be reduced, and the execution efficiency of the instruction can be accelerated.
  • the instruction processing unit 41 is further configured to, after acquiring the first computing instruction to be processed, determine the address of the first address information of the first access data corresponding to the first computing instruction. address mode.
  • the instruction execution unit 42 is further configured to obtain the accumulation step size information based on the first calculation instruction when the addressing mode is the address accumulation mode, and obtain the information of the second memory access data corresponding to the second calculation instruction second address information; and determining the first address information based on the second address information and the accumulation step information, and executing the first calculation instruction based on the first address information.
  • the instruction processing unit may determine the addressing mode of the first address information of the first access data corresponding to the first calculation instruction.
  • the instruction execution unit can obtain the accumulation step size information based on the first calculation instruction, and obtain the second address information of the second memory access data corresponding to the second calculation instruction, and then based on the The second address information and the accumulation step information determine the first address information, and execute the first calculation instruction based on the first address information.
  • the first address information of the first access data of the first calculation instruction is determined through the address accumulation mode, and the determination process of the first address information can be hidden in the first
  • the instruction processing process of the calculation instruction reduces the extra instruction cycle, thereby speeding up the execution efficiency of the instruction.
  • the instruction processing unit 41 is further configured to: if the addressing mode is a direct addressing mode, obtain the field content in the address field in the first calculation instruction; and Determine the first address information of the first memory access data based on the obtained field content, and send the first address information to the instruction execution unit, so that the instruction execution unit based on the first address The information executes the first computing instruction.
  • the first address information of the first memory access data may be acquired based on the instruction content of the first computing instruction.
  • the first address information of the first memory access data can be obtained in the register file or instruction encoding based on the instruction content of the first computing instruction.
  • the first address information of the first fetched data can be obtained through the two methods described in the second case of the above embodiment, which will not be described in detail here.
  • the instruction execution unit 42 includes an accumulation register 421 , a first calculation unit 442 and a second calculation unit 423 .
  • the accumulation register 421 is configured to store the second address information.
  • the first calculation unit 422 is configured to perform accumulation calculation on the second address information and the accumulation step information to obtain the first address information.
  • the second computing unit 423 is configured to obtain the first access address and the first storage address sent by the first computing unit, and obtain the operand stored in the storage location corresponding to the first access address;
  • the operand obtained in the storage location corresponding to the first access address is used as the first memory access data to execute the first calculation instruction, obtain a first calculation result of the first calculation instruction, and store the The first calculation result is stored in a storage location corresponding to the first storage address.
  • an address accumulation unit can be set for each second calculation unit, and the address accumulation unit includes an accumulation register 421 and a first calculation unit Unit 422. Further, the address accumulation unit may include multiple sub-accumulation units, and each sub-accumulation unit includes an accumulation register 421 and a first calculation unit 422 .
  • each second calculation unit is used to calculate multiple operands to obtain calculation results. At this time, for each operand and calculation result, a sub-accumulation unit can be correspondingly set.
  • the first calculation unit After the first calculation unit accumulates and calculates the second address information and the accumulation step information to obtain the first address information, it may send the first address information to the second calculation unit.
  • the first address information includes a first access address and a first storage address.
  • the second calculation unit may obtain the operand stored in the corresponding storage location in the first access address. For example, obtaining the operand stored in the register corresponding to the first access address in the register file of the instruction processing device, and executing the first calculation instruction with the obtained operand, so as to obtain the first calculation result of the first calculation instruction, and The first calculation result is stored in the register corresponding to the first storage address in the register file.
  • the determination process of the first address information can be hidden in the instruction processing process of the first calculation instruction, thereby reducing the extra instruction cycle, and further speeding up the execution efficiency of the instruction.
  • the instruction processing unit 41 includes an instruction reading unit 411 , an instruction decoding unit 412 and an instruction issuing unit 413 .
  • the instruction fetching unit is configured to fetch the first computation instruction to be processed.
  • the instruction decoding unit is configured to determine a first enable flag in the first calculation instruction, wherein the first enable flag is used to indicate whether the address accumulation mode for the first memory access data is enabled or not. ; and determining an addressing mode of the first address information of the first memory access data corresponding to the first computing instruction based on the first enabling flag.
  • the instruction issuing unit is configured to implement data transmission between the instruction processing unit, the instruction execution unit and the register file.
  • the instruction decoding unit can obtain the value of the specified data bit in the first calculation instruction, and then determine the first calculation instruction according to the value of the specified data bit. enable flag. After the first enabling flag is acquired, it may be determined based on the first enabling flag whether the address accumulation mode for the first memory access data is enabled and valid.
  • the instruction issuing unit can send the instruction execution unit The accumulation step information is transmitted, so that the instruction execution unit determines the first address information based on the second address information and the accumulation step information.
  • the first enabling flag includes a plurality of first sub-enabling flags; each of the first sub-enabling flags corresponds to one data in the first access data.
  • the instruction decoding unit is configured to determine, among the plurality of first sub-enabling flags, a first sub-enabling flag that matches each data in the first memory access data; and based on The first sub-enable flag matching each data in the first memory access data determines the addressing mode of the first address information of each data in the first calculation instruction.
  • first enablement flag may include a plurality of first sub-enablement flags, and each first sub-enablement flag is used to indicate the first address information of each data in the first access data. address mode.
  • each data in the first fetch data can be understood as each operand used to execute the first calculation instruction and/or the calculation result of the operand.
  • the addressing modes of the first address information of each operand and/or the calculation result of the operand may be the same or different, which is not specifically limited in the present disclosure.
  • the first address information can be understood as the read address of the operand (that is, the first access address described below); for the calculation result of the operand, the first address information can be It is understood as the storage location of the calculation result (that is, the first storage address described below).
  • the addressing modes of the first address information of each operand and the calculation result of the operand may not be completely the same. At this time, for each operation data and calculation result of the operand, the corresponding The addressing mode determines first address information.
  • the first address information of each data can expand the application scenarios of the technical solution, so as to meet the programming needs of programmers.
  • the above-mentioned instruction decoding unit 412 is configured to detect the second enable flag in the second calculation instruction after determining that the first enable flag indicates that the address accumulation mode is enabled ; Wherein, the second enabling flag is used to indicate whether the address accumulation mode indicated by the first enabling flag in the first calculation instruction is enabled and valid; and determining the first The first address information of the first memory access data corresponding to a computing instruction.
  • the above address accumulation mode is extended, so that the extended address accumulation mode can support the loop program more concisely and efficiently.
  • the specific extension method is as follows:
  • a second enable flag is set in the previous instruction (that is, the second computation instruction) of the first computation instruction, and the second enable flag is used to indicate the next computation instruction (that is, the first computation instruction) of the second computation instruction. instruction) whether the address accumulation mode indicated by the first enable flag is enabled or not.
  • the first enable flag in the first computing instruction indicates that the address accumulation mode for the first memory access data is enabled
  • the second enabling flag in the second computing instruction is enabled If disabled, it is determined that the address accumulation mode indicated by the first enable flag in the first computing instruction is enabled and disabled. That is to say, even if the addressing mode is determined to be the address accumulation mode according to the first enabling flag in the first calculation instruction, if the second enabling flag is enabled and disabled, the first memory access data in the first computing instruction
  • the addressing mode may be a direct addressing mode, or the first address information is determined according to the second address information.
  • the instruction decoding unit is configured to determine the first address of the first memory access data corresponding to the first calculation instruction when it is determined that the second enable flag is enabled and disabled
  • the information is the second address information of the second access data corresponding to the second computing instruction.
  • the second address information of the second memory access data corresponding to the second calculation instruction may be determined as the above-mentioned first address information.
  • each layer of the loop program in the multiple loop program includes an initial instruction and a loop instruction.
  • the initial instruction is used to give the initial address.
  • the second calculation instruction is the address initialization instruction in the cyclic program
  • the first calculation instruction is the first loop instruction in the cyclic program
  • the second enabling flag can be set in the second calculation instruction as Enable and disable.
  • the second address information of the second memory access data corresponding to the second calculation instruction may be determined as the first address information.
  • the second address information in the address initialization instruction is determined as the first address information of the first calculation instruction.
  • the programmer can set whether the second enabling flag is enabled or disabled according to actual needs. Through this processing method, an error in the data address information of the first instruction in the loop instruction can be avoided, so that an accurate operand can be obtained. At the same time, through this processing method, the flexibility of programs written by users can be improved, so as to meet various programming needs of programmers.
  • the second enabling flag includes multiple second sub-enabling flags, and each second sub-enabling flag corresponds to one data in the first access data.
  • the instruction decoding unit is configured to determine a second sub-enablement flag that matches each data in the first memory access data among the plurality of second sub-enablement flags; and based on The second sub-enabling identifier matched with each data in the first access data determines the first address information of each data in the first access data.
  • the above-mentioned second enablement flag may include multiple second sub-enablement flags, and each second sub-enablement flag corresponds to one data in the first access data.
  • each data in the first memory access data can be understood as each operand used to execute the first calculation instruction, and the calculation result of the operand.
  • the second sub-enabling identifier matching each data in the first access data may be determined among multiple second sub-enabling identifiers, and then according to the matched second sub-enabling identifier The identification value of the enabling identification determines the first address information of the corresponding data.
  • the instruction content of the first calculation instruction includes at least one first data bit and/or at least one second data bit, wherein each of the first data bits includes a first enable flag and/or First identification content, each of the second data bits includes a second enable identification and/or second identification content, the first enable identification is used to indicate the addressing mode of the first calculation instruction, the The content of the first identification is used to indicate the accumulation step information or the first address information, the second enabling identification is used to indicate the addressing mode of the next calculation instruction of the first calculation instruction, and the first The content of the second identification is used to indicate the accumulative step size information or the first address information corresponding to the execution of the next calculation instruction.
  • addr/dlt is the above-mentioned first enabling flag
  • the data bit is the value of addr/dlt, corresponding
  • the enabling flag of is *dlt*on/off
  • a, b and c are the first flag contents of the first enabling flag.
  • nxt_dlt0_on, nxt_dlt1_on, nxt_dlt2_off are at least one second data bit
  • nxt_dlt0, nxt_dlt1 and nxt_dlt2 are the second enable flags, and on or off is the second flag content of the second enable flag.
  • the instruction processing device further includes a register file 61; wherein, the register file is used to store at least one of the following: the accumulation step information, the first memory access data and the first address information.
  • the instruction decoding unit is configured to decode the instruction content of the first computing instruction to obtain a decoding result; the instruction issuing unit is configured to send a fetch to the register file based on the decoding result The instruction for accumulating step size information; the instruction executing unit is configured to determine the first address information of the first memory access data based on the second address information and the accumulating step size information.
  • the instruction processing device includes an instruction processing unit, an instruction execution unit, and a register file; wherein, the instruction execution unit includes an address accumulation unit A and a second calculation unit A , the address accumulation unit B and the second calculation unit B, the address accumulation unit C and the second calculation unit C. Wherein, each of the address accumulation unit A, the address accumulation unit B and the address accumulation unit C includes an accumulation register and a first calculation unit.
  • the instruction processing method can be described as the following process.
  • the above idea of address accumulation can be applied to the design of the instruction processing device.
  • the instruction processing device is simply divided into three parts: an instruction processing unit, an instruction execution unit and a register file. Among them, the instruction processing unit is responsible for reading, decoding and launching instructions, and the instruction execution unit is responsible for arithmetic and memory access.
  • the computing unit in the instruction execution unit supports, for example, the following instructions:
  • the instruction reading unit reads the first computing instruction, and after the instruction decoding unit decodes the first computing instruction, it parses out the addressing mode (direct addressing addr mode/address accumulation dlt mode), and for the next Whether the dlt mode of a calculation instruction is enabled (nxt_dlt_on/nxt_dlt_off).
  • the instruction emission unit establishes a communication link with the register file, so as to take out the value of addr/dlt from the register file or instruction encoding through the communication link;
  • the instruction execution unit directly uses the value of addr to read the register file.
  • the last access address (that is, the second address information corresponding to the second calculation instruction) is maintained in the accumulation register, after that, the first calculation unit calculates the last access address and the accumulation result of the accumulation step information,
  • the first address information is sent to the second calculation unit of the instruction execution unit, and the second calculation unit of the instruction execution unit uses the first address information to access the register file.
  • the register file includes a vector register file and a scalar register file
  • the vector register file is used to store the first memory access data of the first calculation instruction
  • the scalar register file is used to store the accumulated step size information and/or the first address information.
  • the instruction processing device includes an instruction processing unit, an instruction execution unit, a scalar register file and a vector register file; wherein, the instruction execution unit includes an address accumulation unit A and a second computing unit A, an address accumulation unit B and a second A calculation unit B, an address accumulation unit C and a second calculation unit C.
  • the address accumulation unit A, the address accumulation unit B and the address accumulation unit C includes an accumulation register and a first calculation unit.
  • the instruction processing method can be described as the following process.
  • the above idea of address accumulation can be applied to the design of the instruction processing device.
  • the instruction processing device is simply divided into three parts: an instruction processing unit, an instruction execution unit and a register file. Among them, the instruction processing unit is responsible for reading, decoding and launching instructions, and the instruction execution unit is responsible for arithmetic and memory access.
  • the technical solution provided by the embodiments of the present disclosure can be extended to an instruction processing device including a parallel computing unit, such as a CPU (Central Processing Unit) or a GPU (Graphics Processing Unit) that includes a SIMD (Single Instruction Multiple Data) unit. Unit).
  • a parallel computing unit such as a CPU (Central Processing Unit) or a GPU (Graphics Processing Unit) that includes a SIMD (Single Instruction Multiple Data) unit. Unit).
  • the instruction processing device contains two independent register files, among which the scalar register file is mainly used to store simple scalar data or control information, and the vector register file is used to store parallel computing SIMD/SIMT (Single Instruction Multiple Threads, Single Instruction Multiple Threads) data.
  • SIMD/SIMT Single Instruction Multiple Threads, Single Instruction Multiple Threads
  • the vector register file is used to store the first memory access data of the first calculation instruction
  • the scalar register file is used to store the accumulation step information and/or the first address information.
  • the instruction reading unit reads the first calculation instruction, and after the instruction decoding unit decodes the first calculation instruction, it parses out the addressing mode (direct addressing addr mode/address accumulation dlt mode), and for the next first calculation instruction Whether the dlt mode of a calculation instruction is enabled (nxt_dlt_on/nxt_dlt_off);
  • the instruction emission unit establishes a communication link with the register file, so as to take out the value of addr/dlt from the register file or instruction encoding through the communication link;
  • the instruction execution unit directly uses the value of addr to read the vector register file.
  • the last access address (that is, the second address information corresponding to the second calculation instruction) is maintained in the accumulation register, after that, the first calculation unit calculates the last access address and the accumulation result of the accumulation step information, The first address information is sent to the second calculation unit of the instruction execution unit, and the second calculation unit of the instruction execution unit uses the address to access the vector register file.
  • the writing order of each step does not mean a strict execution order and constitutes any limitation on the implementation process.
  • the specific execution order of each step should be based on its function and possible
  • the inner logic is OK.
  • the embodiment of the present disclosure also provides an instruction processing device corresponding to the instruction processing method. Since the problem-solving principle of the device in the embodiment of the present disclosure is similar to the above-mentioned instruction processing method in the embodiment of the present disclosure, the implementation of the device Reference can be made to the implementation of the method, and repeated descriptions will not be repeated.
  • the instruction processing device includes:
  • the first obtaining unit 91 is configured to obtain the first computing instruction to be processed
  • a determining unit 92 configured to determine an addressing mode of the first address information of the first memory access data corresponding to the first calculation instruction; the first memory access data includes an operation for executing the first calculation instruction results of calculations on numbers and/or operands;
  • the second obtaining unit 93 is configured to obtain the accumulation step size information based on the first calculation instruction when the addressing mode is the address accumulation mode, and obtain the second memory access data corresponding to the second calculation instruction Second address information; the second computing instruction is a previous instruction of the first computing instruction;
  • the instruction execution unit 94 is configured to determine the first address information based on the second address information and the accumulation step information, and execute the first calculation instruction based on the first address information.
  • the instruction execution unit is further configured to obtain the operation stored in the storage location corresponding to the first access address when the first address information includes the first access address and the first storage address. number; using the operand obtained from the memory corresponding to the first access address as the first memory access data to execute the first calculation instruction to obtain a first calculation result of the first calculation instruction, and storing the first calculation result to a storage location corresponding to the first storage address.
  • the instruction processing device is further configured to obtain the field content in the address field in the first calculation instruction when the addressing mode is the direct addressing mode; based on the obtained The content of the field of determines the first address information of the first fetched data.
  • the determining unit is further configured to determine a first enable flag in the first computing instruction, where the first enable flag is used to indicate the Whether the address accumulation mode is enabled and valid; determining the addressing mode of the first address information of the first memory access data corresponding to the first calculation instruction based on the first enable flag.
  • the determining unit is further configured to include a plurality of first sub-enabling identifiers in the first enabling identifier; each of the first sub-enabling identifiers corresponds to an In the case of one data, among the plurality of first sub-enabling identifiers, determine a first sub-enabling identifier that matches each data in the first memory access data; The first sub-enabling identifier matched by each data in the data determines the addressing mode of the first address information of each data in the first calculation instruction.
  • the instruction processing device is further configured to detect a second enablement flag in the second calculation instruction after determining that the first enablement flag is enabled; wherein, the The second enabling flag is used to indicate whether the address accumulation mode indicated by the first enabling flag in the first computing instruction is enabled and valid; determine the address corresponding to the first computing instruction based on the second enabling flag First address information of the first fetched data.
  • the instruction processing device is further configured to, in the case of determining that the second enable flag is enabled and disabled, determine the first memory access data corresponding to the first calculation instruction
  • the address information is the second address information of the second fetch data corresponding to the second computing instruction.
  • the instruction processing device is further configured to include a plurality of second sub-enabling identifiers in the second enabling identifier, and each second sub-enabling identifier corresponds to an In the case of one data, among the multiple second sub-enablement identifiers, determine a second sub-enablement identifier that matches each data in the first memory access data; Each data in the data matches the second sub-enabling identifier to determine the first address information of each data in the first fetched data.
  • the second acquisition unit is further configured to The instruction content of the first calculation instruction acquires the accumulative step information in the register file; the instruction execution unit is further configured to determine the first memory access based on the second address information and the accumulative step information The first address information of the data.
  • the register file includes a vector register file and a scalar register file
  • the vector register file is used to store the first memory access data of the first computing instruction
  • the scalar register file is used to store the Describe the accumulative step size information.
  • the instruction processing apparatus may also be implemented as a processor, which will not be repeated here.
  • the various units included in the instruction processing device mentioned in the embodiment of the present application can be realized as a part of the processor, or in the case that the instruction processing device is a multi-core processor, it can be implemented as The processor itself is implemented as a part of a chip, or as various electronic circuits, etc.
  • the present application does not limit its specific hardware implementation form, as long as it realizes the functions described in the embodiments of the present application.
  • an embodiment of the present disclosure further provides an electronic device 1000 .
  • FIG. 10 it is a schematic structural diagram of an electronic device 1000 provided by an embodiment of the present disclosure, and the electronic device 1000 includes a processor 101 , a memory 102 and a bus 103 .
  • the memory 102 is used to store execution instructions, including a memory 1021 and an external memory 1022; the memory 1021 here is also called an internal memory, and is used to temporarily store computing data in the processor 101 and data exchanged with an external memory 1022 such as a hard disk.
  • the processor 101 exchanges data with the external memory 1022 through the memory 1021.
  • the processor 101 communicates with the memory 102 through the bus 103, so that the processor 101 executes the following instructions.
  • the first calculation instruction Acquiring the first calculation instruction to be processed; determining the addressing mode of the first address information of the first memory access data corresponding to the first calculation instruction; wherein the first memory access data includes An operand of a calculation instruction and/or a calculation result of the operand; in the case where the addressing mode is an address accumulation mode, acquiring accumulation step size information based on the first calculation instruction, and obtaining the information corresponding to the second calculation instruction The second address information of the second access data; wherein, the second calculation instruction is the previous instruction of the first calculation instruction; based on the second address information and the accumulation step information, determine the first address information, and execute the first calculation instruction based on the first address information.
  • Embodiments of the present disclosure further provide a computer-readable storage medium, on which a computer program is stored.
  • the storage medium may be a volatile or non-volatile computer-readable storage medium.
  • the embodiment of the present disclosure also provides a computer program product, the computer program product carries a program code, and the instructions included in the program code can be used to execute the steps of the instruction processing method described in the above method embodiment, for details, please refer to the above method The embodiment will not be repeated here.
  • Embodiments of the present disclosure further provide a chip, which includes the instruction processing device described in any one of the above embodiments.
  • a chip which includes the instruction processing device described in any one of the above embodiments.
  • the above-mentioned computer program product may be specifically implemented by means of hardware, software or a combination thereof.
  • the computer program product is embodied as a computer storage medium, and in another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (Software Development Kit, SDK) etc. wait.
  • a software development kit Software Development Kit, SDK
  • the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit.
  • the functions are realized in the form of software function units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium executable by a processor.
  • the technical solution of the present disclosure is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make an electronic device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in various embodiments of the present disclosure.
  • the aforementioned storage medium includes various media that can store program codes such as U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Executing Machine-Instructions (AREA)
  • Advance Control (AREA)

Abstract

Provided in the present disclosure are an instruction processing method and apparatus, a chip, an electronic device, and a storage medium. The instruction processing method comprises: acquiring a first computation instruction to be processed; determining an addressing mode of first address information of first access data corresponding to the first computation instruction, wherein the first access data comprises an operand which is used for executing the first computation instruction and/or a computation result of the operand; when the addressing mode is an address accumulation mode, acquiring accumulated step size information on the basis of the first computation instruction, and acquiring second address information of second access data corresponding to a second computation instruction, wherein the second computation instruction is the instruction preceding the first computation instruction; and on the basis of the second address information and the accumulated step size information, determining the first address information, and on the basis of the first address information, executing the first computation instruction.

Description

指令处理方法、装置、芯片、电子设备以及存储介质Instruction processing method, device, chip, electronic device and storage medium
交叉引用声明cross-reference statement
本申请要求于2022年01月30日提交的申请号为202210114536.0的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application with application number 202210114536.0 filed on January 30, 2022, the entire contents of which are incorporated in this application by reference.
技术领域technical field
本公开涉及电子技术领域,具体而言,涉及一种指令处理方法、装置、芯片、电子设备以及计算机可读存储介质。The present disclosure relates to the field of electronic technology, and in particular, to an instruction processing method, device, chip, electronic equipment, and computer-readable storage medium.
背景技术Background technique
计算机的工作过程涉及对按一定顺序排列的计算机指令的执行,计算机指令是指挥和协调计算机各个部件工作的指示和命令。指令的执行主要包括对存储空间的访问和对数据的计算,其中,存储空间访问的形式包括立即数直接寻址和利用运算结果的间接寻址。间接寻址方式需要实时计算地址的值,因此,间接寻址方式带来了额外的指令周期,从而影响了指令的执行效率。The working process of a computer involves the execution of computer instructions arranged in a certain order. Computer instructions are instructions and commands to direct and coordinate the work of various components of the computer. The execution of instructions mainly includes access to storage space and calculation of data, wherein the form of storage space access includes immediate direct addressing and indirect addressing using operation results. The indirect addressing mode needs to calculate the value of the address in real time. Therefore, the indirect addressing mode brings extra instruction cycles, thereby affecting the execution efficiency of the instruction.
发明内容Contents of the invention
本公开实施例至少提供一种指令处理方法、装置、芯片、电子设备以及计算机可读存储介质。Embodiments of the present disclosure at least provide an instruction processing method, device, chip, electronic device, and computer-readable storage medium.
第一方面,本公开实施例提供了一种指令处理装置,包括:指令处理单元,被配置成获取待处理的第一计算指令;指令执行单元,被配置成基于所述第一计算指令获取累加步长信息,并获取第二计算指令所对应的第二访存数据的第二地址信息;其中,所述第二计算指令为所述第一计算指令的上一条指令;基于所述第二地址信息和所述累加步长信息,确定所述第一计算指令所对应的第一访存数据的第一地址信息,并基于所述第一地址信息执行所述第一计算指令,其中所述第一访存数据包括的操作数和/或操作数的计算结果。In a first aspect, an embodiment of the present disclosure provides an instruction processing device, including: an instruction processing unit configured to obtain a first calculation instruction to be processed; an instruction execution unit configured to obtain an accumulated calculation instruction based on the first calculation instruction step size information, and obtain the second address information of the second access data corresponding to the second calculation instruction; wherein, the second calculation instruction is the previous instruction of the first calculation instruction; based on the second address information and the accumulative step information, determine the first address information of the first access data corresponding to the first calculation instruction, and execute the first calculation instruction based on the first address information, wherein the first An operand included in the fetched data and/or a calculation result of the operand.
在本公开实施例中,在指令处理单元获取到第一计算指令之后,指令执行单元可以基于第一计算指令获取累加步长信息,并获取第二计算指令所对应的第二访存数据的第二地址信息,进而基于该第二地址信息和累加步长信息确定第一地址信息,并基于第一地址信息执行所述第一计算指令。在上述实施方式中,可以将地址计算隐藏在计算指令的指令处理过程中,从而可以减少额外的指令周期,进而加快了指令的执行效率。In the embodiment of the present disclosure, after the instruction processing unit acquires the first calculation instruction, the instruction execution unit may acquire the accumulative step size information based on the first calculation instruction, and acquire the first value of the second access data corresponding to the second calculation instruction. second address information, and then determine the first address information based on the second address information and the accumulation step information, and execute the first calculation instruction based on the first address information. In the above implementation manner, the address calculation can be hidden in the instruction processing process of the calculation instruction, so that the extra instruction cycle can be reduced, and the execution efficiency of the instruction can be accelerated.
在一种可选的实施方式中,所述指令处理单元被配置成,在所述获取待处理的第一计算指令之后,确定所述第一计算指令所对应的第一访存数据的第一地址信息的寻址模式;所述指令执行单元被配置成,在所述寻址模式为地址累加模式的情况下,基于所述第一计算指令获取所述累加步长信息,并获取第二计算指令所对应的第二访存数据的第二地址信息;以及基于所述第二地址信息和所述累加步长信息,确定所述第一地址信息,并基于所述第一地址信息执行所述第一计算指令。In an optional implementation manner, the instruction processing unit is configured to, after acquiring the first computing instruction to be processed, determine the first Addressing mode of address information; the instruction execution unit is configured to, when the addressing mode is an address accumulation mode, obtain the accumulation step information based on the first calculation instruction, and obtain the second calculation second address information of the second access data corresponding to the instruction; and based on the second address information and the accumulation step information, determine the first address information, and execute the first address information based on the first address information A first calculation instruction.
在上述实施方式中,在获取到第一计算指令之后,通过地址累加模式确定第一计算指令的第一访存数据的第一地址信息的方式,可以将第一地址信息的确定过程隐藏在第一计算指令的指令处理过程,从而减少了额外的指令周期,进而加快了指令的执行效率。In the above embodiment, after the first calculation instruction is acquired, the first address information of the first access data of the first calculation instruction can be determined through the address accumulation mode, and the determination process of the first address information can be hidden in the first An instruction processing process for computing instructions, thereby reducing additional instruction cycles, thereby speeding up the execution efficiency of instructions.
在一种可选的实施方式中,所述指令执行单元包括:累加寄存器,被配置成存储所述第二地址信息;第一计算单元,被配置成,在获取所述指令处理单元发送的所述累加 步长信息之后,对所述第二地址信息和所述累加步长信息进行累加计算,得到所述第一地址信息。In an optional implementation manner, the instruction execution unit includes: an accumulation register configured to store the second address information; a first calculation unit configured to obtain the After the accumulative step information, perform accumulative calculation on the second address information and the accumulative step information to obtain the first address information.
在一种可选的实施方式中,所述第一地址信息包括第一访问地址和第一存储地址;所述指令执行单元进一步包括第二计算单元,被配置成:获取所述第一计算单元发送的所述第一访问地址和所述第一存储地址,并获取所述第一访问地址所对应的存储位置中存储的操作数;并将从所述第一访问地址所对应的存储位置中获取到的操作数作为所述第一访存数据执行所述第一计算指令,得到所述第一计算指令的第一计算结果,并将所述第一计算结果存储至所述第一存储地址对应的存储位置。In an optional implementation manner, the first address information includes a first access address and a first storage address; the instruction execution unit further includes a second computing unit configured to: obtain the first computing unit Send the first access address and the first storage address, and obtain the operand stored in the storage location corresponding to the first access address; and obtain the operand stored in the storage location corresponding to the first access address Executing the first computing instruction with the obtained operand as the first memory access data, obtaining a first computing result of the first computing instruction, and storing the first computing result in the first storage address corresponding storage location.
在一种可选的实施方式中,所述指令处理单元还被配置成:在所述寻址模式为直接寻址模式的情况下,获取所述第一计算指令中的地址字段中的字段内容;基于获取到的所述字段内容确定所述第一访存数据的第一地址信息,并向所述指令执行单元发送所述第一地址信息,以使所述指令执行单元基于所述第一地址信息执行所述第一计算指令。In an optional implementation manner, the instruction processing unit is further configured to: if the addressing mode is a direct addressing mode, obtain the field content in the address field in the first calculation instruction ; Determine the first address information of the first memory access data based on the obtained field content, and send the first address information to the instruction execution unit, so that the instruction execution unit based on the first The address information executes the first calculation instruction.
在一种可选的实施方式中,所述指令处理单元包括指令译码单元,被配置成确定所述第一计算指令中的第一使能标识,其中,所述第一使能标识用于指示针对所述第一访存数据的地址累加模式是否使能有效;以及基于所述第一使能标识确定所述第一计算指令所对应的第一访存数据的第一地址信息的寻址模式。In an optional implementation manner, the instruction processing unit includes an instruction decoding unit configured to determine a first enable flag in the first calculation instruction, where the first enable flag is used for Indicating whether the address accumulation mode for the first memory access data is enabled and valid; and determining the addressing of the first address information of the first memory access data corresponding to the first calculation instruction based on the first enable flag model.
在一种可选的实施方式中,所述第一使能标识包含多个第一子使能标识,每个所述第一子使能标识对应所述第一访存数据中的一个数据;所述指令译码单元被配置成:在所述多个第一子使能标识中确定与所述第一访存数据中的每个数据相匹配的第一子使能标识;以及基于与所述第一访存数据中的每个数据相匹配的第一子使能标识,确定所述第一计算指令所对应的第一访存数据中的每个数据的第一地址信息的寻址模式。In an optional implementation manner, the first enabling flag includes a plurality of first sub-enabling flags, and each of the first sub-enabling flags corresponds to one data in the first access data; The instruction decoding unit is configured to: determine a first sub-enablement flag that matches each data in the first memory access data among the plurality of first sub-enablement flags; The first sub-enabling flag that matches each data in the first memory access data, and determine the addressing mode of the first address information of each data in the first memory access data corresponding to the first calculation instruction .
在一种可选的实施方式中,所述指令译码单元被配置成:在确定所述第一使能标识为地址累加模式使能有效之后,在所述第二计算指令中检测第二使能标识;其中,所述第二使能标识用于指示所述第一计算指令中的第一使能标识所指示的地址累加模式是否使能有效;以及基于所述第二使能标识确定所述第一计算指令所对应的第一访存数据的第一地址信息。In an optional implementation manner, the instruction decoding unit is configured to: after determining that the first enable flag indicates that address accumulation mode enable is valid, detect the second enable in the second calculation instruction An enable flag; wherein, the second enable flag is used to indicate whether the address accumulation mode indicated by the first enable flag in the first calculation instruction is enabled and valid; and determining the The first address information of the first access data corresponding to the first calculation instruction.
在一种可选的实施方式中,所述指令译码单元被配置成:在确定所述第二使能标识为地址累加模式使能禁止的情况下,确定所述第一计算指令所对应的第一访存数据的第一地址信息为所述第二计算指令所对应的第二访存数据的第二地址信息。In an optional implementation manner, the instruction decoding unit is configured to: when determining that the second enabling flag is address accumulation mode enable and disable, determine the The first address information of the first access data is the second address information of the second access data corresponding to the second calculation instruction.
在一种可选的实施方式中,所述第二使能标识包含多个第二子使能标识,每个所述第二子使能标识对应所述第一访存数据中的一个数据;所述指令译码单元被配置成:在所述多个第二子使能标识中确定与所述第一访存数据中的每个数据相匹配的第二子使能标识;以及基于与所述第一访存数据中的每个数据相匹配的第二子使能标识,确定所述第一访存数据中的每个数据的第一地址信息。In an optional implementation manner, the second enabling flag includes a plurality of second sub-enabling flags, and each of the second sub-enabling flags corresponds to one data in the first access data; The instruction decoding unit is configured to: determine a second sub-enablement flag that matches each data in the first memory access data among the plurality of second sub-enablement flags; The second sub-enabling identifier that matches each data in the first access data, and determine the first address information of each data in the first access data.
在一种可选的实施方式中,所述第一计算指令的指令内容包含至少一个连续的第一使能标识和/或至少一个连续的第二使能标识,其中,每个所述第一使能标识包括第一标识字段和/或第一字段内容,每个所述第二使能标识包括第二标识字段和/或第二字段内容,所述第一标识字段用于指示所述第一计算指令的寻址模式,所述第一字段内容用于指示所述累加步长信息或者所述第一地址信息,所述第二标识字段用于指示所述第一计算指令的下一条计算指令的寻址模式,所述第二字段内容用于指示执行所述下一条计算指令对应的累加步长信息或者第一地址信息。In an optional implementation manner, the instruction content of the first calculation instruction includes at least one continuous first enable flag and/or at least one continuous second enable flag, wherein each of the first The enabling identifier includes a first identifying field and/or first field content, each of the second enabling identifiers includes a second identifying field and/or second field content, and the first identifying field is used to indicate that the first An addressing mode of a calculation instruction, the content of the first field is used to indicate the accumulation step information or the first address information, and the second identification field is used to indicate the next calculation of the first calculation instruction The addressing mode of the instruction, the content of the second field is used to indicate the accumulation step size information or the first address information corresponding to the execution of the next calculation instruction.
在一种可选的实施方式中,所述指令处理装置还包括:寄存器堆,用于存储所述累加步长信息、所述第一访存数据和所述第一地址信息中的至少一个。In an optional implementation manner, the instruction processing device further includes: a register file, configured to store at least one of the accumulation step information, the first memory access data, and the first address information.
在一种可选的实施方式中,所述指令执行单元包括:指令译码单元,被配置成对所述第一计算指令的指令内容进行译码,得到译码结果;指令发射单元,被配置成基于所述译码结果向所述寄存器堆发送获取所述累加步长信息的指令;其中,所述指令执行单 元被配置成基于所述第二地址信息和所述累加步长信息,确定所述第一访存数据的第一地址信息。In an optional implementation manner, the instruction execution unit includes: an instruction decoding unit configured to decode the instruction content of the first computing instruction to obtain a decoding result; an instruction issuing unit configured to An instruction for acquiring the accumulation step information is sent to the register file based on the decoding result; wherein, the instruction execution unit is configured to determine the accumulated step information based on the second address information and the accumulation step information The first address information of the first access data.
在一种可选的实施方式中,所述寄存器堆包含向量寄存器堆和标量寄存器堆,其中,所述向量寄存器堆用于存储所述第一计算指令的第一访存数据,所述标量寄存器堆用于存储所述累加步长信息和/或所述第一地址信息。In an optional implementation manner, the register file includes a vector register file and a scalar register file, wherein the vector register file is used to store the first memory access data of the first computing instruction, and the scalar register The stack is used to store the accumulation step information and/or the first address information.
第二方面,本公开实施例提供了一种指令处理方法,包括:获取待处理的第一计算指令;确定所述第一计算指令所对应的第一访存数据的第一地址信息的寻址模式;其中,所述第一访存数据包括用于执行所述第一计算指令的操作数和/或操作数的计算结果;在所述寻址模式为地址累加模式的情况下,基于所述第一计算指令获取累加步长信息,并获取第二计算指令所对应的第二访存数据的第二地址信息;其中,所述第二计算指令为所述第一计算指令的上一条指令;基于所述第二地址信息和所述累加步长信息,确定所述第一地址信息,并基于所述第一地址信息执行所述第一计算指令。In a second aspect, an embodiment of the present disclosure provides an instruction processing method, including: obtaining a first computing instruction to be processed; determining the addressing of the first address information of the first access data corresponding to the first computing instruction Mode; wherein, the first memory access data includes the operand and/or the calculation result of the operand used to execute the first calculation instruction; in the case where the addressing mode is an address accumulation mode, based on the The first calculation instruction obtains the cumulative step size information, and obtains the second address information of the second access data corresponding to the second calculation instruction; wherein, the second calculation instruction is a previous instruction of the first calculation instruction; The first address information is determined based on the second address information and the accumulation step information, and the first calculation instruction is executed based on the first address information.
第三方面,本公开实施例提供了一种指令处理装置,包括:第一获取单元,用于获取待处理的第一计算指令;确定单元,用于确定所述第一计算指令所对应的第一访存数据的第一地址信息的寻址模式;其中,所述第一访存数据包括用于执行所述第一计算指令的操作数和/或操作数的计算结果;第二获取单元,用于在所述寻址模式为地址累加模式的情况下,基于所述第一计算指令获取累加步长信息,并获取第二计算指令所对应的第二访存数据的第二地址信息;其中,所述第二计算指令为所述第一计算指令的上一条指令;指令执行单元,用于基于所述第二地址信息和所述累加步长信息,确定所述第一地址信息,并基于所述第一地址信息执行所述第一计算指令。In a third aspect, an embodiment of the present disclosure provides an instruction processing device, including: a first acquiring unit, configured to acquire a first computing instruction to be processed; a determining unit, configured to determine a first computing instruction corresponding to the first computing instruction An addressing mode of the first address information of the access data; wherein, the first access data includes the operand and/or the calculation result of the operand used to execute the first calculation instruction; the second acquisition unit, It is used to obtain the accumulation step size information based on the first calculation instruction when the addressing mode is the address accumulation mode, and obtain the second address information of the second memory access data corresponding to the second calculation instruction; wherein , the second calculation instruction is the previous instruction of the first calculation instruction; the instruction execution unit is configured to determine the first address information based on the second address information and the accumulation step information, and based on The first address information executes the first calculation instruction.
第四方面,本公开实施例还提供一种芯片,包括上述第一方面中任一项所述的指令处理装置。In a fourth aspect, an embodiment of the present disclosure further provides a chip, including the instruction processing device described in any one of the above first aspects.
第五方面,本公开实施例还提供一种电子设备,包括处理器、存储器和总线,所述存储器存储有所述处理器可执行的机器可读指令,当所述电子设备运行时,所述处理器与所述存储器之间通过所述总线通信,所述机器可读指令被所述处理器执行时实现上述第二方面中任一项所述的指令处理方法的步骤。In a fifth aspect, an embodiment of the present disclosure further provides an electronic device, including a processor, a memory, and a bus, the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the The processor communicates with the memory through the bus, and when the machine-readable instructions are executed by the processor, the steps of the instruction processing method described in any one of the above-mentioned second aspects are implemented.
第六方面,本公开实施例还提供一种电子设备,包括上述第四方面所述的芯片。In a sixth aspect, an embodiment of the present disclosure further provides an electronic device, including the chip described in the fourth aspect.
第七方面,本公开实施例还提供一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器运行时执行上述第二方面中任一项所述的指令处理方法的步骤。In the seventh aspect, the embodiments of the present disclosure further provide a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is run by a processor, it executes any one of the above-mentioned second aspects. Steps of the instruction processing method described above.
为使本公开的上述目的、特征和优点能更明显易懂,下文特举较佳实施例,并配合所附附图,作详细说明如下。In order to make the above-mentioned objects, features and advantages of the present disclosure more comprehensible, preferred embodiments will be described in detail below together with the accompanying drawings.
附图说明Description of drawings
为了更清楚地说明本公开实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍。这些附图示出了符合本公开的实施例,并与说明书一起用于说明本公开的技术方案。应当理解,以下附图仅示出了本公开的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following will briefly introduce the drawings required in the embodiments. These drawings show embodiments consistent with the present disclosure, and are used together with the description to explain the technical solution of the present disclosure. It should be understood that the following drawings only show some embodiments of the present disclosure, and therefore should not be regarded as limiting the scope. For those skilled in the art, they can also make From these drawings other related drawings are obtained.
图1示出了本公开实施例所提供的一种指令处理方法的流程图;FIG. 1 shows a flowchart of an instruction processing method provided by an embodiment of the present disclosure;
图2示出了本公开实施例所提供的指令处理方法中确定所述第一计算指令所对应的第一访存数据的第一地址信息的寻址模式的具体方法的流程图;Fig. 2 shows a flow chart of a specific method for determining the addressing mode of the first address information of the first access data corresponding to the first calculation instruction in the instruction processing method provided by the embodiment of the present disclosure;
图3示出了本公开实施例所提供的另一种指令处理方法的流程图;FIG. 3 shows a flowchart of another instruction processing method provided by an embodiment of the present disclosure;
图4示出了本公开实施例所提供的第一种指令处理装置的结构示意图;FIG. 4 shows a schematic structural diagram of a first instruction processing device provided by an embodiment of the present disclosure;
图5示出了本公开实施例所提供的第二种指令处理装置的结构示意图;FIG. 5 shows a schematic structural diagram of a second instruction processing device provided by an embodiment of the present disclosure;
图6示出了本公开实施例所提供的第三种指令处理装置的结构示意图;FIG. 6 shows a schematic structural diagram of a third instruction processing device provided by an embodiment of the present disclosure;
图7示出了本公开实施例所提供的第一种指令处理装置的指令处理流程的示意图;Fig. 7 shows a schematic diagram of the instruction processing flow of the first instruction processing device provided by the embodiment of the present disclosure;
图8示出了本公开实施例所提供的第二种指令处理装置的指令处理流程的示意图;FIG. 8 shows a schematic diagram of an instruction processing flow of a second instruction processing apparatus provided by an embodiment of the present disclosure;
图9示出了本公开实施例所提供的一种指令处理装置的示意图;FIG. 9 shows a schematic diagram of an instruction processing device provided by an embodiment of the present disclosure;
图10示出了本公开实施例所提供的一种电子设备的示意图。Fig. 10 shows a schematic diagram of an electronic device provided by an embodiment of the present disclosure.
具体实施方式Detailed ways
为使本公开实施例的目的、技术方案和优点更加清楚,下面将结合本公开实施例中附图,对本公开实施例中的技术方案进行清楚、完整地描述。所描述的实施例仅仅是本公开一部分实施例,而不是全部的实施例。通常在此处附图中描述和示出的本公开实施例的组件可以以各种不同的配置来布置和设计。因此,以下对在附图中提供的本公开的实施例的详细描述无意限制要求保护的本公开的范围。基于本公开的实施例,本领域技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本公开保护的范围。In order to make the purpose, technical solutions and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. The described embodiments are only some of the embodiments of the present disclosure, not all of them. The components of the disclosed embodiments generally described and illustrated in the figures herein may be arranged and designed in a variety of different configurations. Accordingly, the following detailed description of embodiments of the present disclosure provided in the accompanying drawings is not intended to limit the scope of the claimed disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without creative effort shall fall within the protection scope of the present disclosure.
应注意到,相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释。It should be noted that like numerals and letters denote similar items in the following figures, therefore, once an item is defined in one figure, it does not require further definition and explanation in subsequent figures.
本文中术语“和/或”,仅仅是描述一种关联关系,表示可以存在三种关系,例如,A和/或B,可以表示单独存在A,同时存在A和B,单独存在B这三种情况。另外,本文中术语“至少一种”表示多种中的任意一种或多种中的至少两种的任意组合,例如,包括A、B、C中的至少一种,可以表示包括从A、B和C构成的集合中选择的任意一个或多个元素。The term "and/or" in this article only describes an association relationship, which means that there may be three kinds of relationships. For example, A and/or B may mean that A exists alone, A and B exist simultaneously, and B exists alone. Condition. In addition, the term "at least one" herein means any one of a variety or any combination of at least two of the more, for example, including at least one of A, B, and C, which may mean including from A, Any one or more elements selected from the set formed by B and C.
计算机指令的执行主要包括对存储空间的访问和对数据的计算,其中,存储空间访问的形式包括立即数直接寻址和利用运算结果的间接寻址。间接寻址方式需要实时计算地址的值,因此,间接寻址方式带来了额外的指令周期,从而影响了指令的执行效率。The execution of computer instructions mainly includes access to storage space and calculation of data, wherein the form of storage space access includes direct addressing of immediate data and indirect addressing using operation results. The indirect addressing mode needs to calculate the value of the address in real time. Therefore, the indirect addressing mode brings extra instruction cycles, thereby affecting the execution efficiency of the instruction.
基于上述研究,本公开提供了一种指令处理方法。在本公开实施例中,在获取到第一计算指令之后,可以确定第一计算指令所对应的第一访存数据的第一地址信息的寻址模式。在寻址模式为地址累加模式的情况下,可以基于第一计算指令获取累加步长信息,并获取第二计算指令所对应的第二访存数据的第二地址信息,进而基于该第二地址信息和累加步长信息确定第一地址信息,并基于第一地址信息执行所述第一计算指令。在本公开实施例中,在获取到第一计算指令之后,通过地址累加模式确定第一计算指令的第一访存数据的第一地址信息,可以将第一地址信息的确定过程隐藏在第一计算指令的指令处理过程,从而减少了额外的指令周期,进而加快了指令的执行效率。Based on the above research, the present disclosure provides an instruction processing method. In the embodiment of the present disclosure, after the first calculation instruction is acquired, the addressing mode of the first address information of the first access data corresponding to the first calculation instruction may be determined. When the addressing mode is the address accumulation mode, the accumulation step information can be obtained based on the first calculation instruction, and the second address information of the second access data corresponding to the second calculation instruction can be obtained, and then based on the second address information and accumulation step information determine first address information, and execute the first calculation instruction based on the first address information. In the embodiment of the present disclosure, after the first calculation instruction is obtained, the first address information of the first access data of the first calculation instruction is determined through the address accumulation mode, and the determination process of the first address information can be hidden in the first The instruction processing process of the calculation instruction reduces the extra instruction cycle, thereby speeding up the execution efficiency of the instruction.
为便于对本实施例进行理解,首先对本公开实施例所公开的一种指令处理方法进行详细介绍。本公开实施例所提供的指令处理方法的执行主体一般为具有一定计算能力的电子设备。In order to facilitate the understanding of this embodiment, a method for processing instructions disclosed in this embodiment of the present disclosure is first introduced in detail. The execution subject of the instruction processing method provided by the embodiments of the present disclosure is generally an electronic device with a certain computing capability.
参见图1所示,为本公开实施例提供的指令处理方法的流程图,所述方法包括步骤S101~S107。Referring to FIG. 1 , which is a flowchart of an instruction processing method provided by an embodiment of the present disclosure, the method includes steps S101 to S107.
S101:获取待处理的第一计算指令。S101: Acquire a first computing instruction to be processed.
在本公开实施例中,可以从指令寄存器中获取待处理的第一计算指令。这里,第一计算指令可以是任意类型的计算指令,例如,乘累加指令macc,本公开对此不作具体限定。In the embodiment of the present disclosure, the first calculation instruction to be processed may be obtained from the instruction register. Here, the first calculation instruction may be any type of calculation instruction, for example, a multiply-accumulate instruction macc, which is not specifically limited in the present disclosure.
S103:确定所述第一计算指令所对应的第一访存数据的第一地址信息的寻址模式;其中,所述第一访存数据包括用于执行所述第一计算指令的操作数和/或操作数的计算结果。S103: Determine the addressing mode of the first address information of the first memory access data corresponding to the first calculation instruction; wherein the first memory access data includes an operand and an operand used to execute the first calculation instruction /or the result of the computation of the operand.
这里,寻址模式包含地址累加模式和直接寻址模式。其中,地址累加模式可以理解为在指令执行过程中,按照预设累加算法确定第一访存数据在存储装置中的第一地址信息(访问地址信息和/或存储地址信息)。直接寻址模式可以理解为在执行指令过程中, 基于第一计算指令中的地址字段获取该第一访存数据在存储装置中的第一地址信息(访问地址信息和/或存储地址信息)。其中,该存储装置可以为该指令处理装置的内部存储装置中的内存和寄存器堆,还可以为该指令处理装置的外部存储装置。Here, the addressing mode includes an address accumulation mode and a direct addressing mode. Wherein, the address accumulation mode can be understood as determining the first address information (access address information and/or storage address information) of the first memory access data in the storage device according to a preset accumulation algorithm during instruction execution. The direct addressing mode can be understood as obtaining the first address information (access address information and/or storage address information) of the first access data in the storage device based on the address field in the first calculation instruction during the execution of the instruction. Wherein, the storage device may be a memory and a register file in an internal storage device of the instruction processing device, or may be an external storage device of the instruction processing device.
在本公开实施例中,可以基于第一计算指令的指令内容确定第一访存数据的第一地址信息的寻址模式。具体实施时,可以基于第一计算指令中的指定数据位确定第一访存数据的第一地址信息的寻址模式是地址累加模式,还是直接寻址模式。In the embodiment of the present disclosure, the addressing mode of the first address information of the first access data may be determined based on the instruction content of the first calculation instruction. During specific implementation, it may be determined based on the specified data bit in the first computing instruction whether the addressing mode of the first address information of the first access data is an address accumulation mode or a direct addressing mode.
S105:在所述寻址模式为地址累加模式的情况下,基于所述第一计算指令获取累加步长信息,并获取第二计算指令所对应的第二访存数据的第二地址信息;其中,所述第二计算指令为所述第一计算指令的上一条指令。S105: If the addressing mode is an address accumulation mode, obtain accumulation step information based on the first calculation instruction, and obtain second address information of the second memory access data corresponding to the second calculation instruction; wherein , the second calculation instruction is a previous instruction of the first calculation instruction.
在本公开实施例中,第二计算指令为紧挨第一计算指令之前执行的上一条指令。这里,第二地址信息为第二计算指令对应的第二访存数据在指令处理装置的存储装置中的地址信息(访问地址信息和/或存储地址信息)。这里,第二访存数据包括用于执行第二计算指令的操作数(operand)和/或该操作数的计算结果。In the embodiment of the present disclosure, the second calculation instruction is a previous instruction executed immediately before the first calculation instruction. Here, the second address information is address information (access address information and/or storage address information) of the second memory access data corresponding to the second calculation instruction in the storage device of the instruction processing device. Here, the second memory access data includes an operand (operand) for executing the second calculation instruction and/or a calculation result of the operand.
在本文中出现的“操作数”是指运算符作用于的实体,它规定了待处理指令的处理对象。例如,待处理指令为比较指令,在比较指令中操作符指定计算机做比较操作,则操作数指定了进行比较的两个数值。The "operand" in this article refers to the entity that the operator acts on, which specifies the processing object of the instruction to be processed. For example, the instruction to be processed is a comparison instruction, in which the operator specifies the computer to perform a comparison operation, and the operand specifies two values to be compared.
发明人发现,对于高性能计算场景,多条指令的数据访问地址往往具有一定的关联性,例如,地址往往以一个固定的步长递增。基于此,在本公开实施例中,可以预先设定一个累加步长信息。这里,累加步长信息的确定与第一访存数据在指令处理装置的存储装置中的存储位置相关联。The inventors found that for high-performance computing scenarios, the data access addresses of multiple instructions often have a certain correlation, for example, the addresses are often incremented by a fixed step size. Based on this, in the embodiment of the present disclosure, information of an accumulation step size may be preset. Here, the determination of the accumulation step size information is associated with the storage location of the first memory access data in the storage device of the instruction processing device.
S107:基于所述第二地址信息和所述累加步长信息,确定所述第一地址信息,并基于所述第一地址信息执行所述第一计算指令。S107: Determine the first address information based on the second address information and the accumulation step information, and execute the first calculation instruction based on the first address information.
在确定出第二地址信息和累加步长信息之后,可以对第二地址信息和累加步长信息进行累加计算,得到第一地址信息。After the second address information and the accumulation step information are determined, an accumulation calculation may be performed on the second address information and the accumulation step information to obtain the first address information.
下面,以卷积运算中的点积运算为例,对现有技术中存在的间接寻址方式带来了额外的指令周期的问题来进行说明。Next, taking the dot product operation in the convolution operation as an example, the problem of extra instruction cycles brought by the indirect addressing mode in the prior art will be described.
假设输入数据分别x=[a1,a2,a3],y=[b1,b2,b3],令向量x存储至存储空间0至2,y存至存储空间3至5,那么对应点积计算的程序如下:Assuming that the input data are respectively x=[a1, a2, a3], y=[b1, b2, b3], let the vector x be stored in the storage space 0 to 2, and y be stored in the storage space 3 to 5, then the corresponding dot product calculation The procedure is as follows:
Figure PCTCN2022124520-appb-000001
Figure PCTCN2022124520-appb-000001
在上述程序代码中,macc为乘累加指令。针对上述for循环指令,在每次执行乘累加指令macc的过程中,都要执行以下指令“x_addr=x_addr+1”和“y_addr=y_addr+1”。因此,针对for循环指令的每个循环过程,需要发出并执行上述3个指令才能实现乘累加指令macc的功能,此时,将消耗3个指令周期。针对处理性能要求较高的指令处理装置,通过3个指令周期实现一个指令的功能将会降低该指令处理装置的处理性能。In the above program code, macc is a multiply-accumulate instruction. For the above-mentioned for loop instruction, the following instructions "x_addr=x_addr+1" and "y_addr=y_addr+1" must be executed during each execution of the multiply-accumulate instruction macc. Therefore, for each loop process of the for loop instruction, the above three instructions need to be issued and executed to realize the function of the multiply-accumulate instruction macc, and at this time, three instruction cycles will be consumed. For an instruction processing device with high processing performance requirements, implementing the function of one instruction through three instruction cycles will reduce the processing performance of the instruction processing device.
在本公开实施例中,在获取到第一计算指令之后,可以确定第一计算指令所对应的第一访存数据的第一地址信息的寻址模式。在寻址模式为地址累加模式的情况下,可以基于第一计算指令获取累加步长信息,并获取第二计算指令所对应的第二访存数据的第二地址信息,进而基于该第二地址信息和累加步长信息确定第一地址信息,并基于第一地址信息执行所述第一计算指令。在本公开实施例中,在获取到第一计算指令之后,通 过地址累加模式确定第一计算指令的第一访存数据的第一地址信息,可以将第一地址信息的确定过程隐藏在第一计算指令的指令处理过程,从而减少了额外的指令周期,进而加快了指令的执行效率。In the embodiment of the present disclosure, after the first calculation instruction is acquired, the addressing mode of the first address information of the first access data corresponding to the first calculation instruction may be determined. When the addressing mode is the address accumulation mode, the accumulation step information can be obtained based on the first calculation instruction, and the second address information of the second access data corresponding to the second calculation instruction can be obtained, and then based on the second address information and accumulation step information determine first address information, and execute the first calculation instruction based on the first address information. In the embodiment of the present disclosure, after the first calculation instruction is obtained, the first address information of the first access data of the first calculation instruction is determined through the address accumulation mode, and the determination process of the first address information can be hidden in the first The instruction processing process of the calculation instruction reduces the extra instruction cycle, thereby speeding up the execution efficiency of the instruction.
下面将结合具体实施方式对上述指令处理方法进行介绍。The above instruction processing method will be introduced below in combination with specific implementation manners.
在本公开实施例中,首先,从指令寄存器中获取待处理的第一计算指令,然后,确定第一计算指令所对应的第一访存数据的第一地址信息的寻址模式。In the embodiment of the present disclosure, firstly, the first calculation instruction to be processed is obtained from the instruction register, and then the addressing mode of the first address information of the first memory access data corresponding to the first calculation instruction is determined.
在一个可选的实施方式中,如图2所示,上述步骤S103:确定所述第一计算指令所对应的第一访存数据的第一地址信息的寻址模式,具体包括如下步骤:In an optional implementation manner, as shown in FIG. 2, the above step S103: determining the addressing mode of the first address information of the first memory access data corresponding to the first computing instruction, specifically includes the following steps:
S1031:确定所述第一计算指令中的第一使能标识,其中,所述第一使能标识用于指示针对所述第一访存数据的地址累加模式是否使能有效;S1031: Determine a first enable flag in the first calculation instruction, where the first enable flag is used to indicate whether the address accumulation mode for the first memory access data is enabled and valid;
S1032:基于所述第一使能标识确定所述第一计算指令所对应的第一访存数据的第一地址信息的寻址模式。S1032: Determine an addressing mode of the first address information of the first memory access data corresponding to the first computing instruction based on the first enabling flag.
在本公开实施例中,可以在第一计算指令的各个数据位中确定包含第一使能标识的指定数据位,并将该指定数据位的数值确定为第一使能标识。In an embodiment of the present disclosure, a specified data bit including the first enable flag may be determined in each data bit of the first calculation instruction, and the value of the specified data bit is determined as the first enable flag.
具体实施时,在第一使能标识为第一数值的情况下,可以确定第一访存数据的地址累加模式使能有效;在第一使能标识为第二数值的情况下,可以确定第一访存数据的地址累加模式使能禁止。During specific implementation, when the first enabling flag is the first numerical value, it can be determined that the address accumulation mode of the first memory access data is enabled; when the first enabling flag is the second numerical value, it can be determined that the first 1. The address accumulation mode of accessing data is enabled and disabled.
这里,第一数值和第二数值可以根据实际需要来进行设定,本公开对此不作具体限定。例如,第一数值可以设置为“1”,表示第一访存数据的地址累加模式使能有效;第二数值可以设置为“0”,表示第一访存数据的地址累加模式使能禁止。Here, the first value and the second value may be set according to actual needs, which is not specifically limited in the present disclosure. For example, the first value can be set to "1", indicating that the address accumulation mode of the first memory access data is enabled; the second value can be set to "0", indicating that the address accumulation mode of the first memory access data is enabled and disabled.
在本示例中,以第一使能标识对应一个指定数据位为例进行说明,然而,在第一使能标识包括多个第一子使能标识的情况下(其中,每个子使能标识对应第一访存数据的一个数据),第一使能标识可以对应多个指定数据位,将在后续实施例中进行描述。In this example, the first enabling flag corresponds to a specified data bit as an example for illustration, however, in the case where the first enabling flag includes multiple first sub-enabling flags (wherein, each sub-enabling flag corresponds to One data of the first access data), the first enable flag may correspond to multiple specified data bits, which will be described in subsequent embodiments.
在本公开实施例中,在获取到第一计算指令之后,可以获取该第一计算指令中的指定数据位的数值,进而根据该指定数据位的数值确定第一使能标识。在获取到该第一使能标识之后,可以基于该第一使能标识确定针对第一访存数据的地址累加模式是否使能有效。In the embodiment of the present disclosure, after the first calculation instruction is obtained, the value of the designated data bit in the first calculation instruction may be obtained, and then the first enabling flag is determined according to the value of the designated data bit. After the first enabling flag is acquired, it may be determined based on the first enabling flag whether the address accumulation mode for the first memory access data is enabled and valid.
在确定出地址累加模式使能有效的情况下,可以确定针对第一访存数据的第一地址信息的寻址模式为地址累加模式;在确定出地址累加模式使能禁止的情况下,可以确定针对第一访存数据的第一地址信息的寻址模式为非地址累加模式(例如,直接寻址模式)。When it is determined that the address accumulation mode is enabled and valid, it can be determined that the addressing mode for the first address information of the first memory access data is the address accumulation mode; when it is determined that the address accumulation mode is enabled and disabled, it can be determined that The addressing mode for the first address information of the first access data is a non-address accumulation mode (for example, a direct addressing mode).
在上述实施方式中,通过在第一计算指令中确定第一使能标识,进而根据该第一使能标识确定第一访存数据的第一地址信息的寻址模式,可以实现将第一地址信息的确定过程隐藏在第一计算指令的指令处理过程,从而减少了额外的指令周期,进而加快了指令的执行效率。In the above embodiment, by determining the first enable flag in the first calculation instruction, and then determining the addressing mode of the first address information of the first access data according to the first enable flag, it can be realized that the first address The determination process of the information is hidden in the instruction processing process of the first calculation instruction, thereby reducing the extra instruction cycle, thereby speeding up the execution efficiency of the instruction.
在确定出第一访存数据的第一地址信息的寻址模式之后,可以基于该寻址模式确定该第一访存数据的第一地址信息(即,上述第一地址信息),下面分情况进行介绍。After determining the addressing mode of the first address information of the first access data, the first address information of the first access data (that is, the above-mentioned first address information) can be determined based on the addressing mode, the following cases Make an introduction.
情况一:寻址模式为地址累加模式。Case 1: The addressing mode is the address accumulation mode.
在寻址模式为地址累加模式的情况下,可以基于第一计算指令的指令内容获取累加步长信息。When the addressing mode is the address accumulation mode, the accumulation step size information may be acquired based on the instruction content of the first calculation instruction.
具体实施时,可以基于第一计算指令的指令内容在寄存器堆或者指令编码中获取累加步长信息,下面将对这两种方式分别进行介绍。During specific implementation, the accumulative step size information can be obtained in the register file or in the instruction code based on the instruction content of the first calculation instruction, and the two methods will be introduced respectively below.
方式一:基于寄存器堆的方式。Method 1: The method based on the register file.
在寻址模式为地址累加模式的情况下,第一计算指令的指令内容中包含寄存器堆中存储该累加步长信息的寄存器的索引标识。在此情况下,可以基于该索引标识读取对应寄存器中的数据,并将读取到的数据确定为累加步长信息。When the addressing mode is the address accumulation mode, the instruction content of the first calculation instruction includes an index identifier of a register in the register file storing the accumulation step information. In this case, the data in the corresponding register may be read based on the index identifier, and the read data may be determined as the accumulative step size information.
方式二:基于指令编码的方式。Method 2: A method based on instruction encoding.
在寻址模式为地址累加模式的情况下,第一计算指令的指令内容中包含累加步长信息。在此情况下,可以直接根据第一计算指令的指令内容确定累加步长信息。When the addressing mode is the address accumulation mode, the instruction content of the first calculation instruction includes accumulation step size information. In this case, the accumulative step size information can be directly determined according to the instruction content of the first calculation instruction.
在按照上述方式一和方式二所描述的方式确定出累加步长信息之后,可以获取执行第二计算指令过程中所使用的操作数的第二地址信息,并基于所述第二地址信息和所述累加步长信息,确定第一地址信息,进而基于所述第一地址信息执行所述第一计算指令。After determining the accumulative step size information in the manners described above in the first and second ways, the second address information of the operand used in the execution of the second calculation instruction can be obtained, and based on the second address information and the The accumulation step information is used to determine first address information, and then the first calculation instruction is executed based on the first address information.
情况二:寻址模式为直接寻址模式。Case 2: The addressing mode is direct addressing mode.
在所述寻址模式为直接寻址模式的情况下,获取所述第一计算指令中的地址字段中的字段内容;并基于获取到的所述字段内容确定所述第一访存数据的第一地址信息。In the case where the addressing mode is the direct addressing mode, obtaining the field content in the address field in the first computing instruction; and determining the first access data of the first memory based on the obtained field content 1. Address information.
在本公开实施例中,在寻址模式为直接寻址模式的情况下,可以基于第一计算指令中地址字段的字段内容获取第一访存数据的第一地址信息(即,上述第一地址信息)。In the embodiment of the present disclosure, when the addressing mode is the direct addressing mode, the first address information of the first fetched data (that is, the above-mentioned first address information).
具体实施时,可以基于第一计算指令中地址字段的字段内容在寄存器堆或者指令编码中获取第一访存数据的第一地址信息,下面将对这两种方式分别进行介绍。During specific implementation, the first address information of the first memory access data can be obtained in the register file or in the instruction code based on the field content of the address field in the first computing instruction, and the two methods will be introduced respectively below.
方式一:基于寄存器堆的方式。Method 1: The method based on the register file.
在寻址模式为直接寻址模式的情况下,第一计算指令中地址字段的字段内容中包含寄存器堆中存储该第一地址信息的寄存器的索引标识。在此情况下,可以基于该索引标识读取对应寄存器中的第一地址信息。In the case that the addressing mode is the direct addressing mode, the field content of the address field in the first computing instruction includes the index identifier of the register storing the first address information in the register file. In this case, the first address information in the corresponding register can be read based on the index identifier.
方式二:基于指令编码的方式。Method 2: A method based on instruction encoding.
在寻址模式为直接寻址模式的情况下,第一计算指令中地址字段的字段内容中包含第一访存数据的第一地址信息。在此情况下,可以直接根据第一计算指令中地址字段的字段内容确定第一访存数据的第一地址信息。When the addressing mode is the direct addressing mode, the field content of the address field in the first calculation instruction includes the first address information of the first memory access data. In this case, the first address information of the first fetched data can be determined directly according to the field content of the address field in the first calculation instruction.
在按照上述方式一或方式二确定出第一访存数据的第一地址信息之后,可以基于所述第一地址信息执行所述第一计算指令。After the first address information of the first access data is determined according to the above-mentioned manner 1 or manner 2, the first calculation instruction may be executed based on the first address information.
举例来说,第一计算指令的指令形式可以为opcal(addr1/dlt1=a,addr2/dlt2=b,addr3/dlt3=c),其中,opcal为上述第一计算指令,(addr1/dlt1,addr2/dlt2,addr3/dlt3)为第一计算指令的部分指令内容。其中,addr1/dlt1和addr2/dlt2为用于确定第一访存数据中操作数的访问信息(例如,操作数的访问地址)的指令内容,addr3/dlt3为用于确定第一访存数据的计算结果的存储信息(例如,计算结果的存储地址)的指令内容。For example, the instruction form of the first calculation instruction may be opcal(addr1/dlt1=a, addr2/dlt2=b, addr3/dlt3=c), wherein, opcal is the above-mentioned first calculation instruction, (addr1/dlt1, addr2 /dlt2, addr3/dlt3) are part of the instruction content of the first calculation instruction. Among them, addr1/dlt1 and addr2/dlt2 are the instruction contents used to determine the access information (for example, the access address of the operand) of the operand in the first memory access data, and addr3/dlt3 are used to determine the first memory access data. The instruction content of the storage information of the calculation result (for example, the storage address of the calculation result).
在寻址模式为地址累加模式的情况下,第一计算指令的部分指令内容中包含以下信息(dlt1=a1,dlt2=b1,dlt3=c1),其中,dlt1,dlt2,dlt3可以表示为第一使能标识使能有效,a1,b1,c1可以为累加步长信息,还可以表示为寄存器堆中存储有该累加步长信息的寄存器的索引标识。In the case that the addressing mode is the address accumulation mode, the following information (dlt1=a1, dlt2=b1, dlt3=c1) is contained in the part of the instruction content of the first calculation instruction, wherein, dlt1, dlt2, dlt3 can be expressed as the first The enable flag is enabled and valid, and a1, b1, and c1 may be accumulation step information, and may also be expressed as index identifiers of registers storing the accumulation step information in the register file.
在寻址模式为直接寻址模式的情况下,第一计算指令的部分指令内容中包含以下信息(addr1=a2,addr2=b2,addr3=c2),其中,addr1,addr2,addr3可以表示为第一使能标识使能禁止,a2,b2,c2可以为第一访存数据的第一地址信息,还可以表示为寄存器堆中存储第一访存数据的第一地址信息的寄存器的索引标识。In the case that the addressing mode is the direct addressing mode, the following information (addr1=a2, addr2=b2, addr3=c2) is included in the part of the instruction content of the first calculation instruction, wherein, addr1, addr2, addr3 can be expressed as the first An enable flag enables and disables, a2, b2, c2 can be the first address information of the first memory access data, and can also be expressed as index marks of registers storing the first address information of the first memory access data in the register file.
在一个可选的实施方式中,第一使能标识包括多个第一子使能标识;每个所述第一子使能标识对应所述第一访存数据中的一个数据。In an optional implementation manner, the first enabling flag includes a plurality of first sub-enabling flags; each of the first sub-enabling flags corresponds to one data in the first access data.
以第一计算指令opcal(addr1/dlt1=a,addr2/dlt2=b,addr3/dlt3=c)为例来进行说明,其中,addr/dlt即为上述第一使能标识,addr表示为第一使能标识使能禁止,dlt表示为第一使能标识使能有效。Take the first calculation instruction opcal (addr1/dlt1=a, addr2/dlt2=b, addr3/dlt3=c) as an example for illustration, where addr/dlt is the above-mentioned first enabling flag, and addr represents the first The enable flag is enabled and disabled, and dlt indicates that the first enable flag is enabled and valid.
addr1/dlt1,addr2/dlt2和addr3/dlt3为上述多个第一子使能标识,其中,第一子使能标识addr1/dlt1用于指示操作数1的访问地址的寻址模式,第一子使能标识addr2/dlt2用于指示操作数2的访问地址的寻址模式,第一子使能标识addr3/dlt3用于指示第一计算指令的操作数的计算结果的存储地址的寻址模式。addr1/dlt1, addr2/dlt2 and addr3/dlt3 are the above-mentioned multiple first sub-enabling identifiers, wherein the first sub-enabling identifier addr1/dlt1 is used to indicate the addressing mode of the access address of operand 1, and the first sub-enabling identifier The enable flag addr2/dlt2 is used to indicate the addressing mode of the access address of operand 2, and the first sub-enable flag addr3/dlt3 is used to indicate the addressing mode of the storage address of the calculation result of the operand of the first calculation instruction.
在此情况下,上述步骤S1032:基于所述第一使能标识确定所述第一计算指令所对应的第一访存数据的第一地址信息的寻址模式,包括如下步骤:In this case, the above step S1032: determining the addressing mode of the first address information of the first access data corresponding to the first calculation instruction based on the first enabling flag includes the following steps:
在所述多个第一子使能标识中确定与所述第一访存数据中的每个数据相匹配的第一子使能标识;determining, among the plurality of first sub-enabling identifiers, a first sub-enabling identifier that matches each data in the first memory access data;
基于与所述第一访存数据中的每个数据相匹配的第一子使能标识,确定所述第一计算指令所对应的第一访存数据中的每个数据的第一地址信息的寻址模式。Based on the first sub-enabling identifier that matches each data in the first memory access data, determine the first address information of each data in the first memory memory data corresponding to the first calculation instruction addressing mode.
应理解的是,上述第一使能标识可以包含多个第一子使能标识,每个第一子使能标识用于指示第一访存数据中的每个数据的第一地址信息的寻址模式。这里,第一访存数据中的每个数据可以理解为用于执行该第一计算指令的每个操作数和/或该操作数的计算结果。It should be understood that the above-mentioned first enablement flag may include a plurality of first sub-enablement flags, and each first sub-enablement flag is used to indicate the first address information of each data in the first access data. address mode. Here, each data in the first fetch data can be understood as each operand used to execute the first calculation instruction and/or the calculation result of the operand.
也就是说,每个操作数和/或该操作数的计算结果的第一地址信息的寻址模式可以相同,还可以不相同,本公开对此不作具体限定。That is to say, the addressing modes of the first address information of each operand and/or the calculation result of the operand may be the same or different, which is not specifically limited in the present disclosure.
这里,针对操作数来说,该第一地址信息可以理解为该操作数的读取地址(也即,下述第一访问地址);针对操作数的计算结果来说,该第一地址信息可以理解为计算结果的存储位置(也即,下述第一存储地址)。Here, for the operand, the first address information can be understood as the read address of the operand (that is, the first access address described below); for the calculation result of the operand, the first address information can be It is understood as the storage location of the calculation result (that is, the first storage address described below).
在一个第一计算指令中,各个操作数和操作数的计算结果的第一地址信息的寻址模式可以不完全相同,此时,针对每个操作数据和操作数的计算结果,可以根据对应的寻址模式确定第一地址信息。In a first calculation instruction, the addressing modes of the first address information of each operand and the calculation result of the operand may not be completely the same. At this time, for each operation data and calculation result of the operand, the corresponding The addressing mode determines first address information.
具体实施时,可以在多个第一子使能标识中确定与所述第一访存数据中的每个数据相匹配的第一子使能标识,进而根据匹配到的第一子使能标识的标识内容(addr1/dlt1)确定对应数据的第一地址信息的寻址模式是否为地址累加模式。During specific implementation, the first sub-enabling identifier that matches each data in the first memory access data may be determined among the plurality of first sub-enabling identifiers, and then according to the matched first sub-enabling identifier The identification content (addr1/dlt1) of determines whether the addressing mode of the first address information corresponding to the data is an address accumulation mode.
在上述实施方式中,通过为第一访存数据中的每个数据(即,操作数和操作数的计算结果)均设置对应的第一子使能标识,并根据第一子使能标识控制每个数据的第一地址信息的方式,可以扩展该技术方案适用场景,从而满足程序员的编程需求。In the above embodiment, by setting a corresponding first sub-enabling flag for each data in the first access data (that is, the operand and the calculation result of the operand), and controlling the operation according to the first sub-enabling flag The manner of the first address information of each data can expand the application scenarios of the technical solution, thereby satisfying the programming requirements of programmers.
在上述图2所描述的实施方式的基础上,如图3所示,本公开实施例所提供的方法还包括如下步骤:On the basis of the implementation described in FIG. 2 above, as shown in FIG. 3 , the method provided by the embodiment of the present disclosure further includes the following steps:
S301:在确定所述第一使能标识为使能有效之后,在所述第二计算指令中检测第二使能标识;其中,所述第二使能标识用于指示所述第一计算指令中的第一使能标识所指示的地址累加模式是否使能有效;S301: After determining that the first enabling flag is valid, detect a second enabling flag in the second computing instruction; wherein the second enabling flag is used to indicate the first computing instruction Whether the address accumulation mode indicated by the first enabling flag in is enabled and valid;
S302:基于所述第二使能标识确定所述第一计算指令所对应的第一访存数据的第一地址信息。S302: Determine first address information of first memory access data corresponding to the first computing instruction based on the second enabling flag.
对于高性能计算场景,往往需要多重循环实现计算过程。针对每一层循环过程的程序,包含初始指令和循环指令;其中,初始指令用于给定初始地址。假设循环指令为循环执行N次的指令,如果针对第一条循环指令中设置了地址累加模式使能有效,那么每次执行该循环时,该第一条循环指令所对应的数据地址信息为基于初始地址的数据地址信息进行地址累加计算之后确定的。这样,就会导致第一条循环指令的数据地址信息出现错误,从而导致获取到错误的操作数,进而严重影响了指令计算结果。For high-performance computing scenarios, multiple loops are often required to implement the computing process. The program for each layer of loop process includes an initial instruction and a loop instruction; wherein, the initial instruction is used to give an initial address. Assuming that the loop instruction is an instruction that loops and executes N times, if the address accumulation mode is enabled for the first loop instruction, then each time the loop is executed, the data address information corresponding to the first loop instruction is based on The data address information of the initial address is determined after address accumulation calculation. In this way, the data address information of the first loop instruction will be wrong, resulting in wrong operands being obtained, which seriously affects the calculation result of the instruction.
基于此,在本公开实施例中,对上述地址累加模式进行了扩展,以使扩展之后的地址累加模式能够更简洁高效地支持循环程序,具体扩展方式为:Based on this, in the embodiment of the present disclosure, the above-mentioned address accumulation mode is extended, so that the extended address accumulation mode can support the loop program more concisely and efficiently. The specific extension method is:
在第一计算指令的上一条指令(即,第二计算指令)中设置第二使能标识,该第二使能标识用于指示第二计算指令的下一条计算指令(也即,第一计算指令)中第一使能标识所指示的地址累加模式是否使能有效。A second enable flag is set in the previous instruction (that is, the second computation instruction) of the first computation instruction, and the second enable flag is used to indicate the next computation instruction (that is, the first computation instruction) of the second computation instruction. instruction) whether the address accumulation mode indicated by the first enable flag is enabled or not.
具体实施时,在第一计算指令中的第一使能标识表示为针对第一访存数据的地址累加模式使能有效的情况下,如果第二计算指令中的第二使能标识为地址累加模式使能禁止,则确定第一计算指令中的第一使能标识所指示的地址累加模式使能禁止。也就是说,即使根据第一计算指令中的第一使能标识确定出寻址模式为地址累加模式,如果第二使能标识为使能禁止,针对第一计算指令中的第一访存数据的寻址模式可以为直接寻址模式,或者,根据第二地址信息确定第一地址信息。During specific implementation, when the first enabling flag in the first calculation instruction indicates that the address accumulation mode for the first memory access data is enabled, if the second enabling flag in the second computing instruction is address accumulation If the mode is enabled and disabled, it is determined that the address accumulation mode indicated by the first enable flag in the first calculation instruction is enabled and disabled. That is to say, even if the addressing mode is determined to be the address accumulation mode according to the first enabling flag in the first calculation instruction, if the second enabling flag is enabled and disabled, the first memory access data in the first computing instruction The addressing mode may be a direct addressing mode, or the first address information is determined according to the second address information.
举例来说,第二计算指令为循环程序中的地址初始化指令,在第一计算指令为循环程序中的第一条循环指令的情况下,此时,可以在第一计算指令中设置第一使能标识为使能有效,并在第二计算指令中设置第二使能标识为使能禁止。此时,针对第一条循环指令,可以通过直接寻址模式确定第一访存数据的第一地址信息,或者,将第二计算指令所对应的第二访存数据的第二地址信息确定为上述第一地址信息。针对循环程序中的其他循环指令,例如,第N条循环指令,N大于1,可以根据第N-1条循环指令中的第二使能标识确定地址累加模式是否使能有效。For example, the second calculation instruction is an address initialization instruction in the cyclic program. In the case that the first calculation instruction is the first loop instruction in the cyclic program, at this time, the first use can be set in the first calculation instruction. The enable flag is valid, and the second enable flag is set in the second calculation instruction as enable and disable. At this time, for the first loop instruction, the first address information of the first memory access data can be determined through the direct addressing mode, or the second address information of the second memory access data corresponding to the second calculation instruction can be determined as The above-mentioned first address information. For other loop instructions in the loop program, for example, the Nth loop instruction, where N is greater than 1, it can be determined whether the address accumulation mode is enabled and valid according to the second enable flag in the N-1th loop instruction.
在本公开实施例中,在第二使能标识为第三数值的情况下,可以确定第二计算指令的下一条计算指令中的第一使能标识所指示的地址累加模式使能有效;在第二使能标识为第四数值的情况下,可以确定第二计算指令的下一条计算指令中的第一使能标识所指示的地址累加模式使能禁止。In the embodiment of the present disclosure, when the second enable flag is the third value, it can be determined that the address accumulation mode indicated by the first enable flag in the next computation instruction of the second computation instruction is enabled; When the second enabling flag is the fourth value, it may be determined that the address accumulation mode indicated by the first enabling flag in the next computing instruction of the second computing instruction is enabled and disabled.
这里,第三数值和第四数值可以根据实际需要来进行设定,本公开对此不作具体限定。例如,第三数值可以设置为“1”,表示使能有效;第四数值可以设置为“0”,表示使能禁止。Here, the third value and the fourth value can be set according to actual needs, which is not specifically limited in the present disclosure. For example, the third numerical value may be set to "1", indicating that enabling is valid; the fourth numerical value may be set as "0", indicating that enabling is disabled.
应理解的是,上述步骤S301和步骤S302所描述的扩展方案不仅可以应用到多重循环的计算过程,还可以应用到其他计算过程,例如,与多重循环的计算过程相似的计算过程,或者,其他需要指定第一计算指令中的第一使能标识所指示的地址累加模式使能禁止的场景,本公开对此不作具体限定,以能够实现为准。It should be understood that the expansion scheme described in the above step S301 and step S302 can not only be applied to the multi-cycle calculation process, but also can be applied to other calculation processes, for example, a calculation process similar to the multi-cycle calculation process, or other It is necessary to specify the scenarios where the address accumulation mode indicated by the first enable flag in the first calculation instruction is enabled and disabled, and this disclosure does not specifically limit this, and the implementation shall prevail.
在一个可选的实施方式中,上述步骤S302:基于所述第二使能标识确定所述第一计算指令所对应的第一访存数据的第一地址信息,具体包括如下步骤:In an optional implementation manner, the above step S302: determining the first address information of the first access data corresponding to the first computing instruction based on the second enabling flag, specifically includes the following steps:
S3021:在确定所述第二使能标识为地址累加模式使能禁止的情况下,确定所述第一计算指令所对应的第一访存数据的第一地址信息为所述第二计算指令所对应的第二访存数据的第二地址信息。S3021: In the case where it is determined that the second enable flag is address accumulation mode enable and disable, determine that the first address information of the first memory access data corresponding to the first calculation instruction is set by the second calculation instruction Corresponding second address information of the second fetched data.
在本公开实施例中,在确定第二使能标识为地址累加模式使能有效的情况下,可以按照地址累加模式确定第一访存数据的第一地址信息。具体实施时,可以基于所述第一计算指令获取累加步长信息,并获取第二计算指令所对应的第二访存数据的第二地址信息;进而基于所述第二地址信息和所述累加步长信息,确定所述第一地址信息,并基于所述第一地址信息执行所述第一计算指令。In the embodiment of the present disclosure, in a case where it is determined that the second enabling flag is valid for enabling the address accumulation mode, the first address information of the first memory access data may be determined according to the address accumulation mode. During specific implementation, the accumulative step size information can be obtained based on the first computing instruction, and the second address information of the second memory access data corresponding to the second computing instruction can be obtained; further, based on the second address information and the accumulating step size information, determining the first address information, and executing the first calculation instruction based on the first address information.
在确定第二使能标识为地址累加模式使能禁止的情况下,可以将第二计算指令所对应的第二访存数据的第二地址信息确定为上述第一地址信息。In a case where it is determined that the second enabling flag is enabling and disabling the address accumulation mode, the second address information of the second memory access data corresponding to the second calculation instruction may be determined as the above-mentioned first address information.
下面以上述实施例中的循环程序为例来进行说明。通过上述描述可知,多重循环程序中的每层循环程序包含初始指令和循环指令。其中,初始指令用于给定初始地址。The following takes the cyclic program in the above-mentioned embodiment as an example for illustration. It can be seen from the above description that each layer of the loop program in the multiple loop program includes an initial instruction and a loop instruction. Among them, the initial instruction is used to give the initial address.
假设第二计算指令为循环程序中的地址初始化指令,在第一计算指令为循环程序中的第一条循环指令的情况下,此时,可以在第二计算指令中设置第二使能标识为使能禁止。此时,针对第一条循环指令,可以将第二计算指令所对应的第二访存数据的第二地址信息确定为上述第一地址信息。例如,将地址初始化指令中的第二地址信息,确定为第一条计算指令的第一地址信息。Assuming that the second calculation instruction is the address initialization instruction in the cyclic program, in the case that the first calculation instruction is the first loop instruction in the cyclic program, at this time, the second enabling flag can be set in the second calculation instruction as Enable and disable. At this time, for the first loop instruction, the second address information of the second memory access data corresponding to the second calculation instruction may be determined as the first address information. For example, the second address information in the address initialization instruction is determined as the first address information of the first calculation instruction.
在本公开实施例中,编程人员可以根据实际需要设定第二使能标识是使能有效,还是使能禁止。通过该处理方式,可以避免第一条循环指令的数据地址信息出现错误,从而能够获取到准确的操作数。同时,通过该处理方式,可以提高用户所编写程序的灵活性,从而满足编程人员的各种编程需求。In the embodiment of the present disclosure, the programmer can set whether the second enabling flag is enabled or disabled according to actual needs. Through this processing method, errors in the data address information of the first loop instruction can be avoided, so that accurate operands can be obtained. At the same time, through this processing method, the flexibility of programs written by users can be improved, so as to meet various programming needs of programmers.
在上述实施方式中,通过在第一计算指令的上一条指令中设置第二使能标识,以根据该第二使能标识确定第一计算指令中的第一使能标识所指示的地址累加模式是否使能有效的方式,可以扩展该本公开技术方案的适用场景,针对多重循环的计算过程,依然可以通过本公开技术方案对计算指令进行处理,从而提高了循环指令的处理效率。In the above embodiment, by setting the second enabling flag in the instruction preceding the first computing instruction, the address accumulation mode indicated by the first enabling flag in the first computing instruction is determined according to the second enabling flag Whether to enable an effective method can expand the applicable scenarios of the technical solution of the present disclosure. For the calculation process of multiple cycles, the technical solution of the present disclosure can still process calculation instructions, thereby improving the processing efficiency of cycle instructions.
在一个可选的实施方式中,在第二使能标识包含多个第二子使能标识,每个第二子 使能标识对应所述第一访存数据中的一个数据的情况下,上述步骤S302:基于所述第二使能标识确定所述第一计算指令所对应的第一访存数据的第一地址信息,具体包括如下步骤:In an optional implementation manner, in the case where the second enablement identifier includes a plurality of second sub-enablement identifiers, and each second sub-enablement identifier corresponds to one data in the first access data, the above-mentioned Step S302: Determine the first address information of the first memory access data corresponding to the first computing instruction based on the second enabling flag, specifically including the following steps:
(1)在所述多个第二子使能标识中确定与所述第一访存数据中的每个数据相匹配的第二子使能标识;(1) determining a second sub-enablement identifier that matches each data in the first access data among the plurality of second sub-enablement identifiers;
(2)基于与所述第一访存数据中的每个数据相匹配的第二子使能标识,确定所述第一访存数据中的每个数据的第一地址信息。(2) Determine the first address information of each data in the first access data based on the second sub-enabling identifier that matches each data in the first access data.
在本公开实施例中,上述第二使能标识可以包含多个第二子使能标识,每个第二子使能标识对应所述第一访存数据中的一个数据。这里,第一访存数据中的每个数据可以理解为用于执行该第一计算指令的每个操作数和/或该操作数的计算结果。In the embodiment of the present disclosure, the above-mentioned second enablement flag may include multiple second sub-enablement flags, and each second sub-enablement flag corresponds to one data in the first access data. Here, each data in the first fetch data can be understood as each operand used to execute the first calculation instruction and/or the calculation result of the operand.
在本公开实施例中,可以在多个第二子使能标识中确定与所述第一访存数据中的每个数据相匹配的第二子使能标识,进而根据匹配到的第二子使能标识的标识值确定对应数据的第一地址信息。In this embodiment of the present disclosure, the second sub-enabling identifier matching each data in the first access data may be determined among multiple second sub-enabling identifiers, and then according to the matched second sub-enabling identifier The identification value of the enabling identification determines the first address information of the corresponding data.
举例来说,第一计算指令和第二计算指令为:For example, the first calculation instruction and the second calculation instruction are:
opinit(addr1,addr2,addr3,nxt_dlt0_on,nxt_dlt1_on,nxt_dlt2_off);opinit(addr1, addr2, addr3, nxt_dlt0_on, nxt_dlt1_on, nxt_dlt2_off);
opcal(addr1/dlt1,addr2/dlt2,addr3/dlt3,nxt_dlt0_on,nxt_dlt1_on,nxt_dlt2_off)。opcal(addr1/dlt1, addr2/dlt2, addr3/dlt3, nxt_dlt0_on, nxt_dlt1_on, nxt_dlt2_off).
其中,opcal为上述第一计算指令,opinit为第二计算指令,(addr1/dlt1,addr2/dlt2,addr3/dlt3,nxt_dlt_on[2:0])为第一计算指令的部分指令内容。其中,addr1/dlt1和addr2/dlt2为用于确定第一访存数据中的操作数的访问信息的指令内容,addr3/dlt3为用于确定第一访存数据中的操作数的计算结果的存储信息的指令内容。Wherein, opcal is the above-mentioned first calculation instruction, opinit is the second calculation instruction, (addr1/dlt1, addr2/dlt2, addr3/dlt3, nxt_dlt_on[2:0]) is part of the instruction content of the first calculation instruction. Among them, addr1/dlt1 and addr2/dlt2 are the instruction content used to determine the access information of the operand in the first memory access data, and addr3/dlt3 are used to determine the storage of the calculation result of the operand in the first memory access data The command content of the message.
假设第一计算指令中的第一使能标识为地址累加模式使能有效。通过第二计算指令中的第二使能标识(nxt_dlt0_on,nxt_dlt1_on,nxt_dlt2_off)可知,第一计算指令中与“dlt0”和“dlt1”对应的操作数的访问地址的地址累加模式使能有效,第一计算指令中与“dlt2”对应的计算结果的存储地址的地址累加模式使能禁止。It is assumed that the first enabling flag in the first computing instruction is valid for enabling the address accumulation mode. According to the second enable flag (nxt_dlt0_on, nxt_dlt1_on, nxt_dlt2_off) in the second calculation instruction, the address accumulation mode of the access address of the operand corresponding to "dlt0" and "dlt1" in the first calculation instruction is enabled. The address accumulation mode of the storage address of the calculation result corresponding to "dlt2" in a calculation instruction is enabled and disabled.
在此情况下,可以基于地址累加模式确定“dlt0”和“dlt1”对应的操作数的访问地址,并将第二计算指令的计算结果的存储地址确定为该第一计算指令的计算结果的存储地址。In this case, the access addresses of the operands corresponding to "dlt0" and "dlt1" can be determined based on the address accumulation mode, and the storage address of the calculation result of the second calculation instruction can be determined as the storage address of the calculation result of the first calculation instruction address.
在上述实施方式中,通过为第一访存数据中的每个数据均设置对应的第二子使能标识,并根据第二子使能标识控制每个数据的第一地址信息的地址累加模式是否使能有效的方式,可以进一步地扩展该技术方案适用场景,从而满足程序员的编程需求。In the above embodiment, by setting a corresponding second sub-enabling flag for each data in the first memory access data, and controlling the address accumulation mode of the first address information of each data according to the second sub-enabling flag Whether an effective method is enabled can further expand the applicable scenarios of the technical solution, so as to meet the programming needs of programmers.
下面以上述点积计算的程序为例对上述内容进行介绍。针对上述所描述的点积计算的程序,在采用本公开实施例所提供的技术方案之后,该程序可以描述为:The above-mentioned content will be introduced below by taking the above-mentioned dot product calculation program as an example. For the program of dot product calculation described above, after adopting the technical solution provided by the embodiment of the present disclosure, the program can be described as:
Figure PCTCN2022124520-appb-000002
Figure PCTCN2022124520-appb-000002
其中,minit为地址初始化指令,该地址初始化指令为for循环中第一条指令的前一条指令,也即,minit为上述的第二计算指令,for循环中第一条macc指令可以为上述的第一计算指令。Wherein, minit is an address initialization instruction, and the address initialization instruction is the previous instruction of the first instruction in the for loop, that is, minit is the above-mentioned second calculation instruction, and the first macc instruction in the for loop can be the above-mentioned first instruction. a calculation instruction.
在地址初始化指令中,包含向量x、向量y,以及向量x和向量y的计算结果的初始地址。地址初始化指令中“nxt_dlt0_on,nxt_dlt1_on,nxt_dlt2_on”分别表示在for循环的第一条macc指令中向量x对应的地址累加模式使能有效,for循环的第一条macc指令中向量y对应的地址累加模式使能有效,for循环的第一条macc指令中向量x和向量y的计算结果对应的地址累加模式使能有效。In the address initialization instruction, vector x, vector y, and initial addresses of calculation results of vector x and vector y are included. "nxt_dlt0_on, nxt_dlt1_on, nxt_dlt2_on" in the address initialization instruction respectively indicate that the address accumulation mode corresponding to vector x in the first macc instruction of the for loop is enabled and valid, and the address accumulation mode corresponding to vector y in the first macc instruction of the for loop Enable is valid, and the address accumulation mode corresponding to the calculation results of vector x and vector y in the first macc instruction of the for loop is enabled and valid.
此时,针对for循环的第一条macc指令,可以基于地址累加模式确定向量x和向 量y的访问地址,并确定向量x和向量y的计算结果的存储地址。At this time, for the first macc instruction of the for loop, the access addresses of vector x and vector y can be determined based on the address accumulation mode, and the storage addresses of the calculation results of vector x and vector y can be determined.
在一个可选的实施方式中,上述指令处理装置中包含寄存器堆,所述寄存器堆用于存储所述累加步长信息和第一访存数据。In an optional implementation manner, the above-mentioned instruction processing device includes a register file, and the register file is used to store the accumulation step size information and the first memory access data.
在此情况下,上述步骤S105:基于所述第一计算指令获取累加步长信息,包括:基于所述第一计算指令的指令内容在所述寄存器堆中获取所述累加步长信息。In this case, the above step S105: acquiring the accumulation step information based on the first calculation instruction includes: acquiring the accumulation step information in the register file based on the instruction content of the first calculation instruction.
在此情况下,上述步骤S107:基于所述第二地址信息和所述累加步长信息,确定所述第一地址信息,包括:基于所述第二地址信息和从所述寄存器堆获取的所述累加步长信息,确定所述第一访存数据的第一地址信息。In this case, the above step S107: determining the first address information based on the second address information and the accumulation step information includes: based on the second address information and the The accumulative step size information is used to determine the first address information of the first memory access data.
在本公开实施例中,在寻址模式为地址累加模式的情况下,第一计算指令的指令内容中包含寄存器堆中存储该累加步长信息的寄存器的索引标识。在此情况下,可以基于该索引标识读取对应寄存器中的数据,并将读取到的数据确定为累加步长信息。In the embodiment of the present disclosure, when the addressing mode is the address accumulation mode, the instruction content of the first calculation instruction includes an index identifier of a register in the register file storing the accumulation step information. In this case, the data in the corresponding register may be read based on the index identifier, and the read data may be determined as the accumulative step size information.
在确定出累加步长信息之后,可以对第二地址信息和累加步长信息进行累加计算,从而得到第一访存数据的第一地址信息。After the accumulation step information is determined, the second address information and the accumulation step information may be accumulated and calculated to obtain the first address information of the first access data.
在一个可选的实施方式中,所述寄存器堆包含向量寄存器堆和标量寄存器堆,所述向量寄存器堆用于存储第一计算指令的第一访存数据,所述标量寄存器堆用于存储所述累加步长信息。In an optional implementation, the register file includes a vector register file and a scalar register file, the vector register file is used to store the first memory access data of the first computing instruction, and the scalar register file is used to store the Describe the accumulative step size information.
目前,人工智能的发展对算力提出了更高的要求。在这一背景下,指令处理装置的算力密度不断提高,相应地对访存的性能需求也随之提高。为了满足访存需求,目前的趋势是在指令处理装置内部增加高速的内部存储空间(例如,寄存器堆),指令处理装置的第一计算单元可直接访问这些存储空间(例如,寄存器堆),并在其中进行高效的数据复用,从而提高指令处理装置中的第一计算单元的计算效率。At present, the development of artificial intelligence has put forward higher requirements for computing power. In this context, the computing power density of instruction processing devices continues to increase, and the performance requirements for memory access also increase accordingly. In order to meet memory access requirements, the current trend is to increase high-speed internal storage spaces (for example, register files) inside the instruction processing device, and the first calculation unit of the instruction processing device can directly access these storage spaces (for example, register files), and Efficient data multiplexing is performed therein, thereby improving the calculation efficiency of the first calculation unit in the instruction processing device.
在一个可选的实施方式中,在第一地址信息包括第一访问地址和第一存储地址的情况下,上述步骤S107:基于所述第一地址信息执行所述第一计算指令,具体包括如下步骤:In an optional implementation manner, when the first address information includes the first access address and the first storage address, the above step S107: Execute the first calculation instruction based on the first address information, which specifically includes the following step:
S1071:获取所述第一访问地址所对应的存储位置中存储的操作数;S1071: Obtain an operand stored in a storage location corresponding to the first access address;
S1072:将从所述第一访问地址所对应的存储位置中获取到的操作数作为所述第一访存数据执行所述第一计算指令,得到所述第一计算指令的第一计算结果,并将所述第一计算结果存储至所述第一存储地址对应的存储位置。S1072: Execute the first calculation instruction by using the operand obtained from the storage location corresponding to the first access address as the first memory access data, to obtain a first calculation result of the first calculation instruction, and storing the first calculation result in a storage location corresponding to the first storage address.
在本公开实施例中,可以获取第一访问地址所对应存储位置中存储的操作数。例如,获取寄存器堆中第一访问地址对应的寄存器中存储的操作数,并将获取到的操作数执行第一计算指令,从而得到第一计算指令的第一计算结果,并将第一计算结果存储至寄存器堆中与第一存储地址对应的寄存器中。In the embodiment of the present disclosure, the operand stored in the storage location corresponding to the first access address may be acquired. For example, obtain the operand stored in the register corresponding to the first access address in the register file, and execute the first calculation instruction with the obtained operand, so as to obtain the first calculation result of the first calculation instruction, and store the first calculation result Store in the register corresponding to the first storage address in the register file.
在上述实施方式中,通过上述处理方式,可以将第一地址信息的确定过程隐藏在第一计算指令的指令处理过程,从而减少了额外的指令周期,进而加快了指令的执行效率。In the above embodiment, through the above processing method, the determination process of the first address information can be hidden in the instruction processing process of the first calculation instruction, thereby reducing the extra instruction cycle, and further speeding up the execution efficiency of the instruction.
参照图4所示,为本公开实施例提供的一种指令处理装置的示意图,所述指令处理装置包括:Referring to FIG. 4 , which is a schematic diagram of an instruction processing device provided by an embodiment of the present disclosure, the instruction processing device includes:
指令处理单元41,被配置成获取待处理的第一计算指令;an instruction processing unit 41 configured to obtain a first computing instruction to be processed;
指令执行单元42,被配置成基于所述第一计算指令获取累加步长信息,并获取第二计算指令所对应的第二访存数据的第二地址信息;其中,所述第二计算指令为所述第一计算指令的上一条指令;以及基于所述第二地址信息和所述累加步长信息,确定所述第一计算指令所对应的第一访存数据的第一地址信息,并基于所述第一地址信息执行所述第一计算指令,其中,所述第一访存数据包括所述第一计算指令的操作数和/或操作数的计算结果。The instruction execution unit 42 is configured to obtain the accumulation step size information based on the first calculation instruction, and obtain the second address information of the second access data corresponding to the second calculation instruction; wherein, the second calculation instruction is The previous instruction of the first calculation instruction; and based on the second address information and the accumulation step information, determine the first address information of the first memory access data corresponding to the first calculation instruction, and based on The first address information executes the first calculation instruction, wherein the first memory access data includes an operand and/or a calculation result of the operand of the first calculation instruction.
在本公开实施例中,在指令处理单元获取到第一计算指令之后,指令执行单元可以基于第一计算指令获取累加步长信息,并获取第二计算指令所对应的第二访存数据的第二地址信息,进而基于该第二地址信息和累加步长信息确定第一地址信息,并基于第一 地址信息执行所述第一计算指令。在上述实施方式中,可以将地址计算隐藏在计算指令的指令处理过程中,从而可以减少额外的指令周期,进而加快了指令的执行效率。In the embodiment of the present disclosure, after the instruction processing unit acquires the first calculation instruction, the instruction execution unit may acquire the accumulative step size information based on the first calculation instruction, and acquire the first value of the second access data corresponding to the second calculation instruction. second address information, and then determine the first address information based on the second address information and the accumulation step information, and execute the first calculation instruction based on the first address information. In the above implementation manner, the address calculation can be hidden in the instruction processing process of the calculation instruction, so that the extra instruction cycle can be reduced, and the execution efficiency of the instruction can be accelerated.
在一个可选的实施方式中,指令处理单元41还被配置成在获取待处理的第一计算指令之后,确定所述第一计算指令所对应的第一访存数据的第一地址信息的寻址模式。In an optional implementation manner, the instruction processing unit 41 is further configured to, after acquiring the first computing instruction to be processed, determine the address of the first address information of the first access data corresponding to the first computing instruction. address mode.
指令执行单元42还被配置成在所述寻址模式为地址累加模式的情况下,基于所述第一计算指令获取累加步长信息,并获取第二计算指令所对应的第二访存数据的第二地址信息;以及基于所述第二地址信息和所述累加步长信息,确定所述第一地址信息,并基于所述第一地址信息执行所述第一计算指令。The instruction execution unit 42 is further configured to obtain the accumulation step size information based on the first calculation instruction when the addressing mode is the address accumulation mode, and obtain the information of the second memory access data corresponding to the second calculation instruction second address information; and determining the first address information based on the second address information and the accumulation step information, and executing the first calculation instruction based on the first address information.
在本公开实施例中,在指令处理单元获取到第一计算指令之后,可以确定第一计算指令所对应的第一访存数据的第一地址信息的寻址模式。在寻址模式为地址累加模式的情况下,指令执行单元可以基于第一计算指令获取累加步长信息,并获取第二计算指令所对应的第二访存数据的第二地址信息,进而基于该第二地址信息和累加步长信息确定第一地址信息,并基于第一地址信息执行所述第一计算指令。在本公开实施例中,在获取到第一计算指令之后,通过地址累加模式确定第一计算指令的第一访存数据的第一地址信息,可以将第一地址信息的确定过程隐藏在第一计算指令的指令处理过程,从而减少了额外的指令周期,进而加快了指令的执行效率。In the embodiment of the present disclosure, after the instruction processing unit acquires the first calculation instruction, it may determine the addressing mode of the first address information of the first access data corresponding to the first calculation instruction. In the case where the addressing mode is the address accumulation mode, the instruction execution unit can obtain the accumulation step size information based on the first calculation instruction, and obtain the second address information of the second memory access data corresponding to the second calculation instruction, and then based on the The second address information and the accumulation step information determine the first address information, and execute the first calculation instruction based on the first address information. In the embodiment of the present disclosure, after the first calculation instruction is obtained, the first address information of the first access data of the first calculation instruction is determined through the address accumulation mode, and the determination process of the first address information can be hidden in the first The instruction processing process of the calculation instruction reduces the extra instruction cycle, thereby speeding up the execution efficiency of the instruction.
在一个可选的实施方式中,指令处理单元41还被配置成:在所述寻址模式为直接寻址模式的情况下,获取所述第一计算指令中的地址字段中的字段内容;以及基于获取到的所述字段内容确定所述第一访存数据的第一地址信息,并向所述指令执行单元发送所述第一地址信息,以使所述指令执行单元基于所述第一地址信息执行所述第一计算指令。In an optional implementation manner, the instruction processing unit 41 is further configured to: if the addressing mode is a direct addressing mode, obtain the field content in the address field in the first calculation instruction; and Determine the first address information of the first memory access data based on the obtained field content, and send the first address information to the instruction execution unit, so that the instruction execution unit based on the first address The information executes the first computing instruction.
在本公开实施例中,在寻址模式为直接寻址模式的情况下,可以基于第一计算指令的指令内容获取第一访存数据的第一地址信息。In the embodiment of the present disclosure, when the addressing mode is the direct addressing mode, the first address information of the first memory access data may be acquired based on the instruction content of the first computing instruction.
具体实施时,可以基于第一计算指令的指令内容在寄存器堆或者指令编码中获取第一访存数据的第一地址信息。具体可以通过上述实施例中情况二所描述的两种方式获取第一访存数据的第一地址信息,此处不再详细赘述。During specific implementation, the first address information of the first memory access data can be obtained in the register file or instruction encoding based on the instruction content of the first computing instruction. Specifically, the first address information of the first fetched data can be obtained through the two methods described in the second case of the above embodiment, which will not be described in detail here.
在本公开实施例中,如图5所示,指令执行单元42包括累加寄存器421、第一计算单元442和第二计算单元423。In the embodiment of the present disclosure, as shown in FIG. 5 , the instruction execution unit 42 includes an accumulation register 421 , a first calculation unit 442 and a second calculation unit 423 .
累加寄存器421被配置成存储所述第二地址信息。The accumulation register 421 is configured to store the second address information.
第一计算单元422被配置成对所述第二地址信息和所述累加步长信息进行累加计算,得到所述第一地址信息。The first calculation unit 422 is configured to perform accumulation calculation on the second address information and the accumulation step information to obtain the first address information.
第二计算单元423,被配置成获取第一计算单元发送的第一访问地址和所述第一存储地址,并获取所述第一访问地址所对应的存储位置中存储的操作数;并将从所述第一访问地址所对应的存储位置中获取到的操作数作为所述第一访存数据执行所述第一计算指令,得到所述第一计算指令的第一计算结果,并将所述第一计算结果存储至所述第一存储地址对应的存储位置。The second computing unit 423 is configured to obtain the first access address and the first storage address sent by the first computing unit, and obtain the operand stored in the storage location corresponding to the first access address; The operand obtained in the storage location corresponding to the first access address is used as the first memory access data to execute the first calculation instruction, obtain a first calculation result of the first calculation instruction, and store the The first calculation result is stored in a storage location corresponding to the first storage address.
在本公开实施例中,在指令执行单元中包含多个第二计算单元的情况下,针对每个第二计算单元都可以设置一个地址累加单元,该地址累加单元包括累加寄存器421和第一计算单元422。进一步地,该地址累加单元中可以包含多个子累加单元,每个子累加单元包括一个累加寄存器421和一个第一计算单元422。例如,每个第二计算单元用于对多个操作数进行计算,得到计算结果,此时,针对每个操作数和计算结果,均可以对应设置一个子累加单元。In the embodiment of the present disclosure, in the case that the instruction execution unit includes a plurality of second calculation units, an address accumulation unit can be set for each second calculation unit, and the address accumulation unit includes an accumulation register 421 and a first calculation unit Unit 422. Further, the address accumulation unit may include multiple sub-accumulation units, and each sub-accumulation unit includes an accumulation register 421 and a first calculation unit 422 . For example, each second calculation unit is used to calculate multiple operands to obtain calculation results. At this time, for each operand and calculation result, a sub-accumulation unit can be correspondingly set.
第一计算单元在对第二地址信息和所述累加步长信息进行累加计算,得到所述第一地址信息之后,可以向第二计算单元发送该第一地址信息。其中,第一地址信息包括第一访问地址和第一存储地址。After the first calculation unit accumulates and calculates the second address information and the accumulation step information to obtain the first address information, it may send the first address information to the second calculation unit. Wherein, the first address information includes a first access address and a first storage address.
第二计算单元在获取到第一地址信息之后,可以获取第一访问地址中对应存储位置 中存储的操作数。例如,获取指令处理装置的寄存器堆中第一访问地址对应的寄存器中存储的操作数,并将获取到的操作数执行第一计算指令,从而得到第一计算指令的第一计算结果,并将第一计算结果存储至寄存器堆中与第一存储地址对应的寄存器中。After obtaining the first address information, the second calculation unit may obtain the operand stored in the corresponding storage location in the first access address. For example, obtaining the operand stored in the register corresponding to the first access address in the register file of the instruction processing device, and executing the first calculation instruction with the obtained operand, so as to obtain the first calculation result of the first calculation instruction, and The first calculation result is stored in the register corresponding to the first storage address in the register file.
在上述实施方式中,通过上述处理方式,可以将第一地址信息的确定过程隐藏在第一计算指令的指令处理过程,从而减少了额外的指令周期,进而加快了指令的执行效率。In the above embodiment, through the above processing method, the determination process of the first address information can be hidden in the instruction processing process of the first calculation instruction, thereby reducing the extra instruction cycle, and further speeding up the execution efficiency of the instruction.
在本公开实施例中,如图5所示,指令处理单元41包括指令读取单元411、指令译码单元412和指令发射单元413。In the embodiment of the present disclosure, as shown in FIG. 5 , the instruction processing unit 41 includes an instruction reading unit 411 , an instruction decoding unit 412 and an instruction issuing unit 413 .
指令读取单元被配置成获取待处理的第一计算指令。The instruction fetching unit is configured to fetch the first computation instruction to be processed.
指令译码单元被配置成确定所述第一计算指令中的第一使能标识,其中,所述第一使能标识用于指示针对所述第一访存数据的地址累加模式是否使能有效;以及基于所述第一使能标识确定所述第一计算指令所对应的第一访存数据的第一地址信息的寻址模式。The instruction decoding unit is configured to determine a first enable flag in the first calculation instruction, wherein the first enable flag is used to indicate whether the address accumulation mode for the first memory access data is enabled or not. ; and determining an addressing mode of the first address information of the first memory access data corresponding to the first computing instruction based on the first enabling flag.
指令发射单元,被配置成实现指令处理单元与指令执行单元和寄存器堆之间的数据传输。The instruction issuing unit is configured to implement data transmission between the instruction processing unit, the instruction execution unit and the register file.
在本公开实施例中,在指令读取单元读取到第一计算指令之后,指令译码单元可以获取该第一计算指令中指定数据位的数值,进而根据该指定数据位的数值确定第一使能标识。在获取到该第一使能标识之后,可以基于该第一使能标识确定针对第一访存数据的地址累加模式是否使能有效。In the embodiment of the present disclosure, after the instruction reading unit reads the first calculation instruction, the instruction decoding unit can obtain the value of the specified data bit in the first calculation instruction, and then determine the first calculation instruction according to the value of the specified data bit. enable flag. After the first enabling flag is acquired, it may be determined based on the first enabling flag whether the address accumulation mode for the first memory access data is enabled and valid.
在确定出地址累加模式使能有效的情况下,可以确定针对第一访存数据的第一地址信息的寻址模式为地址累加模式以及累加步长信息;之后,指令发射单元可以向指令执行单元发射累加步长信息,以使指令执行单元基于第二地址信息和累加步长信息确定第一地址信息。When it is determined that the address accumulation mode is enabled and valid, it can be determined that the addressing mode for the first address information of the first memory access data is the address accumulation mode and the accumulation step size information; after that, the instruction issuing unit can send the instruction execution unit The accumulation step information is transmitted, so that the instruction execution unit determines the first address information based on the second address information and the accumulation step information.
在上述实施方式中,通过在第一计算指令中确定第一使能标识,进而根据该第一使能标识确定第一访存数据的第一地址信息的寻址模式,可以实现将第一地址信息的确定过程隐藏在第一计算指令的指令处理过程,从而减少了额外的指令周期,进而加快了指令的执行效率。In the above embodiment, by determining the first enable flag in the first calculation instruction, and then determining the addressing mode of the first address information of the first access data according to the first enable flag, it can be realized that the first address The determination process of the information is hidden in the instruction processing process of the first calculation instruction, thereby reducing the extra instruction cycle, thereby speeding up the execution efficiency of the instruction.
在一个可选的实施方式中,第一使能标识包含多个第一子使能标识;每个所述第一子使能标识对应所述第一访存数据中的一个数据。In an optional implementation manner, the first enabling flag includes a plurality of first sub-enabling flags; each of the first sub-enabling flags corresponds to one data in the first access data.
在此情况下,指令译码单元被配置成在所述多个第一子使能标识中确定与所述第一访存数据中的每个数据相匹配的第一子使能标识;以及基于与所述第一访存数据中的每个数据相匹配的第一子使能标识,确定所述第一计算指令中的每个数据的第一地址信息的寻址模式。In this case, the instruction decoding unit is configured to determine, among the plurality of first sub-enabling flags, a first sub-enabling flag that matches each data in the first memory access data; and based on The first sub-enable flag matching each data in the first memory access data determines the addressing mode of the first address information of each data in the first calculation instruction.
应理解的是,上述第一使能标识可以包含多个第一子使能标识,每个第一子使能标识用于指示第一访存数据中的每个数据的第一地址信息的寻址模式。这里,第一访存数据中的每个数据可以理解为用于执行该第一计算指令的每个操作数和/或该操作数的计算结果。It should be understood that the above-mentioned first enablement flag may include a plurality of first sub-enablement flags, and each first sub-enablement flag is used to indicate the first address information of each data in the first access data. address mode. Here, each data in the first fetch data can be understood as each operand used to execute the first calculation instruction and/or the calculation result of the operand.
也就是说,每个操作数和/或该操作数的计算结果的第一地址信息的寻址模式可以相同,还可以不相同,本公开对此不作具体限定。That is to say, the addressing modes of the first address information of each operand and/or the calculation result of the operand may be the same or different, which is not specifically limited in the present disclosure.
这里,针对操作数来说,该第一地址信息可以理解为该操作数的读取地址(也即,下述第一访问地址);针对操作数的计算结果来说,该第一地址信息可以理解为计算结果的存储位置(也即,下述第一存储地址)。Here, for the operand, the first address information can be understood as the read address of the operand (that is, the first access address described below); for the calculation result of the operand, the first address information can be It is understood as the storage location of the calculation result (that is, the first storage address described below).
在一个第一计算指令中,各个操作数和操作数的计算结果的第一地址信息的寻址模式可以不完全相同,此时,针对每个操作数据和操作数的计算结果,可以根据对应的寻址模式确定第一地址信息。In a first calculation instruction, the addressing modes of the first address information of each operand and the calculation result of the operand may not be completely the same. At this time, for each operation data and calculation result of the operand, the corresponding The addressing mode determines first address information.
在上述实施方式中,通过为第一访存数据中的每个数据(即,操作数和操作数的计算结果)均设置对应的第一子使能标识,并根据第一子使能标识控制每个数据的第一地 址信息,可以扩展该技术方案适用场景,从而满足程序员的编程需求。In the above embodiment, by setting a corresponding first sub-enabling flag for each data in the first access data (that is, the operand and the calculation result of the operand), and controlling the operation according to the first sub-enabling flag The first address information of each data can expand the application scenarios of the technical solution, so as to meet the programming needs of programmers.
在一个可选的实施方式中,上述指令译码单元412被配置成在确定所述第一使能标识为地址累加模式使能有效之后,在所述第二计算指令中检测第二使能标识;其中,所述第二使能标识用于指示所述第一计算指令中的第一使能标识所指示的地址累加模式是否使能有效;以及基于所述第二使能标识确定所述第一计算指令所对应的第一访存数据的第一地址信息。In an optional implementation manner, the above-mentioned instruction decoding unit 412 is configured to detect the second enable flag in the second calculation instruction after determining that the first enable flag indicates that the address accumulation mode is enabled ; Wherein, the second enabling flag is used to indicate whether the address accumulation mode indicated by the first enabling flag in the first calculation instruction is enabled and valid; and determining the first The first address information of the first memory access data corresponding to a computing instruction.
通过上述实施例所描述的可知,在本公开实施例中,对上述地址累加模式进行了扩展,以使扩展之后的地址累加模式能够更简洁高效地支持循环程序,具体扩展方式为:From the description of the above embodiments, it can be seen that in the embodiments of the present disclosure, the above address accumulation mode is extended, so that the extended address accumulation mode can support the loop program more concisely and efficiently. The specific extension method is as follows:
在第一计算指令的上一条指令(即,第二计算指令)中设置第二使能标识,该第二使能标识用于指示第二计算指令的下一条计算指令(也即,第一计算指令)中第一使能标识所指示的地址累加模式是否使能有效。A second enable flag is set in the previous instruction (that is, the second computation instruction) of the first computation instruction, and the second enable flag is used to indicate the next computation instruction (that is, the first computation instruction) of the second computation instruction. instruction) whether the address accumulation mode indicated by the first enable flag is enabled or not.
具体实施时,在第一计算指令中的第一使能标识表示为针对第一访存数据的地址累加模式使能有效的情况下,如果第二计算指令中的第二使能标识为使能禁止,则确定第一计算指令中的第一使能标识所指示的地址累加模式使能禁止。也就是说,即使根据第一计算指令中的第一使能标识确定出寻址模式为地址累加模式,如果第二使能标识为使能禁止,针对第一计算指令中的第一访存数据的寻址模式可以为直接寻址模式,或者,根据第二地址信息确定第一地址信息。During specific implementation, when the first enable flag in the first computing instruction indicates that the address accumulation mode for the first memory access data is enabled, if the second enabling flag in the second computing instruction is enabled If disabled, it is determined that the address accumulation mode indicated by the first enable flag in the first computing instruction is enabled and disabled. That is to say, even if the addressing mode is determined to be the address accumulation mode according to the first enabling flag in the first calculation instruction, if the second enabling flag is enabled and disabled, the first memory access data in the first computing instruction The addressing mode may be a direct addressing mode, or the first address information is determined according to the second address information.
在本公开实施例中,指令译码单元被配置成在确定所述第二使能标识为使能禁止的情况下,确定所述第一计算指令所对应的第一访存数据的第一地址信息为第二计算指令所对应的第二访存数据的第二地址信息。In an embodiment of the present disclosure, the instruction decoding unit is configured to determine the first address of the first memory access data corresponding to the first calculation instruction when it is determined that the second enable flag is enabled and disabled The information is the second address information of the second access data corresponding to the second computing instruction.
在确定第二使能标识为使能禁止的情况下,可以将第二计算指令所对应的第二访存数据的第二地址信息确定为上述第一地址信息。In a case where it is determined that the second enable flag is enabled and disabled, the second address information of the second memory access data corresponding to the second calculation instruction may be determined as the above-mentioned first address information.
下面以上述实施例中的循环程序为例来进行说明。通过上述描述可知,多重循环程序中的每层循环程序包含初始指令和循环指令。其中,初始指令用于给定初始地址。The following takes the cyclic program in the above-mentioned embodiment as an example for description. It can be seen from the above description that each layer of the loop program in the multiple loop program includes an initial instruction and a loop instruction. Among them, the initial instruction is used to give the initial address.
假设第二计算指令为循环程序中的地址初始化指令,在第一计算指令为循环程序中的第一条循环指令的情况下,此时,可以在第二计算指令中设置第二使能标识为使能禁止。此时,针对第一条循环指令,可以将第二计算指令所对应的第二访存数据的第二地址信息确定为上述第一地址信息。例如,将地址初始化指令中的第二地址信息,确定为第一条计算指令的第一地址信息。Assuming that the second calculation instruction is the address initialization instruction in the cyclic program, in the case that the first calculation instruction is the first loop instruction in the cyclic program, at this time, the second enabling flag can be set in the second calculation instruction as Enable and disable. At this time, for the first loop instruction, the second address information of the second memory access data corresponding to the second calculation instruction may be determined as the first address information. For example, the second address information in the address initialization instruction is determined as the first address information of the first calculation instruction.
在本公开实施例中,编程人员可以根据实际需要设定第二使能标识是使能有效,还是使能禁止。通过该处理方式,可以避免循环指令中的第一条指令的数据地址信息出现错误,从而能够获取到准确的操作数。同时,通过该处理方式,可以提高用户所编写程序的灵活性,从而满足编程人员的各种编程需求。In the embodiment of the present disclosure, the programmer can set whether the second enabling flag is enabled or disabled according to actual needs. Through this processing method, an error in the data address information of the first instruction in the loop instruction can be avoided, so that an accurate operand can be obtained. At the same time, through this processing method, the flexibility of programs written by users can be improved, so as to meet various programming needs of programmers.
在本公开实施例中,第二使能标识包含多个第二子使能标识,每个第二子使能标识对应所述第一访存数据中的一个数据。In the embodiment of the present disclosure, the second enabling flag includes multiple second sub-enabling flags, and each second sub-enabling flag corresponds to one data in the first access data.
在此情况下,指令译码单元被配置成在所述多个第二子使能标识中确定与所述第一访存数据中的每个数据相匹配的第二子使能标识;以及基于与所述第一访存数据中的每个数据相匹配的第二子使能标识,确定所述第一访存数据中的每个数据的第一地址信息。In this case, the instruction decoding unit is configured to determine a second sub-enablement flag that matches each data in the first memory access data among the plurality of second sub-enablement flags; and based on The second sub-enabling identifier matched with each data in the first access data determines the first address information of each data in the first access data.
在本公开实施例中,上述第二使能标识可以包含多个第二子使能标识,每个第二子使能标识对应所述第一访存数据中的一个数据。这里,第一访存数据中的每个数据可以理解为用于执行该第一计算指令的每个操作数,以及该操作数的计算结果。In the embodiment of the present disclosure, the above-mentioned second enablement flag may include multiple second sub-enablement flags, and each second sub-enablement flag corresponds to one data in the first access data. Here, each data in the first memory access data can be understood as each operand used to execute the first calculation instruction, and the calculation result of the operand.
在本公开实施例中,可以在多个第二子使能标识中确定与所述第一访存数据中的每个数据相匹配的第二子使能标识,进而根据匹配到的第二子使能标识的标识值确定对应数据的第一地址信息。In this embodiment of the present disclosure, the second sub-enabling identifier matching each data in the first access data may be determined among multiple second sub-enabling identifiers, and then according to the matched second sub-enabling identifier The identification value of the enabling identification determines the first address information of the corresponding data.
在上述实施方式中,通过为第一访存数据中的每个数据均设置对应的第二子使能标识,并根据第二子使能标识控制每个数据的第一地址信息地址累加模式是否使能有效的 方式,可以进一步地扩展该技术方案适用场景,从而满足程序员的编程需求。In the above embodiment, by setting a corresponding second sub-enabling flag for each data in the first memory access data, and controlling whether the first address information address accumulation mode of each data is based on the second sub-enabling flag Enabling an effective way can further expand the application scenarios of the technical solution, so as to meet the programming needs of programmers.
在本公开实施例中,第一计算指令的指令内容包含至少一个第一数据位和/或至少一个第二数据位,其中,每个所述第一数据位包括第一使能标识和/或第一标识内容,每个所述第二数据位包括第二使能标识和/或第二标识内容,所述第一使能标识用于指示所述第一计算指令的寻址模式,所述第一标识内容用于指示所述累加步长信息或者所述第一地址信息,所述第二使能标识用于指示所述第一计算指令的下一条计算指令的寻址模式,所述第二标识内容用于指示执行所述下一条计算指令对应的累加步长信息或者第一地址信息。In an embodiment of the present disclosure, the instruction content of the first calculation instruction includes at least one first data bit and/or at least one second data bit, wherein each of the first data bits includes a first enable flag and/or First identification content, each of the second data bits includes a second enable identification and/or second identification content, the first enable identification is used to indicate the addressing mode of the first calculation instruction, the The content of the first identification is used to indicate the accumulation step information or the first address information, the second enabling identification is used to indicate the addressing mode of the next calculation instruction of the first calculation instruction, and the first The content of the second identification is used to indicate the accumulative step size information or the first address information corresponding to the execution of the next calculation instruction.
举例来说,第一计算指令为opinit(addr1/dlt1=a,addr2/dlt2=b,addr3/dlt3=c,nxt_dlt0_on,nxt_dlt1_on,nxt_dlt2_off)。For example, the first calculation instruction is opinit(addr1/dlt1=a, addr2/dlt2=b, addr3/dlt3=c, nxt_dlt0_on, nxt_dlt1_on, nxt_dlt2_off).
其中,addr1/dlt1=a,addr2/dlt2=b,addr3/dlt3=c为上述至少一个第一数据位,addr/dlt即为上述第一使能标识,数据位即addr/dlt的值,对应的使能标识为*dlt*on/off,a,b和c为第一使能标识的第一标识内容。nxt_dlt0_on,nxt_dlt1_on,nxt_dlt2_off为上述至少一个第二数据位,nxt_dlt0、nxt_dlt1和nxt_dlt2为第二使能标识,on或者off为第二使能标识的第二标识内容。Wherein, addr1/dlt1=a, addr2/dlt2=b, addr3/dlt3=c is the above-mentioned at least one first data bit, addr/dlt is the above-mentioned first enabling flag, and the data bit is the value of addr/dlt, corresponding The enabling flag of is *dlt*on/off, a, b and c are the first flag contents of the first enabling flag. nxt_dlt0_on, nxt_dlt1_on, nxt_dlt2_off are at least one second data bit, nxt_dlt0, nxt_dlt1 and nxt_dlt2 are the second enable flags, and on or off is the second flag content of the second enable flag.
在本公开实施例中,如图6所示,指令处理装置还包括寄存器堆61;其中,所述寄存器堆用于存储以下至少之一:所述累加步长信息、所述第一访存数据和所述第一地址信息。In the embodiment of the present disclosure, as shown in FIG. 6 , the instruction processing device further includes a register file 61; wherein, the register file is used to store at least one of the following: the accumulation step information, the first memory access data and the first address information.
在此情况下,指令译码单元被配置成对所述第一计算指令的指令内容进行译码,得到译码结果;指令发射单元被配置成基于所述译码结果向所述寄存器堆发送获取所述累加步长信息的指令;指令执行单元被配置成基于所述第二地址信息和所述累加步长信息,确定所述第一访存数据的第一地址信息。In this case, the instruction decoding unit is configured to decode the instruction content of the first computing instruction to obtain a decoding result; the instruction issuing unit is configured to send a fetch to the register file based on the decoding result The instruction for accumulating step size information; the instruction executing unit is configured to determine the first address information of the first memory access data based on the second address information and the accumulating step size information.
下面将结合图7对上述指令处理方法进行介绍,如图7所示,指令处理装置包含指令处理单元、指令执行单元和寄存器堆;其中,指令执行单元包括地址累加单元A和第二计算单元A、地址累加单元B和第二计算单元B、地址累加单元C和第二计算单元C。其中,地址累加单元A、地址累加单元B和地址累加单元C中的每个地址累加单元包括累加寄存器和第一计算单元。The above instruction processing method will be introduced below in conjunction with FIG. 7. As shown in FIG. 7, the instruction processing device includes an instruction processing unit, an instruction execution unit, and a register file; wherein, the instruction execution unit includes an address accumulation unit A and a second calculation unit A , the address accumulation unit B and the second calculation unit B, the address accumulation unit C and the second calculation unit C. Wherein, each of the address accumulation unit A, the address accumulation unit B and the address accumulation unit C includes an accumulation register and a first calculation unit.
在此基础上,指令处理方法可以描述为如下过程。On this basis, the instruction processing method can be described as the following process.
上述地址累加的思想,可以应用到指令处理装置设计中。将指令处理装置简单划分为指令处理单元、指令执行单元和寄存器堆三个部分。其中,指令处理单元负责指令的读取、译码和发射,指令执行单元负责算术、访存等。The above idea of address accumulation can be applied to the design of the instruction processing device. The instruction processing device is simply divided into three parts: an instruction processing unit, an instruction execution unit and a register file. Among them, the instruction processing unit is responsible for reading, decoding and launching instructions, and the instruction execution unit is responsible for arithmetic and memory access.
指令执行单元中的计算单元支持例如以下指令:The computing unit in the instruction execution unit supports, for example, the following instructions:
opinit(addr1/dlt1,addr1/dlt1,addr2/dlt2,nxt_dlt_on[2:0]);opinit(addr1/dlt1, addr1/dlt1, addr2/dlt2, nxt_dlt_on[2:0]);
opcal(addr1/dlt1,addr1/dlt1,addr1/dlt1,nxt_dlt_on[2:0])。opcal(addr1/dlt1, addr1/dlt1, addr1/dlt1, nxt_dlt_on[2:0]).
指令处理装置执行上述指令时对地址的解析流程如图7所示。The process of parsing addresses when the instruction processing device executes the above instructions is shown in FIG. 7 .
1)指令读取单元读取第一计算指令,指令译码单元对第一计算指令进行译码后,解析出寻址模式(直接寻址addr模式/地址累加dlt模式),以及针对下一个第一计算指令的dlt模式是否使能(nxt_dlt_on/nxt_dlt_off)。1) The instruction reading unit reads the first computing instruction, and after the instruction decoding unit decodes the first computing instruction, it parses out the addressing mode (direct addressing addr mode/address accumulation dlt mode), and for the next Whether the dlt mode of a calculation instruction is enabled (nxt_dlt_on/nxt_dlt_off).
2)指令发射单元与寄存器堆建立通信链路,以通过该通信链路从寄存器堆或者指令编码中取出addr/dlt的值;2) The instruction emission unit establishes a communication link with the register file, so as to take out the value of addr/dlt from the register file or instruction encoding through the communication link;
3)对于addr模式,指令执行单元直接使用addr的值读取寄存器堆。3) For the addr mode, the instruction execution unit directly uses the value of addr to read the register file.
对于dlt模式,累加寄存器中维护上一次的访问地址(即,第二计算指令所对应的第二地址信息),之后,第一计算单元计算上一次的访问地址和累加步长信息的累加结果,作为第一地址信息发送给指令执行单元的第二计算单元,指令执行单元的第二计算单元使用该第一地址信息对寄存器堆进行访问。For the dlt mode, the last access address (that is, the second address information corresponding to the second calculation instruction) is maintained in the accumulation register, after that, the first calculation unit calculates the last access address and the accumulation result of the accumulation step information, The first address information is sent to the second calculation unit of the instruction execution unit, and the second calculation unit of the instruction execution unit uses the first address information to access the register file.
在一个可选的实施方式中,寄存器堆包含向量寄存器堆和标量寄存器堆,所述向量 寄存器堆用于存储第一计算指令的第一访存数据,所述标量寄存器堆用于存储所述累加步长信息和/或所述第一地址信息。In an optional implementation, the register file includes a vector register file and a scalar register file, the vector register file is used to store the first memory access data of the first calculation instruction, and the scalar register file is used to store the accumulated step size information and/or the first address information.
在此情况下,下面将结合图8对上述指令处理方法进行介绍。如图8所示,指令处理装置包含指令处理单元、指令执行单元、标量寄存器堆和向量寄存器堆;其中,指令执行单元包括地址累加单元A和第二计算单元A、地址累加单元B和第二计算单元B、地址累加单元C和第二计算单元C。其中,地址累加单元A、地址累加单元B和地址累加单元C中的每个地址累加单元包括累加寄存器和第一计算单元。In this case, the above instruction processing method will be introduced below with reference to FIG. 8 . As shown in Figure 8, the instruction processing device includes an instruction processing unit, an instruction execution unit, a scalar register file and a vector register file; wherein, the instruction execution unit includes an address accumulation unit A and a second computing unit A, an address accumulation unit B and a second A calculation unit B, an address accumulation unit C and a second calculation unit C. Wherein, each of the address accumulation unit A, the address accumulation unit B and the address accumulation unit C includes an accumulation register and a first calculation unit.
在此基础上,指令处理方法可以描述为如下过程。On this basis, the instruction processing method can be described as the following process.
上述地址累加的思想,可以应用到指令处理装置设计中。将指令处理装置简单划分为指令处理单元、指令执行单元和寄存器堆三个部分。其中,指令处理单元负责指令的读取、译码和发射,指令执行单元负责算术、访存等。The above idea of address accumulation can be applied to the design of the instruction processing device. The instruction processing device is simply divided into three parts: an instruction processing unit, an instruction execution unit and a register file. Among them, the instruction processing unit is responsible for reading, decoding and launching instructions, and the instruction execution unit is responsible for arithmetic and memory access.
本公开实施例所提供的技术方案可拓展到包含并行计算单元的指令处理装置中,如包含SIMD(Single Instruction Multiple Data,单指令多数据流)单元的CPU(Central Processing Unit)或者GPU(Graphics Processing Unit)。主要思想为:指令处理装置中包含两个独立的寄存器堆,其中,标量寄存器堆主要用于存储简单标量数据或者控制信息,向量寄存器堆用于存储并行计算的SIMD/SIMT(Single Instruction Multiple Threads,单指令多线程)数据。The technical solution provided by the embodiments of the present disclosure can be extended to an instruction processing device including a parallel computing unit, such as a CPU (Central Processing Unit) or a GPU (Graphics Processing Unit) that includes a SIMD (Single Instruction Multiple Data) unit. Unit). The main idea is: the instruction processing device contains two independent register files, among which the scalar register file is mainly used to store simple scalar data or control information, and the vector register file is used to store parallel computing SIMD/SIMT (Single Instruction Multiple Threads, Single Instruction Multiple Threads) data.
这里,向量寄存器堆用于存储第一计算指令的第一访存数据,标量寄存器堆用于存储所述累加步长信息和/或所述第一地址信息。Here, the vector register file is used to store the first memory access data of the first calculation instruction, and the scalar register file is used to store the accumulation step information and/or the first address information.
指令处理装置执行上述指令时对地址的解析流程如图8所示:The process of parsing the address when the instruction processing device executes the above instructions is shown in Figure 8:
1)指令读取单元读取第一计算指令,指令译码单元对第一计算指令进行译码后,解析出寻址模式(直接寻址addr模式/地址累加dlt模式),以及针对下一个第一计算指令的dlt模式是否使能(nxt_dlt_on/nxt_dlt_off);1) The instruction reading unit reads the first calculation instruction, and after the instruction decoding unit decodes the first calculation instruction, it parses out the addressing mode (direct addressing addr mode/address accumulation dlt mode), and for the next first calculation instruction Whether the dlt mode of a calculation instruction is enabled (nxt_dlt_on/nxt_dlt_off);
2)指令发射单元与寄存器堆建立通信链路,以通过该通信链路从寄存器堆或者指令编码中取出addr/dlt的值;2) The instruction emission unit establishes a communication link with the register file, so as to take out the value of addr/dlt from the register file or instruction encoding through the communication link;
3)对于addr模式,指令执行单元直接使用addr的值读取向量寄存器堆。3) For the addr mode, the instruction execution unit directly uses the value of addr to read the vector register file.
对于dlt模式,累加寄存器中维护上一次的访问地址(即,第二计算指令所对应的第二地址信息),之后,第一计算单元计算上一次的访问地址和累加步长信息的累加结果,作为第一地址信息发送给指令执行单元的第二计算单元,指令执行单元的第二计算单元使用该地址对向量寄存器堆进行访问。For the dlt mode, the last access address (that is, the second address information corresponding to the second calculation instruction) is maintained in the accumulation register, after that, the first calculation unit calculates the last access address and the accumulation result of the accumulation step information, The first address information is sent to the second calculation unit of the instruction execution unit, and the second calculation unit of the instruction execution unit uses the address to access the vector register file.
本领域技术人员可以理解,在具体实施方式的上述方法中,各步骤的撰写顺序并不意味着严格的执行顺序而对实施过程构成任何限定,各步骤的具体执行顺序应当以其功能和可能的内在逻辑确定。Those skilled in the art can understand that in the above method of specific implementation, the writing order of each step does not mean a strict execution order and constitutes any limitation on the implementation process. The specific execution order of each step should be based on its function and possible The inner logic is OK.
基于同一发明构思,本公开实施例中还提供了与指令处理方法对应的指令处理装置,由于本公开实施例中的装置解决问题的原理与本公开实施例上述指令处理方法相似,因此装置的实施可以参见方法的实施,重复之处不再赘述。Based on the same inventive concept, the embodiment of the present disclosure also provides an instruction processing device corresponding to the instruction processing method. Since the problem-solving principle of the device in the embodiment of the present disclosure is similar to the above-mentioned instruction processing method in the embodiment of the present disclosure, the implementation of the device Reference can be made to the implementation of the method, and repeated descriptions will not be repeated.
参照图9所示,为本公开实施例提供的一种指令处理装置的示意图,所述指令处理装置包括:Referring to FIG. 9 , which is a schematic diagram of an instruction processing device provided by an embodiment of the present disclosure, the instruction processing device includes:
第一获取单元91,用于获取待处理的第一计算指令;The first obtaining unit 91 is configured to obtain the first computing instruction to be processed;
确定单元92,用于确定所述第一计算指令所对应的第一访存数据的第一地址信息的寻址模式;所述第一访存数据包括用于执行所述第一计算指令的操作数和/或操作数的计算结果;A determining unit 92, configured to determine an addressing mode of the first address information of the first memory access data corresponding to the first calculation instruction; the first memory access data includes an operation for executing the first calculation instruction results of calculations on numbers and/or operands;
第二获取单元93,用于在所述寻址模式为地址累加模式的情况下,基于所述第一计算指令获取累加步长信息,并获取第二计算指令所对应的第二访存数据的第二地址信息;所述第二计算指令为所述第一计算指令的上一条指令;The second obtaining unit 93 is configured to obtain the accumulation step size information based on the first calculation instruction when the addressing mode is the address accumulation mode, and obtain the second memory access data corresponding to the second calculation instruction Second address information; the second computing instruction is a previous instruction of the first computing instruction;
指令执行单元94,用于基于所述第二地址信息和所述累加步长信息,确定所述第 一地址信息,并基于所述第一地址信息执行所述第一计算指令。The instruction execution unit 94 is configured to determine the first address information based on the second address information and the accumulation step information, and execute the first calculation instruction based on the first address information.
在一种可能的实施方式中,指令执行单元还用于在第一地址信息包括第一访问地址和第一存储地址的情况下,获取所述第一访问地址所对应的存储位置中存储的操作数;将从所述第一访问地址所对应的存储器中获取到的操作数作为所述第一访存数据执行所述第一计算指令,得到所述第一计算指令的第一计算结果,并将所述第一计算结果存储至所述第一存储地址对应的存储位置。In a possible implementation manner, the instruction execution unit is further configured to obtain the operation stored in the storage location corresponding to the first access address when the first address information includes the first access address and the first storage address. number; using the operand obtained from the memory corresponding to the first access address as the first memory access data to execute the first calculation instruction to obtain a first calculation result of the first calculation instruction, and storing the first calculation result to a storage location corresponding to the first storage address.
在一种可能的实施方式中,该指令处理装置还用于在所述寻址模式为直接寻址模式的情况下,获取所述第一计算指令中的地址字段中的字段内容;基于获取到的所述字段内容确定所述第一访存数据的第一地址信息。In a possible implementation manner, the instruction processing device is further configured to obtain the field content in the address field in the first calculation instruction when the addressing mode is the direct addressing mode; based on the obtained The content of the field of determines the first address information of the first fetched data.
在一种可能的实施方式中,确定单元还用于确定所述第一计算指令中的第一使能标识,其中,所述第一使能标识用于指示针对所述第一访存数据的地址累加模式是否使能有效;基于所述第一使能标识确定所述第一计算指令所对应的第一访存数据的第一地址信息的寻址模式。In a possible implementation manner, the determining unit is further configured to determine a first enable flag in the first computing instruction, where the first enable flag is used to indicate the Whether the address accumulation mode is enabled and valid; determining the addressing mode of the first address information of the first memory access data corresponding to the first calculation instruction based on the first enable flag.
在一种可能的实施方式中,确定单元还用于在第一使能标识包括多个第一子使能标识;每个所述第一子使能标识对应所述第一访存数据中的一个数据的情况下,在所述多个第一子使能标识中确定与所述第一访存数据中的每个数据相匹配的第一子使能标识;基于与所述第一访存数据中的每个数据相匹配的第一子使能标识,确定所述第一计算指令中的每个数据的第一地址信息的寻址模式。In a possible implementation manner, the determining unit is further configured to include a plurality of first sub-enabling identifiers in the first enabling identifier; each of the first sub-enabling identifiers corresponds to an In the case of one data, among the plurality of first sub-enabling identifiers, determine a first sub-enabling identifier that matches each data in the first memory access data; The first sub-enabling identifier matched by each data in the data determines the addressing mode of the first address information of each data in the first calculation instruction.
在一种可能的实施方式中,该指令处理装置还用于在确定所述第一使能标识为使能有效之后,在所述第二计算指令中检测第二使能标识;其中,所述第二使能标识用于指示所述第一计算指令中的第一使能标识所指示的地址累加模式是否使能有效;基于所述第二使能标识确定所述第一计算指令所对应的第一访存数据的第一地址信息。In a possible implementation manner, the instruction processing device is further configured to detect a second enablement flag in the second calculation instruction after determining that the first enablement flag is enabled; wherein, the The second enabling flag is used to indicate whether the address accumulation mode indicated by the first enabling flag in the first computing instruction is enabled and valid; determine the address corresponding to the first computing instruction based on the second enabling flag First address information of the first fetched data.
在一种可能的实施方式中,该指令处理装置还用于在确定所述第二使能标识为使能禁止的情况下,确定所述第一计算指令所对应的第一访存数据的第一地址信息为第二计算指令所对应的第二访存数据的第二地址信息。In a possible implementation manner, the instruction processing device is further configured to, in the case of determining that the second enable flag is enabled and disabled, determine the first memory access data corresponding to the first calculation instruction The address information is the second address information of the second fetch data corresponding to the second computing instruction.
在一种可能的实施方式中,该指令处理装置还用于在第二使能标识包含多个第二子使能标识,每个第二子使能标识对应所述第一访存数据中的一个数据的情况下,在所述多个第二子使能标识中确定与所述第一访存数据中的每个数据相匹配的第二子使能标识;基于与所述第一访存数据中的每个数据相匹配的第二子使能标识,确定所述第一访存数据中的每个数据的第一地址信息。In a possible implementation manner, the instruction processing device is further configured to include a plurality of second sub-enabling identifiers in the second enabling identifier, and each second sub-enabling identifier corresponds to an In the case of one data, among the multiple second sub-enablement identifiers, determine a second sub-enablement identifier that matches each data in the first memory access data; Each data in the data matches the second sub-enabling identifier to determine the first address information of each data in the first fetched data.
在一种可能的实施方式中,在指令处理装置中包含寄存器堆,所述寄存器堆用于存储所述累加步长信息和第一访存数据的情况下,第二获取单元还用于基于所述第一计算指令的指令内容在所述寄存器堆中获取所述累加步长信息;指令执行单元还用于基于所述第二地址信息和所述累加步长信息,确定所述第一访存数据的第一地址信息。In a possible implementation manner, when the instruction processing device includes a register file, and the register file is used to store the accumulation step size information and the first memory access data, the second acquisition unit is further configured to The instruction content of the first calculation instruction acquires the accumulative step information in the register file; the instruction execution unit is further configured to determine the first memory access based on the second address information and the accumulative step information The first address information of the data.
在一种可能的实施方式中,所述寄存器堆包含向量寄存器堆和标量寄存器堆,所述向量寄存器堆用于存储第一计算指令的第一访存数据,所述标量寄存器堆用于存储所述累加步长信息。In a possible implementation manner, the register file includes a vector register file and a scalar register file, the vector register file is used to store the first memory access data of the first computing instruction, and the scalar register file is used to store the Describe the accumulative step size information.
在一种可能的实施方式中,本公开提供的指令处理装置还可以实现为处理器,这里不再赘述。In a possible implementation manner, the instruction processing apparatus provided in the present disclosure may also be implemented as a processor, which will not be repeated here.
关于装置中的各模块的处理流程、以及各模块之间的交互流程的描述可以参照上述方法实施例中的相关说明,这里不再详述。For the description of the processing flow of each module in the device and the interaction flow between the modules, reference may be made to the relevant description in the above method embodiment, and details will not be described here.
在本申请实施例中提到的指令处理装置包括的各个单元(如图4到图9中所示),可以实现为处理器的一部分,或者在指令处理装置为多核处理器的情况下实现为处理器本身,或者实现为芯片的一部分,或者实现为各种电子电路,等等,本申请并不对其具体的硬件实现形式进行限制,只要其实现本申请实施例所描述的功能即可。The various units included in the instruction processing device mentioned in the embodiment of the present application (as shown in Fig. 4 to Fig. 9 ) can be realized as a part of the processor, or in the case that the instruction processing device is a multi-core processor, it can be implemented as The processor itself is implemented as a part of a chip, or as various electronic circuits, etc. The present application does not limit its specific hardware implementation form, as long as it realizes the functions described in the embodiments of the present application.
对应于图1中的指令处理方法,本公开实施例还提供了一种电子设备1000。如图 10所示,为本公开实施例提供的电子设备1000结构示意图,该电子设备1000包括处理器101、存储器102和总线103。Corresponding to the instruction processing method in FIG. 1 , an embodiment of the present disclosure further provides an electronic device 1000 . As shown in FIG. 10 , it is a schematic structural diagram of an electronic device 1000 provided by an embodiment of the present disclosure, and the electronic device 1000 includes a processor 101 , a memory 102 and a bus 103 .
存储器102用于存储执行指令,包括内存1021和外部存储器1022;这里的内存1021也称内存储器,用于暂时存放处理器101中的运算数据,以及与硬盘等外部存储器1022交换的数据。处理器101通过内存1021与外部存储器1022进行数据交换,当所述电子设备1000运行时,所述处理器101与所述存储器102之间通过总线103通信,使得所述处理器101执行以下指令。The memory 102 is used to store execution instructions, including a memory 1021 and an external memory 1022; the memory 1021 here is also called an internal memory, and is used to temporarily store computing data in the processor 101 and data exchanged with an external memory 1022 such as a hard disk. The processor 101 exchanges data with the external memory 1022 through the memory 1021. When the electronic device 1000 is running, the processor 101 communicates with the memory 102 through the bus 103, so that the processor 101 executes the following instructions.
获取待处理的第一计算指令;确定所述第一计算指令所对应的第一访存数据的第一地址信息的寻址模式;其中,所述第一访存数据包括用于执行所述第一计算指令的操作数和/或操作数的计算结果;在所述寻址模式为地址累加模式的情况下,基于所述第一计算指令获取累加步长信息,并获取第二计算指令所对应的第二访存数据的第二地址信息;其中,所述第二计算指令为所述第一计算指令的上一条指令;基于所述第二地址信息和所述累加步长信息,确定所述第一地址信息,并基于所述第一地址信息执行所述第一计算指令。Acquiring the first calculation instruction to be processed; determining the addressing mode of the first address information of the first memory access data corresponding to the first calculation instruction; wherein the first memory access data includes An operand of a calculation instruction and/or a calculation result of the operand; in the case where the addressing mode is an address accumulation mode, acquiring accumulation step size information based on the first calculation instruction, and obtaining the information corresponding to the second calculation instruction The second address information of the second access data; wherein, the second calculation instruction is the previous instruction of the first calculation instruction; based on the second address information and the accumulation step information, determine the first address information, and execute the first calculation instruction based on the first address information.
本公开实施例还提供一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序被处理器运行时执行上述方法实施例中所述的指令处理方法的步骤。其中,该存储介质可以是易失性或非易失的计算机可读取存储介质。Embodiments of the present disclosure further provide a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a processor, the steps of the instruction processing method described in the foregoing method embodiments are executed. Wherein, the storage medium may be a volatile or non-volatile computer-readable storage medium.
本公开实施例还提供一种计算机程序产品,该计算机程序产品承载有程序代码,所述程序代码包括的指令可用于执行上述方法实施例中所述的指令处理方法的步骤,具体可参见上述方法实施例,在此不再赘述。The embodiment of the present disclosure also provides a computer program product, the computer program product carries a program code, and the instructions included in the program code can be used to execute the steps of the instruction processing method described in the above method embodiment, for details, please refer to the above method The embodiment will not be repeated here.
本公开实施例还提供了一种芯片,该芯片包括上述实施例中任一项所述的指令处理装置,具体可参见上述装置实施例,在此不再赘述。Embodiments of the present disclosure further provide a chip, which includes the instruction processing device described in any one of the above embodiments. For details, please refer to the above device embodiments, which will not be repeated here.
其中,上述计算机程序产品可以具体通过硬件、软件或其结合的方式实现。在一个可选实施例中,所述计算机程序产品具体体现为计算机存储介质,在另一个可选实施例中,计算机程序产品具体体现为软件产品,例如软件开发包(Software Development Kit,SDK)等等。Wherein, the above-mentioned computer program product may be specifically implemented by means of hardware, software or a combination thereof. In an optional embodiment, the computer program product is embodied as a computer storage medium, and in another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (Software Development Kit, SDK) etc. wait.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统和装置的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。在本公开所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,又例如,多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些通信接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working process of the above-described system and device can refer to the corresponding process in the foregoing method embodiments, which will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices and methods may be implemented in other ways. The device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or May be integrated into another system, or some features may be ignored, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some communication interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
另外,在本公开各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit.
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个处理器可执行的非易失的计算机可读取存储介质中。基于这样的理解,本公开的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台电子设备(可以是个人计算机,服务器,或者网络设备等)执行本公开各个实施例所述方法的全部或部分步骤。而前述的存储介质包括U盘、移动硬盘、只读存储器 (Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。If the functions are realized in the form of software function units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium executable by a processor. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make an electronic device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in various embodiments of the present disclosure. The aforementioned storage medium includes various media that can store program codes such as U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk.
最后应说明的是,以上所述实施例,仅为本公开的具体实施方式,用以说明本公开的技术方案,而非对其限制,本公开的保护范围并不局限于此,尽管参照前述实施例对本公开进行了详细的说明,本领域的普通技术人员应当理解,任何熟悉本技术领域的技术人员在本公开揭露的技术范围内,其依然可以对前述实施例所记载的技术方案进行修改或可轻易想到变化,或者对其中部分技术特征进行等同替换;而这些修改、变化或者替换,并不使相应技术方案的本质脱离本公开实施例技术方案的精神和范围,都应涵盖在本公开的保护范围之内。因此,本公开的保护范围应所述以权利要求的保护范围为准。Finally, it should be noted that the above-described embodiments are only specific implementations of the present disclosure, and are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto, although referring to the aforementioned The embodiments have described the present disclosure in detail, and those skilled in the art should understand that any person familiar with the technical field can still modify the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present disclosure Changes can be easily imagined, or equivalent replacements can be made to some of the technical features; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in this disclosure. within the scope of protection. Therefore, the protection scope of the present disclosure should be defined by the protection scope of the claims.

Claims (19)

  1. 一种指令处理装置,其特征在于,包括:An instruction processing device, characterized in that it includes:
    指令处理单元,被配置成获取待处理的第一计算指令;an instruction processing unit configured to obtain a first computing instruction to be processed;
    指令执行单元,被配置成基于所述第一计算指令获取累加步长信息,并获取第二计算指令所对应的第二访存数据的第二地址信息;其中,所述第二计算指令为所述第一计算指令的上一条指令;基于所述第二地址信息和所述累加步长信息,确定所述第一计算指令所对应的第一访存数据的第一地址信息,并基于所述第一地址信息执行所述第一计算指令,其中,所述第一访存数据包括所述第一计算指令的操作数和/或操作数的计算结果。The instruction execution unit is configured to obtain the accumulation step size information based on the first calculation instruction, and obtain the second address information of the second access data corresponding to the second calculation instruction; wherein the second calculation instruction is the The previous instruction of the first calculation instruction; based on the second address information and the accumulation step information, determine the first address information of the first memory access data corresponding to the first calculation instruction, and based on the The first address information executes the first calculation instruction, wherein the first memory access data includes an operand of the first calculation instruction and/or a calculation result of the operand.
  2. 根据权利要求1所述的指令处理装置,其特征在于,The instruction processing device according to claim 1, wherein:
    所述指令处理单元被配置成,在获取待处理的所述第一计算指令之后,确定所述第一计算指令所对应的第一访存数据的第一地址信息的寻址模式;The instruction processing unit is configured to, after acquiring the first computing instruction to be processed, determine an addressing mode of the first address information of the first memory access data corresponding to the first computing instruction;
    所述指令执行单元被配置成,在所述寻址模式为地址累加模式的情况下,基于所述第一计算指令获取所述累加步长信息,并获取所述第二计算指令所对应的第二访存数据的第二地址信息;以及基于所述第二地址信息和所述累加步长信息,确定所述第一地址信息,并基于所述第一地址信息执行所述第一计算指令。The instruction execution unit is configured to, when the addressing mode is an address accumulation mode, obtain the accumulation step size information based on the first calculation instruction, and obtain the second calculation instruction corresponding to the second calculation instruction. second address information of the access data; and based on the second address information and the accumulation step information, determine the first address information, and execute the first calculation instruction based on the first address information.
  3. 根据权利要求1或2所述的指令处理装置,其特征在于,所述指令执行单元包括:The instruction processing device according to claim 1 or 2, wherein the instruction execution unit comprises:
    累加寄存器,被配置成存储所述第二地址信息;an accumulation register configured to store the second address information;
    第一计算单元,被配置成,在获取所述指令处理单元发送的所述累加步长信息之后,对所述第二地址信息和所述累加步长信息进行累加计算,得到所述第一地址信息。The first calculating unit is configured to, after acquiring the accumulative step information sent by the instruction processing unit, perform accumulative calculation on the second address information and the accumulative step information to obtain the first address information.
  4. 根据权利要求3所述的指令处理装置,其特征在于,所述第一地址信息包括第一访问地址和第一存储地址;所述指令执行单元进一步包括:第二计算单元,被配置成:The instruction processing device according to claim 3, wherein the first address information includes a first access address and a first storage address; the instruction execution unit further comprises: a second calculation unit configured to:
    获取所述第一计算单元发送的所述第一访问地址和所述第一存储地址,并获取所述第一访问地址所对应的存储位置中存储的操作数;Obtaining the first access address and the first storage address sent by the first computing unit, and obtaining an operand stored in a storage location corresponding to the first access address;
    将从所述第一访问地址所对应的存储位置中获取到的操作数作为所述第一访存数据执行所述第一计算指令,得到所述第一计算指令的第一计算结果;Executing the first calculation instruction by using the operand obtained from the storage location corresponding to the first access address as the first memory access data, to obtain a first calculation result of the first calculation instruction;
    将所述第一计算结果存储至所述第一存储地址对应的存储位置。storing the first calculation result to a storage location corresponding to the first storage address.
  5. 根据权利要求2至4中任一项所述的指令处理装置,其特征在于,所述指令处理单元还被配置成:The instruction processing device according to any one of claims 2 to 4, wherein the instruction processing unit is further configured to:
    在所述寻址模式为直接寻址模式的情况下,获取所述第一计算指令中的地址字段中的字段内容;In the case where the addressing mode is a direct addressing mode, acquiring field content in an address field in the first computing instruction;
    基于获取到的所述字段内容确定所述第一访存数据的第一地址信息,并向所述指令执行单元发送所述第一地址信息,以使所述指令执行单元基于所述第一地址信息执行所述第一计算指令。Determine the first address information of the first memory access data based on the obtained field content, and send the first address information to the instruction execution unit, so that the instruction execution unit based on the first address The information executes the first computing instruction.
  6. 根据权利要求1至5中任一项所述的指令处理装置,其特征在于,所述指令处理单元包括:指令译码单元,被配置成:The instruction processing device according to any one of claims 1 to 5, wherein the instruction processing unit comprises: an instruction decoding unit configured to:
    确定所述第一计算指令中的第一使能标识,其中,所述第一使能标识用于指示针对所述第一访存数据的地址累加模式是否使能有效;以及determining a first enable flag in the first calculation instruction, wherein the first enable flag is used to indicate whether the address accumulation mode for the first memory access data is enabled and valid; and
    基于所述第一使能标识确定所述第一计算指令所对应的第一访存数据的第一地址信息的寻址模式。The addressing mode of the first address information of the first memory access data corresponding to the first computing instruction is determined based on the first enabling flag.
  7. 根据权利要求6所述的指令处理装置,其特征在于,所述第一使能标识包含多个第一子使能标识;每个所述第一子使能标识对应所述第一访存数据中的一个数据;所述指令译码单元被配置成:The instruction processing device according to claim 6, wherein the first enable flag includes a plurality of first sub-enable flags; each of the first sub-enable flags corresponds to the first memory access data A data in; the instruction decoding unit is configured to:
    在所述多个第一子使能标识中确定与所述第一访存数据中的每个数据相匹配的第一子使能标识;以及determining, among the plurality of first sub-enabling identifiers, a first sub-enabling identifier that matches each data in the first memory access data; and
    基于与所述第一访存数据中的每个数据相匹配的第一子使能标识,确定所述第一计算指令所对应的第一访存数据中的每个数据的第一地址信息的寻址模式。Based on the first sub-enabling identifier that matches each data in the first memory access data, determine the first address information of each data in the first memory memory data corresponding to the first calculation instruction addressing mode.
  8. 根据权利要求6或7所述的指令处理装置,其特征在于,所述指令译码单元被配置成:The instruction processing device according to claim 6 or 7, wherein the instruction decoding unit is configured to:
    在确定所述第一使能标识为地址累加模式使能有效之后,在所述第二计算指令中检测第二使能标识;其中,所述第二使能标识用于指示所述第一计算指令中的第一使能标识所指示的地址累加模式是否使能有效;以及After determining that the first enabling flag is valid for enabling the address accumulation mode, a second enabling flag is detected in the second computing instruction; wherein the second enabling flag is used to indicate that the first computing Whether the address accumulation mode indicated by the first enabling flag in the instruction is enabled and valid; and
    基于所述第二使能标识确定所述第一计算指令所对应的第一访存数据的第一地址信息。The first address information of the first memory access data corresponding to the first computing instruction is determined based on the second enabling flag.
  9. 根据权利要求8所述的指令处理装置,其特征在于,所述指令译码单元被配置成:The instruction processing device according to claim 8, wherein the instruction decoding unit is configured to:
    在确定所述第二使能标识为地址累加模式使能禁止的情况下,确定所述第一计算指令所对应的第一访存数据的第一地址信息为所述第二计算指令所对应的第二访存数据的第二地址信息。In the case where it is determined that the second enable flag is address accumulation mode enable and disable, determine that the first address information of the first memory access data corresponding to the first calculation instruction is corresponding to the second calculation instruction Second address information of the second fetch data.
  10. 根据权利要求8或9所述的指令处理装置,其特征在于,所述第二使能标识包含多个第二子使能标识,每个所述第二子使能标识对应所述第一访存数据中的一个数据;所述指令译码单元被配置成:The instruction processing device according to claim 8 or 9, wherein the second enablement flag includes a plurality of second sub-enablement flags, and each of the second sub-enablement flags corresponds to the first access One of the stored data; the instruction decoding unit is configured to:
    在所述多个第二子使能标识中确定与所述第一访存数据中的每个数据相匹配的第二子使能标识;以及determining, among the plurality of second sub-enabling identifiers, a second sub-enabling identifier that matches each data in the first memory access data; and
    基于与所述第一访存数据中的每个数据相匹配的第二子使能标识,确定所述第一访存数据中的每个数据的第一地址信息。The first address information of each data in the first memory access data is determined based on the second sub-enabling identifier matched with each data in the first memory memory data.
  11. 根据权利要求8至10中任一项所述的指令处理装置,其特征在于,所述第一计算指令的指令内容包含至少一个第一数据位和/或至少一个第二数据位,其中,每个所述第一数据位包括第一使能标识和/或第一标识内容,每个所述第二数据位包括第二使能标识和/或第二标识内容,所述第一使能标识用于指示所述第一计算指令的寻址模式,所述第一标识内容用于指示所述累加步长信息或者所述第一地址信息,所述第二使能标识用于指示所述第一计算指令的下一条计算指令的寻址模式,所述第二标识内容用于指示执行所述下一条计算指令对应的累加步长信息或者第一地址信息。The instruction processing device according to any one of claims 8 to 10, wherein the instruction content of the first calculation instruction includes at least one first data bit and/or at least one second data bit, wherein each Each of the first data bits includes a first enable flag and/or first flag content, each of the second data bits includes a second enable flag and/or second flag content, and the first enable flag It is used to indicate the addressing mode of the first calculation instruction, the first identification content is used to indicate the accumulation step size information or the first address information, and the second enable flag is used to indicate the first The addressing mode of the next calculation instruction of a calculation instruction, the second identification content is used to indicate the accumulation step size information or the first address information corresponding to the execution of the next calculation instruction.
  12. 根据权利要求1至11中任一项所述的指令处理装置,其特征在于,所述指令处理装置还包括:The instruction processing device according to any one of claims 1 to 11, wherein the instruction processing device further comprises:
    寄存器堆,用于存储所述累加步长信息、所述第一访存数据和所述第一地址信息中的至少一个。A register file, configured to store at least one of the accumulation step information, the first memory access data and the first address information.
  13. 根据权利要求12所述的指令处理装置,其特征在于,所述指令执行单元包括:The instruction processing device according to claim 12, wherein the instruction execution unit comprises:
    指令译码单元,被配置成对所述第一计算指令的指令内容进行译码,得到译码结果;an instruction decoding unit configured to decode the instruction content of the first calculation instruction to obtain a decoding result;
    指令发射单元,被配置成基于所述译码结果向所述寄存器堆发送获取所述累加步长信息的指令;an instruction issuing unit configured to send an instruction for obtaining the accumulation step size information to the register file based on the decoding result;
    其中,所述指令执行单元被配置成基于所述第二地址信息和所述累加步长信息,确定所述第一访存数据的第一地址信息。Wherein, the instruction execution unit is configured to determine the first address information of the first memory access data based on the second address information and the accumulation step information.
  14. 根据权利要求12或13所述的指令处理装置,其特征在于,所述寄存器堆包含向量寄存器堆和标量寄存器堆,其中,所述向量寄存器堆用于存储所述第一计算指令的第一访存数据,所述标量寄存器堆用于存储所述累加步长信息和/或所述第一地址信息。The instruction processing device according to claim 12 or 13, wherein the register file includes a vector register file and a scalar register file, wherein the vector register file is used to store the first access of the first calculation instruction storing data, the scalar register file is used to store the accumulative step size information and/or the first address information.
  15. 一种指令处理方法,其特征在于,包括:A command processing method, characterized in that, comprising:
    获取待处理的第一计算指令;Acquiring a pending first calculation instruction;
    确定所述第一计算指令所对应的第一访存数据的第一地址信息的寻址模式;其中,所述第一访存数据包括用于执行所述第一计算指令的操作数和/或操作数的计算结果;Determine the addressing mode of the first address information of the first memory access data corresponding to the first calculation instruction; wherein the first memory access data includes an operand and/or used to execute the first calculation instruction the result of the computation of the operand;
    在所述寻址模式为地址累加模式的情况下,基于所述第一计算指令获取累加步长信息,并获取第二计算指令所对应的第二访存数据的第二地址信息;其中,所述第二计算指令为所述第一计算指令的上一条指令;In the case where the addressing mode is an address accumulation mode, acquiring accumulation step information based on the first calculation instruction, and acquiring second address information of the second access data corresponding to the second calculation instruction; wherein, the The second calculation instruction is the previous instruction of the first calculation instruction;
    基于所述第二地址信息和所述累加步长信息,确定所述第一地址信息,并基于所述第一地址信息执行所述第一计算指令。The first address information is determined based on the second address information and the accumulation step information, and the first calculation instruction is executed based on the first address information.
  16. 一种芯片,其特征在于,包括如权利要求1至14中任一项所述的指令处理装置。A chip, characterized by comprising the instruction processing device according to any one of claims 1 to 14.
  17. 一种电子设备,其特征在于,包括处理器、存储器和总线,所述存储器存储有所述处理器可执行的机器可读指令,当所述电子设备运行时,所述处理器与所述存储器之间通过所述总线通信,所述机器可读指令被所述处理器执行时实现如权利要求15所述的指令处理方法的步骤。An electronic device, characterized in that it includes a processor, a memory and a bus, the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate with each other through the bus, and implement the steps of the instruction processing method as claimed in claim 15 when the machine-readable instructions are executed by the processor.
  18. 一种电子设备,其特征在于,包括如权利要求16所述的芯片。An electronic device, characterized by comprising the chip according to claim 16.
  19. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器运行时执行如权利要求15所述的指令处理方法的步骤。A computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, and the computer program executes the steps of the instruction processing method according to claim 15 when the computer program is run by a processor.
PCT/CN2022/124520 2022-01-30 2022-10-11 Instruction processing method and apparatus, chip, electronic device, and storage medium WO2023142524A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210114536.0A CN114443143A (en) 2022-01-30 2022-01-30 Instruction processing method, instruction processing device, chip, electronic device and storage medium
CN202210114536.0 2022-01-30

Publications (1)

Publication Number Publication Date
WO2023142524A1 true WO2023142524A1 (en) 2023-08-03

Family

ID=81371343

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/124520 WO2023142524A1 (en) 2022-01-30 2022-10-11 Instruction processing method and apparatus, chip, electronic device, and storage medium

Country Status (2)

Country Link
CN (1) CN114443143A (en)
WO (1) WO2023142524A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114443143A (en) * 2022-01-30 2022-05-06 上海阵量智能科技有限公司 Instruction processing method, instruction processing device, chip, electronic device and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8019981B1 (en) * 2004-01-06 2011-09-13 Altera Corporation Loop instruction execution using a register identifier
CN110825435A (en) * 2018-08-10 2020-02-21 北京百度网讯科技有限公司 Method and apparatus for processing data
CN112699058A (en) * 2020-12-31 2021-04-23 深圳大普微电子科技有限公司 Addressing method, device, accelerator and medium suitable for recurrent neural network
CN114443143A (en) * 2022-01-30 2022-05-06 上海阵量智能科技有限公司 Instruction processing method, instruction processing device, chip, electronic device and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8019981B1 (en) * 2004-01-06 2011-09-13 Altera Corporation Loop instruction execution using a register identifier
CN110825435A (en) * 2018-08-10 2020-02-21 北京百度网讯科技有限公司 Method and apparatus for processing data
CN112699058A (en) * 2020-12-31 2021-04-23 深圳大普微电子科技有限公司 Addressing method, device, accelerator and medium suitable for recurrent neural network
CN114443143A (en) * 2022-01-30 2022-05-06 上海阵量智能科技有限公司 Instruction processing method, instruction processing device, chip, electronic device and storage medium

Also Published As

Publication number Publication date
CN114443143A (en) 2022-05-06

Similar Documents

Publication Publication Date Title
US8417921B2 (en) Running-min and running-max instructions for processing vectors using a base value from a key element of an input vector
US8131979B2 (en) Check-hazard instructions for processing vectors
CN108292229B (en) Instruction and logic for re-occurring neighbor aggregation
US8504806B2 (en) Instruction for comparing active vector elements to preceding active elements to determine value differences
TWI531970B (en) Address generation in a data processing apparatus
TWI733798B (en) An apparatus and method for managing address collisions when performing vector operations
US8484443B2 (en) Running multiply-accumulate instructions for processing vectors
JP2834292B2 (en) Data processor
US20180052685A1 (en) Processor and method for executing instructions on processor
US9317284B2 (en) Vector hazard check instruction with reduced source operands
US9367309B2 (en) Predicate attribute tracker
WO2021249054A1 (en) Data processing method and device, and storage medium
WO2023142524A1 (en) Instruction processing method and apparatus, chip, electronic device, and storage medium
EP1861775B1 (en) Processor and method of indirect register read and write operations
US8862932B2 (en) Read XF instruction for processing vectors
CN112631657B (en) Byte comparison method for character string processing and instruction processing device
US9122485B2 (en) Predicting a result of a dependency-checking instruction when processing vector instructions
JP5490711B2 (en) System and method for determining the address of an element in a table
US8938642B2 (en) Confirm instruction for processing vectors
US9390058B2 (en) Dynamic attribute inference
JP2008527559A (en) Processor and instruction issuing method thereof
US8924693B2 (en) Predicting a result for a predicate-generating instruction when processing vector instructions
US20150089187A1 (en) Hazard Check Instructions for Enhanced Predicate Vector Operations
WO2023142528A1 (en) Instruction processing apparatus and method, chip, computer device, and storage medium
US20160092217A1 (en) Compare Break Instructions

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22923328

Country of ref document: EP

Kind code of ref document: A1