Task scheduling method, device, electronic device and computer readable storage medium

By allocating and updating the task segments of the processing core through the microprocessor, the problems of inflexible task scheduling and complex control of the processing core in the existing technology are solved, and more efficient task scheduling and stronger data processing capabilities are achieved.

CN113360186BActive Publication Date: 2024-10-18STREAM COMPUTING INC
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202010141104.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-03-04
Publication Date
2024-10-18
Estimated Expiration
2040-03-04

AI Technical Summary

Technical Problem

In the existing technology, the task scheduling of processing cores is inflexible and the control is complex, which results in the chip being inefficient when processing diverse data and unable to fully utilize the computing power of multi-core processing.

Method used

Through the microprocessor, the task segment of the processing core is allocated and updated, and the task segment allocation instruction and task segment update message mechanism are used to realize task allocation and cooperation between the processing cores, dynamically adjust the task segment size and allocation strategy, and improve the flexibility of task scheduling. sex and efficiency.

Benefits of technology

The task scheduling flexibility and efficiency of the processing core are improved, the power consumption and area of ​​the chip are reduced, the processing capability of large-scale data is enhanced, and the problems of task scheduling complexity and low efficiency in the existing technology are solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113360186B_ABST
    Figure CN113360186B_ABST
Patent Text Reader

Abstract

The embodiment of the present disclosure discloses a task scheduling method, device, electronic device and computer-readable storage medium. The task scheduling method includes: in response to executing a task segment allocation instruction, the microprocessor instructs to send a task segment to the processing core, wherein the task segment is a part of the task; in response to completing the execution of the task segment, the processing core sends a task segment update message to the microprocessor; in response to receiving the task segment update message, the microprocessor executes the task segment allocation instruction to instruct to send the next task segment to the processing core, and the task segment allocation instruction is an instruction generated by the microprocessor after being configured according to the task segment update message. By allocating and updating the task segment of the processing core by the microprocessor in the chip in the above method, the technical problems of inflexible task scheduling and complex control of the processing core in the prior art are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of processors, and in particular to a task scheduling method, device, electronic device, and computer-readable storage medium. Background Art

[0002] With the development of science and technology, human society is rapidly entering the intelligent era. An important feature of the intelligent era is that people obtain more and more types of data, the amount of data obtained is increasing, and the speed of processing data is getting higher and higher. Chips are the cornerstone of task scheduling, which fundamentally determines people's ability to process data. From the perspective of application fields, there are two main routes for chips: one is the general chip route, such as CPU, etc., which can provide great flexibility, but the effective computing power is relatively low when processing algorithms in specific fields; the other is the dedicated chip route, such as TPU, etc., which can play a higher effective computing power in certain specific fields, but in the face of flexible and changeable more general fields, their processing capabilities are relatively poor or even unable to process. Due to the wide variety and huge amount of data in the intelligent era, chips are required to have both extremely high flexibility, able to process algorithms in different fields and changing with each passing day, and extremely strong processing capabilities, able to quickly process huge and rapidly growing amounts of data.

[0003] In neural network calculations, multi-core or multi-core chips are often used. How to make many processing cores efficiently exert their computing power is the key to determining the performance of the entire chip. The computing power of each processing core depends on many factors, such as task scheduling and allocation, chip architecture, processing core structure, processing core circuits, etc. Among them, task scheduling and allocation is a very critical factor. If the scheduling and allocation of tasks are reasonable, the effective computing power of each processing core can be fully utilized.

[0004] In the prior art, the following two solutions are generally used to schedule core tasks:

[0005] like Figure 1aThe figure shows a scheme for using a scheduler to schedule tasks. In this scheme, the scheduler receives instructions from an instruction source, and then transmits the instructions to each processing core according to a certain strategy, such as sequence. Each processing core executes the same instruction but processes different data. Each processing core can be a relatively simple structure, such as SIMD (Single Instruction Multiple Data) with shared control circuits and registers, or a relatively complex structure with a certain degree of autonomy, such as SIMT (Single Instruction Multiple Threads) with independent control circuits and registers. However, in this scheme, the scheduler can only passively receive instructions from an external instruction source and then distribute them to each processing core. It has a single function and lacks flexibility. Regardless of whether it is a SIMD structure or a SIMT structure, each processing core can only execute the same instruction, and each processing core has a small degree of freedom and simple control.

[0006] like Figure 1b The figure shows a solution where the processing cores independently execute tasks. In this solution, each processing core can independently read instructions from the memory and perform operations; each processing core has a complete control circuit, register group and other circuits. However, for this solution, it is difficult for each processing core to cooperate with each other to efficiently complete a complete task; the circuit control is complex, and each core is almost a complete CPU, which is difficult to design, and has large power consumption and area; multiple processing cores may frequently access the instruction storage area, causing a decrease in storage access efficiency, which in turn affects the performance of the chip computing power. Summary of the invention

[0007] This summary is provided to introduce concepts in a brief form that will be described in detail in the detailed description below. This summary is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.

[0008] In order to solve the technical problems of inflexible task scheduling and complex control of processing cores in the prior art, the embodiments of the present disclosure propose the following technical solutions:

[0009] In a first aspect, an embodiment of the present disclosure provides a task scheduling method, including:

[0010] In response to executing a task segment allocation instruction, the microprocessor instructs sending a task segment to the processing core, wherein the task segment is a part of the task;

[0011] In response to completing the execution of the task segment,

[0012] The processing core sends a task segment update message to the microprocessor;

[0013] In response to receiving the task segment update message, the microprocessor executes the task segment allocation instruction to instruct sending the next task segment to the processing core, and the task segment allocation instruction is an instruction generated by the microprocessor after being configured according to the task segment update message.

[0014] Further, in response to executing the task segment allocation instruction, the microprocessor instructs to send the task segment to the processing core, including:

[0015] The microprocessor executes its own program, and the own program includes the task segment allocation instruction;

[0016] In response to executing the task segment allocation instruction, the microprocessor instructs the storage controller to read the task segment from the external memory and send the task segment to the processing core.

[0017] Further, the microprocessor instructs the storage controller to read the task segment from the external memory and send it to the processing core, including:

[0018] The microprocessor obtains the size of the storage space of the processing core;

[0019] The microprocessor instructs the storage controller to read out the task segment matching the storage space size of the processing core from the memory and send the task segment to the processing core.

[0020] Furthermore, the chip includes at least two processing cores for executing the tasks, and the microprocessor performs allocation of the task segments and update of the task segments for the at least two processing cores.

[0021] Further, in response to executing the task segment allocation instruction, the microprocessor instructs to send the task segment to the processing core, including:

[0022] In response to executing the task segment allocation instruction, the microprocessor determines the processing core indicated by the task segment allocation instruction;

[0023] The microprocessor instructs sending the task segment to the instructed processing core.

[0024] Furthermore, the task segment update message includes different task segment update messages generated by the at least two processing cores executing the task.

[0025] Furthermore, the microprocessor includes a counter, and the processing core corresponds to at least one of the counters.

[0026] Wherein, after the microprocessor instructs to allocate the task segment or instructs to allocate the next task segment, the method further includes:

[0027] The microprocessor starts the counter to record the number of task segments that have been allocated to the processing core that executes the task;

[0028] In response to the number of the assigned task segments of the processing core reaching a preset threshold, the counter is reset.

[0029] In a second aspect, an embodiment of the present disclosure provides a chip, including:

[0030] A processing core, wherein the processing core is used to execute tasks;

[0031] a microprocessor, the microprocessor being used for instructing to send the task segment to the processing core in response to executing the task segment allocation instruction;

[0032] A storage controller is used to retrieve a task segment corresponding to the instruction from an external storage space based on the instruction of the microprocessor, and send the task segment to the processing core.

[0033] Furthermore, the processing core is also used for:

[0034] In response to completing the execution of the task segment, sending a task segment update message to the microprocessor;

[0035] The microprocessor is also used to: in response to receiving the task segment update message, execute the task segment allocation instruction to instruct sending the next task segment to the processing core, and the task segment allocation instruction is an instruction generated by the microprocessor after being configured according to the task segment update message.

[0036] Furthermore, the processing core also includes an internal storage space, and the internal storage space is used to store the task segments.

[0037] Furthermore, the chip includes multiple processing cores; the microprocessor is used to determine the processing core corresponding to the task segment update message based on the received task segment update message, and execute the task segment allocation instruction to instruct the storage controller to send the next task segment corresponding to the processing core to the processing core, wherein the task segment allocation instruction is an instruction generated after the configuration according to the task segment update message.

[0038] In a third aspect, an embodiment of the present disclosure provides an electronic device, comprising: a memory for storing computer-readable instructions; and one or more processors for executing the computer-readable instructions, so that when the processor is running, any task scheduling method described in the first aspect is implemented.

[0039] In a fourth aspect, an embodiment of the present disclosure provides a non-transitory computer-readable storage medium, characterized in that the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute any task scheduling method described in the first aspect.

[0040] In a fifth aspect, an embodiment of the present disclosure provides a computer program product, characterized in that it includes computer instructions, and when the computer instructions are executed by a computing device, the computing device can execute any task scheduling method described in the first aspect.

[0041] In a sixth aspect, an embodiment of the present disclosure provides a computing device, characterized in that it includes any chip described in the second aspect.

[0042] The embodiment of the present disclosure discloses a task scheduling method, device, electronic device and computer-readable storage medium. The task scheduling method includes: in response to executing a task segment allocation instruction, the microprocessor instructs to send a task segment to the processing core, wherein the task segment is a part of the task; in response to completing the execution of the task segment, the processing core sends a task segment update message to the microprocessor; in response to receiving the task segment update message, the microprocessor executes the task segment allocation instruction to instruct to send the next task segment to the processing core, and the task segment allocation instruction is an instruction generated by the microprocessor after being configured according to the task segment update message. By allocating and updating the task segment of the processing core by the microprocessor in the chip in the above method, the technical problems of inflexible task scheduling and complex control of the processing core in the prior art are solved.

[0043] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the following preferred embodiments are specifically cited and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.

[0045] Figure 1a-1b It is a schematic diagram of the prior art of the present disclosure;

[0046] Figure 2 A flowchart of an embodiment of a task scheduling method provided by the present disclosure;

[0047] Figure 3A schematic diagram of the structure of the chip provided by the present disclosure;

[0048] Figure 4 A schematic diagram of the structure of an example of a chip provided by the present disclosure;

[0049] Figure 5 A schematic diagram of a neural network computing task performed by a chip example provided in the present disclosure;

[0050] Figure 6 A schematic diagram of a core pipeline calculation process when a chip example provided by the present disclosure executes a scheduling method;

[0051] Figure 7 A timing diagram of a microprocessor and a processing core when the chip example provided in the present disclosure executes a scheduling method. DETAILED DESCRIPTION

[0052] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0053] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0054] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0055] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0056] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0057] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0058] Figure 2 This is a flowchart of a task scheduling method embodiment provided by an embodiment of the present disclosure. The task scheduling method provided by this embodiment is used in a chip, wherein the chip includes a processing core and a microprocessor. Figure 2 As shown, the method comprises the following steps:

[0059] Step S201, in response to executing a task segment allocation instruction, the microprocessor instructs to send a task segment to the processing core, wherein the task segment is a part of the task;

[0060] In this embodiment, in addition to executing its own program and completing normal functions, the microprocessor is also used to allocate task segments to the processing core of the chip. The task segment is a part of a complete task. The complete task is pre- or dynamically divided into multiple task segments for storage and execution by the processing core. When the microprocessor executes a task segment allocation instruction, it issues an instruction to instruct other components to send the corresponding task segment to the processing core.

[0061] Optionally, the step S201 includes: the microprocessor executes its own program, the self-program includes a task segment allocation instruction; in response to executing the task segment allocation instruction, the microprocessor instructs the storage controller to read the task segment from the external memory and send it to the processing core.

[0062] Most of the time, the microprocessor executes its own program to complete other computing tasks, and the program includes a task segment allocation instruction, which can be a general allocation instruction, and when executed, it is necessary to obtain the parameters of the instruction, such as the target processing core to which the task segment is allocated and the storage location of the task segment in the memory, etc. Exemplarily, the memory controller is a DMAC (Direct Memory Access Controller, DMA controller), which can directly read the task segment from the external memory and send it to the corresponding processing core without the involvement of the microprocessor.

[0063] Optionally, the complete task can be pre-divided into multiple task segments. In this case, the size of each task segment and its storage starting address will be obtained in advance. When the task segment allocation instruction is executed, the task segment can be obtained from the external memory according to the size and starting address of the task segment.

[0064] Optionally, the complete task segment can be dynamically divided into multiple task segments, that is, the number and size of the task segments are uncertain before allocation. At this time, the microprocessor instructs the storage controller to read the task segment from the external memory and send it to the processing core, including: the microprocessor obtains the size of the storage space of the processing core; the microprocessor instructs the storage controller to read the task segment matching the size of the storage space of the processing core from the memory and send it to the processing core. Each processing core has its own storage space, and the available size of the storage space may be different. Therefore, when the microprocessor instructs the processing core to allocate a task segment, the microprocessor first obtains the size of the storage space of the processing core, determines the size of the task segment by the size of the storage space, and then determines the range of the task segment sent to the processing core in the entire task by the first address of the task segment and the size of the task segment. After the current task segment is determined, the first address of the next task segment is also determined for the allocation of the next task segment. Optionally, the dynamic allocation can be implemented as dynamic allocation each time, that is, the size of the storage space of the processing core is obtained each time the task segment allocation instruction is executed; or the dynamic allocation can also be dynamic allocation only for the first time, that is, it is considered that the storage space size of the processing core is fixed when executing the task, and when the task segment is allocated for the first time, the complete task is divided into multiple task segments according to the storage space size of the processing core and the size of the complete task, and then each time the task segment is allocated to the processing core according to the size of the task segment divided this time.

[0065] Step S202, in response to completing the execution of the task segment, the processing core sends a task segment update message to the microprocessor;

[0066] Upon receiving a task segment, the processing core begins executing instructions in the task segment to complete the task segment.

[0067] Optionally, the step S202 includes: in response to the completion of the execution of the task segment, the processing core executes a task segment update instruction; the processing core generates a task segment update message according to the task segment update instruction; the processing core sends the task segment update message to the processor, wherein, when generating the task segment, a task segment update instruction may be added to each task segment to indicate that the task segment is completed and the next task segment may be received. When the processing core completes the execution of the assigned task segment, the last task segment update instruction of the task segment is executed to generate a task segment update message, which is used for information transmission between the processing core and the microprocessor.

[0068] After generating the task segment update message, the processing core sends the task segment update message to the microprocessor so that the microprocessor allocates a new task segment for it. The task segment update message carries the identification or address information of the processing core that generates the task segment update message, and the task segment update message may also include the number information of the executed task segment.

[0069] Step S203, in response to receiving the task segment update message, the microprocessor executes the task segment allocation instruction to instruct sending the next task segment to the processing core, and the task segment allocation instruction is an instruction generated by the microprocessor after being configured according to the task segment update message.

[0070] When the microprocessor receives the task segment update message, it calls the task segment allocation instruction, which includes the parameters of the next task, including the processing core, the task segment address or size, etc. The task segment allocation instruction is used to instruct the next task segment to be sent to the processing core that issued the task segment update message. The parameters of the next task in the task segment allocation instruction are configured by the parameters in the task segment update message.

[0071] Optionally, step S203 includes: in response to receiving the task segment update message, the microprocessor executes the task segment allocation instruction to instruct the storage controller to fetch the next task segment from the external memory and send the next task segment to the processing core. As in step S202, the storage controller here is exemplarily a DMAC (Direct Memory Access Controller, DMA controller), and the process of allocating a new task segment is the same as the process of allocating a task segment before, which will not be repeated here.

[0072] Optionally, in the task scheduling method, the chip includes at least two processing cores for executing the task, and the microprocessor allocates and updates the task segments for the at least two processing cores. For each processing core for executing the task, the microprocessor and the microprocessor can perform the steps S201 to S203 above, and the microprocessor can asynchronously allocate and update the task segments to the at least two processing cores.

[0073] Furthermore, the step S201 further includes: in response to executing the task segment allocation instruction, the microprocessor determines the processing core indicated by the task segment allocation instruction; and the microprocessor instructs to send the task segment to the indicated processing core.

[0074] In this embodiment, when the task segment allocation instruction is the first task segment allocation instruction executed by the microprocessor when it is first started, the instruction parameters are pre-set in the instruction, and these instruction parameters are used to indicate which processing cores the task segments are assigned to. The task segment allocation instruction can divide different tasks into different numbers of segments, and distribute them to different processing cores, which are processed in parallel by different processing cores. Exemplarily, there are two processing cores in the chip that execute the task, and the task segment allocation instruction can divide the complete task into four segments, which are successively assigned to one processing core for execution; the complete task can also be first divided into two parts, each of which is executed by one processing core, and each part is divided into four task segments, that is, each processing core processes four task segments, and when there is no data correlation between the task segments executed by the two processing cores, the two processing cores can process the task segments in parallel. At this time, the microprocessor will instruct the storage controller to read the task segments from the external memory and send them to the corresponding processing cores.

[0075] Furthermore, the task segment update message includes different task segment update messages generated by the at least two processing cores that execute the task. In the task segment update process, the two processing cores generate task segment update messages respectively after executing the task segments assigned to them respectively. The task segment update messages include parameters required by the task segment allocation instruction, such as the identification information of the processing core and the numbering information of the task segment, etc. In this way, after receiving different update messages, the microprocessor will call the task segment allocation instruction to instruct the storage controller to allocate the next task segment to the corresponding processing core until the complete task is executed.

[0076] Since the task is processed in segments, the microprocessor needs to know when the task is completed in order to assign other tasks to the processing core. In order to determine whether the task is completed, optionally, in the task scheduling method, the microprocessor also includes a counter, and the processing core corresponds to at least one of the counters, wherein after the microprocessor indicates the allocation of task segments or indicates the allocation of new task segments, it also includes: the microprocessor starts the counter to record the number of task segments that have been allocated to the processing core that executes the task; in response to the number of the allocated task segments of the processing core reaching a preset threshold, the counter is reset. Exemplarily, a task is divided into four task segments and executed by a processing core. When the first task segment is allocated to the processing core, the counter corresponding to the processing core is started and the value of the counter is set to 1. After that, each time a task segment update message is received and an instruction is given to send a new task segment to the processing core, the value of the counter is accumulated by 1 until the value of the counter reaches 4, and the counter is reset to indicate that the task of the processing core has been completed. When multiple processing cores complete a task together, the value of the counter corresponding to each processing core must reach its preset threshold to indicate the completion of the entire task. When the counter corresponding to a processing core reaches its preset threshold, it indicates that part of the tasks executed by the processing core has been completed, and the processing core can be assigned a new task.

[0077] Optionally, in addition to using the counter to determine whether a task is completed, a task segment update instruction containing parameters indicating task completion may be added to the last task segment of each task. For example, parameters indicating task completion may be added to the task segment update instruction of the last task segment executed by each processing core that executes the task. When the microprocessor receives a task segment update message containing parameters indicating task completion, it determines that the task of the processing core has been completed, and may call a task segment allocation instruction to allocate task segments of other tasks to the processing core.

[0078] The above embodiment discloses a task scheduling method, which is used in a chip, wherein the chip includes a processing core and a microprocessor, wherein the task scheduling method includes: in response to executing a task segment allocation instruction, the microprocessor instructs to send a task segment to the processing core, wherein the task segment is a part of the task; in response to completing the execution of the task segment, the processing core sends a task segment update message to the microprocessor; in response to receiving the task segment update message, the microprocessor executes the task segment allocation instruction to instruct to send the next task segment to the processing core, wherein the task segment allocation instruction is an instruction generated by the microprocessor after being configured according to the task segment update message. By allocating and updating the task segment of the processing core by the microprocessor in the chip in the above method, the technical problems of inflexible task scheduling and complex control of the processing core in the prior art are solved.

[0079] In the above, although the various steps in the above method embodiment are described in the above order, those skilled in the art should be aware that the steps in the embodiments of the present disclosure are not necessarily executed in the above order, and they may also be executed in other orders such as reverse order, parallel order, and cross order. Moreover, on the basis of the above steps, those skilled in the art may also add other steps. These obvious variations or equivalent replacement methods should also be included in the protection scope of the present disclosure and will not be repeated here.

[0080] Figure 3 This is a schematic diagram of the structure of the chip provided by the embodiment of the present disclosure. Figure 3 The chip 300 shown includes: a processing core 301, a microprocessor 302 and a storage controller 303. The processing core is used to execute tasks; the microprocessor is used to instruct to send a task segment to the processing core in response to executing a task segment allocation instruction; the storage controller is used to retrieve the task segment corresponding to the instruction from the external storage space based on the instruction of the microprocessor, and send the task segment to the processing core. The processing core also includes an internal storage space PRAM, and the internal storage space is used to store the task segment.

[0081] Furthermore, the processing core is also used to: in response to completing the execution of the task segment, send the task segment update message to the microprocessor; the microprocessor is also used to: in response to receiving the task segment update message, execute a task segment allocation instruction to instruct sending the next task segment to the processing core, wherein the task segment allocation instruction is an instruction generated after configuring the task segment update message.

[0082] Furthermore, the chip includes multiple processing cores; the microprocessor is used to determine the processing core corresponding to the task segment update message based on the received task segment update message, and execute the task segment allocation instruction to instruct sending the next task segment to the processing core, wherein the task segment allocation instruction is an instruction generated after the configuration according to the task segment update message.

[0083] like Figure 3As shown, the task segments executed by the processing core are scheduled by the microprocessor 302; the microprocessor assigns tasks to each processing core according to a certain strategy. The scheduling strategy of the task is set outside the microprocessor, typically in an external memory or other host. During initialization, the microprocessor reads the scheduling strategy from the outside to execute the scheduling method. Usually, the microprocessor can execute its own program. The scheduling strategy of a complete task starts with the task segment assignment instruction PSend. When the first PSend instruction is executed, the storage controller is instructed to assign the task segment to the corresponding processing core according to the PSend instruction. At this time, the microprocessor configures the storage controller to read the corresponding task segment from the external memory 304 and send it to the corresponding processing core. The processing core includes an internal storage space PRAM for storing the task segment; the task segment consists of a series of instructions. The processing core reads the instructions from the PRAM, decodes the instructions, and then executes the instructions, without having to read the instructions from the external memory. The storage space of the PRAM of each processing core is limited, so a complete task needs to be divided into multiple task segments for execution. After the processing core executes the task segment, it needs to notify the microprocessor to update the task segment. Therefore, at the end of each task segment, there will be a task segment update instruction PUpdate to trigger the update step. The processing core generates a task segment update message Msg through PUpdate and sends it to the microprocessor. After the microprocessor receives the task segment update message sent by the processing core, it starts the PSend instruction and configures the storage controller according to the parameters in the task segment update message to take the new task segment from the external memory and send it to the processing core. In other times when the PSend instruction is not executed, the microprocessor can perform other processing without being idle like a dedicated scheduler, which improves the execution efficiency of the microprocessor.

[0084] The following is an actual application scenario to illustrate the scheduling process in the present disclosure. Figure 4 The figure shows an example of the chip described in the embodiment of the present disclosure. In this example, the chip includes two processing cores C1 and C2, a microprocessor, and a memory controller, wherein the memory is connected to an external memory.

[0085] The microprocessor is used for scheduling tasks, and the tasks are computing tasks of a two-layer neural network, such as Figure 5As shown, the neural network in this example includes two layers, layer1 and layer2, where layer1 receives input data and calculates, and inputs the calculation result into layer2, which calculates the data input from layer1 to obtain the final output. The size of the calculation program of each layer is 128KB, and the amount of calculation of each layer is the same. Therefore, the entire network can be allocated to two processing cores for pipeline calculation according to the evenly distributed task allocation strategy, that is, C1 and C2 are responsible for the calculation of one layer of the network, and each runs the calculation program of the corresponding layer. The input data is input to C1, and C1 will process the input data according to the calculation program of the first layer, and send the processing result to C2. C2 takes the processing result of the first layer as input, processes it according to the calculation program of the second layer, obtains the final result and outputs it.

[0086] The process of pipeline calculation is as follows: Figure 6 As shown, at time t1, C1 receives the first segment of input data, processes the input data according to the calculation program of the first layer, and outputs the processing result to C2. It should be noted that at this time, C1 executes a part of the calculation program, that is, the above-mentioned task segment, so it outputs only a part of the processing result. At time t2, C1 continues to receive input data, processes the input data according to the task segment it executes, and outputs the processing structure to C2; and at time t2, C2 processes the output result of C1 at time t1 according to the output result of C1 at time t1 and the task segment executed on C2 to obtain a partial output result; and so on, until the entire task calculation is completed and the final output result is obtained.

[0087] In this example, the size of the PRAM of each core is 32KB, and the computing program of each layer is 128KB, so the computing program of each layer needs to be scheduled according to a certain strategy to update the programs executed by the two cores. For example, in this example, the computing program of each processing core is divided into 4 parts, that is, each processing core processes 4 task segments, and the entire two-layer computing program is divided into 8 task segments, and the size of each task segment is 32KB.

[0088] The two processing cores are independent of each other when executing task segments. They have data correlation, such as C2 needs to wait for C1's output data as its input data, but they are independent of each other when receiving task segments, executing task segments, and updating task segments. Therefore, the following takes the scheduling of C1's task segments as an example to illustrate the task scheduling process. Figure 7 The timing diagram for processing core tasks. Figure 7As shown, initially, the microprocessor runs its own program until it executes the task segment allocation instruction PSend. The task segment allocation instruction is a general instruction that can be used by any task. It only needs to assign different parameters to the PSend to indicate which task it is scheduling. When the first PSend instruction is executed, according to the parameter indication in the instruction, it needs to write the first task segment of the first task into the PRAM of C1; the microprocessor configures DMAC so that DMAC reads the first task segment from the external memory and writes it into the PRAM of C1, and the microprocessor starts a counter for C1 at this time and adds 1 to the counter value; DMAC reads the first task segment from the external memory and sends it to the PRAM of C1 until the first task segment is written; C1 reads the first task segment from the PRAM and executes it, at which time the microprocessor continues to execute its own program, the two are in parallel and do not interfere with each other; when C1 completes the calculation part of the first task, it will execute the last instruction in the first task, that is, the task segment update instruction PUpdate, indicating that this task segment After the task segment has been executed, it is necessary to send a task segment update message Msg1 to the microprocessor to inform the microprocessor that it can update the next task segment; after the microprocessor receives the task segment update message Msg1 sent by C1, it will interrupt the program it is executing, call the task segment allocation instruction PSend, and configure PSend according to the new parameters to configure DMAC, so that DMAC reads the second task segment from the external memory and writes it into the PRAM of C1. At this time, the microprocessor accumulates 1 in the counter corresponding to C1 to record the number of task segments currently assigned to C1; DMAC reads the second task segment from the external memory and sends it to the PRAM of C1 until the second task segment is written; C1 executes the second program segment in its PRAM, and the microprocessor continues to run its own program, and the two are in parallel and do not interfere with each other. This cycle continues until the value of the counter reaches 4 times, indicating that the tasks assigned by C1 have been completed. At this time, the microprocessor can execute a new PSend to assign a new task segment to C1. Exemplarily, in this example, there are two processing cores C1 and C2. The task scheduling process of C2 is the same as that of C1. Tasks are scheduled by the same microprocessor. For the computing tasks of the above two layers of neural networks, when the values ​​of the counters corresponding to C1 and C2 reach 4, it indicates that the computing process of the entire neural network is completed.

[0089] An embodiment of the present disclosure provides an electronic device, comprising: a memory for storing computer-readable instructions; and one or more processors for executing the computer-readable instructions, so that when the processors are executed, any scheduling method described in the embodiment is implemented.

[0090] The embodiment of the present disclosure also provides a non-transitory computer-readable storage medium, characterized in that the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute any of the scheduling methods described in the aforementioned embodiments.

[0091] The embodiment of the present disclosure also provides a computer program product, which is characterized in that it includes computer instructions. When the computer instructions are executed by a computing device, the computing device can execute any of the scheduling methods in the aforementioned embodiments.

[0092] The disclosed embodiments further provide a computing device, characterized in that it comprises any chip described in the embodiments.

[0093] The flowchart and block diagram in the accompanying drawings of the present disclosure illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of the boxes in the block diagram and / or the flowchart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0094] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit does not, in some cases, limit the unit itself.

[0095] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0096] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, 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), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

Claims

1. A task scheduling method, used in a chip, wherein the chip includes a processing core and a microprocessor, characterized in that: The method comprises: In response to executing a task segment allocation instruction, the microprocessor issues an instruction to instruct the storage controller to send a corresponding task segment to the processing core, wherein the task segment is a part of the task; In response to completing the execution of the task segment, the processing core sends a task segment update message to the microprocessor; In response to receiving the task segment update message, the microprocessor executes the task segment allocation instruction to instruct the storage controller to send the next task segment to the processing core. The task segment allocation instruction is an instruction generated by the microprocessor after being configured according to the task segment update message.

2. The task scheduling method according to claim 1, wherein: In response to executing the task segment allocation instruction, the microprocessor issues an instruction to instruct the storage controller to send the corresponding task segment to the processing core, including: The microprocessor executes its own program, and the own program includes the task segment allocation instruction; In response to executing the task segment allocation instruction, the microprocessor instructs the storage controller to read the task segment from the external memory and send the task segment to the processing core.

3. The task scheduling method according to claim 2, wherein: The microprocessor instructs the storage controller to read the task segment from the external memory and send it to the processing core, including: The microprocessor obtains the size of the storage space of the processing core; The microprocessor instructs the storage controller to read out the task segment matching the storage space size of the processing core from the external memory and send the task segment to the processing core.

4. The task scheduling method according to any one of claims 1 to 3, wherein the chip comprises at least two processing cores for executing the task, and the microprocessor executes the allocation of the task segments and the updating of the task segments for at least two of the processing cores.

5. The task scheduling method according to claim 4, characterized in that: In response to executing the task segment allocation instruction, the microprocessor instructs the storage controller to send the task segment to the processing core, including: In response to executing the task segment allocation instruction, the microprocessor determines the processing core indicated by the task segment allocation instruction; The microprocessor instructs a storage controller to send the task segment to the instructed processing core. 6 . The task scheduling method according to claim 4 , wherein the task segment update message comprises different task segment update messages generated by the at least two processing cores executing the task.

7. The task scheduling method according to claim 1, characterized in that: The microprocessor includes a counter, and the processing core corresponds to at least one of the counters, wherein after the microprocessor instructs to allocate the task segment or instructs to allocate the next task segment, the process further includes: The microprocessor starts the counter to record the number of task segments that have been allocated to the processing core that executes the task; In response to the number of the assigned task segments of the processing core reaching a preset threshold, the counter is reset.

8. A chip, characterized in that: include: A processing core, wherein the processing core is used to execute tasks; a microprocessor, the microprocessor being configured to, in response to executing a task segment allocation instruction, instruct a storage controller to send a task segment to the processing core, wherein the task segment is a part of the task; A storage controller, the storage controller is used to fetch a task segment corresponding to the instruction from an external storage space based on the instruction of the microprocessor, and send the task segment to the processing core; The processing core is further used for: in response to completing the execution of the task segment, sending a task segment update message to the microprocessor; The microprocessor is also used to: in response to receiving the task segment update message, execute the task segment allocation instruction to instruct the storage controller to send the next task segment to the processing core, wherein the task segment allocation instruction is an instruction generated after configuration according to the task segment update message.

9. The chip according to claim 8, characterized in that The processing core also includes an internal storage space, and the internal storage space is used to store the task segments.

10. The chip according to any one of claims 8 to 9, wherein: The chip includes a plurality of processing cores; The microprocessor is used to determine the processing core corresponding to the task segment update message based on the received task segment update message, and execute the task segment allocation instruction to instruct the storage controller to send the next task segment corresponding to the processing core to the processing core, wherein the task segment allocation instruction is an instruction generated after configuration according to the task segment update message.

Citation Information

Patent Citations

  • On-chip heterogeneous multi-core system based on star type interconnection structure, and communication method thereof

    CN102135950A

  • Cluster GPU (graphic processing unit) resource scheduling system and method

    CN102541640A

  • Computing device and method for allocating power to the plurality of cores in the computing device

    CN108509014A

  • Multi-core task scheduler, multi-core task scheduling method and device and related products

    CN110750351A

  • Synchronization amongst processor tiles

    US20190121679A1