Thread weaving for cross-ISA procedure calls
By compiling and pruning CPU instruction set architecture objects, inserting remote procedure call proxies and renaming sections in heterogeneous multi-processor systems, binary incompatibility issues between heterogeneous processors are solved and seamless cross-processor architectures are achieved Simplification of transitions and functional correctness.
Patent Information
- Application Number
- CN201980053016.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-07-10
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2039-07-10
AI Technical Summary
In complex computer systems, when using heterogeneous multiprocessors, it is difficult for programmers to deal with binary incompatibilities between multiple processor cores from different vendors, resulting in the complexity of handling procedure call boundaries, which makes using traditional high-level computers It becomes difficult for languages to focus on functional correctness.
Create common central processing unit (CPU) instruction set architecture objects by compiling applications on different heterogeneous processors, removing unnecessary functions, inserting remote procedure call proxies, and renaming objects in sections. Application libraries enable seamless transition across processor architectures.
Simplifies the programmer's job, allowing them to focus on functional correctness and modularly migrate blocks of code to more efficient processors across processors without rewriting code or relying on a different set of libraries. Seamless transition of architecture.
Smart Images

Figure CN112585581B_ABST
Abstract
Description
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims priority to U.S. Provisional Patent Application No. 62 / 696,132, filed on July 10, 2018, the entire contents of which are incorporated herein by reference in their entirety. Technical Field
[0003] The invention relates to a method for starting codes, a method for executing application programs and a heterogeneous multiprocessor. Background Art
[0004] Complex computer systems often utilize a heterogeneous approach involving multiple processor cores from different vendors, each with a unique instruction set architecture. Generating code for heterogeneous multiprocessors can be a daunting task for programmers. The programmer will essentially have to deal with procedure calls that are compatible with two separate binary incompatible cores, and process procedure calls that may switch from one thread to another at a boundary where another processor may be more efficient. This complexity makes it difficult for software authors to focus on functional correctness using traditional high-level computer languages (such as, high-level C++ thread primitives and libraries). Summary of the invention
[0005] The present invention provides a method for starting code, the method comprising: (i) storing an application in a memory, the application having first, second and third functions, the first function being a main function that calls the second and third functions to run the application; (ii) compiling the application to first and second heterogeneous processors to create first and second central processing unit (CPU) instruction set architecture (ISA) objects, respectively; (iii) pruning the first and second CPU ISA objects by removing the third function from the first CPU ISA object and removing the first and second functions from the second CPU ISA object; (iv) proxy-inserting first and second remote procedure calls (RPCs) in the first and second CPU ISA objects, respectively, and pointing to the third function in the second CPU ISA object and the second function in the first CPU ISA object, respectively; and (v) section-renaming the second CPU ISA object to create a common application library of the first and second CPU ISA objects.
[0006] The present invention also provides a computer-readable medium having a set of instructions stored thereon, which can be executed by a processor to perform a method. The method may include: (i) storing an application in a memory, the application having first, second and third functions, the first function being a main function that calls the second and third functions to run the first application; (ii) compiling the application to first and second heterogeneous processors to create first and second central processing unit (CPU) instruction set architecture (ISA) objects, respectively; (iii) pruning the first and second CPU ISA objects by removing the third function from the first CPU ISA object and removing the first and second functions from the second CPU ISA object; (iv) proxy-inserting first and second remote procedure calls (RPCs) in the first and second CPU ISA objects, respectively, and pointing to the third function in the second CPU ISA object and the second function in the first CPU ISA object, respectively; and (v) performing section renaming on the second CPU ISA object to create a common application library of the first and second CPU ISA objects.
[0007] The present invention further provides a method for executing an application, the method comprising: (1) executing a first function of an application having first, second and third functions on a first processor using at least one first central processing unit (CPU) instruction set architecture (ISA) object compiled into the first processor, the first function being a main function, the main function resulting in the following sequential execution: (2) executing a first remote procedure call (RPC) on the first processor using at least one first CPU ISA object among the first CPU ISA objects; (3) executing the third function on the second processor using at least one second CPU ISA object among the second CPU ISA objects compiled into the second processor; (4) executing a second RPC on the second processor using at least one second CPU ISA object among the second CPU ISA objects; and (5) executing the second function on the first processor using at least one first CPU ISA object among the first CPU ISA objects.
[0008] The present invention also provides a heterogeneous multiprocessor, comprising: first and second heterogeneous processors, a memory, and an application on the memory, the application comprising first, second and third functions, and first and second remote procedure calls (RPCs), wherein (1) the first function is a main function executed on the first processor using at least one first CPU ISA object of a first central processing unit (CPU) instruction set architecture (ISA) object compiled into the first processor. The main function causes the following sequential execution: (2) executing a first RPC on the first processor using at least one first CPU ISA object of the first CPU ISA object; (3) executing a third function on the second processor using at least one second CPU ISA object of a second CPU ISA object compiled into the second processor; (4) executing a second RPC on the second processor using at least one second CPU ISA object of the second CPU ISA object; and (5) executing a second function on the first processor using at least one first CPU ISA object of the first CPU ISA object. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] The present invention will now be further described by way of example with reference to the accompanying drawings, in which:
[0010] Figure 1 is a block diagram illustrating a conceptual heterogeneous multiprocessor application;
[0011] Figures 2 to 6 is a block diagram illustrating development of a heterogeneous multiprocessor application;
[0012] Figures 7 to 11 shows runtime execution for heterogeneous multiprocessors; and
[0013] Fig.12 is a block diagram of a machine in the form of a computer that can host a build system for deploying heterogeneous multiprocessor applications. DETAILED DESCRIPTION
[0014] Figure 1 A conceptual heterogeneous multiprocessor application 10 is shown including code 12 running on a primary instruction set architecture (ISA), code 14 running on a secondary ISA, and common data 16 .
[0015] The code 14 includes a first function 18 and a second function 20. The first function 18 is a main function, which is the first function executed to run the heterogeneous multiprocessor application 10. The code 14 includes a third function 22. The common data 16 includes a data structure 24. The first function 18 points to the second function 20 at 26 and points to the third function 22 at 28. The third function 22 points to the second function 20 at 30. The first function 18 and the third function 22 depend on the data structure 24 at 32 and 34, respectively.
[0016] It will be appreciated that an application may have more than three functions. For purposes of discussion, a heterogeneous multiprocessor architecture with only three functions is described, which is sufficient to describe the present invention and does not include unnecessary confusion that may make the present invention difficult to understand. However, additional functions may be included before, between, and / or after the three functions used in this specification, and the additional functions may call any other function in the system belonging to any ISA via the same method.
[0017] Figure 2 A first operation for creating a heterogeneous multiprocessor application 40 according to an embodiment of the present invention is shown. The application is written in source code and stored in a memory. The application is then compiled to a first heterogeneous processor and a second heterogeneous processor to create a first central processing unit (CPU) ISA object 42A and a second CPU ISA object 42B, respectively. The processors have different ISAs and therefore rely on objects with different functions. Therefore, the CPU ISA objects 42A and 42B are different from each other according to the different requirements of the ISAs of different processors. The CPU ISA objects 42A and 42B are compiled from the same source code and therefore have the same functional blocks. For example, the CPU ISA object 42A includes the first function 18A, and the CPU ISA object 42B also includes the first function 18B. The functional components of the CPU ISA objects 42A and 42B are the same as those of the reference ISA objects 18A and 18B. Figure 1 The functional components of the conceptual heterogeneous multiprocessor application 10 described are the same. The components of the first CPU ISA object 42A and the links between the components have the same Figure 1 10, except that an "A" is appended to the first CPU ISA object 42A and its links (e.g., "20" becomes "20A"). Similarly, the components of the second CPU ISA object 42B are the same as those of the conceptual heterogeneous multiprocessor application 10 in FIG. Figure 1 The components of the heterogeneous multiprocessor application 10 in FIG. 1 are the same except that they are appended with a "B" (eg, "20" becomes "20B").
[0018] Figure 3The pruning operation performed to build a heterogeneous multiprocessor application 40 is shown. In the first CPU ISA object 42A, the code 14A and the third function 22A are deleted. The removal of the third function 22A also removes the link 34A to the data structure 24A. In the second CPU ISA object 42B, the code 12B running on the second ISA, as well as the first function 18B and the second function 20B are removed. The common data 16B and the data structure 24B are also removed from the second CPU ISA object 42B. Removing the component from the second CPU ISA object 42B also cuts off the links at 26B, 28B and 32B. The code 12A running on the primary ISA has a ".text" naming structure, which is called a "linker input section", ".text section" or "target file section". The code 14B running on the auxiliary ISA has a ".text.isab" naming structure.
[0019] Figure 4 1 shows proxy insertion operations performed in the construction of a heterogeneous multiprocessor application 40. A first proxy section 46 and a second proxy section 48 are inserted into a first CPU ISA object 42A and a second CPU ISA object 42B, respectively. The first proxy section 46 includes a first remote procedure call (RPC) 50. The first function 18A points to the first RPC 50. The first RPC 50 points to a third function 22B of the second CPU ISA object 42B at 52. In practice, the first proxy section 46 and the second proxy section 48 are inserted into a first CPU ISA object 42A and a second CPU ISA object 42B, respectively. The first proxy section 46 includes a first remote procedure call (RPC) 50. The first function 18A points to the first RPC 50. The first RPC 50 points to a third function 22B of the second CPU ISA object 42B at 52. Figure 2 The third function 22A in is replaced by Figure 4 The first RPC 50 in.
[0020] The second proxy section 48 includes a second remote procedure call (RPC) 54. The third function 22B points to the second RPC 54 at 30B. Figure 4 , the second RPC 54 points to the second function 20A at 56. The second proxy node 48 has not yet been renamed at this time, and therefore the link 56 is inactive. However, the link 56 is included in Figure 4 4B is shown to point to data structure 24A to show the final functionality of heterogeneous multiprocessor application 40 after code 14B to be run on the auxiliary ISA is renamed.
[0021] Figure 5 Shown is a section renaming operation performed to construct a heterogeneous multiprocessor application 40. The code 14B running on the auxiliary ISA and second agent section 48 is renamed from ".text.isab" to ".text" to be consistent with the naming of the first CPU ISA object 42A. Figure 6 Shown in Figure 5The final linking in the application library after the section renaming in. The section renaming creates a common ".text" section 60, which contains the first function 18A, the second function 20A, the third function 22B, the first RPC 50 and the second RPC 54.
[0022] For example, the source code can be written in C++, and then, by Figure 2 The processing threads represented by the first function 18A, the second function 20A, and the third function 24A in FIG. 1 are invisibly converted from one binary incompatible core to another binary incompatible core at a process called a boundary in an event called a "weave". Software authors can first focus on functional correctness using traditional high-level C++ thread primitives and libraries, and can then migrate individual code blocks to more efficient processors in a modular manner without having to rewrite the code or rely on different sets of libraries. A system may have, for example, a digital signal processor (DSP) and a general-purpose central processing unit (CPU). From the software author's perspective, to run a function on a DSP, all that needs to be done is to add an attribute tag to the function to specify that it be placed in a specific non-".text" program section, as follows:
[0023] #define ML_ON_DSP__attribute__((section(“.text_dsp”))) ...
[0025] ML_ON_DSP int foo(void){
[0026] return 42;
[0027] }
[0028] In the above example, after compiling the source files, the resulting object file will contain the function "foo" in the ".text_dsp" section. The build system identifies and strips the ".text_dsp" section from the object file, and then recompiles the source file for the DSP's ISA. Any references to the "foo" function will be replaced with a shim function to initiate a remote procedure call on the DSP. In a similar manner, the opposite will happen to the DSP object file: any functions in .text will be stripped, and any references to that function in the .text_dsp section will be replaced with a shim function to initiate a remote procedure call back to the CPU. As long as both processors have the same compiled structure layout, have the same view of the same virtual memory, and have coherent caches when a weaving event occurs, the application should be able to transition seamlessly from one processor architecture to another while maintaining a simple and consistent view of the execution flow for the programmer.
[0029] Figure 7 The first operation performed during runtime execution is shown. The heterogeneous multiprocessor 70 has a main memory 72 that stores Figure 6 1 is a component of a heterogeneous multiprocessor application 40. The first function 18A is the main function executed to run the application. Box 74 indicates that the first function 18A is executed on the first processor using the first CPU ISA object. Box 76 indicates that the second processor using the second CPU ISA object is idle. The first function 18A depends on the data structure 24A at 32A, for example, for the purpose of looking up data. The first function 18A executes the second function 20A and the first RPC 50 at 26A and 26B.
[0030] Figure 8 The second process is shown executing on the heterogeneous multiprocessor 70 when the first function 18A initiates the first RPC 50. Box 78 indicates that the first RPC 50 is executed on the first CPU using the first ISA object. Box 78 indicates that the second CPU is still idle. The first RPC 50 executes the third function 22B at 52.
[0031] Fig. 9 A third operation is shown performed on the heterogeneous multiprocessor 70 when the first RPC 50 executes the third function 22B. Box 80 indicates that the first CPU using the first ISA object is paused. Box 82 indicates that the third function 22B is executed with the second CPU using the second ISA object. The third function 22B utilizes the data structure 24A at 34B, for example, for the purpose of performing a lookup. The third function 22B executes the second RPC 54 at 30B.
[0032] Fig.10 A fourth operation is shown performed on the heterogeneous multiprocessor 70 when the second RPC 54 is executed. Block 80 indicates that the first CPU is still paused. Block 84 indicates that the second RPC 54 is executed with the second CPU using the second ISA object. The second RPC 54 executes the second function 20A at 56.
[0033] Fig.11 A fifth operation is shown being performed on the heterogeneous multiprocessor 70 while the second function 20A is being executed. Block 86 indicates executing the first function 18A with the first CPU using the first ISA object. Block 88 indicates the second CPU is halted.
[0034] Fig.12A schematic diagram of a machine in the exemplary form of a computer system 900 is shown within which a set of instructions may be executed for causing the machine to perform any one or more of the methodologies discussed herein. In alternative embodiments, the machine operates as a standalone device or may be connected (e.g., networked) to other machines. Further, while a single machine is shown, the term "machine" shall also be construed to include any collection of machines that individually or collectively execute a set (or multiple sets) of instructions to perform any one or more of the methodologies discussed herein.
[0035] The exemplary computer system 900 includes a processor 902 (e.g., a central processing unit (CPU), a graphics processing unit (GPU), or both), a main memory 904 (e.g., read-only memory (ROM), flash memory, dynamic random access memory (DRAM) such as synchronous DRAM (SDRAM) or Rambus DRAM (RDRAM)), etc.), and a static memory 906 (e.g., flash memory, static random access memory (SRAM), etc.), which communicate with each other via a bus 908.
[0036] The computer system 900 may further include a disk drive unit 916 and a network interface device 920 .
[0037] The disk drive unit 916 includes a machine-readable medium 922 on which is stored one or more sets of instructions 924 (e.g., software) embodying any one or more of the methods or functions described herein. The software may also reside, in whole or in part, within the main memory 904 and / or within the processor 902 during execution by the computer system 900, the main memory 904 and the processor 902 also constituting machine-readable media.
[0038] The software may further be sent or received over a network 928 via the network interface device 920 .
[0039] Although the machine-readable medium 922 is shown as a single medium in the exemplary embodiment, the term "machine-readable medium" should be taken to include a single medium or multiple media (e.g., a centralized or distributed database, and / or associated caches and servers) that store one or more sets of instructions. The term "machine-readable medium" should also be taken to include any medium that can store, encode, or carry a set of instructions for machine execution and cause the machine to perform any one or more of the methods of the present invention. Thus, the term "machine-readable medium" should be taken to include, but is not limited to, solid-state memories, optical and magnetic media, and carrier signals.
[0040] Although certain exemplary embodiments have been described and shown in the drawings, it will be understood that these embodiments are merely illustrative and not restrictive of the invention and that the invention is not limited to the specific construction and arrangements shown and described since modifications may be made by those skilled in the art.
Claims
1. A method for starting a code, comprising: (i) storing an application in a memory, the application having a first function, a second function and a third function, the first function being a main function that calls the second function and the third function to run the application; (ii) compiling the application to the first heterogeneous processor and the second heterogeneous processor to create a first central processing unit CPU instruction set architecture ISA object and a second CPU ISA object, respectively; (iii) pruning the first CPU ISA object and the second CPU ISA object by removing the third function from the first CPU ISA object and removing the first function and the second function from the second CPU ISA object; (iv) inserting the first remote procedure call RPC and the second remote procedure call RPC into the first CPU ISA object and the second CPU ISA object respectively, and pointing to the third function in the second CPU ISA object and the second function in the first CPU ISA object respectively; as well as (v) performing section renaming on the second CPU ISA object to create a common application library of the first CPU ISA object and the second CPU ISA object.
2. The method according to claim 1, wherein: The first function points to the second function.
3. The method according to claim 1, wherein: The first function points to the first RPC.
4. The method according to claim 1, further comprising: The third function in the first CPU ISA object and the second function in the second CPU ISA object are replaced with the first RPC and the second RPC, respectively.
5. The method according to claim 1, wherein: The application has data structures used by functions of the first CPUISA object and the second CPUISA object.
6. The method according to claim 5, wherein: During the compiling (ii), the data structure is compiled to the second processor.
7. The method according to claim 6, wherein: During the pruning (iii), the data structure is removed from the second CPUISA object.
8. The method according to claim 5, wherein: The first function uses the data structure.
9. The method according to claim 5, wherein: The third function uses the data structure.
10. The method according to claim 9, wherein: The third function in the second CPUISA object points to the data structure in the first CPUISA object.
11. The method according to claim 4, further comprising: (1) executing the main function on the first processor using at least one first CPUISA object among the first CPUISA objects, the main function causing the following sequential execution: (2) executing the first RPC on the first processor using at least one first CPUISA object among the first CPUISA objects; (3) executing the third function on the second processor using at least one second CPUISA object of the second CPUISA objects; (4) executing the second RPC on the second processor using at least one second CPUISA object of the second CPUISA object; as well as (5) executing the second function on the first processor using at least one of the first CPUISA objects.
12. A computer readable medium having a set of instructions stored thereon, the instructions being executable by a processor to perform a method, the method comprising: (i) storing an application in a memory, the application having a first function, a second function and a third function, the first function being a main function that calls the second function and the third function to run the first application; (ii) compiling the application to the first heterogeneous processor and the second heterogeneous processor to create a first central processing unit CPU instruction set architecture ISA object and a second CPU ISA object, respectively; (iii) pruning the first CPU ISA object and the second CPU ISA object by removing the third function from the first CPU ISA object and removing the first function and the second function from the second CPU ISA object; (iv) inserting the first remote procedure call RPC and the second remote procedure call RPC into the first CPU ISA object and the second CPU ISA object respectively, and pointing to the third function in the second CPU ISA object and the second function in the first CPU ISA object respectively; as well as (v) performing section renaming on the second CPU ISA object to create a common application library of the first CPU ISA object and the second CPU ISA object.
Citation Information
Patent Citations
Two way communication support for heterogenous processors of a computer platform
CN102741828A
System and method for execution of application code compiled according to two instruction set architectures
CN107077337A
