Artificial intelligence chip, register space dynamic management method, medium and program

By dynamically managing the register space in the artificial intelligence chip and allocating and releasing the register space required for the subroutine segment of the thread warp in real time, the problem of resource waste and low parallelism caused by fixed-size allocation is solved, and the parallelism and parallelism of the task are improved. Register bank usage efficiency.

CN118626146BActive Publication Date: 2024-10-29北京壁仞科技开发有限公司 +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411081222.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-08
Publication Date
2024-10-29
Estimated Expiration
2044-08-08

AI Technical Summary

Technical Problem

In the existing technology, artificial intelligence chips adopt a fixed-size strategy when allocating register space, which leads to a reduction in the usage of the register group and affects the parallel execution of multiple tasks, especially when multiple thread warps are executed in parallel, due to the limited number of available registers. This causes the execution of some thread warps to be suspended, resulting in low parallelism.

Method used

Using the method of dynamically managing register space, the execution circuit allocates and releases the register space in real time during the execution of the subprogram segment of the thread warp, instead of releasing it after the execution of the entire thread warp is completed. Specifically, instructions are dispatched and released through the register space ( mem_alloc and mem_dealloc) dynamically allocate and free register space.

Benefits of technology

It improves the usage efficiency of the register group, increases the parallelism of tasks, ensures flexible utilization of register space, and avoids resource waste and low parallelism problems caused by fixed size allocation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118626146B_ABST
    Figure CN118626146B_ABST
Patent Text Reader

Abstract

The present invention provides an artificial intelligence chip and a register space dynamic management method thereof, a machine-readable storage medium, and a computer program product. The artificial intelligence chip includes an instruction cache, a register circuit, and an execution circuit. The instruction cache is used to store instructions required for the execution of a thread bundle. The register circuit is used to provide a register space. The execution circuit is coupled to the instruction cache and the register circuit. The execution circuit obtains and executes the thread bundle from the instruction cache. The thread bundle includes a first subroutine segment, wherein the first subroutine segment needs to use a first register space. During the execution of the thread bundle, the execution circuit requires the register circuit to allocate the first register space from the register space of the register circuit to the first subroutine segment for use. After the execution of the first subroutine segment is completed and before the execution of the thread bundle is completed, the execution circuit requires the register circuit to release the first register space in real time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of chip technology, and in particular to an artificial intelligence (AI) chip and a register space dynamic management method thereof. Background Art

[0002] In artificial intelligence (AI) computing, there are usually scenarios where multiple computing tasks are executed in parallel. Before a warp is executed, the chip will allocate several registers (fixed register space of a predetermined size) to it. The life cycle of this fixed register space is from the start to the end of the warp execution. Before the warp starts executing, it is checked and judged based on the description information it carries. The size of the register space required by the warp is recorded as req_size, and the remaining available register space in the register file is recorded as free_size. When req_size < free_size, the chip can allocate register space for it and then start executing the warp calculation. After the last instruction of the warp is executed, the register space occupied by the warp is released.

[0003] The prior art allocates a fixed number of registers (fixed register space) to a thread warp for use. Generally speaking, the allocated fixed register space is sufficient for any thread warp. But in reality, a thread warp often does not use all of the allocated register space when executing, and a thread warp does not need so much register space all the time during the execution of a thread warp. Most of the time, a thread warp will only use a part of the allocated register space, or even no register space. Allocating a fixed number of registers to each thread warp reduces the utilization rate of the register group and even affects the parallel execution of multiple tasks. If multiple thread warps are executed in parallel, the execution of some thread warps will often be suspended due to the limited number of available registers, resulting in low parallelism. How to more efficiently utilize the register space of the register group and thus improve the parallelism of tasks is one of the many technical issues in this field. Summary of the invention

[0004] The present invention is directed to an artificial intelligence (AI) chip and a register space dynamic management method thereof, a machine-readable storage medium, and a computer program product, so as to make the allocation and release of register space more flexible, thereby making register files more efficiently utilized and improving the parallelism of tasks.

[0005] In an embodiment according to the present invention, the artificial intelligence chip includes an instruction cache, a register circuit and an execution circuit. The instruction cache is used to store instructions required for the warp to run. The register circuit is used to provide register space. The execution circuit is coupled to the instruction cache and the register circuit. The execution circuit obtains and executes the warp from the instruction cache. The warp includes a first subroutine segment, wherein the first subroutine segment needs to use a first register space. During the execution of the warp, the execution circuit requires the register circuit to allocate the first register space from the register space of the register circuit to the first subroutine segment for use. After the execution of the first subroutine segment is completed and before the execution of the warp is completed, the execution circuit requires the register circuit to release the first register space in real time.

[0006] In an embodiment according to the present invention, the register space dynamic management method includes: the execution circuit of the artificial intelligence chip obtains and executes the thread bundle from the instruction cache of the artificial intelligence chip, wherein the thread bundle includes a first subprogram segment, and the first subprogram segment needs to use the first register space; in the process of executing the thread bundle, the register circuit of the artificial intelligence chip allocates the first register space from the register space of the register circuit to the first subprogram segment for use; and after the first subprogram segment is executed and before the thread bundle is executed, the register circuit releases the first register space in real time.

[0007] In an embodiment of the present invention, the machine-readable storage medium is used to store non-transitory machine-readable instructions. When the non-transitory machine-readable instructions are executed by a processor, the register space dynamic management method of the artificial intelligence chip can be implemented.

[0008] In an embodiment of the present invention, the computer program product includes a computer program. When the computer program is executed by a processor, the register space dynamic management method of the artificial intelligence chip can be implemented.

[0009] Based on the above, the artificial intelligence chip can dynamically allocate the corresponding register space (first register space) for the first subprogram segment in the thread bundle, instead of allocating fixed register space regardless of the usage requirements of the thread bundle. Therefore, the artificial intelligence chip can be more flexible in allocating register space, so that the limited register space of the register group can be used more efficiently. After the execution of the first subprogram segment is completed and before the execution of the thread bundle is completed, the artificial intelligence chip can release the first register space occupied by the first subprogram segment in real time (not releasing the register space after the execution of the entire thread bundle is completed). Therefore, the artificial intelligence chip can be more flexible in releasing the register group space, so that the limited register space of the register group can be used more efficiently and the parallelism of the task can be improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] Figure 1 It is a circuit block diagram of an artificial intelligence (AI) chip according to an embodiment of the present invention.

[0011] Figure 2 FIG. 4 is a schematic diagram of pseudo codes of different warps according to an embodiment of the present invention.

[0012] Figure 3 FIG. 1 is a timing diagram of register space allocation for different thread warps by an AI chip according to an embodiment.

[0013] Figure 4 It is a flowchart of a register space dynamic management method of an AI chip according to an embodiment of the present invention.

[0014] Figure 5 FIG. 1 is a timing diagram of register space allocation for different thread warps by an AI chip according to an embodiment of the present invention.

[0015] Figure 6 FIG. 4 is a timing diagram of different register space allocation methods according to an embodiment of the present invention.

[0016] Figure 7 FIG. 1 is a circuit block diagram of a register circuit and an execution circuit according to an embodiment of the present invention.

[0017] Figure 8 It is a flowchart of a register space dynamic management method of an AI chip according to another embodiment of the present invention.

[0018] Fig. 9 FIG. 4 is a schematic diagram of virtual program codes of different warps according to another embodiment of the present invention.

[0019] Fig.10 It is a flowchart of a register space dynamic management method of an AI chip according to another embodiment of the present invention.

[0020] Description of reference numerals:

[0021] 100: AI Chip

[0022] 110: Instruction Cache

[0023] 120: Register circuit

[0024] 121: Thread Warp Management Circuit

[0025] 122: Register Group

[0026] 130: Execution circuit

[0027] 131: Command transmission circuit

[0028] 132: Execution Core

[0029] 211~214, 221~224, 231~234, 911~914, 921~924, 931~934: Subroutine segment

[0030] 311, 313, 511-516: Register space

[0031] 610: Upper part

[0032] 620: Lower part

[0033] Alloc_1, Dealloc_1: Requirements

[0034] mem_alloc: register space allocation instruction

[0035] mem_dealloc: register space release instruction

[0036] P31, P32, P33, P51, P52, P53, P54, P55, P56, P57: Period

[0037] S410~S430, S810~S870, S1010~S1080: Steps

[0038] T61: Long time

[0039] warp21, warp22, warp23, warp91, warp92, warp93: thread bundles DETAILED DESCRIPTION

[0040] Reference will now be made in detail to exemplary embodiments of the present invention, examples of which are illustrated in the accompanying drawings. Whenever possible, the same reference numerals are used in the drawings and the description to refer to the same or like parts.

[0041] The term "coupled (or connected)" used in the entire specification of this case (including the claims) may refer to any direct or indirect means of connection. For example, if the text describes a first device coupled (or connected) to a second device, it should be interpreted that the first device can be directly connected to the second device, or the first device can be indirectly connected to the second device through other devices or some means of connection. The terms "first", "second", etc. mentioned in the entire specification of this case (including the claims) are used to name the components (element) or to distinguish different embodiments or ranges, and are not used to limit the upper or lower limit of the number of components, nor to limit the order of components. In addition, wherever possible, components / components / steps with the same number in the drawings and embodiments represent the same or similar parts. Components / components / steps with the same number or the same terminology in different embodiments can refer to the relevant descriptions of each other.

[0042] Figure 1 It is a circuit block diagram of an artificial intelligence (AI) chip 100 according to an embodiment of the present invention. Figure 1 The AI ​​chip 100 shown includes an instruction cache 110, a register circuit 120, and an execution circuit 130. The instruction cache 110 is used to store and provide instructions required for warp execution. The register circuit 120 is used to provide register space. The execution circuit 130 is coupled to the instruction cache 110 and the register circuit 120. The execution circuit 130 obtains and executes the warp from the instruction cache 110. Figure 2 and Figure 3 An example scenario is described in which a fixed number of registers (fixed register space) is allocated to each warp.

[0043] Figure 2 FIG. 1 is a schematic diagram of pseudo code of different thread warps warp21, warp22 and warp23 according to an embodiment of the present invention. Figure 2In the example shown, thread warp21 has instructions inst1 to inst30, wherein it is assumed that subroutine segment 211 (i.e., instructions inst1, inst2, ..., inst10) does not need to use register space, subroutine segment 212 (i.e., instructions inst11, ..., inst19) needs to use register space, subroutine segment 213 (i.e., instructions inst20, ..., inst25) does not need to use register space, and subroutine segment 214 (i.e., instructions inst26, ..., inst30) needs to use register space. Subroutine segment 211 is executed before subroutine segment 212. During the execution of subroutine segment 211, no register space will be allocated to thread warp21.

[0044] Thread bundle warp22 has instructions inst1~inst40, where it is assumed that subroutine segment 221 (i.e., instructions inst1, inst2, ..., inst8) does not need to use register space, subroutine segment 222 (i.e., instructions inst9, ..., inst25) needs to use register space, subroutine segment 223 (i.e., instructions inst26, ..., inst29) does not need to use register space, and subroutine segment 224 (i.e., instructions inst30, ..., inst40) needs to use register space. Thread bundle warp23 has instructions inst1 to inst25, where it is assumed that subroutine segment 231 (i.e., instructions inst1, inst2, ..., inst6) does not need to use register space, subroutine segment 232 (i.e., instructions inst7, ..., inst10) needs to use register space, subroutine segment 233 (i.e., instructions inst11, ..., inst18) does not need to use register space, and subroutine segment 234 (i.e., instructions inst19, ..., inst25) needs to use register space.

[0045] Figure 3 FIG. 1 is a timing diagram of the AI ​​chip 100 allocating register spaces for different thread warps warp21 , warp22 , and warp23 according to an embodiment. Figure 3 The horizontal axis represents time. Figure 3 The upper part shows the execution period of different thread warps warp21, warp22 and warp23, and Figure 3 The lower part shows the allocation status of the register space of the register circuit 120 based on the allocation strategy of "fixed register space". Figure 2 and Figure 3Based on the “fixed register space” dispatching strategy, the AI ​​chip 100 will dispatch a fixed register space of a predetermined size to different thread bundles warp21, warp22, and warp23, regardless of whether the thread bundles warp21, warp22, and warp23 need so much register space.

[0046] For example, the AI ​​chip 100 can allocate a fixed register space 311 from the register space of the register circuit 120 to the thread warp21 for use during period P31, so the execution circuit 130 can execute the thread warp21. In addition, the AI ​​chip 100 can allocate a fixed register space 313 from the register space of the register circuit 120 to the thread warp22 for use during period P31, so the execution circuit 130 can execute the thread warp22. Because the register circuit 120 has no sufficient register space to allocate to the thread warp23, the thread warp23 cannot be executed during period P31 because the register space cannot be allocated. Because the thread warp21 that has been executed has released the register space 311, the AI ​​chip 100 can allocate a fixed register space 311 from the register space of the register circuit 120 to the thread warp23 for use during periods P32 and P33, so that the execution circuit 130 can execute the thread warp23 during periods P32 and P33. The warp 22 that has completed execution releases the register space 313 in the period P33 .

[0047] Based on the above, when multiple thread bundles warp21, warp22 and warp23 are executed in parallel, thread bundle warp23 cannot be executed because it cannot be allocated to register space. But in fact, when the program is executed, register space is not required throughout the entire execution process, and the number of registers required is not constant. Most of the time, only part of the register group will be used, or even not used. The above-mentioned "fixed register space" dispatch strategy allocates a fixed number of registers to different thread bundles warp21, warp22 and warp23 during the entire process of the thread bundle running the task, which leads to a reduction in the utilization rate of the register space of the register circuit 120, and even affects the parallel execution of multiple tasks. The following will explain the dispatch strategy of "dynamically allocating corresponding register space for subroutine segments in the thread bundle" (rather than allocating fixed register space regardless of the use requirements of the thread bundle), and the release strategy of "releasing register space in real time after the execution of the subroutine segment is completed and before the execution of the thread bundle is completed" (not releasing the register space after the execution of the entire thread bundle is completed).

[0048] Figure 4is a flowchart of a method for dynamically managing register space of an AI chip according to an embodiment of the present invention. In some embodiments, Figure 4 The register space dynamic management method shown can be implemented in firmware or software. Each step in the flowchart or a combination of steps in the flowchart can be implemented by various means, such as hardware, one or more computer-readable media storing a computer program, or a computer program product. For example, Figure 4 The related operations of the register space dynamic management method shown can be implemented as non-transitory machine-readable instructions (code or program), and the non-transitory machine-readable instructions can be stored in a "non-transitory machine-readable storage medium". When the non-transitory machine-readable instructions are executed by a computer, Figure 4 In some other embodiments, Figure 4 The register space dynamic management method shown can be implemented in hardware, for example, Figure 1 AI chip 100 shown. In some other embodiments, one or more steps in the flowchart may be embodied by a computer program of a computer program product. The computer program product may be stored by one or more memory devices in a computing device and executed by a processor in the computing device. The computer program product may be implemented on a computer or other programmable device to generate a machine so that the computer program product generates functions for implementing the steps of the flowchart. The computer program product may include one or more computer-readable memories (the memory may store computer program instructions), or the computer program instructions of one or more computer program products may also be loaded onto a computer or other programmable device.

[0049] Please refer to Figure 1 and Figure 4In step S410, the execution circuit 130 obtains and executes a thread warp from the instruction cache 110, wherein the thread warp includes a first subprogram segment, and the first subprogram segment needs to use a first register space. During the execution of the thread warp, based on the request Alloc_1 of the execution circuit 130, the register circuit 120 allocates the first register space from the register space of the register circuit 120 for use by the first subprogram segment (step S420). Therefore, the first subprogram segment executed in the execution circuit 130 can use the first register space of the register circuit 120. After the execution of the first subprogram segment is completed and before the execution of the thread warp is completed, based on the request Dealloc_1 of the execution circuit 130, the register circuit 120 releases the first register space in real time (step S430).

[0050] Figure 5 FIG. 1 is a timing diagram of the AI ​​chip 100 allocating register spaces for different thread warps warp21 , warp22 , and warp23 according to an embodiment of the present invention. Figure 5 The horizontal axis represents time. Figure 2 Pseudo codes of different warps warp21 , warp22 , and warp23 are shown as illustrative examples. Figure 5 The upper part shows the execution period of different thread warps warp21, warp22 and warp23, and Figure 5 The lower part shows the Figure 4 The “register space dynamic management method” shown in the figure shows the allocation status of the register space of the register circuit 120.

[0051] Please refer to Figure 2 and Figure 5, the sub-program segment 211 of the warp 21, the sub-program segment 221 of the warp 22, and the sub-program segment 231 of the warp 23 do not need register space, so the warps 21, 22, and 23 can be executed in parallel during period P51. When the execution circuit 130 is ready to execute the sub-program segment 212 of the warp 21 and the sub-program segment 222 of the warp 22, the register circuit 120 allocates register spaces 511 and 512 required for the sub-program segments 212 and 222 to run. For example, the register circuit 120 can allocate register space 511 from the register space of the register circuit 120 to the sub-program segment 212 of the warp 21 during period P52, and allocate register space 512 to the sub-program segment 222 of the warp 22, so that the execution circuit 130 can continue to execute the sub-program segments 212 and 222. At this time, the warps warp21 and warp22 have occupied all the register spaces of the register circuit 120 , and there are no extra registers that can be allocated to the subprogram segment 232 of the warp warp23 . Therefore, the warp warp23 can only suspend execution and wait during period P52 .

[0052] After a period of time, the subprogram segment 212 of the thread warp21 and the subprogram segment 222 of the thread warp22 are finished (then the subprogram segment 213 of the thread warp21 and the subprogram segment 223 of the thread warp22 do not need the register space), so before the thread warp21 and the thread warp22 are finished, the register circuit 120 can release the register space 511 and 512 occupied by the subprogram segment 212 and 222 in real time for use by the program segments of other thread warps. Therefore, during period P53, the register circuit 120 can allocate the register space 513 of the register circuit 120 to the subprogram segment 232 of the thread warp23 that has been waiting due to insufficient space. The execution circuit 130 can continue to execute the subprogram segment 213 of the thread warp21, the subprogram segment 223 of the warp22, and the subprogram segment 232 of the warp23 in parallel during period P53.

[0053] After a period of time, the sub-program segment 213 of the warp 21 and the sub-program segment 223 of the warp 22 are finished, and then the sub-program segment 214 of the warp 21 and the sub-program segment 224 of the warp 22 need register space. The register circuit 120 can allocate the register space 514 and 515 of the register circuit 120 to the sub-program segment 214 of the warp 21 and the sub-program segment 224 of the warp 22. Therefore, in the period P54, the execution circuit 130 can continue to execute the sub-program segment 214 of the warp 21, the sub-program segment 224 of the warp 22, and the sub-program segment 232 of the warp 23 in parallel.

[0054] After a period of time, the subprogram segment 232 of the thread warp 23 is completed (the subprogram segment 233 of the thread warp 23 does not need the register space next), so the register circuit 120 can release the register space 513 occupied by the subprogram segment 232 in real time before the thread warp 23 is executed, so as to be used by the program segments of other thread warps. The execution circuit 130 can continue to execute the subprogram segment 214 of the thread warp 21, the subprogram segment 224 of the warp 22, and the subprogram segment 233 of the warp 23 in parallel during period P55.

[0055] After a period of time, the subprogram segment 233 of the thread warp 23 is finished, and the next subprogram segment 234 of the thread warp 23 needs register space. The register circuit 120 can allocate the register space 516 of the register circuit 120 to the subprogram segment 234 of the thread warp 23. Therefore, in the period P56, the execution circuit 130 can continue to execute the subprogram segment 214 of the thread warp 21, the subprogram segment 224 of the warp 22, and the subprogram segment 234 of the warp 23 in parallel.

[0056] After a period of time, the subprogram segment 214 of the thread warp21 and the subprogram segment 234 of the thread warp23 are finished, so the register circuit 120 can release the register spaces 514 and 516 occupied by the subprogram segments 214 and 234 in real time for use by the program segments of other thread warps. The execution circuit 130 can continue to execute the subprogram segment 224 of the thread warp22 during period P57 until the subprogram segment 224 is finished.

[0057] Figure 6 FIG. 4 is a timing diagram of different register space allocation methods according to an embodiment of the present invention. Figure 6 The horizontal axis represents time. Figure 6 The upper portion 610 is again depicted Figure 3The execution time length of different thread bundles warp21, warp22 and warp23 in Figure 6 The lower portion 620 is again depicted Figure 5 The execution time length of different thread warps warp21, warp22 and warp23 in . Figure 6 It can be clearly seen that compared with Figure 3 The implementation example adopts the "fixed register space" allocation strategy. Figure 5 The embodiment adopts " Figure 4 The register space dynamic management method shown in the figure saves time T61.

[0058] Figure 7 FIG. 1 is a circuit block diagram of a register circuit 120 and an execution circuit 130 according to an embodiment of the present invention. Figure 7 The register circuit 120 and the execution circuit 130 shown can be used as Figure 1 The register circuit 120 and the execution circuit 130 are one of many implementation examples. Figure 7 In the illustrated embodiment, the execution circuit 130 includes an instruction issuing circuit 131 and a plurality of execution cores 132. The execution core 132 is coupled to the register circuit 120. The instruction issuing circuit 131 is coupled to the instruction cache 110 and the execution core 132. The instruction issuing circuit 131 issues the instruction of the thread warp obtained from the instruction cache 110 to at least one of the execution cores 132 for execution. Before the instruction issuing circuit 131 issues the first subprogram segment of the thread warp to the execution core 132, the instruction issuing circuit 131 requires the register circuit 120 to allocate the first register space required by the first subprogram to the first subprogram segment for use. After the register circuit 120 allocates the first register space to the first subprogram segment, the instruction issuing circuit 131 issues the first subprogram segment to at least one of the execution cores 132 for execution. After the execution of the first subprogram segment is completed and before the execution of the thread warp is completed, the instruction issuing circuit 131 requires the register circuit 120 to release the first register space in real time.

[0059] exist Figure 7In the illustrated embodiment, the register circuit 120 includes a warp management circuit 121 and a register group 122. The register group 122 is coupled to the execution circuit 130 to provide register space to the execution core 132. The warp management circuit 121 is coupled to the instruction issuing circuit 131 and the register group 122 of the execution circuit 130. Before the execution circuit 130 executes the first sub-program segment of the warp, based on the requirements of the execution circuit 130, the warp management circuit 121 allocates the first register space required by the first sub-program segment from the register space of the register group 122 to the first sub-program segment for use. After the execution of the first sub-program segment is completed and before the execution of the warp is completed, based on the requirements of the execution circuit 130, the warp management circuit 121 releases the first register space of the register group 122 in real time.

[0060] Figure 8 FIG. 1 is a flow chart of a method for dynamically managing register space of an AI chip according to another embodiment of the present invention. Figure 7 and Figure 8 In step S810, the instruction issuing circuit 131 obtains a subroutine segment of the thread warp from the instruction cache 110 as the current subroutine segment. When the current subroutine segment does not need to use the register space (the judgment result of step S820 is "No"), the instruction issuing circuit 131 issues the instruction of the current subroutine segment to the execution core 132 so as to execute the current subroutine segment (step S850). When the current subroutine segment needs to use the register space (the judgment result of step S820 is "Yes"), before the instruction issuing circuit 131 issues the current subroutine segment to the execution core 132, the instruction issuing circuit 131 requests the thread warp management circuit 121 to allocate the register space required by the current subroutine segment to the current subroutine segment for use (step S830).

[0061] When the warp management circuit 121 is unable to allocate the register space required by the current subroutine segment from the register space of the register group 122 to the current subroutine segment (the judgment result of step S840 is "no"), for example, because the register space is insufficient, the warp management circuit 121 will continue to try to allocate (return to step S830). After the warp management circuit 121 successfully allocates the register space required by the current subroutine segment from the register space of the register group 122 to the current subroutine segment (the judgment result of step S840 is "yes"), the instruction emission circuit 131 emits the instruction of the current subroutine segment to the execution core 132 so as to execute the current subroutine segment (step S850). After the execution core 132 completes the execution of the current subroutine segment, the warp management circuit 121 releases the register space occupied by the current subroutine segment in real time (step S860). When there are remaining subroutine segments of the thread warp that have not been executed (the result of determination in step S870 is “yes”), the instruction issuing circuit 131 continues to obtain the next subroutine segment of the thread warp from the instruction cache 110 as a new current subroutine segment (returning to step S810 ).

[0062] Based on the above, when multiple thread bundles warp21, warp22, and warp23 are executed in parallel, the dispatch strategy of "dynamically assigning corresponding register space to subprogram segments in thread bundles" can dynamically assign corresponding register space to subprogram segments in thread bundles, rather than assigning fixed register space regardless of the usage requirements of thread bundles. Therefore, the AI ​​chip 100 can be more flexible in allocating register space of register group 122, so that the limited register space of register group 122 can be more efficiently utilized. Based on the release strategy of "releasing register space in real time after the execution of the subprogram segment is completed and before the execution of the thread bundle is completed" (not releasing register space only after the execution of the entire thread bundle is completed), the AI ​​chip 100 can be more flexible in releasing the register space of register group 122, so that the limited register space of register group 122 can be more efficiently utilized, thereby improving the parallelism of tasks.

[0063] In order to improve the execution efficiency of the warp computing task, the following embodiment will define two new instructions and apply them to the instruction sequence of the warp. The two instructions are the register space allocation instruction mem_alloc and the register space release instruction mem_dealloc. For example, Fig. 9 FIG. 1 is a schematic diagram of pseudo code of different thread warps warp91, warp92 and warp93 according to another embodiment of the present invention. Fig. 9In the illustrated example, the warp 91 has sub-program segments 911 , 912 , 913 , and 914 , the warp 92 has sub-program segments 921 , 922 , 923 , and 924 , and the warp 93 has sub-program segments 931 , 932 , 933 , and 934 . Fig. 9 The subroutine segments 911 to 914, 921 to 924 and 931 to 934 shown can refer to Figure 2 The related descriptions of the subroutine segments 211-214, 221-224 and 231-234 are similar and will not be repeated here.

[0064] Different from Figure 2 The embodiment shown is that Fig. 9 The illustrated embodiment applies register space dispatch instruction mem_alloc and register space release instruction mem_dealloc to the instruction sequence of thread warp91, warp92 and warp93. For example, register space dispatch instructions mem_alloc1 and mem_alloc2 are added to the beginning of subprogram segments 912, 914, 922, 924, 932 and 934, respectively, and register space release instructions mem_dealloc1 and mem_dealloc2 are added to the end of subprogram segments 912, 914, 922, 924, 932 and 934, respectively. The execution circuit 130 sends the register space dispatch instruction mem_alloc to the register circuit 120. The register space dispatch instruction mem_alloc includes a dispatch offset parameter alloc_offset and a dispatch size parameter alloc_size. The dispatch offset parameter alloc_offset defines the starting number of the register group occupied by this warp. The dispatch size parameter alloc_size defines the number of register groups occupied by this warp. The register circuit 120 determines the allocated register space based on the dispatch offset parameter alloc_offset and the dispatch size parameter alloc_size. The register circuit 120 allocates the register space required by the current subroutine segment from the register space of the register circuit 120 to the current subroutine segment for use based on the register space dispatch instruction mem_alloc.

[0065] When the current subroutine segment is executed, the execution circuit 130 transmits the register space release instruction mem_dealloc to the register circuit 120. The register space release instruction mem_dealloc includes a release offset parameter dealloc_offset and a release size parameter dealloc_size. The register circuit 120 determines the released register space based on the release offset parameter dealloc_offset and the release size parameter dealloc_size. The register circuit 120 releases the register space occupied by the current subroutine segment in real time based on the register space release instruction mem_dealloc before the thread warp is executed. In this way, when the program is executed, registers can be allocated to it when the program is executed to the point where registers are needed, and the register space can be released in advance when the subroutine segment does not need it, thereby achieving dynamic allocation and release of register space, rather than fixedly occupying registers throughout the entire task execution process.

[0066] For example, after the execution core 132 completes the subprogram segment 911 of the thread warp 91, the instruction issuing circuit 131 issues the register space dispatch instruction mem_alloc1 of the subprogram segment 912 to the thread warp management circuit 121. Based on the dispatch offset parameter alloc_offset and the dispatch size parameter alloc_size of the register space dispatch instruction mem_alloc1, the thread warp management circuit 121 determines whether the register group 122 has sufficient register space. In the case that the register group 122 has sufficient register space, the register circuit 120 allocates the register space required by the current subprogram segment 912 from the register space of the register circuit 120 to the current subprogram segment 912 for use based on the register space dispatch instruction mem_alloc1. When the current subprogram segment 912 is executed, the instruction issuing circuit 131 issues the register space release instruction mem_dealloc1 to the thread warp management circuit 121. Based on the release offset parameter dealloc_offset and the release size parameter dealloc_size of the register space release instruction mem_dealloc1, the warp management circuit 121 determines the register space to be released (the register space occupied by the warp warp91). Before the warp warp91 is executed, the warp management circuit 121 releases the register space occupied by the current subprogram segment 912 in real time based on the register space release instruction mem_dealloc1, so as to facilitate the use of other warps. The other subprogram segments 914, 922, 924, 932 and 934 can refer to the relevant description of the subprogram segment 912 and be inferred by analogy, so they will not be repeated.

[0067] Fig.10FIG. 1 is a flow chart of a method for dynamically managing register space of an AI chip according to another embodiment of the present invention. Figure 7 , Fig. 9 and Fig.10 In step S1010, the instruction issuing circuit 131 obtains an instruction of the thread warp from the instruction cache 110 as the current instruction. When the current instruction is not the register space allocation instruction mem_alloc (the judgment result of step S1020 is "No"), and when the current instruction is not the register space release instruction mem_dealloc (the judgment result of step S1030 is "No"), the instruction issuing circuit 131 issues the current instruction to the execution core 132 to execute the current instruction (step S1040). When there are remaining instructions of the thread warp that have not been executed (the judgment result of step S1050 is "Yes"), the instruction issuing circuit 131 continues to obtain the next instruction of the thread warp from the instruction cache 110 as the new current instruction (return to step S1010). For example, the instruction issuing circuit 131 obtains an instruction of the subroutine segment 911 of the thread warp 91 from the instruction cache 110 as the current instruction. Because subroutine segment 911 does not have register space allocation instruction mem_alloc and register space release instruction mem_dealloc (the judgment result of step S1020 is "No", and the judgment result of step S1030 is "No"), the instruction issuance circuit 131 sends the instructions of subroutine segment 911 to the execution core 132 one by one (step S1040).

[0068] When the current instruction obtained in step S1010 is the register space dispatch instruction mem_alloc (the judgment result of step S1020 is "yes"), the instruction issuing circuit 131 issues the register space dispatch instruction mem_alloc to the warp management circuit 121. The warp management circuit 121 attempts to dispatch the register space of the register group 122 to the current warp based on the register space dispatch instruction mem_alloc (step S1060). Based on the dispatch offset parameter alloc_offset and the dispatch size parameter alloc_size of the register space dispatch instruction mem_alloc, the warp management circuit 121 can determine whether the register group 122 has enough register space. When the register group 122 does not have enough register space (the judgment result of step S1070 is "no"), the warp management circuit 121 waits for other warps to release the register space of the register group 122 (return to step S1060). When the register set 122 has enough register space (the result of determination in step S1070 is “yes”), the warp management circuit 121 allocates the register space of the register set 122 to the current warp based on the register space allocation instruction mem_alloc. When there are remaining instructions in the warp that have not been executed (the result of determination in step S1050 is “yes”), the instruction issuing circuit 131 continues to obtain the next instruction of the warp from the instruction cache 110 as the new current instruction (returning to step S1010).

[0069] For example, when the instruction issuing circuit 131 obtains the register space allocation instruction mem_alloc1 of the subprogram segment 912 of the thread warp 91 from the instruction cache 110 as a new current instruction (step S1010), the instruction issuing circuit 131 issues the register space allocation instruction mem_alloc1 to the thread warp management circuit 121. The thread warp management circuit 121 attempts to allocate the register space of the register group 122 to the current thread warp 91 based on the register space allocation instruction mem_alloc1 (step S1060). Based on the allocation offset parameter alloc_offset and the allocation size parameter alloc_size of the register space allocation instruction mem_alloc1, the thread warp management circuit 121 can determine whether the register group 122 has enough register space for the subprogram segment 912. When the register group 122 has enough register space, the warp management circuit 121 allocates the register space of the register group 122 to the current warp warp91 based on the register space allocation instruction mem_alloc1, and then the instruction issuance circuit 131 continues to obtain the next instruction inst11 of the subroutine segment 912 of the warp warp91 from the instruction cache 110 as the new current instruction (step S1010).

[0070] When the current instruction obtained in step S1010 is not the register space allocation instruction mem_alloc (the judgment result of step S1020 is "no"), but when the current instruction is the register space release instruction mem_dealloc (the judgment result of step S1020 is "yes"), the instruction issuing circuit 131 issues the register space release instruction mem_dealloc to the thread warp management circuit 121. The thread warp management circuit 121 determines the released register space based on the release offset parameter dealloc_offset and the release size parameter dealloc_size of the register space release instruction mem_dealloc. The thread warp management circuit 121 releases the register space occupied by the current subroutine segment in real time based on the register space release instruction mem_dealloc before the current thread warp is executed (step S1080). When there are remaining instructions in the current thread warp that have not been executed (the judgment result of step S1050 is "yes"), the instruction issuing circuit 131 continues to fetch the next instruction of the thread warp from the instruction cache 110 as the new current instruction (return to step S1010). When there are no remaining instructions of the current thread warp that have not been executed (the determination result of step S1050 is “none”), the execution of the current thread warp is completed.

[0071] For example, when the instruction issuing circuit 131 obtains the register space release instruction mem_dealloc1 of the subprogram segment 912 of the warp 91 from the instruction cache 110 as a new current instruction (step S1010), the instruction issuing circuit 131 issues the register space release instruction mem_dealloc1 to the warp management circuit 121. The warp management circuit 121 determines the released register space (the register space occupied by the warp 91) based on the release offset parameter dealloc_offset and the release size parameter dealloc_size of the register space release instruction mem_dealloc1. The warp management circuit 121 releases the register space occupied by the current subprogram segment 912 in real time based on the register space release instruction mem_dealloc1 before the execution of the current warp 91 is completed.

[0072] Based on the above, multiple warps warp91, warp92 and warp93 can be executed in parallel. Based on the register space allocation instruction mem_alloc emitted by the instruction emission circuit 131, the warp management circuit 121 can dynamically allocate corresponding register space for the subprogram segment in the warp, rather than uniformly allocating fixed register space regardless of the use requirements of the warp. Therefore, the warp management circuit 121 can be more flexible in allocating the register space of the register group 122, so that the limited register space of the register group 122 can be more efficiently utilized. After the subprogram segment is executed and before the warp is executed, based on the register space release instruction mem_dealloc emitted by the instruction emission circuit 131, the warp management circuit 121 can release the first register space occupied by the first subprogram segment in real time (not after the entire warp is executed). Therefore, the warp management circuit 121 can be more flexible in releasing the register space of the register group 122, so that the limited register space of the register group 122 can be more efficiently utilized, thereby improving the parallelism of the task.

[0073] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. An artificial intelligence chip, characterized in that: The artificial intelligence chip includes: Instruction cache, used to store instructions required for thread warp execution; A register circuit for providing a register space; and An execution circuit is coupled to the instruction cache and the register circuit, wherein the execution circuit obtains and executes the thread bundle from the instruction cache, the thread bundle includes a first sub-program segment, the first sub-program segment needs to use a first register space, the execution circuit requires the register circuit to allocate the first register space from the register space of the register circuit to the first sub-program segment for use during the execution of the thread bundle, and the execution circuit requires the register circuit to release the first register space in real time after the execution of the first sub-program segment is completed and before the execution of the thread bundle is completed.

2. The artificial intelligence chip according to claim 1, characterized in that: The thread warp also includes a second subprogram segment, the second subprogram segment does not need to use the register space of the register circuit, the second subprogram segment is executed before the first subprogram segment, and no register space will be allocated to the thread warp during the execution of the second subprogram segment.

3. The artificial intelligence chip according to claim 1, characterized in that: The execution circuit comprises: a plurality of execution cores coupled to the register circuit; and An instruction emission circuit is coupled to the instruction cache and the multiple execution cores, wherein the instruction emission circuit emits the instruction of the thread bundle obtained from the instruction cache to at least one of the multiple execution cores for execution, before the instruction emission circuit emits the first subprogram segment to the multiple execution cores, the instruction emission circuit requires the register circuit to allocate the first register space to the first subprogram segment for use, after allocating the first register space to the first subprogram segment, the instruction emission circuit emits the first subprogram segment to at least one of the multiple execution cores for execution, and the instruction emission circuit requires the register circuit to release the first register space in real time after the first subprogram segment is executed and before the thread bundle is executed.

4. The artificial intelligence chip according to claim 1, characterized in that: The register circuit comprises: a register group coupled to the execution circuit to provide the register space; and A thread warp management circuit is coupled to the execution circuit and the register set, wherein Before the execution circuit executes the first subprogram segment, based on a requirement of the execution circuit, the thread warp management circuit allocates the first register space from the register space of the register group to the first subprogram segment for use; and After the first subprogram segment is executed and before the thread warp is executed, based on a requirement of the execution circuit, the thread warp management circuit releases the first register space of the register group in real time.

5. The artificial intelligence chip according to claim 1, characterized in that: The first subprogram segment includes a register space allocation instruction and a register space release instruction. The execution circuit transmits the register space allocation instruction to the register circuit. The register circuit allocates the first register space from the register space of the register circuit to the first subprogram segment for use based on the register space allocation instruction. The execution circuit transmits the register space release instruction to the register circuit. The register circuit releases the first register space in real time based on the register space release instruction before the thread warp is executed.

6. The artificial intelligence chip according to claim 5, characterized in that: The register space dispatch instruction includes a dispatch offset parameter and a dispatch size parameter, the register circuit determines the first register space based on the dispatch offset parameter and the dispatch size parameter, the register space release instruction includes a release offset parameter and a release size parameter, and the register circuit releases the first register space based on the release offset parameter and the release size parameter.

7. A method for dynamic management of register space of an artificial intelligence chip, characterized in that: The register space dynamic management method comprises: fetching and executing a warp from an instruction cache of the artificial intelligence chip by an execution circuit of the artificial intelligence chip, wherein the warp includes a first subroutine segment, and the first subroutine segment requires use of a first register space; In the process of executing the thread warp, the register circuit of the artificial intelligence chip allocates the first register space from the register space of the register circuit to the first subprogram segment for use; and After the first subprogram segment is executed and before the thread warp is executed, the register circuit releases the first register space in real time.

8. The register space dynamic management method according to claim 7, characterized in that: The thread warp also includes a second subprogram segment, the second subprogram segment does not need to use the register space of the register circuit, the second subprogram segment is executed before the first subprogram segment, and no register space will be allocated to the thread warp during the execution of the second subprogram segment.

9. The register space dynamic management method according to claim 7, characterized in that: The register space dynamic management method further includes: issuing, by an instruction issuing circuit of the execution circuit, the instructions of the thread warp obtained from the instruction cache to at least one of a plurality of execution cores of the execution circuit for execution; Before the instruction issuing circuit issues the first subprogram segment to the multiple execution cores, the instruction issuing circuit requests the register circuit to allocate the first register space to the first subprogram segment for use; After allocating the first register space to the first subprogram segment, the instruction issuing circuit issues the first subprogram segment to at least one of the plurality of execution cores for execution; and After the first subprogram segment is executed and before the thread warp is executed, the instruction issuing circuit requires the register circuit to release the first register space in real time.

10. The register space dynamic management method according to claim 7, characterized in that: The register space dynamic management method further includes: The register space is provided by a register group of the register circuit; Before the execution circuit executes the first subprogram segment, based on a requirement of the execution circuit, the warp management circuit of the register circuit allocates the first register space from the register space of the register group to the first subprogram segment for use; and After the first subprogram segment is executed and before the thread warp is executed, the thread warp management circuit releases the first register space of the register group in real time based on a requirement of the execution circuit.

11. The register space dynamic management method according to claim 7, characterized in that: The first subprogram segment includes a register space allocation instruction and a register space release instruction, and the register space dynamic management method further includes: The execution circuit transmits the register space allocation instruction to the register circuit; Allocating, by the register circuit based on the register space allocation instruction, the first register space from the register space of the register circuit to the first subprogram segment for use; The execution circuit sends the register space release instruction to the register circuit; and Before the thread warp is executed, the register circuit releases the first register space in real time based on the register space release instruction.

12. The register space dynamic management method according to claim 11, characterized in that: The register space dispatch instruction includes a dispatch offset parameter and a dispatch size parameter, the register space release instruction includes a release offset parameter and a release size parameter, and the register space dynamic management method further includes: determining, by the register circuitry, the first register space based on the dispatch offset parameter and the dispatch size parameter; and The first register space is released by the register circuit based on the release offset parameter and the release size parameter.

13. A machine-readable storage medium for storing non-transitory machine-readable instructions, characterized in that: When the non-transitory machine-readable instructions are executed by a computer, the register space dynamic management method according to any one of claims 7 to 12 is implemented.

14. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the register space dynamic management method according to any one of claims 7 to 12 is implemented.

Citation Information

Patent Citations

  • Method of managing register file units

    CN111459543A

  • SIMT device, thread group dynamic construction method and processor

    CN117009054A