Task runtime scheduling method and device for data stream many-core processor
By building a task group in the data streaming multi-core processor and modifying the task micro-instruction code, directly transmitting data between PE cores, the problems of low PE array utilization and low task processing efficiency are solved, and more efficient task execution is achieved .
Patent Information
- Application Number
- CN202411019358.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-29
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2044-07-29
AI Technical Summary
Existing data streams and multi-core processors have problems with low PE array utilization and low overall task processing efficiency when executing tasks. Especially when the data scale is small, the task cannot fully cover the PE array, resulting in reduced processing efficiency.
By generating a task flow chart at runtime, recording the attribute information of the task, and building a task group based on the remaining resources of the PE array and on-chip storage space, modifying the micro-instruction code between tasks to directly transmit the result data, reducing the dependence on on-chip storage data based on the remaining resources of the PE array and the on-chip storage space. Interaction.
Improve the utilization rate and task processing efficiency of PE arrays, and reduce task waiting time and storage access latency by directly transmitting data between PE cores.
Smart Images

Figure CN119065832A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer architecture, in particular to the field of data stream multi-core processors, and more particularly to a task runtime scheduling method and device for data stream multi-core processors. Background Art
[0002] The data stream many-core processor is a high-performance computing system with many computing cores (Process Element, or PE or PE core for short). Each PE core supports concurrent processing of tasks to fully exploit the parallelism between tasks, and is suitable for big data processing, artificial intelligence, 5G communications and other fields.
[0003] Traditional data stream many-core processors mainly include: PE array composed of multiple processing units, on-chip storage, direct memory access (DMA), on-chip network, and off-chip storage. Among them, the PE array is the computing component that executes tasks; the on-chip storage is responsible for storing the source data required for task execution and the result data after execution; the DMA is responsible for moving data from off-chip storage to on-chip storage; the on-chip network is responsible for data interaction between different PE cores on the PE array and between PE cores and on-chip storage; and the off-chip storage stores the application programs that need to be executed.
[0004] In a data flow multi-core processor, the application is compiled by the compiler into a task flow graph that reflects the dependencies between tasks, and each task in the task flow graph is described as a directed acyclic data flow graph and mapped to the PE array for execution. For example, Figure 1 An example is given to show the relationship between applications, task flow graphs, and data flow graphs. Assume that there are three applications, namely applications 1 to 3, where the task flow graph corresponding to application 1 contains six tasks: tasks 1 to 6, and the data flow graph corresponding to task 4 contains eight nodes: nodes 1 to 8. The dependencies between tasks in the task flow graph and the dependencies between nodes in the data flow graph are represented by edges (arrows). Taking the data flow graph as an example, each node represents the microinstruction code, that is, the specific calculation or processing required for the data, and the edges in the data flow graph represent the flow direction of the data and the dependencies between nodes. Data flows continuously from the root node along the edges according to the data flow graph until the task is executed to the leaf node. The data-centric data flow multi-core processor can not only mine the parallelism in the task, but also reduce the access of the PE core to the storage, reduce the waiting time of the PE core, and improve the efficiency of task execution.
[0005] Usually, the tasks in the task flow graph will determine the order of task execution according to the dependencies between the tasks, and then the PE array will execute the tasks in the task flow graph in a fixed order. Under different data scales, the number of PE cores required for a task is not fixed. When the data scale is small, the task may only need to occupy 2 or even 1 PE core. During the execution of the task, other tasks cannot be mapped to the PE array for execution, which is obviously not conducive to the utilization of the PE array. At the same time, data interaction between tasks can only be achieved through on-chip storage, which has a large transmission delay and reduces the overall efficiency of task processing.
[0006] It can be seen that the existing technology has the problem that the utilization rate of the PE array is not high and the efficiency of the overall task processing needs to be improved.
[0007] It should be noted that this background technology is only used to introduce the relevant information of the present invention to help understand the technical solution of the present invention, but it does not mean that the relevant information is necessarily the prior art. The relevant information is submitted and disclosed together with the present invention solution. If there is no evidence that the relevant information has been disclosed before the application date of the present invention, the relevant information shall not be regarded as the prior art. Summary of the invention
[0008] Therefore, the purpose of the present invention is to overcome the defects of the above-mentioned prior art and provide a task runtime scheduling method and device for a data stream multi-core processor.
[0009] The objective of the present invention is achieved through the following technical solutions:
[0010] According to a first aspect of the present invention, a task runtime scheduling method for a data stream many-core processor is provided, comprising the following operations in a runtime environment: obtaining an application, generating a task flow graph describing the dependency relationship between tasks in the application, wherein a node in the task flow graph represents a task, an edge between nodes represents a data dependency relationship, a starting point of an edge represents a predecessor task, an end point of an edge represents a successor task, and each node records attribute information of the task; when there is free space in a task emission queue, selecting a task from the task flow graph according to the data dependency relationship, and transferring the attribute information of the selected task to the task emission queue; marking resource-adapted tasks from the task emission queue to construct a task group according to the remaining resources of a PE array, the remaining resources of an on-chip storage space, and the attribute information of each task; preprocessing the tasks in the task group to obtain a preprocessed task group, and mapping the preprocessed task group to a PE array for execution, wherein the preprocessing comprises: identifying an association pair consisting of two tasks with data dependency in the task group, and modifying the microinstruction code corresponding to the predecessor task and the successor task in the association pair, so that the PE core processing the predecessor task directly transmits the result data to the PE core processing the successor task.
[0011] Optionally, modifying the microinstruction code corresponding to the predecessor task and the successor task in the associated pair includes: replacing the storage instruction in the microinstruction code corresponding to the predecessor task with a data transfer instruction, wherein the storage instruction is used to instruct the result data of the predecessor task to be stored in the on-chip storage, and the data transfer instruction is used to instruct the PE core that processes the predecessor task to directly transfer the result data to the PE core that processes the successor task through the on-chip network; and removing the load instruction in the microinstruction code corresponding to the successor task, wherein the load instruction is used to instruct the load instruction to load the result data of the predecessor task in the associated pair from the on-chip storage.
[0012] Optionally, the attribute information of the task includes a task sequence number, a successor task sequence number and a task state, wherein the task state includes waiting to be activated and awakening, and the initial task state of all tasks is waiting to be activated; the method of selecting tasks from the task flow graph according to the data dependency relationship includes: when all non-root nodes have no predecessor tasks that have been passed into the task emission queue, a root node of the task flow graph is selected from the set of the current task flow graph, and the task attributes of the task corresponding to the root node are passed into the task emission queue; otherwise, the task attributes of the successor tasks to be activated are passed into the task emission queue one by one according to the data dependency relationship, wherein the task state in the task attributes initially passed into the task emission queue is modified to awakening. In this way, after the tasks of a task flow graph are completely passed into the task emission queue, the tasks of another task flow graph are selected to be passed into the task emission queue, so as to avoid the waiting process of some applications being too long. If there are multiple candidate task flow graphs without tasks being passed into the task emission queue, a task flow graph is selected from the multiple task flow graphs according to the priority and / or waiting time, and the tasks are selected from the selection according to the data dependency relationship in the above manner.
[0013] Optionally, the attribute information of the task also includes: a predecessor task sequence number, a source data scale, a result data scale and the number of PE cores used, and the task status also includes being executed and ended, wherein a task group is constructed according to the predecessor task sequence number and the task status according to a preset construction rule, and the rule includes: based on the predecessor task sequence number and the task status, identifying the candidate tasks whose task status of the predecessor task is ended, and selecting tasks from the candidate tasks in the order of the time of entering the task launch queue from early to late, wherein the task corresponding to the root node is regarded as the candidate task; after each task is selected, based on the source data scale, the result data scale and the number of PE cores used of the task, it is judged whether the resources required after the selected task and the marked task are integrated meet the requirements, if so, the selected task is set as the marked task, and the successor task of the marked task is continued to be selected, if not, other candidate tasks are selected until no candidate tasks that meet the requirements are found in the task launch queue, wherein the requirement is that the resources required after integration do not exceed the remaining resources of the PE array and the remaining resources of the on-chip storage space. This preset construction rule can improve the parallelism of task processing while giving priority to tasks that enter the queue first, so that the tasks of each application can be carried out in an orderly manner; at the same time, when other task root nodes enter the queue, it can also use the last opportunity to start tasks of other applications through idle resources to improve the overall processing efficiency.
[0014] Optionally, the attribute information of the task also includes: a mapped PE core number, wherein after the preprocessed task group is mapped to the PE array for execution, the mapped PE core number corresponding to the PE core processing each task is filled into the task launch queue, and the task status is modified to being executed.
[0015] Optionally, the attribute information of the task also includes: the total number of loops and the loop granularity, wherein the total number of loops refers to the total number of iterative executions of the task, and the loop granularity refers to the number of iterative executions of the task required to obtain result data that can be passed to the successor task each time; the method also includes: for any two tasks with a dependency relationship, after the predecessor task iterates the loop granularity number of times, a data transfer instruction is executed once, and the successor task is triggered to iterate the loop granularity number of times; when the number of iterative executions of the task reaches the total number of loops, the task status is set to end.
[0016] Optionally, the attribute information of the task also includes: a source data address and a result data address, and the method also includes: calibrating the source data address and result data address of each task according to a preset address calibration method, including: for a task that has no predecessor task and successor task in the task group, calibrating the address of the source data in the on-chip storage in the source data address of the task, and calibrating the address of the result data in the on-chip storage in the result data address of the task; for a task that has only a successor task in the task group, calibrating the address of the source data in the on-chip storage only in the source data address of the task; for a task that has only a predecessor task in the task group, calibrating the address of the result data in the on-chip storage only in the result data address of the task; for a task that has both a predecessor task and a successor task in the task group, neither the source data address nor the result data address of the task needs to be calibrated; according to the calibrated source data address, reading the source data required for the task when the task is executed; according to the calibrated result data address, saving the result data at the corresponding address of the on-chip storage at the end of the task execution. The address calibration unit calibrates the source data address and result data address of each task differently according to the needs, which can reduce the calibration time.
[0017] According to a second aspect of the present invention, there is provided a task runtime scheduling device for a data stream multi-core processor, which is used to implement the method of the first aspect, including: a microcontroller module, which is configured to: obtain an application program, generate a task flow graph describing the dependency relationship between tasks in the application program, wherein a node in the task flow graph represents a task, an edge between nodes represents a data dependency relationship, a starting point of an edge represents a predecessor task, an end point of an edge represents a successor task, and each node records attribute information of the task; and when there is free space in a task emission queue, select a task from the task flow graph according to the data dependency relationship, and pass the attribute information of the selected task to the task emission queue; The task transmitting module is configured to: construct a task group from the tasks marked with resource adaptation in the task transmitting queue according to the remaining resources of the PE array, the remaining resources of the on-chip storage space and the attribute information of each task; and pre-process the tasks in the task group to obtain a pre-processed task group, and map the pre-processed task group to the PE array for execution, wherein the pre-processing includes: identifying an association pair consisting of two tasks with data dependency in the task group, and modifying the microinstruction code corresponding to the predecessor task and the successor task in the association pair, so that the PE core of the predecessor task directly transmits the result data to the PE core processing the successor task.
[0018] According to a third aspect of the present invention, there is provided an electronic device comprising: one or more processors; and a memory, wherein the memory is used to store executable instructions; the one or more processors are configured to implement the steps of the method described in the first aspect by executing the executable instructions. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The embodiments of the present invention are further described below with reference to the accompanying drawings, in which:
[0020] Figure 1 is a schematic diagram of a task flow chart according to an embodiment of the present invention;
[0021] Figure 2 It is a schematic diagram of the module structure of a task runtime scheduling device according to an embodiment of the present invention;
[0022] Figure 3 A schematic diagram of a task emission queue according to an embodiment of the present invention;
[0023] Figure 4 A schematic diagram of modifying microinstruction codes according to an embodiment of the present invention;
[0024] Figure 5 A schematic diagram of an example process of a task runtime scheduling method according to an embodiment of the present invention;
[0025] Figure 6 The figure is a flowchart of a task runtime scheduling method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below through specific embodiments in conjunction with the accompanying drawings. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0027] As mentioned in the background technology section, the prior art has the problem of low utilization of the PE array and the need to improve the efficiency of overall task processing. On the one hand, research on data flow-based multi-core processors shows that when the task data scale is small, the PE array resources required by the task are relatively small, and the task calculation cannot cover the entire PE array, resulting in low utilization of the PE array, affecting the execution efficiency of the application. On the other hand, there are situations in which there is data dependency between two or more tasks in the application. For tasks with data dependency, if data interaction is only performed through on-chip storage, the advantages of the data flow multi-core processor cannot be fully utilized. In this regard, if the hardware is improved for scheduling optimization, it will be costly and unsuitable for existing data flow multi-core processors. Therefore, the method of the present invention starts from the runtime environment and makes improvements at the software level. The task flow graph generated for the application is recorded in the task flow graph. When there is free space in the task launch queue, the task is selected from the task flow graph according to the data dependency relationship, and the attribute information of the selected task is passed into the task launch queue to ensure that the attribute information related to one task flow graph is fully loaded in the task launch queue before the attribute information related to the remaining task flow graphs is loaded. Subsequently, according to the remaining resources of the PE array, the remaining resources of the on-chip storage space and the attribute information of each task, the resource-adapted tasks are marked from the task launch queue to construct the task The group can make full use of the remaining resources of the PE array and the remaining resources of the on-chip storage space with the help of attribute information to improve the utilization rate of the PE array; in addition, the method of the present invention also modifies the microinstruction code corresponding to the predecessor task and the successor task in the associated pair by identifying the association pair composed of two tasks with data dependence in the task group, so that the PE core processing the predecessor task directly transmits the result data to the PE core processing the successor task, which can avoid transmitting the result data of the predecessor task in the task group to the on-chip storage first and then the PE core processing the successor task reading the data from the on-chip storage, thereby reducing time overhead and can effectively improve the efficiency of the overall task processing at low cost.
[0028] First, the schematic structure of the data stream many-core processor is described, which includes off-chip storage, DMA, on-chip storage and a PE array composed of multiple PE cores, wherein the off-chip storage is used to store the application program and source data to be executed, the DMA is used to transfer data from the off-chip storage to the on-chip storage, and the on-chip storage is used to store the source data required for task execution and the result data after the execution is completed; the PE array is the computing component of the data stream many-core processor to execute tasks, including multiple PE cores. For example Figure 2 As shown, the PE array includes 16 PE cores (it can also be 32, 64 or 128, etc., depending on the configuration of the data flow many-core processor), and any two PE cores can exchange data through the on-chip network.
[0029] Secondly, for the above data stream multi-core processor, the present invention provides a task runtime scheduling (Runtime Schedule) device for the data stream multi-core processor, including: a microcontroller module and a task launch module, the task launch module includes a task launch queue, a loop control unit and an address calibration unit. Among them, the microcontroller module (Micro Controller Unit, referred to as MCU) is responsible for compiling the application into a task flow chart, recording the attribute information of the task, selecting the task that can be scheduled for execution and transmitting its attribute information to the task launch queue; the task launch module is responsible for recording all the tasks to be scheduled for execution through the task launch queue, selecting a suitable task group to be scheduled for execution on the PE array, and also maintaining the task status information; the loop control unit is used to allocate the PE core mapped by the task to be scheduled for execution, control the source data of the task to be transferred from the off-chip storage to the on-chip storage through DMA, and distribute the microinstruction code required for task execution, and generate data transmission instructions for the tasks with dependencies in the task group, insert the generated data transmission instructions in the loop iteration process of advancing the task, and count the remaining resources of the PE array; the address calibration unit is used to calibrate the location of the source data and result data of the task stored on the chip, maintain the validity of the address information of the task, and count the remaining space resources stored on the chip. The following is a schematic description of each part of the task runtime scheduling device.
[0030] (1) Microcontroller module
[0031] According to one embodiment of the present invention, the microcontroller module is configured to: obtain an application program, generate a task flow graph describing the dependency relationship between tasks in the application program, wherein a node in the task flow graph represents a task, an edge between nodes represents a data dependency relationship, the starting point of the edge represents a predecessor task, the end point of the edge represents a successor task, and each node records the attribute information of the task; and when there is free space in the task emission queue, select a task from the task flow graph according to the data dependency relationship, and pass the attribute information of the selected task into the task emission queue. Wherein, the method of selecting a task from the task flow graph according to the data dependency relationship includes: when all non-root nodes do not have a predecessor task that has been passed into the task emission queue, select a root node of the task flow graph from the set of the current task flow graph, and pass the task attribute of the task corresponding to the root node into the task emission queue; otherwise, pass the task attributes of the successor tasks to be activated into the task emission queue one by one according to the data dependency relationship, wherein the task state in the task attribute initially passed into the task emission queue is modified to wake-up. Preferably, the method of selecting tasks from the task flow graph according to data dependency is as follows: obtain the currently selected task flow graph, start from the root node of the task flow graph, modify the task status of the tasks corresponding to the nodes to wake-up in turn, and use the awakened tasks as the selected tasks, wherein, after the attribute information of an awakened task is passed into the task emission queue, if there is still free space in the task emission queue, according to the task sequence number of the awakened task and the sequence number of the subsequent task, continue to modify the task status of the subsequent task of the awakened task to wake-up; if all tasks in the currently selected task flow graph are awakened, then continue to select task flow graphs from other task flow graphs whose tasks are to be activated, and repeat the previous process. In this way, the tasks of a task flow graph can be completely passed into the task emission queue before selecting the tasks of another task flow graph to be passed into the task emission queue, so as to avoid the waiting process of some applications being too long. If there are multiple candidate task flow graphs without tasks being passed into the task emission queue, a task flow graph is selected from multiple task flow graphs according to priority and / or waiting time, and tasks are selected from the selection according to data dependency in the above manner.
[0032] The nodes in the task flow graph represent a task function divided within the application scenario, and the nodes in the data flow graph within each task represent the microinstruction code for processing data within the task.
[0033] According to an embodiment of the present invention, the attribute information of a task includes: task number, predecessor task number, successor task number, task status, total number of loops, loop granularity, source data size, result data size, source data address, result data address, number of PE cores used and mapped PE core number or a combination thereof. Of course, some items in the attribute information are not available when the attribute information is initially generated, that is, some items can be set to default values at the beginning, and then can be gradually modified and improved in the subsequent process.
[0034] (2) Mission launch module
[0035] 2.1、Task launch queue
[0036] According to an embodiment of the present invention, the task transmission queue is used to record the attribute information of the task. For an exemplary task transmission queue, see Figure 3 shown.
[0037] According to one embodiment of the present invention, the task launch queue is also used to schedule the task group to be executed on the PE array. For example, the task group is constructed according to the predecessor task sequence number and the task status according to the preset construction rules, and the rules include: based on the predecessor task sequence number and the task status, identifying the candidate task whose task status of the predecessor task is ended, and selecting tasks from the candidate tasks in the order of the time of entering the task launch queue from early to late, wherein the task corresponding to the root node is regarded as the candidate task; after each task is selected, according to the source data scale of the task, the result data scale and the use of the PE core, it is judged whether the resources required after the selected task and the marked task are integrated meet the requirements, if so, the selected task is set as the marked task, and the successor task of the marked task is continuously selected, if not, other candidate tasks are selected until the candidate task that meets the requirements is not found in the task launch queue, wherein the requirement is that the resources required after integration do not exceed the remaining resources of the PE array and the remaining resources of the on-chip storage space. For example: Assume that the task status of the three predecessor tasks in the task emission queue are ended tasks, namely tasks A, B, C, and a task D corresponding to a root node, and the time of entering the queue is tasks A, B, and C in order. For simplicity, assume that tasks A, B, and D have no successor tasks, and task C has a successor task c1. After selecting task A, the marked tasks are empty at this time, and the resources required after the integration of task A and the marked tasks do not exceed the remaining resources of the PE array and the remaining resources of the on-chip storage space, then task A will be marked; then, select task B, and the resources required after the integration of task B and the marked task A exceed the remaining resources of the PE array and the remaining resources of the on-chip storage space, then task B will not be marked; then, select task C, and the resources required after the integration of task C and the marked task A do not exceed the remaining resources of the PE array and the remaining resources of the on-chip storage space, then task C will be marked. Then, select the successor task c1 of task C. If the resources required after the integration of task c1 and the marked tasks A and C do not exceed the remaining resources of the PE array and the remaining resources of the on-chip storage space, then mark task c1 (note that if c1 has a successor task, the successor task of c1 will actually be selected); finally, select task D. If the resources required after the integration of task D and the marked tasks A, C, and c1 do not exceed the remaining resources of the PE array and the remaining resources of the on-chip storage space, then mark task D; then the constructed task group includes tasks A, C, c1, and D. The technical solution of this embodiment can at least achieve the following beneficial technical effects: while improving the parallelism of task processing, it can give priority to the tasks that enter the queue first, so that the tasks of each application can be carried out in an orderly manner; at the same time, when there are other task root nodes in the queue, the last opportunity can also be used to start the tasks of other applications through idle resources to improve the overall processing efficiency.
[0038] Of course, the above preset construction rules are only preferred implementation methods, and the implementer can set the preset construction rules required to construct the task group. For example: according to an optional embodiment of the present invention, the preset construction rules are used to construct the task group, and the preset construction rules include:
[0039] Rule A: Based on the predecessor task sequence number and task status, identify the candidate tasks whose task status of the predecessor task is ended, and select tasks from the candidate tasks in the order of the time they enter the task launch queue from the earliest to the latest, among which the task corresponding to the root node is regarded as the candidate task;
[0040] Rule B: After each task is selected, it is determined whether the resources required after the selected task and the marked task are integrated meet the requirements according to the source data scale, result data scale and PE core used by the task. If so, the selected task is set as the marked task, and the successor task of the marked task is continuously selected. If not, other candidate tasks are selected until no candidate tasks meeting the requirements are found in the task launch queue, wherein the requirement is that the resources required after integration do not exceed the remaining resources of the PE array and the remaining resources of the on-chip storage space.
[0041] Rule C: Among the marked tasks, the number of root node tasks must be less than a preset threshold (such as 1, 3, or 10, etc., set as needed according to the processing capacity of the PE array). By setting Rule C, it is possible to prevent a task group from loading too many root nodes of applications at one time, thereby reducing the impact on the execution efficiency of applications that were started earlier.
[0042] The task launch queue maintains the task status in the attribute information of each task. Task status includes pending activation, awakening, executing and ending, among which pending activation is the initial state in the attribute information of the task (the state before being passed into the task launch queue), and awakening represents the state in which the attribute information of the task is activated before being passed into the task launch queue. Executing represents the state in which the task is launched to the PE array for calculation. Ending represents the state in which the task completes the calculation on the PE array. For example: after the preprocessed task group is mapped to the PE array for execution, the loop control unit notifies the task launch queue to fill the mapped PE core serial number corresponding to the PE core that processes each task into the task launch queue, and changes the task status to executing; when the number of iterative executions of the task reaches the total number of loops, the task status is set to ending.
[0043] 2.2 Address calibration unit
[0044] According to one embodiment of the present invention, after selecting the task group to be executed, each task in the task group needs to be preprocessed. Among them, the address calibration unit is used to calibrate the address (position) of the source data and result data of the task stored on the chip. The address calibration unit is configured to: calibrate the source data address and result data address of each task according to a preset address calibration method, including: Rule 1: For tasks that do not have predecessor tasks and successor tasks in the task group, calibrate the address of the source data in the on-chip storage in the source data address of the task, and calibrate the address of the result data in the on-chip storage in the result data address of the task; Rule 2: For tasks that only have successor tasks in the task group, calibrate the address of the source data in the on-chip storage only in the source data address of the task; Rule 3: For tasks that only have predecessor tasks in the task group, calibrate the address of the result data in the on-chip storage only in the result data address of the task; Rule 4: For tasks that have both predecessor tasks and successor tasks in the task group, the source data address and result data address of the task do not need to be calibrated. For Rule 2, since there is no predecessor task in the task group, it is difficult to coordinate the direct transmission of the result data. Therefore, the corresponding source data is still obtained from the source data address. For Rule 3, since there is no successor task in the task group, the corresponding result data is still stored at the result data address for later on-demand access. For Rule 4, the source data required for the task can be obtained from the upstream PE core, and the result data generated by the task can be directly transmitted to the downstream PE core. Therefore, there is no need to calibrate the source data address and result data address of the task.
[0045] According to an embodiment of the present invention, the address calibration unit not only needs to calibrate the address of the task, but also needs to record the status of the task with the calibrated address, count the remaining resources of the on-chip storage space according to the data addresses of these tasks, and when the task status is ended, the on-chip storage space resources occupied by the task need to be released. The address calibration unit sends the counted remaining resources of the on-chip storage space to the task transmission queue.
[0046] 2.3. Cycle Control Unit
[0047] According to one embodiment of the present invention, in addition to calibrating the addresses of the tasks in the task group, the preprocessing unit also receives the microinstruction code of each task in the task group from the off-chip storage, and allocates a mapped PE core number to each task according to the remaining resources of the PE array.
[0048] For any two tasks in a task group that have a dependency relationship, the loop control unit needs to change the microinstruction code of the task. According to one embodiment of the present invention, the method of modifying the microinstruction code corresponding to the predecessor task and the successor task in the associated pair includes: replacing the storage instruction in the microinstruction code corresponding to the predecessor task with a data transfer instruction, wherein the storage instruction is used to instruct the result data of the predecessor task to be stored in the on-chip storage, and the data transfer instruction is used to instruct the PE core that processes the predecessor task to directly transfer the result data to the PE core that processes the successor task through the on-chip network; removing the load instruction in the microinstruction code corresponding to the successor task, wherein the load instruction is used to instruct the load instruction to load the result data of the predecessor task in the associated pair from the on-chip storage. Figure 4 As shown, the storage instruction of the predecessor task that stores the result data back to the on-chip storage and the load instruction of the successor task that fetches the source data to the PE core will be hidden, and a data transfer instruction block is generated and inserted into the position where the storage instruction of the predecessor task is located. When the data transfer instruction is generated, it is necessary to use the information of the storage instruction of the predecessor task and the load instruction of the successor task, including the PE core serial number corresponding to the storage instruction and the load instruction that operate the data at the same address, and the register serial number where the data is located in the corresponding storage instruction and the load instruction, so as to realize a group of data directly from the PE core processing the predecessor task to the PE core processing the successor task.
[0049] According to one embodiment of the present invention, the loop control unit is also used to promote the execution process of the loop iteration of the task. The loop control unit is configured to: for any two tasks with a dependency relationship, after each iteration of the predecessor task executes the loop granularity number of times, execute a data transmission instruction once, and trigger the successor task to iterate one loop granularity number of times; when the number of task iterations reaches the total number of loops, notify the task launch queue to set the task status to end.
[0050] According to an embodiment of the present invention, the loop control unit is further used to count the remaining resources of the PE array, that is, the idle PE cores. The loop control unit sends the counted remaining resources of the PE array to the task transmission queue.
[0051] According to one embodiment of the present invention, based on the above device, a task runtime scheduling method for a data stream multi-core processor can be implemented, the method comprising: performing the following operations in a runtime environment: obtaining an application, generating a task flow graph describing the dependency relationship between tasks in the application, wherein a node in the task flow graph represents a task, an edge between nodes represents a data dependency relationship, a starting point of an edge represents a predecessor task, an end point of an edge represents a successor task, and each node records the attribute information of the task; when there is free space in the task launch queue, selecting a task from the task flow graph according to the data dependency relationship, and passing the attribute information of the selected task into the task launch queue; according to the PE The remaining resources of the array, the remaining resources of the on-chip storage space and the attribute information of each task are used to mark the resource-adapted tasks from the task launch queue to build a task group; the tasks in the task group are preprocessed to obtain a preprocessed task group, and the preprocessed task group is mapped to the PE array for execution, wherein the preprocessing includes: calibrating the source data address and the result data address of each task according to a preset address calibration method, and identifying an association pair consisting of two tasks with data dependence in the task group, and modifying the microinstruction code corresponding to the predecessor task and the successor task in the association pair, so that the PE core that processes the predecessor task directly transmits the result data to the PE core that processes the successor task.
[0052] According to an example of the present invention, Figure 5 As shown, a schematic implementation process of a task runtime scheduling method for a data stream multi-core processor is provided, including: A1, A2, A3, A4.
[0053] in:
[0054] A1. MCU generates a task flow graph G according to the application program P, records the attribute information of the nodes in the graph, and transmits the tasks to be executed to the task launch queue.
[0055] The schematic process of step A1 is as follows Figure 6As shown in S1, first, the MCU generates a task flow graph G describing the dependency relationship between tasks according to the configuration information of the application program P. The task flow graph G is described in the form of a data structure. The attribute information of the task needs to include: task number, predecessor task number, successor task number, task status, total number of loops, loop granularity, source data size, address of source data stored off-chip, result data size, address of result data stored off-chip, and number of PE cores used. These attribute information are used as judgment conditions for task runtime scheduling, and also include task execution information. Initially, the task status of all tasks in all task flow graphs G is in the idle state. At this time, according to whether there is still space in the task launch queue to accommodate the task attribute information, if there is, the task status of the root node of the task flow graph G is set to the wake-up state. Whenever a task is changed to the wake-up state, the attribute information of the task needs to be sent to the task launch queue. At the same time, if there is still space in the task launch queue to accommodate the attribute information of the task, the task status of the successor task of the task needs to be changed to the wake-up state, and this cycle continues. If the task has no successor task, the MCU can look for other awakened tasks and transmit the task attribute information to the task launch queue according to the same process to improve the performance of processor parallel processing and the utilization of the PE array.
[0056] A2. The task launch module builds a task group and preprocesses the tasks in the task group.
[0057] The schematic process of step A2 is as follows: Figure 6 As shown in S2, the attribute information of each awakened task is recorded in the task launch queue, such as Figure 3As shown, it includes task number, predecessor task number, successor task number, task status, predecessor task status, total number of loops, loop granularity, source data size, result data size, source data address, result data address, number of PE cores used, and mapped PE core number. First, the task launch queue selects the task whose predecessor task status is over. If there are multiple options, the task that enters the task launch queue earlier is given priority. After selecting the task, it is determined whether the task can meet the requirements of the remaining resources of the PE array and the remaining resources of the on-chip storage space. If not, then select other tasks whose predecessor task status is over. If yes, then mark the task as a task to be executed, and at the same time, judge the successor task of the task. After integrating the required resources of the predecessor task and the successor task, whether the requirements of the remaining resources of the PE array and the remaining resources of the on-chip storage space can still be met, then mark the successor task as a task to be executed. If there is no successor task, then select other tasks whose predecessor task status is over, and determine whether the task can meet the requirements of the remaining resources of the PE array and the remaining resources of the on-chip storage space after integration with the marked tasks. Each time a task is selected, it needs to integrate resources with the marked tasks. Only when the required resources after integration can meet the requirements of the remaining resources of the PE array and the remaining resources of the on-chip storage space can the selected task be marked as a task to be executed. In this way, by continuously marking tasks until no tasks that meet the requirements are found in the task launch queue, a task group to be executed is selected.
[0058] After selecting the task group to be executed, each task in the task group needs to be preprocessed. The address calibration unit calibrates the addresses of the source data and result data in the on-chip storage for each task in the selected task group. For any two tasks with a dependency relationship, only the source data address of the predecessor task and the result data address of the successor task can be calibrated. If a task has both a predecessor task and a successor task in the task group, then the source data address and result data address of the task do not need to be marked. The address calibration unit not only needs to calibrate the address of the task, but also needs to record the status of the tasks with the calibrated addresses, and count the remaining resources of the on-chip storage space based on the data addresses of these tasks. At the same time, when the task status is ended, the on-chip storage space resources occupied by the task need to be released.
[0059] In addition to calibrating the addresses of the tasks in the task group, the preprocessing will also receive the microinstruction code of each task in the task group from the off-chip storage, and allocate the mapped PE core number to each task according to the remaining resources of the PE array. For any two tasks with dependencies in the task group, the microinstruction code of the task needs to be changed. The storage instruction of the predecessor task to store the result data back to the on-chip storage and the load instruction of the successor task to get the source data to the PE core will be hidden (such as deleted or ignored), and a data transfer instruction block is generated and inserted into the location of the storage instruction of the predecessor task. When generating the data transfer instruction, it is necessary to include the PE core number corresponding to the storage instruction and load instruction of the data operating at the same address, and the register number of the data in the corresponding storage instruction and load instruction, so as to realize a group of data directly transferred from the PE core of the predecessor task to the PE core of the successor task. The loop control unit is also responsible for counting the remaining resources of the PE array, that is, the PE core of the task that has not been mapped.
[0060] A3. The task group is mapped to the PE array for execution, and the task status of any task is updated after the execution of any task is completed.
[0061] The specific process of this step is as follows Figure 6 As shown in S3, after the selected task group is preprocessed, the tasks in the task group can be mapped to the PE array according to the assigned PE core number, the task microinstruction code is loaded by the loop control unit, and the source data is moved from the off-chip storage to the on-chip storage through DMA according to the calibrated address. After the instructions and source data are loaded, the loop control unit will advance the execution of the task, and the total number of loops in the task attribute information will be used as the number of task iterations, and the loop granularity refers to the number of task iterations required to obtain the result data from a set of source data. For any two tasks with a dependency relationship, after the predecessor task iterates the loop granularity times each time, it executes a data transfer instruction block, and then triggers the successor task to iterate one loop granularity times. In this way, when a set of source data of the predecessor task A obtains a set of result data, it can be immediately transmitted to the successor task B as a set of source data to trigger an iterative execution of a loop granularity. At the same time, after obtaining a set of result data, task B can transmit it to its successor task C and trigger the execution of task C. Similarly, a set of data can be continuously transmitted and flowed between dependent tasks to realize the pipeline execution of data between tasks, and the predecessor task will not block the execution of the successor task due to the dependency between tasks, which reduces the access to on-chip storage while also improving the execution efficiency of the application.
[0062] After the task is executed, the task can be terminated directly if the result data is taken over by the subsequent task. For the task whose result data is not taken over, the loop control unit will send a request to the DMA to move the task result data from the on-chip storage to the off-chip storage according to the on-chip storage address and the off-chip storage address. After the transfer is completed, the task execution is completed, and the information on the completion of the task execution is sent to the task transmission queue and the address calibration unit, and the status of the corresponding task is updated to the over status, and sent to the MCU at the same time. The MCU updates the task status to the over status.
[0063] A4. Application P is executed and the result data is transferred from the on-chip storage to the off-chip storage via DMA.
[0064] When the status of all tasks in the task flow graph G of the application P in the MCU is over, it means that the application execution is completed, and the result data will be transferred from the on-chip storage to the off-chip storage via DMA for access by the general-purpose processor.
[0065] In general, the solution provided by the embodiment of the present invention has at least one of the following beneficial effects:
[0066] (1) By real-time sensing of the remaining resources of the PE array and the on-chip storage resources required by the task, the available tasks in the task list are dynamically scheduled and mapped to the PE array, thereby exploring the parallelism between tasks, reducing the idleness of the PE core, and improving the utilization of the PE array;
[0067] (2) For tasks with data dependencies, the present invention provides a method for changing task microinstruction codes, which can pipeline the independent data blocks in the source data of the predecessor task between tasks with dependencies, so that tasks with data dependencies do not need to exchange data through on-chip storage, but can directly transmit data between PE cores, thereby improving the execution efficiency of the application.
[0068] It should be noted that although the above describes the various steps in a specific order, it does not mean that the various steps must be executed in the above specific order. In fact, some of these steps can be executed concurrently or even in a different order as long as the required functions can be achieved.
[0069] The present invention may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present invention.
[0070] Computer readable storage medium can be a tangible device that holds and stores instructions used by an instruction execution device. Computer readable storage medium can include, for example, but is not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination thereof. More specific examples (non-exhaustive list) of computer readable storage medium include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, for example, a punch card or a protruding structure in a groove on which instructions are stored, and any suitable combination thereof.
[0071] The embodiments of the present invention have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.
Claims
1. A task runtime scheduling method for data stream many-core processors, It is characterized in that This includes doing the following in the runtime environment: Get the application and generate a task flow graph that describes the dependencies between tasks in the application. A node in the task flow graph represents a task, and an edge between nodes represents data dependencies. The starting point of the edge represents the predecessor task, and the end point of the edge represents the successor task. Each node records the attribute information of the task. When there is free space in the task launch queue, a task is selected from the task flow graph according to the data dependency relationship, and the attribute information of the selected task is transferred to the task launch queue; According to the remaining resources of the PE array, the remaining resources of the on-chip storage space and the attribute information of each task, the resource-adapted tasks are marked from the task launch queue to construct a task group; Preprocessing the tasks in the task group to obtain a preprocessed task group, and mapping the preprocessed task group to the PE array for execution, wherein the preprocessing includes: identifying an association pair consisting of two tasks with data dependence in the task group, and modifying the microinstruction code corresponding to the predecessor task and the successor task in the association pair so that the PE core processing the predecessor task directly transmits the result data to the PE core processing the successor task.
2. The method according to claim 1, It is characterized in that The microinstruction codes corresponding to the predecessor task and the successor task in the modification association pair include: Replace the storage instruction in the microinstruction code corresponding to the predecessor task with a data transfer instruction, wherein the storage instruction is used to instruct the result data of the predecessor task to be stored in the on-chip storage, and the data transfer instruction is used to instruct the PE core processing the predecessor task to directly transfer the result data to the PE core processing the successor task through the on-chip network; The load instruction in the microinstruction code corresponding to the successor task is removed, wherein the load instruction is used to instruct the load instruction to load the result data of the predecessor task in the associated pair from the on-chip storage.
3. The method according to claim 2, It is characterized in that The attribute information of the task includes the task number, the subsequent task number and the task status, wherein the task status includes pending activation and awakening, and the initial task status of all tasks is pending activation; The methods for selecting tasks from the task flow diagram based on data dependencies include: When all non-root nodes have no predecessor tasks that have been passed into the task emission queue, a root node of the task flow graph is selected from the set of the current task flow graph, and the task attributes of the task corresponding to the root node are passed into the task emission queue; Otherwise, the task attributes of the successor tasks to be activated are passed into the task emission queue one by one according to the data dependency, wherein the task state in the task attributes initially passed into the task emission queue is modified to wake-up.
4. The method according to claim 3, It is characterized in that The attribute information of the task also includes: the predecessor task sequence number, the source data size, the result data size and the number of PE cores used, and the task status also includes executing and ending, wherein the task group is constructed according to the predecessor task sequence number and the task status according to the preset construction rules, and the rules include: Based on the predecessor task sequence number and task status, identify the candidate tasks whose task status of the predecessor task is ended, and select tasks from the candidate tasks in the order of the time of entering the task launch queue from the earliest to the latest, among which the task corresponding to the root node is regarded as the candidate task; After each task is selected, it is determined whether the resources required after the selected task is integrated with the marked tasks meet the requirements based on the source data scale, result data scale and PE core used. If so, the selected task is set as the marked task, and the successor task of the marked task is continued to be selected. If not, other alternative tasks are selected until no alternative tasks that meet the requirements are found in the task launch queue, wherein the requirement is that the resources required after integration do not exceed the remaining resources of the PE array and the remaining resources of the on-chip storage space.
5. The method according to claim 4, It is characterized in that The attribute information of the task also includes: a mapped PE core number, wherein after the pre-processed task group is mapped to the PE array for execution, the mapped PE core number corresponding to the PE core processing each task is filled into the task emission queue, and the task state is modified to being executed.
6. The method according to claim 5, It is characterized in that The attribute information of the task also includes: the total number of loops and the loop granularity, wherein the total number of loops refers to the total number of iterative executions of the task, and the loop granularity refers to the number of iterative executions of the task required to obtain result data that can be passed to the subsequent task each time; The method further comprises: For any two tasks with dependencies, after the predecessor task iterates for the number of loop granularity, a data transfer instruction is executed, and the successor task is triggered to iterate for one loop granularity number; When the number of task iterations reaches the total number of loops, the task status is set to ended.
7. The method according to claim 6, It is characterized in that The attribute information of the task also includes: a source data address and a result data address, and the method further includes: The source data address and result data address of each task are calibrated according to the preset address calibration method, including: For a task without a predecessor task and a successor task in the task group, the address of the source data in the on-chip storage is marked in the source data address of the task, and the address of the result data in the on-chip storage is marked in the result data address of the task; For a task that has only a successor task in the task group, the address of the source data in the on-chip storage is calibrated only in the source data address of the task; For a task that has only a predecessor task in the task group, the address of the result data in the on-chip storage is calibrated only in the result data address of the task; For a task that has both a predecessor task and a successor task in the task group, the source data address and the result data address of the task do not need to be calibrated; According to the calibrated source data address, the source data required by the task is read when the task is executed; According to the calibrated result data address, the result data is saved at the corresponding address of the on-chip storage at the end of the task execution.
8. A task runtime scheduling device for a data stream many-core processor, used to implement the method according to any one of claims 1 to 7, include: The microcontroller module is configured to: obtain an application program, generate a task flow graph describing the dependency relationship between tasks in the application program, wherein a node in the task flow graph represents a task, an edge between nodes represents a data dependency relationship, a starting point of an edge represents a predecessor task, an end point of an edge represents a successor task, and each node records attribute information of a task; and when there is free space in a task launch queue, select a task from the task flow graph according to the data dependency relationship, and transfer the attribute information of the selected task to the task launch queue; The task transmission module is configured to: construct a task group from tasks marked with resource adaptation in the task transmission queue according to the remaining resources of the PE array, the remaining resources of the on-chip storage space and the attribute information of each task; And preprocessing the tasks in the task group to obtain a preprocessed task group, mapping the preprocessed task group to the PE array for execution, wherein the preprocessing includes: identifying an association pair consisting of two tasks with data dependency in the task group, modifying the microinstruction code corresponding to the predecessor task and the successor task in the association pair, so that the PE core of the predecessor task directly transmits the result data to the PE core processing the successor task.
9. A computer-readable storage medium, It is characterized in that A computer program is stored thereon, and the computer program can be executed by a processor to implement the steps of the method according to any one of claims 1 to 7.
10. An electronic device, It is characterized in that include: one or more processors; as well as A memory, wherein the memory is used to store executable instructions; The one or more processors are configured to implement the steps of the method of one of claims 1 to 7 by executing the executable instructions.
Citation Information
Patent Citations
Method and system for accelerating task control flow
CN107209688A
Data asynchronous processing method and device based on synchronous programming
CN109002286A
Efficient execution method and system of coarse-grained reconfigurable array data stream processor
CN116303226A
Idempotent task execution in on-demand network code execution systems
US10061613B1
Method, device, and system for creating a massively parallilized executable object
US20180095738A1
