Patent Description:
This invention relates to a method of initiating code and a computer-readable medium.

Complex computer systems frequently make use of a heterogeneous approach involving multiple processor cores from different vendors each with unique instruction set architectures. Generating code for a heterogeneous multiprocessor may be a difficult task for a programmer. A programmer will essentially have to deal with procedure calls that are separately compatible with two separate binary incompatible cores and deal with procedure calls that may transition from one thread to another at boundaries where the other processor may be more efficient. This kind of complexity makes it difficult for a software author to focus on functional correctness using conventional high-level computer language, such as high-level C++ threading primitives and libraries.

<CIT> discloses a method to compile code for a heterogeneous multi-core processor that includes a first core and a second core, the method comprising: receiving, by a multi-core compilation system, a set of source code that includes a plurality of code segments, wherein the multi-core compilation system is configured to compile the set of source code and generate an executable program that is executable by the heterogeneous multi-core processor; generating, by the multi-core compilation system, a first instruction set based on a specific code segment selected from the plurality of code segments, wherein the first instruction set is executable by the first core of the heterogeneous multi-core processor; and in response to a determination that a performance indicator associated with the first core executing the first instruction set is above a particular threshold, generating, by the multi-core compilation system, a second instruction set based on the specific code segment, wherein the second instruction set is executable by the second core of the heterogeneous multi-core processor, and the first instruction set and the second instruction set are implemented in the executable program.

<CIT> discloses A method of operating a multiprocessing system, the method comprising: determining a first process of a first processor to be handed off to a second processor for execution; creating a first memory protection domain in a common memory, the first memory protection domain corresponding to the first process; and extending the memory protection domain between the first processor and the second processor such that the second processor is enabled to execute the first process within the first memory protection domain.

The invention is as set out in the appended set of claims. The invention provides a method of initiating code including (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 objects and removing first and second functions from the second CPU ISA objects;, (iv) proxy inserting first and second remote procedure calls (RPC's) in the first and second CPU ISA objects respectively, and pointing respectively to the third function in the second CPU ISA objects and the second function in the first CPU ISA objects, and (v) section renaming the second CPU ISA objects to create a common application library of the first and second CPU ISA objects.

The invention also provides a computer-readable medium having stored thereon a set of instructions that are executable by a processor to carry out 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 objects and removing first and second functions from the second CPU ISA objects, (iv) proxy inserting first and second remote procedure calls (RPC's) in the first and second CPU ISA objects respectively, and pointing respectively to the third function in the second CPU ISA objects and the second function in the first CPU ISA objects, and (v) section renaming the second CPU ISA objects to create a common application library of the first and second CPU ISA objects.

A method of executing an application is also disclosed, including (<NUM>) executing a first function of an application that has first, second and third functions, the first function being a main function, on a first processor with at least one of first central processing unit (CPU) instruction set architecture (ISA) objects that are compiled to the first processor, the main function causing sequential execution of (<NUM>) a first remote procedure call (RPC) on the first processor with at least one of the first CPU ISA objects; (<NUM>) the third function on a second processor with at least one of second CPU ISA objects that are compiled to the second processor; (<NUM>) the second RPC on the second processor with at least one of the second CPU ISA objects, and (<NUM>) the second function on the first processor with at least one of the first CPU ISA objects.

A heterogeneous multiprocessor is also disclosed, including first and second heterogeneous processors, a memory and an application on the memory, including first, second and third functions and first and second remote procedure calls (RPC), wherein (<NUM>) the first function is a main function that is executed on the first processor with at least one of first central processing unit (CPU) instruction set architecture (ISA) objects that are compiled to the first processor. The main function causing sequential execution of (<NUM>) the first RPC on the first processor with at least one of the first CPU ISA objects, (<NUM>) the third function on a second processor with at least one of second CPU ISA objects that are compiled to the second processor, (<NUM>) the second RPC on the second processor with at least one of the second CPU ISA objects and (<NUM>) the second function on the first processor with at least one of the first CPU ISA objects.

The invention is further described by way of example with reference to the accompanying drawings, wherein:.

<FIG> illustrates a conceptual heterogeneous multiprocessor application <NUM>, including code <NUM> to run on a primary instruction set architecture (ISA), code <NUM> to run on a secondary ISA and common data <NUM>.

The code <NUM> includes first and second functions <NUM> and <NUM>. The first function <NUM> is a main function, which is the first function that is executed to run the heterogeneous multiprocessor application <NUM>. The code <NUM> includes a third function <NUM>. The common data <NUM> includes a data structure <NUM>. The first function <NUM> at <NUM> points to the second function <NUM> and, at <NUM>, points at the third function <NUM>. The third function <NUM>, at <NUM>, points to the second function <NUM>. The first and third functions <NUM> and <NUM> rely on the data structure <NUM> at <NUM> and <NUM> respectively.

It will be understood that an application may have more than three functions. For purposes of discussion, the construction of a heterogeneous multiprocessor is described having only three functions, which is sufficient to describe the invention, and which does not include unnecessary clutter that may obscure the invention. Additional functions may however be included before, in between and/or after the three functions that are used in this description, and may call any other function in the system belonging to any ISA via the same methods.

<FIG> illustrates a first operation to create a heterogeneous multiprocessor application <NUM>, according to an embodiment of the invention. An application is written in source code and stored in memory. The application is then compiled to first and second heterogeneous processors to create first and second central processing unit (CPU) ISA objects 42A and 42B, respectively. The processors have different ISA's and therefore rely on objects that are different for their functioning. The CPU ISA objects 42A and 42B are thus different from one another in accordance with the different requirements of the ISA's of the different processors. The CPU ISA objects 42A and 42B are compiled from the same source code and thus have the same functional blocks. For example, the CPU ISA objects 42A include a first function 18A and the CPU ISA objects 42B also include a first function 18B. The functional components of the CPU ISA objects 42A and 42B are the same as the functional components of the conceptual heterogeneous multiprocessor application <NUM> described with reference to <FIG>. The components of the first CPU ISA objects 42A and links between them have the same reference numerals as the components of the conceptual heterogeneous multiprocessor application <NUM> in <FIG>, except that the first CPU ISA objects 42A and their links have been appended with "A" (e.g., "<NUM>" to "20A"). Similarly, the components of the second CPU ISA objects 42B are the same as the components of the heterogeneous multiprocessor application <NUM> in <FIG> except that they have been appended with "B" (e.g., "<NUM>" to "20B").

<FIG> illustrates a pruning operation that is carried out to construct the heterogeneous multiprocessor application <NUM>. In the first CPU ISA objects 42A, the code 14A and the third function 22A are removed. The removal of the third function 22A also removes the link 34A to the data structure 24A. In the second CPU ISA objects 42B, the code 12B to run on the secondary ISA is removed, together with the first and second functions 18B and 20B. The common data 16B and the data structure 24B are also removed from the second CPU ISA objects 42B. Removal of the components from the second CPU ISA objects 42B also severs the links at 26B, 28B and 32B. The code 12A to run on the primary ISA has a ". text" naming structure, referred to as a "linker input section", ". text section" or "object file section". The code 14B to run on the secondary ISA has a ". isab" naming structure.

<FIG> illustrates a proxy insertion operation that is carried out in the construction of the heterogeneous multiprocessor application <NUM>. First and second proxy sections <NUM> and <NUM> are inserted into the first and second CPU ISA objects 42A and 42B, respectively. The first proxy section <NUM> includes a first remote procedure call (RPC) <NUM>. The first function 18A points to the first RPC <NUM>. The first RPC <NUM>, at <NUM>, points to the third function 22B of the second CPU ISA objects 42B. In practice, the third function 22A in <FIG> can be replaced with the first RPC <NUM> in <FIG>.

The second proxy section <NUM> includes a second remote procedure call (RPC) <NUM>. The third function 22B points to the second RPC <NUM> at 30B. The second RPC <NUM>, at <NUM>, points to the second function 20A in <FIG>. The second proxy section <NUM> has not, at this time, been renamed and the link <NUM> is thus not active. The link <NUM> is however included in <FIG> to illustrate the eventual functioning of the heterogeneous multiprocessor application <NUM> after the second proxy section <NUM> has been renamed. Similarly, the link 34B is shown to point to the data structure 24A to illustrate the eventual functioning of the heterogeneous multiprocessor application <NUM> after the code 14B to run on the secondary ISA has been renamed.

<FIG> illustrates a section rename operation that is carried out to construct the heterogeneous multiprocessor application <NUM>. The code 14B to run on the secondary ISA and the second proxy section <NUM> are renamed from ". isab" to ". text" to be consistent with the naming of the first CPU ISA objects 42A. <FIG> illustrates the final links in the application library after the section renaming in <FIG>. The section renaming creates a generic ". text" section <NUM> that contains the first, second and third functions 18A, 20A and 22B and the first and second RPC's <NUM> and <NUM>.

The source code may for example be written in C++ code, whereafter the processing threads as represented by the first, second and third functions 18A, 20A and 24A in <FIG> invisibly transition in what can be referred to as a "weave" event from one binary incompatible core to another at procedure called boundaries. The software author may first focus on functional correctness using conventional high-level C++ threading primitives and libraries, and may then, in a modular way, migrate individual blocks of code to the more efficient processor without having to rewrite the code or having to rely on different sets of libraries. A system may, for example, have a digital signal processor (DSP) and a general purpose central processing unit (CPU). From a software author's point of view, to run a function on the DSP, all that would need to be done would be to add an attribute tag to a function specifying that it be placed in a specific non-". text" program section as follows:
#define ML_ON_DSP _attribute_ ((section (". text_dsp"))). ML_ON_DSP int foo(void) {
return <NUM>;
}.

In the above example, after compiling the source file, the resultant object file would contain the function "foo" in the ". text_dsp" section. The build system recognizes and strips the ". text_dsp" section from the object file, then recompiles the source file for the DSP's ISA. Any references to the "foo" function would be replaced with a shim function to initiate a remote procedure call on the DSP. In a similar manner, the reverse would occur for the DSP object file: any functions in. text would be stripped and any references to them in functions in the. text_dsp section would be replaced with a shim function to initiate a remote procedure call back onto the CPU. As long as the two processors have identical compiled structural layouts, have identical views to the same virtual memory, and have coherent caches at the time of a weave event, an application should be able to seamlessly transition from one processor architecture to the other while maintaining a simple and coherent programmer view of the flow of execution.

<FIG> illustrates a first operation that is carried out during runtime execution. A heterogeneous multiprocessor <NUM> has a main memory <NUM> that stores the components of the heterogeneous multiprocessor application <NUM> of <FIG>. The first function 18A is the main function that is executed to run the application. The block <NUM> indicates that the first function 18A is executed on a first processor using the first CPU ISA objects. The block <NUM> indicates that the second processor that uses the second CPU ISA objects is idle. The first function 18A, at 32A, relies on the data structure 24A, e.g. for purposes of looking up data. The first function 18A, at 26A and 26B, executes the second function 20A and the first RPC <NUM>.

<FIG> illustrates a second process that is executed on the heterogeneous multiprocessor <NUM> when the first function 18A initiates the first RPC <NUM>. The block <NUM> indicates that the first RPC <NUM> is executed on the first CPU using the first ISA objects. The block <NUM> indicates that the second CPU is still idle. The first RPC <NUM>, at <NUM>, executes the third function 22B.

<FIG> illustrates a third operation that is executed on the heterogeneous multiprocessor <NUM> when the first RPC <NUM> executes the third function 22B. The block <NUM> indicates that the first CPU that uses the first ISA objects is paused. The block <NUM> indicates that the third function 22B is executed with the second CPU using the second ISA objects. The third function 22B, at 34B, utilizes the data structure 24A, e.g. for purposes of executing a lookup. The third function 22B, at 30B, executes the second RPC <NUM>.

<FIG> illustrates a fourth operation that is executed on the heterogeneous multiprocessor <NUM> when the second RPC <NUM> is executed. Block <NUM> indicates that the first CPU is still paused. Block <NUM> indicates that the second RPC <NUM> is executed with the second CPU using the second ISA objects. The second RPC <NUM>, at <NUM>, executes the second function 20A.

<FIG> illustrates a fifth operation that is executed on the heterogeneous multiprocessor <NUM> when the second function 20A is executed. The block <NUM> indicates that the first function 20A is executed with the first CPU using the first ISA objects. The block <NUM> indicates that the second CPU is paused.

Figure <NUM> shows a diagrammatic representation of a machine in the exemplary form of a computer system <NUM> within which a set of instructions, for causing the machine to perform any one or more of the methodologies discussed herein, may be executed. In alternative embodiments, the machine operates as a standalone device or may be connected (e.g., networked) to other machines. Further, while only a single machine is illustrated, the term "machine" shall also be taken to include any collection of machines that individually or jointly execute a set (or multiple sets) of instructions to perform any one or more of the methodologies discussed herein.

The exemplary computer system <NUM> includes a processor <NUM> (e.g., a central processing unit (CPU), a graphics processing unit (GPU) or both), a main memory <NUM> (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 <NUM> (e.g., flash memory, static random access memory (SRAM), etc.), which communicate with each other via a bus <NUM>.

The computer system <NUM> may further include a disk drive unit <NUM>, and a network interface device <NUM>.

The disk drive unit <NUM> includes a machine-readable medium <NUM> on which is stored one or more sets of instructions <NUM> (e.g., software) embodying any one or more of the methodologies or functions described herein. The software may also reside, completely or at least partially, within the main memory <NUM> and/or within the processor <NUM> during execution thereof by the computer system <NUM>, the main memory <NUM> and the processor <NUM> also constituting machine-readable media.

The software may further be transmitted or received over a network <NUM> via the network interface device <NUM>.

While the machine-readable medium <NUM> is shown in an exemplary embodiment to be a single medium, 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 the one or more sets of instructions. The term "machine-readable medium" shall also be taken to include any medium that is capable of storing, encoding, or carrying a set of instructions for execution by the machine and that cause the machine to perform any one or more of the methodologies of the present invention. The term "machine-readable medium" shall accordingly be taken to include, but not be limited to, solid-state memories, optical and magnetic media, and carrier wave signals.

Claim 1:
A method of initiating code comprising:
(i) storing an application (<NUM>, <NUM>) in a memory, the application having first, second and third functions (<NUM>, <NUM>, <NUM>), the first function (<NUM>) being a main function that calls the second and third functions (<NUM>, <NUM>) to run the application;
(ii) compiling the application to first and second heterogeneous processors (<NUM>) to create first and second central processing unit, CPU, instruction set architecture, ISA, objects (42A, 42B) respectively, wherein each of the first and second CPU ISA objects have first and second naming structures;
(iii) pruning the first and second CPU ISA objects (42A, 42B) by removing the third function (<NUM>) from the first CPU ISA objects (42A) and removing first and second functions (<NUM>, <NUM>) from the second CPU ISA objects (42B), wherein, after pruning, the first and second CPU ISA objects have first and second naming structures respectively;
characterised by
(iv) proxy inserting first and second remote procedure calls, RPCs, (<NUM>, <NUM>) in the first and second CPU ISA objects (42A, 42B) respectively, and pointing respectively to the third function (<NUM>) in the second CPU ISA objects (42B) and the second function (<NUM>) in the first CPU ISA objects (42A); and
(v) section renaming the second CPU ISA objects (42B), including renaming the second RPC (<NUM>), from the second naming structure to the first naming structure so that the first and second CPU ISA objects (42A, 42B), including the first and second RPCs (<NUM>, <NUM>) of the first and second CPU ISA objects (42A, 42B), both have the first naming structure, to create a common application library of the first and second CPU ISA objects (42A, 42B).