# US 2015/0149987 A1 · Method and apparatus for compiler processing for a function marked with multiple execution spaces

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2015/0149987 A1
- Document ID: US20150149987A1
- Status: Published application
- Kind: A1
- Application number: 14/089,542
- Filed: 2013-11-25
- Published: 2015-05-28
- Earliest claimed: 2013-11-25
- Assignees: NVIDIA Corporation
- Inventors: Jaydeep MARATHE
- Web page: https://patentgrep.com/patent/US20150149987A1

## CPC

- G06F 8/443: {Optimisation}
- G06F 8/314: {Parallel programming languages (G06F8/313 takes precedence)}
- G06F 8/4452: {Software pipelining}
- G06F 8/447: {Target code generation}
- G06F 8/45: {Exploiting coarse grain parallelism in compilation, i.e. parallelism between groups of instructions}
- G06F 9/449: {Object-oriented method invocation or resolution}
- G06F 8/433: {Dependency analysis; Data or control flow analysis}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method for processing a function with a plurality of execution spaces is disclosed. The method comprises creating an internal compiler representation for the function. Creating the internal compiler representation comprises copying substantially all lexical tokens corresponding to a body of the function. Further, the creating comprises inserting the lexical tokens into a plurality of conditional if-statements, wherein a conditional if-statement is generated for each corresponding execution space of said plurality of execution spaces, and wherein each conditional if-statement determines which execution space the function is executing in. During compilation, the method finally comprises performing overload resolution at a call site of an overloaded function by checking for compatibility with a first execution space specified by one of the plurality of conditional if-statements, wherein the overloaded function is called within the body of the function.

## Claims

### Claim 1

A method for processing a function with a plurality of execution spaces comprising:
creating an internal compiler representation for said function, wherein said creating comprises:
copying substantially all lexical tokens corresponding to a body of said function; and
inserting said lexical tokens into a plurality of conditional if-statements, wherein a conditional if-statement is generated for each corresponding execution space of said plurality of execution spaces, and wherein each conditional if-statement determines which execution space said function is executing in; and
during compilation, performing overload resolution at a call site of an overloaded function by checking for compatibility with a first execution space specified by one of said plurality of conditional if-statements, wherein said overloaded function is called within said body of said function.

### Claim 2 (depends on 1)

The method of claim 1, further comprising:
deleting code associated with each conditional if-statement not corresponding to said first execution space during said compilation.

### Claim 3 (depends on 1)

The method of claim 1, wherein said creating further comprises:
renaming label tokens appearing in said lexical tokens, wherein each label token receives a unique name corresponding to each execution space.

### Claim 4 (depends on 1)

The method of claim 1, wherein an underlying computing substrate corresponding to an execution space is selected from the group consisting of: a CPU, a GPU, an FPGA, an x86 processor and an x64 processor.

### Claim 5 (depends on 1)

The method of claim 1, wherein said overloaded function comprises different return types for each corresponding execution space.

### Claim 6 (depends on 1)

The method of claim 1, further comprising:
during said compilation, performing overload resolution at a call site of said overloaded function by checking for compatibility with a second execution space specified by one of said plurality of conditional if-statements.

### Claim 7 (depends on 1)

The method of claim 1, wherein each of said plurality of conditional if-statements and associated execution space corresponds to a discrete parse tree.

### Claim 8

A non-transitory computer-readable storage medium having stored thereon, computer executable instructions that, if executed by a computer system cause the computer system to perform a compilation method for processing a function with multiple execution spaces comprising:
creating an internal compiler representation for said function, wherein said creating comprises:
cloning substantially all lexical tokens corresponding to a body of said function; and
inserting said lexical tokens into a plurality of conditional if-statements, wherein a conditional if-statement is generated for each corresponding execution space of said plurality of execution spaces, and wherein each conditional if-statement determines which execution space said function is executing in; and
during compilation, performing overload resolution at a call site of an overloaded function by checking for compatibility with a first execution space specified by one of said plurality of conditional if-statements, wherein said overloaded function is called within said body of said function.

### Claim 9 (depends on 9)

The computer-readable medium as described in claim 9, wherein said method further comprises:
deleting code associated with each conditional if-statement not corresponding to said first execution space during said compilation.

### Claim 10 (depends on 9)

The computer-readable medium as described in claim 9, wherein said method further comprises:
renaming label tokens appearing in said lexical tokens, wherein each label token receives a unique name corresponding to each execution space.

### Claim 11 (depends on 9)

The computer-readable medium as described in claim 9, wherein an underlying computing substrate corresponding to an execution space is selected from the group consisting of: a CPU, a GPU, an FPGA, an x86 processor and an x64 processor.

### Claim 12 (depends on 9)

The computer-readable medium as described in claim 9, wherein said overloaded function comprises different return types for each corresponding execution space.

### Claim 13 (depends on 9)

The computer-readable medium as described in claim 9, wherein said method further comprises:
during said compilation, performing overload resolution at a call site of said overloaded function by checking for compatibility with a second execution space specified by one of said plurality of conditional if-statements.

### Claim 14 (depends on 9)

The computer-readable medium as described in claim 9, wherein said plurality of conditional if-statements are IF-EXEC statements, and wherein each of said plurality of conditional if-statements and associated execution space corresponds to a discrete parse tree.

### Claim 15

A system for processing a function with multiple execution spaces, said system comprising:
a memory storing information related to a heterogeneous programming environment, wherein said programming environment comprises a compiler to compile said function with multiple execution spaces;
a processor coupled to said memory, the processor operable to implement a method of compiling comprising:
creating an internal compiler representation for said function, wherein said creating comprises:
cloning substantially all lexical tokens corresponding to a body of said function; and
inserting said lexical tokens into a plurality of conditional if-statements, wherein a conditional if-statement is generated for each corresponding execution space, and wherein each conditional if-statement determines which execution space said function is executing in; and
during compilation, performing overload resolution at a call site of an overloaded function by checking for compatibility with a first execution space specified by one of said plurality of conditional if-statements, wherein said overloaded function is called within said body of said function.

### Claim 16 (depends on 15)

The system of claim 15, wherein said method further comprises:
deleting code associated with each conditional if-statement not corresponding to said first execution space during code generation.

### Claim 17 (depends on 15)

The system of claim 15, wherein said method further comprises:
during said compilation, performing overload resolution at a call site of said overloaded function by checking for compatibility with a second execution space specified by one of said plurality of conditional if-statements.

### Claim 18 (depends on 15)

The system of claim 15, wherein an underlying computing substrate corresponding to an execution space is selected from the group consisting of: a CPU, a GPU, an FPGA, an x86 processor and an x64 processor.

### Claim 19 (depends on 15)

The system of claim 15, wherein said overloaded function comprises different return types for each corresponding execution space.

### Claim 20 (depends on 15)

The system of claim 15, wherein each of said plurality of conditional if-statements and associated execution space corresponds to a discrete parse tree.
