Stack storage circuit, stack push and pop method and device based on stack storage circuit

By using an instruction parser and a stack controller in the stack storage circuit to parse and push relevant information of branch instructions in the same clock cycle, the problem of low execution efficiency in the existing technology is solved and more efficient branch instruction processing is achieved. .

CN118349193BActive Publication Date: 2024-10-18北京辉羲智能科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410782891.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-18
Publication Date
2024-10-18
Estimated Expiration
2044-06-18

AI Technical Summary

Technical Problem

In the existing technology, when the stack storage circuit processes branch instructions, it requires multiple clock cycles to obtain and push relevant information of the convergence instruction and the divergence instruction onto the stack, resulting in reduced execution efficiency.

Method used

Design a stack storage circuit, including an instruction parser and a stack controller, by parsing the relevant information of the currently executed instruction in the same clock cycle, and separately dividing the sub-item information of the converged instruction, the first divergent instruction and the second divergent instruction. Push into different target substacks to optimize the stack pushing process.

Benefits of technology

The execution efficiency of the stack storage circuit is improved, the number of clock cycles is reduced, and the efficiency of processing branch instructions is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118349193B_ABST
    Figure CN118349193B_ABST
Patent Text Reader

Abstract

The present invention provides a stack storage circuit, a stack push and pop method and device based on the stack storage circuit, and relates to the field of storage technology, wherein the stack storage circuit includes an instruction parser, a stack controller and a stack entity, wherein: the instruction parser is used to parse the current execution instruction in the target program to obtain relevant information of the current execution instruction; when the current execution instruction is a branch instruction, the relevant information includes the sub-item information of the convergence instruction or the remaining path corresponding to the current execution instruction, the sub-item information of the first divergence instruction corresponding to the current execution instruction, and the sub-item information of the second divergence instruction; the stack controller is used to push each target sub-item information into different first target sub-stacks in the stack entity in the current clock cycle. When the current execution instruction is a branch instruction, the present invention implements pushing at least one target sub-item information into different first target sub-stacks in the same clock cycle, thereby improving the execution efficiency of the stack storage circuit.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of storage technology, and in particular to a stack storage circuit, and a stack push and pop method and device based on the stack storage circuit. Background Art

[0002] Single Instruction Multiple Thread (SIMT) is a model used in graphics processing unit (GPU) computing. SIMT Stack is part of the SIMT architecture design and is used to handle the execution of thread bundle differentiation on the SIMT architecture. The SIMT architecture cannot perform different operations on data vectors at the same time in the same cycle, but it needs to provide the "illusion" that a single scalar thread follows a different program path. SIMTStack solves this problem when GPU execution encounters thread divergence. It shields threads that do not need to be executed by Lane Mask, and executes the basic block code of each branch in sequence, and finally still shows the "illusion" that each thread is executed independently. Since thread bundle differentiation will reduce the execution efficiency of the hardware, different technologies can be used to reduce this impact. One of the simplest technologies is based on the mechanism of stack-based post-dominant node reconvergence, which is also the function of SIMT Stack.

[0003] In the related technology, in the stack storage circuit, when the currently executed instruction is a branch instruction, the relevant information of the convergence instruction and the relevant information of each divergence instruction corresponding to the currently executed instruction are usually obtained, and the relevant information of the convergence instruction and the relevant information of each divergence instruction are pushed onto the stack respectively using different clock cycles, thereby reducing the execution efficiency of the stack storage circuit. Summary of the invention

[0004] The present invention provides a stack storage circuit, a stack push and pop method and a stack pop device based on the stack storage circuit, so as to solve the defect of reducing the execution efficiency of the stack storage circuit in the prior art.

[0005] The present invention provides a stack storage circuit, comprising an instruction parser, a stack controller and a stack entity, wherein: the instruction parser is used to parse the current execution instruction in the target program to obtain relevant information of the current execution instruction; when the current execution instruction is a branch instruction, the relevant information includes sub-item information of the convergence instruction or the remaining path corresponding to the current execution instruction, sub-item information of the first divergence instruction corresponding to the current execution instruction and sub-item information of the second divergence instruction; the sub-item information of the convergence instruction includes the address of the convergence instruction and the mask of the active thread executing the convergence instruction; the sub-item information of the first divergence instruction includes the address of the convergence instruction, the address of the first divergence instruction and the mask of the active thread executing the first divergence instruction; the sub-item information of the second divergence instruction includes the address of the convergence instruction, the address of the second divergence instruction and the mask of the active thread executing the second divergence instruction.

[0006] The stack controller is used to determine at least one target sub-item information from the sub-item information of the convergence instruction or the remaining path corresponding to the currently executed instruction, the sub-item information of the first branch instruction and the sub-item information of the second branch instruction within the current clock cycle, and push each target sub-item information into a different first target sub-stack in the stack entity.

[0007] According to a stack storage circuit provided by the present invention, the stack controller is specifically used to: when it is determined that the convergence instruction and the top convergence instruction are different, determine the sub-item information of the convergence instruction as the target sub-item information; when it is determined that the first divergence instruction and the convergence instruction are different, determine the sub-item information of the first divergence instruction as the target sub-item information; when it is determined that the second divergence instruction and the convergence instruction are different, determine the sub-item information of the second divergence instruction as the target sub-item information.

[0008] According to a stack storage circuit provided by the present invention, the stack controller is also used to: when the currently executed instruction is not the first instruction in the target program, pop the sub-item information at the top of the second target sub-stack of the stack entity within the current clock cycle.

[0009] According to a stack storage circuit provided by the present invention, the stack controller is also used to: when the currently executed instruction is a non-branch instruction, determine whether the next instruction of the currently executed instruction is a top-of-stack aggregation instruction; when the next instruction is not the top-of-stack aggregation instruction, push the sub-item information of the next instruction into the third target sub-stack in the stack entity.

[0010] According to a stack storage circuit provided by the present invention, the stack controller is also used to: determine a first target address based on the sub-stack identifier of the last pop, the number of target sub-item information of the last pop, and the order of the target sub-item information pushed this time, and determine the sub-stack corresponding to the first target address as the first target sub-stack corresponding to the target sub-item information pushed this time; determine a second target address based on the sub-stack identifier of the last pop, the number of target sub-item information of the last pop, and the number of the target sub-item information, and determine the sub-stack corresponding to the second target address as the second target sub-stack.

[0011] A stack storage circuit provided according to the present invention further includes a static random access memory SRAM controller, and the stack entity includes a shared SRAM and a cache register file corresponding to at least one thread warp.

[0012] The first target sub-stack is used to push each target sub-item information included in the push instruction into the top of the target cache register stack of the corresponding thread warp when receiving the push instruction sent by the stack controller.

[0013] The first target sub-stack is further used to pop the target sub-item information at the top of the target cache register stack based on the pop instruction when receiving the pop instruction sent by the stack controller.

[0014] The SRAM controller is used to send a write request to the shared SRAM when it is determined that the occupied space in the target cache register stack is greater than a first preset value, wherein the write request is used to instruct to write a first preset number of target sub-item information first stored in the target cache register stack into the shared SRAM.

[0015] The SRAM controller is also used to send a read request to the shared SRAM when it is determined that the occupied space in the target cache register stack is less than a second preset value, and the read request is used to instruct to write the second preset number of target sub-item information most recently stored in the shared SRAM back to the target cache register stack; the second preset value is less than the first preset value.

[0016] According to a stack storage circuit provided by the present invention, the stack entity further includes an arbitrator, and all the thread warps correspond to the same shared SRAM.

[0017] The shared SRAM is used to send an arbitration request to the arbitrator when receiving read and write requests sent by at least two target warps; the arbitration request includes an identifier of each of the target warps.

[0018] The arbiter is used to determine the read and write order of the target warps corresponding to the identifiers of the target warps based on a preset priority or a polling priority, and send the read and write order to the shared SRAM.

[0019] The shared SRAM is further used to execute each of the read and write requests based on the read and write sequence.

[0020] The present invention also provides a stack push and pop method based on a stack storage circuit, comprising: parsing the current execution instruction in the target program to obtain relevant information of the current execution instruction; when the current execution instruction is a branch instruction, the relevant information includes sub-item information of the convergence instruction or the remaining path corresponding to the current execution instruction, sub-item information of the first divergence instruction corresponding to the current execution instruction, and sub-item information of the second divergence instruction; the sub-item information of the convergence instruction includes the address of the convergence instruction and the mask of the active thread executing the convergence instruction; the sub-item information of the first divergence instruction includes the address of the convergence instruction, the address of the first divergence instruction, and the mask of the active thread executing the first divergence instruction; the sub-item information of the second divergence instruction includes the address of the convergence instruction, the address of the second divergence instruction, and the mask of the active thread executing the second divergence instruction; in the current clock cycle, determining at least one target sub-item information from the sub-item information of the convergence instruction or the remaining path corresponding to the current execution instruction, the sub-item information of the first divergence instruction, and the sub-item information of the second divergence instruction, and pushing each of the target sub-item information into a different first target sub-stack in the stack entity.

[0021] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the stacking and popping methods based on the stack storage circuit as described above are implemented.

[0022] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the stack push and pop method based on the stack storage circuit as described above is implemented.

[0023] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the stacking and popping methods based on the stack storage circuit described above are implemented.

[0024] The stack storage circuit, the stack push and pop method and device based on the stack storage circuit provided by the present invention, parse the current execution instruction in the target program through the instruction parser in the stack storage circuit to obtain the relevant information of the current execution instruction; when the current execution instruction is a branch instruction, the relevant information includes the sub-item information of the convergence instruction corresponding to the current execution instruction, the sub-item information of the first divergence instruction corresponding to the current execution instruction, and the sub-item information of the second divergence instruction, and then the stack controller in the stack storage circuit determines at least one target sub-item information from the sub-item information of the convergence instruction corresponding to the current execution instruction, the sub-item information of the first divergence instruction, and the sub-item information of the second divergence instruction in the current clock cycle, and pushes each target sub-item information into different first target sub-stacks in the stack entity. It can be seen that the present invention, when the current execution instruction is a branch instruction, realizes pushing at least one target sub-item information into different first target sub-stacks in the same clock cycle, thereby improving the execution efficiency of the stack storage circuit. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0026] Figure 1 is a schematic diagram of an example program in the related art.

[0027] Figure 2 This is one of the principle schematic diagrams of the stack storage circuit provided by the embodiment of the present invention.

[0028] Figure 3 This is the second principle schematic diagram of the stack storage circuit provided by the embodiment of the present invention.

[0029] Figure 4 It is a schematic diagram of a target program provided by an embodiment of the present invention.

[0030] Figure 5 It is a flowchart of a stack push and pop method based on a stack storage circuit provided in an embodiment of the present invention.

[0031] Figure 6 It is a structural schematic diagram of a stack push and pop device based on a stack storage circuit provided in an embodiment of the present invention.

[0032] Figure 7 It is a schematic diagram of the physical structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0033] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0034] The SIMT model introduces the concept of threads, which allows each thread to execute the same instructions independently, but each thread may process different data. The SIMT model is usually used for parallel computing of large-scale data and is suitable for applications that need to process a large amount of similar data, such as the following scenarios.

[0035] The first scenario is graphics processing requirements: GPU is mainly used for graphics rendering, which requires processing a large amount of pixel data at the same time. In order to improve the efficiency of graphics rendering, GPU introduced SIMT technology, which allows GPU to execute multiple threads simultaneously to process different parts of the image.

[0036] The second scenario is the demand for large-scale data parallelism: With the development of scientific computing and data-intensive applications, the demand for processing large-scale data parallelism is increasing. SIMT technology provides an effective way to achieve efficient processing of large-scale data by allowing threads running independently on different data to execute the same instructions.

[0037] The third scenario is heterogeneous computing architecture: With the continuous increase in computing needs, traditional central processing units (CPUs) have been unable to meet the needs of high-performance computing. In order to meet this challenge, heterogeneous computing architectures have emerged, which provide more powerful computing capabilities through the collaboration of GPUs and other accelerators with CPUs. SIMT technology has been widely used in this heterogeneous environment.

[0038] The fourth scenario is data parallel computing: data parallelism exists in many applications, that is, the same operation is performed on a large amount of data. SIMT technology can manage and perform such data parallel computing at the hardware level, thereby improving computing efficiency.

[0039] The fifth scenario, parallel programming model: As the demand for parallel computing increases, some tools and frameworks that support parallel programming models have emerged, such as Compute Unified Device Architecture (CUDA) and OpenCL. These tools enable developers to use SIMT technology to more easily implement parallel computing.

[0040] The sixth scenario, deep learning and neural network computing: The development of deep learning and neural networks has put forward great demands on computing resources, including parallel computing of large-scale matrices and tensors. SIMT technology plays a key role in these fields and provides support for efficient deep learning computing.

[0041] In general, SIMT technology emerged to meet the computing needs of large-scale data parallelism, especially in the fields of graphics processing, scientific computing, deep learning, etc. This technical architecture provides an effective way for threads running independently on different data to execute the same instructions to improve computing efficiency.

[0042] Figure 1 Schematic diagram of an example program in the related art, and the stack entry and exit of the example program are described as follows.

[0043] 1) When executing instruction A of the sample program, three clock cycles are used to push the relevant information of the convergence instruction G, divergence instruction F, and divergence instruction B respectively, as shown in Table 1. First, one clock cycle is used to push the convergence instruction G and the mask of the corresponding active thread, and then one clock cycle is used to push the convergence instruction G, divergence instruction F, and the mask of the active thread corresponding to the divergence instruction F, and then one clock cycle is used to push the convergence instruction G, divergence instruction B, and the mask of the active thread corresponding to the divergence instruction B. In Table 1, the mask 1111 of the active thread indicates that all four threads execute instruction G, the mask 0001 of the active thread indicates that the last thread executes instruction F, and the mask 1110 of the active thread indicates that the first three threads all execute instruction B.

[0044] Table 1

[0045]

[0046] 2) When the divergence instruction B of the example program is executed, the relevant information of the divergence instruction B is popped out of the stack, and the B->G route is disassembled into B->E+E->G, where B->E diverges. Three clock cycles are used to push these three paths onto the stack respectively, as shown in Table 2. At this time, the convergence instruction G is also the top convergence instruction of the stack. First, one clock cycle is used to push the convergence instruction G, the convergence instruction E corresponding to the divergence instruction B, and the mask of the active thread corresponding to the convergence instruction E. Then one clock cycle is used to push the convergence instruction E, instruction D, and the mask of the active thread corresponding to instruction D. Then one clock cycle is used to push the convergence instruction E, instruction C, and the mask of the active thread corresponding to instruction C.

[0047] Table 2

[0048]

[0049] 3) When instruction C of the sample program is executed, the relevant information of instruction C is popped out of the stack in one clock cycle.

[0050] 4) When instruction D of the sample program is executed, the relevant information of instruction D is popped out of the stack in one clock cycle. At this time, the relevant information in the stack is shown in Table 3.

[0051] Table 3

[0052]

[0053] 5) When instruction E of the sample program is executed, the relevant information of instruction E is popped out of the stack in one clock cycle.

[0054] 6) When instruction F of the sample program is executed, the relevant information of instruction F is popped out of the stack in one clock cycle.

[0055] 7) When instruction G of the sample program is executed, the relevant information of instruction G is popped out of the stack in one clock cycle.

[0056] In summary, the above solution requires 11 clock cycles to complete execution, which reduces the execution efficiency.

[0057] Based on this, the present invention proposes a stack storage circuit, which, when the currently executed instruction is a branch instruction, pushes at least one target sub-item information into different first target sub-stacks in the same clock cycle to improve the execution efficiency of the stack storage circuit.

[0058] Combine the following Figure 2-Figure 5 The stack storage circuit of the present invention is described. The stack storage circuit can be arranged in electronic devices such as computers, servers or terminals.

[0059] Figure 2 is one of the principle schematic diagrams of the stack storage circuit provided by the embodiment of the present invention, such as Figure 2 As shown, the stack storage circuit includes an instruction parser, a stack controller (stack ctrl) and a stack entity, and the stack entity includes at least one sub-stack. Figure 2 In the example, a stack entity includes substack 0, substack 1, substack 2 and substack 3.

[0060] The instruction parser is used to parse the current execution instruction in the target program to obtain relevant information of the current execution instruction; when the current execution instruction is a branch instruction, the relevant information includes sub-item information of the convergence instruction or the remaining path corresponding to the current execution instruction, sub-item information of the first divergence instruction corresponding to the current execution instruction, and sub-item information of the second divergence instruction; the sub-item information of the convergence instruction includes the address of the convergence instruction and the mask of the active thread executing the convergence instruction; the sub-item information of the first divergence instruction includes the address of the convergence instruction, the address of the first divergence instruction, and the mask of the active thread executing the first divergence instruction; the sub-item information of the second divergence instruction includes the address of the convergence instruction, the address of the second divergence instruction, and the mask of the active thread executing the second divergence instruction.

[0061] The stack controller is used to determine at least one target sub-item information from the sub-item information of the convergence instruction or the remaining path corresponding to the currently executed instruction, the sub-item information of the first branch instruction and the sub-item information of the second branch instruction within the current clock cycle, and push each target sub-item information into a different first target sub-stack in the stack entity.

[0062] For example, the instruction parser parses the current executing instruction in the target program. When the parsing determines that the current executing instruction is a branch instruction, three items of information of the branch instruction are parsed. The three items of information include sub-item information of the convergence instruction, sub-item information of the first divergence instruction, and sub-item information of the second divergence instruction. The sub-item information further includes the address of the convergence instruction, the address of the divergence instruction, and the mask of the active thread, as shown in Table 4 below.

[0063] Table 4

[0064]

[0065] The stack controller determines which sub-item information needs to be pushed in the current clock cycle. When determining at least one target sub-item information that needs to be pushed, it determines the first target sub-stack corresponding to each target sub-item information, and pushes each target sub-item information into the corresponding first target sub-stack in the stack entity.

[0066] The stack storage circuit provided by the present invention parses the current execution instruction in the target program through the instruction parser in the stack storage circuit to obtain the relevant information of the current execution instruction; when the current execution instruction is a branch instruction, the relevant information includes the sub-item information of the convergence instruction corresponding to the current execution instruction, the sub-item information of the first divergence instruction corresponding to the current execution instruction, and the sub-item information of the second divergence instruction, and then the stack controller in the stack storage circuit determines at least one target sub-item information from the sub-item information of the convergence instruction corresponding to the current execution instruction, the sub-item information of the first divergence instruction, and the sub-item information of the second divergence instruction in the current clock cycle, and pushes each target sub-item information into different first target sub-stacks in the stack entity. It can be seen that the present invention realizes pushing at least one target sub-item information into different first target sub-stacks in the same clock cycle when the current execution instruction is a branch instruction, thereby improving the execution efficiency of the stack storage circuit.

[0067] In one embodiment, the stack controller is specifically used to: when it is determined that the convergence instruction and the top convergence instruction are different, determine the sub-item information of the convergence instruction as the target sub-item information; when it is determined that the first divergence instruction and the convergence instruction are different, determine the sub-item information of the first divergence instruction as the target sub-item information; when it is determined that the second divergence instruction and the convergence instruction are different, determine the sub-item information of the second divergence instruction as the target sub-item information.

[0068] For example, when the currently executed instruction is a branch instruction and the branch instruction diverges, the stack controller needs to determine the target sub-item information that needs to be pushed from the sub-item information of the convergence instruction corresponding to the currently executed instruction, the sub-item information of the first divergence instruction, and the sub-item information of the second divergence instruction. The number of target sub-item information can be one or more, and the judgment conditions for whether each sub-item information is pushed is shown in the following Table 5.

[0069] Table 5

[0070]

[0071] In this embodiment, the stack controller pre-sets the judgment conditions for whether each sub-item information corresponding to the branch instruction is pushed, and determines the target sub-item information to be pushed based on the judgment conditions to ensure the accuracy of the pushed data corresponding to the branch instruction.

[0072] In one embodiment, the stack controller is further used to: when the currently executed instruction is not the first instruction in the target program, pop the sub-item information at the top of the second target sub-stack of the stack entity within the current clock cycle.

[0073] For example, when the currently executing instruction is not the first instruction in the target program, the stack controller, in the current clock cycle, in addition to pushing the target sub-item information determined from the sub-item information of the convergence instruction corresponding to the currently executing instruction, the sub-item information of the first divergence instruction, and the sub-item information of the second divergence instruction, also determines a second target sub-stack for storing the currently executing instruction, and pops the sub-item information at the top of the second target sub-stack, thereby realizing the push and pop process of the stack storage circuit.

[0074] It should be noted that when the currently executed instruction is the first instruction in the target program, the stack is empty and there is no sub-item information that needs to be popped.

[0075] In one embodiment, the stack controller is also used to: when the currently executed instruction is a non-branch instruction, determine whether the next instruction of the currently executed instruction is a top-of-stack aggregation instruction; when the next instruction is not the top-of-stack aggregation instruction, push the sub-item information of the next instruction into the third target sub-stack in the stack entity.

[0076] For example, when the currently executed instruction is a non-branch instruction, that is, when the currently executed instruction is a regular instruction, determine whether the next instruction of the currently executed instruction in the target program is a stack top aggregation instruction. When the next instruction of the currently executed instruction is not a stack top aggregation instruction, push the sub-item information of the next instruction of the currently executed instruction into the third target sub-stack in the stack entity. Here, the third target sub-stack is determined by the stack controller based on the sub-stack identifier of the last pop, the number of target sub-item information of the last pop, and the order of the sub-item information pushed in this time. For example, the number of target sub-item information of the last pop is 1, the sub-stack identifier rd_old_id of the last pop is 0, and the sub-item information pushed in this time is the sub-item information of the next instruction of the currently executed instruction, then the order of the sub-item information pushed in this time is 1, then 0-1+1=0, then it is determined that the id of the third target sub-stack is 0, and the third target sub-stack is sub-stack 0.

[0077] In this embodiment, the stack controller pre-sets the judgment condition of whether to push the sub-item information corresponding to the non-branch instruction to ensure the accuracy of the pushed data corresponding to the non-branch instruction.

[0078] In one embodiment, the stack controller is further used to: determine the first target address based on the substack identifier of the last popped stack, the number of target sub-item information of the last popped stack, and the order of the target sub-item information pushed this time, and determine the substack corresponding to the first target address as the first target substack corresponding to the target sub-item information pushed this time. Determine the second target address based on the substack identifier of the last popped stack, the number of target sub-item information of the last popped stack, and the number of the target sub-item information, and determine the substack corresponding to the second target address as the second target substack.

[0079] Specifically, rd_old_id is used to represent the identifier of the substack that was popped last time, that is, the identifier of the substack that was popped in the previous clock cycle, rd_en is used to represent the number of target sub-item information that was popped last time, and wr_idex is used to represent the order of the target sub-item information that is pushed this time. Then, the identifier of the first target substack corresponding to the target sub-item information that is pushed this time, wr_cur_id=rd_old_id-rd_en+wr_idex; for example, taking the stack entity including 4 substacks as an example, the 4 substacks are substack 0, substack 1, substack 2, and substack 3, where 0, 1, 2 and 3 are both substack identifiers. The identifier of the substack popped last time is 0, and the number of target sub-item information to be pushed in is 3. Then the id of the first target substack corresponding to the first target sub-item information = 0-1+1=0, that is, the first target substack corresponding to the first target sub-item information is substack 0; the id of the first target substack corresponding to the second target sub-item information = 0-1+2=1, that is, the first target substack corresponding to the second target sub-item information is substack 1; the id of the first target substack corresponding to the third target sub-item information = 0-1+3=2, that is, the first target substack corresponding to the third target sub-item information is substack 2.

[0080] Using wr_num to represent the number of target sub-item information, the identifier of the second target sub-stack rd_cur_id=rd_old_id+wr_num-rd_en; for example, the identifier of the sub-stack popped last time is 0, and the number of target sub-item information to be pushed in is 3, then the id of the second target sub-stack=0-1+3=2, that is, the second target sub-stack is sub-stack 2.

[0081] In this embodiment, based on the sub-stack identifier of the last pop, the number of target sub-item information of the last pop, and the order of the target sub-item information pushed this time, the first target sub-stack corresponding to the target sub-item information pushed this time is determined, and based on the sub-stack identifier of the last pop, the number of target sub-item information of the last pop, and the number of target sub-item information, the second target sub-stack is determined, thereby realizing the automatic determination of the sub-stack corresponding to pushing and the sub-stack corresponding to pushing.

[0082] In one embodiment, Figure 3 FIG. 2 is a schematic diagram of the principle of the stack storage circuit provided by an embodiment of the present invention. Figure 3 As shown, the stack storage circuit further includes a static random access memory (SRAM) controller, and the stack entity includes a shared SRAM and a cache register file corresponding to at least one thread warp.

[0083] The first target sub-stack is used to push each target sub-item information included in the push instruction into the top of the target cache register stack of the corresponding thread warp when receiving the push instruction sent by the stack controller.

[0084] The first target sub-stack is further used to pop the target sub-item information at the top of the target cache register stack based on the pop instruction when receiving the pop instruction sent by the stack controller.

[0085] The SRAM controller is used to send a write request to the shared SRAM when it is determined that the occupied space in the target cache register stack is greater than a first preset value, wherein the write request is used to instruct to write a first preset number of target sub-item information first stored in the target cache register stack into the shared SRAM.

[0086] The SRAM controller is also used to send a read request to the shared SRAM when it is determined that the occupied space in the target cache register stack is less than a second preset value, and the read request is used to instruct to write the second preset number of target sub-item information most recently stored in the shared SRAM back to the target cache register stack; the second preset value is less than the first preset value.

[0087] For example, the stack entity supports pushing multiple pieces of information onto the stack at the same time, supports pushing and popping the stack at the same time, supports sharing by multiple warps, and has high-speed characteristics. The stack entity consists of three parts, namely, the cache register file corresponding to each warp, the arbiter, and the shared SRAM.

[0088] The workflow is described as follows: when the sub-stack receives a push instruction, the data included in the push instruction is pushed into the target cache register stack of the corresponding thread bundle, and the existing data in the target cache register stack is shifted down in sequence; when the sub-stack receives a pop instruction, the data at the top of the stack is popped out of the target cache register stack, and the existing data in the target cache register stack is shifted up in sequence; when the space occupied by the target cache register stack is greater than the first preset value A, a write request is issued to the shared SRAM, and the first preset number of target sub-item information first stored in the target cache register stack is written to the shared SRAM; when the space occupied in the target cache register stack is less than the second preset value B, a read request is issued to the shared SRAM, and the second preset number of target sub-item information most recently stored in the shared SRAM is written back to the target cache register stack. The first preset number and the second preset number here can be set based on demand, and the present invention does not limit this. Figure 3As shown, the cache register stack corresponding to each thread bundle warp is divided into two parts, the upper part represents the part that does not exceed the first preset value A, which is used for high-speed stacking and popping; the lower part represents the part that exceeds the first preset value A, which needs to interact with the shared SRAM for reading and writing.

[0089] In this embodiment, the stack entity of the stack storage circuit includes a shared SRAM and a cache register stack corresponding to at least one thread warp. The shared SRAM and the cache register stack are combined. Since most of the sub-item information is pushed and popped multiple times in the cache register stack, the present invention can utilize the efficient reading and writing advantages of the cache register stack to improve execution efficiency; at the same time, when the cache register stack overflows, the shared SRAM can be used to increase the storage capacity.

[0090] In one embodiment, if Figure 3 As shown, the stack entity further includes an arbiter, and all the thread warps correspond to the same shared SRAM.

[0091] The shared SRAM is used to send an arbitration request to the arbitrator when receiving read and write requests sent by at least two target warps; the arbitration request includes an identifier of each of the target warps.

[0092] The arbiter is used to determine the read and write order of the target warps corresponding to the identifiers of the target warps based on a preset priority or a polling priority, and send the read and write order to the shared SRAM.

[0093] The shared SRAM is further used to execute each of the read and write requests based on the read and write sequence.

[0094] For example, since all thread bundles correspond to the same shared SRAM, multiple thread bundles cannot be read and written at the same time. When the shared SRAM receives read and write requests sent by at least two target thread bundles, it needs to send an arbitration request to the arbitrator. When the arbitrator receives the arbitration request sent by the shared SRAM, it obtains the priority of the target thread bundle corresponding to the identifier of each target thread bundle from the preset priority of each thread bundle, and determines the read and write order of all target thread bundles in order from high to low priority. The target thread bundle with the highest priority is the thread bundle that is read and written first; or, the read and write order of the target thread bundle corresponding to the identifier of each target thread bundle is determined based on the polling priority. For example, if the arbitrator polls thread bundle 0 with the highest priority this time, the read and write of thread bundle 0 will be executed first. If the arbitrator polls thread bundle 1 with the highest priority next time, the read and write of thread bundle 1 will be executed first.

[0095] In this embodiment, all thread warps correspond to the same shared SRAM, which reduces the area overhead of the stack storage circuit compared to each thread warp corresponding to an SRAM of a fixed size; and when all thread warps correspond to the same shared SRAM, when the shared SRAM receives read and write requests sent by at least two target thread warps, it can determine the read and write order of the target thread warps corresponding to the identifiers of each target thread warp based on a preset priority or a polling priority, so as to ensure the orderly execution of the read and write operations corresponding to each target thread warp.

[0096] The following describes the working process of the stack storage circuit provided by the present invention with reference to a specific example. Figure 4 is a schematic diagram of a target program provided by an embodiment of the present invention. Assuming that a warp has 4 threads, the execution flow of the warp is as follows: Figure 4 As shown, the execution instructions of each clock cycle, that is, the push and pop situations are as follows: The first clock cycle: the instruction address pc=A, it is a branch instruction, the convergence point is the convergence instruction K, the first divergence instruction 0=divergence instruction B, the mask tmask of the active thread corresponding to the divergence instruction B=1110, the second divergence instruction 1=divergence instruction E, the mask tmask of the active thread corresponding to the divergence instruction E=0001, and the stack is empty at this time.

[0097] The second clock cycle: push the sub-item information of the convergence instruction K (convergence instruction K, the mask 1111 of the active thread corresponding to the convergence instruction K), push the sub-item information of the divergence instruction E (convergence instruction K, divergence instruction E and the mask 0001 of the active thread corresponding to the divergence instruction E) and the sub-item information of the divergence instruction B (convergence instruction K, divergence instruction B and the mask 1110 of the active thread corresponding to the divergence instruction B), as shown in Table 6; the instruction address pc=B, it is a branch instruction, the convergence point is the convergence instruction G, the remaining path is G->K, the first divergence instruction 0=divergence instruction C, the mask tmask of the active thread corresponding to the divergence instruction C=1100, the second divergence instruction 1=divergence instruction G, the divergence instruction G overlaps with the convergence instruction, therefore, the sub-item information of the second divergence instruction 1 does not need to be pushed.

[0098] Table 6

[0099]

[0100] The third clock cycle: the top of the stack is popped, the sub-item information of the remaining paths (convergence instruction K, convergence instruction G, and the mask 1110 of the active thread corresponding to convergence instruction G) is pushed, and the sub-item information of the divergence instruction C (convergence instruction G, divergence instruction C, and the mask 1100 of the active thread corresponding to divergence instruction C) is pushed, as shown in Table 7; the instruction address pc=C, the tmask corresponding to instruction C=1100, instruction C is a non-branch instruction, and the next instruction F of instruction C is not the top convergence instruction, so the next instruction F needs to be pushed.

[0101] Table 7

[0102]

[0103] The 4th clock cycle: the top of the stack is popped, and the sub-item information of the next instruction F (convergence instruction G, divergence instruction F, and the mask 1100 of the active thread corresponding to divergence instruction F) is pushed onto the stack, as shown in Table 8; the instruction address pc=F, the tmask corresponding to instruction F=1100, instruction F is a non-branch instruction, and the next instruction G of instruction F is the top convergence instruction, so the next instruction G is not pushed onto the stack.

[0104] Table 8

[0105]

[0106] 5th clock cycle: the top of the stack is popped, as shown in Table 9; the instruction address pc = G, instruction G is a branch instruction, the convergence instruction G coincides with the convergence instruction at the top of the stack, so the sub-item information of the convergence instruction G is not pushed, the first divergence instruction 0 = divergence instruction H, the mask tmask of the active thread corresponding to the divergence instruction H = 1000, the second divergence instruction 1 = divergence instruction I, the mask tmask of the active thread corresponding to the divergence instruction I = 0110.

[0107] Table 9

[0108]

[0109] The 6th clock cycle: the top of the stack is popped, and the sub-item information of the divergence instruction H (convergence instruction K, divergence instruction H, and the mask 1000 of the active thread corresponding to the divergence instruction H) and the sub-item information of the divergence instruction I (convergence instruction K, divergence instruction I, and the mask 0110 of the active thread corresponding to the divergence instruction I) are pushed onto the stack, as shown in Table 10; the instruction address pc=I, the tmask corresponding to instruction I=0110, instruction I is a non-branch instruction, and the next instruction J of instruction I is not the top convergence instruction, so the next instruction J needs to be pushed onto the stack.

[0110] Table 10

[0111]

[0112] 7th clock cycle: the top of the stack is popped, and the sub-item information of the next instruction J (convergence instruction K, divergence instruction J, and the mask 0110 of the active thread corresponding to divergence instruction J) is pushed onto the stack, as shown in Table 11; the instruction address pc = J, the tmask corresponding to instruction J = 0110, instruction J is a non-branch instruction, and the next instruction K of instruction J is the top convergence instruction, so the next instruction K is not pushed onto the stack.

[0113] Table 11

[0114]

[0115] 8th clock cycle: the top of the stack is popped, as shown in Table 12; the instruction address pc = H, the tmask corresponding to instruction H = 1000, instruction H is a non-branch instruction, and the next instruction K of instruction H is a top-of-stack convergence instruction, so the next instruction K is not pushed onto the stack.

[0116] Table 12

[0117]

[0118] 9th clock cycle: the top of the stack is popped, as shown in Table 13; the instruction address pc = E, the tmask corresponding to instruction E = 0001, instruction E is a non-branch instruction, and the next instruction K of instruction E is a top-of-stack convergence instruction, so the next instruction K is not pushed onto the stack.

[0119] Table 13

[0120]

[0121] 10th clock cycle: the top of the stack is popped, as shown in Table 14; instruction address pc=K, tmask corresponding to instruction K=1111, instruction K is a non-branch instruction, and there is no next instruction.

[0122] Table 14

[0123]

[0124] 11th clock cycle: The top of the stack is popped and the stack is empty.

[0125] It should be noted that in each clock cycle, the specific instruction address of the instruction is determined by the stack controller, and the present invention will not elaborate on it here.

[0126] Figure 5 is a flow chart of a stack push and pop method based on a stack storage circuit provided by an embodiment of the present invention, such as Figure 5 As shown, the stack push and pop method based on the stack storage circuit includes the following steps 501 and 502.

[0127] Step 501, parse the current execution instruction in the target program to obtain relevant information of the current execution instruction; when the current execution instruction is a branch instruction, the relevant information includes sub-item information of the convergence instruction or the remaining path corresponding to the current execution instruction, sub-item information of the first divergence instruction corresponding to the current execution instruction, and sub-item information of the second divergence instruction; the sub-item information of the convergence instruction includes the address of the convergence instruction and the mask of the active thread executing the convergence instruction; the sub-item information of the first divergence instruction includes the address of the convergence instruction, the address of the first divergence instruction, and the mask of the active thread executing the first divergence instruction; the sub-item information of the second divergence instruction includes the address of the convergence instruction, the address of the second divergence instruction, and the mask of the active thread executing the second divergence instruction.

[0128] Step 502: In the current clock cycle, determine at least one target sub-item information from the sub-item information of the convergence instruction or the remaining path corresponding to the currently executed instruction, the sub-item information of the first divergence instruction, and the sub-item information of the second divergence instruction, and push each of the target sub-item information into a different first target sub-stack in the stack entity.

[0129] The stack push and pop method based on the stack storage circuit provided by the present invention parses the current execution instruction in the target program to obtain relevant information of the current execution instruction; when the current execution instruction is a branch instruction, the relevant information includes the sub-item information of the convergence instruction corresponding to the current execution instruction, the sub-item information of the first divergence instruction corresponding to the current execution instruction, and the sub-item information of the second divergence instruction. In the current clock cycle, at least one target sub-item information is determined from the sub-item information of the convergence instruction corresponding to the current execution instruction, the sub-item information of the first divergence instruction, and the sub-item information of the second divergence instruction, and each target sub-item information is pushed into different first target sub-stacks in the stack entity. It can be seen that the present invention realizes pushing at least one target sub-item information into different first target sub-stacks in the same clock cycle when the current execution instruction is a branch instruction, thereby improving the execution efficiency of the stack storage circuit.

[0130] In one embodiment, within the current clock cycle, at least one target sub-item information is determined from the sub-item information of the convergence instruction corresponding to the currently executed instruction, the sub-item information of the first divergence instruction, and the sub-item information of the second divergence instruction. This can be specifically achieved in the following manner: when it is determined that the convergence instruction and the top convergence instruction are different, the sub-item information of the convergence instruction is determined as the target sub-item information; when it is determined that the first divergence instruction and the convergence instruction are different, the sub-item information of the first divergence instruction is determined as the target sub-item information; when it is determined that the second divergence instruction and the convergence instruction are different, the sub-item information of the second divergence instruction is determined as the target sub-item information.

[0131] In one embodiment, the stack push and pop method based on the stack storage circuit also includes the following steps: when the currently executed instruction is not the first instruction in the target program, within the current clock cycle, the sub-item information at the top of the second target sub-stack of the stack entity is popped.

[0132] In one embodiment, the stack push and pop method based on the stack storage circuit also includes the following steps: when the currently executed instruction is a non-branch instruction, determining whether the next instruction of the currently executed instruction is a top-of-stack aggregation instruction; when the next instruction is not the top-of-stack aggregation instruction, pushing the sub-item information of the next instruction into the third target sub-stack in the stack entity.

[0133] In one embodiment, the stack push and pop method based on the stack storage circuit also includes the following steps: determining a first target address based on the sub-stack identifier of the last pop, the number of target sub-item information of the last pop, and the order of the target sub-item information pushed this time, and determining the sub-stack corresponding to the first target address as the first target sub-stack corresponding to the target sub-item information pushed this time; determining a second target address based on the sub-stack identifier of the last pop, the number of target sub-item information of the last pop, and the number of the target sub-item information, and determining the sub-stack corresponding to the second target address as the second target sub-stack.

[0134] In one embodiment, the stack push and pop method based on the stack storage circuit also includes the following steps: when a push instruction sent by a stack controller is received, each target sub-item information included in the push instruction is pushed into the top of the target cache register stack of the corresponding thread warp; when a pop instruction sent by the stack controller is received, based on the pop instruction, the target sub-item information at the top of the target cache register stack is popped; when it is determined that the occupied space in the target cache register stack is greater than a first preset value, a write request is sent to a shared SRAM, and the write request is used to indicate that the first preset number of target sub-item information first stored in the target cache register stack is written to the shared SRAM; when it is determined that the occupied space in the target cache register stack is less than a second preset value, a read request is sent to the shared SRAM, and the read request is used to indicate that the second preset number of target sub-item information most recently stored in the shared SRAM is written back to the target cache register stack; the second preset value is less than the first preset value.

[0135] In one embodiment, the stack push and pop method based on the stack storage circuit also includes the following steps: when receiving read and write requests sent by at least two target thread bundles, based on a preset priority or a polling priority, determining the read and write order of the target thread bundles corresponding to the identifiers of each target thread bundle included in the read and write requests, and executing each of the read and write requests based on the read and write order.

[0136] The stacking and popping device based on the stack storage circuit provided by the present invention is described below. The stacking and popping device based on the stack storage circuit described below and the stacking and popping method based on the stack storage circuit described above can be referred to each other.

[0137] Figure 6 is a schematic diagram of the structure of a stack push and pop device based on a stack storage circuit provided by an embodiment of the present invention, such as Figure 6 As shown, the stack push and pop device 600 based on the stack storage circuit includes a parsing unit 601 and a determining unit 602.

[0138] The parsing unit 601 is used to parse the current execution instruction in the target program to obtain relevant information of the current execution instruction; when the current execution instruction is a branch instruction, the relevant information includes sub-item information of the convergence instruction or the remaining path corresponding to the current execution instruction, sub-item information of the first divergence instruction corresponding to the current execution instruction, and sub-item information of the second divergence instruction; the sub-item information of the convergence instruction includes the address of the convergence instruction and the mask of the active thread executing the convergence instruction; the sub-item information of the first divergence instruction includes the address of the convergence instruction, the address of the first divergence instruction, and the mask of the active thread executing the first divergence instruction; the sub-item information of the second divergence instruction includes the address of the convergence instruction, the address of the second divergence instruction, and the mask of the active thread executing the second divergence instruction.

[0139] Determination unit 602 is used to determine at least one target sub-item information from the sub-item information of the convergence instruction or the remaining path corresponding to the currently executed instruction, the sub-item information of the first divergence instruction and the sub-item information of the second divergence instruction within the current clock cycle, and push each of the target sub-item information into a different first target sub-stack in the stack entity.

[0140] The stack push and pop device based on the stack storage circuit provided by the present invention parses the current execution instruction in the target program to obtain relevant information of the current execution instruction; when the current execution instruction is a branch instruction, the relevant information includes the sub-item information of the convergence instruction corresponding to the current execution instruction, the sub-item information of the first divergence instruction corresponding to the current execution instruction, and the sub-item information of the second divergence instruction. In the current clock cycle, at least one target sub-item information is determined from the sub-item information of the convergence instruction corresponding to the current execution instruction, the sub-item information of the first divergence instruction, and the sub-item information of the second divergence instruction, and each target sub-item information is pushed into different first target sub-stacks in the stack entity. It can be seen that the present invention realizes pushing at least one target sub-item information into different first target sub-stacks in the same clock cycle when the current execution instruction is a branch instruction, thereby improving the execution efficiency of the stack storage circuit.

[0141] Figure 7 is a schematic diagram of the physical structure of an electronic device provided by an embodiment of the present invention, such as Figure 7As shown, the electronic device may include: a processor (processor) 710, a communication interface (Communications Interface) 720, a memory (memory) 730 and a communication bus 740, wherein the processor 710, the communication interface 720, and the memory 730 communicate with each other through the communication bus 740. The processor 710 can call the logic instructions in the memory 730 to execute the stack push and pop method based on the stack storage circuit, the method comprising: parsing the current execution instruction in the target program to obtain the relevant information of the current execution instruction; in the case where the current execution instruction is a branch instruction, the relevant information includes the sub-item information of the convergence instruction or the remaining path corresponding to the current execution instruction, the sub-item information of the first divergence instruction corresponding to the current execution instruction, and the sub-item information of the second divergence instruction; the sub-item information of the convergence instruction includes the address of the convergence instruction and the mask of the active thread executing the convergence instruction; the first divergence The sub-item information of the instruction includes the address of the convergence instruction, the address of the first divergence instruction and the mask of the active thread executing the first divergence instruction; the sub-item information of the second divergence instruction includes the address of the convergence instruction, the address of the second divergence instruction and the mask of the active thread executing the second divergence instruction; within the current clock cycle, at least one target sub-item information is determined from the sub-item information of the convergence instruction or the remaining path corresponding to the currently executed instruction, the sub-item information of the first divergence instruction and the sub-item information of the second divergence instruction, and each target sub-item information is pushed into a different first target sub-stack in the stack entity.

[0142] In addition, the logic instructions in the above-mentioned memory 730 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0143] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the stack push and pop methods based on the stack storage circuit provided by the above methods. The method includes: parsing the current execution instruction in the target program to obtain relevant information of the current execution instruction; when the current execution instruction is a branch instruction, the relevant information includes the sub-item information of the convergence instruction or the remaining path corresponding to the current execution instruction, the sub-item information of the first divergence instruction corresponding to the current execution instruction, and the sub-item information of the second divergence instruction; the sub-item information of the convergence instruction includes The address of the convergence instruction and the mask of the active thread executing the convergence instruction; the sub-item information of the first divergence instruction includes the address of the convergence instruction, the address of the first divergence instruction and the mask of the active thread executing the first divergence instruction; the sub-item information of the second divergence instruction includes the address of the convergence instruction, the address of the second divergence instruction and the mask of the active thread executing the second divergence instruction; in the current clock cycle, at least one target sub-item information is determined from the sub-item information of the convergence instruction or the remaining path corresponding to the currently executed instruction, the sub-item information of the first divergence instruction and the sub-item information of the second divergence instruction, and each target sub-item information is pushed into a different first target sub-stack in the stack entity.

[0144] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the stack push and pop methods based on the stack storage circuit provided by the above-mentioned methods, the method comprising: parsing the current execution instruction in the target program to obtain relevant information of the current execution instruction; in the case where the current execution instruction is a branch instruction, the relevant information includes the sub-item information of the convergence instruction or the remaining path corresponding to the current execution instruction, the sub-item information of the first divergence instruction corresponding to the current execution instruction, and the sub-item information of the second divergence instruction; the sub-item information of the convergence instruction includes the address of the convergence instruction and the execution instruction. The mask of the active thread of the convergence instruction; the sub-item information of the first divergence instruction includes the address of the convergence instruction, the address of the first divergence instruction and the mask of the active thread executing the first divergence instruction; the sub-item information of the second divergence instruction includes the address of the convergence instruction, the address of the second divergence instruction and the mask of the active thread executing the second divergence instruction; in the current clock cycle, at least one target sub-item information is determined from the sub-item information of the convergence instruction or the remaining path corresponding to the currently executed instruction, the sub-item information of the first divergence instruction and the sub-item information of the second divergence instruction, and each target sub-item information is pushed into a different first target sub-stack in the stack entity.

[0145] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0146] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0147] 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 make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A stack storage circuit, characterized in that: It includes instruction parser, stack controller and stack entity, among which: The instruction parser is used to parse the current execution instruction in the target program to obtain relevant information of the current execution instruction; when the current execution instruction is a branch instruction, the relevant information includes sub-item information of the convergence instruction or the remaining path corresponding to the current execution instruction, sub-item information of the first divergence instruction corresponding to the current execution instruction, and sub-item information of the second divergence instruction; the sub-item information of the convergence instruction includes the address of the convergence instruction and the mask of the active thread executing the convergence instruction; the sub-item information of the first divergence instruction includes the address of the convergence instruction, the address of the first divergence instruction, and the mask of the active thread executing the first divergence instruction; the sub-item information of the second divergence instruction includes the address of the convergence instruction, the address of the second divergence instruction, and the mask of the active thread executing the second divergence instruction; The stack controller is used to determine at least one target sub-item information from the sub-item information of the convergence instruction or the remaining path corresponding to the currently executed instruction, the sub-item information of the first divergence instruction and the sub-item information of the second divergence instruction in the current clock cycle, and push each of the target sub-item information into different first target sub-stacks in the stack entity respectively; The stack controller is specifically used for: When it is determined that the aggregation instruction and the stack top aggregation instruction are different, determining the sub-item information of the aggregation instruction as the target sub-item information; In a case where it is determined that the first divergence instruction and the convergence instruction are different, determining the sub-item information of the first divergence instruction as the target sub-item information; In the case where it is determined that the second divergence instruction and the convergence instruction are different, determining the sub-item information of the second divergence instruction as the target sub-item information; In the case where the currently executed instruction is not the first instruction in the target program, in the current clock cycle, popping the sub-item information at the top of the second target sub-stack of the stack entity; The stack controller is further configured to: Determine a first target address based on the substack identifier of the last popped substack, the number of target sub-item information of the last popped substack, and the order of the target sub-item information pushed this time, and determine the substack corresponding to the first target address as the first target substack corresponding to the target sub-item information pushed this time; Based on the sub-stack identifier of the last pop, the number of target sub-item information of the last pop and the number of the target sub-item information, a second target address is determined, and the sub-stack corresponding to the second target address is determined as the second target sub-stack.

2. The stack storage circuit according to claim 1, characterized in that: The stack controller is further configured to: When the currently executed instruction is a non-branch instruction, determining whether the next instruction of the currently executed instruction is a stack top aggregation instruction; When the next instruction is not the stack top aggregation instruction, the sub-item information of the next instruction is pushed into a third target sub-stack in the stack entity.

3. The stack storage circuit according to claim 1, characterized in that: It also includes a static random access memory SRAM controller, wherein the stack entity includes a shared SRAM and a cache register file corresponding to at least one thread warp; The first target sub-stack is used to push each target sub-item information included in the push instruction into the top of the target cache register stack of the corresponding thread warp when receiving the push instruction sent by the stack controller; The first target sub-stack is further used to pop the target sub-item information at the top of the target cache register stack based on the pop instruction when receiving the pop instruction sent by the stack controller; The SRAM controller is used to send a write request to the shared SRAM when it is determined that the occupied space in the target cache register stack is greater than a first preset value, wherein the write request is used to instruct to write a first preset number of target sub-item information first stored in the target cache register stack into the shared SRAM; The SRAM controller is further configured to send a read request to the shared SRAM when it is determined that the occupied space in the target cache register stack is less than a second preset value, wherein the read request is used to instruct to write the second preset number of target sub-item information most recently stored in the shared SRAM back to the target cache register stack; The second preset value is smaller than the first preset value.

4. The stack storage circuit according to claim 3, characterized in that: The stack entity further includes an arbiter, and all the thread warps correspond to the same shared SRAM; The shared SRAM is used to send an arbitration request to the arbitrator when receiving a read or write request sent by at least two target warps; The arbitration request includes an identifier of each of the target warps; The arbiter is used to determine the read and write order of the target warps corresponding to the identifiers of the target warps based on a preset priority or a polling priority, and send the read and write order to the shared SRAM; The shared SRAM is further used to execute each of the read and write requests based on the read and write sequence.

5. A stack push and pop method based on a stack storage circuit, characterized in that: include: Parsing the currently executed instruction in the target program to obtain relevant information of the currently executed instruction; In the case where the currently executed instruction is a branch instruction, the relevant information includes sub-item information of a convergence instruction or a remaining path corresponding to the currently executed instruction, sub-item information of a first divergence instruction corresponding to the currently executed instruction, and sub-item information of a second divergence instruction; the sub-item information of the convergence instruction includes an address of the convergence instruction and a mask of an active thread executing the convergence instruction; the sub-item information of the first divergence instruction includes an address of the convergence instruction, an address of the first divergence instruction, and a mask of an active thread executing the first divergence instruction; the sub-item information of the second divergence instruction includes an address of the convergence instruction, an address of the second divergence instruction, and a mask of an active thread executing the second divergence instruction; In the current clock cycle, at least one target sub-item information is determined from the sub-item information of the convergence instruction or the remaining path corresponding to the currently executed instruction, the sub-item information of the first divergence instruction, and the sub-item information of the second divergence instruction, and each of the target sub-item information is pushed into a different first target sub-stack in the stack entity; The determining, within the current clock cycle, at least one target sub-item information from the sub-item information of the convergent instruction corresponding to the currently executed instruction, the sub-item information of the first divergent instruction, and the sub-item information of the second divergent instruction comprises: When it is determined that the convergence instruction and the top-of-stack convergence instruction are different, the sub-item information of the convergence instruction is determined as the target sub-item information; when it is determined that the first divergence instruction and the convergence instruction are different, the sub-item information of the first divergence instruction is determined as the target sub-item information; when it is determined that the second divergence instruction and the convergence instruction are different, the sub-item information of the second divergence instruction is determined as the target sub-item information; The method further comprises: In the case where the currently executed instruction is not the first instruction in the target program, in the current clock cycle, popping the sub-item information at the top of the second target sub-stack of the stack entity; Based on the sub-stack identifier of the last pop, the number of target sub-item information popped last, and the order of the target sub-item information pushed this time, the first target address is determined, and the sub-stack corresponding to the first target address is determined as the first target sub-stack corresponding to the target sub-item information pushed this time; based on the sub-stack identifier of the last pop, the number of target sub-item information popped last, and the number of target sub-item information, the second target address is determined, and the sub-stack corresponding to the second target address is determined as the second target sub-stack.

6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the stack push and pop method based on the stack storage circuit as claimed in claim 5 is implemented.

7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the stack push and pop method based on a stack storage circuit as claimed in claim 5 is implemented.

Citation Information

Patent Citations

  • Branch instruction processing method, processor, chip, board card, equipment and medium

    CN114911528A

  • Synchronized microthreading

    CN116893894A