Task processing methods and chips

By using relational identifiers and restricting instruction queues in task processing, the task execution logic is simplified, the compiler burden caused by complex data dependencies between multiple execution units is resolved, and task processing efficiency is improved.

CN118672742BActive Publication Date: 2025-11-14HUAWEI TECH CO LTD

Patent Information

Application Number
CN202310317498.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-16
Publication Date
2025-11-14
Estimated Expiration
2043-03-16

AI Technical Summary

Technical Problem

In scenarios with complex task execution logic, due to the complex data dependencies between multiple execution units, existing technologies require a large number of judgment instructions to ensure the correctness of task execution, resulting in an excessive burden on the compiler and low task processing efficiency.

Method used

By using relational identifiers and restricting instruction queues in tasks, data dependencies can be indicated, task processing status can be updated, and pairing trigger and wait instructions can be avoided, simplifying task execution logic.

Benefits of technology

It reduces the compiler's burden, improves task processing efficiency, simplifies code, and ensures the accuracy of task execution timing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118672742B_ABST
    Figure CN118672742B_ABST
Patent Text Reader

Abstract

This application provides a task processing method and chip, relating to the field of computer technology. The task processing method includes: placing all instructions in an instruction sequence used to implement a task into multiple instruction queues corresponding one-to-one with multiple execution units; determining the processing state of a second instruction queue that the first instruction queue depends on in the data dependency relationship indicated by the relation identifier based on a relation identifier corresponding to a restricted instruction at the head of a first instruction queue; and, if the processing state is complete, retrieving the restricted instruction corresponding to the relation identifier from the first instruction queue to execute the instructions following the restricted instruction; wherein the processing state is updated according to the relation identifier; and completing the processing of the multiple instruction queues to obtain the task processing result. This application can reduce the compiler burden when different tasks are executed asynchronously, improving task processing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a task processing method and a chip. Background Technology

[0002] With the significant increase in workload in fields such as artificial intelligence and cloud computing, multiple execution units are used to execute multiple tasks with data dependencies to improve processing efficiency. This has led to the widespread use of acceleration chips that include asynchronous execution units, such as graphics processing units (GPUs), field-programmable gate arrays (FPGAs), and application-specific integrated circuits (ASICs).

[0003] In related technologies, data dependencies between multiple tasks lead to data dependencies between multiple execution units. These execution units need to process tasks asynchronously to ensure the correct timing of each task's execution. For example, execution unit E0 executes task A0, and execution unit E1 executes task A1. Task A1 depends on the data output by task A0. After execution unit E0 completes task A0, it sends a trigger instruction to execution unit E1, and execution unit E1 executes a wait instruction to await receiving the trigger instruction. In this way, execution unit E1 can access the data output by execution unit E1 from task A0, thereby executing task A1. In other words, in the above task processing, different execution units with data dependencies must maintain pairs of trigger instructions and wait instructions.

[0004] However, in scenarios with complex task execution logic, there may be multiple conditions for whether a task has completed. In such cases, it is necessary to set judgment instructions for each condition to determine the corresponding task execution status, i.e., whether the task has completed, to ensure that the correct pairs of trigger and wait instructions are set for different judgment instructions. This results in a large number of judgments in task processing, which can easily burden the compiler and lead to low task processing efficiency. Summary of the Invention

[0005] To address the aforementioned technical problems, this application provides a task processing method and a chip. In this task processing method, asynchronous execution between the task and its dependent tasks can be achieved through a relational identifier used to indicate the data dependencies of the task and a restriction instruction set at the head of the instruction queue used to implement the task. This reduces the compiler burden and improves task processing efficiency.

[0006] In a first aspect, embodiments of this application provide a task processing method, which may include: reading all instructions in an instruction sequence for implementing a task and placing them into multiple instruction queues corresponding one-to-one with multiple execution units; determining the processing status of a second instruction queue that the first instruction queue depends on in the data dependency relationship indicated by the relation identifier, based on the relation identifier corresponding to the restriction instruction at the head of the first instruction queue; wherein the first instruction queue is any one of the multiple instruction queues, and the second instruction queue is one of the multiple instruction queues; when the processing status is completed, retrieving the restriction instruction corresponding to the relation identifier from the first instruction queue and executing the instructions following the restriction instruction through the execution unit corresponding to the first instruction queue; when the processing of the first instruction queue is completed, updating the processing status of the first instruction queue to completed based on the relation identifier; and when the processing of multiple instruction queues is completed, obtaining the task processing result.

[0007] For example, the task could be an image recognition task, a data retrieval task, a video encoding task, etc. Any instruction queue can have one or more data dependencies. For example, instruction queue 2 has two data dependencies: the first is the data dependency between instruction queue 2 and instruction queue 1, indicated by relation identifier #1; the second is the data dependency between instruction queue 2 and instruction queue m, indicated by relation identifier #2.

[0008] In this embodiment, the processing status of a task is updated based on different relation identifiers used to indicate different data dependencies within the task. This allows the processing of another task that has a data dependency on this task to be performed directly based on the corresponding relation identifier, without the need for numerous conditional statements. Furthermore, a constraint instruction is set at the head of the instruction queue used to implement the task. This ensures that if the task on which the task depends is not completed, the constraint instruction is not retrieved to postpone the execution of the task, thus guaranteeing accurate task execution timing without the need for paired trigger and wait instructions. Therefore, this solution achieves asynchronous task execution without the need for numerous conditional statements and corresponding trigger and wait instructions, thereby reducing the compiler burden and improving task processing efficiency. Additionally, eliminating the need for numerous conditional statements and corresponding trigger and wait instructions ensures that the code used to implement the task is more concise.

[0009] According to the first aspect, at least one data dependency of the first instruction queue includes: when the execution of the first instruction queue depends on the data output by the second instruction queue among multiple instruction queues, there is a data dependency between the first instruction queue and the second instruction queue.

[0010] For example, Figure 6This is an example diagram illustrating task relationships and relationship identifiers in a task processing method provided in an embodiment of this application. For example... Figure 6 As shown, the relation identifier #1 indicates the data dependency between instruction queue 1 (represented by instruction queue 1) and instruction queue 2 (represented by instruction queue 2). Instruction queue 1 contains instruction instr1, and instruction queue 2 contains instructions instr2 and instr3. The execution of instruction instr2 depends on the execution result of instruction instr1, which is the data output by instruction queue 1.

[0011] According to the first aspect, or any implementation of the first aspect above, all instructions in the instruction sequence for implementing the task are read and placed into multiple instruction queues corresponding one-to-one with multiple execution units, including: reading all instructions in the instruction sequence for implementing the task one by one and placing the read instructions into a target instruction queue, wherein the target instruction queue is one of multiple instruction queues; when a restrictive instruction is read, first information is allocated to the restrictive instruction according to the relation identifier corresponding to the restrictive instruction; wherein the first information is used to indicate the execution order of the restrictive instruction in the data dependency relationship indicated by the corresponding relation identifier; when the first instruction queue has been processed, the processing status of the first instruction queue is updated to completed processing according to the relation identifier, including: when the first instruction queue has been processed, second information corresponding to the relation identifier is allocated to the first instruction queue, wherein... The second information is used to indicate that the first instruction queue has completed processing. The second sequential information corresponding to the same relation identifier is allocated in the same way as the first information. Based on the relation identifier corresponding to the restriction instruction at the head of the first instruction queue, the processing status of the second instruction queue that the first instruction queue depends on in the data dependency relationship indicated by the relation identifier is determined. This includes: reading the first information and the second information corresponding to the relation identifier based on the relation identifier corresponding to the restriction instruction at the head of the first instruction queue; if the first information and the second information read are the same, the processing status of the second instruction queue that the first instruction queue depends on in the data dependency relationship indicated by the relation identifier is determined to be completed processing; if the first information and the second information read are different, the processing status of the second instruction queue that the first instruction queue depends on in the data dependency relationship indicated by the relation identifier is determined to be incomplete processing.

[0012] In this embodiment, first and second information corresponding to the relationship identifier respectively indicate the execution order of restriction instructions in the corresponding data dependency relationship, and whether the first instruction queue in the data dependency relationship has been processed. Furthermore, the allocation method of the second information is the same as that of the first information. Thus, when the second instruction queue has completed execution, the second information corresponding to the relationship identifier is updated to be the same as the first information of the first instruction queue corresponding to the second instruction queue. This ensures that the processing status of the second instruction queue can be determined simply by comparing whether the first and second information are the same, without needing to establish a corresponding relationship to record the processing progress and data dependency relationships of the instruction queue, further improving task processing efficiency.

[0013] According to the first aspect, or any implementation of the first aspect above, when a restriction instruction is read, first information is allocated to the restriction instruction based on the relation identifier corresponding to the restriction instruction, including: when a restriction instruction is read, determining the first information for the relation identifier corresponding to the restriction instruction and allocating it to the restriction instruction; when first information is allocated for a relation identifier each time, updating the first information corresponding to a relation identifier for use in the next allocation of first information for that relation identifier; when the first instruction queue is processed, second information corresponding to the relation identifier is allocated to the first instruction queue, including: when the first instruction queue is processed, determining the second information for the relation identifier corresponding to the first instruction queue and allocating it to the first instruction queue; when second information is allocated for a relation identifier each time, updating the second information corresponding to a relation identifier for use in the next allocation of second information for that relation identifier.

[0014] For example, Figure 7 This is a timing example diagram of a task processing method provided in an embodiment of this application. For example... Figure 7 As shown, at time t1, the restriction variable get cnt of the restriction instruction get(E1,#0) in the instruction queue 1 corresponding to the execution unit E1 is 1, which is the same as the value of the second information global rel cnt corresponding to the relation identifier #0. It can be determined that the processing status of the second instruction queue, which is the instruction queue 0, corresponding to the instruction queue 1 is completed.

[0015] In this embodiment of the application, by allocating the first information and the second information in the same way, it can be ensured that the processing status of the second subtask can be determined by directly comparing the first information and the second information, without the need to establish a complex correspondence table, thereby further improving the task processing efficiency.

[0016] According to the first aspect, or any implementation of the first aspect above, after retrieving the restriction instruction corresponding to the relation identifier from the first instruction queue, the task processing method further includes: determining that the first instruction queue has completed processing when the update instruction corresponding to the relation identifier is retrieved from the first instruction queue; wherein the update instruction corresponding to the relation identifier is set at the tail of the queue used to implement the first instruction queue.

[0017] For example, such as Figure 6 As shown, the relation identifier #1 of instruction queue 1 corresponds to the update instruction rel(E0, #1); the update instruction rel(E0, #1) is located at the tail of instruction queue 1, that is, after instruction instr1 and adjacent to instruction instr1. Thus, retrieving the update instruction means that the instructions used to implement the instruction queue in the corresponding instruction queue have been executed, and the processing status of the instruction queue is complete.

[0018] In this embodiment of the application, by setting an update instruction at the tail of the instruction queue used to implement the instruction queue, it is possible to determine that the instruction queue in which the update instruction is located has been processed as soon as the update instruction is retrieved, thereby further improving the efficiency of task processing.

[0019] According to the first aspect, or any implementation of the first aspect above, determining the first information for the relation identifier corresponding to the restriction instruction includes: reading the first counting result of the first counting unit to obtain the first information for the relation identifier corresponding to the restriction instruction; updating the first information corresponding to a relation identifier for the next allocation of first information for that relation identifier when first information has been allocated each time, including: controlling the first counting unit to count based on the allocated first counting result to obtain the updated first information corresponding to a relation identifier for the next allocation of first information for that relation identifier when first information has been allocated each time; in the first... When an instruction queue is completed, for the relation identifier corresponding to the first instruction queue, second information is determined and allocated to the first instruction queue, including: for the relation identifier corresponding to the first instruction queue, the second counting result of the second counting unit is read to obtain the second information; when second information is allocated for a relation identifier each time, the second information corresponding to the relation identifier is updated for the next allocation of second information for the relation identifier, including: when second information is allocated for a relation identifier each time, the second counting unit is controlled to count based on the allocated second counting result to obtain the updated second information corresponding to the relation identifier for the next allocation of second information for the relation identifier.

[0020] For example, the first information is global get cnt, and updating the first information can be the control unit controlling the first counter to execute "global get cnt++"; the second information is global rel cnt, and updating the second information can be the control unit controlling the second counter to execute "global rel cnt++".

[0021] In this embodiment, the values ​​of the first information and the second information are updated respectively using the counting results of the first counting unit and the second counting unit, which is more concise and accurate.

[0022] Secondly, embodiments of this application provide a chip, which includes: a control unit, multiple execution units, and multiple queue placement units connected to the multiple execution units one by one; the multiple queue placement units are respectively connected to the control unit; the control unit is configured to read all instructions in an instruction sequence for implementing a task and place them into multiple instruction queues, wherein the multiple instruction queues are placed in the multiple queue placement units one by one; the queue placement units are configured to place instruction queues corresponding to the connected execution units; the control unit is further configured to determine, based on the relation identifier corresponding to the restriction instruction at the head of the first instruction queue, the second instruction that the first instruction queue depends on in the data dependency relationship indicated by the relation identifier. The processing status of the queue; wherein, the first instruction queue is any one of multiple instruction queues, and the second instruction queue is one of multiple instruction queues; when the processing status is "processing complete", the restriction instruction corresponding to the relation identifier is retrieved from the first instruction queue and the instruction following the restriction instruction is executed by the execution unit corresponding to the first instruction queue; the execution unit is used to process the instruction queue in the queue placement unit connected to the execution unit under the scheduling of the control unit; the control unit is also used to update the processing status of the first instruction queue to "processing complete" according to the relation identifier when the processing of the first instruction queue is completed; when the processing of multiple instruction queues is completed, the processing result of the task is obtained.

[0023] According to the second aspect, the control unit is specifically configured to: read all instructions in the instruction sequence for implementing the task one by one, and place the read instructions into a target instruction queue, wherein the target instruction queue is one of multiple instruction queues; when a restriction instruction is read, allocate first information to the restriction instruction according to the relation identifier corresponding to the restriction instruction; wherein the first information is used to indicate the execution order of the restriction instruction in the data dependency relationship indicated by the corresponding relation identifier; when the first instruction queue has been processed, allocate second information corresponding to the relation identifier to the first instruction queue, wherein the second information is used to indicate that the first instruction queue has been processed, and the allocation method of the second sequence information corresponding to the same relation identifier is the same as that of the first information; read the first information and second information corresponding to the relation identifier according to the relation identifier corresponding to the restriction instruction at the head of the first instruction queue; when the read first information and read second information are the same, determine that the processing status of the second instruction queue that the first instruction queue depends on in the data dependency relationship indicated by the relation identifier is completed; when the read first information and read second information are different, determine that the processing status of the second instruction queue that the first instruction queue depends on in the data dependency relationship indicated by the relation identifier is not completed.

[0024] According to the second aspect, or any implementation thereof, the control unit is specifically configured to: upon reading a restriction instruction, determine first information for the relation identifier corresponding to the restriction instruction and allocate it to the restriction instruction; upon allocating first information for a relation identifier each time, update the first information corresponding to the relation identifier for the next allocation of first information for that relation identifier; upon completion of processing of the first instruction queue, allocate second information corresponding to the relation identifier to the first instruction queue, including: upon completion of processing of the first instruction queue, determine second information for the relation identifier corresponding to the first instruction queue and allocate it to the first instruction queue; upon allocating second information for a relation identifier each time, update the second information corresponding to the relation identifier for the next allocation of second information for that relation identifier.

[0025] According to the second aspect, or any implementation of the second aspect above, the control unit is further configured to: after retrieving the restriction instruction corresponding to the relation identifier from the first instruction queue, and in the case of retrieving the update instruction corresponding to the relation identifier from the first instruction queue, determine that the first instruction queue has completed processing; wherein the update instruction corresponding to the relation identifier is set at the tail of the queue used to implement the first instruction queue.

[0026] According to the second aspect, or any implementation thereof, the chip further includes a first counting unit and a second counting unit respectively connected to the control unit; the first counting unit is used to count according to a preset counting method under the control of the control unit to obtain a first counting result; the second counting unit is used to count according to a preset counting method under the control of the control unit to obtain a second counting result; the control unit is specifically used to: read the first counting result of the first counting unit for the relation identifier corresponding to the restriction instruction to obtain first information; when first information is allocated for a relation identifier each time, control the first counting unit to count based on the allocated first counting result to obtain updated first information corresponding to a relation identifier for the next allocation of first information for a relation identifier; read the second counting result of the second counting unit for the relation identifier corresponding to the first instruction queue to obtain second information; when second information is allocated for a relation identifier each time, control the second counting unit to count based on the allocated second counting result to obtain updated second information corresponding to a relation identifier for the next allocation of second information for that relation identifier.

[0027] The second aspect and any implementation thereof correspond to the first aspect and any implementation thereof, respectively. The technical effects of the second aspect and any implementation thereof are similar to those of the first aspect and any implementation thereof, and will not be repeated here.

[0028] Thirdly, embodiments of this application provide a task processing system, which includes: a control unit, multiple execution units, and multiple queue placement units connected to the multiple execution units one by one, wherein the multiple queue placement units are respectively connected to the control unit; wherein the control unit and the multiple queue placement units are included in a first chip, and the multiple execution units are respectively included in at least one second chip; the control unit is used to read all instructions in an instruction sequence for implementing a task and place them into multiple instruction queues, wherein the multiple instruction queues are placed in multiple queue placement units one by one; the queue placement units are used to place the instruction queues corresponding to the connected execution units; the control unit is further used to determine the first instruction queue according to the relation identifier corresponding to the restriction instruction at the head of the first instruction queue. The processing status of the second instruction queue, which is depended upon in the data dependency relationship indicated by the relation identifier, is listed; wherein the first instruction queue is any one of multiple instruction queues, and the second instruction queue is one of multiple instruction queues; when the processing status is "processing complete", the restriction instruction corresponding to the relation identifier is retrieved from the first instruction queue and the instruction following the restriction instruction is executed by the execution unit corresponding to the first instruction queue; the execution unit is used to process the instruction queue in the queue placement unit connected to the execution unit under the scheduling of the control unit; the control unit is also used to update the processing status of the first instruction queue to "processing complete" according to the relation identifier when the processing of the first instruction queue is completed; when the processing of multiple instruction queues is completed, the processing result of the task is obtained.

[0029] According to the third aspect, the control unit is specifically configured to: read all instructions in the instruction sequence for implementing the task one by one, and place the read instructions into a target instruction queue, wherein the target instruction queue is one of multiple instruction queues; when a restriction instruction is read, allocate first information to the restriction instruction according to the relation identifier corresponding to the restriction instruction; wherein the first information is used to indicate the execution order of the restriction instruction in the data dependency relationship indicated by the corresponding relation identifier; when the first instruction queue has been processed, allocate second information corresponding to the relation identifier to the first instruction queue, wherein the second information is used to indicate that the first instruction queue has been processed, and the second sequence information corresponding to the same relation identifier is allocated in the same way as the first information; read the first information and second information corresponding to the relation identifier according to the relation identifier corresponding to the restriction instruction at the head of the first instruction queue; when the read first information and read second information are the same, determine that the processing status of the second instruction queue that the first instruction queue depends on in the data dependency relationship indicated by the relation identifier is completed; when the read first information and read second information are different, determine that the processing status of the second instruction queue that the first instruction queue depends on in the data dependency relationship indicated by the relation identifier is not completed.

[0030] According to the third aspect, or any implementation of the third aspect above, the control unit is specifically configured to: upon reading a restriction instruction, determine first information for the relation identifier corresponding to the restriction instruction and allocate it to the restriction instruction; upon allocating first information for a relation identifier each time, update the first information corresponding to the relation identifier for the next allocation of first information for that relation identifier; upon completion of processing of the first instruction queue, allocate second information corresponding to the relation identifier to the first instruction queue, including: upon completion of processing of the first instruction queue, determine second information for the relation identifier corresponding to the first instruction queue and allocate it to the first instruction queue; upon allocating second information for a relation identifier each time, update the second information corresponding to the relation identifier for the next allocation of second information for that relation identifier.

[0031] According to the third aspect, or any implementation of the third aspect above, the control unit is further configured to: after retrieving the restriction instruction corresponding to the relation identifier from the first instruction queue, and in the case of retrieving the update instruction corresponding to the relation identifier from the first instruction queue, determine that the first instruction queue has completed processing; wherein the update instruction corresponding to the relation identifier is set at the tail of the queue used to implement the first instruction queue.

[0032] According to the third aspect, or any implementation thereof, the chip further includes a first counting unit and a second counting unit respectively connected to the control unit; the first counting unit is used to count according to a preset counting method under the control of the control unit to obtain a first counting result; the second counting unit is used to count according to a preset counting method under the control of the control unit to obtain a second counting result; the control unit is specifically used to: read the first counting result of the first counting unit for the relation identifier corresponding to the restriction instruction to obtain first information; when first information is allocated for a relation identifier each time, control the first counting unit to count based on the allocated first counting result to obtain updated first information corresponding to a relation identifier for the next allocation of first information for a relation identifier; read the second counting result of the second counting unit for the relation identifier corresponding to the first instruction queue to obtain second information; when second information is allocated for a relation identifier each time, control the second counting unit to count based on the allocated second counting result to obtain updated second information corresponding to a relation identifier for the next allocation of second information for that relation identifier.

[0033] The third aspect and any implementation thereof correspond to the first aspect and any implementation thereof, respectively. The technical effects of the third aspect and any implementation thereof are similar to those of the first aspect and any implementation thereof, and will not be repeated here.

[0034] Fourthly, embodiments of this application provide an electronic device, including: a processor and a transceiver; a memory for storing one or more programs; and when the one or more programs are executed by one or more processors, causing the one or more processors to implement the method as described in the first aspect and any implementation thereof.

[0035] Fifthly, embodiments of this application provide a computer-readable medium for storing a computer program, the computer program including instructions for performing the method in the first aspect or any possible implementation of the first aspect.

[0036] In a sixth aspect, embodiments of this application provide a computer program including instructions for performing the method in the first aspect or any possible implementation thereof. Attached Figure Description

[0037] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0038] Figure 1 This is an example diagram illustrating one possible task processing procedure;

[0039] Figure 2 This is a structural block diagram of a chip 200 provided in an embodiment of this application;

[0040] Figure 3 This is a structural block diagram of an electronic device 300 provided in an embodiment of this application;

[0041] Figure 4 This is a structural block diagram of a task processing system 400 provided in an embodiment of this application;

[0042] Figure 5 This is a flowchart illustrating a task processing method provided in an embodiment of this application;

[0043] Figure 6 This is an example diagram of task relationships and relationship identifiers in a task processing method provided in an embodiment of this application;

[0044] Figure 7 This is a timing example diagram of a task processing method provided in an embodiment of this application. Detailed Implementation

[0045] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0046] In this article, the term "and / or" is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.

[0047] The terms "first" and "second," etc., used in the specification and claims of this application are used to distinguish different objects, not to describe a specific order of objects. For example, "first target object" and "second target object," etc., are used to distinguish different target objects, not to describe a specific order of target objects.

[0048] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0049] In the description of the embodiments in this application, unless otherwise stated, "multiple" means two or more. For example, multiple processing units means two or more processing units; multiple systems means two or more systems.

[0050] A task processing device can break down a task into multiple subtasks, each executed by at least two execution units from a plurality of execution units to improve task processing efficiency. Tasks may include, for example, image recognition tasks, data retrieval tasks, video encoding tasks, etc. The task processing device may include a single chip, multiple communicatively connected chips, a single electronic device, or multiple communicatively connected electronic devices. Where an electronic device contains multiple execution units, for example, the chip in the electronic device may be an acceleration chip such as a GPU; or, the electronic device may contain multiple chips, with at least two execution units distributed across different chips. Multiple communicatively connected electronic devices may, for example, have at least two execution units contained within different electronic devices within multiple communicatively connected electronic devices.

[0051] For example, Figure 1 This is an example diagram illustrating a task processing procedure. For example... Figure 1 As shown, a task is broken down into multiple subtasks, and execution unit 1 and execution unit 2 execute a portion of these subtasks respectively. Specifically, execution unit 2 executes subtasks Execute0, Execute1, and Execute2; execution unit 1 executes subtasks Execute3 and Execute4. Subtask Execute3 has a data dependency on subtask Execute0, subtask Execute4 has a data dependency on subtask Execute1, and subtask Execute2 has a data dependency on subtask Execute3. Execution units 1 and Execution unit 2 perform asynchronous processing on each subtask to ensure that the data depended on by each subtask can be accessed normally, that is, to ensure that the execution timing of each subtask is correct. This asynchronous processing may include the following steps:

[0052] At time t1, after execution unit 2 finishes executing subtask execute0, it sends event trigger instruction set0 to execution unit 1. Execution unit 1 executes wait instruction wait0 to stall the instruction used to execute subtask execute3. After receiving instruction set0, execution unit 2 can start executing subtask execute3.

[0053] At time t2, after execution unit 2 finishes executing subtask execute1, it triggers a set1 event, that is, sends the event triggering instruction set1 to execution unit 1;

[0054] At time t3, after execution unit 1 finishes executing subtask excute3, it sends event trigger instruction set3 to execution unit 2. Execution unit 2 executes wait instruction wait3. Upon receiving instruction set3, it continues to execute subtask excute2.

[0055] At time t4, execution unit 1 executes the wait instruction wait1. If it receives the instruction set1, it can continue to execute the subtask execute4.

[0056] The above Figure 1 In the example, the dependent execution unit, i.e., the source, sets an event trigger instruction (such as `set`) to indicate task completion. The execution unit that depends on this source, i.e., the peer, sets a wait instruction (such as `wait`) to postpone the execution of the source's pending task instructions until it receives the event trigger instruction from the source. Only then can the peer's instructions proceed. In this way, the event trigger instruction indicating task completion from the source and the corresponding wait instruction for the peer's postponed execution instructions ensure that each execution unit with data dependencies executes its respective task at the correct timing.

[0057] However, in scenarios with complex task execution logic, there may be multiple scenarios regarding whether the source task or the peer task is executed. In such cases, ensuring the pairing of the `set` and `wait` instructions requires many judgment instructions to determine the execution status of each execution unit under different circumstances, which can easily burden the compiler.

[0058] For example, consider the following task execution scenario: Execution unit E0 executes the task instruction E0.instr0 to perform the task assigned to it when the condition indicated by the conditional statement cond1 is true; execution unit E1, which has data dependencies on execution unit E0, executes the task instruction E1.instr0 to perform the task assigned to it when the condition indicated by the conditional statement cond2 is true and the instruction E0.instr0 has been completed. The code to implement this task is shown in Table 1 below:

[0059]

[0060] As can be seen, in the complex scenario shown in Table 1 above, several conditional instructions have been added, such as instructions indicating that flag is true, and instructions indicating that flag is true and cond2 is false, to ensure that the event trigger instruction set and the wait instruction wait are paired. This results in a large number of conditional statements in task processing, which can easily burden the compiler and lead to low task processing efficiency.

[0061] To address the aforementioned problems, this application provides a task processing method. This method is applied to an electronic device containing multiple execution units, where at least two of the execution units process tasks that have data dependencies. In this method, the processing state of a task is updated based on different relationship identifiers used to indicate different data dependencies within the task. This allows the processing of another task that has a data dependency on the task to be performed directly based on the corresponding relationship identifier, without the need for numerous conditional statements. Furthermore, a restriction instruction is set at the head of the instruction queue used to implement the task. This ensures that if the task on which the task depends is not completed, the restriction instruction is not retrieved to postpone the execution of the task, thus guaranteeing accurate task execution timing without the need for paired trigger and wait instructions. Therefore, this solution achieves asynchronous task execution without the need for numerous conditional instructions and corresponding trigger and wait instructions, thereby reducing the compiler burden and improving task processing efficiency. Additionally, eliminating the need for numerous conditional statements and corresponding trigger and wait instructions ensures more concise code for implementing the task.

[0062] Before describing the technical solutions of the embodiments of this application, the electronic devices of the embodiments of this application will first be described with reference to the accompanying drawings. The embodiments of this application can be applied to electronic devices such as computers, mobile terminals, wearable devices, internet TVs, and servers. The chip of the aforementioned electronic device includes multiple execution units, and at least two of these execution units have data dependencies; that is, there are multiple asynchronous execution units within the same chip of the electronic device.

[0063] For example, Figure 2 This is a structural block diagram of a chip 200 provided in an embodiment of this application. For example... Figure 2 As shown, the chip 200 may include: a control unit 201, a first counting unit 202, a second counting unit 203, multiple instruction queue placement units (such as instruction queue placement unit 2040, instruction queue placement unit 2041, ... and instruction queue placement unit 204m, where m is the number of instruction queue placement units), and multiple execution units (such as execution unit 205E0, execution unit 205E1, ... and execution unit 205Em), wherein the multiple instruction queue placement units and the multiple execution units correspond one-to-one.

[0064] The control unit 201 is used to receive a sequence of instructions, which is the code for the same task, such as the code for an image recognition task. When the control unit 201 receives all instructions in the sequence sequentially, it can dispatch the received instructions to multiple instruction queues according to their type, so that the execution units corresponding to different instruction queues can execute the instructions in their respective queues. In other words, dispatching instructions from the sequence to multiple instruction queues effectively splits the same task into multiple instruction queues, each queue being a separate instruction queue.

[0065] Instruction queue placement units 2040 to 204m are respectively used to place the instruction queues corresponding to the respective execution units. For example, instruction queue placement unit 2040 is used to place instruction queue 0 corresponding to execution unit 205E0. In specific applications, the instruction queue placement unit may be hardware with storage function, such as a memory, and this application embodiment does not limit this.

[0066] Execution units 205E0 to 205Em are respectively used to execute instructions in the corresponding instruction queues.

[0067] The first counting unit 202 and the second counting unit 203 are respectively used to record the first second information and the second second information. The first second information is used to indicate whether the execution unit has completed the task processing status of the associated execution unit with data dependency. The second second information is used to indicate whether the execution unit has completed the task processing status.

[0068] The control unit 201 is also used to obtain first second information or second second information respectively through the restriction instructions and update instructions in each instruction queue, and then, if it is determined that the instruction queue meets the execution conditions based on the first second information or second second information, send the instructions in the instruction queue to the corresponding execution unit for processing.

[0069] For example, the above Figure 2 The chip 200 shown can be included in an electronic device. Figure 3 This is a structural block diagram of an electronic device 300 provided in an embodiment of this application. For example... Figure 3 As shown, the electronic device 300 may include some or all of the following components: processor 301, communication line 305, memory 303, storage medium 304, and at least one communication interface 302.

[0070] The processor 301 is used to execute the task processing method provided in subsequent embodiments of this application. The processor 301 may include the above-described... Figure 2 The chip shown is 200.

[0071] Communication line 305 is used to connect various components in electronic device 300. Specifically, communication line 305 may include data bus, power bus, control bus, and status signal bus, etc. However, for clarity, all buses are labeled as communication line 305 in the figure.

[0072] Memory 303 can be volatile memory or non-volatile memory, or it can include both. Memory 303 can exist independently and be connected to processor 301 via communication line 305. Memory 303 can also be integrated with processor 301. Memory 303 stores computer instructions. Processor 301 can implement the task processing methods provided in subsequent embodiments of this application by executing the computer instructions stored in memory 303. Optionally, the computer instructions in this embodiment can also be referred to as application code, and this embodiment does not specifically limit this.

[0073] Storage medium 304 is used to store computer instructions and various data for implementing the technical solutions of the embodiments of this application, so that when electronic device 300 executes the task processing method provided in subsequent embodiments of this application, it loads the computer instructions and various data stored in storage medium 304 into memory 303, so that processor 301 can implement the task processing method provided in the embodiments of this application by executing the computer instructions stored in memory 303.

[0074] Communication interface 302 uses any electronic device such as a transceiver to communicate with other devices or communication networks, such as Ethernet, radio access network (RAN), wireless local area network (WLAN), etc.

[0075] In one alternative implementation, the embodiments of this application can be applied to a task processing system. Figure 4 This is a structural block diagram of a task processing system 400 provided in an embodiment of this application. For example... Figure 4 As shown, the task processing system 400 includes:

[0076] The system comprises a main control chip 401 and multiple execution chips, such as execution chips 402, 403, ..., and 40m, where m is the total number of instruction queues. These instruction queues are queues of instructions derived from splitting instructions for the same task, i.e., instruction sequences. Each execution chip can contain one execution unit, which executes one instruction queue; that is, there are multiple execution units with data dependencies. For example, execution unit 402E in execution chip 402, execution unit 403E in execution chip 403, ..., and execution unit 40Me in execution chip 40m. In one optional example, an execution chip can contain at least one execution unit. In another example, there can be one execution chip, with multiple execution units contained within it.

[0077] The main control chip 401 includes: a control unit 4011, a first counting unit 4012, a second counting unit 4013, and multiple instruction queue placement units for placing multiple instruction queues, such as instruction queue placement unit 4020, instruction queue placement unit 4021, ... and instruction queue placement unit 402m.

[0078] In one example, the task processing system is contained in an electronic device, that is, the electronic device contains multiple chips, including a master control chip and at least one execution chip.

[0079] In another example, Figure 4 The task processing system shown can be a cluster containing multiple electronic devices, such as a computer cluster. The main control chip and the execution chip can be contained in different electronic devices in the cluster; different execution chips can be contained in the same or different electronic devices in the cluster.

[0080] Figure 4 The units shown are Figure 2 Units with the same name are similar, differing only in their labeling. For example, first counting unit 4012 and first counting unit 202 are similar, but their labeling differs. Similarities will not be elaborated further here; please refer to the above for details. Figure 2 Description of the embodiments.

[0081] It should be understood that the above Figure 2 The chip 200 shown Figure 3 The electronic devices shown are 300 and Figure 4 The task processing system 400 shown is merely an example, and the chip 200, electronic device 300, and task processing system 400 may have more or fewer components than shown in the figure, may combine two or more components, or may have different component configurations. Figures 2 to 4The various components shown can be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and / or application-specific integrated circuits.

[0082] The following is combined Figures 5 to 7 The task processing method provided in the embodiments of this application will be described by way of example.

[0083] For example, Figure 5 This is a flowchart illustrating a task processing method provided in an embodiment of this application. Figure 5 As shown, the task processing method provided in this application embodiment is applied to a control unit, which may be included in the above-mentioned... Figure 2 The chip shown Figure 3 The electronic devices shown, or Figure 4 In the task processing system shown, the task processing method may include, but is not limited to, the following steps:

[0084] S501 reads all instructions from the instruction sequence used to implement the task one by one and puts them into multiple instruction queues that correspond one-to-one with multiple execution units.

[0085] The instruction sequence used to perform the task may, for example, be code for performing the task (e.g., the instruction sequence for an image recognition task may include code for performing image recognition), and executing the instruction sequence is equivalent to processing the task. For example, the control unit may receive the instruction sequence for the task input by the user, or directly read the instruction sequence for the task pre-stored; this application embodiment does not impose any limitations on this.

[0086] For example, the instruction sequence, which is the code used to implement the task, is shown in Table 2 below:

[0087]

[0088] After acquiring the instruction sequence, the control unit can read all the instructions in the sequence one by one and place them into multiple instruction queues corresponding to multiple execution units. Instructions in the same instruction queue can be used to achieve the same function, and the order in which different instructions are placed can be determined according to the specific task logic; this embodiment does not impose such restrictions. At least two instruction queues have a data dependency relationship. For example, in a data retrieval task, there is a data dependency relationship between the retrieval condition parsing instruction queue and the data matching instruction queue. S501 above is equivalent to splitting the instruction sequence used to implement the task into multiple instruction queues corresponding to multiple execution units. Multiple execution units can then execute multiple instruction queues separately to process the task, thereby improving task processing efficiency.

[0089] In one alternative example, the control unit reads all instructions from the instruction sequence used to implement the task one by one and places them into multiple instruction queues corresponding to multiple execution units. Specifically, this may include:

[0090] The control unit reads all instructions in the instruction sequence used to implement the task one by one; according to the attribute information of the read instructions (such as the type of the instruction), the read instructions are placed into the target instruction queue, wherein the target instruction queue is one of multiple instruction queues corresponding one-to-one with multiple execution units; when a restrictive instruction is read, first information is allocated to the restrictive instruction according to the relation identifier contained in the restrictive instruction, wherein the restrictive instruction is placed at the head of the corresponding instruction queue, the relation identifier is used to indicate a data dependency relationship of the instruction queue in which the restrictive instruction corresponding to the relation identifier is located, and the first information is used to indicate the execution order of the restrictive instruction corresponding to the first information in the corresponding data dependency relationship.

[0091] For example, Figure 6 This is an example diagram illustrating task relationships and relationship identifiers in a task processing method provided in an embodiment of this application. For example... Figure 6 As shown, after the control unit reads all the instructions in the instruction sequence shown in Table 2, it can obtain the following instruction queues: instruction queue 1 corresponding to execution unit E0, which contains instruction instr1; instruction queue 2 corresponding to execution unit E1, which contains instructions instr2 and instr3; ... and instruction queue m corresponding to execution unit Em, which contains instruction instrm, where m is the number of instruction queues. The task relationships include: the execution of instruction instr2 depends on the execution result of instruction instr1, meaning instruction queue 1 and instruction queue 2 have a data dependency relationship; the execution of instruction instrm depends on the execution result of instruction instr3, meaning instruction queue 2 and instruction queue m have a data dependency relationship.

[0092] See also Figure 6The control unit reads the first instruction, get(E0, #1), from the instruction sequence shown in Table 2. Since get(E0, #1) is a restriction instruction, it is placed at the head of instruction queue 1. Furthermore, based on the relation identifier #1 contained in get(E0, #1), first information is allocated to this restriction instruction: get_cnt = 0. That is, in the data dependency relationship indicated by relation identifier #1, instruction queue 1 is executed first. Similarly, when the control unit reads a restriction instruction get(E1, #1) containing relation identifier #1, it places the restriction instruction get(E1, #1) at the head of instruction queue 2. Furthermore, based on the relation identifier #1 contained in get(E0, #1), first information is allocated to this restriction instruction: get_cnt = 1. That is, in the data dependency relationship indicated by relation identifier #1, instruction queue 2 is executed later, meaning instruction queue 2 depends on the data output by instruction queue 1.

[0093] In an alternative example, the control unit can be configured as described above. Figure 2 The first counting unit 202 or Figure 4 The first counting unit 4012 assigns first information to each restriction instruction. For example... Figure 6 As shown, the relation identifier ID can specifically include #0, #1, #2, ..., #n. The first calculation unit can be, for example, a first counter (get counter). Here, relation identifier #0 corresponds to the first count result get_counter#0; relation identifier #1 corresponds to the first count result get_counter#1; relation identifier #2 corresponds to the first count result get_counter#2; ..., relation identifier #m corresponds to the first count result get_counter#m. The control unit allocates first information to the restriction instruction using the first counter (get counter) to further improve efficiency and accuracy. Specifically, the control unit's allocation of first information using the first counter can include: the control unit reads the count result of the first counter, obtains the first count result, and allocates it to the currently read restriction instruction; wherein, after each allocation of first information, the control unit controls the first counter to count the first count result corresponding to the corresponding relation identifier to update the first information corresponding to that relation identifier, and then allocates the updated first information to the next restriction instruction corresponding to that relation identifier to realize the allocation of first information.

[0094] For example, the control unit can control the first counter by sending a trigger signal or a counting notification to the first counter. The first counter responds to this control by counting, for example, incrementing the value of the first information by 1. For instance, the first count result corresponding to a relation identifier is stored in the global variable `global get cnt` corresponding to that relation identifier. The control unit can control the first counter to count the relation identifier by executing the instruction `global get cnt++`. Based on this, the control unit reads the value of the global variable `global get cnt` and assigns it to the restriction variable `get_cnt` of the restriction instruction; that is, the first information = the value of `get_cnt` = the value of `global get cnt`. Furthermore, the initial value of the first count result corresponding to each relation identifier, which is the value of the first first information assigned to each relation identifier, can be 0. For example, when the control unit reads the restriction instruction `get(E0, #1)` from the instruction sequence, it reads the first count result `global get cnt` corresponding to relation identifier #1 from the first counter as 0, assigns it to the restriction variable `get_cnt` of the restriction instruction `get(E0, #1)`, that is, assigns the first information 0 to the restriction instruction `get(E0, #1)`. At this point, the control unit controls the first counter to perform `global get cnt++` on the first count result corresponding to relation identifier #1, resulting in an updated first count result `globalget cnt` of 1. Based on this, when the control unit reads the restriction instruction `get(E1, #1)`, it reads the first count result `global get cnt = 1` and assigns it to the restriction variable `get_cnt` of the restriction instruction `get(E1, #1)`, thus allocating the first information 1 to the restriction instruction `get(E1, #1)`. Similarly, the control unit allocates the first information 0 corresponding to relation identifier #2 to the restriction instruction `get(E1, #2)`, and allocates the first information 1 corresponding to relation identifier #2 to the restriction instruction `get(Em, #2)`. By assigning the first information to the restriction variable, it ensures a direct correspondence between the restriction instruction and the first information. Subsequently, in S502, when determining the processing status of the second instruction queue corresponding to each relation identifier, the corresponding restriction variable can be read directly, which is more efficient.

[0095] A data dependency for each instruction queue can include the execution of that instruction queue depending on the data output by another instruction queue. This dependency can include: the instruction queue can only execute after reading the data output by the other instruction queue (i.e., a read dependency), or the instruction queue can only execute after the data output by the other instruction queue is written (i.e., a write dependency). For example, referring to Table 2 above, if instruction queue 2 has a data dependency on instruction queue 1, then the data dependency of instruction queue 2 can include the data dependency between instruction queue 2 and instruction queue 1, indicated by relation identifier #1; correspondingly, the data dependency of instruction queue 1 can include the data dependency between instruction queue 2 and instruction queue 1, also indicated by relation identifier #1.

[0096] Each instruction queue can have one or more data dependencies. For example, in Table 2 above, instruction queue 2 has two data dependencies: the first is between instruction queue 2 and instruction queue 1, indicated by relation identifier #1; the second is between instruction queue 2 and instruction queue m, indicated by relation identifier #2. In other words, two instruction queues with the same data dependency can use the same relation identifier to indicate that dependency, which is more concise and accurate.

[0097] It is understandable that the instructions contained in each of the above instruction queues are only examples. In specific applications, the specific instructions in the instruction queues can be set according to the application requirements.

[0098] S502, based on the relation identifier corresponding to the restriction instruction at the head of the first instruction queue, determine the processing status of the second instruction queue that the first instruction queue depends on in the data dependency relationship indicated by the relation identifier, and if the processing status is completed, retrieve the restriction instruction corresponding to the relation identifier from the first instruction queue and execute the instructions following the restriction instruction through the execution unit corresponding to the instruction queue, wherein the first instruction queue is any one of multiple instruction queues, and the second instruction queue is one of multiple instruction queues.

[0099] After reading all instructions from the instruction sequence used to implement the task and placing them into multiple instruction queues corresponding one-to-one with multiple execution units, the control unit can process the multiple instruction queues to complete the task processing. Thus, any one of the multiple instruction queues is the first instruction queue, and each instruction queue is processed according to the method described in S502 above. The second instruction queue is the instruction queue among the multiple instruction queues that has a data dependency relationship with the first instruction queue, and this data dependency relationship is the data dependency relationship indicated by the relation identifier corresponding to the first instruction queue.

[0100] by Figure 6 Taking the instruction queues shown as an example, if the first instruction queue is instruction queue 1, then the second instruction queue is empty. This means that the execution of instruction queue 1 does not depend on the other instruction queue, which is equivalent to the processing status of the second instruction queue corresponding to instruction queue 1 always being "processed." If the first instruction queue is instruction queue 2, then the second instruction queue is instruction queue 1. If instruction queue m is the first instruction queue, then the second instruction queue is instruction queue 2.

[0101] To facilitate understanding and reasonable layout, the following describes, in conjunction with S503, the specific method by which the control unit determines the processing status of the second instruction queue that the first instruction queue depends on in the data dependency relationship indicated by the relation identifier corresponding to the restriction instruction at the head of the first instruction queue.

[0102] S503, if the processing of the first instruction queue is completed, update the processing status of the first instruction queue to complete processing according to the relationship identifier corresponding to the restriction instruction at the head of the first instruction queue.

[0103] The control unit retrieves the restriction instruction corresponding to the relation identifier from the first instruction queue and executes the instructions following the restriction instruction through the execution unit corresponding to the first instruction queue, which is equivalent to processing the first instruction queue. Based on this, the control unit can update the processing status of the first instruction queue to "processing complete" according to the relation identifier after the processing of the first instruction queue is completed. In this way, after the processing of the instruction queue in the data dependency relationship indicated by each relation identifier is completed, the processing status of that instruction queue is updated, ensuring that when the control unit processes the first instruction queue in the data dependency relationship indicated by the relation identifier according to S502, it can accurately determine the processing status of the second instruction queue based on the relation identifier, thereby ensuring the accurate execution timing of the first instruction queue.

[0104] In one optional implementation, the control unit determines the processing status of the second instruction queue that the first instruction queue depends on in the data dependency relationship indicated by the relation identifier corresponding to the restriction instruction at the head of the first instruction queue. This may include: the control unit searching for the processing status of the second instruction queue that the first instruction queue depends on in the data dependency relationship indicated by the relation identifier from the correspondence between the relation identifier and the processing status, based on the relation identifier corresponding to the restriction instruction at the head of the first instruction queue.

[0105] Accordingly, when the first instruction queue is completed, the control unit updates the processing status of the first instruction queue to complete processing according to the relation identifier corresponding to the restriction instruction at the head of the first instruction queue. This may include: when the first instruction queue is completed, the control unit searches for the processing status of the first instruction queue in the correspondence between the relation identifier and the processing status and updates it to complete processing according to the relation identifier corresponding to the restriction instruction at the head of the first instruction queue.

[0106] For example, the control unit pre-establishes a mapping between relation identifiers and processing states to record and update the processing state of the first instruction queue in the data dependency relationship indicated by each relation identifier. Thus, by looking up the mapping through the relation identifier, the processing state of the second instruction queue in the data dependency relationship indicated by that relation identifier can be determined. It is understood that in the initial state, that is, before task processing begins, the processing state of the second instruction queue in the data dependency relationship indicated by each relation identifier is incomplete.

[0107] In another optional implementation, when the control unit allocates first information to the restriction instructions in each instruction queue, and the control unit updates the processing status of the first instruction queue to complete processing according to the relationship identifier corresponding to the restriction instruction at the head of the first instruction queue when the first instruction queue has been processed, it may include: when the first instruction queue has been processed, the control unit allocates second information to the first instruction queue corresponding to the restriction instruction at the head of the first instruction queue, wherein the second information is used to indicate that the corresponding instruction queue has been processed.

[0108] In one example, the second sequence information corresponding to the same relation identifier is allocated in the same way as the first information. Accordingly, the control unit determines the processing status of the second instruction queue that the first instruction queue depends on in the data dependency relationship indicated by the relation identifier based on the relation identifier corresponding to the restriction instruction at the head of the first instruction queue. This can include:

[0109] The control unit reads the first information and the second information corresponding to the relation identifier corresponding to the restriction instruction at the head of the first instruction queue. If the first information and the second information are the same, the control unit determines that the processing status of the second instruction queue that the first instruction queue depends on in the data dependency relationship indicated by the relation identifier is completed. If the first information and the second information are different, the control unit determines that the processing status of the second instruction queue that the first instruction queue depends on in the data dependency relationship indicated by the relation identifier is incomplete.

[0110] It is understandable that when the control unit is not processing a task, the first and second information corresponding to each relation identifier are the same, for example, both can be "0", "false", or "fake". That is, the initial values ​​of the first and second information corresponding to each relation identifier are the same. This ensures that when the instruction queue that is depended upon in the data dependency relationship is processed according to S502 above, the instruction queue can be executed normally.

[0111] In an alternative example, similar to the allocation of the first information, the control unit can be configured as described above. Figure 2 The second counting unit 203 or Figure 4 The second counting unit 4013 allocates the second information. For example, as shown... Figure 6 As shown, the second counting unit can be, for example, a second counter, rel counter. Here, relation identifier #0 corresponds to second information rel_counter#0; relation identifier #1 corresponds to second information rel_counter#1; relation identifier #2 corresponds to first information rel_counter#2; ..., relation identifier #m corresponds to first information rel_counter#m. Specifically, the control unit's allocation of second information via the second counter may include: the control unit reading the counting result of the second counter, obtaining the second counting result, and allocating it to the currently processed first instruction queue; wherein, each time the control unit determines that the first instruction queue has been processed, it controls the second counter to count the second counting result corresponding to the corresponding relation identifier to update the second information corresponding to that relation identifier, and then allocates the updated second information to the currently processed first instruction queue corresponding to that relation identifier to achieve the allocation of the second information. Furthermore, the control unit controls the second counter in the same way as it controls the first counter; please refer to the description of the control method for the first counter in S501 above, which will not be repeated here.

[0112] For example, the second count result corresponding to the relation identifier is stored in the global variable `global relcnt` corresponding to that relation identifier. The control unit can control the first counter to count the relation identifier by executing the instruction "global relcnt++". Based on this, the control unit reads the value of the global variable `global relcnt` to obtain the second information. In addition, the initial value of the second count result corresponding to each relation identifier, that is, the value of the first piece of second information assigned to each relation identifier, can be 0.

[0113] by Figure 6For example, when the control unit starts processing instruction queue 1, it reads the second count result global relcnt corresponding to relation identifier #1 as 0 (i.e., the initial value). At this time, the first information of the restriction instruction get(E0, #1) in instruction queue 1 is 0, and the first information and the second information are the same, so the control unit can retrieve the restriction instruction get(E0, #1). When instruction queue 1 is completed, the control unit controls the second counter to count: it performs global relcnt++ on the second count result corresponding to relation identifier #1, resulting in an updated second count result global relcnt of 1. Based on this, when the control unit processes the restriction instruction get(E1, #1), it reads the first information of the restriction instruction get(E1, #1) as 1, which is the same as the second information corresponding to relation identifier #1, so the control unit can retrieve the restriction instruction get(E1, #1). Similarly, when instruction queue 2 is completed, the second information corresponding to relation identifier #1 is 2, and the second information corresponding to relation identifier #2 is 1.

[0114] Furthermore, taking instruction queue 2 and instruction queue 1 in Table 2 as examples, the control unit executes the instructions following the restriction instruction get(E0, #1) through execution unit E0: instruction E0.instr1 and instruction rel(E0, #1). That is, the control unit retrieves the instructions following get(E0, #1) from instruction queue 1 and assigns them to execution unit E0 for execution. After execution unit E0 completes its execution, meaning instruction queue 1 has finished processing, the control unit updates the second information corresponding to relation identifier #1, global rel_cnt.

[0115] In one optional implementation, the control unit may determine that the first instruction queue has completed processing if the update instruction corresponding to the relation identifier is retrieved from the tail of the first instruction queue when the execution unit corresponding to the first instruction queue executes the instruction following the restriction instruction corresponding to the relation identifier.

[0116] For example, see still Figure 6In instruction queue 1, the relation identifier #1 corresponds to the restriction instruction get(E0, #1) and the update instruction rel(E0, #1). The restriction instruction get(E0, #1) is located at the head of instruction queue 1, that is, before and adjacent to instruction instr1. The update instruction rel(E0, #1) is located at the tail of instruction queue 1, that is, after and adjacent to instruction instr1. Similarly, in instruction queue 2, the relation identifier #1 corresponds to the restriction instruction get(E1, #1) at the head of instruction queue 2 and the update instruction rel(E1, #1) at the tail of instruction queue 2. The relation identifier #2 of instruction queue 2 corresponds to the restriction instruction get(E1, #2) at the head of instruction queue 2 and the update instruction rel(E1, #2) at the tail of instruction queue 2. The relation identifier #2 of instruction queue m corresponds to the restriction instruction get(Em, #2) at the head of instruction queue m and the update instruction rel(Em, #2) at the tail of instruction queue m.

[0117] Thus, retrieving an update instruction signifies that the instructions in the corresponding instruction queue used to implement the task have been executed, and the processing status of that instruction queue is "processed." Therefore, this embodiment of the application, by setting an update instruction at the tail of the instruction queue, can determine that the instruction queue containing the update instruction has been processed as soon as it is retrieved, thereby further improving task processing efficiency.

[0118] In one example, restriction and update instructions can be independent of the task's logic. Retrieving a restriction or update instruction from the task's instruction queue is equivalent to "popping" the instruction from the stack; after retrieval, neither instruction needs to be executed. In other words, placing the restriction instruction at the head of the instruction queue allows the first-in, first-out (FIFO) mechanism to control the execution timing of instructions used to implement the task, eliminating the need for dedicated logic to control the retrieval of subsequent instructions. Similarly, placing the update instruction at the tail of the instruction queue ensures that its retrieval indicates the completion of all preceding instructions, meaning the task represented by the instruction queue containing the update instruction is complete, without requiring dedicated logic to determine task completion. This makes task processing more efficient.

[0119] In this embodiment of the application, by setting an update instruction at the tail of the instruction queue, it can be ensured that when the update instruction is retrieved, it means that the instructions before the update instruction have been processed, thereby automatically determining that the processing status of the instruction queue is completed, which is more efficient.

[0120] In one optional implementation, the second piece of information can be included in the update instruction. This eliminates the need to establish a correspondence between the relationship identifier and the update instruction, making it more convenient and efficient.

[0121] In one example, the first and second information corresponding to each relation identifier can both be global variables to ensure accurate synchronization of instruction execution status between different instruction queues in the same data dependency relationship.

[0122] For ease of understanding, the following is a combination of Table 3 and... Figure 7 The task processing method provided in the embodiments of this application will be integrated and described in detail. For example, the instruction sequence, i.e., the code used to implement the task, is shown in Table 3 below:

[0123]

[0124] The data dependencies between the instruction queues corresponding to different execution units in Table 3 above are as follows:

[0125] There is a data dependency between instruction instr0 of instruction queue 0 corresponding to execution unit E0 and instruction instr1 of instruction queue 1 corresponding to execution unit E1. This dependency is indicated by the same relation identifier #0 in the restriction instructions get(E0,#0) and rel(E0,#0). The task logic shown in Table 3 above is configured to execute the task 100 times in a loop. Within a loop, instruction instr1 of instruction queue 1 has a data read dependency on instruction instr0 of instruction queue 0; instruction instr0 of instruction queue 0 can only be executed after instruction instr0 of instruction queue 1 has finished executing. There is a data write dependency between instruction instr1 of instruction queue 1 in the current loop and instruction instr0 of instruction queue 0 in the next loop; instruction instr0 of instruction queue 0 in the next loop can only be executed after instruction instr1 of instruction queue 1 in the current loop has finished executing.

[0126] Similarly, in Table 3 above, there is a data dependency between instruction instr1 of instruction queue 1 corresponding to execution unit E1 and instruction instr2 of instruction queue 2 corresponding to execution unit E2. This dependency is indicated by the relation identifier #1 in the restriction instruction get(E1,#1) and update instruction rel(E1,#1). Within a loop, instruction instr2 of instruction queue 2 has a data read dependency on instruction instr1 of instruction queue 1; instruction instr2 of instruction queue 2 can only be executed after instruction instr1 of instruction queue 1 has been executed. There is a data write dependency between instruction instr2 of instruction queue 2 in the current loop and instruction instr1 of instruction queue 1 in the next loop; instruction instr2 of instruction queue 2 in the current loop can only be executed after instruction instr1 of instruction queue 1 in the next loop has been executed.

[0127] It is understandable that the instruction "For i=0:100" in Table 3 above, which executes the task 100 times in a loop, is only an example. The specific logic of the task in the application can be set according to specific needs.

[0128] Figure 7 This is a timing example diagram of a task processing method provided in an embodiment of this application. For example... Figure 7 As shown in Table 3 above, instruction queue 1 corresponding to execution unit E0 and instruction queue 2 corresponding to execution unit E1 have a data dependency relationship indicated by relation identifier #0; instruction queue 2 corresponding to execution unit E1 and instruction queue 3 corresponding to execution unit E2 have a data dependency relationship indicated by relation identifier #1. The initial values ​​of the first information global get cnt and the second information global relcnt are both 0. Based on the above, the control unit can process the tasks shown in Table 3 through the following process:

[0129] The control unit reads the instructions in the instruction sequence shown in Table 3 one by one and puts them into the instruction queue corresponding to each instruction. Within each loop, the control unit allocates first information to different restriction instructions corresponding to different relational identifiers through the first counting unit. Taking three loops as an example:

[0130] In the first loop, for relation identifier #0, first information 0 is allocated to the restriction instruction get(E0,#0), and first information 1 is allocated to the restriction instruction get(E1,#0); for relation identifier #1, first information 0 is allocated to the restriction instruction get(E1,#1), and first information 1 is allocated to the restriction instruction get(E2,#1).

[0131] In the second loop, for relation identifier #0, first information 2 is allocated to the restriction instruction get(E0,#0), and first information 3 is allocated to the restriction instruction get(E1,#0); for relation identifier #1, first information 2 is allocated to the restriction instruction get(E1,#1), and first information 3 is allocated to the restriction instruction get(E2,#1).

[0132] In the third loop, for relation identifier #0, first information 4 is allocated to the restriction instruction get(E0,#0), and first information 5 is allocated to the restriction instruction get(E1,#0); for relation identifier #1, first information 4 is allocated to the restriction instruction get(E1,#1), and first information 5 is allocated to the restriction instruction get(E2,#1).

[0133] In other words, by controlling the first counting unit to execute "global getcnt++" for each relation identifier, the control unit can accurately allocate the first information for the restriction instruction, and can still ensure the accuracy of the first information even when the task is executed in a loop.

[0134] At time t0, the control unit reads the first instruction queue, which is instruction queue 0 corresponding to execution unit E0. This queue contains the constraint variable get_cnt=global get cnt=0 corresponding to the constraint instruction get(E0,#0) with relation identifier #0, and the second information global relcnt=0 corresponding to relation identifier #0. The first and second information are identical. Based on this, the control unit can retrieve the constraint instruction get(E0,#0) from instruction queue 0. After retrieving the constraint instruction get(E0,#0), the execution unit E0 can execute the instruction instr0 (loop=0, i.e., the first loop) of instruction queue 0. It can be understood that in the first loop, instruction queue 0 can be executed without depending on data from another queue. That is, at this time, the second instruction queue that instruction queue 0 depends on in the data dependency relationship indicated by relation identifier #0 is empty, equivalent to the processing status of the second instruction queue being completed, meaning the second information and the first information are both 0.

[0135] At time t1, instruction instr0 (loop=0) in instruction queue 0 corresponding to execution unit E0 is completed. Correspondingly, the control unit can retrieve the update instruction rel(E0,#0) from the tail of instruction queue 0 and allocate the second information corresponding to relation identifier #0 to instruction queue 0, i.e., global relcnt++, meaning the value of the second information global relcnt corresponding to relation identifier #0 is 1. At this time, the control unit reads the restriction variable get cnt=1 from instruction queue 1 corresponding to execution unit E1, which is the same as the value of the second information global relcnt corresponding to relation identifier #0. This confirms that the processing status of the second instruction queue corresponding to instruction queue 1, i.e., instruction queue 0, is complete, and the control unit can retrieve the restriction instruction get(E1,#0) from instruction queue 1.

[0136] At time t2, the control unit reads the constraint variable get cnt=0 for the constraint instruction get(E1,#1) in the first instruction queue, which is the instruction queue 1 corresponding to execution unit E1, and the second information globalrelcnt=0 corresponding to relation identifier #1. This means the first and second information corresponding to relation identifier #1 are the same, both with an initial value of 0. Therefore, the constraint instruction get(E1,#1) can be retrieved. After retrieving the constraint instruction get(E1,#1), the two constraint instructions get(E1,#0) and get(E1,#1) preceding instruction E1.instr1 in instruction queue 1 are retrieved. The control unit can then retrieve instruction E1.instr1 and execute instruction E1.instr1 through execution unit E1.

[0137] At time t3, the control unit retrieves the update instruction rel(E1,#0) from the tail of instruction queue 1 corresponding to execution unit E1, and allocates the second information corresponding to relation identifier #0 to instruction queue 1: controls the second counting unit to perform global relcnt++ on the second information corresponding to relation identifier #0, that is, updates the global relcnt of the second information corresponding to relation identifier #0 to 2.

[0138] At time t3, the restriction variable get_cnt of the restriction instruction get(E0,#0) in instruction queue 0 corresponding to execution unit E0 is 2, meaning the first information corresponding to relation identifier #0 is 2. The control unit determines that the first information corresponding to relation identifier #0 of get(E0,#0) is the same as the second information global relcnt=2, and thus retrieves the restriction instruction get(E0,#0) to enter the second loop. In this loop, the instruction instr0 in instruction queue 0 is executed (Loop=1, i.e., the second loop). The specific execution method is similar to the first loop, the difference being the adaptive update of the second information.

[0139] At time t4, the control unit retrieves the update instruction rel(E1,#1) from instruction queue 1 corresponding to execution unit E1, and allocates the second information corresponding to relation identifier #1 to instruction queue 1: the control unit increments the global relcnt of the second information corresponding to relation identifier #1, that is, updates the global relcnt of relation identifier #1 to 1. The control unit reads the restriction variable get_cnt=global getcnt=1 of the restriction instruction get(E2,#1) in instruction queue 2 corresponding to execution unit E2, which is the same as the global relcnt of relation identifier #1, and can retrieve the restriction instruction get(E2,#1). Thus, the control unit executes the instruction instr2 (loop=0, i.e., the first loop) after the restriction instruction get(E2,#1) through execution unit E2.

[0140] At time t5, after the control unit completes the processing of instruction queue 0 in the second loop through execution unit E0, it allocates the second information corresponding to relation identifier #0, namely global relcnt++=3, to instruction queue 0. At this time, the control unit can read the restriction variable get_cnt=global get cnt=3 from the restriction instruction get(E1,#0) of execution unit E1, as well as the second information corresponding to relation identifier #0, global relcnt=3 and get_cnt=global relcnt. Since the first and second information corresponding to relation identifier #0 are the same, the control unit can retrieve the restriction instruction get(E1,#0) to enter the second loop.

[0141] At time t6, after the control unit executes the instruction instr2 following the restriction instruction get(E2,#1) in instruction queue 2 via execution unit E2, it can retrieve the update instruction rel(E2,#1) from instruction queue 2 corresponding to execution unit E2 and allocate the second information corresponding to relation identifier #1 to instruction queue 2, which is to execute global relcnt++=2. At this time, the control unit has already retrieved the restriction instruction get(E1,#0) from the second loop at time t5. Therefore, the control unit can read the restriction variable get_cnt=global get cnt=2 of the restriction instruction get(E1,#1) in instruction queue 1 corresponding to execution unit E1, which is the same as the second information. Therefore, the control unit retrieves the restriction instruction get(E1,#1) to enter the second loop. In this loop, the control unit executes the instruction instr1 in instruction queue 1 via execution unit E1 (Loop=1, i.e., the second loop).

[0142] The control unit executes the above steps sequentially until the cycle is repeated 100 times.

[0143] S504: After all instruction queues have been processed, the task processing result is obtained.

[0144] The control unit processes each of the multiple instruction queues according to steps S501 to S503 described above. Once all instruction queues have been processed, the task processing result is obtained. For example, for the task shown in Table 3 above, the control unit processes three instruction queues (equivalent to three sub-tasks) according to steps S501 to S503, and executes the process 100 times according to the instructions in the task. After all three instruction queues are processed, the task processing result shown in Table 3 is obtained.

[0145] It is understood that the specific tasks, instructions and code in the embodiments of this application are examples and do not constitute a limitation on the specific form of tasks, instructions and code in the task processing method provided in the embodiments of this application.

[0146] In this embodiment, the processing status of a task is updated based on different relation identifiers used to indicate different data dependencies within the task. This allows the processing of another task that has a data dependency on this task to be performed directly based on the corresponding relation identifier, without the need for numerous conditional statements. Furthermore, a constraint instruction is set at the head of the instruction queue used to implement the task. This ensures that if the task on which the task depends is not completed, the constraint instruction is not retrieved to postpone the execution of the task, thus guaranteeing accurate task execution timing without the need for paired trigger and wait instructions. Therefore, this solution achieves asynchronous task execution without the need for numerous conditional statements and corresponding trigger and wait instructions, thereby reducing the compiler burden and improving task processing efficiency. Additionally, eliminating the need for numerous conditional statements and corresponding trigger and wait instructions ensures that the code used to implement the task is more concise.

[0147] This embodiment also provides a computer storage medium storing computer instructions. When the computer instructions are executed on an electronic device, the electronic device performs the aforementioned method steps to implement the task processing method described above.

[0148] This embodiment also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned steps to implement the task processing method described in the above embodiment.

[0149] In this embodiment, the electronic device, computer storage medium, computer program product or chip are all used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can be referred to the beneficial effects of the corresponding method provided above, and will not be repeated here.

[0150] Any content in the various embodiments of this application, as well as any content in the same embodiment, can be freely combined. Any combination of the above content is within the scope of this application.

[0151] Those skilled in the art will recognize that the functions described in the embodiments of this application in one or more of the above examples can be implemented using hardware, software, firmware, or any combination thereof. When implemented using software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or code on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein communication media include any medium that facilitates the transfer of a computer program from one place to another. Storage media can be any available medium that can be accessed by a general-purpose or special-purpose computer.

[0152] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

Claims

1. A task processing method, characterized in that, The method includes: Read all instructions from the instruction sequence used to implement the task and place them into multiple instruction queues that correspond one-to-one with multiple execution units; Based on the relation identifier corresponding to the restriction instruction at the head of the first instruction queue, determine the processing status of the second instruction queue that the first instruction queue depends on in the data dependency relationship indicated by the relation identifier; wherein, the first instruction queue is any one of multiple instruction queues, and the second instruction queue is one of multiple instruction queues; When the processing status is "processing complete", the restriction instruction corresponding to the relationship identifier is retrieved from the first instruction queue and the instruction following the restriction instruction is executed by the execution unit corresponding to the first instruction queue. If the processing of the first instruction queue is completed, the processing status of the first instruction queue is updated to complete processing according to the relationship identifier; When the processing status is incomplete, the restriction instruction corresponding to the relationship identifier is retained in the first instruction queue, so as to prevent the execution of instructions after the restriction instruction when the processing is incomplete through the first-in-first-out mechanism of the queue; Once all the instruction queues have been processed, the processing result of the task is obtained.

2. The method according to claim 1, characterized in that, The data dependencies include: When the execution of the first instruction queue depends on the data output by the second instruction queue among the plurality of instruction queues, the data dependency relationship exists between the first instruction queue and the second instruction queue.

3. The method according to claim 1 or 2, characterized in that, The step of reading all instructions from the instruction sequence used to implement the task and placing them into multiple instruction queues corresponding one-to-one with multiple execution units includes: Read all instructions in the instruction sequence used to implement the task one by one, and put the read instructions into the target instruction queue, wherein the target instruction queue is one of the plurality of instruction queues; Upon reading a restriction instruction, first information is allocated to the restriction instruction based on the relation identifier corresponding to the restriction instruction; wherein, the first information is used to indicate the execution order of the restriction instruction in the data dependency relationship indicated by the corresponding relation identifier; The step of updating the processing status of the first instruction queue to "processing completed" according to the relationship identifier when the first instruction queue has been processed includes: When the first instruction queue has been processed, second information corresponding to the relationship identifier is allocated to the first instruction queue. The second information is used to indicate that the first instruction queue has completed processing. The second sequence information corresponding to the same relationship identifier is allocated in the same way as the first information. The step of determining the processing status of the second instruction queue that the first instruction queue depends on in the data dependency relationship indicated by the relation identifier corresponding to the restriction instruction at the head of the first instruction queue includes: Based on the relationship identifier corresponding to the restriction instruction at the head of the first instruction queue, read the first information and the second information corresponding to the relationship identifier; If the first information and the second information read are the same, determine that the processing status of the second instruction queue, which the first instruction queue depends on in the data dependency relationship indicated by the relation identifier, is completed. If the first information and the second information read are different, the processing status of the second instruction queue that the first instruction queue depends on in the data dependency relationship indicated by the relation identifier is determined to be incomplete processing.

4. The method according to claim 3, characterized in that, Upon reading a restriction instruction, the first information is allocated to the restriction instruction based on the relationship identifier corresponding to the restriction instruction, including: Upon reading a restriction instruction, first information is determined based on the relationship identifier corresponding to the restriction instruction and assigned to the restriction instruction; Each time first information is allocated for a relation identifier, the first information corresponding to the relation identifier is updated for the next allocation of first information for the relation identifier. Upon completion of processing of the first instruction queue, second information corresponding to the relationship identifier is allocated to the first instruction queue, including: Once the first instruction queue has been processed, second information is determined for the relation identifier corresponding to the first instruction queue and assigned to the first instruction queue. Each time second information is allocated for a relation identifier, the second information corresponding to the relation identifier is updated for the next allocation of second information for the relation identifier.

5. The method according to claim 1, 2 or 4, characterized in that, After retrieving the restriction instruction corresponding to the relation identifier from the first instruction queue, the method further includes: If the update instruction corresponding to the relation identifier is retrieved from the first instruction queue, it is determined that the first instruction queue has completed processing; wherein the update instruction corresponding to the relation identifier is located at the tail of the first instruction queue.

6. The method according to claim 4, characterized in that, The determination of the first information based on the relationship identifier corresponding to the restriction instruction includes: Based on the relation identifier corresponding to the restriction instruction, the first counting result of the first counting unit is read to obtain the first information; The step of updating the first information corresponding to a relationship identifier each time first information has been allocated for that relationship identifier, so as to be used for the next allocation of first information for that relationship identifier, includes: Each time first information is allocated for a relation identifier, the first counting unit is controlled to count based on the allocated first counting result to obtain the updated first information corresponding to the relation identifier for the next allocation of first information for the relation identifier. When the first instruction queue has been processed, determining the second information and allocating it to the first instruction queue based on the relationship identifier corresponding to the first instruction queue includes: Based on the relation identifier corresponding to the first instruction queue, the second counting result of the second counting unit is read to obtain the second information; The step of updating the second information corresponding to a relationship identifier each time second information is allocated for that relationship identifier, so as to be used for the next allocation of second information for that relationship identifier, includes: Each time second information is allocated for a relation identifier, the second counting unit is controlled to count based on the allocated second counting result to obtain the updated second information corresponding to the relation identifier for the next allocation of second information for the relation identifier.

7. A chip, characterized in that, The chip includes: a control unit, multiple execution units, and multiple queue placement units connected to each of the multiple execution units; the multiple queue placement units are respectively connected to the control unit. The control unit is used to read all instructions in the instruction sequence for implementing the task and put them into multiple instruction queues, wherein the multiple instruction queues are placed one by one in the multiple queue placement units; The queue placement unit is used to place the instruction queue corresponding to the connected execution unit; The control unit is further configured to determine the processing status of the second instruction queue that the first instruction queue depends on in the data dependency relationship indicated by the relation identifier, based on the relation identifier corresponding to the restriction instruction at the head of the first instruction queue; wherein the first instruction queue is any one of a plurality of instruction queues, and the second instruction queue is one of a plurality of instruction queues; when the processing status is completed, the restriction instruction corresponding to the relation identifier is retrieved from the first instruction queue to execute the instruction following the restriction instruction through the execution unit corresponding to the first instruction queue; when the processing status is incomplete, the restriction instruction corresponding to the relation identifier is retained in the first instruction queue to prevent the execution of the instruction following the restriction instruction when the processing is incomplete; when the processing status is incomplete, the restriction instruction corresponding to the relation identifier is retained in the first instruction queue to prevent the execution of the instruction following the restriction instruction when the processing is incomplete. The execution unit is configured to process the instruction queue in the queue placement unit to which the execution unit is connected, under the scheduling of the control unit. The control unit is further configured to, when the first instruction queue has been processed, update the processing status of the first instruction queue to "processing completed" according to the relationship identifier; and when all the instruction queues have been processed, obtain the processing result of the task.

8. The chip according to claim 7, characterized in that, The control unit is specifically used for: Read all instructions in the instruction sequence used to implement the task one by one, and put the read instructions into the target instruction queue, wherein the target instruction queue is one of the plurality of instruction queues; Upon reading a restriction instruction, first information is allocated to the restriction instruction based on the relation identifier corresponding to the restriction instruction; wherein, the first information is used to indicate the execution order of the restriction instruction in the data dependency relationship indicated by the corresponding relation identifier; When the first instruction queue has been processed, second information corresponding to the relationship identifier is allocated to the first instruction queue. The second information is used to indicate that the first instruction queue has completed processing. The second sequence information corresponding to the same relationship identifier is allocated in the same way as the first information. Based on the relationship identifier corresponding to the restriction instruction at the head of the first instruction queue, read the first information and the second information corresponding to the relationship identifier; If the first information and the second information read are the same, determine that the processing status of the second instruction queue, which the first instruction queue depends on in the data dependency relationship indicated by the relation identifier, is completed. If the first information and the second information read are different, the processing status of the second instruction queue that the first instruction queue depends on in the data dependency relationship indicated by the relation identifier is determined to be incomplete processing.

9. The chip according to claim 8, characterized in that, The control unit is specifically used for: Upon reading a restriction instruction, first information is determined based on the relationship identifier corresponding to the restriction instruction and assigned to the restriction instruction; Each time first information is allocated for a relation identifier, the first information corresponding to the relation identifier is updated for the next allocation of first information for the relation identifier. Upon completion of processing of the first instruction queue, second information corresponding to the relationship identifier is allocated to the first instruction queue, including: Once the first instruction queue has been processed, second information is determined for the relation identifier corresponding to the first instruction queue and assigned to the first instruction queue. Each time second information is allocated for a relation identifier, the second information corresponding to the relation identifier is updated for the next allocation of second information for the relation identifier.

10. The chip according to any one of claims 7-9, characterized in that, The control unit is also used for: After retrieving the restriction instruction corresponding to the relationship identifier from the first instruction queue, and then retrieving the update instruction corresponding to the relationship identifier from the first instruction queue, it is determined that the first instruction queue has completed processing; wherein, the update instruction corresponding to the relationship identifier is located at the tail of the first instruction queue.

11. The chip according to claim 8, characterized in that, The chip also includes a first counting unit and a second counting unit that are respectively connected to the control unit; The first counting unit is used to count according to a preset counting method under the control of the control unit to obtain a first counting result; The second counting unit is used to count according to the preset counting method under the control of the control unit to obtain a second counting result; The control unit is specifically used for: For the relation identifier corresponding to the restriction instruction, the first counting result of the first counting unit is read to obtain the first information; when the first information is allocated for a relation identifier each time, the first counting unit is controlled to count based on the allocated first counting result to obtain the updated first information corresponding to the relation identifier for the next allocation of the first information for the relation identifier. For the relation identifier corresponding to the first instruction queue, the second counting result of the second counting unit is read to obtain the second information; when the second information is allocated for a relation identifier each time, the second counting unit is controlled to count based on the allocated second counting result to obtain the updated second information corresponding to the relation identifier for the next allocation of the second information for the relation identifier.

12. A task processing system, characterized in that, The system includes: a control unit, multiple execution units, and multiple queue placement units connected to each of the multiple execution units, wherein the multiple queue placement units are respectively connected to the control unit; wherein the control unit and the multiple queue placement units are contained in a first chip, and the multiple execution units are respectively contained in at least one second chip; The control unit is used to read all instructions in the instruction sequence for implementing the task and put them into multiple instruction queues, wherein the multiple instruction queues are placed one by one in the multiple queue placement units; The queue placement unit is used to place the instruction queue corresponding to the connected execution unit; The control unit is further configured to determine the processing status of the second instruction queue that the first instruction queue depends on in the data dependency relationship indicated by the relation identifier, based on the relation identifier corresponding to the restriction instruction at the head of the first instruction queue; wherein the first instruction queue is any one of a plurality of instruction queues, and the second instruction queue is one of a plurality of instruction queues; when the processing status is completed, the restriction instruction corresponding to the relation identifier is retrieved from the first instruction queue and the instruction following the restriction instruction is executed by the execution unit corresponding to the first instruction queue; when the processing status is incomplete, the restriction instruction corresponding to the relation identifier is retained in the first instruction queue to prevent the execution of the instruction following the restriction instruction when the processing is incomplete through the first-in-first-out mechanism of the queue; The execution unit is configured to process the instruction queue in the queue placement unit to which the execution unit is connected, under the scheduling of the control unit. The control unit is further configured to, when the first instruction queue has been processed, update the processing status of the first instruction queue to "processing completed" according to the relationship identifier; and when all the instruction queues have been processed, obtain the processing result of the task.

13. The system according to claim 12, characterized in that, The control unit is specifically used for: Read all instructions in the instruction sequence used to implement the task one by one, and put the read instructions into the target instruction queue, wherein the target instruction queue is one of the plurality of instruction queues; Upon reading a restriction instruction, first information is allocated to the restriction instruction based on the relation identifier corresponding to the restriction instruction; wherein, the first information is used to indicate the execution order of the restriction instruction in the data dependency relationship indicated by the corresponding relation identifier; When the first instruction queue has been processed, second information corresponding to the relationship identifier is allocated to the first instruction queue. The second information is used to indicate that the first instruction queue has completed processing. The second sequence information corresponding to the same relationship identifier is allocated in the same way as the first information. Based on the relationship identifier corresponding to the restriction instruction at the head of the first instruction queue, read the first information and the second information corresponding to the relationship identifier; If the first information and the second information read are the same, determine that the processing status of the second instruction queue, which the first instruction queue depends on in the data dependency relationship indicated by the relation identifier, is completed. If the first information and the second information read are different, the processing status of the second instruction queue that the first instruction queue depends on in the data dependency relationship indicated by the relation identifier is determined to be incomplete processing.

14. The system according to claim 13, characterized in that, The control unit is specifically used for: Upon reading a restriction instruction, first information is determined based on the relationship identifier corresponding to the restriction instruction and assigned to the restriction instruction; Each time first information is allocated for a relation identifier, the first information corresponding to the relation identifier is updated for the next allocation of first information for the relation identifier. Upon completion of processing of the first instruction queue, second information corresponding to the relationship identifier is allocated to the first instruction queue, including: Once the first instruction queue has been processed, second information is determined for the relation identifier corresponding to the first instruction queue and assigned to the first instruction queue. Each time second information is allocated for a relation identifier, the second information corresponding to the relation identifier is updated for the next allocation of second information for the relation identifier.

15. The system according to any one of claims 12-14, characterized in that, The control unit is also used for: After retrieving the restriction instruction corresponding to the relationship identifier from the first instruction queue, and then retrieving the update instruction corresponding to the relationship identifier from the first instruction queue, it is determined that the first instruction queue has completed processing; wherein, the update instruction corresponding to the relationship identifier is located at the tail of the first instruction queue.

16. The system according to claim 13, characterized in that, The chip also includes a first counting unit and a second counting unit that are respectively connected to the control unit; The first counting unit is used to count according to a preset counting method under the control of the control unit to obtain a first counting result; The second counting unit is used to count according to the preset counting method under the control of the control unit to obtain a second counting result; The control unit is specifically used for: For the relation identifier corresponding to the restriction instruction, the first counting result of the first counting unit is read to obtain the first information; when the first information is allocated for a relation identifier each time, the first counting unit is controlled to count based on the allocated first counting result to obtain the updated first information corresponding to the relation identifier for the next allocation of the first information for the relation identifier. For the relation identifier corresponding to the first instruction queue, the second counting result of the second counting unit is read to obtain the second information; when the second information is allocated for a relation identifier each time, the second counting unit is controlled to count based on the allocated second counting result to obtain the updated second information corresponding to the relation identifier for the next allocation of the second information for the relation identifier.

17. An electronic device, characterized in that, include: Transceiver and one or more processors; Memory, used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1 to 6.

18. A computer-readable storage medium, characterized in that, The method includes a computer program, characterized in that, when the computer program is run on an electronic device, it causes the electronic device to perform the method as described in any one of claims 1 to 6.

19. A computer program product, characterized in that, The method includes a computer program that, when executed by an electronic device, causes the electronic device to perform the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Instruction processing method and device

    CN111857815A

  • Apparatus and method for managing parallel execution units, and electronic device

    WO2021217300A1

Cited By

  • Task processing method and chip

    EP4675428A1

  • Task processing method and chip

    WO2024188112A1