# US 2010/0169861 A1 · Energy/performance with optimal communication in dynamic parallelization of single-threaded programs

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

- Number: US 2010/0169861 A1
- Document ID: US20100169861A1
- Status: Published application
- Kind: A1
- Application number: 12/344,721
- Filed: 2008-12-29
- Published: 2010-07-01
- Earliest claimed: 2008-12-29
- Assignees: Intel Corporation
- Inventors: Cheng Wang; Youfeng Wu
- Web page: https://patentgrep.com/patent/US20100169861A1

## CPC

- G06F 8/443: {Optimisation}
- G06F 8/41: Compilation
- G06F 8/445: {Exploiting fine grain parallelism, i.e. parallelism at instruction level (run-time instruction scheduling G06F9/3836)}
- G06F 8/457: {Communication (intertask communication G06F9/54)}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method and apparatus for optimizing parallelized single threaded programs is herein described. Code regions, such as dependency chains, are replicated utilizing any known method, such as dynamic code replication. A flow network associated with a replicated code region is built and a minimum cut algorithm is applied to determine duplicated nodes, which may include a single instruction or a group of instructions, to be removed. The dependency of removed nodes is fulfilled with inserted communication to ensure proper data consistency of the original single-threaded program. As a result, both performance and power consumption is optimized for parallel code sections through removal of expensive workload nodes and replacement with communication between other replicated code regions to be executed in parallel.

## Claims

### Claim 1

An article of manufacture including program code which, when executed by a machine, causes the machine to perform the operations of:
determining a duplicated node to remove from a first parallelized code region; and
inserting a communication operation, when executed, to fulfill a dependence associated with the duplicated node removed from the first parallelized code region.

### Claim 2 (depends on 1)

The article of manufacture of claim 1, wherein inserting a communication operation, when executed, to fulfill a dependence associated with the duplicated node removed from the first parallelized code region comprises inserting a receive operation in the first parallelized code region.

### Claim 3 (depends on 2)

The article of manufacture of claim 2, wherein inserting a communication operation, when executed, to fulfill a dependence associated with the duplicated node removed from the first parallelized code region further comprises inserting a send operation in a second parallelized code region to produce a value to be consumed by the receive operation inserted in the first parallelized code region.

### Claim 4 (depends on 3)

The article of manufacture of claim 3, wherein the first parallelized code region and the second parallelized code region include dependence chains replicated based on dependency relation, and wherein the nodes of the first parallelized code region including the duplicated node comprise sub-dependence chains.

### Claim 5 (depends on 1)

The article of manufacture of claim 1, wherein determining a duplicated node to remove from a first parallelized code region is based on a flow network associated with the first parallelized code region.

### Claim 6 (depends on 5)

The article of manufacture of claim 5, wherein the flow network is associated with workloads for nodes within the first parallelized code region and communication costs between producer nodes and consumer nodes within the first parallelized code region if the producer nodes were removed from the first parallelized code region.

### Claim 7 (depends on 6)

The article of manufacture of claim 6, wherein determining a duplicated node to remove from a first parallelized code region is based on a flow network associated with the first parallelized code region comprises performing a minimum-cut of the flow network associated with the first parallelized code region based on the workloads for nodes and communication costs between producer nodes and consumer nodes to determine the duplicated node to remove.

### Claim 8 (depends on 6)

The article of manufacture of claim 6, wherein performing a minimum-cut of the flow network associated with the first parallelized code region based on the workloads for nodes and communication costs between producer nodes and consumer nodes to determine the duplicated operation to remove comprises
associating edges of the flow network with capacity values that are individually selected from a group consisting of a large default value for non-duplicated nodes of the first parallelized code region, a communication cost between producer nodes and consumer nodes of the first parallelized code region, and a workload for the nodes of the first parallelized code region, and
performing a cut through the edges of the flow network that forms a minimum summation of capacity values associated with the cut through the edges.

### Claim 9 (depends on 7)

The article of manufacture of claim 7, wherein a workload for a node within the first parallelized code region is based on an average execution count of the node and a number of times the node is to be executed, and wherein a communication cost between a producer node and consumer node within the first parallelized code region includes an average communication cost between a producer node executed within a second parallelized code region and the consumer node executed within the first parallelized code region and a number of times the communication between the producer node and the consumer node is to occur.

### Claim 10 (depends on 9)

The article of manufacture of claim 9, wherein the number of times the node is to be executed and the number of times the communication between the producer node and consumer node is to take place are individually based on program profiling.

### Claim 11 (depends on 9)

The article of manufacture of claim 9, wherein the first parallelized code region and the second parallelized code region include a replicated dependence chain, and wherein each of the nodes within the first replicated dependence chain include an instruction.

### Claim 12 (depends on 1)

The article of manufacture of claim 1, wherein the program code is to be executed during runtime of the machine to dynamically perform the operations of: determining a duplicated node to remove from a first parallelized code region; and inserting a communication operation, when executed, to fulfill a dependence associated with the duplicated node removed from the first parallelized code region.

### Claim 13

An article of manufacture including program code which, when executed by a machine, causes the machine to perform the operations of:
maintaining a flow network for a code region; and
performing a minimum flow cut of the flow network to determine at least a node of the flow network to remove from the code region.

### Claim 14 (depends on 13)

The article of manufacture of claim 13, wherein maintaining the flow network for the code region comprises identifying a plurality of nodes for the code region in the flow network.

### Claim 15 (depends on 14)

The article of manufacture of claim 14, wherein each of the plurality of nodes are selected from a group consisting of an instruction, a group of instructions, a sub-dependence chain of instructions.

### Claim 16 (depends on 14)

The article of manufacture of claim 14, wherein maintaining the flow network for the code region further comprises adding a source node and a sink node to the flow network.

### Claim 17 (depends on 16)

The article of manufacture of claim 16, wherein maintaining the flow network for the code region further comprises connecting the source node to non-duplicated nodes of the plurality of nodes with edges associated with maximum values.

### Claim 18 (depends on 17)

The article of manufacture of claim 17, wherein maintaining the flow network for the code region further comprises connecting the plurality of nodes to the sink node with edges associated with workload values.

### Claim 19 (depends on 18)

The article of manufacture of claim 18, wherein maintaining the flow network for the code region further comprises interconnecting intra-dependent nodes of the plurality of nodes with edges associated with communication values.

### Claim 20 (depends on 18)

The article of manufacture of claim 18, wherein performing a minimum flow cut of the flow network to determine at least a node of the flow network to remove from the code region comprise cutting through edges of the flow cut network to obtain a minimum summation of cut edges associated with workload values and communication values.

### Claim 21 (depends on 13)

The article of manufacture of claim 13, wherein the program code is to be executed by the machine to cause the machine to perform the operations of maintaining a flow network for a code region; and performing a minimum flow cut of the flow network to determine at least a node of the flow network to remove from the code region are to be performed at a time selected from a group consisting of dynamically during runtime of the machine, statically during compilation of application code, and a combination of statically during compilation and dynamically during runtime of the machine.

### Claim 22 (depends on 13)

The article of manufacture of claim 13, wherein the program code which, when executed by a machine, further causes the machine to perform the operations of: inserting a first communication operation in the code region and a second communication operation in a replicated code region, the first communication operation, when executed on a first processing element of the machine, is to receive output data, wherein the second communication operation, when executed on a second processing element of the machine, is to generate the output data.

### Claim 23

An article of manufacture including program code which, when executed by a machine, causes the machine to perform the operations of:
creating a plurality of nodes in a flow network corresponding to a plurality of instructions in a replicated dependence chain;
creating a source node and a sink node in the flow network;
creating workload edges associated with workload costs from the plurality of nodes to the sink node;
creating communication edges associated with communication costs from each producer node of the plurality of nodes to each consumer node of the plurality of nodes; and

### Claim 24 (depends on 23)

The article of manufacture of claim 23, wherein the program code which, when executed by a machine, further causes the machine to perform the operations of: creating maximum capacity edges associated with a maximum capacity from the source node to each non-duplicated node of the plurality of nodes.

### Claim 25 (depends on 23)

The article of manufacture of claim 23, wherein performing a minimum cut of the flow network to determine an instruction to remove from the replicated dependence chain comprises:
determining a minimum cut of the flow network to associate at least one node of the plurality of nodes with a set corresponding to the sink node, wherein the minimum cut includes a minimum available sum of the workload edges and communication edges sliced by the minimum cut; and
determining the instruction corresponding to the at least one node include the instruction to removed from the replicated dependence chain.

### Claim 26 (depends on 23)

The article of manufacture of claim 23, wherein the program code is to be executed during runtime of the machine.

### Claim 27 (depends on 23)

The article of manufacture of claim 23, wherein the program code includes a compiler code executed to perform static whole program analysis compilation of application code including the replicated dependence chain.

### Claim 28 (depends on 23)

The article of manufacture of claim 23, wherein the program code which, when executed by a machine, further causes the machine to perform the operations of: inserting a communication operation in the code region, when executed, to receive output data from the instruction executed in another replicated dependence chain.

### Claim 29

A method comprising:
determining a workload for each node of a code segment;
determining a communication cost for each intra-dependence edge between nodes of the code segment;
creating a flow network for the code segment based on the workload for each node of the code segment and the communication cost for each intra-dependence between nodes of the code segment; and
applying a minimum-cut algorithm to the flow network to determine removable nodes from the code segment.

### Claim 30 (depends on 29)

The method of claim 29, further comprising: inserting communication operations in the code segment to receive output data from the removable nodes in another code segment.

### Claim 31 (depends on 29)

The method of claim 29, wherein the workload for each node includes an average execution time of each node multiplied by a number of times each node is to be executed.

### Claim 32 (depends on 31)

The method of claim 31, wherein the average execution time of each node and the number of times each node is to be executed are each individually selected from a group of techniques consisting of program profiling analysis, estimation, and actual execution.

### Claim 33 (depends on 29)

The method of claim 29, wherein the communication cost for each intra-dependence between nodes of the code segment includes an average communication time multiplied by a number of times each intra-dependence is to be executed.

### Claim 34 (depends on 31)

The method of claim 31, wherein the average communication time is estimated based on a topology of a communication path and an amount of data to be communicated, and wherein the number of times each intra-dependence is to be executed is based on program profiling analysis.

### Claim 35 (depends on 31)

The method of claim 31, wherein creating a flow network for the code segment based on the workload for each node of the code segment and the communication cost for each intra-dependence edge between nodes of the code segment comprises:
adding a source node and a sink node to the flow network;
connecting the source node to non-duplicated nodes of the code segment with maximum value edges;
connecting each of the nodes of the code segment to the sink node with workload value edges;
inter-connecting each of the intra-dependent nodes of the code segment with communication cost value edges;

### Claim 36 (depends on 35)

The method of claim 35, wherein applying a minimum-cut algorithm to the flow network to determine removable nodes from the code segment comprises:
determining a minimum value of the sum of maximum value edges, workload value edges, and communication cost value edges to slice with a cut;
performing the cut to form a source set of nodes associated with the source and a sink set of nodes associated with the sink; and
determining the removable nodes form the code segment include the sink set of nodes.
