# US 2022/0283790 A1 · Method for executing computation, computing device, computing system, and storage medium

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

- Number: US 2022/0283790 A1
- Document ID: US20220283790A1
- Status: Published application
- Kind: A1
- Application number: 17/686,413
- Filed: 2022-03-04
- Published: 2022-09-08
- Earliest claimed: 2021-03-05
- Assignees: Shanghai Biren Technology Co., Ltd
- Applicants: Shanghai Biren Technology Co., Ltd
- Inventors: HaiChuan WANG; Huayuan TIAN; Long CHEN
- Web page: https://patentgrep.com/patent/US20220283790A1

## CPC

- G06F 8/41: Compilation
- G06F 8/45: {Exploiting coarse grain parallelism in compilation, i.e. parallelism between groups of instructions}
- G06F 9/30054: {Unconditional branch instructions}
- G06F 9/30087: {Synchronisation or serialisation instructions}
- G06F 9/3009: {Thread control instructions}
- G06F 9/30145: {Instruction analysis, e.g. decoding, instruction word fields}
- G06F 9/3836: {Instruction issuing, e.g. dynamic instruction scheduling or out of order instruction execution}
- G06F 9/3851: {from multiple instruction streams, e.g. multistreaming}
- G06F 9/3888: {controlled by a single instruction for multiple threads [SIMT] in parallel}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method for executing computation, a computing device, a computing system, and a storage medium are provided. The method includes: confirming, via a compiler, whether there is a call instruction related to a thread block modification request in a kernel function to be compiled; in response to confirming that there is the call instruction related to the thread block modification request in the kernel function to be compiled, determining a corresponding program segment associated with the call instruction; configuring a required thread block and thread local register for the corresponding program segment; and inserting a control instruction into the corresponding program segment to enable the thread block configured for the corresponding program segment to execute relevant computation of the corresponding program segment, and an unconfigured thread block not to execute the relevant computation. The disclosure can improve overall performance, make coding and maintenance easy and reduce error rate of code.

## Claims

### Claim 1

A method for executing computation, comprising:
confirming, via a compiler, whether there is a call instruction related to a thread block modification request in a kernel function to be compiled;
in response to confirming that there is the call instruction related to the thread block modification request in the kernel function to be compiled, determining a corresponding program segment associated with the call instruction;
configuring a required thread resource for the corresponding program segment; and
inserting a control instruction into the corresponding program segment to enable the thread resource configured for the corresponding program segment to execute relevant computation of the corresponding program segment, wherein an unconfigured thread resource does not execute the relevant computation.

### Claim 2 (depends on 1)

The method according to claim 1, wherein determining the corresponding program segment associated with the call instruction comprises:
dividing the kernel function to be compiled into a plurality of corresponding program segments based on a number of call instructions.

### Claim 3 (depends on 2)

The method according to claim 2, wherein configuring the required thread resource for the corresponding program segment comprises:
configuring a required thread block and thread local register for each of the corresponding program segments.

### Claim 4 (depends on 1)

The method according to claim 1, further comprising:
in response to confirming that a compiled kernel function is started, configuring a numbering of a thread block and assigning a thread local register based on a maximum number of threads required by the compiled kernel function, wherein the compiled kernel function comprises a plurality of corresponding program segments respectively inserted with the control instruction.

### Claim 5 (depends on 1)

The method according to claim 1, further comprising:
in response to the control instruction of the corresponding program segment being called, performing followings:
synchronizing all threads of a thread block configured for the corresponding program segment;
allocating a thread local register for each of the threads of the configured thread block; and
reconfiguring a numbering of each of the threads, so that the reconfigured numbering is written to the assigned thread local register.

### Claim 6 (depends on 1)

The method according to claim 1, further comprising:
starting, via a driver, a compiled kernel function;
confirming, via the compiler or the driver, a maximum number of threads required by the compiled kernel function; and
requesting, via the driver, the maximum number of threads from a graphics processor.

### Claim 7 (depends on 1)

The method according to claim 1, wherein enabling the thread resource configured for the corresponding program segment to execute the relevant computation of the corresponding program segment comprises:
controlling an executive stream through a control flow code to encapsulate the corresponding program segment, so that when a thread identifier of a current thread is determined to belong to a thread block identifier set configured for the corresponding program segment, the current thread is used to execute the relevant computation of the corresponding program segment; and when the thread identifier of the current thread is determined to not belong to the thread block identifier set configured for the corresponding program segment, the current thread is skipped.

### Claim 8 (depends on 1)

The method according to claim 1, wherein confirming whether there is the call instruction related to the thread block modification request in the kernel function to be compiled comprises:
scanning, via the compiler, the kernel function to be compiled to confirm whether the kernel function to be compiled comprises the call instruction related to the thread block modification request, wherein the call instruction related to the thread block modification request indicates a thread configuration required by the corresponding program segment.

### Claim 9 (depends on 1)

A computing device comprising:
at least one processor; and
a memory, communicatively connected to the at least one processor, wherein
the memory stores an instruction executable by the at least one processor, the instruction is executed by the at least one processor, so that the at least one processor executes the method according to claim 1.

### Claim 10 (depends on 1)

A non-transitory computer-readable storage medium, storing a computer program, wherein when the computer program is executed by a machine, the method according to claim 1 is executed.

### Claim 11

A computing system, comprising:
a compiler module, configured to identify a call instruction related to a thread block modification request comprised in a received kernel function to be compiled, and to convert the kernel function to be compiled of the call instruction to generate a compiled kernel function, wherein a corresponding program segment comprised in the compiled kernel function is configured with a control instruction;
a driver module, configured to determine a maximum number of threads required by the compiled kernel function to start based on the compiled kernel function; and
an execution unit computation core module, configured to modify a function call of a thread block in response to the control instruction of the corresponding program segment in the compiled kernel function being executed.

### Claim 12 (depends on 11)

The computing system according to claim 11, wherein the driver module is configured in a central processor, the execution unit computation core module is configured in a graphics processor, and the central processor and the graphics processor are comprised in the computing system.

### Claim 13 (depends on 11)

The computing system according to claim 11, wherein the compiler module is further configured to: when the kernel function to be compiled is confirmed to comprise the call instruction related to the thread block modification request, configure a required thread resource for the corresponding program segment associated with the call instruction; and insert the control instruction into the corresponding program segment to enable the thread resource configured for the corresponding program segment to execute relevant computation of the corresponding program segment, wherein an unconfigured thread resource does not execute the relevant computation.

### Claim 14 (depends on 11)

The computing system according to claim 11, wherein modifying the function call of the thread block comprises: resuming or pausing a thread, and assigning a thread local register for each configured thread.
