Conversion program and conversion method
The conversion program addresses the inefficiency of converting x64 to AArch64 executable code by adjusting SIMD register sizes, resulting in faster processing by optimizing the number of execution steps and improving CPU performance.
Patent Information
- Application Number
- JP2023075665
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2023-05-01
- Publication Date
- 2024-11-14
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing methods fail to efficiently convert executable code for x64 CPUs to executable code for AArch64 CPUs, leading to slower processing due to mismatches in SIMD register sizes, which increases the number of execution steps and reduces CPU processing speed.
A conversion program that checks for 128, 256, and 512-bit SIMD instructions in x64 code and adjusts the SIMD register size settings to 128, 256, or 512 bits accordingly, converting these instructions to AArch64 instructions while minimizing the number of execution steps.
The conversion program effectively transforms x64 executable code into AArch64 executable code that can be processed faster by reducing the number of instructions and optimizing SIMD register size settings, thereby enhancing CPU performance.
Smart Images

Figure 2024160544000001_ABST
Abstract
Description
[Technical field]
[0001] The present invention relates to a conversion program and the like. [Background technology]
[0002] In recent years, systems that previously used Intel's x64 instruction set CPUs (Central Processing Units) are increasingly adopting Arm's AArch64 instruction set CPUs. This is because Arm architecture CPUs have superior power efficiency.
[0003] Therefore, there is a growing need to convert executable code for the x64 instruction set into executable code for the AArch64 instruction set and run it on systems with the Arm architecture. [Prior art documents] [Patent documents]
[0004] [Patent Document 1] JP 2023-2165 A Summary of the Invention [Problem to be solved by the invention]
[0005] According to one aspect, an object of the present invention is to convert execution code for x64 into execution code for AArch64, which can be processed by a CPU at a faster speed. [Means for solving the problem]
[0006] According to one aspect, the conversion program causes a computer to execute the following processes: check whether the SIMD instructions included in the x64 execution code to be converted include 128×n (n=1, 2, 4)-bit SIMD instructions; if the SIMD instructions do not include any SIMD instructions of 256 bits or more but include 128-bit SIMD instructions, generate and output execution code that changes the setting value of the CPU's SIMD register size to 128 bits; switch to a destination SIMD instruction when converting the x64 128-bit SIMD instructions to AArch64 SIMD instructions according to the changed SIMD register size; and convert and output the x64 execution code to be converted into an AArch64 execution code. Effect of the Invention
[0007] According to one aspect, executable code for x64 can be converted into executable code for AArch64, which the CPU can process faster. [Brief description of the drawings]
[0008] [Figure 1] FIG. 1 is a functional configuration diagram of a conversion device according to an embodiment. [Diagram 2] FIG. 2 is a hardware configuration diagram of the conversion device according to the embodiment. [Diagram 3] FIG. 3 is a schematic diagram of a register file included in the processor according to the embodiment. [Figure 4] FIG. 4 is a diagram illustrating an example of converting an x64 execution code into an AArch64 execution code. [Diagram 5] FIG. 5 is a diagram illustrating an example of a flowchart of the command conversion process according to the embodiment. [Figure 6] FIG. 6 is a diagram illustrating an example of a flowchart of the process a. [Figure 7] FIG. 7 is a diagram illustrating an example of a flowchart of the process b. [Figure 8] FIG. 8 is a diagram illustrating an example of a flowchart of the process c. [Figure 9] FIG. 9 is a diagram illustrating an example of a flowchart of the process d. [Figure 10] FIG. 10 is a diagram for explaining x64 SIMD instructions. [Figure 11] FIG. 11 is a diagram for explaining AArch64 SIMD instructions. [Figure 12] FIG. 12 is a diagram illustrating a reference example of converting an x64 execution code into an AArch64 execution code. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0009] Prior to describing this embodiment, the basis of this embodiment will be described.
[0010] First, the SIMD (Single Instruction Multiple Data) instructions of Intel's x64 and the SIMD instructions of Arm's AArch64 will be described with reference to FIGS. 10 and 11.
[0011] 10 is a diagram for explaining x64 SIMD instructions. As shown in FIG 10, x64 has 32 SIMD registers, numbered 0 to 31.
[0012] In the case of an x64-based CPU, the bit length of the SIMD register is 512. One SIMD register can store, for example, eight pieces of 64-bit data, or 16 pieces of 32-bit data. Each of the multiple SIMD registers is identified by a string such as "zmm0", "zmm1", ... "zmm31".
[0013] For example, of the 512 bits of zmm0, the lowest 256 bits are shared with another register, the ymm register, and of the 256 bits of ymm0, the lowest 128 bits are shared with another register, the xmm register.
[0014] For example, in a SIMD add instruction for 32-bit integers, when using xmm registers, the instruction code will be the following (1). The instruction code (1) adds four 32-bit integers together. vpadd xmm0,xmm1,xmm2...(1)
[0015] When using the ymm register, the instruction code becomes (2) below. The instruction code (2) adds eight 32-bit integers together. vpadd ymm0,ymm1,ymm2...(2)
[0016] When using the zmm register, the instruction code becomes (3). The instruction code (3) adds 16 32-bit integers together. vpadd zmm0,zmm1,zmm2...(3) In other words, in x64, three types of SIMD instructions with SIMD data bit lengths of 128, 256, and 512 bits can be mixed and used within the executable code.
[0017] 11 is a diagram for explaining SIMD instructions of AArch64. As shown in FIG 11, AArch64 has 32 SIMD registers, numbered 0 to 31.
[0018] For CPUs based on the Arm (AArch64) architecture, the vendor developing the CPU can select one of 128×n (n = an integer from 1 to 16) for the bit length of the SIMD register. In other words, the vendor may select one of 128, 256, 384, 512,..., 2048 for implementation. When n is 4, the bit length of the SIMD register is 512 bits. And one SIMD register can store eight pieces of 64-bit data. Each of the multiple SIMD registers is identified by a string of characters: "z0", "z1",... "z31".
[0019] The lower 128 bits of the z0 register are shared with another register, the v register.
[0020] For example, in a SIMD addition instruction for 32-bit integers, when the v register is used, the instruction code becomes the following (4). The instruction code (4) adds four 32-bit integers together. add v0.4s,v1.4s,v2.4s...(4)
[0021] When the z register is used, the instruction code becomes (5). The instruction code (5) adds n × 4 32-bit integers together. add z0.s,z1.s,z2.s (5) In other words, the size (bit length) of the z register varies depending on the type of CPU (value of n) and the setting value of the SVE (Scalable Vector Extensions) size at that time (can be set to n or less). In AArch64, two types of SIMD instructions can be used in the execution code, either with the v register (128-bit SIMD register) as an operand or with the z register as an operand.
[0022] A reference example of converting such a SIMD instruction for x64 into a SIMD instruction for AArch64 will be described with reference to Fig. 12. Fig. 12 is a diagram showing a reference example of converting an x64 execution code into an AArch64 execution code.
[0023] As shown in Figure 12, the upper row shows a case where an xmm register is used as the execution code for x64 to be converted. The xmm register shares the lower 128 bits of the 512 bits of zmm0. For example, the instruction code "vpadd xmm0,xmm1,xmm2" writes 128 bits (32 bits x 4) of the result of xmm1+xmm2 to xmm0, and sets the remaining upper 384 bits to 0.
[0024] The instruction code "vpadd xmm0,xmm1,xmm2" converted to an instruction code for AArch64 results in the following instruction codes (e1) and (e2). Note that n, which indicates the CPU type, is always 4. In other words, the size of the z register is always 512 bits. add z0.s,z1.s,z2.s (e1) mov z0.s,p0 / m,0···(e2) The instruction code (e1) writes 512 bits (32 bits x 16) of the result of z1 + z2 to z0. In addition, the instruction code (e2) sets 384 bits (12 32-bit integers) of z0 to 0 to produce the same result as in the x64 case. In other words, a separate instruction code (e2) is required. Here, p0 is a predicate, and can be used to specify the SIMD lane to which the result of the instruction will be reflected in instructions that use the z register as an operand. For example, the p0 register in (e2) holds the value necessary to reflect the result of the execution in the SIMD lane for the upper 384 bits of the z register.
[0025] In addition, the instruction codes for x64 "vpadd xmm3,xmm4,xmm5" and "vpadd xmm6,xmm7,xmm8" are also converted to AArch64 in the same way as (e1) and (e2).
[0026] The middle row shows the case where xmm and ymm registers are used as the x64 executable code to be converted. When xmm registers are used, they are converted to AArch64, just like the upper row. In contrast, ymm registers share the lower 256 bits of the 512 bits of zmm0. For example, the instruction code "vpadd ymm3,ymm4,ymm5" writes 256 bits (32 bits x 8) of the result of ymm4+xmm5 to ymm3, and sets the remaining upper 256 bits to 0.
[0027] The instruction code "vpadd ymm3,ymm4,ymm5" converted into execution code for AArch64 results in the following instruction codes (e3) and (e4). Note that n, which indicates the CPU type, is always 4. In other words, the size of the z register is always 512 bits. add z3.s,z4.s,z5.s (e3) mov z3.s,p1 / m,0···(e4) The instruction code (e3) writes the result of z4 + z5 to z3 for 512 bits (32 bits x 16). In addition, the instruction code (e4) sets 256 bits (8 x 32-bit integers) of z3 to 0 to produce the same result as in the x64 case. In other words, the instruction code (e4) is required separately.
[0028] The lower row shows the cases where xmm registers, ymm registers, and zmm registers are used as the x64 execution code to be converted. When xmm registers are used, they are converted to AArch64, just like the upper row. When ymm registers are used, they are converted to AArch64, just like the middle row. In contrast, zmm registers use 512 bits of zmm. For example, the instruction code "vpadd zmm6,zmm7,zmm8" writes 512 bits (32 bits x 16) of the result of ymm7+xmm8 to ymm6.
[0029] When the instruction code "vpadd zmm6,zmm7,zmm8" is converted into an execution code for AArch64, it becomes the following instruction code (e5). Note that n, which is the type of CPU, is always 4. In other words, the size of the z register is always 512 bits. add z6.s,z7.s,z8.s (e5) The instruction code (e5) writes the result of z7+z8 to z6 as 512 bits (32 bits x 16).
[0030] In this way, if the x64 executable code to be converted uses 128 or 256-bit registers, and the converted AArch64 executable code always uses 512-bit registers, instructions are added to set the remaining bits other than the bits to be converted to 0. This increases the number of execution steps when the executable code is executed, preventing the CPU from processing faster. In other words, there is a problem in that the x64 executable code cannot be converted to AArch64 executable code, which the CPU can process faster.
[0031] Therefore, in the following embodiments, a conversion method for converting execution code for x64 into execution code for AArch64 that can be processed by a CPU at higher speed will be described.
[0032] [Functional configuration of the conversion device] FIG. 1 is a functional configuration diagram of a conversion device according to an embodiment. As shown in FIG. 1, the conversion device 1 is a computer such as a physical machine or a virtual machine, and includes a control unit 20 and a storage unit 30. The control unit 20 includes an instruction conversion unit 21. The storage unit 30 includes an execution code 11 to be converted and an execution code 12 after conversion. The execution code 11 to be converted is a binary file of the execution code (machine language) to be converted. The execution code 11 to be converted is, for example, an execution code for x64. The execution code 12 after conversion is a binary file of the execution code (machine language) after conversion. The execution code 12 after conversion is, for example, a binary file of the execution code (machine language) for AArch64. In the embodiment, a case will be described in which the bit length of the SIMD register for AArch64 is 512.
[0033] The instruction conversion unit 21 converts the execution code 11 to be converted into the execution code 12 after conversion.
[0034] For example, the instruction conversion unit 21 analyzes the execution code 11 to be converted and checks whether the SIMD instructions included in the execution code 11 to be converted include a 128-bit SIMD instruction, a 256-bit SIMD instruction, and a 512-bit SIMD instruction. As an example, the instruction conversion unit 21 disassembles the execution code 11 to be converted and checks whether the SIMD instructions included in the execution code 11 to be converted include a 128-bit SIMD instruction, a 256-bit SIMD instruction, and a 512-bit SIMD instruction.
[0035] Then, the instruction conversion unit 21 generates and outputs an execution code that saves the setting value of the current CPU SIMD register size. As an example, the instruction conversion unit 21 acquires the current CPU SIMD register size from a system register, and generates and outputs an execution code that temporarily saves the acquired SIMD register size.
[0036] If the SIMD instructions included in the execution code 11 to be converted do not include 256,512-bit SIMD instructions but include 128-bit SIMD instructions, the instruction conversion unit 21 generates and outputs execution code that changes the set value of the SIMD register size to 128 bits. As an example, the instruction conversion unit 21 generates and outputs execution code that sets the SIMD register size to 128 bits in the system register.
[0037] Furthermore, when the SIMD instructions included in the execution code 11 to be converted do not include a 512-bit SIMD instruction but include a 256-bit SIMD instruction, the instruction conversion unit 21 generates and outputs an execution code that changes the set value of the SIMD register size to 256 bits. As an example, the instruction conversion unit 21 generates and outputs an execution code that sets the SIMD register size to 256 bits in the system register.
[0038] Furthermore, when the SIMD instruction included in the execution code 11 to be converted includes a 512-bit SIMD instruction, the instruction conversion unit 21 generates and outputs an execution code for changing the set value of the SIMD register size to 512 bits. As an example, the instruction conversion unit 21 generates and outputs an execution code for setting the SIMD register size to 512 bits in the system register.
[0039] Then, the instruction conversion unit 21 switches the SIMD instruction to a destination SIMD instruction when converting the x64 128-bit SIMD instruction, 256-bit SIMD instruction, or 512-bit SIMD instruction into an AArch64 SIMD instruction, depending on the changed SIMD register size.
[0040] As an example, when the changed SIMD register size is 128 bits, the instruction conversion unit 21 changes the xmm register, which is a 128-bit SIMD instruction in x64, to the z register in AArch64. Specifically, the instruction conversion unit 21 converts the 128-bit SIMD instruction in x64 "vpadd xmm0,xmm1,xmm2" into the following execution code (10) for AArch64. add z0.s,z1.s,z2.s (10) As a result, the instruction conversion unit 21 can process the z register converted from x64 as 128 bits by setting the size of the z register to 128 bits.
[0041] As another example, when the changed SIMD register size is 256 bits, the instruction conversion unit 21 changes the ymm register, which is a 256-bit SIMD instruction in x64, to the z register in AArch64. Specifically, the instruction conversion unit 21 converts the 256-bit SIMD instruction in x64 "vpadd ymm0,ymm1,ymm2" into an execution code for AArch64 similar to (10). As a result, the instruction conversion unit 21 sets the size of the z register to 256 bits, thereby allowing the z register converted from x64 to be processed as 256 bits.
[0042] Furthermore, when the instruction conversion unit 21 includes the xmm register, which is a 128-bit SIMD instruction of x64, it only has to change the xmm register to the z register of AArch64 and set the upper 128 bits of the changed z register to 0. Specifically, the instruction conversion unit 21 converts the 128-bit SIMD instruction of x64 "vpadd xmm0,xmm1,xmm2" into the execution codes (11) and (12) for AArch64. Note that (12) is an instruction to set the upper 128 bits (32-bit integer x 4) of the z0 register to 0. add z0.s,z1.s,z2.s (11) mov z0,p0 / m,0 (12)
[0043] As another example, when the changed SIMD register size is 512 bits, the instruction conversion unit 21 changes the zmm register, which is a 512-bit SIMD instruction of x64, to the z register of AArch64. Specifically, the instruction conversion unit 21 converts the 512-bit SIMD instruction of x64 "vpadd zmm0,zmm1,zmm2" into an execution code for AArch64 similar to (10). As a result, the instruction conversion unit 21 sets the size of the z register to 512 bits, thereby allowing the z register converted from x64 to be processed as 512 bits.
[0044] Furthermore, when the instruction conversion unit 21 includes a ymm register, which is a 256-bit SIMD instruction of x64, it only has to change the ymm register to a z register of AArch64 and set the upper 256 bits of the changed z register to 0. Specifically, the instruction conversion unit 21 converts the 256-bit SIMD instruction of x64 "vpadd ymm0,ymm1,ymm2" into an execution code for AArch64 in the same manner as (11) and (12). Note that (12) may be any instruction that sets the upper 256 (32-bit integer x 8) bits of the z0 register to 0.
[0045] Furthermore, when the instruction conversion unit 21 includes the xmm register, which is a 128-bit SIMD instruction of x64, it only has to change the xmm register to the z register of AArch64 and set the upper 384 bits of the changed z register to 0. Specifically, the instruction conversion unit 21 converts the 128-bit SIMD instruction of x64 "vpadd xmm0,xmm1,xmm2" into an execution code for AArch64 in the same manner as (11) and (12). Note that (12) may be any instruction that sets the upper 384 (32-bit integer x 12) bits of the z0 register to 0.
[0046] [Hardware configuration of the conversion device] Fig. 2 is a hardware configuration diagram of a conversion device according to an embodiment. As shown in Fig. 2, the conversion device 1 is a computer such as a high performance computer (HPC) or a server, and includes a storage device 10a, a memory 10b, a processor 10c, a communication interface 10d, a display device 10e, an input device 10f, and a recording medium 10h. These components are connected to each other by a bus 10g.
[0047] Among these, the storage device 10a is a non-volatile storage device such as an HDD (Hard Disk Drive) or an SSD (Solid State Drive), and stores an executable code 11 to be converted and an executable code 12 after conversion. The executable code 11 to be converted is a binary file of machine language obtained by compiling a source program for x64. The executable code 12 after conversion is a binary file of machine language for AArch64 after converting the executable code 11 to be converted.
[0048] The execution code 11 to be converted may be recorded in a computer-readable recording medium 10h, and the processor 10c may read the execution code 11 to be converted from the recording medium 10h.
[0049] Such recording media 10h include physically portable recording media such as CD-ROMs (Compact Disc - Read Only Memory), DVDs (Digital Versatile Discs), and USB (Universal Serial Bus) memories. Semiconductor memories such as flash memories and hard disk drives may also be used as the recording media 10h. These recording media 10h are not temporary media such as carrier waves that do not have a physical form.
[0050] Furthermore, the execution code 11 to be converted may be stored in a device connected to a public line, the Internet, a LAN (Local Area Network), or the like, and the processor 10c may read out the execution code 11 to be converted.
[0051] On the other hand, the memory 10b is hardware such as a DRAM that temporarily stores data, and the execution code 11 to be converted described above is expanded on the memory 10b. The execution code 11 to be converted to be expanded includes a plurality of instructions.
[0052] The processor 10c controls each part of the conversion device 1 described in FIG. 1. That is, the processor 10c is hardware such as a CPU (Central Processing Unit) or a GPU (Graphical Processing Unit) that converts the execution code 11 to be converted into the converted execution code 12 in cooperation with the memory 10b. The processor 10c is provided with a register file 14 that stores instructions, data, and the like. The details of the register file 14 will be described later. The processor 10c is also provided with a system register 15 that stores the bit length of the SIMD register. The bit length of the SIMD register selected by the vendor developing the CPU from among 128×n (n=an integer from 1 to 16) is set in advance in the system register 15. The bit length of the SIMD register selected from among 128×n (n=an integer from 1 to 16) during conversion is set in the system register 15. The processor 10c is, for example, A64FX manufactured by Fujitsu Limited. The A64FX is a processor capable of executing an instruction set that extends Arm's Armv8.2-A instruction set with SVE (Scalable Vector Extension). This instruction set is called AArch64.
[0053] Furthermore, the communication interface 10d is an interface for connecting the conversion device 1 to a network such as a LAN (Local Area Network).
[0054] The display device 10e is hardware such as a liquid crystal display device, and displays prompts for encouraging the developer to input various pieces of information. The input device 10f is hardware such as a keyboard and a mouse.
[0055] [Schematic diagram of a register file] 3 is a schematic diagram of the register file 14 included in the processor 10c. In the following, a case where the processor 10c executes an instruction set of AArch64 will be described as an example.
[0056] 3, the register file 14 includes a plurality of SIMD registers 140. The register file 14 also includes a plurality of predicate registers and a plurality of scalar registers, although not shown.
[0057] In the case of a CPU based on the Arm (AArch64) architecture, the vendor developing the CPU may select one of 128, 256, 384, 512, ... 2048 as the bit length of the SIMD register 140 for implementation. In FIG. 3, the bit length of the SIMD register is 512 bits. And, one SIMD register 140 can store eight pieces of 64-bit data. In the following, each of the multiple SIMD registers 140 will be identified by a character string of "z0", "z1", ... "z31".
[0058] The lower 128 bits of one SIMD register 140 are shared with another register, the v register. When the v register is used for an operation, a SIMD instruction specifying lanes "0" to "31" can be used.
[0059] [Example of conversion] Here, an example of converting x64 execution code into AArch64 execution code will be described with reference to Fig. 4. Fig. 4 is a diagram showing an example of converting x64 execution code into AArch64 execution code.
[0060] As shown in FIG. 4, the left column shows the result of disassembling the x64 executable code 11a to be converted.
[0061] The upper left shows the case where an xmm register is used. The xmm register shares the lower 128 bits of the 512 bits of the zmm register.
[0062] Under such circumstances, the instruction conversion unit 21 disassembles the execution code 11a to be converted and checks whether the SIMD instructions included in the execution code 11a to be converted include 128-bit SIMD instructions, 256-bit SIMD instructions, and 512-bit SIMD instructions. Here, since only xmm registers are used in the result of disassembling the execution code 11a to be converted, the instruction conversion unit 21 determines that the SIMD instructions included in the execution code 11a to be converted include only 128-bit SIMD instructions.
[0063] Then, the instruction conversion unit 21 generates and outputs an execution code that temporarily saves the setting value of the current CPU's SIMD register size. Here, the instruction conversion unit 21 obtains the setting value of the z register size from "ZCR_EL1", and generates and outputs an execution code that saves it in the x2 register (symbol c1). "ZCR_EL1" here is a system register that saves the setting value of the z register size.
[0064] Then, as a result of the check, the instruction conversion unit 21 finds that the SIMD instructions do not include 256,512-bit SIMD instructions, but only 128-bit SIMD instructions, so it generates and outputs an execution code that changes the set value of the SIMD register size to 128 bits. Here, the instruction conversion unit 21 generates and outputs an execution code that changes the set value of the size of the z register to "ZCR_EL1" as 128 bits (code c2).
[0065] Then, the instruction conversion unit 21 converts the xmm register, which is a 128-bit SIMD instruction of x64, into the z register of AArch64. Here, the instruction conversion unit 21 converts "vpadd xmm0, xmm1, xmm2" into the following execution code (c3) for AArc64. add z0.s,z1.s,z2.s (c3) The execution code of (c3) indicates the addition of four 32-bit integers. That is, this execution code writes 128 bits (32 bits x 4) of the result of z1 + z2 to z0.
[0066] Similarly, the instruction conversion unit 21 converts "vpadd xmm3,xmm4,xmm5" into the following execution code (c4) for Aarc64. add z3.s,z4.s,z5.s (c4)
[0067] Similarly, the instruction conversion unit 21 converts "vpadd xmm6,xmm7,xmm8" into the following execution code (c5) for Aarc64. add z6.s,z7.s,z8.s···(c5)
[0068] Then, the instruction conversion unit 21 generates and outputs an execution code for restoring the setting value of the CPU's SIMD register size to the temporarily saved size. Here, the instruction conversion unit 21 generates and outputs an execution code for restoring "ZCR_EL1" to the size saved in the x2 register (code c6).
[0069] As a result, when the SIMD instruction in the execution code 11a for x64 to be converted is only a 128-bit SIMD instruction, the instruction conversion unit 21 sets the z register size to 128 bits, so that "add z0.s,z1.s,z2.s" is processed as an addition instruction for 128 bits. Therefore, the instruction conversion unit 21 can convert the execution code 11a for x64 to obtain the same result as the execution code 11a for x64 to be converted without adding an instruction such as "mov z0,p0 / m,0" (setting "0" for 12 x 32-bit integers). As a result, the instruction conversion unit 21 can reduce the number of instructions in the execution code 12a for AArch64 after conversion, and convert it into an execution code that can be processed at high speed. Although five instructions are added to set and restore the z register size, the number of instructions in the execution code for x64 to be converted is several hundred to several thousand, so it may be ignored.
[0070] The bottom left shows the case where xmm and ymm registers are used. The xmm registers share the lower 128 bits of the 512-bit zmm registers. The ymm registers share the lower 256 bits of the 512-bit zmm registers.
[0071] Under such circumstances, the instruction conversion unit 21 disassembles the execution code 11a to be converted and checks whether the SIMD instructions included in the execution code 11b to be converted include a 128-bit SIMD instruction, a 256-bit SIMD instruction, and a 512-bit SIMD instruction. Here, since the xmm register and the ymm register are used in the result of disassembling the execution code 11a to be converted, the instruction conversion unit 21 determines that the SIMD instructions included in the execution code 11a to be converted include a 128-bit SIMD instruction and a 256-bit SIMD instruction.
[0072] Then, the instruction conversion unit 21 generates and outputs an execution code that temporarily saves the setting value of the current CPU's SIMD register size. Here, the instruction conversion unit 21 obtains the setting value of the z register size from "ZCR_EL1", and generates and outputs an execution code that saves it in the x2 register (symbol c21). "ZCR_EL1" here is a system register that saves the setting value of the z register size.
[0073] Then, as a result of the check, the instruction conversion unit 21 finds that the SIMD instructions do not include a 512-bit SIMD instruction, but include a 128-bit SIMD instruction and a 256-bit SIMD instruction, so it generates and outputs an execution code for changing the set value of the SIMD register size to 256 bits. Here, the instruction conversion unit 21 generates and outputs an execution code for changing the set value of the size of the z register to "ZCR_EL1" as 256 bits (code c22).
[0074] Then, the instruction conversion unit 21 converts the xmm register, which is a 128-bit SIMD instruction of x64, into the z register of AArch64. Here, the instruction conversion unit 21 converts "vpadd xmm0, xmm1, xmm2" into the following execution codes (c23) and (c24) for AArc64. add z0.s,z1.s,z2.s (c23) mov z0.s,p0 / m,0···(c24)
[0075] The execution code in (c23) indicates the addition of eight 32-bit integers. In other words, this execution code writes 256 bits (32 bits x 8) of the result of z1 + z2 to z0. In addition, the execution code in (c24) sets four 32-bit integers to 0 to produce the same result as in the x64 case. Note that "p0" is a predicate register, and specifies which 32-bit data is to be changed. " / m" specifies that unspecified 32-bit data is not to be changed. In other words, p0 in the execution code in (c24) is set to a value indicating the upper 128 bits (32 bits x 4) of the z register.
[0076] Then, the instruction conversion unit 21 converts the ymm register, which is a 256-bit SIMD instruction of x64, into the z register of AArch64. Here, the instruction conversion unit 21 converts "vpadd ymm3, ymm4, ymm5" into the following execution code (c25) for AArc64. add z3.s,z4.s,z5.s···(c25)
[0077] Then, the instruction conversion unit 21 generates and outputs an execution code for restoring the setting value of the CPU's SIMD register size to the temporarily saved size. Here, the instruction conversion unit 21 generates and outputs an execution code for restoring "ZCR_EL1" to the size saved in the x2 register (reference number 26).
[0078] As a result, when the SIMD instructions in the execution code 11a for x64 to be converted are 128-bit SIMD instructions and 256-bit SIMD instructions, the instruction conversion unit 21 sets the z register size to 256 bits, so that "add z3.s,z4.s,z5.s" is processed as an addition instruction for 256 bits. Therefore, the instruction conversion unit 21 can convert the execution code 11b for x64 to obtain the same result as the execution code 11b for x64 to be converted without adding an instruction such as "mov z3.s,p1 / m,0" (setting "0" for 8 x 32-bit integers). As a result, the instruction conversion unit 21 can reduce the number of instructions in the execution code 12b for AArch64 after conversion, and convert the execution code into an execution code that can be processed at high speed. Five instructions are added to set and restore the z register size, but since the number of instructions in the execution code for x64 to be converted is several hundred to several thousand, this may be ignored.
[0079] In addition, when the z register size is set to 256 bits, "add z0.s,z1.s,z2.s" is processed as a 256-bit addition instruction when a 128-bit SIMD instruction of x64 is converted. For this reason, the instruction conversion unit 21 needs to add an instruction such as "mov z0,p0 / m,0" (setting "0" for four 32-bit integers). However, since the execution code 11 to be converted includes a 256-bit instruction, the instruction conversion unit 21 can reduce the overall number of instructions in the execution code 12 for AArch64 after conversion even if the execution code 11 includes a 128-bit SIMD instruction, and can convert the execution code into an execution code that can be processed at high speed. Even when the z register size is set to 512 bits, the instruction conversion unit 21 provides the same effect. In other words, since the execution code 11 to be converted contains 512-bit instructions, even if the execution code 12 contains 128-bit or 256-bit SIMD instructions, the instruction conversion unit 21 can reduce the overall number of instructions in the converted execution code 12 for AArch64, and can convert it into an execution code that can be processed at high speed.
[0080] [Flowchart of command conversion process] Next, a flowchart of the instruction conversion process executed by the instruction conversion unit 21 will be described with reference to Figs. 5 to 9. Fig. 5 is a diagram showing an example of a flowchart of the instruction conversion process according to the embodiment. As shown in Fig. 5, the instruction conversion unit 21 analyzes the execution code 11 to be converted and performs the following process. The instruction conversion unit 21 checks whether the execution code 11 to be converted includes an instruction (A) that handles a 128-bit SIMD register, an instruction (B) that handles a 256-bit SIMD register, or an instruction (C) that handles a 512-bit SIMD register (step S11).
[0081] The instruction conversion unit 21 judges whether or not any of A, B, and C is included (step S12). If it is judged that any of A, B, and C is not included (step S12; Yes), the instruction conversion unit 21 executes a process a for the case where there is no SIMD instruction (step S13). The flowchart of the process a will be described later. Then, the instruction conversion unit 21 ends the instruction conversion process.
[0082] On the other hand, if it is determined that any of A, B, or C is included (step S12; No), the instruction conversion unit 21 determines whether or not only A is included (step S14). If it is determined that only A is included (step S14; Yes), the instruction conversion unit 21 executes process b for the case of only 128-bit SIMD instructions (step S15). The flowchart of process b will be described later. Then, the instruction conversion unit 21 ends the instruction conversion process.
[0083] On the other hand, if it is determined that the instruction does not include only A (step S14; No), the instruction conversion unit 21 determines whether or not only A and B are included (step S16). If it is determined that only A and B are included (step S16; Yes), the instruction conversion unit 21 executes process c for the case where there is no 512-bit SIMD instruction (step S17). The flowchart of process c will be described later. Then, the instruction conversion unit 21 ends the instruction conversion process.
[0084] On the other hand, if it is determined that not only A and B are included (step S16; No), the instruction conversion unit 21 executes a process d for the case where a 512-bit SIMD instruction is included (step S18). The flowchart of the process d will be described later. Then, the instruction conversion unit 21 ends the instruction conversion process.
[0085] Next, a flowchart of process a in the case where there is no SIMD instruction will be described with reference to Fig. 6. Fig. 6 is a diagram showing an example of a flowchart of process a. As shown in Fig. 6, the instruction conversion unit 21 converts an x64 instruction that does not include a SIMD instruction to be converted into a corresponding AArch64 instruction and outputs it (step S21). Then, the instruction conversion unit 21 ends process a.
[0086] Next, a flowchart of process b in the case of only 128-bit SIMD instructions will be described with reference to Fig. 7. Fig. 7 is a diagram showing an example of a flowchart of process b. As shown in Fig. 7, the instruction conversion unit 21 temporarily saves the current setting value of the SIMD register size of the CPU (step S31).
[0087] Then, the instruction conversion unit 21 outputs an execution code for changing the setting value of the CPU's SIMD register size to 128 bits (step S32).Then, the instruction conversion unit 21 converts the 128-bit x64 SIMD instruction into an AArch64 instruction under the assumption that the SIMD register size is 128 bits, and outputs the instruction (step S33).
[0088] Then, the instruction conversion unit 21 judges whether all x64 SIMD instructions in the execution code 11 to be converted have been converted (step S34). If it is judged that all have not been converted (step S34; No), the instruction conversion unit 21 proceeds to step S33 to convert the x64 SIMD instructions that have not yet been converted.
[0089] On the other hand, if it is determined that all have been converted (step S34; Yes), the instruction conversion unit 21 outputs an execution code for changing the SIMD register size of the CPU to the temporarily saved size (step S35). Then, the instruction conversion unit 21 ends the instruction conversion process.
[0090] Next, a flowchart of process c in the case where there is no 512-bit SIMD instruction will be described with reference to Fig. 8. Fig. 8 is a diagram showing an example of a flowchart of process c. As shown in Fig. 8, the instruction conversion unit 21 temporarily saves the current setting value of the SIMD register size of the CPU (step S41).
[0091] Then, the instruction conversion unit 21 outputs an execution code for changing the setting value of the CPU's SIMD register size to 256 bits (step S42).Then, the instruction conversion unit 21 converts the x64 128-bit SIMD instruction and the 256-bit SIMD instruction into an AArch64 instruction under the assumption that the SIMD register size is 256 bits, and outputs the instruction (step S43).
[0092] Then, the instruction conversion unit 21 judges whether or not all x64 SIMD instructions in the execution code 11 to be converted have been converted (step S44). If it is judged that all have not been converted (step S44; No), the instruction conversion unit 21 proceeds to step S43 to convert the x64 SIMD instructions that have not yet been converted.
[0093] On the other hand, if it is determined that all have been converted (step S44; Yes), the instruction conversion unit 21 outputs an execution code for changing the SIMD register size of the CPU to the temporarily saved size (step S45). Then, the instruction conversion unit 21 ends the instruction conversion process.
[0094] Next, a flowchart of process d in the case where a 512-bit SIMD instruction is present will be described with reference to Fig. 9. Fig. 9 is a diagram showing an example of a flowchart of process d. As shown in Fig. 9, the instruction conversion unit 21 temporarily saves the current setting value of the SIMD register size of the CPU (step S51).
[0095] Then, the instruction conversion unit 21 outputs an execution code for changing the setting value of the CPU's SIMD register size to 512 bits (step S52).Then, the instruction conversion unit 21 converts the x64 128-bit SIMD instruction, 256-bit SIMD instruction, and 512-bit SIMD instruction into an AArch64 instruction under the assumption that the SIMD register size is 512 bits, and outputs the instruction (step S53).
[0096] Then, the instruction conversion unit 21 judges whether or not all x64 SIMD instructions in the execution code 11 to be converted have been converted (step S54). If it is judged that all have not been converted (step S54; No), the instruction conversion unit 21 proceeds to step S53 to convert the x64 SIMD instructions that have not yet been converted.
[0097] On the other hand, if it is determined that all have been converted (step S54; Yes), the instruction conversion unit 21 outputs an execution code for changing the SIMD register size of the CPU to the temporarily saved size (step S55). Then, the instruction conversion unit 21 ends the instruction conversion process.
[0098] In the embodiment, the instruction conversion unit 21 converts an x64 SIMD instruction for an addition instruction into an AArch64 SIMD instruction in accordance with the changed SIMD register size of the CPU. However, the instruction conversion unit 21 is not limited to the addition instruction, and may convert an x64 SIMD instruction into an AArch64 SIMD instruction in the same manner for other arithmetic operations and logical operations.
[0099] In the embodiment, the conversion device 1 converts the execution code 11 to be converted into the converted execution code 12. However, a target machine that executes the converted execution code 12 may convert the execution code 11 to be converted into the converted execution code 12. The target machine here has a processor and a memory, and the processor and the memory work together to execute the converted execution code 12. The processor is provided with a register file 14 that stores instructions, data, etc., and a system register 15. The processor may be the same as the processor 10c of the conversion device 1, for example.
[0100] [Effects of the embodiment] According to the above embodiment, the conversion device 1 checks whether the SIMD instructions included in the x64 execution code to be converted include 128×n (n=an integer from 1 to 16)-bit SIMD instructions. If the conversion device 1 does not include a 256-bit or more SIMD instruction and includes a 128-bit SIMD instruction, the conversion device 1 generates and outputs execution code for changing the setting value of the SIMD register size of the CPU to 128 bits. The conversion device 1 switches to a conversion destination SIMD instruction when converting the 128-bit SIMD instruction of x64 to a SIMD instruction of AArch64 according to the changed SIMD register size. Then, the conversion device 1 converts and outputs the execution code for x64 to be converted into the execution code for AArch64. As a result, the conversion device 1 changes the setting value of the SIMD register size of the CPU according to the SIMD instruction included in the x64 execution code to be converted, thereby reducing the number of instructions at the conversion destination, and the execution code for x64 can be converted into the execution code for AArch64 that can be processed at high speed.
[0101] According to the above embodiment, the conversion device 1 generates and outputs an execution code that saves the current setting value of the SIMD register size of the CPU before changing the setting value of the SIMD register size of the CPU. After completing the conversion of the execution code for x64 to be converted, the conversion device 1 generates and outputs an execution code that returns the setting value of the SIMD register size of the CPU to the saved setting value of the SIMD register size. This allows the conversion device 1 to convert the execution code for x64 to the execution code for AArch64 that can process the execution code for x64 at high speed for each execution code for x64 to be converted that has a different SIMD instruction size.
[0102] According to the above embodiment, the conversion device 1 generates and outputs an execution code that changes the set value of the SIMD register size of the CPU to 256 bits when the conversion device does not include a SIMD instruction of 512 bits or more and includes a SIMD instruction of 256 bits. Then, the conversion device 1 generates and outputs an execution code that changes the set value of the SIMD register size of the CPU to 512 bits when the conversion device does not include a SIMD instruction of more than 512 bits and includes a SIMD instruction of 512 bits. This allows the conversion device 1 to convert the execution code for x64 to the execution code for AArch64 that can process the execution code for x64 at high speed for each of the execution codes for x64 to be converted that have different SIMD instruction sizes.
[0103] According to the above embodiment, when a 128×n1-bit SIMD instruction and a 128×n2 (n1>n2)-bit SIMD instruction are included, the conversion device 1 generates and outputs an execution code that changes the setting value of the SIMD register size of the CPU to 128×n1 bits. Then, the conversion device 1 switches the 128×n1-bit SIMD instruction to a 128×n1-bit converted SIMD instruction. The conversion device 1 switches the 128×n2-bit SIMD instruction to a 128×n1-bit converted SIMD instruction, and switches the 128×n2-bit SIMD instruction to a 128×n1-bit converted SIMD instruction that sets the upper bits of the converted SIMD instruction to zero by the value obtained by subtracting 128×n2 from 128×n1. This allows the conversion device 1 to convert the x64 executable code to the AArch64 executable code even if the x64 executable code to be converted includes a SIMD instruction of a different size.
[0104] [others] Note that each component of the illustrated conversion device 1 does not necessarily have to be physically configured as illustrated. In other words, the specific form of distribution and integration of the conversion device 1 is not limited to that shown in the figure, and all or part of it can be functionally or physically distributed and integrated in any unit according to various loads, usage conditions, etc. Also, the storage unit 30 may be connected to the conversion device 1 as an external device via a network.
[0105] The following supplementary notes are further disclosed regarding the embodiments including the above examples.
[0106] (Note 1) Check whether the SIMD instructions in the x64 executable code to be converted contain 128×n (n=1,2,4)-bit SIMD instructions. If the program does not include a 256-bit or larger SIMD instruction but includes a 128-bit SIMD instruction, generate and output execution code that changes the CPU's SIMD register size setting to 128 bits; Depending on the changed SIMD register size, the SIMD instruction to be converted is changed when converting the x64 128-bit SIMD instruction to the AArch64 SIMD instruction. The target x64 executable code is converted to AArch64 executable code and output. A conversion program that causes a computer to carry out processing.
[0107] (Appendix 2) Before changing the setting value of the SIMD register size of the CPU, generate and output an execution code that saves the current setting value of the SIM register size of the CPU; After the conversion of the execution code for x64 to be converted is completed, an execution code is generated and output to return the setting value of the SIMD register size of the CPU to the saved setting value of the SIMD register size. 2. The conversion program according to claim 1,
[0108] (Note 3) The process of generating and outputting execution code to change the setting value of the SIMD register size generates and outputs execution code to change the setting value of the CPU's SIMD register size to 256 bits if the instruction does not include a SIMD instruction of 512 bits or more and includes a 256-bit SIMD instruction, and generates and outputs execution code to change the setting value of the CPU's SIMD register size to 512 bits if the instruction does not include a SIMD instruction of more than 512 bits and includes a 512-bit SIMD instruction. 2. The conversion program according to claim 1,
[0109] (Note 4) The process of generating and outputting execution code for changing the setting value of the SIMD register size includes, when the SIMD instruction includes a 128×n1-bit SIMD instruction and a 128×n2 (n1>n2)-bit SIMD instruction, generating and outputting execution code for changing the setting value of the SIMD register size of the CPU to 128×n1 bits; The process of switching to the converted SIMD instruction includes: For 128×n1-bit SIMD instructions, switch to 128×n1-bit destination SIMD instructions, For a 128×n2-bit SIMD instruction, the instruction is switched to a 128×n1-bit destination SIMD instruction, and the upper bits of the destination SIMD instruction are set to zero by the value obtained by subtracting 128×n2 from 128×n1. 2. The conversion program according to claim 1,
[0110] (Note 5) Check whether the SIMD instructions in the x64 executable code to be converted contain 128×n (n=1,2,4)-bit SIMD instructions. If the program does not include a 256-bit or larger SIMD instruction but includes a 128-bit SIMD instruction, generate and output execution code that changes the CPU's SIMD register size setting to 128 bits; Depending on the changed SIMD register size, the SIMD instruction to be converted is changed when converting the x64 128-bit SIMD instruction to the AArch64 SIMD instruction. The target x64 executable code is converted to AArch64 executable code and output. A conversion method in which processing is performed by a computer.
[0111] (Note 6) A check unit that checks whether the SIMD instructions included in the x64 executable code to be converted include 128×n (n=1, 2, 4)-bit SIMD instructions; a generating and outputting unit that generates and outputs an execution code for changing a setting value of a SIMD register size of the CPU to 128 bits when the SIMD instruction does not include a SIMD instruction of 256 bits or more and includes a SIMD instruction of 128 bits; a switching unit that switches a 128-bit x64 SIMD instruction to a destination SIMD instruction when converting the 128-bit x64 SIMD instruction to a destination SIMD instruction of the AArch64 according to the changed SIMD register size; a conversion output unit that converts the x64 executable code to be converted into an AArch64 executable code and outputs the converted code; A conversion device comprising: [Explanation of symbols]
[0112] 1. Conversion device 10a storage device 10b Memory 10c processor 10d Communication Interface 10e display device 10f Input Device 10g Bus 10h Recording medium 11 Execution code to be converted 12 Execution code after conversion 14 Register File 15 System Registers 20 Control section 21 Command conversion unit 30 Storage section 140 SIMD Registers
Claims
1. Check whether the SIMD instructions included in the x64 executable code to be converted include 128×n (n=1, 2, 4)-bit SIMD instructions, If the instruction does not include a 256-bit or more SIMD instruction but includes a 128-bit SIMD instruction, generate and output an execution code for changing the setting value of the SIMD register size of the CPU to 128 bits; According to the changed SIMD register size, a conversion destination SIMD instruction is switched when converting a 128-bit x64 SIMD instruction into an AArch64 SIMD instruction; The execution code for x64 to be converted is converted into an execution code for AArch64 and output. A conversion program that causes a computer to carry out processing.
2. Before changing the setting value of the SIMD register size of the CPU, generate and output an execution code for saving the current setting value of the SIM register size of the CPU; After the conversion of the execution code for x64 to be converted is completed, an execution code is generated and output for returning the setting value of the SIMD register size of the CPU to the saved setting value of the SIMD register size.
2. The conversion program according to claim 1 .
3. The process of generating and outputting execution code for changing the set value of the SIMD register size generates and outputs execution code for changing the set value of the SIMD register size of the CPU to 256 bits if the SIMD instruction does not include an SIMD instruction of 512 bits or more but includes an SIMD instruction of 256 bits, and generates and outputs execution code for changing the set value of the SIMD register size of the CPU to 512 bits if the SIMD instruction does not include an SIMD instruction of more than 512 bits but includes an SIMD instruction of 512 bits.
2. The conversion program according to claim 1 .
4. The process of generating and outputting execution code for changing the set value of the SIMD register size includes, when the instruction includes a 128×n1-bit SIMD instruction and a 128×n2 (n1>n2)-bit SIMD instruction, generating and outputting execution code for changing the set value of the SIMD register size of the CPU to 128×n1 bits; The process of switching to the converted SIMD instruction includes: For 128×n1 bit SIMD instructions, switch to 128×n1 bit destination SIMD instructions, A 128×n2-bit SIMD instruction is switched to a 128×n1-bit destination SIMD instruction, and the upper bits of the destination SIMD instruction are set to zero by the value obtained by subtracting 128×n2 from 128×n1.
2. The conversion program according to claim 1 .
5. Check whether the SIMD instructions included in the x64 executable code to be converted include 128×n (n=1, 2, 4)-bit SIMD instructions, If the instruction does not include a 256-bit or more SIMD instruction but includes a 128-bit SIMD instruction, generate and output an execution code for changing the setting value of the SIMD register size of the CPU to 128 bits; According to the changed SIMD register size, a conversion destination SIMD instruction is switched when converting a 128-bit x64 SIMD instruction into an AArch64 SIMD instruction; The execution code for x64 to be converted is converted into an execution code for AArch64 and output. A conversion method in which processing is performed by a computer.
Citation Information
Patent Citations
Compiler and compilation method
JP2023002165A
