TOOL-LEVEL AND HARDWARE-LEVEL CODE OPTIMIZATION AND RESPECTIVE HARDWARE MODIFICATION
The present invention related to a method for compiling high-level software code into hardware, transforming each instruction into a respective hardware block and using an execution control signal representing the program pointer for triggering the execution within each respective hardware block.
Latest Hyperion Core, Inc. Patents:
This application is a continuation of U.S. patent application Ser. No. 14/124,636, filed Jan. 13, 2014, which is a U.S. national phase of International Patent Application No. PCT/EP2012/002419, filed Jun. 6, 2012, which claims priority to European Patent Application No. 11 009 912.4, filed Dec. 16, 2011, European Patent Application No. 11 007 370.7, filed Sep. 9, 2011, European Patent Application No. 11 005 196.8, filed Jun. 27, 2011, and European Patent Application No. 11 004 667.9, filed Jun. 8, 2011, all of which are hereby incorporated by reference as if set forth in full in the application for all purposes.
PRIORITYPriority is claimed to [1], [2], [3], [4], and [5].
REFERENCE TO COMPUTER PROGRAM LISTING APPENDIX AND INCORPORATION BY REFERENCEA computer program listing appendix is included with this application on a compact disc (CD) (in duplicate). The entire contents of the program listing appendix are incorporated by reference into the patent for complete disclosure. The file name, date, and size in bytes for the files submitted on the compact disc are:
Program Listing 1: LISTING1.txt, May 9, 2017, 11 KB
Program Listing 2: LISTING2.txt, May 9, 2017, 14 KB
Introduction and Field of InventionTools for compiling high-level software code (e.g. C, C++, Fortran, etc) to hardware are known in the prior art. For example compilers from Handle-C(Celoxica), Impulse-C (Impulse Accelerated Technologies) are known.
Those tools focus on transforming high-level code into as optimal as possible hardware, e.g. in terms of area, power dissipation and/or performance.
Those tools have in common that the high-level code has to be modified for being transformable. Tools require hints (pragmas) to guide the compiler and/or support only a subset of the high-level language, or are even rather different but only use syntax similar to a known high-level language.
With smaller silicon geometries, area limitations are not particularly critical. With today's multi-core processor architectures even performance becomes less critical. However, power aspects become increasingly important and a driving factor for compiling high-level software code to hardware. Simultaneously time-to-market contradicts major code modifications as required in the state-of-the-art.
This patent describes a method and hardware architecture which allows compiling high-level software code to hardware without major modifications.
A standard high-level compiler might compile high-level code into assembly code without any modifications. Note: Later in this patent are possible optimizations described which may make the code produced by the compiler more efficient.
Each resulting assembly instruction is then compiled into a hardware block, representing the instructions. The interface of the hardware block is defined by the source and target registers and possible status checking or generation of the assembly instruction.
In addition, each hardware block receives an execution signal (in_exec) for triggering operation and returns an execution signal (out_exec) if the operation has been performed and the result is produced.
A graph (code graphl.txt) representing the data transmission via the registers is generated by an analyser function (ANALYZER). The hardware blocks are chained respectively together by connecting the outputs and inputs of the blocks as defined by the register accesses of the assembly code.
Each block could operate synchronous and comprise respective registers at the signal inputs and/or output.
However, in a preferred embodiment, the blocks operate asynchronous for optimizing cycle time. Registers are inserted under e.g. at least one of the following exemplary conditions:
-
- 1. A block is complex and produces a long signal delay reduces the target frequency. This could be e.g. complex calculations, multipliers, etc.
- 2. A block depends on external timing and/or has to synchronize with external data senders and/or receivers.
The signals in_exec and out_exec connect the blocks and trigger their operation. By such, the in_exec/out_exec signal chain represents the program pointer of a real processor executing the assembly code.
Load/Store operations are implemented and stack accesses are performed as described in the assembly code. Therefore even recursive code can be processed.
In one embodiment, the generated hardware function comprising the assembly code might use dedicated memories for holding data local to the hardware function. For example preferably at least a local stack memory is implemented.
Blocks are grouped into modules. The contents of a module are defined by the execution graph of the assembly code. Some exemplary rules are:
-
- 1. Jump target address defines the beginning of a module. Jump target addresses can be detected by labels in the assembly code and/or target addresses of jump instructions. A jump target address is any jump target of any instruction (e.g. jmp; call; mov pc,r . . . (in ARM assembly)).
- 2. Jump instructions define the end of a module (e.g. jmp; call; mov pc,r_. (in ARM assembly)).
- 3. Saving the program counter (PC) into a link register (as e.g. known from ARM processors).
- If the PC is saved with an offset, simultaneously the address PC+offset is defining the beginning of a new module.
Modules receive all register content according to the real processors register file as input and send all registers back as output. This may include any status and/or processor control and/or processor supervising registers.
Modules are preferably synchronous and register the input and/or output information. By such each module represents the register file of the real processor. It receives data from the internally grouped blocks and provides the data to other modules acting as register file.
If the signal delay within a module becomes too long to meet the target frequency, pipeline stages might be inserted in the module.
Modules are combined in a main routine (main). A call graph (which may comprise additional information) is generated by analysing the program pointer modifications in the assembly language. The main routine respectively has an input multiplexer in front of each module for receiving the input data from all potentially previously executed modules potentially jumping to/addressing the respective module. The selection of each of the multiplexers is controlled by the exec signals received from the previously executed module addressing the respective module.
Reconfigurable CoreThe shown algorithm performs efficiently for small algorithms and functions (such as e.g. a FIR filter or a DCT). However, more complex algorithms, such as e.g. a complete H.264 video decoder will require an unacceptable amount of silicon area.
The solution to this problem is two-fold:
-
- 1. Using a reconfigurable hardware architecture, which is in line with the processing model of the compiler algorithm. The hardware platform is reused over time for various configurations, each representing a part of the algorithm to be processed.
- 2. Partitioning the compiled code into configuration, fitting and efficiently performing on the reconfigurable hardware.
The ALUs are capable performing functions according to the instructions set used by the compiler (or vice versa, the instruction set of the compiler is in accordance with the functions provided by the ALUs). In one embodiment, the required capabilities of the ALUs are analysed by the compiler at compile time and the ALUs are respectively designed in hardware. In one particular embodiment, the ALUs within the datapath (0101) may be heterogeneous and offer different functionality. The respective functions are defined by analysing the target algorithms, e.g. the compiler (or analysis tools such as profilers) could define on basis of one or a set of target algorithms which instructions are required, at which position(s) within the datapath and/or how frequently they are required be required (e.g. in only one ALU within the datapath, 2 ALUs or any other amount).
Preferably, the elements (e.g. ALUs) within the datapath operate asynchronously, so that all datapath operations are performed in a single clock cycle and then the next configuration is executed or the same configuration is repeated (e.g. for processing loops) once again. However, in some embodiments at least some pipelining might be supported, e.g. each or some of the ALUs comprise operand and/or result registers. In some embodiments some ALUs may comprise operand registers, while others comprise result registers and again others have no registers at all. Yet in other embodiments, pipeline stages may be drawn into the datapath at several physical stages not related to ALUs, e.g. in between the first and second half of the datapath, or after each quarter. The registers might be positioned in the interconnect structure.
Operand data is received from a register file (0102) and the results are written back to the register file.
It is typical for configurable architectures, that any element of a configurable array can send data to any other element. Particularly there is no strict limitation in which direction result data is send and from which direction operand data is received. Reference is made e.g. to Xilinx's Virtex4, -5, -6, and -7 FPGA series, PACT's XPP architecture, IMEC's ADRES architecture and othet academic projects such as KressArray, Pleiades, PADDI, and DPGAs. This unlimited degree of freedom leads to various problems, e.g. the undefined timing and operation termination characteristic, which even includes potential timing loops in non-registered signal paths.
In the preferred implementation the datapath interconnection architecture of the ZZYX processors is implemented in its strictest variant, which is limited to a unidirectional top-to-bottom data transmission. Reference is made to [4], e.g.
Particularly if the datapath operates asynchronously it is important to reduce the ALUs complexity to achieve an acceptable operating frequency. Therefore, complex time consuming instructions (e.g. multiplications) and/or multi-cycle instructions (e.g. division) are implemented in a dedicated Complex Function Block (CFB) (0103) separated from the datapath. The CFB performs such function(s) preferably within the cycle-time of the datapath (0101).
In one particular embodiment, the reconfigurable core might represent a standard processor or DSP, such as e.g. an ARMS, Intel ×86 or a TI C64. The register file might represent exactly the registers as available in the respective processor. However, those register files are small, limiting the potential parallelism in the datapath. Therefore it is preferred using a larger register file, e.g. providing 32 to 256 registers depending on the amount of ALUs in the datapath. Analysis has shown, that for typical datapath sizes (e.g. 4×4, 6×4, or 6×6 arrays of ALUs) register files of about 32 registers (±16) are reasonable.
In one implementation of the software tool-chain (e.g. C-compiler, linker, assembler, etc.) the compiler might use already a larger amount of registers and generate an incompatible binary with the standard processor and/or produce directly the configuration binary. In other implementations of the tool-chain a configuration-generator (CG) might analyse the register use and dependency and extend the amount of registers at that stage, e.g. by reassigning the registers or inserting virtual registers.
Typically the reconfigurable core comprises a Configuration Pointer (CP) or Configuration Counter (CC) register which is the respective substitution of the processors program pointer (PP) or program counter (PC). Within this patent we may use PC or PP, which are synonymous. The CC/CP (0104) points to the next configuration in a configuration memory (0105) to be configured and executed indicated by 0106.
The configuration memory might be a non-volatile memory, such as a ROM or Flash-ROM. In other embodiments it might be a RAM, particularly a SRAM. The RAM might be preloaded from another instance. Alternatively the RAM might operate similar to a Level-1 instruction cache (quasi a Level-1 configuration cache) and receive configuration from higher memory instances in the memory hierarchy, e.g. a Level-2 and/or Level-3 cache, or ultimately the system memory.
It shall be expressively noted, that the invention is applicable on ZZYX processor cores and may be used as a compiler or directly implemented in the processor hardware e.g. as shown in
In difference to reconfigurable architectures in the prior art, Load/Store Operations (LSO) are managed separately from other operations. The reasons are manifold, for example: LSO, particularly load operations, require a different timing model than other operations (e.g. ADD, SUBtract, ShiFT) as the latency of the memory access must be taken into account. Further LSO, particularly load operations, limit the achievable parallelism due to the bottleneck of accessing the memory.
Those reasons are some examples why in the prior art the programmer had to take specific measures to code and manage memory accesses and/or they significantly reduced the performance of the reconfigurable architecture. In the following an advanced architecture is described overcoming those limitations in conjunction with a novel Optimizer for compilers and/or low level tools to manage LSO more efficiently.
Particularly for timing reasons, LSO are not performed within the datapath, but in a dedicated separated Load/Store Block (LSB) (0107). The LSB has direct access to the register file.
Within the LSB a plurality of Load/Store Units (LSU) might be located, each LSU (0108) operating in parallel to the others on dedicated memory blocks (0109), supporting a plurality of data accesses in parallel. Some of the dedicated memories might be small scratch memories (e.g. Tightly-Coupled Memories (TCM)); some of them might be preloadable (so that e.g. constant data can loaded); some of them might be loaded from and off-loaded to the memory hierarchy (0110) (e.g. for supporting context switching), while others are only scratch da-to which could be destroyed (e.g. in a context switch). Other dedicated memory might be Level-1 data caches exchanging data with the higher memory hierarch (0110). Preferably each of the Level-1 caches operates in a dedicated and exclusive memory address range, so that no coherence problems exist. Reference is made to [1], [2], [4] and [5] which are all entirely incorporated by reference into this patent for full disclosure and claims my comprise features of those references.
In a preferred embodiment the plurality of LSU is not only capable of accessing different memory ranges in parallel, but at least some of the LSU (preferably all of them) may support parallel accessing of data within a vicinity. This technology and benefits are described in detail in [5].
Conditional ExecutionProcessors tend to fine granular conditional execution, which frequently disturbs the linear increment of the program pointer (PC/PP). Theoretically a reconfigurable architecture could jump on the granularity of configurations (see e.g. [7] or [8]) or select parts of a configuration for execution (see e.g. [91), if the tools are capable of generating respective code. Particularly for selecting parts of configurations for execution, it is required to replace the conditional jump operation by a conditional execution enable signal.
Some processors, e.g. ARM provide one conditional execution filed per instruction, which supports conditional execution based on one single state (e.g. one flag). More complex (e.g. nested) conditions are not supported. However, even in rather simple algorithms it is not sufficient to support only one single conditional level.
While processors, such as ARM, have to trade-off between performance and dense instruction set, configurable technologies tend to have slightly larger headroom and can afford some additional control bits for managing conditional execution in both the configuration data file and the actual hardware. Therefore, depending on the implementation 8 to 16 conditional levels are supported in the inventive core, future implementations may even support more levels.
SynchronisationConfigurable processors in the prior art either support no implicit synchronization (requiring explicit timing management by the software and/or programmer) as e.g. FPGAs, DPGAs and the like, or synchronization statemachines in each element (making timing entirely transparent to the programmer and/or software but requiring additional hardware) as e.g. PACT XPP.
In the inventive embodiment, synchronization occurs on a configuration level driven by the clock signal. Configurations have to terminate and complete data processing within the granularity of a clock cycle. Typically a configuration has to complete and terminate within one single clock cycles. However, depending on the complexity of the data path in asynchronous implementations, data may take longer to cross the datapath than a single clock cycle. It would certainly be possible to limit the datapath such that any operation will be completed within a clock cycles, and/or extend the compiler tool chain such that it ensures that the generated code meets the timing requirements.
ClockIn a preferred embodiment the processor hardware and the complier tool chain supports (maybe additionally) to configure the synchronization depending on the execution time (signal delay time) within the datapath. In this case at least for some configuration the number of clock cycles to complete da-to processing is configurable. In typical implementations small ranges, such as 2 to 4 clock cycles is sufficient, while for datapaths supporting complex operations (e.g. floating point) the number of clock cycles should be configurable in a far larger scale, e.g. up to 128 clock cycles.
Description of a Code ExampleFor further explanation reference is made to the ARM Thumb assembly code (CODE1) in Appendix A of the present specification. This code is part of the ×264 Encoder [6]. The listed code does not require much explanation as it is obvious for a person skilled in the art that the lines start with the line number, followed by an instruction or a label. Instructions comprise a 32-bit binary displayed in hexadecimal notation. Although Thumb instruction set is used, the binary is already displayed in standard ARM non-Thumb binary code. Constant values are indicated by .word. For more detailed information reference is made to the ARM instruction set documentation.
The code in Appendix 1 (CODE1) is translated into a new format (CODE2) as shown in Program Listing 1 of the computer program listing appendix.
This translation may be performed at various levels, which may be claimed separately.
In one embodiment, the translation is already performed at compile time. In this case not necessarily a translation is performed, but the compiler back end may directly emit code according to CODE2. The respective optimization is then part of the compiler optimization passes and the backend generates the respective code. The optimization passes may operate on the compiler internal data structures, such as e.g. the dependency graphs, DAGs, etc.
In another embodiment, the translation is performed in an intermediate step, analysing already compiled code and transforming it. This may happen in a separated tool run. Alternatively or additionally the operating system may perform the translation e.g. while installing the respective software, or while starting the respective software (e.g. by the loader). In yet another embodiment the translation is performed in hardware, e.g. within the micro-processor chip. As will be described, the translation may be performed at execution time. In one embodiment it is performed in front of and/or using an instruction cache and/or buffer structure.
In one embodiment, the optimization is done at different stages, for example:
At compile time the ideal instruction dependency might be analysed and the instructions respectively sorted, particularly in respect of the load/store instructions (LSI).
Possibly at install and/or load time, e.g. for adaption ideally to the systems memory and/or IO architecture.
At runtime within the processor, e.g. for expanding the binary from the limited instruction set architecture (ISA) to the processors hardware capabilities (e.g. a virtual register file).
The first characters of the CODE2 listing are for debugging purposes (<, −, >) and do not require detailed explanation. The line number is next, followed by a conditional control field comprising 16 levels of additional conditional execution levels. The respective instruction is executed depending on the conditional control settings and status flags provided by earlier executed instructions, such as compare instructions (cmp). It is followed by the binary and the instruction mnemonic. The register references are enhanced with dependency information, an underscore followed by the address of the register source, or in case of a register target followed by the current address. The mnemonic is enhanced with conditional and flag information. For each conditional level the flag source is provided, indicated by “f_” followed by the source's address. Instructions generating flags are enhanced with “c_” and the current address, indicating the conditional information (flags) are provided.
Instruction using a register (e.g. as base address), modifying it and writing back a different value, are enhanced with the full register access sequence: For example push {r3, r4, r5, r6, r7, lr} uses the stack pointer (r13) as base address for the data transfer and returns the modified stack point to the register. Consequently the instruction is replaced by push /t13_007c, s13_0000/!, {s3_0000, s4_0000, s5_0000, s6_0000, s7_0000, s14_0000} for indicating all register transactions requiring for the optimization.
It shall be mentioned here, that the reference _0000 indicates that the registers of the function (callee) are set prior to entering the function by the calling routine (caller).
The code (CODE2) is partitioned into boxes (BOX n). All instructions within a box can execute simultaneously. In this embodiment an asynchronous datapath is implemented, supporting a plurality of instructions, even depending ones, to be issued in one clock cycles and executed in one clock cycle. Load/Store instructions cannot be executed asynchronously due to the rather long delays and/or the pipelined nature of the memory subsystem, e.g. even a level-1 cache access may require a plurality of clock cycles. Therefore depending Load/Store instructions are placed in different boxes.
In one embodiment a box comprises a sequence of instructions which might execute concurrently and asynchronously. Instructions might depend on other instructions, e.g. a result of an instruction might feed operands of one or more subsequent instructions. Instructions within a box might execute conditionally, e.g. as known from the ARM instruction set (see condition field of ARM instructions, e.g. [13]). A jump (or call) or conditional jump (or call) defines the end of a box and is usually the last instruction to be placed into a box. In another embodiment the instructions within the box must be independent, i.e. a result of an instruction might not feed operands of one or more subsequent instructions.
In one embodiment a jump target (instruction to be jumped to by a jump or conditional jump instruction) must be located at the very beginning of a box, i.e. the first instruction. Only one jump target is supported per box.
In another embodiment multiple jump targets might be allowed within a box which can even be placed at random position. In this case the hardware must decode the instruction pointer PP delivered by the previous box initiating the jump into the box and omit all instructions prior to the instruction pointer PP.
In a preferred embodiment, all instructions of a box have the same timing, e.g. perform in a single clock cycle, two clock cycles, . . . n clock cycles. Also instructions with the same timing model might be grouped, e.g. load instructions which have to wait for the incoming data, or store instructions which depend on the availability of write access to memory. Those boxes trigger all individual instructions once for a single execution, individual instructions might perform and terminate independently of others. The box is only left, i.e. execution continued with the next subsequent box, if each individual instruction has been performed and terminated.
A box is left with a pointer to the next box to be executed, preferably this pointer is the instruction pointer PP. For further details see
Load/Store instructions (LSI) are grouped. In an ideal embodiment of the Load/Store Units (LSU) all or at least some of the Load/Store instructions (LSI) can be executed simultaneously. Theoretically all LSI within a box can be executed in parallel, however the capabilities of the LSU may limit the achievable concurrency.
It is therefore preferred, that a plurality of memories is implemented, each memory operating on a different address range. Reference is made to [1] and [2], describing respective memory hierarchies. It shall be noted again, that these patents are entirely incorporated by reference for full disclosure and respective claims may use features described in them.
In an even more preferred embodiment a plurality of addresses are accessible simultaneously within at least some of the single memories. Reference is made to [5], describing a respective memory. It shall be noted again, that this patent is entirely incorporated by reference for full disclosure and respective claims may use features described in it.
Load/Store instructions (LSI) and other datapath instructions may be placed into the same box. In this case no dependency between the Load/Store instructions (LSI) and any other datapath instruction is allowed within the same box.
The OptimizerVarious implementation of a respective optimizer algorithm are possible. For example may the implementation depend on the environment in which the algorithm is used.
An exemplary optimizer algorithm is described which operates on non-optimized binaries already generated by a compiler. The algorithm might be used in a separated tool optimizing code or by an operating system optimizing code while loading or installing it.
A slightly modified embodiment might be implemented in hardware, e.g. in a micro-processor.
Other optimizer algorithms might operate on the Data-Flow-Graph (DFG) and Control-Flow-Graph (CFG) within a compiler and use Dependency Graphs and analysis for scheduling the instructions.
The exemplary algorithm operates in two passes:
The first pass is outlined in
-
- OP1-1. If the instruction is a jump instruction (0202), the type of jump instruction is checked.
- a. If it is a conditional and optimizable instruction (0203), it is checked whether the jump points backwards (0204) in the code to an earlier instruction.
- i. In this case a loop is detected and respectively marked (0205).
- ii. If not, a conditional code section has been detected. The jump instruction is removed from the code, but a respective entry with all information of the jump instruction, including the condition for its execution, is put (0206) onto a jump-stack (jmpstk) comprising all information of conditional and optimizable jump instructions in the order of their occurrence. Additionally flag dependency data is added to the jmpstk indicating from which flag the conditional jump depends on and which instruction generates the respective flag.
- b. If it is a non-conditional or non-optimizable instruction (0207) (in this simple exemplary embodiment of the optimizer) all jumps still present on the jmpstk (see below) are written back into the code (0208) in stack order, i.e. from top to bottom.
- a. If it is a conditional and optimizable instruction (0203), it is checked whether the jump points backwards (0204) in the code to an earlier instruction.
- OP1-2. If the instruction is not a jump instruction (0212):
- a. It is checked if the address is a target address of a jump instruction by evaluating the jmpstk.
- i. If so, the respective entry/entries is/are removed from the jmpstk.
- b. The jmpstk is evaluated and conditional control information added (0215). As conditional jump instructions might be removed from the code in 0206, it is necessary to add the respective conditional execution control code to the instruction.
- c. Flag dependency information is collected from the jmpstk and added to the instruction (0216).
- d. Registers are renamed (0217).
- a. It is checked if the address is a target address of a jump instruction by evaluating the jmpstk.
- OP1-1. If the instruction is a jump instruction (0202), the type of jump instruction is checked.
The second pass is shown in
-
- OP2-1. If the current instruction is not a jump instruction (0302), the latest source of the instruction is detected based on the register reference information generated by the first pass. The information of the latest (latest in terms of last recently produced) source is retrieved.
- a. If the current instruction is a store instruction (0304) it is placed into the next subsequent box after the box in which the latest (latest in terms of last recently produced) source instruction is placed (0305); else
- i. If the current instruction's latest (latest in terms of last recently produced) source is a nonload instruction (0306), the current instruction can be placed into the same box as the source instruction (0307). (However, if the current instruction is a multi-cycle instruction (such as e.g. multiplication, division, load, etc.) it is also preferably placed into the next subsequent box after the box in which the latest (latest in terms of last recently produced) source instruction is placed (see dotted line 0307a).)
- ii. If the current instruction's latest (latest in terms of last recently produced) source is a load instruction (0308), the current instruction is placed into the next subsequent box after the box in which the latest (latest in terms of last recently produced) source instruction is placed (0309).
- a. If the current instruction is a store instruction (0304) it is placed into the next subsequent box after the box in which the latest (latest in terms of last recently produced) source instruction is placed (0305); else
- OP2-2. If the current instruction is a jump instruction (0312):
- a. If the current instruction is a conditional jump (0313) it is placed into the same box as the instruction the condition depends on (0314), e.g. a compare or flag generating arithmetic instruction. Conditional jumps can be handled that way and moved within the box structure as the code is controlled by the conditional control information added by 0215.
- b. If the current instruction is a non-conditional jump (0315) it is placed in the last available box (0316). With that all boxes (prior to and the last) are closed (0317). Subsequent instructions cannot be moved into one of those boxes as this would destroy the correct execution of the code. Therefore subsequent instructions are moved into a new set of boxes beginning after the last box.
- OP2-1. If the current instruction is not a jump instruction (0302), the latest source of the instruction is detected based on the register reference information generated by the first pass. The information of the latest (latest in terms of last recently produced) source is retrieved.
An exemplary respective algorithm operating on assembly code (e.g. CODE1) is shown in Program Listing 2 of the computer program listing appendix. It produces assembly code again (e.g. CODE2) and is written in Perl for easy understanding.
Exemplary TransformationEither high level code (e.g. C, C++, Fortran, . . . ) is compiled to assembly code, or plain assembly code is directly taken as an input. Any compiler for a given existing processor architecture can be used.
The assembly code is reordered and grouped into boxes by a hardware generator software tool as described. Each box comprises the respective instructions. Each box has one or more entry points. If at runtime a box is enabled, the correct entry point is chosen depending on program pointer PP provided when enabling the box. PP is decoded and selects the according instruction as entry point.
For each instruction the respective hardware macro is instantiated and placed into the respective box's hardware module by the hardware generator software tool.
drive the bus for all subsequent instructions and the bus connection to previous instructions is respectively disconnected (see e.g. 0533, 0534), or inserted into the bus via a multiplexer selecting result data from the respective macro instead the previous bus information.
For example instruction 0531 receives operand data from register buses r1 and r15 and puts its result back onto register bus r1; instruction 0532 receives operand data from register buses r0 and r1 and puts its result back onto register bus r15.
The register buses in the box modules may contain pipeline stages (0510) for reducing the overall delay. The insertion of pipeline registers depends on the application's target clock frequency and latency requirements. Pipeline registers are preferably automatically inserted by the hardware generator tool (e.g. 0510).
The register file buses are fed by the register file (0541) located in the main module (0504). In alternative embodiments, the register file might not be located in the main module, but formed by pipeline registers in the box modules, e.g. 0511. Respectively pipeline registers might be inserted directly at the output of each box module (as exemplary shown by 0511).
The last instruction of a box typically defines the program pointer PP (0512) to continue with. This is particularly true if the last instruction is a conditional or unconditional jump (or call) instruction. This program pointer is transmitted to the main module for selecting the next subsequent box for execution. If a pipeline register exists at the exit of the box (e.g. 0511), the program pointer is registered too.
All result data from the boxes is fed to the main module, in a one embodiment one bus for each for each register and box. For writing back the result data of each of the boxes into the register file, a multiplexer bank (0542) in the main module (0504) selects the source bus for each register of the register file (0541) according to the currently active box, e.g. multiplexer 0543 for register r0, 0544 for register r1, and 0545 for r15.
Multiplexer 0551 selects the target program point (i.e. the address of the next instruction to be executed) (0512) according to the currently active box. The target program pointer is decoded by a decoder (0552) and stored in a register (0553). The stored information enables the box comprising the respective instruction according to the target program pointer of the current execution in the next execution cycle (e.g. clock cycle) and selects the result data and target program pointer of the next execution via the multiplexer bank 0542 and register 0551 respectively.
In addition to the connectivity of the boxes shown in
Register buses not used within a box, might be eliminated within a box for reducing the hardware overhead. The respective registers of the register file (0541) are disabled when writing back result data from the respective box module.
In-Line Conditional ExecutionConditional execution is supported within boxes, if no branching is required. The ARM instruction set, for example, supports respective operations by the condition field of at least some instructions defining, see [11]. The respective status information is transported via the box internal buses, similar as the register data. It shall be explicitly mentioned, that the register file 0541 also comprises a status register, with a multiplexer selecting the source box—similar as the data registers. A conditionally executed macro (0500) evaluates the status information from the status bus according to its condition setting (e.g. the condition field in the ARM instruction set, see [11]). If the condition is met, the results data of the macro is written onto the respective bus according to the target register. The result data is conditionally written to the bus via a multiplexer in the bus (e.g. in place of 0534 or 0533 respectively). Alternatively the respective bus data is by passed via a multiplexer inside the macro, in which case the target bus becomes an additional input to the macro just for providing the data to be bypassed in case the condition is not met.
Effect of Managing the Program Pointer PPThe active management of the PP by transferring between the boxes and the main module and in some embodiments even within boxes allows for flexible processing of jumps. Depending on the implementation even for jump tables and runtime calculated address values.
In some embodiments boxes (e.g. 0501, 0502, 0503) and/or macros (e.g. 0500) might even compare their code address range and/or code address to the currently transmitted program pointer PP and become active when the current program pointer meets the boxes and/or macros set point.
Applicability on Processor HardwareThe inventive optimizer is applicable on processors by integrating it into the processor hardware. The optimizer reduces the complexity and power dissipation of processors, particularly Out-of-Order processors, as for example large and power consuming Reorder Buffers are replaced by the inventive technology.
Reference is made to
In a preferred embodiment the optimizer of
In a very basic implementation the loader starts loading instructions with the first address of code not loaded yet and/or not being present in any of the code buffers and/or caches downstream the loader, i.e. between the loader and the execution units of the processor, until the first return instruction leaving the routine. However, it cannot be guaranteed that the first return instruction is the only one leaving the routine. Due to conditional execution other return instructions may exist, so that the first found return instruction might not be a sufficient criterion.
In an ideal implementation it must be ensured that the complete software routine and/or function is loaded. Various implementations are possible, for example:
a) The loader uses a jump directory (0404) in which each target address of detected jump instructions are stored and performs the following steps:
-
- LD1. Whenever a target address is reached and read by the loader it is removed from the jump directory.
- LD2. If a return instruction is detected, but the jump directory is not empty obviously more code must exist belonging to the function. In that case the loader continues loading instructions.
- LD3. If a return instruction is detected and the jump directory is empty no more code exists belonging to the function. The loader stops loading code.
- LD4. If a non-conditional jump backwards in the code is detected and the jump directory is empty no more code exists belonging to the function. The loader stops loading code.
b) The optimizer (0405) performs the steps of a) and instructs the loader respectively (0406). It might use a respectively amended jmpstk (0407) to perform the functions of the jump directory.
The loader forwards the loaded instructions to a first optimizer pass (0405) (e.g. OP1 as described above). The optimizer pass uses a stack memory (0407) to implement the jmpstk.
In a register file (0408) for each register the latest source instruction is stored.
The results of first optimizer pass are written into a buffer memory (0409). Various embodiments are possible, for example: In one embodiment, the buffer memory is a processor internal buffer. The loader gets the instructions from a Level-1 Cache.
In another embodiment, the loader and first optimizer pass are located in front of the Level-1 Instruction Cache. The loader gets the instructions from a Level-2 Cache. The Level-1 Instruction Cache is used as buffer memory 0409.
The second optimizer pass (0410) gets the instructions from the buffer memory (0409) and writes the optimized instructions into a second buffer memory (0412). The second optimizer pass might use an instruction box reference memory (0411) for looking up the box in which a specific instruction has been placed. The instruction's address is translated into a memory reference, under which the identification can be found of the box into which the respective instruction has been placed.
The Execution Units (EX) receive the instructions (or microcode at this stage) from the second buffer.
The second buffer can be located at various positions, depending on the implementation. For example:
In one embodiment, the second buffer is the Level-1 Instruction Cache, in this case, the first buffer might be a Level-2 Instruction Cache.
In another embodiment, the second buffer is a Trace Cache replacing and/or extending the functionality of the Trace Cache. During the second optimizer pass instructions are translated into microcode and possibly fused or split. For details of the Trace Cache, reference is made to the Pentium-4 Processor, particularly to [10], [11] and [12]. [10], [11] and [12] are entirely incorporated by reference into this patent for full disclosure, claims of this patent may comprise features of [10], [11] and [12]. For further details on micro-10 code fusion and splitting, particularly in conjunction with the inventive processor technology, reference is made to [4] and [5].
In yet another embodiment, the second buffer might be in the position of a ReOrder Buffer (ROB), replacing and/or extending its functionality. Respectively the first buffer might be a Trace Cache (if implemented) or a Level-1 Instruction Cache.
In yet another embodiment, the second buffer might be replacing and/or extending the Reservation Stations of a processor.
It shall be noted that
Ideally the structure according to
In one advanced embodiment, function calls within the prefetched function or routine might be detected. For example call instructions could be placed in a dedicated call stack memory e.g. by the loader or optimizer or respectively marked in the jmp directory (0404) and/or jmpstk (0407). Preferably after the complete function has been (pre-)fetched, the called functions are prefetched, so that they are available prior to calling them. It might be beneficial to priorized the prefetching, e.g. by prefetching functions early in the code and/or those with are non-conditionally called first. Then conditionally called functions are fetched, while the conditions might be evaluated for the likelihood of their execution. Several evaluation methods are possible, for example:
-
- a) based on statistics (e.g. stored together with the binary);
- b) jump instructions including a likelihood indicator of their execution (e.g. 2 bits: 00—unlikely, 01—rather unlikely, 10—rather likely, 11—likely);
- c) based on how the condition is expressed in the binary: The condition false path might be defined as likely, while the condition true path might be defined as unlikely (or vice versa);
- d) a dummy instruction located before the (function call) instruction indicating the likelihood of the execution of the call, the instruction might be only evaluated by the loader/optimizer and removed afterwards.
Obviously the evaluations might also be very useful for other conditional jumps (other than calls) for providing optimization information to the processor, e.g. for loop optimization and/or speculative execution.
Known from [5], which is expressively incorporated by reference, are optimizations for managing constant data. In addition to the optimizations discussed in [5], processors having buffers for storing instructions which are frequently accessed may replace instructions loading constant data once the constant data has been loaded from memory with the constant data itself. If the processor comprises a Trace Cache as previously described, in one preferred embodiment, the constant data is written into the trace cache replacing the original instruction. In other embodiments, instructions in the Reorder Buffer and/or Reservation Station might be replaced with the constant data. By replacing the load instruction with the actual data, the instruction will not be executed anymore and therefore the respective time and energy is saved.
Is shall also be further noted, particularly referring to [5], that some processor instruction sets support loading data from a Program Counter (PC) relative address, e.g. ARM's LDR <Rd>, [PC, #<immed8>*4]. As typically data within the code segment (relative to the program pointer) is generated at compile and/or link time, such data is constant. Therefore pc relative load instructions might be recognized and/or used as dedicated load-constant instructions (e.g. ldc).
Prior ArtTrace Caches are known in the prior art, which store a transformed representation of original binary code. Reference is made to the Pentium-4 Processor, particularly to [10], [11] and [12]. [10], [11] and [12] are entirely incorporated by reference into this patent for full disclosure, claims of this patent may comprise features of [10], [11] and [12]. However Trace Caches are significantly different from this invention. Some major differences are:
-
- 1. Trace Caches store decoded instructions in microcode format. The code stored in Trace Caches is not optimized, but solely decoded (transformed) from a dense binary opcode representation into a large vector controlling the processor hardware.
- The inventive caches store modified code, in which e.g. the sequence of instructions is rearranged, and/or source and/or target registers are changed (even replaced by Execution Units, e.g. ALUs in the ALU-Block of a ZZYX processor), and/or instructions are combined and/or grouped to form code blocks (e.g. Catenas, reference is made to [1] and [3], both incorporated by reference into this patent for full disclosure, claims of this patent may comprise features from [1] and [3]) which are executed and/or scheduled simultaneously. The optimizer routine may also perform completely different or additional optimizations of the binary which results are stored in the inventilw cache.
- 2. Trace Caches store only code which has been already executed. Only code which have been previously addressed by the processor's program pointer, respectively fetched and decoded are present in a Trace Cache. This invention, however, operates (timely and locally) in front of the program pointer. While it is under control of the program pointer (e.g. jumps affect the next code range to be fetched, optimized and stored) the loading and optimization of a code is done ahead of addressing the code by the program pointer. The inventive caches comprise codes which have not been addressed by the processor's program pointer yet.
- 1. Trace Caches store decoded instructions in microcode format. The code stored in Trace Caches is not optimized, but solely decoded (transformed) from a dense binary opcode representation into a large vector controlling the processor hardware.
While Trace Caches store only code which has already been executed, the inventive caches store complete code blocks, e.g. subroutines, functions, loops, inner loops etc.
Exemplary EmbodimentReferring to
The code of the exemplary loop shown in
The listed code has the identical structure as in the Figures for easy referencing.
The detection of the code pattern might be implemented in 0405 and/or 0410. In particular microcode fusion techniques might apply for fusing the plurality of instructions of the respective code patterns into (preferably) one microcode.
The lsuld instruction loads bytes (lsuldb) or words (lsuldw) from memory. Complex address arithmetic is supported by the instruction, in which an immediate offset is added (+=offset) to a base pointer which might then be sequentially incremented by a specific value (̂ value) with each processing cycle.
The lsust instruction stores bytes (lsustb) or words (lsustw) to memory. The address generation operates as for the lsuld instruction.
A for instruction defines loops, setting the start-, end-values, and the step width; all in a single mnemonic. The endfor instruction respectively indicates the end of the loop code.
The code shown in
The listed code has the identical structure as in the Figure for easy referencing.
In a preferred embodiment, the instruction set is enhanced with dedicated instructions, e.g.:
-
- Isuld(w/b), Isust(w/b): memory instructions optimized for block transfers, including 2D/3D address generation, e.g., striding;
- for, endfor: loop instructions managing loop control; and
- Advanced (thumb) instructions in Loop Acceleration Mode increasing code density.
The following references are incorporated by reference into the patent for complete disclosure. It is expressively noted, that claims may comprise elements of any reference embodied into the specification:
[1] ZZYX07: PCT/EP 2009/007415 (WO2010/043401); Vorbach
[2] ZZYX08: PCT/EP 2010/003459 (WO2010/142432); Vorbach
[3] ZZYX09: PCT/EP 2010/007950; Vorbach
[4] ZZYX10: PCT/EP 2011/003428; Vorbach
[5] ZZYX11: DE 11 006 698.2; Vorbach
[6] http://www.videolan.org/developers/×264.html: VideoLAN, VLC media player and ×264 are trademarks registered (or in registration process) by the VideoLAN non-profit organization. Software are licensed under the GNU General License.
[7] PACT04: U.S. Pat. No. 7,028,107; Vorbach et al
[8] PACT10: U.S. Pat. No. 6,990,555; Vorbach et al
[9] PACT08: U.S. Pat. No. 7,036,036; Vorbach et al.
[10] The unabridged Pentium 4; IA32 Processor Genealogy; Tom Shanley; Mindshare Inc.; ISBNO-321-25656-X
[11] Trace Cache: a Low Latency Approach to High Bandwidth Instruction Fetching; Eric Rotenberg Computer Science Dept. Univ. of Wisconsin, Steve Bennett Intel Corporation, James E. Smith Dept. of Elec. and Comp. Engr. Univ. of Wisconsin; Copyright 1996 IEEE. Published in the Proceedings of the 29th Annual International Symposium on Microarchitecture, Dec. 2-4, 1996, Paris, France.
[12] U.S. Pat. No. 5,381,533; Peleg et al (DYNAMIC FLOW INSTRUCTION CACHE MEMORY ORGANIZED AROUND TRACE SEGMENTS INDEPENDENT OF VIRTUAL ADDRESS LINE)
[13] ARM Architecture Reference Manual; Copyright © 1996-1998, 2000, 2004, 2005 ARM Limited. All rights reserved. ARM DDI 01001
Claims
1. (canceled)
2-8. (canceled)
9. A method for translating high-level software code into a hardware representation, the method comprising:
- analyzing the high-level software code by analyzer software;
- splitting the high-level software code into blocks, including mapping a plurality of software instructions of the high-level software code to hardware routines, one or more blocks of the plurality of blocks comprising one main routine and at least one subordinate code block, the plurality of blocks being defined by jump and call instructions to code sections or subroutines of the high-level software code, each block of the plurality of blocks having a unique identifier, wherein software instructions in each block are mapped to hardware functions and are arranged in an execution order, at least some of the software instructions in each block configured to execute at least one of concurrently and asynchronously, wherein particular instructions of the software instructions that depend on other instructions of the high-level software code receive input data from results produced by the other instructions, wherein the plurality of blocks are configured such that, upon completion of execution of the software instructions in a respective block, the respective block returns a pointer matching the unique identifier of a next block to execute; and
- generating the hardware representation based on the plurality of blocks.
Type: Application
Filed: Jul 7, 2017
Publication Date: Dec 21, 2017
Applicant: Hyperion Core, Inc. (Los Gatos, CA)
Inventor: Martin VORBACH (Lingenfeld)
Application Number: 15/643,554