A low-overhead thread switching method for tensor operations

By employing a low-overhead thread switching method in semiconductor chips and utilizing hash indexes to confirm the state of tensor data in the SRAM cache, the problems of instruction fetching and cache misses in tensor operations are solved, improving performance and energy efficiency, and optimizing compiler scheduling.

CN116578340BActive Publication Date: 2026-11-24SHANGHAI ARTIFICIAL INTELLIGENCE INNOVATION CENT +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310395659.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-13
Publication Date
2026-11-24
Estimated Expiration
2043-04-13

AI Technical Summary

Technical Problem

Traditional semiconductor chips suffer from high instruction fetch overhead, high power consumption, and frequent cache misses when performing tensor operations, leading to performance degradation. Furthermore, the high complexity of the compiler affects the utilization of computing units.

Method used

A low-overhead thread switching method is adopted, which utilizes the processing unit to execute tensor instructions, receive data packets, parse hash indexes and data, prioritize the execution of high-priority tensor instructions, and confirm the cache status of data in SRAM through hash indexes to reduce cache misses.

Benefits of technology

It reduces instruction fetch and cache miss overhead, improves energy efficiency, reduces circuit area, enhances performance, and optimizes compiler scheduling, thus reducing the probability of cache misses.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116578340B_ABST
    Figure CN116578340B_ABST
Patent Text Reader

Abstract

This invention relates to the field of semiconductor chip technology and proposes a low-overhead thread switching method for tensor operations. The method involves a processing unit performing the following actions: executing a first tensor instruction; receiving a data packet including a hash index and data; parsing the data packet, wherein when a second tensor instruction is parsed and there is an available thread register in the processing unit, the operands and priority of the second tensor instruction are determined; and when all operands of the second tensor instruction are ready and the priority of the second tensor instruction is higher than that of the first tensor instruction, the second tensor instruction is executed. This invention uses tensors as basic operands, significantly reducing the number of instructions within the process object (PE), thereby avoiding additional power consumption, resulting in lower chip power consumption, higher energy efficiency, reduced circuit area, and avoiding instruction cache misses caused by numerous instruction fetch operations, thus improving performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention generally relates to the field of semiconductor chip technology. Specifically, this invention relates to a low-overhead thread switching method for tensor operations. Background Technology

[0002] Traditionally, semiconductor chips typically use operands or processing units at the granularity of individual data points or vectors. This results in significant instruction fetch overhead. Tensor operations require numerous instruction fetches, leading to substantial additional fetch and decode overhead, high power consumption, and low energy efficiency. The large number of fetch operations also necessitates a large instruction cache, resulting in significant area overhead. Furthermore, the high frequency of fetch operations makes cache misses more likely, leading to performance degradation.

[0003] Especially when performing tensor computations, the same cache replacement policy can easily lead to data cache misses when dealing with many different tensor computations. Therefore, different cache replacement policies need to be used for different tensor sizes and computation types. When switching between different tensor computation threads, tensor data that has not yet been computed by the other thread can be evicted from the cache. This can result in the current thread finding that much of the data it needs has already been evicted from the cache line, further degrading performance.

[0004] Due to the large number of processing elements (PEs) and long routing distances in wafer-level chips, the aforementioned problems, such as the miss penalty caused by cache misses, are further increased compared to traditional computing systems, becoming a bottleneck and constraint that severely restricts the utilization rate of computing elements. Furthermore, in wafer-level chips, data that is frequently accessed should ideally be cached locally as much as possible. However, each processing element (PE) itself does not know whether the cached data corresponds to the actual data. If this is entirely guaranteed by the compiler, it will lead to excessively high computational complexity and cause problems with computational correctness when errors occur. Summary of the Invention

[0005] To at least partially solve the aforementioned problems in the prior art, this invention proposes a low-overhead thread switching method for tensor operations, characterized by comprising the following actions performed by a processing unit:

[0006] Execute the first tensor instruction;

[0007] Receive a data packet, the data packet including a hash index and data;

[0008] Parse the data packet, wherein when a second tensor instruction is obtained and there is an idle thread register in the processing unit, determine the operands and priority of the second tensor instruction; and

[0009] The second tensor instruction is executed when all operands of the second tensor instruction are ready and the priority of the second tensor instruction is higher than that of the first tensor instruction.

[0010] In one embodiment of the present invention, parsing the data packet further includes:

[0011] When the immediate value of the second tensor instruction is parsed, the operands of the second tensor instruction other than the immediate value and its priority are determined. The second tensor instruction is executed when all operands of the second tensor instruction other than the immediate value are ready and the priority of the second tensor instruction is higher than that of the first tensor instruction.

[0012] In one embodiment of the present invention, the processing unit includes:

[0013] Multiple thread registers, including:

[0014] Multiple second-level pointers Root Tensor DSDs point to the storage space of the first-level pointer Tensor DSD and the static random access memory, wherein the processing unit uses the second-level pointers Root Tensor DSDs as basic operands.

[0015] Multiple first-level pointers to a Tensor DSD, representing the dimensions of the tensor; and

[0016] Static random access memory.

[0017] In one embodiment of the present invention, the instructions and states stored in the thread register include:

[0018] In one embodiment of the present invention, the instructions and states stored in the thread register include one or more of the following:

[0019] Valid indicates whether the current thread is valid.

[0020] Interrupt Enable indicates whether interrupts are enabled when the current thread is executing.

[0021] Priority indicates the current thread's priority in the scheduling process;

[0022] The source operand represents the data that the thread needs to use during execution;

[0023] The destination operand, Dst Operand, represents the data that the thread will write or modify during execution.

[0024] The opcode indicates the type of operation performed by the instruction.

[0025] Instruction Type, which indicates the type of instruction being executed by the current thread;

[0026] The source register pointer ptr represents the address of the tensor pointed to by the source operand;

[0027] Source stride, which represents the mode of reading the source operand tensor;

[0028] The destination register pointer, Dst Register ptr, represents the address of the tensor pointed to by the destination operand;

[0029] The target step size, Dst Stride, indicates the mode when reading the target operand tensor.

[0030] The source operand hash index represents the hash value of the source operand; and

[0031] The Destination Index (Dst Index) represents the routing information that the destination operand ultimately needs to forward.

[0032] In one embodiment of the present invention, the state and linker stored in the second-level pointer Root Tensor DSD include one or more of the following:

[0033] Start Address, End Address, Hash Index, Tensor Dimension, Validity, Destination Transfer, Link Tensor Index, Data Length, Data Width, Protection Enabled, Ready, and Type.

[0034] In one embodiment of the present invention, the state stored in the first-level pointer Tensor_DSD includes one or more of the following:

[0035] Dimension Length, Data Width, Stride, and Validity.

[0036] In one embodiment of the present invention, the decoded instructions of the processing unit include:

[0037] Calculation instructions, which include:

[0038] Three operands, wherein the three operands include immediate, immediate, and SPM, or immediate, SPM, and SPM, or SPM, SPM, and SPM; or

[0039] Two operands, where the two operands include an immediate value and an immediate value, or an immediate value and an SPM;

[0040] SPM storage commands; and

[0041] SPM load command.

[0042] In one embodiment of the present invention, the current calculation state is stored by the source register pointer (Source Register ptr) and the destination register pointer (Dst Register ptr).

[0043] The present invention also proposes a processing unit that performs the steps of the method.

[0044] The present invention also proposes a wafer-level chip having the aforementioned processing unit.

[0045] This invention has at least the following beneficial effects: It uses a tensor (Root Tensor DSD) as the basic operand, significantly reducing the number of instructions within the PE (Executable Executor). This avoids the additional power consumption caused by fetching and decoding with a large number of instructions, resulting in lower power consumption and higher energy efficiency. Furthermore, it avoids the high instruction cache overhead caused by a large number of instructions, reducing circuit area and preventing instruction cache misses due to numerous instruction fetch operations, thus improving performance. This invention uses tensor computation Thread X as the basic instruction, which is pointed to by a second-level pointer Root Tensor DSD, which in turn points to a first-level pointer Tensor DSD, and then to the corresponding SRAM space. The SRAM address space corresponding to tensors that have not yet completed computation is in a protected state, making it difficult to be replaced, reducing cache misses caused by thread switching. The Source Register 0 ptr to Source Register 2 ptr and Dst Register 0 ptr in the corresponding thread register Thread X during thread computation store the current computation state, making the overhead during thread switching very low, allowing computation to continue directly from the current state address stored in the corresponding pointer. Different threads can be assigned different priorities within Thread X, allowing the compiler to allocate different registers for tasks of varying importance, thus reducing critical paths. The compiler can allocate different tensor computation tasks at different times based on the resource constraints of each processing element (PE) in the wafer-level chip. Since each PE can perform data replacement at the tensor (Root Tensor DSD) granularity, the compiler's scheduling allocation can minimize the probability of cache misses. In wafer-level chips, due to the large number of PEs and long routes, data that is called multiple times should be cached locally as much as possible. This invention proposes a tensor identifier based on a hash index to confirm whether the tensor specified by the route-decoded instruction has been cached in the SRAM within the PE. Attached Figure Description

[0046] To further illustrate the advantages and other features of the various embodiments of the present invention, a more specific description of the embodiments of the present invention will be presented with reference to the accompanying drawings. It is understood that these drawings depict only typical embodiments of the invention and are therefore not intended to limit its scope. In the drawings, identical or corresponding parts will be indicated by the same or similar reference numerals for clarity.

[0047] Figure 1 A schematic diagram of a processing unit with tensor granularity is shown in one embodiment of the present invention.

[0048] Figure 2 A schematic diagram of information stored in Thread, Root_DSD, and Tensor_DSD is shown in one embodiment of the present invention.

[0049] Figure 3 A schematic diagram of the decoded Tensor PE instruction is shown in one embodiment of the present invention.

[0050] Figure 4 A schematic diagram of a data packet is shown in one embodiment of the present invention.

[0051] Figure 5 This diagram illustrates the processing flow after receiving a data packet in one embodiment of the present invention.

[0052] Figure 6A -B illustrates a schematic diagram of thread switching in an embodiment of the present invention.

[0053] Figure 7A -L illustrates a schematic diagram of the operation process of the processing unit in one embodiment of the present invention. Detailed Implementation

[0054] It should be noted that the components in the various figures may be shown exaggeratedly for illustrative purposes and are not necessarily to scale. In each figure, the same reference numerals are used for components that are identical or have the same function.

[0055] In this invention, unless otherwise specified, "arranged on," "arranged above," and "arranged on" do not exclude the possibility of an intermediate element between them. Furthermore, "arranged on or above" merely indicates the relative positional relationship between two components, and in certain cases, such as when the product orientation is reversed, it can also be converted to "arranged below or under," and vice versa.

[0056] In this invention, the various embodiments are merely intended to illustrate the solutions of the invention and should not be construed as limiting.

[0057] In this invention, unless otherwise specified, the quantifiers “a” and “one” do not exclude scenarios involving multiple elements.

[0058] It should also be noted that, in the embodiments of the present invention, only a portion of the components or parts may be shown for clarity and simplicity. However, those skilled in the art will understand that, under the teachings of the present invention, necessary components or parts can be added as needed for specific scenarios. Furthermore, unless otherwise stated, features in different embodiments of the present invention can be combined with each other. For example, a feature in the second embodiment can replace a corresponding or functionally identical or similar feature in the first embodiment, and the resulting embodiment will also fall within the scope of disclosure or description of this application.

[0059] It should also be noted that, within the scope of this invention, the terms "same," "equal," and "equal to" do not imply that the two values ​​are absolutely equal, but rather allow for a certain reasonable margin of error. In other words, the terms also encompass "substantially the same," "substantially equal," and "substantially equal to." Similarly, in this invention, the directional terms "perpendicular to," "parallel to," etc., also encompass the meanings of "substantially perpendicular to" and "substantially parallel to."

[0060] Furthermore, the numbering of the steps in the methods of the present invention does not limit the execution order of the method steps. Unless otherwise specified, the method steps may be executed in different orders.

[0061] The present invention will be further described below with reference to the accompanying drawings and specific embodiments.

[0062] Figure 1 A schematic diagram of a processing unit with tensor-level granularity is shown in one embodiment of the present invention. For example... Figure 1 As shown, the processing unit (Tensor PE) may include multiple Threads, multiple Root_DSDs, multiple Tensor_DSDs, and SRAM. The Thread register can store the Root_DSD of the source operand and destination operand of a given instruction, its interruptibility, priority, and the current execution pointer state. The Root_DSD is the root DSD, similar to a double pointer, containing 0-4 Tensor_DSDs. The Tensor_DSD represents the corresponding dimension.

[0063] Figure 2 A schematic diagram of information stored in Thread, Root_DSD, and Tensor_DSD is shown in one embodiment of the present invention.

[0064] like Figure 2 As shown, the instructions and states stored in a Thread can include:

[0065] Valid: Indicates whether the current thread is valid; Interrupt Enable: Indicates whether interrupts are enabled during the execution of the current thread; Priority: Indicates the priority of the current thread in the scheduler; SourceOperand 0-2: Source operands 0-2: Indicates the data required by a thread during execution, supporting a minimum of one and a maximum of three source operands; Dst Operand: Destination operand: Indicates the data to be written or modified by a thread during execution; Opcode: Indicates the type of operation performed by a given instruction, such as addition, multiplication, comparison, etc.; Instruction Type: Indicates the type of instruction being executed by the current thread, such as having only one source operand or two source operands; State Regs: Indicates the status of the current instruction execution, such as in progress, current position, etc.; Source Register 0-2 ptr: Source register pointer 0-2: Indicates the address of the tensor pointed to by the source operand; Source 0-2 stride: Source stride 0-2: Indicates the mode of reading the source operand tensor, such as continuous reading or reading at certain intervals; Dst Register 0 ptr, Destination Register Pointer, indicates the address of the tensor pointed to by the destination operand; Dst0 Stride, Destination Step 0, indicates the mode of reading the destination operand tensor, such as continuous reading or reading at certain intervals; Source Operand Hash Index, Source Operand Hash Index, indicates the hash value of the source operand to determine whether a certain tensor already exists in a certain core's SPM; Dst Index, Destination Index, indicates the routing information that the destination operand ultimately needs to forward.

[0066] The state and linker stored in the Root_DSD can include: start address StartAddr, end address End Address, Hash Index, Tensor Dimension, Validity, Dst Transfer, Link TENSOR DSD INDEX, DataLength, Data Width, Protection enabled, Ready status, and Type.

[0067] The state stored in Tensor_DSD can include: Dimension Length, Data Width, Stride, and Validity.

[0068] In this invention, instruction decoding can accept at most one immediate value as the source operand. Figure 3 A schematic diagram of the decoded Tensor PE instruction is shown in one embodiment of the present invention.

[0069] like Figure 3 As shown, the decoded Tensor PE instructions include calculation instructions and SPM L / S instructions. Calculation instructions include three-operand calculation instructions and two-operand calculation instructions. Three-operand calculation instructions can include immediate value, immediate value, and SPM, or immediate value, SPM, and SPM, or SPM, SPM, and SPM. Two-operand calculation instructions can include immediate value and immediate value, or immediate value and SPM, or SPM and SPM. SPM L / S instructions include the SPM STORE instruction and the SPM LOAD instruction.

[0070] The hash values ​​of the SPM Tensors used in the decoded Tensor PE instructions are compared. For the SPM LOAD instruction, if the hash values ​​are equal, the instruction is invalidated, a backtracking feedback is sent, and subsequent transmissions are canceled. If the hash values ​​are not equal, the instruction's `ready` flag is set to 1, and the thread operation is switched based on the priority level. The `protect` flag of the corresponding Tensor_DSD is set to 0, and the hash value of the corresponding Tensor_DSD is calculated after execution. For other decoded Tensor PE instructions, if the hash values ​​are equal, the instruction's `ready` flag is set to 1, and the thread operation is switched based on the priority level. The `protect` flag of the corresponding Tensor_DSD is set to 1. If the hash values ​​are not equal, the instruction's `ready` flag is set to 0, the process is temporarily held, and a backtracking feedback is sent to request the reading of the corresponding data.

[0071] Figure 4 A schematic diagram of a data packet is shown in one embodiment of the present invention. For example... Figure 4 As shown, a 32-bit package can include a 16-bit hash index and 16-bit data. The data packet can be parsed into instruction / data, forwarding rules, and control / data information.

[0072] Figure 5 This diagram illustrates the processing flow after receiving a data packet, according to one embodiment of the present invention. Figure 5As shown, this process includes, upon receiving a 32-bit package, first determining if it is instruction information. If the package is not instruction information, it compares the hash_index in the package with the hash_index of all Root_DSDs with a ready value of 0 in existing read instructions, and also compares the hash_index in the package with the hash_index of an immediate operand in a computation instruction. If no matching hash_index is found (Match Not Found), it compares the hash_index again with the hash_index of all Root_DSDs with a ready value of 0 in existing read instructions. If a matching hash_index is found in a read instruction (Match Found in Read Inst), data is written to the Root_DSD address of the corresponding hash_index. If a matching hash_index is found in the immediate operand of a computation instruction (Match Found in ComputeInst's Immediate Operand), the corresponding computation thread is switched, the immediate operand is received, and computation is performed.

[0073] When the package is an instruction message, check if there is an idle thread. If there is no idle thread, trigger BackPressure and return the failure information of the instruction; if there is an idle thread, receive and parse the complete instruction in cycles, and write information to the corresponding thread register (such as priority, interrupt, source operand, destination operand, hash_index, destination operand forwarding information, etc.).

[0074] Figure 6A -B illustrates a schematic diagram of thread switching in an embodiment of the present invention.

[0075] like Figure 6AAs shown, when tensor instruction A is running, the system first checks if interrupt enabled. If the conditions for receiving instruction B and having an empty thread register in Tensor PE are not met, instruction A continues to run until instruction A stalls. However, if instruction B is received and Tensor PE has an empty thread register, the system checks if all operands for instruction B are ready and if a higher priority is available. If the conditions for receiving all operands for instruction B are not met and a higher priority is available, instruction A continues to run until instruction A stalls. A valid thread with the highest priority is selected for execution; if priorities are equal, a thread is randomly selected or a round-robin algorithm is used. When all operands for instruction B are ready and a higher priority is available, execution switches to instruction B, and the running state and pointers of instruction A are preserved in the original registers.

[0076] like Figure 6B As shown, when tensor instruction A is running, it first checks if Interrupt Enable is enabled. If not, and the received data packet is parsed to show that hash_index is an immediate value of another computation instruction B, instruction A continues running, discards the received data packet, and returns fail. If the received data packet is received and the hash_index is parsed to show that hash_index is an immediate value of another computation instruction B, it checks if instruction B has all operands except the immediate value ready and if a higher priority is available. If instruction B has all operands except the immediate value ready and if a higher priority is available, instruction A continues running, discards the received data packet, and returns fail. If instruction B has all operands except the immediate value ready and if a higher priority is available, it switches to executing instruction B, and retains the running state and pointer of instruction A in the original registers.

[0077] Figure 7A -L illustrates a schematic diagram of the operation process of the processing unit in one embodiment of the present invention.

[0078] The operation of the processing unit may include:

[0079] like Figure 7A As shown, the processing unit Tensor PE includes multiple registers Thread. Each Thread includes a primary pointer Tensor DSD, a secondary pointer Root Tensor DSD that points to the primary pointer Tensor DSD, and 48KB of SRAM space.

[0080] like Figure 7BAs shown, the processing unit Tensor PE reads tensor A using the "Read Tensor A Instruction". This involves loading tensor A into the Thread register, where the hash index of tensor A can be 0x1acf and ptr = 0000. The hash index of tensor A is stored in the second pointer, and the dimension of tensor A (Adimension 4) is stored in the first pointer Tensor DSD, occupying the first space in SRAM.

[0081] like Figure 7C As shown, the processing unit Tensor PE receives a 32-bit packet. This packet includes a 16-bit index = 0x1acf and a 16-bit data = [15:0]data, with ptr = 1000 in the Thread register, and occupies storage space in the first space. Until... Figure 7D As shown, in the Thread register, ptr = 3ffff, the data packet reception is complete, and the first space is fully occupied.

[0082] like Figure 7E As shown, the processing unit Tensor PE receives the instruction C = A × B. The Thread register is not ready to execute the C = A × B instruction (C = A × B not ready). The second pointer Root Tensor DSD stores the hash index of tensor C (C hash index 0x3d2e), indicating a need for tensor B.

[0083] like Figure 7F As shown, the processing unit Tensor PE reads and loads tensor B. Tensor B is loaded into the Thread register, with Tensor B ptr = 4000. The hash index of tensor B (Bhash index 0xff71) is stored in the second-level pointer Root Tensor DSD, and the dimension of tensor B (B dimension 4) is stored in the first-level pointer Tensor DSD, occupying a second space in SRAM.

[0084] like Figure 7G As shown, the processing unit Tensor PE receives a 32-bit package. This package includes a 16-bit index = 0xff71 and a 16-bit data = [15:0]data. Tensor B is loaded into the Thread register into TensorB ptr = 7fff, completing the reception of the data package. The second space is then fully occupied.

[0085] like Figure 7H As shown, the processing unit Tensor PE reads and loads tensor D. This involves loading tensor D (priority3) into the Thread register, and setting tensor C = A × B (ptr = 8000, priority2). The second-level pointer Root TensorDSD stores the hash index of tensor D (D hash index 0xd59a), and the first-level pointer Tensor DSD stores the dimension of tensor D (D dimension 2). C hash index 0x3d2e points to the third space in SRAM, and D hash index 0xd59a points to the fourth space in SRAM.

[0086] like Figure 7I As shown, the processing unit Tensor PE receives the data packet (irrelated data package). The tensor C = A × B (ptr = 9000, priority2) in the Thread register occupies storage space in the third space.

[0087] like Figure 7J As shown, the processing unit Tensor PE receives a 32-bit packet. This packet includes a 16-bit index = 0xd59a and a 16-bit data = [15:0]data, which occupies storage space in the fourth space of SRAM.

[0088] like Figure 7K As shown, the processing unit Tensor PE receives the data packet (irrelated data package). In the Thread register, tensor C = A × B (ptr = c999, priority2) is used to complete the reception of the data packet, and the third space is fully occupied.

[0089] like Figure 7L As shown, the processing unit Tensor PE receives the instruction E = C + D. The register Thread is not ready to execute the instruction E = C + D (E = C + D unready). The second pointer stores the hash index of tensor E (E hash index 0x37b9).

[0090] This invention uses root tensors (DSDs) as basic operands, significantly reducing the number of instructions within the PE (Executable Executor). This avoids the extra power consumption caused by fetching and decoding with a large number of instructions, resulting in lower power consumption and higher energy efficiency. Furthermore, it avoids the high instruction cache overhead caused by a large number of instructions, reducing circuit area, and prevents instruction cache misses caused by numerous instruction fetch operations, thus improving performance.

[0091] This invention uses tensor computation Thread X as the basic instruction. It is pointed to by a second-level pointer, Root Tensor DSD, which points to a first-level pointer, Tensor DSD, and then to the corresponding SRAM space. The SRAM address space corresponding to tensors that have not yet been computed is protected and not easily replaced, reducing cache misses caused by thread switching. The Source Register 0ptr to Source Register 2 ptr and Dst Register 0ptr in the corresponding thread register Thread X store the current computation state, making the overhead of thread switching very low, allowing computation to continue directly from the current state address stored in the corresponding pointer.

[0092] Different threads can be assigned different priorities within Thread X, allowing the compiler to allocate different registers for tasks of varying importance, thus reducing critical paths. The compiler can allocate different tensor computation tasks at different times based on the resource constraints of each processing element (PE) in the wafer-level chip. Since each PE can perform data replacement at the tensor (Root Tensor DSD) granularity, the compiler's scheduling allocation can minimize the probability of cache misses. In wafer-level chips, due to the large number of PEs and long routes, data that is called multiple times should be cached locally as much as possible. This invention proposes a tensor identifier based on a hash index to confirm whether the tensor specified by the route-decoded instruction has been cached in the SRAM within the PE.

[0093] Although various embodiments of the invention have been described above, it should be understood that they are presented by way of example only and not as limitations. It will be apparent to those skilled in the art that various combinations, modifications, and alterations can be made without departing from the spirit and scope of the invention. Therefore, the breadth and scope of the invention disclosed herein should not be limited by the exemplary embodiments disclosed above, but should be defined solely by the appended claims and their equivalents.

Claims

1. A low-overhead thread switching method for tensor operations, characterized in that, This includes the following actions being performed by the processing unit: Execute the first tensor instruction; Receive a data packet, the data packet including a hash index and data; The data packet is parsed, wherein when a second tensor instruction is obtained and there is an idle thread register in the processing unit, the operands and priority of the second tensor instruction are determined; as well as The second tensor instruction is executed when all operands of the second tensor instruction are ready and the second tensor instruction has a higher priority than the first tensor instruction. The processing unit includes: Multiple thread registers, including: Multiple second-level pointers Root Tensor DSDs point to the storage space of the first-level pointer Tensor DSD and the static random access memory, wherein the processing unit uses the second-level pointers Root Tensor DSDs as basic operands. Multiple first-level pointers to a Tensor DSD, which represents the dimension of the tensor; and Static Random Access Memory (SRAM) Upon receiving the data packet, the system first determines whether it is an instruction message. If the data packet is not an instruction message, it compares the hash_index in the data packet with the hash_index of all Root_DSDs with a ready value of 0 in existing read instructions. It also compares the hash_index in the data packet with the hash_index of an immediate operand in a calculation instruction. If no matching hash_index is found, it compares the hash_index again with the hash_index of all Root_DSDs with a ready value of 0 in existing read instructions. If a matching hash_index is found in a read instruction, data is written to the corresponding Root_DSD address. If a matching hash_index is found in the immediate operand of a calculation instruction, the corresponding calculation thread is switched, the immediate operand is received, and calculation is performed. When the data packet is an instruction message, it is determined whether there is an idle thread. If there is no idle thread, BackPressure is triggered, and the failure information of the instruction is returned. If there is an idle thread, the complete instruction is received and parsed in cycles, and the information is written to the corresponding thread register.

2. The low-overhead thread switching method for tensor operations according to claim 1, characterized in that, Parsing the data packet also includes: When the immediate value of the second tensor instruction is parsed, the operands of the second tensor instruction other than the immediate value and its priority are determined. The second tensor instruction is executed when all operands of the second tensor instruction other than the immediate value are ready and the priority of the second tensor instruction is higher than that of the first tensor instruction.

3. The low-overhead thread switching method for tensor operations according to claim 1, characterized in that, The instructions and states stored in the thread register include one or more of the following: Valid indicates whether the current thread is valid. Interrupt Enable indicates whether interrupts are enabled when the current thread is executing. Priority indicates the current thread's priority in the scheduling process; The source operand represents the data that the thread needs to use during execution; The destination operand, Dst Operand, represents the data that the thread will write or modify during execution. The opcode indicates the type of operation performed by the instruction. Instruction Type, which indicates the type of instruction being executed by the current thread; The source register pointer ptr represents the address of the tensor pointed to by the source operand; Source stride, which represents the mode of reading the source operand tensor; The destination register pointer, Dst Register ptr, represents the address of the tensor pointed to by the destination operand; The target step size, Dst Stride, indicates the mode when reading the target operand tensor. The Source Operand Hash Index represents the hash value of the source operand. as well as The Destination Index (Dst Index) represents the routing information that the destination operand ultimately needs to forward.

4. The low-overhead thread switching method for tensor operations according to claim 3, characterized in that, The state and linker stored in the second-level pointer Root Tensor DSD include one or more of the following: Start Address, End Address, Hash Index, Tensor Dimension, Validity, Destination Transfer, Link Tensor Index, Data Length, Data Width, Protection Enabled, Ready, and Type.

5. The low-overhead thread switching method for tensor operations according to claim 4, characterized in that, The states stored in the first-level pointer Tensor_DSD include one or more of the following: Dimension Length, Data Width, Stride, and Validity.

6. The low-overhead thread switching method for tensor operations according to claim 5, characterized in that, The decoded instructions from the processing unit include: Calculation instructions, which include: Three operands, wherein the three operands include an immediate value, an immediate value, and an SPM, or an immediate value, an SPM, and an SPM, or an SPM, an SPM, and an SPM; or Two operands, where the two operands include an immediate value and an immediate value, or an immediate value and an SPM; SPM storage commands; and SPM load command.

7. The low-overhead thread switching method for tensor operations according to claim 3, characterized in that, The current calculation state is stored in Source Register 0-2 ptr and Dst Register 0 ptr.

8. A processing unit, characterized in that, Perform the steps of the method according to any one of claims 1-7.

9. A wafer-level chip, characterized in that, It has the processing unit as described in claim 8.

Citation Information

Patent Citations

  • Direct memory access architecture with multiple levels and multiple steps

    CN114556311A

  • Command distribution method, command distributor, chip and electronic device

    CN115129369A