Task processing method and device, electronic device, and computer-readable storage medium
By determining the data transmission relationship and order between processing cores in the multi-core system, the processing priority of tasks in the neural network model is optimized, and the problem of low storage space utilization efficiency in the neural network model is solved, and more efficient storage and computing performance is achieved.
Patent Information
- Application Number
- CN202411845489.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-13
- Publication Date
- 2025-04-08
AI Technical Summary
In the calculation process of neural network models, how to optimize limited on-chip storage resources and improve the efficiency of storage space use, especially when processing large-scale tensor data.
By determining the data transmission relationship and order between different processing cores in the multi-core system, the routing priority of the target task is determined, and the processing priority of the task is determined based on the routing priority, thereby optimizing the task processing order and reducing data storage time.
Effectively dispatch storage space in the multi-core architecture, reduce the impact of too small free storage space in a single processing core, improve storage and computing efficiency, and reduce data storage pressure.
Smart Images

Figure CN119781926A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a task processing method and device, an electronic device, and a computer-readable storage medium. Background Art
[0002] With the rapid development of deep learning technology, the scale and complexity of neural network models are increasing, and the requirements for computing chips are also increasing. Neural network operations mainly involve the processing of large-scale tensor data, which requires a lot of storage space. Under the constraints of limited on-chip storage resources, how to optimize the efficiency of storage space is a key issue. Summary of the invention
[0003] The present disclosure provides a task processing method and device based on a many-core system, a processing core, an electronic device, and a computer-readable storage medium.
[0004] In a first aspect, the present disclosure provides a task processing method for a first processing core, the task processing method comprising:
[0005] When receiving the target task, determining task information corresponding to the target task, the task information including a routing identifier, the routing identifier being used to represent a second processing core that uses output data of the target task as input data;
[0006] Determine a routing priority of the target task according to the task information, where the routing priority is used to define the order in which output data of the target task is transmitted to the second processing core;
[0007] The processing priority of the target task is determined according to the routing priority of the target task, and the target task is inserted into the task queue of the first processing core as a to-be-processed task, wherein the task queue includes a plurality of to-be-processed tasks sorted according to corresponding processing priorities.
[0008] In a possible implementation, determining the routing priority of the target task according to the task information includes:
[0009] Determining a first free memory of the first processing core at the time when the target task is received;
[0010] Determine, according to the routing identifier, a second idle storage of the second processing core at the time when the target task is received;
[0011] A routing priority corresponding to the target task is determined according to the first free storage and the second free storage.
[0012] In a possible implementation, determining the processing priority of the target task according to the routing priority of the target task includes:
[0013] Determine the candidate priority corresponding to the target task according to the task information;
[0014] The processing priority of the target task is determined according to the routing priority and the candidate priority.
[0015] In a possible implementation, the task information further includes the input data volume and the output data volume of the target task, and determining the candidate priority corresponding to the target task according to the task information includes:
[0016] Determine the corresponding storage parameters according to the input data volume and output data volume of the target task;
[0017] Determine candidate priorities for target tasks based on storage parameters.
[0018] In a possible implementation, determining the candidate priority corresponding to the target task according to the task information includes:
[0019] In the case where the input data of the target task is shared data, determining other tasks to be processed that use the shared data as input data as shared input tasks;
[0020] Determine the sharing parameter corresponding to the target task according to the output data volume of the target task and the corresponding shared input task, and the data volume of the shared data;
[0021] The corresponding candidate priority is determined according to the shared parameters and storage parameters of the target task.
[0022] In a possible implementation, the method further includes:
[0023] In response to satisfying a preset condition, re-determining the processing priority of the corresponding to-be-processed task in the task queue;
[0024] Update the task queue according to the updated processing priority of the pending tasks.
[0025] In a possible implementation, the preset condition includes that the time from the last task queue update reaches a preset time threshold, or there is a pending task in the task queue to be executed;
[0026] Under the preset condition that there are pending tasks to be executed in the task queue, the processing priority of the corresponding pending tasks in the task queue is re-determined, including:
[0027] Re-determine the routing priority of each pending task in the task queue.
[0028] In a possible implementation, re-determining the processing priority of the corresponding to-be-processed task in the task queue includes:
[0029] For each pending task, determine the duration parameter of the pending task according to the waiting execution duration of the pending task;
[0030] Determine the storage parameters of the task to be processed according to the input data volume and output data volume of the task to be processed;
[0031] Determine the processing priority of the tasks to be processed according to their routing priority, duration parameters, and storage parameters.
[0032] In a possible implementation, re-determining the processing priority of the corresponding to-be-processed task in the task queue further includes:
[0033] When the input data of the task to be processed is shared data, determining the shared parameters of the task to be processed;
[0034] Determine the processing priority of the task to be processed based on its routing priority, duration parameter, and storage parameter, including:
[0035] The processing priority of the task to be processed is determined according to the routing priority, duration parameter, sharing parameter and storage parameter of the task to be processed.
[0036] In a possible implementation, the task to be processed includes any one of an image processing task, a speech processing task, a text processing task, and a video processing task.
[0037] In a second aspect, the present disclosure provides a task processing device for a first processing core, the task processing device comprising:
[0038] An information determination module, configured to determine task information corresponding to the target task when receiving the target task, wherein the task information includes a routing identifier, and the routing identifier is used to indicate a second processing core that uses output data of the target task as input data;
[0039] A priority determination module, used to determine the routing priority of the target task according to the task information, the routing priority being used to define the order in which the output data of the target task is transmitted to the second processing core;
[0040] The task insertion module is used to determine the processing priority of the target task according to the routing priority of the target task, and insert the target task as a to-be-processed task into the task queue of the first processing core, wherein the task queue includes multiple to-be-processed tasks sorted according to corresponding processing priorities.
[0041] In a third aspect, the present disclosure provides an electronic device comprising: a plurality of processing cores; and an on-chip network configured to exchange data between the plurality of processing cores and external data; wherein one or more instructions are stored in one or more of the processing cores, and one or more of the instructions are executed by one or more of the processing cores, so that one or more of the processing cores can perform the above-mentioned task processing method.
[0042] In a fourth aspect, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the above-mentioned task processing method when executed by a processor / processing core.
[0043] The embodiments provided by the present disclosure can determine the routing priority of the received target task by determining the data transmission relationship and data transmission order between different processing cores, and further determine the processing priority of the task based on the routing priority, so as to process the tasks in sequence according to the processing priority, give priority to processing the pending tasks corresponding to the output data that tends to be sent earlier, and reduce the storage time of the data in the processing core.
[0044] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the present disclosure and do not constitute a limitation of the present disclosure. The above and other features and advantages will become more apparent to those skilled in the art by describing detailed example embodiments with reference to the accompanying drawings, in which:
[0046] Figure 1 A schematic diagram of a task processing process provided by an embodiment of the present disclosure;
[0047] Figure 2 A flowchart of a task processing method provided by an embodiment of the present disclosure;
[0048] Figure 3 A schematic diagram of a data routing process between processing cores provided in an embodiment of the present disclosure;
[0049] Figure 4 A schematic diagram of determining candidate priorities provided in an embodiment of the present disclosure;
[0050] Figure 5 A schematic diagram of sharing data provided by an embodiment of the present disclosure;
[0051] Figure 6 A block diagram of a task processing device provided by an embodiment of the present disclosure;
[0052] Figure 7 A block diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0053] In order to enable those skilled in the art to better understand the technical solutions of the present disclosure, the exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0054] In the absence of conflict, the various embodiments of the present disclosure and the various features therein may be combined with each other.
[0055] As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.
[0056] The terms used herein are only used to describe specific embodiments and are not intended to limit the present disclosure. As used herein, the singular forms "a" and "the" are also intended to include plural forms, unless the context clearly indicates otherwise. It will also be understood that when the terms "including" and / or "made of" are used in this specification, the presence of the features, wholes, steps, operations, elements and / or components is specified, but the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof is not excluded. "Connected" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect.
[0057] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and the present disclosure, and will not be interpreted as having an idealized or overly formal meaning unless explicitly defined as such herein.
[0058] The task processing method according to the embodiment of the present disclosure can be executed by an electronic device such as a terminal device or a server, and the terminal device can be a vehicle-mounted device, a user equipment (User Equipment, UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (Personal Digital Assistant, PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. The method can be implemented by a processor calling a computer-readable program instruction stored in a memory. Alternatively, the method can be executed by a server.
[0059] At present, the execution process of neural networks mainly involves the operation of large blocks of tensor data. Each block of tensor data often takes up a large storage space, and some tensor data can be released after being used by the calculation operation to save storage. The order of calculation has a key influence on when a piece of data is generated and when it can be released, which in turn determines the utilization of storage space.
[0060] Figure 1 A schematic diagram of a task processing process provided by an embodiment of the present disclosure. Figure 1 As shown, when the pending tasks to be processed include T1, T2 and T3, the left side is a solution for executing the pending tasks in the order of task reception T1, T2 and T3. This process causes the output data of T1 to be stored during the execution of T2 and before the execution of T3, resulting in too long storage time for the data, which increases the overall storage space occupied. The right side shows the pending tasks after the execution order is adjusted, and the pending tasks are executed in the order of T1, T3 and T2. The output data of T1 is used as the input data of T3, and the output data of T1 can be released after T3 is executed. Compared with the execution order on the left, it can reduce the storage time of some intermediate data and reduce the overall storage space occupied.
[0061] Based on this, the present disclosure proposes a task processing method for rearranging the order of task execution based on a priority queue.
[0062] Figure 2 A flowchart of a task processing method provided by an embodiment of the present disclosure. Figure 2 , the method comprising:
[0063] Step S10: upon receiving the target task, determining the task information corresponding to the target task.
[0064] In a possible implementation, the electronic device of the embodiment of the present disclosure may include a multi-core architecture of multiple processing cores, each processing core may have a task processing function and a data routing function, that is, the storage of a processing core is not only used or generated by the tasks of the processing core, each processing core may receive data sent by other processing cores through routing primitives (routing instructions), and may also send data generated by the processing core to other processing cores. Among them, a task queue may be maintained in each processing core, and the task queue is used to limit the execution order of multiple tasks to be processed in the processing core, that is, it includes multiple tasks to be processed sorted according to corresponding processing priorities. When a target task to be processed is received, the processing core that receives and processes the target task is determined to be the first processing core.
[0065] Optionally, when the first processing core receives the target task, it can simultaneously obtain the task information corresponding to the target task. Among them, the target task of the embodiment of the present disclosure can be any one of an image processing task, a speech processing task, a text processing task, and a video processing task. Alternatively, the target task can also be a step in a task such as an image processing task, a speech processing task, a text processing task, and a video processing task. For example, the target task can be any image processing step such as feature extraction, graph convolution, image denoising, and histogram processing in an image processing task. The process of processing a task by a processing core can be to perform task processing based on input data routed by local storage or other processing cores, and generate corresponding output data after completing the task processing. After completing the processing of a task, if the input data used to process the task is no longer used as input data for other tasks, the input data corresponding to the task can be directly released. When the output data of the task that has been processed is also used as input data for tasks in other processing cores, the local output data can be routed to other processing cores if the preset conditions are met.
[0066] Furthermore, the task information may include a routing identifier, which is used to characterize the second processing core that uses the output data of the target task as input data. That is, the first processing core can determine the processing core that is the routing destination of the output data of the target task as the second processing core by obtaining the routing identifier in the task information. Optionally, the task information may also include other task-related information, such as the input data volume and output data volume of the target task, or any information related to the target task, such as the task type, task content, and task execution method.
[0067] Step S20: Determine the routing priority of the target task according to the task information.
[0068] In a possible implementation, after determining the task information corresponding to the target task, the embodiment of the present disclosure may first determine the routing priority corresponding to the target task according to the task information, and the routing priority is used to limit the order in which the output data of the target task is transmitted to the second processing core. In other words, the output data corresponding to the task with a higher routing priority in the first processing core is transmitted to the second processing core first.
[0069] Optionally, the routing priority in the embodiment of the present disclosure can be determined based on the storage space tension between the first processing core and the second processing core, and the storage space tension is the difference in the space storage between the first processing core and the second processing core. In other words, the method for determining the routing priority can be to first determine the first free storage of the first processing core at the time when the target task is received, and then determine the second free storage of the second processing core at the time when the target task is received based on the routing identifier. According to the first free storage and the second free storage, the routing priority corresponding to the target task is determined. Based on this priority calculation method, the data in the many-core architecture can be stored in the processing core with relatively larger free storage space, reducing the storage pressure in the processing core with small free storage space, effectively scheduling the storage space in the many-core architecture, reducing the possibility of affecting the computing process due to too small free storage space in a single processing core, and improving the storage and computing efficiency in a single processing core.
[0070] The routing priority may be the difference between the second free storage C2 and the first free storage C1. Optionally, in order to maintain the rationality of the priority calculation, the calculated difference may be added with a preset value or a preset mathematical calculation may be performed so that the obtained routing priority is a positive number while maintaining the actual meaning, for example, (C2 -C1) , the present disclosure does not limit the specific calculation method of routing priority.
[0071] For any pending tasks in each processing core, when other tasks are completed, or the data in this processing core is routed to other processing cores, or the data in other processing cores is routed to this processing core, etc., which will cause the free storage of this core to change, the corresponding routing priority can be updated. Furthermore, when the routing priority of a task is greater than the preset priority threshold, the corresponding data routing can be performed, that is, the output data corresponding to the task is routed to other processing cores, otherwise the corresponding output data is saved locally, regardless of whether the task is completed. Alternatively, when the free storage in the second processing core corresponding to the task changes, the routing priority corresponding to the task in the processing core can also be updated.
[0072] In a many-core architecture, the order of data routing operations (including receiving and sending operations) and task processing operations jointly determine the storage time of a data block within a processing core. For each processing core, if it is considered from the perspective of local storage optimization, the processing core can use a selfish strategy (sending priority strategy), and the first processing core immediately sends data to the second processing core after the data is generated. Alternatively, the processing core can also adopt a selfless strategy (receiving priority strategy) for data routing, that is, the first processing core sends data just before the second processing core needs to use the data. Optionally, there are a large number of more balanced strategies between the above two strategies. In order to achieve these balanced strategies, the embodiments of the present disclosure can set routing priorities P between processing cores. R Furthermore, since the data block tends to be transmitted to the second processing core earlier, the storage cost consumed by the first processing core is also smaller. Therefore, the first processing core tends to give priority to processing the task that generates the data block, thereby improving the utilization of storage space and reducing data storage pressure.
[0073] Step S30 : determining the processing priority of the target task according to the routing priority of the target task, and inserting the target task into the task queue of the first processing core as a task to be processed.
[0074] In a possible implementation, since the earlier the output data transmitted from the first processing core to the second processing core is transmitted, the lower the local storage cost is, the routing priority can be used as an influencing parameter for determining the processing priority of the target task, so as to determine the processing priority of the target task according to the routing priority of the target task. The relationship between the routing priority and the processing priority can be a positive correlation, that is, the higher the routing priority is, the higher the processing priority corresponding to the task to be processed is.
[0075] Figure 3 A schematic diagram of a data routing process between processing cores provided in an embodiment of the present disclosure. Figure 3 As shown in the figure, T represents the task processing operation and R represents the data routing operation. The left side shows the task execution order inside the first processing core (core 1 executing T1, T2 and T3) and the second processing core (core 2 executing T4, T5 and T6) when the routing priority is not considered, as well as the data routing order between the two processing cores. The right side shows the task execution order inside the first processing core and the second processing core after considering the routing priority, as well as the data routing order between the two processing cores. In comparison, based on the task execution order on the right side, the storage space inside the first processing core is effectively saved.
[0076] In a possible implementation, there are other factors that affect the order of task execution. In order to further improve the accuracy of determining the processing priority of the target task, the embodiment of the present disclosure can determine the candidate priority corresponding to the target task based on the task information, and then determine the processing priority of the target task based on the routing priority and the candidate priority. The candidate priority is used to preliminarily limit the execution order of the target task in the first processing core. Based on this technical feature, the embodiment of the present disclosure can first preliminarily determine the candidate priority of the target task based on at least one factor that affects the order of task execution, and then modify the candidate priority based on the routing priority to obtain the processing priority, thereby improving the accuracy of the processing priority through multiple different factors. Optionally, the processing priority of the target task can be obtained by calculating the weighted product of the routing priority and the candidate priority, or by other preset generalized formulas. Exemplarily, when the routing priority is P R , when the candidate priority is P′, the processing priority can be δ is the preset weight of the routing priority. Alternatively, we can also use the generalized formula Calculates processing priority.
[0077] Optionally, during the execution of the task, input data will be consumed and output data will be generated, resulting in changes in the free storage space within the processing core. Therefore, the disclosed embodiment can preliminarily determine the candidate priority of the target task based on the data volume of the input data and the output data. That is, when the task information corresponding to the target task includes the input data volume and the output data volume, the candidate priority corresponding to the target task can determine the corresponding storage parameters based on the input data volume and the output data volume of the target task, and then determine the candidate priority of the target task based on the storage parameters. This method of determining the candidate priority introduces the change of the storage space in the first processing core before and after the task processing, improves the reliability of the obtained candidate priority, and then improves the accuracy of the processing priority determined according to the candidate priority.
[0078] Furthermore, after the task is executed, if the input data is no longer used for the processing of other tasks, it can be released directly. If the input data is still used for the processing of other tasks after the task is executed, it needs to continue to be stored in the processing core. Therefore, the amount of consumed data can be determined first according to the type and amount of input data, and then the candidate priority can be more accurately calculated according to the amount of consumed data and the amount of output data. Among them, when the type of input data is dedicated input data, that is, input data that is not shared with other tasks, or the type of input data is shared data shared with other tasks, but other tasks have been completed, the amount of input data can be directly determined as the amount of consumed data. When the type of input data is shared data shared with other tasks, and there are other tasks that have not been executed, the amount of input data can be determined to be 0.
[0079] After obtaining the consumption data volume S1 and output data volume S2 of the target task, the difference between the consumption data volume and the output data volume can be calculated to obtain the storage parameter, and then the candidate priority P' can be determined according to the storage parameter. Optionally, in order to maintain the rationality of the priority calculation, the difference (i.e., the storage parameter) can be added with a preset value or a preset mathematical calculation can be performed to make the obtained candidate priority remain a positive number while maintaining the actual meaning, such as e (S1-S2) , the present disclosure does not limit the specific calculation method of the candidate priority. For example, when the consumption data volume of the target task is S1 and the output data volume is S2, the difference P can be calculated. Δ = S1-S2, and then further directly determine the difference as the candidate priority P′=P Δ , or the weighted value of the difference is the candidate priority α is the preset storage parameter weight, and other generalization functions calculate the candidate priority as
[0080] Figure 4 A schematic diagram of determining candidate priorities provided by an embodiment of the present disclosure. Figure 4 As shown, for the target tasks T1, T2 and T3 to be processed, the differences Δ1, Δ2 and Δ3 between the amount of consumed data and the amount of output data corresponding to each task are calculated as the corresponding candidate priorities P′.
[0081] Figure 5 A schematic diagram of sharing data provided by an embodiment of the present disclosure. Figure 5 As shown, the input data of some tasks in the disclosed embodiment can be shared data, that is, it can be used as input data for multiple tasks at the same time. For example, the input data S1 in the figure can be used as input data for task T1 and task T2 at the same time. After the first task is executed, the input data S1 is still stored. When multiple tasks share an input data block, the storage occupied by the data block can be released only after all these tasks have calculated it. That is, processing T1 or T2 alone will not consume S1. The amount of data consumed corresponding to the task processed first is 0, and the amount of data consumed corresponding to the task processed later is the amount of data of S1.
[0082] Optionally, the disclosed embodiment can release the storage space occupied by shared data as soon as possible by raising the execution priority of the task whose input data is shared data. Specifically, when the input data of the target task is shared data, the addition of a shared parameter can be considered when determining the candidate priority, that is, the target task and other pending tasks that share the input data are treated as a whole, and a shared parameter is added to increase the processing priority corresponding to all unprocessed tasks. Thus, after receiving the target task, the first processing core can determine whether the input data of the target task is shared data. If it is not shared data, the shared parameter is not considered, or the shared parameter is set to 1. When the input data of the target task is shared data, other pending tasks that use the shared data as input data are determined to be shared input tasks. The shared parameter corresponding to the target task is determined based on the output data volume S2 and S3 of the target task and the corresponding shared input task, and the data volume S1 of the shared data. The corresponding candidate priority is determined based on the shared parameter and storage parameter of the target task. Furthermore, the sharing parameter can be determined based on the difference S1-(S2+S3) between the amount of shared data and the sum of the output data of the target task and the shared input task. Optionally, in order to maintain the rationality of the priority calculation, the calculated difference can be added with a preset value or a preset mathematical calculation can be performed so that the obtained sharing parameter is a positive number while maintaining the actual meaning, for example, expressed as e S1-(S2+S3) Based on the introduction of the above-mentioned shared parameters, the storage duration of the shared data can be comprehensively considered to determine the task priority, which further improves the accuracy of the task priority.
[0083] For example, when the target task consumes data S1, outputs data S2, and the input data of the target task is shared data, and the output data of the corresponding shared input task is S3, the difference P can be calculated. Δ = S1-S2 to obtain the storage parameters, and calculate the difference P between the amount of shared data and the sum of the output data of the target task and the shared input task S = S1-(S2+S3) to obtain the shared parameters. Further, the weighted product of the shared parameters and the stored parameters can be calculated to obtain the candidate priority α is the preset storage parameter weight, and γ is the preset shared parameter weight. Alternatively, the candidate priority can be calculated by other generalization functions:
[0084] Further, after determining the processing priority of the target task, the target task can be inserted into the task queue of the first processing core as a to-be-processed task, and the position of the target task in the task queue can be determined according to the corresponding processing priority. The task queue includes multiple to-be-processed tasks with corresponding processing priorities, and the processing priority of each to-be-processed task can be determined by the above-mentioned method of determining the processing priority of the target task.
[0085] When an event occurs in the first processing core that affects the processing priority corresponding to at least one of the pending tasks, the processing priority of the pending task can be re-determined, and its position in the task queue can be adjusted. This method can adjust the task queue in real time and dynamically, and improve the reliability of the task queue. Optionally, multiple preset conditions can be determined according to the event that affects the processing priority corresponding to at least one of the pending tasks, and the processing priority of the corresponding pending task in the task queue can be re-determined when the preset conditions are met. That is, in response to meeting the preset conditions, the processing priority of the corresponding pending task in the task queue is re-determined, and the task queue is updated according to the updated processing priority of the pending task. Among them, the preset conditions can include that the time from the last task queue update reaches a preset time threshold, or there are pending tasks in the task queue that are executed, or the input data corresponding to the newly received target task is shared input data, etc. The present disclosure does not limit the specific setting method of the preset conditions. When the preset condition is that there are pending tasks in the task queue that are executed, since the processing of the task will cause the free storage space inside the first processing core to change, the routing priority of each pending task in the task queue can be re-determined according to the updated first free storage. Furthermore, when the preset condition is that the time from the last task queue update reaches a preset time threshold, the disclosed embodiment can also re-acquire the first free storage and the second free storage corresponding to each pending task in the task queue, and re-determine the corresponding routing priority when at least one of them changes. The setting of the preset condition can timely and accurately determine the time when the task queue needs to be updated, thereby ensuring the timeliness of the task queue.
[0086] Optionally, in order to avoid the starvation problem in the task scheduling within the first processing core, that is, there are tasks that have not been executed for a long time, the waiting time can be added as a duration parameter to increase the execution priority of the task with too long waiting time. Therefore, the waiting execution time of each pending task in the task queue can be periodically counted, and the duration parameter of the pending task can be determined based on the waiting execution time. Further, the storage parameter of the pending task is determined based on the input data volume and output data volume of the pending task. Then, the processing priority of the pending task is determined based on the routing priority, duration parameter and storage parameter of the pending task. Among them, in the case where the routing priority of the pending task is re-determined, the routing priority of the calculated processing priority is the re-determined routing priority. The processing priority can be calculated by weighted product of the routing priority, duration parameter and storage parameter. α is the preset storage parameter P Δ Weight, β is the duration parameter P R The preset weight of δ is the routing priority P R Preset weights, or bring in other preset generalization functions Thus, this process can reduce the probability of starvation by increasing the execution priority of tasks with too long waiting time.
[0087] Furthermore, in the case where the input data of the task to be processed is shared data, redetermining the processing priority of the task to be processed also requires the introduction of shared parameters, that is, determining the shared parameters of the task to be processed, and then determining the processing priority of the task to be processed based on the routing priority, duration parameter, shared parameter and storage parameter of the task to be processed. Among them, in the case where the routing priority of the task to be processed is redetermined, the routing priority of the calculated processing priority is the redetermined routing priority. In the case where the input data of the received target task is shared data, after receiving the target task, the shared parameters of the shared input task corresponding to the target task also need to be redetermined, and then the processing priority of the task to be processed is determined based on the routing priority, duration parameter, shared parameter and storage parameter of the task to be processed. Specifically, the processing priority can be obtained by calculating the weighted product of the routing priority, duration parameter, shared parameter and storage parameter. α is the preset storage parameter P Δ Weight, β is the duration parameter P R The preset weight of δ is the routing priority P R Preset weight, γ is the shared parameter P S Alternatively, you can also bring in other preset generalization functions Thus, this process can reduce the probability of starvation by increasing the execution priority of tasks with too long waiting time.
[0088] In some possible implementations, the processing priority P can be expressed as:
[0089]
[0090] In formula (1), Represents the storage parameter, which is associated with the difference between the amount of data consumed and the amount of data output by the task to be processed; Represents the duration parameter, which is associated with the waiting execution time of the task to be processed; represents a sharing parameter, which is associated with the difference between the amount of shared data of the task to be processed and the sum of the output data of the task to be processed and the shared input task; Indicates the routing priority, and is associated with the difference between the second free storage and the first free storage corresponding to the task to be processed. α, β, γ, δ represent the weights of each parameter respectively, and those skilled in the art can set the weights of each parameter according to actual conditions, and the present disclosure does not limit this.
[0091] Furthermore, the processing priority P can be generalized as follows:
[0092]
[0093] In formula (2), f() represents a generalized function. Those skilled in the art may set the specific type of the generalized function according to actual conditions, and the present disclosure does not limit this.
[0094] Based on the above technical features, the disclosed embodiment can jointly determine the processing priority of tasks from multiple different dimensions, improve the rationality of the sorting results of pending tasks in the task queue, and thus save the data storage efficiency during the task processing process. At the same time, the task queue can also be updated in real time during the task processing process to ensure the real-time reliability of the task queue during the entire task processing process.
[0095] It can be understood that the above-mentioned various method embodiments mentioned in the present disclosure can be combined with each other to form a combined embodiment without violating the principle logic. Due to space limitations, the present disclosure will not repeat them. It can be understood by those skilled in the art that in the above-mentioned method of the specific implementation method, the specific execution order of each step should be determined according to its function and possible internal logic.
[0096] In addition, the present disclosure also provides a task processing device, an electronic device, and a computer-readable storage medium, all of which can be used to implement any task processing method provided by the present disclosure. The corresponding technical solutions and descriptions are referred to the corresponding records in the method part and will not be repeated here.
[0097] Figure 6 A block diagram of a task processing device provided in an embodiment of the present disclosure.
[0098] Reference Figure 6 , an embodiment of the present disclosure provides a task processing device, the task processing device comprising:
[0099] An information determination module 60 is used to determine task information corresponding to the target task when receiving the target task, wherein the task information includes a routing identifier, and the routing identifier is used to represent the second processing core that uses the output data of the target task as input data;
[0100] A priority determination module 61, used to determine the routing priority of the target task according to the task information, and the routing priority is used to define the order in which the output data of the target task is transmitted to the second processing core;
[0101] The task insertion module 62 is used to determine the processing priority of the target task according to the routing priority of the target task, and insert the target task as a to-be-processed task into the task queue of the first processing core, wherein the task queue includes a plurality of to-be-processed tasks sorted according to corresponding processing priorities.
[0102] In a possible implementation, the priority determination module 61 is further configured to:
[0103] Determining a first free memory of the first processing core at the time when the target task is received;
[0104] Determine, according to the routing identifier, a second idle storage of the second processing core at the time when the target task is received;
[0105] A routing priority corresponding to the target task is determined according to the first free storage and the second free storage.
[0106] In a possible implementation, the task insertion module 62 is further configured to:
[0107] Determine the candidate priority corresponding to the target task according to the task information;
[0108] The processing priority of the target task is determined according to the routing priority and the candidate priority.
[0109] In a possible implementation, the task information further includes the input data volume and the output data volume of the target task, and the task insertion module 62 is further configured to:
[0110] Determine the corresponding storage parameters according to the input data volume and output data volume of the target task;
[0111] Determine candidate priorities for target tasks based on storage parameters.
[0112] In a possible implementation, the task insertion module 62 is further configured to:
[0113] In the case where the input data of the target task is shared data, determining other tasks to be processed that use the shared data as input data as shared input tasks;
[0114] Determine the sharing parameter corresponding to the target task according to the output data volume of the target task and the corresponding shared input task, and the data volume of the shared data;
[0115] The corresponding candidate priority is determined according to the shared parameters and storage parameters of the target task.
[0116] In a possible implementation, the device further includes:
[0117] A priority updating module, for re-determining the processing priority of the corresponding to-be-processed task in the task queue in response to satisfying a preset condition;
[0118] The queue update module is used to update the task queue according to the updated processing priority of the pending tasks.
[0119] In a possible implementation, the preset condition includes that the time from the last task queue update reaches a preset time threshold, or there is a pending task in the task queue to be executed;
[0120] When the preset condition is that there are pending tasks in the task queue to be executed, the priority updating module is further used to:
[0121] Re-determine the routing priority of each pending task in the task queue.
[0122] In a possible implementation, the priority updating module is further used to:
[0123] For each pending task, determine the duration parameter of the pending task according to the waiting execution duration of the pending task;
[0124] Determine the storage parameters of the task to be processed according to the input data volume and output data volume of the task to be processed;
[0125] Determine the processing priority of the tasks to be processed according to their routing priority, duration parameters, and storage parameters.
[0126] In a possible implementation, the priority updating module is further used to:
[0127] When the input data of the task to be processed is shared data, determining the shared parameters of the task to be processed;
[0128] Determine the processing priority of the task to be processed based on its routing priority, duration parameter, and storage parameter, including:
[0129] The processing priority of the task to be processed is determined according to the routing priority, duration parameter, sharing parameter and storage parameter of the task to be processed.
[0130] In a possible implementation, the task to be processed includes any one of an image processing task, a speech processing task, a text processing task, and a video processing task.
[0131] Figure 7 A block diagram of an electronic device provided in an embodiment of the present disclosure.
[0132] Reference Figure 7 An embodiment of the present disclosure provides an electronic device, which includes multiple processing cores 1001 and an on-chip network 1002, wherein the multiple processing cores 1001 are connected to the on-chip network 1002, and the on-chip network 1002 is used to exchange data between the multiple processing cores and external data.
[0133] One or more instructions are stored in one or more processing cores 1001, and the one or more instructions are executed by one or more processing cores 1001, so that one or more processing cores 1001 can execute the above-mentioned task processing method.
[0134] In some embodiments, the electronic device may be a brain-like chip, which can use vectorized computing and needs to load the weight information and other parameters of the neural network model through an external memory such as a double data rate (DDR) synchronous dynamic random access memory. Therefore, the batch processing used in the embodiments of the present disclosure has a higher computing efficiency.
[0135] The present disclosure also provides a computer-readable storage medium on which a computer program is stored, wherein the computer program implements the above-mentioned task processing method when executed by a processor / processing core. The computer-readable storage medium may be a volatile or non-volatile computer-readable storage medium.
[0136] The embodiment of the present disclosure also provides a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above-mentioned task processing method.
[0137] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In a hardware implementation, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable storage medium, which may include a computer storage medium (or a non-transitory medium) and a communication medium (or a temporary medium).
[0138] As is known to those of ordinary skill in the art, the term computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable program instructions, data structures, program modules or other data). Computer storage media include, but are not limited to, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), static random access memory (SRAM), flash memory or other memory technology, portable compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. In addition, it is known to those of ordinary skill in the art that communication media typically contain computer-readable program instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and may include any information delivery medium.
[0139] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0140] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.
[0141] The computer program product described herein may be implemented in hardware, software, or a combination thereof. In one optional embodiment, the computer program product is embodied as a computer storage medium, and in another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (SDK), etc.
[0142] Various aspects of the present disclosure are described herein with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.
[0143] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0144] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0145] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.
[0146] Example embodiments have been disclosed herein, and although specific terms are employed, they are used and should be interpreted only in a general illustrative sense and not for limiting purposes. In some instances, it will be apparent to those skilled in the art that, unless otherwise expressly noted, features, characteristics, and / or elements described in conjunction with a particular embodiment may be used alone or in combination with features, characteristics, and / or elements described in conjunction with other embodiments. Therefore, those skilled in the art will appreciate that various changes in form and detail may be made without departing from the scope of the present disclosure as set forth in the appended claims.
Claims
1. A task processing method, characterized in that: The method is applied to a first processing core and includes: When receiving a target task, determining task information corresponding to the target task, wherein the task information includes a routing identifier, and the routing identifier is used to represent a second processing core that uses output data of the target task as input data; Determine a routing priority of the target task according to the task information, wherein the routing priority is used to define an order in which output data of the target task is transmitted to the second processing core; The processing priority of the target task is determined according to the routing priority of the target task, and the target task is inserted into the task queue of the first processing core as a to-be-processed task, wherein the task queue includes a plurality of to-be-processed tasks sorted according to corresponding processing priorities.
2. The method according to claim 1, characterized in that Determining the routing priority of the target task according to the task information includes: Determine a first free memory of the first processing core at the time when the target task is received; Determine, according to the routing identifier, a second idle storage of the second processing core at the time when the target task is received; A routing priority corresponding to the target task is determined according to the first free storage and the second free storage.
3. The method according to claim 1, characterized in that Determining the processing priority of the target task according to the routing priority of the target task includes: Determine the candidate priority corresponding to the target task according to the task information; The processing priority of the target task is determined according to the routing priority and the candidate priority.
4. The method according to claim 3, characterized in that The task information also includes the input data volume and the output data volume of the target task. The determining the candidate priority corresponding to the target task according to the task information includes: Determine corresponding storage parameters according to the input data volume and output data volume of the target task; A candidate priority of the target task is determined according to the stored parameters.
5. The method according to claim 3, characterized in that: The determining, according to the task information, the candidate priority corresponding to the target task includes: In a case where the input data of the target task is shared data, determining other tasks to be processed that use the shared data as input data as shared input tasks; Determine the sharing parameter corresponding to the target task according to the output data volume of the target task and the corresponding shared input task, and the data volume of the shared data; The corresponding candidate priority is determined according to the shared parameters and storage parameters of the target task.
6. The method according to claim 1, characterized in that The method further comprises: In response to satisfying a preset condition, re-determining the processing priority of the task to be processed in the task queue; The task queue is updated according to the updated processing priority of the to-be-processed task.
7. The method according to claim 6, characterized in that The preset conditions include that the time from the last task queue update reaches a preset time threshold, or there are pending tasks in the task queue to be executed; When the preset condition is that there are pending tasks being executed in the task queue, re-determining the processing priority of the pending tasks in the task queue includes: Re-determine the routing priority of each of the to-be-processed tasks in the task queue.
8. The method according to claim 7, characterized in that The re-determining the processing priority of the task to be processed in the task queue includes: For each of the tasks to be processed, determining a duration parameter of the task to be processed according to the waiting execution duration of the task to be processed; Determining storage parameters of the task to be processed according to the input data volume and output data volume of the task to be processed; The processing priority of the task to be processed is determined according to the routing priority, duration parameter and storage parameter of the task to be processed.
9. The method according to claim 8, characterized in that The re-determining the processing priority of the task to be processed in the task queue also includes: In a case where the input data of the task to be processed is shared data, determining a shared parameter of the task to be processed; Determining the processing priority of the task to be processed according to the routing priority, duration parameter and storage parameter of the task to be processed includes: The processing priority of the task to be processed is determined according to the routing priority, duration parameter, sharing parameter and storage parameter of the task to be processed.
10. A task processing device, the device being applied to a first processing core, comprising: An information determination module, configured to determine task information corresponding to the target task when receiving the target task, wherein the task information includes a routing identifier, and the routing identifier is used to represent a second processing core that uses output data of the target task as input data; a priority determination module, configured to determine a routing priority of the target task according to the task information, wherein the routing priority is used to define an order in which output data of the target task is transmitted to the second processing core; The task insertion module is used to determine the processing priority of the target task according to the routing priority of the target task, and insert the target task as a to-be-processed task into the task queue of the first processing core, wherein the task queue includes multiple to-be-processed tasks sorted according to corresponding processing priorities.
11. An electronic device, characterized in that: include: Multiple processing cores; as well as An on-chip network is configured to exchange data between the multiple processing cores and external data; wherein one or more instructions are stored in one or more of the processing cores, and one or more of the instructions are executed by one or more of the processing cores, so that one or more of the processing cores can execute the task processing method described in any one of claims 1-9.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the computer program implements the task processing method according to any one of claims 1 to 9.